Skip to content

Instantly share code, notes, and snippets.

@VictorVelarde
Last active November 27, 2019 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VictorVelarde/726e28e5f94998197b0b25852ab37d6d to your computer and use it in GitHub Desktop.
Save VictorVelarde/726e28e5f94998197b0b25852ab37d6d to your computer and use it in GitHub Desktop.
Test scg
This file has been truncated, but you can view the full file.
/*!
*
* CARTO VL js https://carto.com/
* Version: 1.4.2 CUSTOM-FOR-DEBUGGING
*
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["carto"] = factory();
else
root["carto"] = factory();
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./node_modules/cartocolor/cartocolor.js":
/*!***********************************************!*\
!*** ./node_modules/cartocolor/cartocolor.js ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;!function() {
var cartocolor = {
"Burg": {
"2": [
"#ffc6c4",
"#672044"
],
"3": [
"#ffc6c4",
"#cc607d",
"#672044"
],
"4": [
"#ffc6c4",
"#e38191",
"#ad466c",
"#672044"
],
"5": [
"#ffc6c4",
"#ee919b",
"#cc607d",
"#9e3963",
"#672044"
],
"6": [
"#ffc6c4",
"#f29ca3",
"#da7489",
"#b95073",
"#93345d",
"#672044"
],
"7": [
"#ffc6c4",
"#f4a3a8",
"#e38191",
"#cc607d",
"#ad466c",
"#8b3058",
"#672044"
],
"tags": [
"quantitative"
]
},
"BurgYl": {
"2": [
"#fbe6c5",
"#70284a"
],
"3": [
"#fbe6c5",
"#dc7176",
"#70284a"
],
"4": [
"#fbe6c5",
"#ee8a82",
"#c8586c",
"#70284a"
],
"5": [
"#fbe6c5",
"#f2a28a",
"#dc7176",
"#b24b65",
"#70284a"
],
"6": [
"#fbe6c5",
"#f4b191",
"#e7807d",
"#d06270",
"#a44360",
"#70284a"
],
"7": [
"#fbe6c5",
"#f5ba98",
"#ee8a82",
"#dc7176",
"#c8586c",
"#9c3f5d",
"#70284a"
],
"tags": [
"quantitative"
]
},
"RedOr": {
"2": [
"#f6d2a9",
"#b13f64"
],
"3": [
"#f6d2a9",
"#ea8171",
"#b13f64"
],
"4": [
"#f6d2a9",
"#f19c7c",
"#dd686c",
"#b13f64"
],
"5": [
"#f6d2a9",
"#f3aa84",
"#ea8171",
"#d55d6a",
"#b13f64"
],
"6": [
"#f6d2a9",
"#f4b28a",
"#ef9177",
"#e3726d",
"#cf5669",
"#b13f64"
],
"7": [
"#f6d2a9",
"#f5b78e",
"#f19c7c",
"#ea8171",
"#dd686c",
"#ca5268",
"#b13f64"
],
"tags": [
"quantitative"
]
},
"OrYel": {
"2": [
"#ecda9a",
"#ee4d5a"
],
"3": [
"#ecda9a",
"#f7945d",
"#ee4d5a"
],
"4": [
"#ecda9a",
"#f3ad6a",
"#f97b57",
"#ee4d5a"
],
"5": [
"#ecda9a",
"#f1b973",
"#f7945d",
"#f86f56",
"#ee4d5a"
],
"6": [
"#ecda9a",
"#f0c079",
"#f5a363",
"#f98558",
"#f76856",
"#ee4d5a"
],
"7": [
"#ecda9a",
"#efc47e",
"#f3ad6a",
"#f7945d",
"#f97b57",
"#f66356",
"#ee4d5a"
],
"tags": [
"quantitative"
]
},
"Peach": {
"2": [
"#fde0c5",
"#eb4a40"
],
"3": [
"#fde0c5",
"#f59e72",
"#eb4a40"
],
"4": [
"#fde0c5",
"#f8b58b",
"#f2855d",
"#eb4a40"
],
"5": [
"#fde0c5",
"#f9c098",
"#f59e72",
"#f17854",
"#eb4a40"
],
"6": [
"#fde0c5",
"#fac7a1",
"#f7ac80",
"#f38f65",
"#f0704f",
"#eb4a40"
],
"7": [
"#fde0c5",
"#facba6",
"#f8b58b",
"#f59e72",
"#f2855d",
"#ef6a4c",
"#eb4a40"
],
"tags": [
"quantitative"
]
},
"PinkYl": {
"2": [
"#fef6b5",
"#e15383"
],
"3": [
"#fef6b5",
"#ffa679",
"#e15383"
],
"4": [
"#fef6b5",
"#ffc285",
"#fa8a76",
"#e15383"
],
"5": [
"#fef6b5",
"#ffd08e",
"#ffa679",
"#f67b77",
"#e15383"
],
"6": [
"#fef6b5",
"#ffd795",
"#ffb77f",
"#fd9576",
"#f37378",
"#e15383"
],
"7": [
"#fef6b5",
"#ffdd9a",
"#ffc285",
"#ffa679",
"#fa8a76",
"#f16d7a",
"#e15383"
],
"tags": [
"quantitative"
]
},
"Mint": {
"2": [
"#e4f1e1",
"#0d585f"
],
"3": [
"#e4f1e1",
"#63a6a0",
"#0d585f"
],
"4": [
"#e4f1e1",
"#89c0b6",
"#448c8a",
"#0d585f"
],
"5": [
"#E4F1E1",
"#9CCDC1",
"#63A6A0",
"#337F7F",
"#0D585F"
],
"6": [
"#e4f1e1",
"#abd4c7",
"#7ab5ad",
"#509693",
"#2c7778",
"#0d585f"
],
"7": [
"#e4f1e1",
"#b4d9cc",
"#89c0b6",
"#63a6a0",
"#448c8a",
"#287274",
"#0d585f"
],
"tags": [
"quantitative"
]
},
"BluGrn": {
"2": [
"#c4e6c3",
"#1d4f60"
],
"3": [
"#c4e6c3",
"#4da284",
"#1d4f60"
],
"4": [
"#c4e6c3",
"#6dbc90",
"#36877a",
"#1d4f60"
],
"5": [
"#c4e6c3",
"#80c799",
"#4da284",
"#2d7974",
"#1d4f60"
],
"6": [
"#c4e6c3",
"#8dce9f",
"#5fb28b",
"#3e927e",
"#297071",
"#1d4f60"
],
"7": [
"#c4e6c3",
"#96d2a4",
"#6dbc90",
"#4da284",
"#36877a",
"#266b6e",
"#1d4f60"
],
"tags": [
"quantitative"
]
},
"DarkMint": {
"2": [
"#d2fbd4",
"#123f5a"
],
"3": [
"#d2fbd4",
"#559c9e",
"#123f5a"
],
"4": [
"#d2fbd4",
"#7bbcb0",
"#3a7c89",
"#123f5a"
],
"5": [
"#d2fbd4",
"#8eccb9",
"#559c9e",
"#2b6c7f",
"#123f5a"
],
"6": [
"#d2fbd4",
"#9cd5be",
"#6cafa9",
"#458892",
"#266377",
"#123f5a"
],
"7": [
"#d2fbd4",
"#a5dbc2",
"#7bbcb0",
"#559c9e",
"#3a7c89",
"#235d72",
"#123f5a"
],
"tags": [
"quantitative"
]
},
"Emrld": {
"2": [
"#d3f2a3",
"#074050"
],
"3": [
"#d3f2a3",
"#4c9b82",
"#074050"
],
"4": [
"#d3f2a3",
"#6cc08b",
"#217a79",
"#074050"
],
"5": [
"#d3f2a3",
"#82d091",
"#4c9b82",
"#19696f",
"#074050"
],
"6": [
"#d3f2a3",
"#8fda94",
"#60b187",
"#35877d",
"#145f69",
"#074050"
],
"7": [
"#d3f2a3",
"#97e196",
"#6cc08b",
"#4c9b82",
"#217a79",
"#105965",
"#074050"
],
"tags": [
"quantitative"
]
},
"ag_GrnYl": {
"2": [
"#245668",
"#EDEF5D"
],
"3": [
"#245668",
"#39AB7E",
"#EDEF5D"
],
"4": [
"#245668",
"#0D8F81",
"#6EC574",
"#EDEF5D"
],
"5": [
"#245668",
"#04817E",
"#39AB7E",
"#8BD16D",
"#EDEF5D"
],
"6": [
"#245668",
"#09787C",
"#1D9A81",
"#58BB79",
"#9DD869",
"#EDEF5D"
],
"7": [
"#245668",
"#0F7279",
"#0D8F81",
"#39AB7E",
"#6EC574",
"#A9DC67",
"#EDEF5D"
],
"tags": [
"aggregation"
]
},
"BluYl": {
"2": [
"#f7feae",
"#045275"
],
"3": [
"#f7feae",
"#46aea0",
"#045275"
],
"4": [
"#f7feae",
"#7ccba2",
"#089099",
"#045275"
],
"5": [
"#f7feae",
"#9bd8a4",
"#46aea0",
"#058092",
"#045275"
],
"6": [
"#f7feae",
"#ace1a4",
"#68bfa1",
"#2a9c9c",
"#02778e",
"#045275"
],
"7": [
"#f7feae",
"#b7e6a5",
"#7ccba2",
"#46aea0",
"#089099",
"#00718b",
"#045275"
],
"tags": [
"quantitative"
]
},
"Teal": {
"2": [
"#d1eeea",
"#2a5674"
],
"3": [
"#d1eeea",
"#68abb8",
"#2a5674"
],
"4": [
"#d1eeea",
"#85c4c9",
"#4f90a6",
"#2a5674"
],
"5": [
"#d1eeea",
"#96d0d1",
"#68abb8",
"#45829b",
"#2a5674"
],
"6": [
"#d1eeea",
"#a1d7d6",
"#79bbc3",
"#599bae",
"#3f7994",
"#2a5674"
],
"7": [
"#d1eeea",
"#a8dbd9",
"#85c4c9",
"#68abb8",
"#4f90a6",
"#3b738f",
"#2a5674"
],
"tags": [
"quantitative"
]
},
"TealGrn": {
"2": [
"#b0f2bc",
"#257d98"
],
"3": [
"#b0f2bc",
"#4cc8a3",
"#257d98"
],
"4": [
"#b0f2bc",
"#67dba5",
"#38b2a3",
"#257d98"
],
"5": [
"#b0f2bc",
"#77e2a8",
"#4cc8a3",
"#31a6a2",
"#257d98"
],
"6": [
"#b0f2bc",
"#82e6aa",
"#5bd4a4",
"#3fbba3",
"#2e9ea1",
"#257d98"
],
"7": [
"#b0f2bc",
"#89e8ac",
"#67dba5",
"#4cc8a3",
"#38b2a3",
"#2c98a0",
"#257d98"
],
"tags": [
"quantitative"
]
},
"Purp": {
"2": [
"#f3e0f7",
"#63589f"
],
"3": [
"#f3e0f7",
"#b998dd",
"#63589f"
],
"4": [
"#f3e0f7",
"#d1afe8",
"#9f82ce",
"#63589f"
],
"5": [
"#f3e0f7",
"#dbbaed",
"#b998dd",
"#9178c4",
"#63589f"
],
"6": [
"#f3e0f7",
"#e0c2ef",
"#c8a5e4",
"#aa8bd4",
"#8871be",
"#63589f"
],
"7": [
"#f3e0f7",
"#e4c7f1",
"#d1afe8",
"#b998dd",
"#9f82ce",
"#826dba",
"#63589f"
],
"tags": [
"quantitative"
]
},
"PurpOr": {
"3": [
"#f9ddda",
"#ce78b3",
"#573b88"
],
"4": [
"#f9ddda",
"#e597b9",
"#ad5fad",
"#573b88"
],
"5": [
"#f9ddda",
"#eda8bd",
"#ce78b3",
"#9955a8",
"#573b88"
],
"6": [
"#f9ddda",
"#f0b2c1",
"#dd8ab6",
"#bb69b0",
"#8c4fa4",
"#573b88"
],
"7": [
"#f9ddda",
"#f2b9c4",
"#e597b9",
"#ce78b3",
"#ad5fad",
"#834ba0",
"#573b88"
],
"tags": [
"quantitative"
]
},
"Sunset": {
"2": [
"#f3e79b",
"#5c53a5"
],
"3": [
"#f3e79b",
"#eb7f86",
"#5c53a5"
],
"4": [
"#f3e79b",
"#f8a07e",
"#ce6693",
"#5c53a5"
],
"5": [
"#f3e79b",
"#fab27f",
"#eb7f86",
"#b95e9a",
"#5c53a5"
],
"6": [
"#f3e79b",
"#fabc82",
"#f59280",
"#dc6f8e",
"#ab5b9e",
"#5c53a5"
],
"7": [
"#f3e79b",
"#fac484",
"#f8a07e",
"#eb7f86",
"#ce6693",
"#a059a0",
"#5c53a5"
],
"tags": [
"quantitative"
]
},
"Magenta": {
"2": [
"#f3cbd3",
"#6c2167"
],
"3": [
"#f3cbd3",
"#ca699d",
"#6c2167"
],
"4": [
"#f3cbd3",
"#dd88ac",
"#b14d8e",
"#6c2167"
],
"5": [
"#f3cbd3",
"#e498b4",
"#ca699d",
"#a24186",
"#6c2167"
],
"6": [
"#f3cbd3",
"#e7a2b9",
"#d67ba5",
"#bc5894",
"#983a81",
"#6c2167"
],
"7": [
"#f3cbd3",
"#eaa9bd",
"#dd88ac",
"#ca699d",
"#b14d8e",
"#91357d",
"#6c2167"
],
"tags": [
"quantitative"
]
},
"SunsetDark": {
"2": [
"#fcde9c",
"#7c1d6f"
],
"3": [
"#fcde9c",
"#e34f6f",
"#7c1d6f"
],
"4": [
"#fcde9c",
"#f0746e",
"#dc3977",
"#7c1d6f"
],
"5": [
"#fcde9c",
"#f58670",
"#e34f6f",
"#d72d7c",
"#7c1d6f"
],
"6": [
"#fcde9c",
"#f89872",
"#ec666d",
"#df4273",
"#c5287b",
"#7c1d6f"
],
"7": [
"#fcde9c",
"#faa476",
"#f0746e",
"#e34f6f",
"#dc3977",
"#b9257a",
"#7c1d6f"
],
"tags": [
"quantitative"
]
},
"ag_Sunset": {
"2": [
"#4b2991",
"#edd9a3"
],
"3": [
"#4b2991",
"#ea4f88",
"#edd9a3"
],
"4": [
"#4b2991",
"#c0369d",
"#fa7876",
"#edd9a3"
],
"5": [
"#4b2991",
"#a52fa2",
"#ea4f88",
"#fa9074",
"#edd9a3"
],
"6": [
"#4b2991",
"#932da3",
"#d43f96",
"#f7667c",
"#f89f77",
"#edd9a3"
],
"7": [
"#4b2991",
"#872ca2",
"#c0369d",
"#ea4f88",
"#fa7876",
"#f6a97a",
"#edd9a3"
],
"tags": [
"aggregation"
]
},
"BrwnYl": {
"2": [
"#ede5cf",
"#541f3f"
],
"3": [
"#ede5cf",
"#c1766f",
"#541f3f"
],
"4": [
"#ede5cf",
"#d39c83",
"#a65461",
"#541f3f"
],
"5": [
"#ede5cf",
"#daaf91",
"#c1766f",
"#95455a",
"#541f3f"
],
"6": [
"#ede5cf",
"#ddba9b",
"#cd8c7a",
"#b26166",
"#8a3c56",
"#541f3f"
],
"7": [
"#ede5cf",
"#e0c2a2",
"#d39c83",
"#c1766f",
"#a65461",
"#813753",
"#541f3f"
],
"tags": [
"quantitative"
]
},
"ArmyRose": {
"2": [
"#929b4f",
"#db8195"
],
"3": [
"#a3ad62",
"#fdfbe4",
"#df91a3"
],
"4": [
"#929b4f",
"#d9dbaf",
"#f3d1ca",
"#db8195"
],
"5": [
"#879043",
"#c1c68c",
"#fdfbe4",
"#ebb4b8",
"#d8758b"
],
"6": [
"#7f883b",
"#b0b874",
"#e3e4be",
"#f6ddd1",
"#e4a0ac",
"#d66d85"
],
"7": [
"#798234",
"#a3ad62",
"#d0d3a2",
"#fdfbe4",
"#f0c6c3",
"#df91a3",
"#d46780"
],
"tags": [
"diverging"
]
},
"Fall": {
"2": [
"#3d5941",
"#ca562c"
],
"3": [
"#3d5941",
"#f6edbd",
"#ca562c"
],
"4": [
"#3d5941",
"#b5b991",
"#edbb8a",
"#ca562c"
],
"5": [
"#3d5941",
"#96a07c",
"#f6edbd",
"#e6a272",
"#ca562c"
],
"6": [
"#3d5941",
"#839170",
"#cecea2",
"#f1cf9e",
"#e19464",
"#ca562c"
],
"7": [
"#3d5941",
"#778868",
"#b5b991",
"#f6edbd",
"#edbb8a",
"#de8a5a",
"#ca562c"
],
"tags": [
"diverging"
]
},
"Geyser": {
"2": [
"#008080",
"#ca562c"
],
"3": [
"#008080",
"#f6edbd",
"#ca562c"
],
"4": [
"#008080",
"#b4c8a8",
"#edbb8a",
"#ca562c"
],
"5": [
"#008080",
"#92b69e",
"#f6edbd",
"#e6a272",
"#ca562c"
],
"6": [
"#008080",
"#7eab98",
"#ced7b1",
"#f1cf9e",
"#e19464",
"#ca562c"
],
"7": [
"#008080",
"#70a494",
"#b4c8a8",
"#f6edbd",
"#edbb8a",
"#de8a5a",
"#ca562c"
],
"tags": [
"diverging"
]
},
"Temps": {
"2": [
"#009392",
"#cf597e"
],
"3": [
"#009392",
"#e9e29c",
"#cf597e"
],
"4": [
"#009392",
"#9ccb86",
"#eeb479",
"#cf597e"
],
"5": [
"#009392",
"#71be83",
"#e9e29c",
"#ed9c72",
"#cf597e"
],
"6": [
"#009392",
"#52b684",
"#bcd48c",
"#edc783",
"#eb8d71",
"#cf597e"
],
"7": [
"#009392",
"#39b185",
"#9ccb86",
"#e9e29c",
"#eeb479",
"#e88471",
"#cf597e"
],
"tags": [
"diverging"
]
},
"TealRose": {
"2": [
"#009392",
"#d0587e"
],
"3": [
"#009392",
"#f1eac8",
"#d0587e"
],
"4": [
"#009392",
"#91b8aa",
"#f1eac8",
"#dfa0a0",
"#d0587e"
],
"5": [
"#009392",
"#91b8aa",
"#f1eac8",
"#dfa0a0",
"#d0587e"
],
"6": [
"#009392",
"#72aaa1",
"#b1c7b3",
"#e5b9ad",
"#d98994",
"#d0587e"
],
"7": [
"#009392",
"#72aaa1",
"#b1c7b3",
"#f1eac8",
"#e5b9ad",
"#d98994",
"#d0587e"
],
"tags": [
"diverging"
]
},
"Tropic": {
"2": [
"#009B9E",
"#C75DAB"
],
"3": [
"#009B9E",
"#F1F1F1",
"#C75DAB"
],
"4": [
"#009B9E",
"#A7D3D4",
"#E4C1D9",
"#C75DAB"
],
"5": [
"#009B9E",
"#7CC5C6",
"#F1F1F1",
"#DDA9CD",
"#C75DAB"
],
"6": [
"#009B9E",
"#5DBCBE",
"#C6DFDF",
"#E9D4E2",
"#D99BC6",
"#C75DAB"
],
"7": [
"#009B9E",
"#42B7B9",
"#A7D3D4",
"#F1F1F1",
"#E4C1D9",
"#D691C1",
"#C75DAB"
],
"tags": [
"diverging"
]
},
"Earth": {
"2": [
"#A16928",
"#2887a1"
],
"3": [
"#A16928",
"#edeac2",
"#2887a1"
],
"4": [
"#A16928",
"#d6bd8d",
"#b5c8b8",
"#2887a1"
],
"5": [
"#A16928",
"#caa873",
"#edeac2",
"#98b7b2",
"#2887a1"
],
"6": [
"#A16928",
"#c29b64",
"#e0cfa2",
"#cbd5bc",
"#85adaf",
"#2887a1"
],
"7": [
"#A16928",
"#bd925a",
"#d6bd8d",
"#edeac2",
"#b5c8b8",
"#79a7ac",
"#2887a1"
],
"tags": [
"diverging"
]
},
"Antique": {
"2": [
"#855C75",
"#D9AF6B",
"#7C7C7C"
],
"3": [
"#855C75",
"#D9AF6B",
"#AF6458",
"#7C7C7C"
],
"4": [
"#855C75",
"#D9AF6B",
"#AF6458",
"#736F4C",
"#7C7C7C"
],
"5": [
"#855C75",
"#D9AF6B",
"#AF6458",
"#736F4C",
"#526A83",
"#7C7C7C"
],
"6": [
"#855C75",
"#D9AF6B",
"#AF6458",
"#736F4C",
"#526A83",
"#625377",
"#7C7C7C"
],
"7": [
"#855C75",
"#D9AF6B",
"#AF6458",
"#736F4C",
"#526A83",
"#625377",
"#68855C",
"#7C7C7C"
],
"8": [
"#855C75",
"#D9AF6B",
"#AF6458",
"#736F4C",
"#526A83",
"#625377",
"#68855C",
"#9C9C5E",
"#7C7C7C"
],
"9": [
"#855C75",
"#D9AF6B",
"#AF6458",
"#736F4C",
"#526A83",
"#625377",
"#68855C",
"#9C9C5E",
"#A06177",
"#7C7C7C"
],
"10": [
"#855C75",
"#D9AF6B",
"#AF6458",
"#736F4C",
"#526A83",
"#625377",
"#68855C",
"#9C9C5E",
"#A06177",
"#8C785D",
"#7C7C7C"
],
"11": [
"#855C75",
"#D9AF6B",
"#AF6458",
"#736F4C",
"#526A83",
"#625377",
"#68855C",
"#9C9C5E",
"#A06177",
"#8C785D",
"#467378",
"#7C7C7C"
],
"tags": [
"qualitative"
]
},
"Bold": {
"2": [
"#7F3C8D",
"#11A579",
"#A5AA99"
],
"3": [
"#7F3C8D",
"#11A579",
"#3969AC",
"#A5AA99"
],
"4": [
"#7F3C8D",
"#11A579",
"#3969AC",
"#F2B701",
"#A5AA99"
],
"5": [
"#7F3C8D",
"#11A579",
"#3969AC",
"#F2B701",
"#E73F74",
"#A5AA99"
],
"6": [
"#7F3C8D",
"#11A579",
"#3969AC",
"#F2B701",
"#E73F74",
"#80BA5A",
"#A5AA99"
],
"7": [
"#7F3C8D",
"#11A579",
"#3969AC",
"#F2B701",
"#E73F74",
"#80BA5A",
"#E68310",
"#A5AA99"
],
"8": [
"#7F3C8D",
"#11A579",
"#3969AC",
"#F2B701",
"#E73F74",
"#80BA5A",
"#E68310",
"#008695",
"#A5AA99"
],
"9": [
"#7F3C8D",
"#11A579",
"#3969AC",
"#F2B701",
"#E73F74",
"#80BA5A",
"#E68310",
"#008695",
"#CF1C90",
"#A5AA99"
],
"10": [
"#7F3C8D",
"#11A579",
"#3969AC",
"#F2B701",
"#E73F74",
"#80BA5A",
"#E68310",
"#008695",
"#CF1C90",
"#f97b72",
"#A5AA99"
],
"11": [
"#7F3C8D",
"#11A579",
"#3969AC",
"#F2B701",
"#E73F74",
"#80BA5A",
"#E68310",
"#008695",
"#CF1C90",
"#f97b72",
"#4b4b8f",
"#A5AA99"
],
"tags": [
"qualitative"
]
},
"Pastel": {
"2": [
"#66C5CC",
"#F6CF71",
"#B3B3B3"
],
"3": [
"#66C5CC",
"#F6CF71",
"#F89C74",
"#B3B3B3"
],
"4": [
"#66C5CC",
"#F6CF71",
"#F89C74",
"#DCB0F2",
"#B3B3B3"
],
"5": [
"#66C5CC",
"#F6CF71",
"#F89C74",
"#DCB0F2",
"#87C55F",
"#B3B3B3"
],
"6": [
"#66C5CC",
"#F6CF71",
"#F89C74",
"#DCB0F2",
"#87C55F",
"#9EB9F3",
"#B3B3B3"
],
"7": [
"#66C5CC",
"#F6CF71",
"#F89C74",
"#DCB0F2",
"#87C55F",
"#9EB9F3",
"#FE88B1",
"#B3B3B3"
],
"8": [
"#66C5CC",
"#F6CF71",
"#F89C74",
"#DCB0F2",
"#87C55F",
"#9EB9F3",
"#FE88B1",
"#C9DB74",
"#B3B3B3"
],
"9": [
"#66C5CC",
"#F6CF71",
"#F89C74",
"#DCB0F2",
"#87C55F",
"#9EB9F3",
"#FE88B1",
"#C9DB74",
"#8BE0A4",
"#B3B3B3"
],
"10": [
"#66C5CC",
"#F6CF71",
"#F89C74",
"#DCB0F2",
"#87C55F",
"#9EB9F3",
"#FE88B1",
"#C9DB74",
"#8BE0A4",
"#B497E7",
"#B3B3B3"
],
"11": [
"#66C5CC",
"#F6CF71",
"#F89C74",
"#DCB0F2",
"#87C55F",
"#9EB9F3",
"#FE88B1",
"#C9DB74",
"#8BE0A4",
"#B497E7",
"#D3B484",
"#B3B3B3"
],
"tags": [
"qualitative"
]
},
"Prism": {
"2": [
"#5F4690",
"#1D6996",
"#666666"
],
"3": [
"#5F4690",
"#1D6996",
"#38A6A5",
"#666666"
],
"4": [
"#5F4690",
"#1D6996",
"#38A6A5",
"#0F8554",
"#666666"
],
"5": [
"#5F4690",
"#1D6996",
"#38A6A5",
"#0F8554",
"#73AF48",
"#666666"
],
"6": [
"#5F4690",
"#1D6996",
"#38A6A5",
"#0F8554",
"#73AF48",
"#EDAD08",
"#666666"
],
"7": [
"#5F4690",
"#1D6996",
"#38A6A5",
"#0F8554",
"#73AF48",
"#EDAD08",
"#E17C05",
"#666666"
],
"8": [
"#5F4690",
"#1D6996",
"#38A6A5",
"#0F8554",
"#73AF48",
"#EDAD08",
"#E17C05",
"#CC503E",
"#666666"
],
"9": [
"#5F4690",
"#1D6996",
"#38A6A5",
"#0F8554",
"#73AF48",
"#EDAD08",
"#E17C05",
"#CC503E",
"#94346E",
"#666666"
],
"10": [
"#5F4690",
"#1D6996",
"#38A6A5",
"#0F8554",
"#73AF48",
"#EDAD08",
"#E17C05",
"#CC503E",
"#94346E",
"#6F4070",
"#666666"
],
"11": [
"#5F4690",
"#1D6996",
"#38A6A5",
"#0F8554",
"#73AF48",
"#EDAD08",
"#E17C05",
"#CC503E",
"#94346E",
"#6F4070",
"#994E95",
"#666666"
],
"tags": [
"qualitative"
]
},
"Safe": {
"2": [
"#88CCEE",
"#CC6677",
"#888888"
],
"3": [
"#88CCEE",
"#CC6677",
"#DDCC77",
"#888888"
],
"4": [
"#88CCEE",
"#CC6677",
"#DDCC77",
"#117733",
"#888888"
],
"5": [
"#88CCEE",
"#CC6677",
"#DDCC77",
"#117733",
"#332288",
"#888888"
],
"6": [
"#88CCEE",
"#CC6677",
"#DDCC77",
"#117733",
"#332288",
"#AA4499",
"#888888"
],
"7": [
"#88CCEE",
"#CC6677",
"#DDCC77",
"#117733",
"#332288",
"#AA4499",
"#44AA99",
"#888888"
],
"8": [
"#88CCEE",
"#CC6677",
"#DDCC77",
"#117733",
"#332288",
"#AA4499",
"#44AA99",
"#999933",
"#888888"
],
"9": [
"#88CCEE",
"#CC6677",
"#DDCC77",
"#117733",
"#332288",
"#AA4499",
"#44AA99",
"#999933",
"#882255",
"#888888"
],
"10": [
"#88CCEE",
"#CC6677",
"#DDCC77",
"#117733",
"#332288",
"#AA4499",
"#44AA99",
"#999933",
"#882255",
"#661100",
"#888888"
],
"11": [
"#88CCEE",
"#CC6677",
"#DDCC77",
"#117733",
"#332288",
"#AA4499",
"#44AA99",
"#999933",
"#882255",
"#661100",
"#6699CC",
"#888888"
],
"tags": [
"qualitative",
"colorblind"
]
},
"Vivid": {
"2": [
"#E58606",
"#5D69B1",
"#A5AA99"
],
"3": [
"#E58606",
"#5D69B1",
"#52BCA3",
"#A5AA99"
],
"4": [
"#E58606",
"#5D69B1",
"#52BCA3",
"#99C945",
"#A5AA99"
],
"5": [
"#E58606",
"#5D69B1",
"#52BCA3",
"#99C945",
"#CC61B0",
"#A5AA99"
],
"6": [
"#E58606",
"#5D69B1",
"#52BCA3",
"#99C945",
"#CC61B0",
"#24796C",
"#A5AA99"
],
"7": [
"#E58606",
"#5D69B1",
"#52BCA3",
"#99C945",
"#CC61B0",
"#24796C",
"#DAA51B",
"#A5AA99"
],
"8": [
"#E58606",
"#5D69B1",
"#52BCA3",
"#99C945",
"#CC61B0",
"#24796C",
"#DAA51B",
"#2F8AC4",
"#A5AA99"
],
"9": [
"#E58606",
"#5D69B1",
"#52BCA3",
"#99C945",
"#CC61B0",
"#24796C",
"#DAA51B",
"#2F8AC4",
"#764E9F",
"#A5AA99"
],
"10": [
"#E58606",
"#5D69B1",
"#52BCA3",
"#99C945",
"#CC61B0",
"#24796C",
"#DAA51B",
"#2F8AC4",
"#764E9F",
"#ED645A",
"#A5AA99"
],
"11": [
"#E58606",
"#5D69B1",
"#52BCA3",
"#99C945",
"#CC61B0",
"#24796C",
"#DAA51B",
"#2F8AC4",
"#764E9F",
"#ED645A",
"#CC3A8E",
"#A5AA99"
],
"tags": [
"qualitative"
]
}
};
var colorbrewer_tags = {
"Blues": { "tags": ["quantitative"] },
"BrBG": { "tags": ["diverging"] },
"Greys": { "tags": ["quantitative"] },
"PiYG": { "tags": ["diverging"] },
"PRGn": { "tags": ["diverging"] },
"Purples": { "tags": ["quantitative"] },
"RdYlGn": { "tags": ["diverging"] },
"Spectral": { "tags": ["diverging"] },
"YlOrBr": { "tags": ["quantitative"] },
"YlGn": { "tags": ["quantitative"] },
"YlGnBu": { "tags": ["quantitative"] },
"YlOrRd": { "tags": ["quantitative"] }
}
var colorbrewer = __webpack_require__(/*! colorbrewer */ "./node_modules/colorbrewer/index.js");
// augment colorbrewer with tags
for (var r in colorbrewer) {
var ramps = colorbrewer[r];
var augmentedRamps = {};
for (var i in ramps) {
augmentedRamps[i] = ramps[i];
}
if (r in colorbrewer_tags) {
augmentedRamps.tags = colorbrewer_tags[r].tags;
}
cartocolor['cb_' + r] = augmentedRamps;
}
if (true) {
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (cartocolor),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
__WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}();
/***/ }),
/***/ "./node_modules/cartocolor/index.js":
/*!******************************************!*\
!*** ./node_modules/cartocolor/index.js ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(/*! ./cartocolor */ "./node_modules/cartocolor/cartocolor.js");
/***/ }),
/***/ "./node_modules/colorbrewer/colorbrewer.js":
/*!*************************************************!*\
!*** ./node_modules/colorbrewer/colorbrewer.js ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;// This product includes color specifications and designs developed by Cynthia Brewer (http://colorbrewer.org/).
// JavaScript specs as packaged in the D3 library (d3js.org). Please see license at http://colorbrewer.org/export/LICENSE.txt
!function() {
var colorbrewer = {YlGn: {
3: ["#f7fcb9","#addd8e","#31a354"],
4: ["#ffffcc","#c2e699","#78c679","#238443"],
5: ["#ffffcc","#c2e699","#78c679","#31a354","#006837"],
6: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#31a354","#006837"],
7: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
8: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
9: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"]
},YlGnBu: {
3: ["#edf8b1","#7fcdbb","#2c7fb8"],
4: ["#ffffcc","#a1dab4","#41b6c4","#225ea8"],
5: ["#ffffcc","#a1dab4","#41b6c4","#2c7fb8","#253494"],
6: ["#ffffcc","#c7e9b4","#7fcdbb","#41b6c4","#2c7fb8","#253494"],
7: ["#ffffcc","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#0c2c84"],
8: ["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#0c2c84"],
9: ["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"]
},GnBu: {
3: ["#e0f3db","#a8ddb5","#43a2ca"],
4: ["#f0f9e8","#bae4bc","#7bccc4","#2b8cbe"],
5: ["#f0f9e8","#bae4bc","#7bccc4","#43a2ca","#0868ac"],
6: ["#f0f9e8","#ccebc5","#a8ddb5","#7bccc4","#43a2ca","#0868ac"],
7: ["#f0f9e8","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#08589e"],
8: ["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#08589e"],
9: ["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"]
},BuGn: {
3: ["#e5f5f9","#99d8c9","#2ca25f"],
4: ["#edf8fb","#b2e2e2","#66c2a4","#238b45"],
5: ["#edf8fb","#b2e2e2","#66c2a4","#2ca25f","#006d2c"],
6: ["#edf8fb","#ccece6","#99d8c9","#66c2a4","#2ca25f","#006d2c"],
7: ["#edf8fb","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#005824"],
8: ["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#005824"],
9: ["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"]
},PuBuGn: {
3: ["#ece2f0","#a6bddb","#1c9099"],
4: ["#f6eff7","#bdc9e1","#67a9cf","#02818a"],
5: ["#f6eff7","#bdc9e1","#67a9cf","#1c9099","#016c59"],
6: ["#f6eff7","#d0d1e6","#a6bddb","#67a9cf","#1c9099","#016c59"],
7: ["#f6eff7","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016450"],
8: ["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016450"],
9: ["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"]
},PuBu: {
3: ["#ece7f2","#a6bddb","#2b8cbe"],
4: ["#f1eef6","#bdc9e1","#74a9cf","#0570b0"],
5: ["#f1eef6","#bdc9e1","#74a9cf","#2b8cbe","#045a8d"],
6: ["#f1eef6","#d0d1e6","#a6bddb","#74a9cf","#2b8cbe","#045a8d"],
7: ["#f1eef6","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#034e7b"],
8: ["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#034e7b"],
9: ["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"]
},BuPu: {
3: ["#e0ecf4","#9ebcda","#8856a7"],
4: ["#edf8fb","#b3cde3","#8c96c6","#88419d"],
5: ["#edf8fb","#b3cde3","#8c96c6","#8856a7","#810f7c"],
6: ["#edf8fb","#bfd3e6","#9ebcda","#8c96c6","#8856a7","#810f7c"],
7: ["#edf8fb","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#6e016b"],
8: ["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#6e016b"],
9: ["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"]
},RdPu: {
3: ["#fde0dd","#fa9fb5","#c51b8a"],
4: ["#feebe2","#fbb4b9","#f768a1","#ae017e"],
5: ["#feebe2","#fbb4b9","#f768a1","#c51b8a","#7a0177"],
6: ["#feebe2","#fcc5c0","#fa9fb5","#f768a1","#c51b8a","#7a0177"],
7: ["#feebe2","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177"],
8: ["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177"],
9: ["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"]
},PuRd: {
3: ["#e7e1ef","#c994c7","#dd1c77"],
4: ["#f1eef6","#d7b5d8","#df65b0","#ce1256"],
5: ["#f1eef6","#d7b5d8","#df65b0","#dd1c77","#980043"],
6: ["#f1eef6","#d4b9da","#c994c7","#df65b0","#dd1c77","#980043"],
7: ["#f1eef6","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#91003f"],
8: ["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#91003f"],
9: ["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"]
},OrRd: {
3: ["#fee8c8","#fdbb84","#e34a33"],
4: ["#fef0d9","#fdcc8a","#fc8d59","#d7301f"],
5: ["#fef0d9","#fdcc8a","#fc8d59","#e34a33","#b30000"],
6: ["#fef0d9","#fdd49e","#fdbb84","#fc8d59","#e34a33","#b30000"],
7: ["#fef0d9","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#990000"],
8: ["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#990000"],
9: ["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"]
},YlOrRd: {
3: ["#ffeda0","#feb24c","#f03b20"],
4: ["#ffffb2","#fecc5c","#fd8d3c","#e31a1c"],
5: ["#ffffb2","#fecc5c","#fd8d3c","#f03b20","#bd0026"],
6: ["#ffffb2","#fed976","#feb24c","#fd8d3c","#f03b20","#bd0026"],
7: ["#ffffb2","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026"],
8: ["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026"],
9: ["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"]
},YlOrBr: {
3: ["#fff7bc","#fec44f","#d95f0e"],
4: ["#ffffd4","#fed98e","#fe9929","#cc4c02"],
5: ["#ffffd4","#fed98e","#fe9929","#d95f0e","#993404"],
6: ["#ffffd4","#fee391","#fec44f","#fe9929","#d95f0e","#993404"],
7: ["#ffffd4","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#8c2d04"],
8: ["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#8c2d04"],
9: ["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"]
},Purples: {
3: ["#efedf5","#bcbddc","#756bb1"],
4: ["#f2f0f7","#cbc9e2","#9e9ac8","#6a51a3"],
5: ["#f2f0f7","#cbc9e2","#9e9ac8","#756bb1","#54278f"],
6: ["#f2f0f7","#dadaeb","#bcbddc","#9e9ac8","#756bb1","#54278f"],
7: ["#f2f0f7","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#4a1486"],
8: ["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#4a1486"],
9: ["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]
},Blues: {
3: ["#deebf7","#9ecae1","#3182bd"],
4: ["#eff3ff","#bdd7e7","#6baed6","#2171b5"],
5: ["#eff3ff","#bdd7e7","#6baed6","#3182bd","#08519c"],
6: ["#eff3ff","#c6dbef","#9ecae1","#6baed6","#3182bd","#08519c"],
7: ["#eff3ff","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#084594"],
8: ["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#084594"],
9: ["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]
},Greens: {
3: ["#e5f5e0","#a1d99b","#31a354"],
4: ["#edf8e9","#bae4b3","#74c476","#238b45"],
5: ["#edf8e9","#bae4b3","#74c476","#31a354","#006d2c"],
6: ["#edf8e9","#c7e9c0","#a1d99b","#74c476","#31a354","#006d2c"],
7: ["#edf8e9","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#005a32"],
8: ["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#005a32"],
9: ["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]
},Oranges: {
3: ["#fee6ce","#fdae6b","#e6550d"],
4: ["#feedde","#fdbe85","#fd8d3c","#d94701"],
5: ["#feedde","#fdbe85","#fd8d3c","#e6550d","#a63603"],
6: ["#feedde","#fdd0a2","#fdae6b","#fd8d3c","#e6550d","#a63603"],
7: ["#feedde","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#8c2d04"],
8: ["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#8c2d04"],
9: ["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]
},Reds: {
3: ["#fee0d2","#fc9272","#de2d26"],
4: ["#fee5d9","#fcae91","#fb6a4a","#cb181d"],
5: ["#fee5d9","#fcae91","#fb6a4a","#de2d26","#a50f15"],
6: ["#fee5d9","#fcbba1","#fc9272","#fb6a4a","#de2d26","#a50f15"],
7: ["#fee5d9","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#99000d"],
8: ["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#99000d"],
9: ["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]
},Greys: {
3: ["#f0f0f0","#bdbdbd","#636363"],
4: ["#f7f7f7","#cccccc","#969696","#525252"],
5: ["#f7f7f7","#cccccc","#969696","#636363","#252525"],
6: ["#f7f7f7","#d9d9d9","#bdbdbd","#969696","#636363","#252525"],
7: ["#f7f7f7","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525"],
8: ["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525"],
9: ["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]
},PuOr: {
3: ["#f1a340","#f7f7f7","#998ec3"],
4: ["#e66101","#fdb863","#b2abd2","#5e3c99"],
5: ["#e66101","#fdb863","#f7f7f7","#b2abd2","#5e3c99"],
6: ["#b35806","#f1a340","#fee0b6","#d8daeb","#998ec3","#542788"],
7: ["#b35806","#f1a340","#fee0b6","#f7f7f7","#d8daeb","#998ec3","#542788"],
8: ["#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788"],
9: ["#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788"],
10: ["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],
11: ["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"]
},BrBG: {
3: ["#d8b365","#f5f5f5","#5ab4ac"],
4: ["#a6611a","#dfc27d","#80cdc1","#018571"],
5: ["#a6611a","#dfc27d","#f5f5f5","#80cdc1","#018571"],
6: ["#8c510a","#d8b365","#f6e8c3","#c7eae5","#5ab4ac","#01665e"],
7: ["#8c510a","#d8b365","#f6e8c3","#f5f5f5","#c7eae5","#5ab4ac","#01665e"],
8: ["#8c510a","#bf812d","#dfc27d","#f6e8c3","#c7eae5","#80cdc1","#35978f","#01665e"],
9: ["#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e"],
10: ["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],
11: ["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]
},PRGn: {
3: ["#af8dc3","#f7f7f7","#7fbf7b"],
4: ["#7b3294","#c2a5cf","#a6dba0","#008837"],
5: ["#7b3294","#c2a5cf","#f7f7f7","#a6dba0","#008837"],
6: ["#762a83","#af8dc3","#e7d4e8","#d9f0d3","#7fbf7b","#1b7837"],
7: ["#762a83","#af8dc3","#e7d4e8","#f7f7f7","#d9f0d3","#7fbf7b","#1b7837"],
8: ["#762a83","#9970ab","#c2a5cf","#e7d4e8","#d9f0d3","#a6dba0","#5aae61","#1b7837"],
9: ["#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837"],
10: ["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],
11: ["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]
},PiYG: {
3: ["#e9a3c9","#f7f7f7","#a1d76a"],
4: ["#d01c8b","#f1b6da","#b8e186","#4dac26"],
5: ["#d01c8b","#f1b6da","#f7f7f7","#b8e186","#4dac26"],
6: ["#c51b7d","#e9a3c9","#fde0ef","#e6f5d0","#a1d76a","#4d9221"],
7: ["#c51b7d","#e9a3c9","#fde0ef","#f7f7f7","#e6f5d0","#a1d76a","#4d9221"],
8: ["#c51b7d","#de77ae","#f1b6da","#fde0ef","#e6f5d0","#b8e186","#7fbc41","#4d9221"],
9: ["#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221"],
10: ["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],
11: ["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]
},RdBu: {
3: ["#ef8a62","#f7f7f7","#67a9cf"],
4: ["#ca0020","#f4a582","#92c5de","#0571b0"],
5: ["#ca0020","#f4a582","#f7f7f7","#92c5de","#0571b0"],
6: ["#b2182b","#ef8a62","#fddbc7","#d1e5f0","#67a9cf","#2166ac"],
7: ["#b2182b","#ef8a62","#fddbc7","#f7f7f7","#d1e5f0","#67a9cf","#2166ac"],
8: ["#b2182b","#d6604d","#f4a582","#fddbc7","#d1e5f0","#92c5de","#4393c3","#2166ac"],
9: ["#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac"],
10: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],
11: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]
},RdGy: {
3: ["#ef8a62","#ffffff","#999999"],
4: ["#ca0020","#f4a582","#bababa","#404040"],
5: ["#ca0020","#f4a582","#ffffff","#bababa","#404040"],
6: ["#b2182b","#ef8a62","#fddbc7","#e0e0e0","#999999","#4d4d4d"],
7: ["#b2182b","#ef8a62","#fddbc7","#ffffff","#e0e0e0","#999999","#4d4d4d"],
8: ["#b2182b","#d6604d","#f4a582","#fddbc7","#e0e0e0","#bababa","#878787","#4d4d4d"],
9: ["#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d"],
10: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],
11: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"]
},RdYlBu: {
3: ["#fc8d59","#ffffbf","#91bfdb"],
4: ["#d7191c","#fdae61","#abd9e9","#2c7bb6"],
5: ["#d7191c","#fdae61","#ffffbf","#abd9e9","#2c7bb6"],
6: ["#d73027","#fc8d59","#fee090","#e0f3f8","#91bfdb","#4575b4"],
7: ["#d73027","#fc8d59","#fee090","#ffffbf","#e0f3f8","#91bfdb","#4575b4"],
8: ["#d73027","#f46d43","#fdae61","#fee090","#e0f3f8","#abd9e9","#74add1","#4575b4"],
9: ["#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4"],
10: ["#a50026","#d73027","#f46d43","#fdae61","#fee090","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],
11: ["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]
},Spectral: {
3: ["#fc8d59","#ffffbf","#99d594"],
4: ["#d7191c","#fdae61","#abdda4","#2b83ba"],
5: ["#d7191c","#fdae61","#ffffbf","#abdda4","#2b83ba"],
6: ["#d53e4f","#fc8d59","#fee08b","#e6f598","#99d594","#3288bd"],
7: ["#d53e4f","#fc8d59","#fee08b","#ffffbf","#e6f598","#99d594","#3288bd"],
8: ["#d53e4f","#f46d43","#fdae61","#fee08b","#e6f598","#abdda4","#66c2a5","#3288bd"],
9: ["#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd"],
10: ["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],
11: ["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]
},RdYlGn: {
3: ["#fc8d59","#ffffbf","#91cf60"],
4: ["#d7191c","#fdae61","#a6d96a","#1a9641"],
5: ["#d7191c","#fdae61","#ffffbf","#a6d96a","#1a9641"],
6: ["#d73027","#fc8d59","#fee08b","#d9ef8b","#91cf60","#1a9850"],
7: ["#d73027","#fc8d59","#fee08b","#ffffbf","#d9ef8b","#91cf60","#1a9850"],
8: ["#d73027","#f46d43","#fdae61","#fee08b","#d9ef8b","#a6d96a","#66bd63","#1a9850"],
9: ["#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850"],
10: ["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],
11: ["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]
},Accent: {
3: ["#7fc97f","#beaed4","#fdc086"],
4: ["#7fc97f","#beaed4","#fdc086","#ffff99"],
5: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0"],
6: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f"],
7: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17"],
8: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"]
},Dark2: {
3: ["#1b9e77","#d95f02","#7570b3"],
4: ["#1b9e77","#d95f02","#7570b3","#e7298a"],
5: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e"],
6: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02"],
7: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d"],
8: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"]
},Paired: {
3: ["#a6cee3","#1f78b4","#b2df8a"],
4: ["#a6cee3","#1f78b4","#b2df8a","#33a02c"],
5: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99"],
6: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c"],
7: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f"],
8: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00"],
9: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6"],
10: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a"],
11: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99"],
12: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"]
},Pastel1: {
3: ["#fbb4ae","#b3cde3","#ccebc5"],
4: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4"],
5: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6"],
6: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc"],
7: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd"],
8: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec"],
9: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]
},Pastel2: {
3: ["#b3e2cd","#fdcdac","#cbd5e8"],
4: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4"],
5: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9"],
6: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae"],
7: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc"],
8: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"]
},Set1: {
3: ["#e41a1c","#377eb8","#4daf4a"],
4: ["#e41a1c","#377eb8","#4daf4a","#984ea3"],
5: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00"],
6: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33"],
7: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628"],
8: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf"],
9: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"]
},Set2: {
3: ["#66c2a5","#fc8d62","#8da0cb"],
4: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3"],
5: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854"],
6: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f"],
7: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494"],
8: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"]
},Set3: {
3: ["#8dd3c7","#ffffb3","#bebada"],
4: ["#8dd3c7","#ffffb3","#bebada","#fb8072"],
5: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3"],
6: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462"],
7: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69"],
8: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5"],
9: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9"],
10: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd"],
11: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5"],
12: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"]
}};
if (true) {
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (colorbrewer),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
__WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}();
/***/ }),
/***/ "./node_modules/colorbrewer/index.js":
/*!*******************************************!*\
!*** ./node_modules/colorbrewer/index.js ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(/*! ./colorbrewer.js */ "./node_modules/colorbrewer/colorbrewer.js");
/***/ }),
/***/ "./node_modules/earcut/src/earcut.js":
/*!*******************************************!*\
!*** ./node_modules/earcut/src/earcut.js ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = earcut;
module.exports.default = earcut;
function earcut(data, holeIndices, dim) {
dim = dim || 2;
var hasHoles = holeIndices && holeIndices.length,
outerLen = hasHoles ? holeIndices[0] * dim : data.length,
outerNode = linkedList(data, 0, outerLen, dim, true),
triangles = [];
if (!outerNode) return triangles;
var minX, minY, maxX, maxY, x, y, invSize;
if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
// if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
if (data.length > 80 * dim) {
minX = maxX = data[0];
minY = maxY = data[1];
for (var i = dim; i < outerLen; i += dim) {
x = data[i];
y = data[i + 1];
if (x < minX) minX = x;
if (y < minY) minY = y;
if (x > maxX) maxX = x;
if (y > maxY) maxY = y;
}
// minX, minY and invSize are later used to transform coords into integers for z-order calculation
invSize = Math.max(maxX - minX, maxY - minY);
invSize = invSize !== 0 ? 1 / invSize : 0;
}
earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
return triangles;
}
// create a circular doubly linked list from polygon points in the specified winding order
function linkedList(data, start, end, dim, clockwise) {
var i, last;
if (clockwise === (signedArea(data, start, end, dim) > 0)) {
for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);
} else {
for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
}
if (last && equals(last, last.next)) {
removeNode(last);
last = last.next;
}
return last;
}
// eliminate colinear or duplicate points
function filterPoints(start, end) {
if (!start) return start;
if (!end) end = start;
var p = start,
again;
do {
again = false;
if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
removeNode(p);
p = end = p.prev;
if (p === p.next) break;
again = true;
} else {
p = p.next;
}
} while (again || p !== end);
return end;
}
// main ear slicing loop which triangulates a polygon (given as a linked list)
function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
if (!ear) return;
// interlink polygon nodes in z-order
if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
var stop = ear,
prev, next;
// iterate through ears, slicing them one by one
while (ear.prev !== ear.next) {
prev = ear.prev;
next = ear.next;
if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
// cut off the triangle
triangles.push(prev.i / dim);
triangles.push(ear.i / dim);
triangles.push(next.i / dim);
removeNode(ear);
// skipping the next vertice leads to less sliver triangles
ear = next.next;
stop = next.next;
continue;
}
ear = next;
// if we looped through the whole remaining polygon and can't find any more ears
if (ear === stop) {
// try filtering points and slicing again
if (!pass) {
earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
// if this didn't work, try curing all small self-intersections locally
} else if (pass === 1) {
ear = cureLocalIntersections(ear, triangles, dim);
earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
// as a last resort, try splitting the remaining polygon into two
} else if (pass === 2) {
splitEarcut(ear, triangles, dim, minX, minY, invSize);
}
break;
}
}
}
// check whether a polygon node forms a valid ear with adjacent nodes
function isEar(ear) {
var a = ear.prev,
b = ear,
c = ear.next;
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
// now make sure we don't have other points inside the potential ear
var p = ear.next.next;
while (p !== ear.prev) {
if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
area(p.prev, p, p.next) >= 0) return false;
p = p.next;
}
return true;
}
function isEarHashed(ear, minX, minY, invSize) {
var a = ear.prev,
b = ear,
c = ear.next;
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
// triangle bbox; min & max are calculated like this for speed
var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x),
minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y),
maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x),
maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y);
// z-order range for the current triangle bbox;
var minZ = zOrder(minTX, minTY, minX, minY, invSize),
maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
var p = ear.prevZ,
n = ear.nextZ;
// look for points inside the triangle in both directions
while (p && p.z >= minZ && n && n.z <= maxZ) {
if (p !== ear.prev && p !== ear.next &&
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
area(p.prev, p, p.next) >= 0) return false;
p = p.prevZ;
if (n !== ear.prev && n !== ear.next &&
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
area(n.prev, n, n.next) >= 0) return false;
n = n.nextZ;
}
// look for remaining points in decreasing z-order
while (p && p.z >= minZ) {
if (p !== ear.prev && p !== ear.next &&
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
area(p.prev, p, p.next) >= 0) return false;
p = p.prevZ;
}
// look for remaining points in increasing z-order
while (n && n.z <= maxZ) {
if (n !== ear.prev && n !== ear.next &&
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
area(n.prev, n, n.next) >= 0) return false;
n = n.nextZ;
}
return true;
}
// go through all polygon nodes and cure small local self-intersections
function cureLocalIntersections(start, triangles, dim) {
var p = start;
do {
var a = p.prev,
b = p.next.next;
if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
triangles.push(a.i / dim);
triangles.push(p.i / dim);
triangles.push(b.i / dim);
// remove two nodes involved
removeNode(p);
removeNode(p.next);
p = start = b;
}
p = p.next;
} while (p !== start);
return p;
}
// try splitting polygon into two and triangulate them independently
function splitEarcut(start, triangles, dim, minX, minY, invSize) {
// look for a valid diagonal that divides the polygon into two
var a = start;
do {
var b = a.next.next;
while (b !== a.prev) {
if (a.i !== b.i && isValidDiagonal(a, b)) {
// split the polygon in two by the diagonal
var c = splitPolygon(a, b);
// filter colinear points around the cuts
a = filterPoints(a, a.next);
c = filterPoints(c, c.next);
// run earcut on each half
earcutLinked(a, triangles, dim, minX, minY, invSize);
earcutLinked(c, triangles, dim, minX, minY, invSize);
return;
}
b = b.next;
}
a = a.next;
} while (a !== start);
}
// link every hole into the outer loop, producing a single-ring polygon without holes
function eliminateHoles(data, holeIndices, outerNode, dim) {
var queue = [],
i, len, start, end, list;
for (i = 0, len = holeIndices.length; i < len; i++) {
start = holeIndices[i] * dim;
end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
list = linkedList(data, start, end, dim, false);
if (list === list.next) list.steiner = true;
queue.push(getLeftmost(list));
}
queue.sort(compareX);
// process holes from left to right
for (i = 0; i < queue.length; i++) {
eliminateHole(queue[i], outerNode);
outerNode = filterPoints(outerNode, outerNode.next);
}
return outerNode;
}
function compareX(a, b) {
return a.x - b.x;
}
// find a bridge between vertices that connects hole with an outer ring and and link it
function eliminateHole(hole, outerNode) {
outerNode = findHoleBridge(hole, outerNode);
if (outerNode) {
var b = splitPolygon(outerNode, hole);
filterPoints(b, b.next);
}
}
// David Eberly's algorithm for finding a bridge between hole and outer polygon
function findHoleBridge(hole, outerNode) {
var p = outerNode,
hx = hole.x,
hy = hole.y,
qx = -Infinity,
m;
// find a segment intersected by a ray from the hole's leftmost point to the left;
// segment's endpoint with lesser x will be potential connection point
do {
if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
if (x <= hx && x > qx) {
qx = x;
if (x === hx) {
if (hy === p.y) return p;
if (hy === p.next.y) return p.next;
}
m = p.x < p.next.x ? p : p.next;
}
}
p = p.next;
} while (p !== outerNode);
if (!m) return null;
if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint
// look for points inside the triangle of hole point, segment intersection and endpoint;
// if there are no points found, we have a valid connection;
// otherwise choose the point of the minimum angle with the ray as connection point
var stop = m,
mx = m.x,
my = m.y,
tanMin = Infinity,
tan;
p = m.next;
while (p !== stop) {
if (hx >= p.x && p.x >= mx && hx !== p.x &&
pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) {
m = p;
tanMin = tan;
}
}
p = p.next;
}
return m;
}
// interlink polygon nodes in z-order
function indexCurve(start, minX, minY, invSize) {
var p = start;
do {
if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, invSize);
p.prevZ = p.prev;
p.nextZ = p.next;
p = p.next;
} while (p !== start);
p.prevZ.nextZ = null;
p.prevZ = null;
sortLinked(p);
}
// Simon Tatham's linked list merge sort algorithm
// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
function sortLinked(list) {
var i, p, q, e, tail, numMerges, pSize, qSize,
inSize = 1;
do {
p = list;
list = null;
tail = null;
numMerges = 0;
while (p) {
numMerges++;
q = p;
pSize = 0;
for (i = 0; i < inSize; i++) {
pSize++;
q = q.nextZ;
if (!q) break;
}
qSize = inSize;
while (pSize > 0 || (qSize > 0 && q)) {
if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
e = p;
p = p.nextZ;
pSize--;
} else {
e = q;
q = q.nextZ;
qSize--;
}
if (tail) tail.nextZ = e;
else list = e;
e.prevZ = tail;
tail = e;
}
p = q;
}
tail.nextZ = null;
inSize *= 2;
} while (numMerges > 1);
return list;
}
// z-order of a point given coords and inverse of the longer side of data bbox
function zOrder(x, y, minX, minY, invSize) {
// coords are transformed into non-negative 15-bit integer range
x = 32767 * (x - minX) * invSize;
y = 32767 * (y - minY) * invSize;
x = (x | (x << 8)) & 0x00FF00FF;
x = (x | (x << 4)) & 0x0F0F0F0F;
x = (x | (x << 2)) & 0x33333333;
x = (x | (x << 1)) & 0x55555555;
y = (y | (y << 8)) & 0x00FF00FF;
y = (y | (y << 4)) & 0x0F0F0F0F;
y = (y | (y << 2)) & 0x33333333;
y = (y | (y << 1)) & 0x55555555;
return x | (y << 1);
}
// find the leftmost node of a polygon ring
function getLeftmost(start) {
var p = start,
leftmost = start;
do {
if (p.x < leftmost.x) leftmost = p;
p = p.next;
} while (p !== start);
return leftmost;
}
// check if a point lies within a convex triangle
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
(ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
(bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
}
// check if a diagonal between two polygon nodes is valid (lies in polygon interior)
function isValidDiagonal(a, b) {
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) &&
locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b);
}
// signed area of a triangle
function area(p, q, r) {
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
}
// check if two points are equal
function equals(p1, p2) {
return p1.x === p2.x && p1.y === p2.y;
}
// check if two segments intersect
function intersects(p1, q1, p2, q2) {
if ((equals(p1, q1) && equals(p2, q2)) ||
(equals(p1, q2) && equals(p2, q1))) return true;
return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 &&
area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
}
// check if a polygon diagonal intersects any polygon segments
function intersectsPolygon(a, b) {
var p = a;
do {
if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
intersects(p, p.next, a, b)) return true;
p = p.next;
} while (p !== a);
return false;
}
// check if a polygon diagonal is locally inside the polygon
function locallyInside(a, b) {
return area(a.prev, a, a.next) < 0 ?
area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
}
// check if the middle point of a polygon diagonal is inside the polygon
function middleInside(a, b) {
var p = a,
inside = false,
px = (a.x + b.x) / 2,
py = (a.y + b.y) / 2;
do {
if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&
(px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
inside = !inside;
p = p.next;
} while (p !== a);
return inside;
}
// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
// if one belongs to the outer ring and another to a hole, it merges it into a single ring
function splitPolygon(a, b) {
var a2 = new Node(a.i, a.x, a.y),
b2 = new Node(b.i, b.x, b.y),
an = a.next,
bp = b.prev;
a.next = b;
b.prev = a;
a2.next = an;
an.prev = a2;
b2.next = a2;
a2.prev = b2;
bp.next = b2;
b2.prev = bp;
return b2;
}
// create a node and optionally link it with previous one (in a circular doubly linked list)
function insertNode(i, x, y, last) {
var p = new Node(i, x, y);
if (!last) {
p.prev = p;
p.next = p;
} else {
p.next = last.next;
p.prev = last;
last.next.prev = p;
last.next = p;
}
return p;
}
function removeNode(p) {
p.next.prev = p.prev;
p.prev.next = p.next;
if (p.prevZ) p.prevZ.nextZ = p.nextZ;
if (p.nextZ) p.nextZ.prevZ = p.prevZ;
}
function Node(i, x, y) {
// vertice index in coordinates array
this.i = i;
// vertex coordinates
this.x = x;
this.y = y;
// previous and next vertice nodes in a polygon ring
this.prev = null;
this.next = null;
// z-order curve value
this.z = null;
// previous and next nodes in z-order
this.prevZ = null;
this.nextZ = null;
// indicates whether this is a steiner point
this.steiner = false;
}
// return a percentage difference between the polygon area and its triangulation area;
// used to verify correctness of triangulation
earcut.deviation = function (data, holeIndices, dim, triangles) {
var hasHoles = holeIndices && holeIndices.length;
var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
if (hasHoles) {
for (var i = 0, len = holeIndices.length; i < len; i++) {
var start = holeIndices[i] * dim;
var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
polygonArea -= Math.abs(signedArea(data, start, end, dim));
}
}
var trianglesArea = 0;
for (i = 0; i < triangles.length; i += 3) {
var a = triangles[i] * dim;
var b = triangles[i + 1] * dim;
var c = triangles[i + 2] * dim;
trianglesArea += Math.abs(
(data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
(data[a] - data[b]) * (data[c + 1] - data[a + 1]));
}
return polygonArea === 0 && trianglesArea === 0 ? 0 :
Math.abs((trianglesArea - polygonArea) / polygonArea);
};
function signedArea(data, start, end, dim) {
var sum = 0;
for (var i = start, j = end - dim; i < end; i += dim) {
sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
j = i;
}
return sum;
}
// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
earcut.flatten = function (data) {
var dim = data[0][0].length,
result = {vertices: [], holes: [], dimensions: dim},
holeIndex = 0;
for (var i = 0; i < data.length; i++) {
for (var j = 0; j < data[i].length; j++) {
for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);
}
if (i > 0) {
holeIndex += data[i - 1].length;
result.holes.push(holeIndex);
}
}
return result;
};
/***/ }),
/***/ "./node_modules/gl-matrix/lib/gl-matrix.js":
/*!*************************************************!*\
!*** ./node_modules/gl-matrix/lib/gl-matrix.js ***!
\*************************************************/
/*! exports provided: glMatrix, mat2, mat2d, mat3, mat4, quat, quat2, vec2, vec3, vec4 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _gl_matrix_common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./gl-matrix/common.js */ "./node_modules/gl-matrix/lib/gl-matrix/common.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "glMatrix", function() { return _gl_matrix_common_js__WEBPACK_IMPORTED_MODULE_0__; });
/* harmony import */ var _gl_matrix_mat2_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gl-matrix/mat2.js */ "./node_modules/gl-matrix/lib/gl-matrix/mat2.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "mat2", function() { return _gl_matrix_mat2_js__WEBPACK_IMPORTED_MODULE_1__; });
/* harmony import */ var _gl_matrix_mat2d_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gl-matrix/mat2d.js */ "./node_modules/gl-matrix/lib/gl-matrix/mat2d.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "mat2d", function() { return _gl_matrix_mat2d_js__WEBPACK_IMPORTED_MODULE_2__; });
/* harmony import */ var _gl_matrix_mat3_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gl-matrix/mat3.js */ "./node_modules/gl-matrix/lib/gl-matrix/mat3.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "mat3", function() { return _gl_matrix_mat3_js__WEBPACK_IMPORTED_MODULE_3__; });
/* harmony import */ var _gl_matrix_mat4_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gl-matrix/mat4.js */ "./node_modules/gl-matrix/lib/gl-matrix/mat4.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "mat4", function() { return _gl_matrix_mat4_js__WEBPACK_IMPORTED_MODULE_4__; });
/* harmony import */ var _gl_matrix_quat_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gl-matrix/quat.js */ "./node_modules/gl-matrix/lib/gl-matrix/quat.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "quat", function() { return _gl_matrix_quat_js__WEBPACK_IMPORTED_MODULE_5__; });
/* harmony import */ var _gl_matrix_quat2_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gl-matrix/quat2.js */ "./node_modules/gl-matrix/lib/gl-matrix/quat2.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "quat2", function() { return _gl_matrix_quat2_js__WEBPACK_IMPORTED_MODULE_6__; });
/* harmony import */ var _gl_matrix_vec2_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gl-matrix/vec2.js */ "./node_modules/gl-matrix/lib/gl-matrix/vec2.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "vec2", function() { return _gl_matrix_vec2_js__WEBPACK_IMPORTED_MODULE_7__; });
/* harmony import */ var _gl_matrix_vec3_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gl-matrix/vec3.js */ "./node_modules/gl-matrix/lib/gl-matrix/vec3.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "vec3", function() { return _gl_matrix_vec3_js__WEBPACK_IMPORTED_MODULE_8__; });
/* harmony import */ var _gl_matrix_vec4_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./gl-matrix/vec4.js */ "./node_modules/gl-matrix/lib/gl-matrix/vec4.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "vec4", function() { return _gl_matrix_vec4_js__WEBPACK_IMPORTED_MODULE_9__; });
/***/ }),
/***/ "./node_modules/gl-matrix/lib/gl-matrix/common.js":
/*!********************************************************!*\
!*** ./node_modules/gl-matrix/lib/gl-matrix/common.js ***!
\********************************************************/
/*! exports provided: EPSILON, ARRAY_TYPE, RANDOM, setMatrixArrayType, toRadian, equals */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EPSILON", function() { return EPSILON; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ARRAY_TYPE", function() { return ARRAY_TYPE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RANDOM", function() { return RANDOM; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setMatrixArrayType", function() { return setMatrixArrayType; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toRadian", function() { return toRadian; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });
/**
* Common utilities
* @module glMatrix
*/
// Configuration Constants
var EPSILON = 0.000001;
var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
var RANDOM = Math.random;
/**
* Sets the type of array used when creating new vectors and matrices
*
* @param {Type} type Array type, such as Float32Array or Array
*/
function setMatrixArrayType(type) {
ARRAY_TYPE = type;
}
var degree = Math.PI / 180;
/**
* Convert Degree To Radian
*
* @param {Number} a Angle in Degrees
*/
function toRadian(a) {
return a * degree;
}
/**
* Tests whether or not the arguments have approximately the same value, within an absolute
* or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
* than or equal to 1.0, and a relative tolerance is used for larger values)
*
* @param {Number} a The first number to test.
* @param {Number} b The second number to test.
* @returns {Boolean} True if the numbers are approximately equal, false otherwise.
*/
function equals(a, b) {
return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));
}
/***/ }),
/***/ "./node_modules/gl-matrix/lib/gl-matrix/mat2.js":
/*!******************************************************!*\
!*** ./node_modules/gl-matrix/lib/gl-matrix/mat2.js ***!
\******************************************************/
/*! exports provided: create, clone, copy, identity, fromValues, set, transpose, invert, adjoint, determinant, multiply, rotate, scale, fromRotation, fromScaling, str, frob, LDU, add, subtract, exactEquals, equals, multiplyScalar, multiplyScalarAndAdd, mul, sub */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transpose", function() { return transpose; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "invert", function() { return invert; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "adjoint", function() { return adjoint; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determinant", function() { return determinant; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotate", function() { return rotate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotation", function() { return fromRotation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromScaling", function() { return fromScaling; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "frob", function() { return frob; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LDU", function() { return LDU; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalar", function() { return multiplyScalar; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalarAndAdd", function() { return multiplyScalarAndAdd; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/lib/gl-matrix/common.js");
/**
* 2x2 Matrix
* @module mat2
*/
/**
* Creates a new identity mat2
*
* @returns {mat2} a new 2x2 matrix
*/
function create() {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4);
if (_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) {
out[1] = 0;
out[2] = 0;
}
out[0] = 1;
out[3] = 1;
return out;
}
/**
* Creates a new mat2 initialized with values from an existing matrix
*
* @param {mat2} a matrix to clone
* @returns {mat2} a new 2x2 matrix
*/
function clone(a) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4);
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
return out;
}
/**
* Copy the values from one mat2 to another
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the source matrix
* @returns {mat2} out
*/
function copy(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
return out;
}
/**
* Set a mat2 to the identity matrix
*
* @param {mat2} out the receiving matrix
* @returns {mat2} out
*/
function identity(out) {
out[0] = 1;
out[1] = 0;
out[2] = 0;
out[3] = 1;
return out;
}
/**
* Create a new mat2 with the given values
*
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m10 Component in column 1, row 0 position (index 2)
* @param {Number} m11 Component in column 1, row 1 position (index 3)
* @returns {mat2} out A new 2x2 matrix
*/
function fromValues(m00, m01, m10, m11) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4);
out[0] = m00;
out[1] = m01;
out[2] = m10;
out[3] = m11;
return out;
}
/**
* Set the components of a mat2 to the given values
*
* @param {mat2} out the receiving matrix
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m10 Component in column 1, row 0 position (index 2)
* @param {Number} m11 Component in column 1, row 1 position (index 3)
* @returns {mat2} out
*/
function set(out, m00, m01, m10, m11) {
out[0] = m00;
out[1] = m01;
out[2] = m10;
out[3] = m11;
return out;
}
/**
* Transpose the values of a mat2
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the source matrix
* @returns {mat2} out
*/
function transpose(out, a) {
// If we are transposing ourselves we can skip a few steps but have to cache
// some values
if (out === a) {
var a1 = a[1];
out[1] = a[2];
out[2] = a1;
} else {
out[0] = a[0];
out[1] = a[2];
out[2] = a[1];
out[3] = a[3];
}
return out;
}
/**
* Inverts a mat2
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the source matrix
* @returns {mat2} out
*/
function invert(out, a) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3];
// Calculate the determinant
var det = a0 * a3 - a2 * a1;
if (!det) {
return null;
}
det = 1.0 / det;
out[0] = a3 * det;
out[1] = -a1 * det;
out[2] = -a2 * det;
out[3] = a0 * det;
return out;
}
/**
* Calculates the adjugate of a mat2
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the source matrix
* @returns {mat2} out
*/
function adjoint(out, a) {
// Caching this value is nessecary if out == a
var a0 = a[0];
out[0] = a[3];
out[1] = -a[1];
out[2] = -a[2];
out[3] = a0;
return out;
}
/**
* Calculates the determinant of a mat2
*
* @param {mat2} a the source matrix
* @returns {Number} determinant of a
*/
function determinant(a) {
return a[0] * a[3] - a[2] * a[1];
}
/**
* Multiplies two mat2's
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the first operand
* @param {mat2} b the second operand
* @returns {mat2} out
*/
function multiply(out, a, b) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3];
var b0 = b[0],
b1 = b[1],
b2 = b[2],
b3 = b[3];
out[0] = a0 * b0 + a2 * b1;
out[1] = a1 * b0 + a3 * b1;
out[2] = a0 * b2 + a2 * b3;
out[3] = a1 * b2 + a3 * b3;
return out;
}
/**
* Rotates a mat2 by the given angle
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat2} out
*/
function rotate(out, a, rad) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3];
var s = Math.sin(rad);
var c = Math.cos(rad);
out[0] = a0 * c + a2 * s;
out[1] = a1 * c + a3 * s;
out[2] = a0 * -s + a2 * c;
out[3] = a1 * -s + a3 * c;
return out;
}
/**
* Scales the mat2 by the dimensions in the given vec2
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the matrix to rotate
* @param {vec2} v the vec2 to scale the matrix by
* @returns {mat2} out
**/
function scale(out, a, v) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3];
var v0 = v[0],
v1 = v[1];
out[0] = a0 * v0;
out[1] = a1 * v0;
out[2] = a2 * v1;
out[3] = a3 * v1;
return out;
}
/**
* Creates a matrix from a given angle
* This is equivalent to (but much faster than):
*
* mat2.identity(dest);
* mat2.rotate(dest, dest, rad);
*
* @param {mat2} out mat2 receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat2} out
*/
function fromRotation(out, rad) {
var s = Math.sin(rad);
var c = Math.cos(rad);
out[0] = c;
out[1] = s;
out[2] = -s;
out[3] = c;
return out;
}
/**
* Creates a matrix from a vector scaling
* This is equivalent to (but much faster than):
*
* mat2.identity(dest);
* mat2.scale(dest, dest, vec);
*
* @param {mat2} out mat2 receiving operation result
* @param {vec2} v Scaling vector
* @returns {mat2} out
*/
function fromScaling(out, v) {
out[0] = v[0];
out[1] = 0;
out[2] = 0;
out[3] = v[1];
return out;
}
/**
* Returns a string representation of a mat2
*
* @param {mat2} a matrix to represent as a string
* @returns {String} string representation of the matrix
*/
function str(a) {
return 'mat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';
}
/**
* Returns Frobenius norm of a mat2
*
* @param {mat2} a the matrix to calculate Frobenius norm of
* @returns {Number} Frobenius norm
*/
function frob(a) {
return Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2));
}
/**
* Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix
* @param {mat2} L the lower triangular matrix
* @param {mat2} D the diagonal matrix
* @param {mat2} U the upper triangular matrix
* @param {mat2} a the input matrix to factorize
*/
function LDU(L, D, U, a) {
L[2] = a[2] / a[0];
U[0] = a[0];
U[1] = a[1];
U[3] = a[3] - L[2] * U[1];
return [L, D, U];
}
/**
* Adds two mat2's
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the first operand
* @param {mat2} b the second operand
* @returns {mat2} out
*/
function add(out, a, b) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
out[2] = a[2] + b[2];
out[3] = a[3] + b[3];
return out;
}
/**
* Subtracts matrix b from matrix a
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the first operand
* @param {mat2} b the second operand
* @returns {mat2} out
*/
function subtract(out, a, b) {
out[0] = a[0] - b[0];
out[1] = a[1] - b[1];
out[2] = a[2] - b[2];
out[3] = a[3] - b[3];
return out;
}
/**
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
*
* @param {mat2} a The first matrix.
* @param {mat2} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
function exactEquals(a, b) {
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
}
/**
* Returns whether or not the matrices have approximately the same elements in the same position.
*
* @param {mat2} a The first matrix.
* @param {mat2} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
function equals(a, b) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3];
var b0 = b[0],
b1 = b[1],
b2 = b[2],
b3 = b[3];
return Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a3), Math.abs(b3));
}
/**
* Multiply each element of the matrix by a scalar.
*
* @param {mat2} out the receiving matrix
* @param {mat2} a the matrix to scale
* @param {Number} b amount to scale the matrix's elements by
* @returns {mat2} out
*/
function multiplyScalar(out, a, b) {
out[0] = a[0] * b;
out[1] = a[1] * b;
out[2] = a[2] * b;
out[3] = a[3] * b;
return out;
}
/**
* Adds two mat2's after multiplying each element of the second operand by a scalar value.
*
* @param {mat2} out the receiving vector
* @param {mat2} a the first operand
* @param {mat2} b the second operand
* @param {Number} scale the amount to scale b's elements by before adding
* @returns {mat2} out
*/
function multiplyScalarAndAdd(out, a, b, scale) {
out[0] = a[0] + b[0] * scale;
out[1] = a[1] + b[1] * scale;
out[2] = a[2] + b[2] * scale;
out[3] = a[3] + b[3] * scale;
return out;
}
/**
* Alias for {@link mat2.multiply}
* @function
*/
var mul = multiply;
/**
* Alias for {@link mat2.subtract}
* @function
*/
var sub = subtract;
/***/ }),
/***/ "./node_modules/gl-matrix/lib/gl-matrix/mat2d.js":
/*!*******************************************************!*\
!*** ./node_modules/gl-matrix/lib/gl-matrix/mat2d.js ***!
\*******************************************************/
/*! exports provided: create, clone, copy, identity, fromValues, set, invert, determinant, multiply, rotate, scale, translate, fromRotation, fromScaling, fromTranslation, str, frob, add, subtract, multiplyScalar, multiplyScalarAndAdd, exactEquals, equals, mul, sub */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "invert", function() { return invert; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determinant", function() { return determinant; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotate", function() { return rotate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "translate", function() { return translate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotation", function() { return fromRotation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromScaling", function() { return fromScaling; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromTranslation", function() { return fromTranslation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "frob", function() { return frob; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalar", function() { return multiplyScalar; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalarAndAdd", function() { return multiplyScalarAndAdd; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/lib/gl-matrix/common.js");
/**
* 2x3 Matrix
* @module mat2d
*
* @description
* A mat2d contains six elements defined as:
* <pre>
* [a, c, tx,
* b, d, ty]
* </pre>
* This is a short form for the 3x3 matrix:
* <pre>
* [a, c, tx,
* b, d, ty,
* 0, 0, 1]
* </pre>
* The last row is ignored so the array is shorter and operations are faster.
*/
/**
* Creates a new identity mat2d
*
* @returns {mat2d} a new 2x3 matrix
*/
function create() {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](6);
if (_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) {
out[1] = 0;
out[2] = 0;
out[4] = 0;
out[5] = 0;
}
out[0] = 1;
out[3] = 1;
return out;
}
/**
* Creates a new mat2d initialized with values from an existing matrix
*
* @param {mat2d} a matrix to clone
* @returns {mat2d} a new 2x3 matrix
*/
function clone(a) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](6);
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
out[4] = a[4];
out[5] = a[5];
return out;
}
/**
* Copy the values from one mat2d to another
*
* @param {mat2d} out the receiving matrix
* @param {mat2d} a the source matrix
* @returns {mat2d} out
*/
function copy(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
out[4] = a[4];
out[5] = a[5];
return out;
}
/**
* Set a mat2d to the identity matrix
*
* @param {mat2d} out the receiving matrix
* @returns {mat2d} out
*/
function identity(out) {
out[0] = 1;
out[1] = 0;
out[2] = 0;
out[3] = 1;
out[4] = 0;
out[5] = 0;
return out;
}
/**
* Create a new mat2d with the given values
*
* @param {Number} a Component A (index 0)
* @param {Number} b Component B (index 1)
* @param {Number} c Component C (index 2)
* @param {Number} d Component D (index 3)
* @param {Number} tx Component TX (index 4)
* @param {Number} ty Component TY (index 5)
* @returns {mat2d} A new mat2d
*/
function fromValues(a, b, c, d, tx, ty) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](6);
out[0] = a;
out[1] = b;
out[2] = c;
out[3] = d;
out[4] = tx;
out[5] = ty;
return out;
}
/**
* Set the components of a mat2d to the given values
*
* @param {mat2d} out the receiving matrix
* @param {Number} a Component A (index 0)
* @param {Number} b Component B (index 1)
* @param {Number} c Component C (index 2)
* @param {Number} d Component D (index 3)
* @param {Number} tx Component TX (index 4)
* @param {Number} ty Component TY (index 5)
* @returns {mat2d} out
*/
function set(out, a, b, c, d, tx, ty) {
out[0] = a;
out[1] = b;
out[2] = c;
out[3] = d;
out[4] = tx;
out[5] = ty;
return out;
}
/**
* Inverts a mat2d
*
* @param {mat2d} out the receiving matrix
* @param {mat2d} a the source matrix
* @returns {mat2d} out
*/
function invert(out, a) {
var aa = a[0],
ab = a[1],
ac = a[2],
ad = a[3];
var atx = a[4],
aty = a[5];
var det = aa * ad - ab * ac;
if (!det) {
return null;
}
det = 1.0 / det;
out[0] = ad * det;
out[1] = -ab * det;
out[2] = -ac * det;
out[3] = aa * det;
out[4] = (ac * aty - ad * atx) * det;
out[5] = (ab * atx - aa * aty) * det;
return out;
}
/**
* Calculates the determinant of a mat2d
*
* @param {mat2d} a the source matrix
* @returns {Number} determinant of a
*/
function determinant(a) {
return a[0] * a[3] - a[1] * a[2];
}
/**
* Multiplies two mat2d's
*
* @param {mat2d} out the receiving matrix
* @param {mat2d} a the first operand
* @param {mat2d} b the second operand
* @returns {mat2d} out
*/
function multiply(out, a, b) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3],
a4 = a[4],
a5 = a[5];
var b0 = b[0],
b1 = b[1],
b2 = b[2],
b3 = b[3],
b4 = b[4],
b5 = b[5];
out[0] = a0 * b0 + a2 * b1;
out[1] = a1 * b0 + a3 * b1;
out[2] = a0 * b2 + a2 * b3;
out[3] = a1 * b2 + a3 * b3;
out[4] = a0 * b4 + a2 * b5 + a4;
out[5] = a1 * b4 + a3 * b5 + a5;
return out;
}
/**
* Rotates a mat2d by the given angle
*
* @param {mat2d} out the receiving matrix
* @param {mat2d} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat2d} out
*/
function rotate(out, a, rad) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3],
a4 = a[4],
a5 = a[5];
var s = Math.sin(rad);
var c = Math.cos(rad);
out[0] = a0 * c + a2 * s;
out[1] = a1 * c + a3 * s;
out[2] = a0 * -s + a2 * c;
out[3] = a1 * -s + a3 * c;
out[4] = a4;
out[5] = a5;
return out;
}
/**
* Scales the mat2d by the dimensions in the given vec2
*
* @param {mat2d} out the receiving matrix
* @param {mat2d} a the matrix to translate
* @param {vec2} v the vec2 to scale the matrix by
* @returns {mat2d} out
**/
function scale(out, a, v) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3],
a4 = a[4],
a5 = a[5];
var v0 = v[0],
v1 = v[1];
out[0] = a0 * v0;
out[1] = a1 * v0;
out[2] = a2 * v1;
out[3] = a3 * v1;
out[4] = a4;
out[5] = a5;
return out;
}
/**
* Translates the mat2d by the dimensions in the given vec2
*
* @param {mat2d} out the receiving matrix
* @param {mat2d} a the matrix to translate
* @param {vec2} v the vec2 to translate the matrix by
* @returns {mat2d} out
**/
function translate(out, a, v) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3],
a4 = a[4],
a5 = a[5];
var v0 = v[0],
v1 = v[1];
out[0] = a0;
out[1] = a1;
out[2] = a2;
out[3] = a3;
out[4] = a0 * v0 + a2 * v1 + a4;
out[5] = a1 * v0 + a3 * v1 + a5;
return out;
}
/**
* Creates a matrix from a given angle
* This is equivalent to (but much faster than):
*
* mat2d.identity(dest);
* mat2d.rotate(dest, dest, rad);
*
* @param {mat2d} out mat2d receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat2d} out
*/
function fromRotation(out, rad) {
var s = Math.sin(rad),
c = Math.cos(rad);
out[0] = c;
out[1] = s;
out[2] = -s;
out[3] = c;
out[4] = 0;
out[5] = 0;
return out;
}
/**
* Creates a matrix from a vector scaling
* This is equivalent to (but much faster than):
*
* mat2d.identity(dest);
* mat2d.scale(dest, dest, vec);
*
* @param {mat2d} out mat2d receiving operation result
* @param {vec2} v Scaling vector
* @returns {mat2d} out
*/
function fromScaling(out, v) {
out[0] = v[0];
out[1] = 0;
out[2] = 0;
out[3] = v[1];
out[4] = 0;
out[5] = 0;
return out;
}
/**
* Creates a matrix from a vector translation
* This is equivalent to (but much faster than):
*
* mat2d.identity(dest);
* mat2d.translate(dest, dest, vec);
*
* @param {mat2d} out mat2d receiving operation result
* @param {vec2} v Translation vector
* @returns {mat2d} out
*/
function fromTranslation(out, v) {
out[0] = 1;
out[1] = 0;
out[2] = 0;
out[3] = 1;
out[4] = v[0];
out[5] = v[1];
return out;
}
/**
* Returns a string representation of a mat2d
*
* @param {mat2d} a matrix to represent as a string
* @returns {String} string representation of the matrix
*/
function str(a) {
return 'mat2d(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ')';
}
/**
* Returns Frobenius norm of a mat2d
*
* @param {mat2d} a the matrix to calculate Frobenius norm of
* @returns {Number} Frobenius norm
*/
function frob(a) {
return Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + 1);
}
/**
* Adds two mat2d's
*
* @param {mat2d} out the receiving matrix
* @param {mat2d} a the first operand
* @param {mat2d} b the second operand
* @returns {mat2d} out
*/
function add(out, a, b) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
out[2] = a[2] + b[2];
out[3] = a[3] + b[3];
out[4] = a[4] + b[4];
out[5] = a[5] + b[5];
return out;
}
/**
* Subtracts matrix b from matrix a
*
* @param {mat2d} out the receiving matrix
* @param {mat2d} a the first operand
* @param {mat2d} b the second operand
* @returns {mat2d} out
*/
function subtract(out, a, b) {
out[0] = a[0] - b[0];
out[1] = a[1] - b[1];
out[2] = a[2] - b[2];
out[3] = a[3] - b[3];
out[4] = a[4] - b[4];
out[5] = a[5] - b[5];
return out;
}
/**
* Multiply each element of the matrix by a scalar.
*
* @param {mat2d} out the receiving matrix
* @param {mat2d} a the matrix to scale
* @param {Number} b amount to scale the matrix's elements by
* @returns {mat2d} out
*/
function multiplyScalar(out, a, b) {
out[0] = a[0] * b;
out[1] = a[1] * b;
out[2] = a[2] * b;
out[3] = a[3] * b;
out[4] = a[4] * b;
out[5] = a[5] * b;
return out;
}
/**
* Adds two mat2d's after multiplying each element of the second operand by a scalar value.
*
* @param {mat2d} out the receiving vector
* @param {mat2d} a the first operand
* @param {mat2d} b the second operand
* @param {Number} scale the amount to scale b's elements by before adding
* @returns {mat2d} out
*/
function multiplyScalarAndAdd(out, a, b, scale) {
out[0] = a[0] + b[0] * scale;
out[1] = a[1] + b[1] * scale;
out[2] = a[2] + b[2] * scale;
out[3] = a[3] + b[3] * scale;
out[4] = a[4] + b[4] * scale;
out[5] = a[5] + b[5] * scale;
return out;
}
/**
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
*
* @param {mat2d} a The first matrix.
* @param {mat2d} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
function exactEquals(a, b) {
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5];
}
/**
* Returns whether or not the matrices have approximately the same elements in the same position.
*
* @param {mat2d} a The first matrix.
* @param {mat2d} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
function equals(a, b) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3],
a4 = a[4],
a5 = a[5];
var b0 = b[0],
b1 = b[1],
b2 = b[2],
b3 = b[3],
b4 = b[4],
b5 = b[5];
return Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a5), Math.abs(b5));
}
/**
* Alias for {@link mat2d.multiply}
* @function
*/
var mul = multiply;
/**
* Alias for {@link mat2d.subtract}
* @function
*/
var sub = subtract;
/***/ }),
/***/ "./node_modules/gl-matrix/lib/gl-matrix/mat3.js":
/*!******************************************************!*\
!*** ./node_modules/gl-matrix/lib/gl-matrix/mat3.js ***!
\******************************************************/
/*! exports provided: create, fromMat4, clone, copy, fromValues, set, identity, transpose, invert, adjoint, determinant, multiply, translate, rotate, scale, fromTranslation, fromRotation, fromScaling, fromMat2d, fromQuat, normalFromMat4, projection, str, frob, add, subtract, multiplyScalar, multiplyScalarAndAdd, exactEquals, equals, mul, sub */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromMat4", function() { return fromMat4; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transpose", function() { return transpose; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "invert", function() { return invert; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "adjoint", function() { return adjoint; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determinant", function() { return determinant; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "translate", function() { return translate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotate", function() { return rotate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromTranslation", function() { return fromTranslation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotation", function() { return fromRotation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromScaling", function() { return fromScaling; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromMat2d", function() { return fromMat2d; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromQuat", function() { return fromQuat; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalFromMat4", function() { return normalFromMat4; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "projection", function() { return projection; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "frob", function() { return frob; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalar", function() { return multiplyScalar; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalarAndAdd", function() { return multiplyScalarAndAdd; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/lib/gl-matrix/common.js");
/**
* 3x3 Matrix
* @module mat3
*/
/**
* Creates a new identity mat3
*
* @returns {mat3} a new 3x3 matrix
*/
function create() {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](9);
if (_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) {
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[5] = 0;
out[6] = 0;
out[7] = 0;
}
out[0] = 1;
out[4] = 1;
out[8] = 1;
return out;
}
/**
* Copies the upper-left 3x3 values into the given mat3.
*
* @param {mat3} out the receiving 3x3 matrix
* @param {mat4} a the source 4x4 matrix
* @returns {mat3} out
*/
function fromMat4(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[4];
out[4] = a[5];
out[5] = a[6];
out[6] = a[8];
out[7] = a[9];
out[8] = a[10];
return out;
}
/**
* Creates a new mat3 initialized with values from an existing matrix
*
* @param {mat3} a matrix to clone
* @returns {mat3} a new 3x3 matrix
*/
function clone(a) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](9);
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
out[4] = a[4];
out[5] = a[5];
out[6] = a[6];
out[7] = a[7];
out[8] = a[8];
return out;
}
/**
* Copy the values from one mat3 to another
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the source matrix
* @returns {mat3} out
*/
function copy(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
out[4] = a[4];
out[5] = a[5];
out[6] = a[6];
out[7] = a[7];
out[8] = a[8];
return out;
}
/**
* Create a new mat3 with the given values
*
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m02 Component in column 0, row 2 position (index 2)
* @param {Number} m10 Component in column 1, row 0 position (index 3)
* @param {Number} m11 Component in column 1, row 1 position (index 4)
* @param {Number} m12 Component in column 1, row 2 position (index 5)
* @param {Number} m20 Component in column 2, row 0 position (index 6)
* @param {Number} m21 Component in column 2, row 1 position (index 7)
* @param {Number} m22 Component in column 2, row 2 position (index 8)
* @returns {mat3} A new mat3
*/
function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](9);
out[0] = m00;
out[1] = m01;
out[2] = m02;
out[3] = m10;
out[4] = m11;
out[5] = m12;
out[6] = m20;
out[7] = m21;
out[8] = m22;
return out;
}
/**
* Set the components of a mat3 to the given values
*
* @param {mat3} out the receiving matrix
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m02 Component in column 0, row 2 position (index 2)
* @param {Number} m10 Component in column 1, row 0 position (index 3)
* @param {Number} m11 Component in column 1, row 1 position (index 4)
* @param {Number} m12 Component in column 1, row 2 position (index 5)
* @param {Number} m20 Component in column 2, row 0 position (index 6)
* @param {Number} m21 Component in column 2, row 1 position (index 7)
* @param {Number} m22 Component in column 2, row 2 position (index 8)
* @returns {mat3} out
*/
function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
out[0] = m00;
out[1] = m01;
out[2] = m02;
out[3] = m10;
out[4] = m11;
out[5] = m12;
out[6] = m20;
out[7] = m21;
out[8] = m22;
return out;
}
/**
* Set a mat3 to the identity matrix
*
* @param {mat3} out the receiving matrix
* @returns {mat3} out
*/
function identity(out) {
out[0] = 1;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 1;
out[5] = 0;
out[6] = 0;
out[7] = 0;
out[8] = 1;
return out;
}
/**
* Transpose the values of a mat3
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the source matrix
* @returns {mat3} out
*/
function transpose(out, a) {
// If we are transposing ourselves we can skip a few steps but have to cache some values
if (out === a) {
var a01 = a[1],
a02 = a[2],
a12 = a[5];
out[1] = a[3];
out[2] = a[6];
out[3] = a01;
out[5] = a[7];
out[6] = a02;
out[7] = a12;
} else {
out[0] = a[0];
out[1] = a[3];
out[2] = a[6];
out[3] = a[1];
out[4] = a[4];
out[5] = a[7];
out[6] = a[2];
out[7] = a[5];
out[8] = a[8];
}
return out;
}
/**
* Inverts a mat3
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the source matrix
* @returns {mat3} out
*/
function invert(out, a) {
var a00 = a[0],
a01 = a[1],
a02 = a[2];
var a10 = a[3],
a11 = a[4],
a12 = a[5];
var a20 = a[6],
a21 = a[7],
a22 = a[8];
var b01 = a22 * a11 - a12 * a21;
var b11 = -a22 * a10 + a12 * a20;
var b21 = a21 * a10 - a11 * a20;
// Calculate the determinant
var det = a00 * b01 + a01 * b11 + a02 * b21;
if (!det) {
return null;
}
det = 1.0 / det;
out[0] = b01 * det;
out[1] = (-a22 * a01 + a02 * a21) * det;
out[2] = (a12 * a01 - a02 * a11) * det;
out[3] = b11 * det;
out[4] = (a22 * a00 - a02 * a20) * det;
out[5] = (-a12 * a00 + a02 * a10) * det;
out[6] = b21 * det;
out[7] = (-a21 * a00 + a01 * a20) * det;
out[8] = (a11 * a00 - a01 * a10) * det;
return out;
}
/**
* Calculates the adjugate of a mat3
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the source matrix
* @returns {mat3} out
*/
function adjoint(out, a) {
var a00 = a[0],
a01 = a[1],
a02 = a[2];
var a10 = a[3],
a11 = a[4],
a12 = a[5];
var a20 = a[6],
a21 = a[7],
a22 = a[8];
out[0] = a11 * a22 - a12 * a21;
out[1] = a02 * a21 - a01 * a22;
out[2] = a01 * a12 - a02 * a11;
out[3] = a12 * a20 - a10 * a22;
out[4] = a00 * a22 - a02 * a20;
out[5] = a02 * a10 - a00 * a12;
out[6] = a10 * a21 - a11 * a20;
out[7] = a01 * a20 - a00 * a21;
out[8] = a00 * a11 - a01 * a10;
return out;
}
/**
* Calculates the determinant of a mat3
*
* @param {mat3} a the source matrix
* @returns {Number} determinant of a
*/
function determinant(a) {
var a00 = a[0],
a01 = a[1],
a02 = a[2];
var a10 = a[3],
a11 = a[4],
a12 = a[5];
var a20 = a[6],
a21 = a[7],
a22 = a[8];
return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
}
/**
* Multiplies two mat3's
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the first operand
* @param {mat3} b the second operand
* @returns {mat3} out
*/
function multiply(out, a, b) {
var a00 = a[0],
a01 = a[1],
a02 = a[2];
var a10 = a[3],
a11 = a[4],
a12 = a[5];
var a20 = a[6],
a21 = a[7],
a22 = a[8];
var b00 = b[0],
b01 = b[1],
b02 = b[2];
var b10 = b[3],
b11 = b[4],
b12 = b[5];
var b20 = b[6],
b21 = b[7],
b22 = b[8];
out[0] = b00 * a00 + b01 * a10 + b02 * a20;
out[1] = b00 * a01 + b01 * a11 + b02 * a21;
out[2] = b00 * a02 + b01 * a12 + b02 * a22;
out[3] = b10 * a00 + b11 * a10 + b12 * a20;
out[4] = b10 * a01 + b11 * a11 + b12 * a21;
out[5] = b10 * a02 + b11 * a12 + b12 * a22;
out[6] = b20 * a00 + b21 * a10 + b22 * a20;
out[7] = b20 * a01 + b21 * a11 + b22 * a21;
out[8] = b20 * a02 + b21 * a12 + b22 * a22;
return out;
}
/**
* Translate a mat3 by the given vector
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the matrix to translate
* @param {vec2} v vector to translate by
* @returns {mat3} out
*/
function translate(out, a, v) {
var a00 = a[0],
a01 = a[1],
a02 = a[2],
a10 = a[3],
a11 = a[4],
a12 = a[5],
a20 = a[6],
a21 = a[7],
a22 = a[8],
x = v[0],
y = v[1];
out[0] = a00;
out[1] = a01;
out[2] = a02;
out[3] = a10;
out[4] = a11;
out[5] = a12;
out[6] = x * a00 + y * a10 + a20;
out[7] = x * a01 + y * a11 + a21;
out[8] = x * a02 + y * a12 + a22;
return out;
}
/**
* Rotates a mat3 by the given angle
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat3} out
*/
function rotate(out, a, rad) {
var a00 = a[0],
a01 = a[1],
a02 = a[2],
a10 = a[3],
a11 = a[4],
a12 = a[5],
a20 = a[6],
a21 = a[7],
a22 = a[8],
s = Math.sin(rad),
c = Math.cos(rad);
out[0] = c * a00 + s * a10;
out[1] = c * a01 + s * a11;
out[2] = c * a02 + s * a12;
out[3] = c * a10 - s * a00;
out[4] = c * a11 - s * a01;
out[5] = c * a12 - s * a02;
out[6] = a20;
out[7] = a21;
out[8] = a22;
return out;
};
/**
* Scales the mat3 by the dimensions in the given vec2
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the matrix to rotate
* @param {vec2} v the vec2 to scale the matrix by
* @returns {mat3} out
**/
function scale(out, a, v) {
var x = v[0],
y = v[1];
out[0] = x * a[0];
out[1] = x * a[1];
out[2] = x * a[2];
out[3] = y * a[3];
out[4] = y * a[4];
out[5] = y * a[5];
out[6] = a[6];
out[7] = a[7];
out[8] = a[8];
return out;
}
/**
* Creates a matrix from a vector translation
* This is equivalent to (but much faster than):
*
* mat3.identity(dest);
* mat3.translate(dest, dest, vec);
*
* @param {mat3} out mat3 receiving operation result
* @param {vec2} v Translation vector
* @returns {mat3} out
*/
function fromTranslation(out, v) {
out[0] = 1;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 1;
out[5] = 0;
out[6] = v[0];
out[7] = v[1];
out[8] = 1;
return out;
}
/**
* Creates a matrix from a given angle
* This is equivalent to (but much faster than):
*
* mat3.identity(dest);
* mat3.rotate(dest, dest, rad);
*
* @param {mat3} out mat3 receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat3} out
*/
function fromRotation(out, rad) {
var s = Math.sin(rad),
c = Math.cos(rad);
out[0] = c;
out[1] = s;
out[2] = 0;
out[3] = -s;
out[4] = c;
out[5] = 0;
out[6] = 0;
out[7] = 0;
out[8] = 1;
return out;
}
/**
* Creates a matrix from a vector scaling
* This is equivalent to (but much faster than):
*
* mat3.identity(dest);
* mat3.scale(dest, dest, vec);
*
* @param {mat3} out mat3 receiving operation result
* @param {vec2} v Scaling vector
* @returns {mat3} out
*/
function fromScaling(out, v) {
out[0] = v[0];
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = v[1];
out[5] = 0;
out[6] = 0;
out[7] = 0;
out[8] = 1;
return out;
}
/**
* Copies the values from a mat2d into a mat3
*
* @param {mat3} out the receiving matrix
* @param {mat2d} a the matrix to copy
* @returns {mat3} out
**/
function fromMat2d(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = 0;
out[3] = a[2];
out[4] = a[3];
out[5] = 0;
out[6] = a[4];
out[7] = a[5];
out[8] = 1;
return out;
}
/**
* Calculates a 3x3 matrix from the given quaternion
*
* @param {mat3} out mat3 receiving operation result
* @param {quat} q Quaternion to create matrix from
*
* @returns {mat3} out
*/
function fromQuat(out, q) {
var x = q[0],
y = q[1],
z = q[2],
w = q[3];
var x2 = x + x;
var y2 = y + y;
var z2 = z + z;
var xx = x * x2;
var yx = y * x2;
var yy = y * y2;
var zx = z * x2;
var zy = z * y2;
var zz = z * z2;
var wx = w * x2;
var wy = w * y2;
var wz = w * z2;
out[0] = 1 - yy - zz;
out[3] = yx - wz;
out[6] = zx + wy;
out[1] = yx + wz;
out[4] = 1 - xx - zz;
out[7] = zy - wx;
out[2] = zx - wy;
out[5] = zy + wx;
out[8] = 1 - xx - yy;
return out;
}
/**
* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
*
* @param {mat3} out mat3 receiving operation result
* @param {mat4} a Mat4 to derive the normal matrix from
*
* @returns {mat3} out
*/
function normalFromMat4(out, a) {
var a00 = a[0],
a01 = a[1],
a02 = a[2],
a03 = a[3];
var a10 = a[4],
a11 = a[5],
a12 = a[6],
a13 = a[7];
var a20 = a[8],
a21 = a[9],
a22 = a[10],
a23 = a[11];
var a30 = a[12],
a31 = a[13],
a32 = a[14],
a33 = a[15];
var b00 = a00 * a11 - a01 * a10;
var b01 = a00 * a12 - a02 * a10;
var b02 = a00 * a13 - a03 * a10;
var b03 = a01 * a12 - a02 * a11;
var b04 = a01 * a13 - a03 * a11;
var b05 = a02 * a13 - a03 * a12;
var b06 = a20 * a31 - a21 * a30;
var b07 = a20 * a32 - a22 * a30;
var b08 = a20 * a33 - a23 * a30;
var b09 = a21 * a32 - a22 * a31;
var b10 = a21 * a33 - a23 * a31;
var b11 = a22 * a33 - a23 * a32;
// Calculate the determinant
var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
if (!det) {
return null;
}
det = 1.0 / det;
out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
return out;
}
/**
* Generates a 2D projection matrix with the given bounds
*
* @param {mat3} out mat3 frustum matrix will be written into
* @param {number} width Width of your gl context
* @param {number} height Height of gl context
* @returns {mat3} out
*/
function projection(out, width, height) {
out[0] = 2 / width;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = -2 / height;
out[5] = 0;
out[6] = -1;
out[7] = 1;
out[8] = 1;
return out;
}
/**
* Returns a string representation of a mat3
*
* @param {mat3} a matrix to represent as a string
* @returns {String} string representation of the matrix
*/
function str(a) {
return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ')';
}
/**
* Returns Frobenius norm of a mat3
*
* @param {mat3} a the matrix to calculate Frobenius norm of
* @returns {Number} Frobenius norm
*/
function frob(a) {
return Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2));
}
/**
* Adds two mat3's
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the first operand
* @param {mat3} b the second operand
* @returns {mat3} out
*/
function add(out, a, b) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
out[2] = a[2] + b[2];
out[3] = a[3] + b[3];
out[4] = a[4] + b[4];
out[5] = a[5] + b[5];
out[6] = a[6] + b[6];
out[7] = a[7] + b[7];
out[8] = a[8] + b[8];
return out;
}
/**
* Subtracts matrix b from matrix a
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the first operand
* @param {mat3} b the second operand
* @returns {mat3} out
*/
function subtract(out, a, b) {
out[0] = a[0] - b[0];
out[1] = a[1] - b[1];
out[2] = a[2] - b[2];
out[3] = a[3] - b[3];
out[4] = a[4] - b[4];
out[5] = a[5] - b[5];
out[6] = a[6] - b[6];
out[7] = a[7] - b[7];
out[8] = a[8] - b[8];
return out;
}
/**
* Multiply each element of the matrix by a scalar.
*
* @param {mat3} out the receiving matrix
* @param {mat3} a the matrix to scale
* @param {Number} b amount to scale the matrix's elements by
* @returns {mat3} out
*/
function multiplyScalar(out, a, b) {
out[0] = a[0] * b;
out[1] = a[1] * b;
out[2] = a[2] * b;
out[3] = a[3] * b;
out[4] = a[4] * b;
out[5] = a[5] * b;
out[6] = a[6] * b;
out[7] = a[7] * b;
out[8] = a[8] * b;
return out;
}
/**
* Adds two mat3's after multiplying each element of the second operand by a scalar value.
*
* @param {mat3} out the receiving vector
* @param {mat3} a the first operand
* @param {mat3} b the second operand
* @param {Number} scale the amount to scale b's elements by before adding
* @returns {mat3} out
*/
function multiplyScalarAndAdd(out, a, b, scale) {
out[0] = a[0] + b[0] * scale;
out[1] = a[1] + b[1] * scale;
out[2] = a[2] + b[2] * scale;
out[3] = a[3] + b[3] * scale;
out[4] = a[4] + b[4] * scale;
out[5] = a[5] + b[5] * scale;
out[6] = a[6] + b[6] * scale;
out[7] = a[7] + b[7] * scale;
out[8] = a[8] + b[8] * scale;
return out;
}
/**
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
*
* @param {mat3} a The first matrix.
* @param {mat3} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
function exactEquals(a, b) {
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];
}
/**
* Returns whether or not the matrices have approximately the same elements in the same position.
*
* @param {mat3} a The first matrix.
* @param {mat3} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
function equals(a, b) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3],
a4 = a[4],
a5 = a[5],
a6 = a[6],
a7 = a[7],
a8 = a[8];
var b0 = b[0],
b1 = b[1],
b2 = b[2],
b3 = b[3],
b4 = b[4],
b5 = b[5],
b6 = b[6],
b7 = b[7],
b8 = b[8];
return Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a8), Math.abs(b8));
}
/**
* Alias for {@link mat3.multiply}
* @function
*/
var mul = multiply;
/**
* Alias for {@link mat3.subtract}
* @function
*/
var sub = subtract;
/***/ }),
/***/ "./node_modules/gl-matrix/lib/gl-matrix/mat4.js":
/*!******************************************************!*\
!*** ./node_modules/gl-matrix/lib/gl-matrix/mat4.js ***!
\******************************************************/
/*! exports provided: create, clone, copy, fromValues, set, identity, transpose, invert, adjoint, determinant, multiply, translate, scale, rotate, rotateX, rotateY, rotateZ, fromTranslation, fromScaling, fromRotation, fromXRotation, fromYRotation, fromZRotation, fromRotationTranslation, fromQuat2, getTranslation, getScaling, getRotation, fromRotationTranslationScale, fromRotationTranslationScaleOrigin, fromQuat, frustum, perspective, perspectiveFromFieldOfView, ortho, lookAt, targetTo, str, frob, add, subtract, multiplyScalar, multiplyScalarAndAdd, exactEquals, equals, mul, sub */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transpose", function() { return transpose; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "invert", function() { return invert; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "adjoint", function() { return adjoint; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determinant", function() { return determinant; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "translate", function() { return translate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotate", function() { return rotate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateX", function() { return rotateX; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateY", function() { return rotateY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateZ", function() { return rotateZ; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromTranslation", function() { return fromTranslation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromScaling", function() { return fromScaling; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotation", function() { return fromRotation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromXRotation", function() { return fromXRotation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromYRotation", function() { return fromYRotation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromZRotation", function() { return fromZRotation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotationTranslation", function() { return fromRotationTranslation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromQuat2", function() { return fromQuat2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTranslation", function() { return getTranslation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getScaling", function() { return getScaling; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getRotation", function() { return getRotation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotationTranslationScale", function() { return fromRotationTranslationScale; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotationTranslationScaleOrigin", function() { return fromRotationTranslationScaleOrigin; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromQuat", function() { return fromQuat; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "frustum", function() { return frustum; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "perspective", function() { return perspective; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "perspectiveFromFieldOfView", function() { return perspectiveFromFieldOfView; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ortho", function() { return ortho; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lookAt", function() { return lookAt; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "targetTo", function() { return targetTo; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "frob", function() { return frob; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalar", function() { return multiplyScalar; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiplyScalarAndAdd", function() { return multiplyScalarAndAdd; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/lib/gl-matrix/common.js");
/**
* 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
* @module mat4
*/
/**
* Creates a new identity mat4
*
* @returns {mat4} a new 4x4 matrix
*/
function create() {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](16);
if (_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) {
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 0;
out[6] = 0;
out[7] = 0;
out[8] = 0;
out[9] = 0;
out[11] = 0;
out[12] = 0;
out[13] = 0;
out[14] = 0;
}
out[0] = 1;
out[5] = 1;
out[10] = 1;
out[15] = 1;
return out;
}
/**
* Creates a new mat4 initialized with values from an existing matrix
*
* @param {mat4} a matrix to clone
* @returns {mat4} a new 4x4 matrix
*/
function clone(a) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](16);
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
out[4] = a[4];
out[5] = a[5];
out[6] = a[6];
out[7] = a[7];
out[8] = a[8];
out[9] = a[9];
out[10] = a[10];
out[11] = a[11];
out[12] = a[12];
out[13] = a[13];
out[14] = a[14];
out[15] = a[15];
return out;
}
/**
* Copy the values from one mat4 to another
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the source matrix
* @returns {mat4} out
*/
function copy(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
out[4] = a[4];
out[5] = a[5];
out[6] = a[6];
out[7] = a[7];
out[8] = a[8];
out[9] = a[9];
out[10] = a[10];
out[11] = a[11];
out[12] = a[12];
out[13] = a[13];
out[14] = a[14];
out[15] = a[15];
return out;
}
/**
* Create a new mat4 with the given values
*
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m02 Component in column 0, row 2 position (index 2)
* @param {Number} m03 Component in column 0, row 3 position (index 3)
* @param {Number} m10 Component in column 1, row 0 position (index 4)
* @param {Number} m11 Component in column 1, row 1 position (index 5)
* @param {Number} m12 Component in column 1, row 2 position (index 6)
* @param {Number} m13 Component in column 1, row 3 position (index 7)
* @param {Number} m20 Component in column 2, row 0 position (index 8)
* @param {Number} m21 Component in column 2, row 1 position (index 9)
* @param {Number} m22 Component in column 2, row 2 position (index 10)
* @param {Number} m23 Component in column 2, row 3 position (index 11)
* @param {Number} m30 Component in column 3, row 0 position (index 12)
* @param {Number} m31 Component in column 3, row 1 position (index 13)
* @param {Number} m32 Component in column 3, row 2 position (index 14)
* @param {Number} m33 Component in column 3, row 3 position (index 15)
* @returns {mat4} A new mat4
*/
function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](16);
out[0] = m00;
out[1] = m01;
out[2] = m02;
out[3] = m03;
out[4] = m10;
out[5] = m11;
out[6] = m12;
out[7] = m13;
out[8] = m20;
out[9] = m21;
out[10] = m22;
out[11] = m23;
out[12] = m30;
out[13] = m31;
out[14] = m32;
out[15] = m33;
return out;
}
/**
* Set the components of a mat4 to the given values
*
* @param {mat4} out the receiving matrix
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m02 Component in column 0, row 2 position (index 2)
* @param {Number} m03 Component in column 0, row 3 position (index 3)
* @param {Number} m10 Component in column 1, row 0 position (index 4)
* @param {Number} m11 Component in column 1, row 1 position (index 5)
* @param {Number} m12 Component in column 1, row 2 position (index 6)
* @param {Number} m13 Component in column 1, row 3 position (index 7)
* @param {Number} m20 Component in column 2, row 0 position (index 8)
* @param {Number} m21 Component in column 2, row 1 position (index 9)
* @param {Number} m22 Component in column 2, row 2 position (index 10)
* @param {Number} m23 Component in column 2, row 3 position (index 11)
* @param {Number} m30 Component in column 3, row 0 position (index 12)
* @param {Number} m31 Component in column 3, row 1 position (index 13)
* @param {Number} m32 Component in column 3, row 2 position (index 14)
* @param {Number} m33 Component in column 3, row 3 position (index 15)
* @returns {mat4} out
*/
function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
out[0] = m00;
out[1] = m01;
out[2] = m02;
out[3] = m03;
out[4] = m10;
out[5] = m11;
out[6] = m12;
out[7] = m13;
out[8] = m20;
out[9] = m21;
out[10] = m22;
out[11] = m23;
out[12] = m30;
out[13] = m31;
out[14] = m32;
out[15] = m33;
return out;
}
/**
* Set a mat4 to the identity matrix
*
* @param {mat4} out the receiving matrix
* @returns {mat4} out
*/
function identity(out) {
out[0] = 1;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 0;
out[5] = 1;
out[6] = 0;
out[7] = 0;
out[8] = 0;
out[9] = 0;
out[10] = 1;
out[11] = 0;
out[12] = 0;
out[13] = 0;
out[14] = 0;
out[15] = 1;
return out;
}
/**
* Transpose the values of a mat4
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the source matrix
* @returns {mat4} out
*/
function transpose(out, a) {
// If we are transposing ourselves we can skip a few steps but have to cache some values
if (out === a) {
var a01 = a[1],
a02 = a[2],
a03 = a[3];
var a12 = a[6],
a13 = a[7];
var a23 = a[11];
out[1] = a[4];
out[2] = a[8];
out[3] = a[12];
out[4] = a01;
out[6] = a[9];
out[7] = a[13];
out[8] = a02;
out[9] = a12;
out[11] = a[14];
out[12] = a03;
out[13] = a13;
out[14] = a23;
} else {
out[0] = a[0];
out[1] = a[4];
out[2] = a[8];
out[3] = a[12];
out[4] = a[1];
out[5] = a[5];
out[6] = a[9];
out[7] = a[13];
out[8] = a[2];
out[9] = a[6];
out[10] = a[10];
out[11] = a[14];
out[12] = a[3];
out[13] = a[7];
out[14] = a[11];
out[15] = a[15];
}
return out;
}
/**
* Inverts a mat4
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the source matrix
* @returns {mat4} out
*/
function invert(out, a) {
var a00 = a[0],
a01 = a[1],
a02 = a[2],
a03 = a[3];
var a10 = a[4],
a11 = a[5],
a12 = a[6],
a13 = a[7];
var a20 = a[8],
a21 = a[9],
a22 = a[10],
a23 = a[11];
var a30 = a[12],
a31 = a[13],
a32 = a[14],
a33 = a[15];
var b00 = a00 * a11 - a01 * a10;
var b01 = a00 * a12 - a02 * a10;
var b02 = a00 * a13 - a03 * a10;
var b03 = a01 * a12 - a02 * a11;
var b04 = a01 * a13 - a03 * a11;
var b05 = a02 * a13 - a03 * a12;
var b06 = a20 * a31 - a21 * a30;
var b07 = a20 * a32 - a22 * a30;
var b08 = a20 * a33 - a23 * a30;
var b09 = a21 * a32 - a22 * a31;
var b10 = a21 * a33 - a23 * a31;
var b11 = a22 * a33 - a23 * a32;
// Calculate the determinant
var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
if (!det) {
return null;
}
det = 1.0 / det;
out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
return out;
}
/**
* Calculates the adjugate of a mat4
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the source matrix
* @returns {mat4} out
*/
function adjoint(out, a) {
var a00 = a[0],
a01 = a[1],
a02 = a[2],
a03 = a[3];
var a10 = a[4],
a11 = a[5],
a12 = a[6],
a13 = a[7];
var a20 = a[8],
a21 = a[9],
a22 = a[10],
a23 = a[11];
var a30 = a[12],
a31 = a[13],
a32 = a[14],
a33 = a[15];
out[0] = a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22);
out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22));
out[2] = a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12);
out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12));
out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22));
out[5] = a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22);
out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12));
out[7] = a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12);
out[8] = a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21);
out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21));
out[10] = a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11);
out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11));
out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21));
out[13] = a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21);
out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11));
out[15] = a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11);
return out;
}
/**
* Calculates the determinant of a mat4
*
* @param {mat4} a the source matrix
* @returns {Number} determinant of a
*/
function determinant(a) {
var a00 = a[0],
a01 = a[1],
a02 = a[2],
a03 = a[3];
var a10 = a[4],
a11 = a[5],
a12 = a[6],
a13 = a[7];
var a20 = a[8],
a21 = a[9],
a22 = a[10],
a23 = a[11];
var a30 = a[12],
a31 = a[13],
a32 = a[14],
a33 = a[15];
var b00 = a00 * a11 - a01 * a10;
var b01 = a00 * a12 - a02 * a10;
var b02 = a00 * a13 - a03 * a10;
var b03 = a01 * a12 - a02 * a11;
var b04 = a01 * a13 - a03 * a11;
var b05 = a02 * a13 - a03 * a12;
var b06 = a20 * a31 - a21 * a30;
var b07 = a20 * a32 - a22 * a30;
var b08 = a20 * a33 - a23 * a30;
var b09 = a21 * a32 - a22 * a31;
var b10 = a21 * a33 - a23 * a31;
var b11 = a22 * a33 - a23 * a32;
// Calculate the determinant
return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
}
/**
* Multiplies two mat4s
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the first operand
* @param {mat4} b the second operand
* @returns {mat4} out
*/
function multiply(out, a, b) {
var a00 = a[0],
a01 = a[1],
a02 = a[2],
a03 = a[3];
var a10 = a[4],
a11 = a[5],
a12 = a[6],
a13 = a[7];
var a20 = a[8],
a21 = a[9],
a22 = a[10],
a23 = a[11];
var a30 = a[12],
a31 = a[13],
a32 = a[14],
a33 = a[15];
// Cache only the current line of the second matrix
var b0 = b[0],
b1 = b[1],
b2 = b[2],
b3 = b[3];
out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
b0 = b[4];b1 = b[5];b2 = b[6];b3 = b[7];
out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
b0 = b[8];b1 = b[9];b2 = b[10];b3 = b[11];
out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
b0 = b[12];b1 = b[13];b2 = b[14];b3 = b[15];
out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
return out;
}
/**
* Translate a mat4 by the given vector
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the matrix to translate
* @param {vec3} v vector to translate by
* @returns {mat4} out
*/
function translate(out, a, v) {
var x = v[0],
y = v[1],
z = v[2];
var a00 = void 0,
a01 = void 0,
a02 = void 0,
a03 = void 0;
var a10 = void 0,
a11 = void 0,
a12 = void 0,
a13 = void 0;
var a20 = void 0,
a21 = void 0,
a22 = void 0,
a23 = void 0;
if (a === out) {
out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
} else {
a00 = a[0];a01 = a[1];a02 = a[2];a03 = a[3];
a10 = a[4];a11 = a[5];a12 = a[6];a13 = a[7];
a20 = a[8];a21 = a[9];a22 = a[10];a23 = a[11];
out[0] = a00;out[1] = a01;out[2] = a02;out[3] = a03;
out[4] = a10;out[5] = a11;out[6] = a12;out[7] = a13;
out[8] = a20;out[9] = a21;out[10] = a22;out[11] = a23;
out[12] = a00 * x + a10 * y + a20 * z + a[12];
out[13] = a01 * x + a11 * y + a21 * z + a[13];
out[14] = a02 * x + a12 * y + a22 * z + a[14];
out[15] = a03 * x + a13 * y + a23 * z + a[15];
}
return out;
}
/**
* Scales the mat4 by the dimensions in the given vec3 not using vectorization
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the matrix to scale
* @param {vec3} v the vec3 to scale the matrix by
* @returns {mat4} out
**/
function scale(out, a, v) {
var x = v[0],
y = v[1],
z = v[2];
out[0] = a[0] * x;
out[1] = a[1] * x;
out[2] = a[2] * x;
out[3] = a[3] * x;
out[4] = a[4] * y;
out[5] = a[5] * y;
out[6] = a[6] * y;
out[7] = a[7] * y;
out[8] = a[8] * z;
out[9] = a[9] * z;
out[10] = a[10] * z;
out[11] = a[11] * z;
out[12] = a[12];
out[13] = a[13];
out[14] = a[14];
out[15] = a[15];
return out;
}
/**
* Rotates a mat4 by the given angle around the given axis
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @param {vec3} axis the axis to rotate around
* @returns {mat4} out
*/
function rotate(out, a, rad, axis) {
var x = axis[0],
y = axis[1],
z = axis[2];
var len = Math.sqrt(x * x + y * y + z * z);
var s = void 0,
c = void 0,
t = void 0;
var a00 = void 0,
a01 = void 0,
a02 = void 0,
a03 = void 0;
var a10 = void 0,
a11 = void 0,
a12 = void 0,
a13 = void 0;
var a20 = void 0,
a21 = void 0,
a22 = void 0,
a23 = void 0;
var b00 = void 0,
b01 = void 0,
b02 = void 0;
var b10 = void 0,
b11 = void 0,
b12 = void 0;
var b20 = void 0,
b21 = void 0,
b22 = void 0;
if (len < _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]) {
return null;
}
len = 1 / len;
x *= len;
y *= len;
z *= len;
s = Math.sin(rad);
c = Math.cos(rad);
t = 1 - c;
a00 = a[0];a01 = a[1];a02 = a[2];a03 = a[3];
a10 = a[4];a11 = a[5];a12 = a[6];a13 = a[7];
a20 = a[8];a21 = a[9];a22 = a[10];a23 = a[11];
// Construct the elements of the rotation matrix
b00 = x * x * t + c;b01 = y * x * t + z * s;b02 = z * x * t - y * s;
b10 = x * y * t - z * s;b11 = y * y * t + c;b12 = z * y * t + x * s;
b20 = x * z * t + y * s;b21 = y * z * t - x * s;b22 = z * z * t + c;
// Perform rotation-specific matrix multiplication
out[0] = a00 * b00 + a10 * b01 + a20 * b02;
out[1] = a01 * b00 + a11 * b01 + a21 * b02;
out[2] = a02 * b00 + a12 * b01 + a22 * b02;
out[3] = a03 * b00 + a13 * b01 + a23 * b02;
out[4] = a00 * b10 + a10 * b11 + a20 * b12;
out[5] = a01 * b10 + a11 * b11 + a21 * b12;
out[6] = a02 * b10 + a12 * b11 + a22 * b12;
out[7] = a03 * b10 + a13 * b11 + a23 * b12;
out[8] = a00 * b20 + a10 * b21 + a20 * b22;
out[9] = a01 * b20 + a11 * b21 + a21 * b22;
out[10] = a02 * b20 + a12 * b21 + a22 * b22;
out[11] = a03 * b20 + a13 * b21 + a23 * b22;
if (a !== out) {
// If the source and destination differ, copy the unchanged last row
out[12] = a[12];
out[13] = a[13];
out[14] = a[14];
out[15] = a[15];
}
return out;
}
/**
* Rotates a matrix by the given angle around the X axis
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat4} out
*/
function rotateX(out, a, rad) {
var s = Math.sin(rad);
var c = Math.cos(rad);
var a10 = a[4];
var a11 = a[5];
var a12 = a[6];
var a13 = a[7];
var a20 = a[8];
var a21 = a[9];
var a22 = a[10];
var a23 = a[11];
if (a !== out) {
// If the source and destination differ, copy the unchanged rows
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
out[12] = a[12];
out[13] = a[13];
out[14] = a[14];
out[15] = a[15];
}
// Perform axis-specific matrix multiplication
out[4] = a10 * c + a20 * s;
out[5] = a11 * c + a21 * s;
out[6] = a12 * c + a22 * s;
out[7] = a13 * c + a23 * s;
out[8] = a20 * c - a10 * s;
out[9] = a21 * c - a11 * s;
out[10] = a22 * c - a12 * s;
out[11] = a23 * c - a13 * s;
return out;
}
/**
* Rotates a matrix by the given angle around the Y axis
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat4} out
*/
function rotateY(out, a, rad) {
var s = Math.sin(rad);
var c = Math.cos(rad);
var a00 = a[0];
var a01 = a[1];
var a02 = a[2];
var a03 = a[3];
var a20 = a[8];
var a21 = a[9];
var a22 = a[10];
var a23 = a[11];
if (a !== out) {
// If the source and destination differ, copy the unchanged rows
out[4] = a[4];
out[5] = a[5];
out[6] = a[6];
out[7] = a[7];
out[12] = a[12];
out[13] = a[13];
out[14] = a[14];
out[15] = a[15];
}
// Perform axis-specific matrix multiplication
out[0] = a00 * c - a20 * s;
out[1] = a01 * c - a21 * s;
out[2] = a02 * c - a22 * s;
out[3] = a03 * c - a23 * s;
out[8] = a00 * s + a20 * c;
out[9] = a01 * s + a21 * c;
out[10] = a02 * s + a22 * c;
out[11] = a03 * s + a23 * c;
return out;
}
/**
* Rotates a matrix by the given angle around the Z axis
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat4} out
*/
function rotateZ(out, a, rad) {
var s = Math.sin(rad);
var c = Math.cos(rad);
var a00 = a[0];
var a01 = a[1];
var a02 = a[2];
var a03 = a[3];
var a10 = a[4];
var a11 = a[5];
var a12 = a[6];
var a13 = a[7];
if (a !== out) {
// If the source and destination differ, copy the unchanged last row
out[8] = a[8];
out[9] = a[9];
out[10] = a[10];
out[11] = a[11];
out[12] = a[12];
out[13] = a[13];
out[14] = a[14];
out[15] = a[15];
}
// Perform axis-specific matrix multiplication
out[0] = a00 * c + a10 * s;
out[1] = a01 * c + a11 * s;
out[2] = a02 * c + a12 * s;
out[3] = a03 * c + a13 * s;
out[4] = a10 * c - a00 * s;
out[5] = a11 * c - a01 * s;
out[6] = a12 * c - a02 * s;
out[7] = a13 * c - a03 * s;
return out;
}
/**
* Creates a matrix from a vector translation
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.translate(dest, dest, vec);
*
* @param {mat4} out mat4 receiving operation result
* @param {vec3} v Translation vector
* @returns {mat4} out
*/
function fromTranslation(out, v) {
out[0] = 1;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 0;
out[5] = 1;
out[6] = 0;
out[7] = 0;
out[8] = 0;
out[9] = 0;
out[10] = 1;
out[11] = 0;
out[12] = v[0];
out[13] = v[1];
out[14] = v[2];
out[15] = 1;
return out;
}
/**
* Creates a matrix from a vector scaling
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.scale(dest, dest, vec);
*
* @param {mat4} out mat4 receiving operation result
* @param {vec3} v Scaling vector
* @returns {mat4} out
*/
function fromScaling(out, v) {
out[0] = v[0];
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 0;
out[5] = v[1];
out[6] = 0;
out[7] = 0;
out[8] = 0;
out[9] = 0;
out[10] = v[2];
out[11] = 0;
out[12] = 0;
out[13] = 0;
out[14] = 0;
out[15] = 1;
return out;
}
/**
* Creates a matrix from a given angle around a given axis
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.rotate(dest, dest, rad, axis);
*
* @param {mat4} out mat4 receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @param {vec3} axis the axis to rotate around
* @returns {mat4} out
*/
function fromRotation(out, rad, axis) {
var x = axis[0],
y = axis[1],
z = axis[2];
var len = Math.sqrt(x * x + y * y + z * z);
var s = void 0,
c = void 0,
t = void 0;
if (len < _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]) {
return null;
}
len = 1 / len;
x *= len;
y *= len;
z *= len;
s = Math.sin(rad);
c = Math.cos(rad);
t = 1 - c;
// Perform rotation-specific matrix multiplication
out[0] = x * x * t + c;
out[1] = y * x * t + z * s;
out[2] = z * x * t - y * s;
out[3] = 0;
out[4] = x * y * t - z * s;
out[5] = y * y * t + c;
out[6] = z * y * t + x * s;
out[7] = 0;
out[8] = x * z * t + y * s;
out[9] = y * z * t - x * s;
out[10] = z * z * t + c;
out[11] = 0;
out[12] = 0;
out[13] = 0;
out[14] = 0;
out[15] = 1;
return out;
}
/**
* Creates a matrix from the given angle around the X axis
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.rotateX(dest, dest, rad);
*
* @param {mat4} out mat4 receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat4} out
*/
function fromXRotation(out, rad) {
var s = Math.sin(rad);
var c = Math.cos(rad);
// Perform axis-specific matrix multiplication
out[0] = 1;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 0;
out[5] = c;
out[6] = s;
out[7] = 0;
out[8] = 0;
out[9] = -s;
out[10] = c;
out[11] = 0;
out[12] = 0;
out[13] = 0;
out[14] = 0;
out[15] = 1;
return out;
}
/**
* Creates a matrix from the given angle around the Y axis
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.rotateY(dest, dest, rad);
*
* @param {mat4} out mat4 receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat4} out
*/
function fromYRotation(out, rad) {
var s = Math.sin(rad);
var c = Math.cos(rad);
// Perform axis-specific matrix multiplication
out[0] = c;
out[1] = 0;
out[2] = -s;
out[3] = 0;
out[4] = 0;
out[5] = 1;
out[6] = 0;
out[7] = 0;
out[8] = s;
out[9] = 0;
out[10] = c;
out[11] = 0;
out[12] = 0;
out[13] = 0;
out[14] = 0;
out[15] = 1;
return out;
}
/**
* Creates a matrix from the given angle around the Z axis
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.rotateZ(dest, dest, rad);
*
* @param {mat4} out mat4 receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat4} out
*/
function fromZRotation(out, rad) {
var s = Math.sin(rad);
var c = Math.cos(rad);
// Perform axis-specific matrix multiplication
out[0] = c;
out[1] = s;
out[2] = 0;
out[3] = 0;
out[4] = -s;
out[5] = c;
out[6] = 0;
out[7] = 0;
out[8] = 0;
out[9] = 0;
out[10] = 1;
out[11] = 0;
out[12] = 0;
out[13] = 0;
out[14] = 0;
out[15] = 1;
return out;
}
/**
* Creates a matrix from a quaternion rotation and vector translation
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.translate(dest, vec);
* let quatMat = mat4.create();
* quat4.toMat4(quat, quatMat);
* mat4.multiply(dest, quatMat);
*
* @param {mat4} out mat4 receiving operation result
* @param {quat4} q Rotation quaternion
* @param {vec3} v Translation vector
* @returns {mat4} out
*/
function fromRotationTranslation(out, q, v) {
// Quaternion math
var x = q[0],
y = q[1],
z = q[2],
w = q[3];
var x2 = x + x;
var y2 = y + y;
var z2 = z + z;
var xx = x * x2;
var xy = x * y2;
var xz = x * z2;
var yy = y * y2;
var yz = y * z2;
var zz = z * z2;
var wx = w * x2;
var wy = w * y2;
var wz = w * z2;
out[0] = 1 - (yy + zz);
out[1] = xy + wz;
out[2] = xz - wy;
out[3] = 0;
out[4] = xy - wz;
out[5] = 1 - (xx + zz);
out[6] = yz + wx;
out[7] = 0;
out[8] = xz + wy;
out[9] = yz - wx;
out[10] = 1 - (xx + yy);
out[11] = 0;
out[12] = v[0];
out[13] = v[1];
out[14] = v[2];
out[15] = 1;
return out;
}
/**
* Creates a new mat4 from a dual quat.
*
* @param {mat4} out Matrix
* @param {quat2} a Dual Quaternion
* @returns {mat4} mat4 receiving operation result
*/
function fromQuat2(out, a) {
var translation = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](3);
var bx = -a[0],
by = -a[1],
bz = -a[2],
bw = a[3],
ax = a[4],
ay = a[5],
az = a[6],
aw = a[7];
var magnitude = bx * bx + by * by + bz * bz + bw * bw;
//Only scale if it makes sense
if (magnitude > 0) {
translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude;
translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude;
translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude;
} else {
translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;
translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;
translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;
}
fromRotationTranslation(out, a, translation);
return out;
}
/**
* Returns the translation vector component of a transformation
* matrix. If a matrix is built with fromRotationTranslation,
* the returned vector will be the same as the translation vector
* originally supplied.
* @param {vec3} out Vector to receive translation component
* @param {mat4} mat Matrix to be decomposed (input)
* @return {vec3} out
*/
function getTranslation(out, mat) {
out[0] = mat[12];
out[1] = mat[13];
out[2] = mat[14];
return out;
}
/**
* Returns the scaling factor component of a transformation
* matrix. If a matrix is built with fromRotationTranslationScale
* with a normalized Quaternion paramter, the returned vector will be
* the same as the scaling vector
* originally supplied.
* @param {vec3} out Vector to receive scaling factor component
* @param {mat4} mat Matrix to be decomposed (input)
* @return {vec3} out
*/
function getScaling(out, mat) {
var m11 = mat[0];
var m12 = mat[1];
var m13 = mat[2];
var m21 = mat[4];
var m22 = mat[5];
var m23 = mat[6];
var m31 = mat[8];
var m32 = mat[9];
var m33 = mat[10];
out[0] = Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13);
out[1] = Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23);
out[2] = Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33);
return out;
}
/**
* Returns a quaternion representing the rotational component
* of a transformation matrix. If a matrix is built with
* fromRotationTranslation, the returned quaternion will be the
* same as the quaternion originally supplied.
* @param {quat} out Quaternion to receive the rotation component
* @param {mat4} mat Matrix to be decomposed (input)
* @return {quat} out
*/
function getRotation(out, mat) {
// Algorithm taken from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
var trace = mat[0] + mat[5] + mat[10];
var S = 0;
if (trace > 0) {
S = Math.sqrt(trace + 1.0) * 2;
out[3] = 0.25 * S;
out[0] = (mat[6] - mat[9]) / S;
out[1] = (mat[8] - mat[2]) / S;
out[2] = (mat[1] - mat[4]) / S;
} else if (mat[0] > mat[5] && mat[0] > mat[10]) {
S = Math.sqrt(1.0 + mat[0] - mat[5] - mat[10]) * 2;
out[3] = (mat[6] - mat[9]) / S;
out[0] = 0.25 * S;
out[1] = (mat[1] + mat[4]) / S;
out[2] = (mat[8] + mat[2]) / S;
} else if (mat[5] > mat[10]) {
S = Math.sqrt(1.0 + mat[5] - mat[0] - mat[10]) * 2;
out[3] = (mat[8] - mat[2]) / S;
out[0] = (mat[1] + mat[4]) / S;
out[1] = 0.25 * S;
out[2] = (mat[6] + mat[9]) / S;
} else {
S = Math.sqrt(1.0 + mat[10] - mat[0] - mat[5]) * 2;
out[3] = (mat[1] - mat[4]) / S;
out[0] = (mat[8] + mat[2]) / S;
out[1] = (mat[6] + mat[9]) / S;
out[2] = 0.25 * S;
}
return out;
}
/**
* Creates a matrix from a quaternion rotation, vector translation and vector scale
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.translate(dest, vec);
* let quatMat = mat4.create();
* quat4.toMat4(quat, quatMat);
* mat4.multiply(dest, quatMat);
* mat4.scale(dest, scale)
*
* @param {mat4} out mat4 receiving operation result
* @param {quat4} q Rotation quaternion
* @param {vec3} v Translation vector
* @param {vec3} s Scaling vector
* @returns {mat4} out
*/
function fromRotationTranslationScale(out, q, v, s) {
// Quaternion math
var x = q[0],
y = q[1],
z = q[2],
w = q[3];
var x2 = x + x;
var y2 = y + y;
var z2 = z + z;
var xx = x * x2;
var xy = x * y2;
var xz = x * z2;
var yy = y * y2;
var yz = y * z2;
var zz = z * z2;
var wx = w * x2;
var wy = w * y2;
var wz = w * z2;
var sx = s[0];
var sy = s[1];
var sz = s[2];
out[0] = (1 - (yy + zz)) * sx;
out[1] = (xy + wz) * sx;
out[2] = (xz - wy) * sx;
out[3] = 0;
out[4] = (xy - wz) * sy;
out[5] = (1 - (xx + zz)) * sy;
out[6] = (yz + wx) * sy;
out[7] = 0;
out[8] = (xz + wy) * sz;
out[9] = (yz - wx) * sz;
out[10] = (1 - (xx + yy)) * sz;
out[11] = 0;
out[12] = v[0];
out[13] = v[1];
out[14] = v[2];
out[15] = 1;
return out;
}
/**
* Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.translate(dest, vec);
* mat4.translate(dest, origin);
* let quatMat = mat4.create();
* quat4.toMat4(quat, quatMat);
* mat4.multiply(dest, quatMat);
* mat4.scale(dest, scale)
* mat4.translate(dest, negativeOrigin);
*
* @param {mat4} out mat4 receiving operation result
* @param {quat4} q Rotation quaternion
* @param {vec3} v Translation vector
* @param {vec3} s Scaling vector
* @param {vec3} o The origin vector around which to scale and rotate
* @returns {mat4} out
*/
function fromRotationTranslationScaleOrigin(out, q, v, s, o) {
// Quaternion math
var x = q[0],
y = q[1],
z = q[2],
w = q[3];
var x2 = x + x;
var y2 = y + y;
var z2 = z + z;
var xx = x * x2;
var xy = x * y2;
var xz = x * z2;
var yy = y * y2;
var yz = y * z2;
var zz = z * z2;
var wx = w * x2;
var wy = w * y2;
var wz = w * z2;
var sx = s[0];
var sy = s[1];
var sz = s[2];
var ox = o[0];
var oy = o[1];
var oz = o[2];
var out0 = (1 - (yy + zz)) * sx;
var out1 = (xy + wz) * sx;
var out2 = (xz - wy) * sx;
var out4 = (xy - wz) * sy;
var out5 = (1 - (xx + zz)) * sy;
var out6 = (yz + wx) * sy;
var out8 = (xz + wy) * sz;
var out9 = (yz - wx) * sz;
var out10 = (1 - (xx + yy)) * sz;
out[0] = out0;
out[1] = out1;
out[2] = out2;
out[3] = 0;
out[4] = out4;
out[5] = out5;
out[6] = out6;
out[7] = 0;
out[8] = out8;
out[9] = out9;
out[10] = out10;
out[11] = 0;
out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz);
out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz);
out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz);
out[15] = 1;
return out;
}
/**
* Calculates a 4x4 matrix from the given quaternion
*
* @param {mat4} out mat4 receiving operation result
* @param {quat} q Quaternion to create matrix from
*
* @returns {mat4} out
*/
function fromQuat(out, q) {
var x = q[0],
y = q[1],
z = q[2],
w = q[3];
var x2 = x + x;
var y2 = y + y;
var z2 = z + z;
var xx = x * x2;
var yx = y * x2;
var yy = y * y2;
var zx = z * x2;
var zy = z * y2;
var zz = z * z2;
var wx = w * x2;
var wy = w * y2;
var wz = w * z2;
out[0] = 1 - yy - zz;
out[1] = yx + wz;
out[2] = zx - wy;
out[3] = 0;
out[4] = yx - wz;
out[5] = 1 - xx - zz;
out[6] = zy + wx;
out[7] = 0;
out[8] = zx + wy;
out[9] = zy - wx;
out[10] = 1 - xx - yy;
out[11] = 0;
out[12] = 0;
out[13] = 0;
out[14] = 0;
out[15] = 1;
return out;
}
/**
* Generates a frustum matrix with the given bounds
*
* @param {mat4} out mat4 frustum matrix will be written into
* @param {Number} left Left bound of the frustum
* @param {Number} right Right bound of the frustum
* @param {Number} bottom Bottom bound of the frustum
* @param {Number} top Top bound of the frustum
* @param {Number} near Near bound of the frustum
* @param {Number} far Far bound of the frustum
* @returns {mat4} out
*/
function frustum(out, left, right, bottom, top, near, far) {
var rl = 1 / (right - left);
var tb = 1 / (top - bottom);
var nf = 1 / (near - far);
out[0] = near * 2 * rl;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 0;
out[5] = near * 2 * tb;
out[6] = 0;
out[7] = 0;
out[8] = (right + left) * rl;
out[9] = (top + bottom) * tb;
out[10] = (far + near) * nf;
out[11] = -1;
out[12] = 0;
out[13] = 0;
out[14] = far * near * 2 * nf;
out[15] = 0;
return out;
}
/**
* Generates a perspective projection matrix with the given bounds.
* Passing null/undefined/no value for far will generate infinite projection matrix.
*
* @param {mat4} out mat4 frustum matrix will be written into
* @param {number} fovy Vertical field of view in radians
* @param {number} aspect Aspect ratio. typically viewport width/height
* @param {number} near Near bound of the frustum
* @param {number} far Far bound of the frustum, can be null or Infinity
* @returns {mat4} out
*/
function perspective(out, fovy, aspect, near, far) {
var f = 1.0 / Math.tan(fovy / 2),
nf = void 0;
out[0] = f / aspect;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 0;
out[5] = f;
out[6] = 0;
out[7] = 0;
out[8] = 0;
out[9] = 0;
out[11] = -1;
out[12] = 0;
out[13] = 0;
out[15] = 0;
if (far != null && far !== Infinity) {
nf = 1 / (near - far);
out[10] = (far + near) * nf;
out[14] = 2 * far * near * nf;
} else {
out[10] = -1;
out[14] = -2 * near;
}
return out;
}
/**
* Generates a perspective projection matrix with the given field of view.
* This is primarily useful for generating projection matrices to be used
* with the still experiemental WebVR API.
*
* @param {mat4} out mat4 frustum matrix will be written into
* @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees
* @param {number} near Near bound of the frustum
* @param {number} far Far bound of the frustum
* @returns {mat4} out
*/
function perspectiveFromFieldOfView(out, fov, near, far) {
var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
var xScale = 2.0 / (leftTan + rightTan);
var yScale = 2.0 / (upTan + downTan);
out[0] = xScale;
out[1] = 0.0;
out[2] = 0.0;
out[3] = 0.0;
out[4] = 0.0;
out[5] = yScale;
out[6] = 0.0;
out[7] = 0.0;
out[8] = -((leftTan - rightTan) * xScale * 0.5);
out[9] = (upTan - downTan) * yScale * 0.5;
out[10] = far / (near - far);
out[11] = -1.0;
out[12] = 0.0;
out[13] = 0.0;
out[14] = far * near / (near - far);
out[15] = 0.0;
return out;
}
/**
* Generates a orthogonal projection matrix with the given bounds
*
* @param {mat4} out mat4 frustum matrix will be written into
* @param {number} left Left bound of the frustum
* @param {number} right Right bound of the frustum
* @param {number} bottom Bottom bound of the frustum
* @param {number} top Top bound of the frustum
* @param {number} near Near bound of the frustum
* @param {number} far Far bound of the frustum
* @returns {mat4} out
*/
function ortho(out, left, right, bottom, top, near, far) {
var lr = 1 / (left - right);
var bt = 1 / (bottom - top);
var nf = 1 / (near - far);
out[0] = -2 * lr;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 0;
out[5] = -2 * bt;
out[6] = 0;
out[7] = 0;
out[8] = 0;
out[9] = 0;
out[10] = 2 * nf;
out[11] = 0;
out[12] = (left + right) * lr;
out[13] = (top + bottom) * bt;
out[14] = (far + near) * nf;
out[15] = 1;
return out;
}
/**
* Generates a look-at matrix with the given eye position, focal point, and up axis.
* If you want a matrix that actually makes an object look at another object, you should use targetTo instead.
*
* @param {mat4} out mat4 frustum matrix will be written into
* @param {vec3} eye Position of the viewer
* @param {vec3} center Point the viewer is looking at
* @param {vec3} up vec3 pointing up
* @returns {mat4} out
*/
function lookAt(out, eye, center, up) {
var x0 = void 0,
x1 = void 0,
x2 = void 0,
y0 = void 0,
y1 = void 0,
y2 = void 0,
z0 = void 0,
z1 = void 0,
z2 = void 0,
len = void 0;
var eyex = eye[0];
var eyey = eye[1];
var eyez = eye[2];
var upx = up[0];
var upy = up[1];
var upz = up[2];
var centerx = center[0];
var centery = center[1];
var centerz = center[2];
if (Math.abs(eyex - centerx) < _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] && Math.abs(eyey - centery) < _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] && Math.abs(eyez - centerz) < _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]) {
return identity(out);
}
z0 = eyex - centerx;
z1 = eyey - centery;
z2 = eyez - centerz;
len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);
z0 *= len;
z1 *= len;
z2 *= len;
x0 = upy * z2 - upz * z1;
x1 = upz * z0 - upx * z2;
x2 = upx * z1 - upy * z0;
len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
if (!len) {
x0 = 0;
x1 = 0;
x2 = 0;
} else {
len = 1 / len;
x0 *= len;
x1 *= len;
x2 *= len;
}
y0 = z1 * x2 - z2 * x1;
y1 = z2 * x0 - z0 * x2;
y2 = z0 * x1 - z1 * x0;
len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);
if (!len) {
y0 = 0;
y1 = 0;
y2 = 0;
} else {
len = 1 / len;
y0 *= len;
y1 *= len;
y2 *= len;
}
out[0] = x0;
out[1] = y0;
out[2] = z0;
out[3] = 0;
out[4] = x1;
out[5] = y1;
out[6] = z1;
out[7] = 0;
out[8] = x2;
out[9] = y2;
out[10] = z2;
out[11] = 0;
out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);
out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);
out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);
out[15] = 1;
return out;
}
/**
* Generates a matrix that makes something look at something else.
*
* @param {mat4} out mat4 frustum matrix will be written into
* @param {vec3} eye Position of the viewer
* @param {vec3} center Point the viewer is looking at
* @param {vec3} up vec3 pointing up
* @returns {mat4} out
*/
function targetTo(out, eye, target, up) {
var eyex = eye[0],
eyey = eye[1],
eyez = eye[2],
upx = up[0],
upy = up[1],
upz = up[2];
var z0 = eyex - target[0],
z1 = eyey - target[1],
z2 = eyez - target[2];
var len = z0 * z0 + z1 * z1 + z2 * z2;
if (len > 0) {
len = 1 / Math.sqrt(len);
z0 *= len;
z1 *= len;
z2 *= len;
}
var x0 = upy * z2 - upz * z1,
x1 = upz * z0 - upx * z2,
x2 = upx * z1 - upy * z0;
len = x0 * x0 + x1 * x1 + x2 * x2;
if (len > 0) {
len = 1 / Math.sqrt(len);
x0 *= len;
x1 *= len;
x2 *= len;
}
out[0] = x0;
out[1] = x1;
out[2] = x2;
out[3] = 0;
out[4] = z1 * x2 - z2 * x1;
out[5] = z2 * x0 - z0 * x2;
out[6] = z0 * x1 - z1 * x0;
out[7] = 0;
out[8] = z0;
out[9] = z1;
out[10] = z2;
out[11] = 0;
out[12] = eyex;
out[13] = eyey;
out[14] = eyez;
out[15] = 1;
return out;
};
/**
* Returns a string representation of a mat4
*
* @param {mat4} a matrix to represent as a string
* @returns {String} string representation of the matrix
*/
function str(a) {
return 'mat4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ', ' + a[9] + ', ' + a[10] + ', ' + a[11] + ', ' + a[12] + ', ' + a[13] + ', ' + a[14] + ', ' + a[15] + ')';
}
/**
* Returns Frobenius norm of a mat4
*
* @param {mat4} a the matrix to calculate Frobenius norm of
* @returns {Number} Frobenius norm
*/
function frob(a) {
return Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2) + Math.pow(a[9], 2) + Math.pow(a[10], 2) + Math.pow(a[11], 2) + Math.pow(a[12], 2) + Math.pow(a[13], 2) + Math.pow(a[14], 2) + Math.pow(a[15], 2));
}
/**
* Adds two mat4's
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the first operand
* @param {mat4} b the second operand
* @returns {mat4} out
*/
function add(out, a, b) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
out[2] = a[2] + b[2];
out[3] = a[3] + b[3];
out[4] = a[4] + b[4];
out[5] = a[5] + b[5];
out[6] = a[6] + b[6];
out[7] = a[7] + b[7];
out[8] = a[8] + b[8];
out[9] = a[9] + b[9];
out[10] = a[10] + b[10];
out[11] = a[11] + b[11];
out[12] = a[12] + b[12];
out[13] = a[13] + b[13];
out[14] = a[14] + b[14];
out[15] = a[15] + b[15];
return out;
}
/**
* Subtracts matrix b from matrix a
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the first operand
* @param {mat4} b the second operand
* @returns {mat4} out
*/
function subtract(out, a, b) {
out[0] = a[0] - b[0];
out[1] = a[1] - b[1];
out[2] = a[2] - b[2];
out[3] = a[3] - b[3];
out[4] = a[4] - b[4];
out[5] = a[5] - b[5];
out[6] = a[6] - b[6];
out[7] = a[7] - b[7];
out[8] = a[8] - b[8];
out[9] = a[9] - b[9];
out[10] = a[10] - b[10];
out[11] = a[11] - b[11];
out[12] = a[12] - b[12];
out[13] = a[13] - b[13];
out[14] = a[14] - b[14];
out[15] = a[15] - b[15];
return out;
}
/**
* Multiply each element of the matrix by a scalar.
*
* @param {mat4} out the receiving matrix
* @param {mat4} a the matrix to scale
* @param {Number} b amount to scale the matrix's elements by
* @returns {mat4} out
*/
function multiplyScalar(out, a, b) {
out[0] = a[0] * b;
out[1] = a[1] * b;
out[2] = a[2] * b;
out[3] = a[3] * b;
out[4] = a[4] * b;
out[5] = a[5] * b;
out[6] = a[6] * b;
out[7] = a[7] * b;
out[8] = a[8] * b;
out[9] = a[9] * b;
out[10] = a[10] * b;
out[11] = a[11] * b;
out[12] = a[12] * b;
out[13] = a[13] * b;
out[14] = a[14] * b;
out[15] = a[15] * b;
return out;
}
/**
* Adds two mat4's after multiplying each element of the second operand by a scalar value.
*
* @param {mat4} out the receiving vector
* @param {mat4} a the first operand
* @param {mat4} b the second operand
* @param {Number} scale the amount to scale b's elements by before adding
* @returns {mat4} out
*/
function multiplyScalarAndAdd(out, a, b, scale) {
out[0] = a[0] + b[0] * scale;
out[1] = a[1] + b[1] * scale;
out[2] = a[2] + b[2] * scale;
out[3] = a[3] + b[3] * scale;
out[4] = a[4] + b[4] * scale;
out[5] = a[5] + b[5] * scale;
out[6] = a[6] + b[6] * scale;
out[7] = a[7] + b[7] * scale;
out[8] = a[8] + b[8] * scale;
out[9] = a[9] + b[9] * scale;
out[10] = a[10] + b[10] * scale;
out[11] = a[11] + b[11] * scale;
out[12] = a[12] + b[12] * scale;
out[13] = a[13] + b[13] * scale;
out[14] = a[14] + b[14] * scale;
out[15] = a[15] + b[15] * scale;
return out;
}
/**
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
*
* @param {mat4} a The first matrix.
* @param {mat4} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
function exactEquals(a, b) {
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15];
}
/**
* Returns whether or not the matrices have approximately the same elements in the same position.
*
* @param {mat4} a The first matrix.
* @param {mat4} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
function equals(a, b) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3];
var a4 = a[4],
a5 = a[5],
a6 = a[6],
a7 = a[7];
var a8 = a[8],
a9 = a[9],
a10 = a[10],
a11 = a[11];
var a12 = a[12],
a13 = a[13],
a14 = a[14],
a15 = a[15];
var b0 = b[0],
b1 = b[1],
b2 = b[2],
b3 = b[3];
var b4 = b[4],
b5 = b[5],
b6 = b[6],
b7 = b[7];
var b8 = b[8],
b9 = b[9],
b10 = b[10],
b11 = b[11];
var b12 = b[12],
b13 = b[13],
b14 = b[14],
b15 = b[15];
return Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a8), Math.abs(b8)) && Math.abs(a9 - b9) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a9), Math.abs(b9)) && Math.abs(a10 - b10) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a10), Math.abs(b10)) && Math.abs(a11 - b11) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a11), Math.abs(b11)) && Math.abs(a12 - b12) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a12), Math.abs(b12)) && Math.abs(a13 - b13) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a13), Math.abs(b13)) && Math.abs(a14 - b14) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a14), Math.abs(b14)) && Math.abs(a15 - b15) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a15), Math.abs(b15));
}
/**
* Alias for {@link mat4.multiply}
* @function
*/
var mul = multiply;
/**
* Alias for {@link mat4.subtract}
* @function
*/
var sub = subtract;
/***/ }),
/***/ "./node_modules/gl-matrix/lib/gl-matrix/quat.js":
/*!******************************************************!*\
!*** ./node_modules/gl-matrix/lib/gl-matrix/quat.js ***!
\******************************************************/
/*! exports provided: create, identity, setAxisAngle, getAxisAngle, multiply, rotateX, rotateY, rotateZ, calculateW, slerp, random, invert, conjugate, fromMat3, fromEuler, str, clone, fromValues, copy, set, add, mul, scale, dot, lerp, length, len, squaredLength, sqrLen, normalize, exactEquals, equals, rotationTo, sqlerp, setAxes */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setAxisAngle", function() { return setAxisAngle; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAxisAngle", function() { return getAxisAngle; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateX", function() { return rotateX; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateY", function() { return rotateY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateZ", function() { return rotateZ; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "calculateW", function() { return calculateW; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "slerp", function() { return slerp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "random", function() { return random; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "invert", function() { return invert; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "conjugate", function() { return conjugate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromMat3", function() { return fromMat3; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromEuler", function() { return fromEuler; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dot", function() { return dot; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lerp", function() { return lerp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "length", function() { return length; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredLength", function() { return squaredLength; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalize", function() { return normalize; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotationTo", function() { return rotationTo; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqlerp", function() { return sqlerp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setAxes", function() { return setAxes; });
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/lib/gl-matrix/common.js");
/* harmony import */ var _mat3_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mat3.js */ "./node_modules/gl-matrix/lib/gl-matrix/mat3.js");
/* harmony import */ var _vec3_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vec3.js */ "./node_modules/gl-matrix/lib/gl-matrix/vec3.js");
/* harmony import */ var _vec4_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vec4.js */ "./node_modules/gl-matrix/lib/gl-matrix/vec4.js");
/**
* Quaternion
* @module quat
*/
/**
* Creates a new identity quat
*
* @returns {quat} a new quaternion
*/
function create() {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4);
if (_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) {
out[0] = 0;
out[1] = 0;
out[2] = 0;
}
out[3] = 1;
return out;
}
/**
* Set a quat to the identity quaternion
*
* @param {quat} out the receiving quaternion
* @returns {quat} out
*/
function identity(out) {
out[0] = 0;
out[1] = 0;
out[2] = 0;
out[3] = 1;
return out;
}
/**
* Sets a quat from the given angle and rotation axis,
* then returns it.
*
* @param {quat} out the receiving quaternion
* @param {vec3} axis the axis around which to rotate
* @param {Number} rad the angle in radians
* @returns {quat} out
**/
function setAxisAngle(out, axis, rad) {
rad = rad * 0.5;
var s = Math.sin(rad);
out[0] = s * axis[0];
out[1] = s * axis[1];
out[2] = s * axis[2];
out[3] = Math.cos(rad);
return out;
}
/**
* Gets the rotation axis and angle for a given
* quaternion. If a quaternion is created with
* setAxisAngle, this method will return the same
* values as providied in the original parameter list
* OR functionally equivalent values.
* Example: The quaternion formed by axis [0, 0, 1] and
* angle -90 is the same as the quaternion formed by
* [0, 0, 1] and 270. This method favors the latter.
* @param {vec3} out_axis Vector receiving the axis of rotation
* @param {quat} q Quaternion to be decomposed
* @return {Number} Angle, in radians, of the rotation
*/
function getAxisAngle(out_axis, q) {
var rad = Math.acos(q[3]) * 2.0;
var s = Math.sin(rad / 2.0);
if (s > _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]) {
out_axis[0] = q[0] / s;
out_axis[1] = q[1] / s;
out_axis[2] = q[2] / s;
} else {
// If s is zero, return any axis (no rotation - axis does not matter)
out_axis[0] = 1;
out_axis[1] = 0;
out_axis[2] = 0;
}
return rad;
}
/**
* Multiplies two quat's
*
* @param {quat} out the receiving quaternion
* @param {quat} a the first operand
* @param {quat} b the second operand
* @returns {quat} out
*/
function multiply(out, a, b) {
var ax = a[0],
ay = a[1],
az = a[2],
aw = a[3];
var bx = b[0],
by = b[1],
bz = b[2],
bw = b[3];
out[0] = ax * bw + aw * bx + ay * bz - az * by;
out[1] = ay * bw + aw * by + az * bx - ax * bz;
out[2] = az * bw + aw * bz + ax * by - ay * bx;
out[3] = aw * bw - ax * bx - ay * by - az * bz;
return out;
}
/**
* Rotates a quaternion by the given angle about the X axis
*
* @param {quat} out quat receiving operation result
* @param {quat} a quat to rotate
* @param {number} rad angle (in radians) to rotate
* @returns {quat} out
*/
function rotateX(out, a, rad) {
rad *= 0.5;
var ax = a[0],
ay = a[1],
az = a[2],
aw = a[3];
var bx = Math.sin(rad),
bw = Math.cos(rad);
out[0] = ax * bw + aw * bx;
out[1] = ay * bw + az * bx;
out[2] = az * bw - ay * bx;
out[3] = aw * bw - ax * bx;
return out;
}
/**
* Rotates a quaternion by the given angle about the Y axis
*
* @param {quat} out quat receiving operation result
* @param {quat} a quat to rotate
* @param {number} rad angle (in radians) to rotate
* @returns {quat} out
*/
function rotateY(out, a, rad) {
rad *= 0.5;
var ax = a[0],
ay = a[1],
az = a[2],
aw = a[3];
var by = Math.sin(rad),
bw = Math.cos(rad);
out[0] = ax * bw - az * by;
out[1] = ay * bw + aw * by;
out[2] = az * bw + ax * by;
out[3] = aw * bw - ay * by;
return out;
}
/**
* Rotates a quaternion by the given angle about the Z axis
*
* @param {quat} out quat receiving operation result
* @param {quat} a quat to rotate
* @param {number} rad angle (in radians) to rotate
* @returns {quat} out
*/
function rotateZ(out, a, rad) {
rad *= 0.5;
var ax = a[0],
ay = a[1],
az = a[2],
aw = a[3];
var bz = Math.sin(rad),
bw = Math.cos(rad);
out[0] = ax * bw + ay * bz;
out[1] = ay * bw - ax * bz;
out[2] = az * bw + aw * bz;
out[3] = aw * bw - az * bz;
return out;
}
/**
* Calculates the W component of a quat from the X, Y, and Z components.
* Assumes that quaternion is 1 unit in length.
* Any existing W component will be ignored.
*
* @param {quat} out the receiving quaternion
* @param {quat} a quat to calculate W component of
* @returns {quat} out
*/
function calculateW(out, a) {
var x = a[0],
y = a[1],
z = a[2];
out[0] = x;
out[1] = y;
out[2] = z;
out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z));
return out;
}
/**
* Performs a spherical linear interpolation between two quat
*
* @param {quat} out the receiving quaternion
* @param {quat} a the first operand
* @param {quat} b the second operand
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
* @returns {quat} out
*/
function slerp(out, a, b, t) {
// benchmarks:
// http://jsperf.com/quaternion-slerp-implementations
var ax = a[0],
ay = a[1],
az = a[2],
aw = a[3];
var bx = b[0],
by = b[1],
bz = b[2],
bw = b[3];
var omega = void 0,
cosom = void 0,
sinom = void 0,
scale0 = void 0,
scale1 = void 0;
// calc cosine
cosom = ax * bx + ay * by + az * bz + aw * bw;
// adjust signs (if necessary)
if (cosom < 0.0) {
cosom = -cosom;
bx = -bx;
by = -by;
bz = -bz;
bw = -bw;
}
// calculate coefficients
if (1.0 - cosom > _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]) {
// standard case (slerp)
omega = Math.acos(cosom);
sinom = Math.sin(omega);
scale0 = Math.sin((1.0 - t) * omega) / sinom;
scale1 = Math.sin(t * omega) / sinom;
} else {
// "from" and "to" quaternions are very close
// ... so we can do a linear interpolation
scale0 = 1.0 - t;
scale1 = t;
}
// calculate final values
out[0] = scale0 * ax + scale1 * bx;
out[1] = scale0 * ay + scale1 * by;
out[2] = scale0 * az + scale1 * bz;
out[3] = scale0 * aw + scale1 * bw;
return out;
}
/**
* Generates a random quaternion
*
* @param {quat} out the receiving quaternion
* @returns {quat} out
*/
function random(out) {
// Implementation of http://planning.cs.uiuc.edu/node198.html
// TODO: Calling random 3 times is probably not the fastest solution
var u1 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]();
var u2 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]();
var u3 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]();
var sqrt1MinusU1 = Math.sqrt(1 - u1);
var sqrtU1 = Math.sqrt(u1);
out[0] = sqrt1MinusU1 * Math.sin(2.0 * Math.PI * u2);
out[1] = sqrt1MinusU1 * Math.cos(2.0 * Math.PI * u2);
out[2] = sqrtU1 * Math.sin(2.0 * Math.PI * u3);
out[3] = sqrtU1 * Math.cos(2.0 * Math.PI * u3);
return out;
}
/**
* Calculates the inverse of a quat
*
* @param {quat} out the receiving quaternion
* @param {quat} a quat to calculate inverse of
* @returns {quat} out
*/
function invert(out, a) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3];
var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3;
var invDot = dot ? 1.0 / dot : 0;
// TODO: Would be faster to return [0,0,0,0] immediately if dot == 0
out[0] = -a0 * invDot;
out[1] = -a1 * invDot;
out[2] = -a2 * invDot;
out[3] = a3 * invDot;
return out;
}
/**
* Calculates the conjugate of a quat
* If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.
*
* @param {quat} out the receiving quaternion
* @param {quat} a quat to calculate conjugate of
* @returns {quat} out
*/
function conjugate(out, a) {
out[0] = -a[0];
out[1] = -a[1];
out[2] = -a[2];
out[3] = a[3];
return out;
}
/**
* Creates a quaternion from the given 3x3 rotation matrix.
*
* NOTE: The resultant quaternion is not normalized, so you should be sure
* to renormalize the quaternion yourself where necessary.
*
* @param {quat} out the receiving quaternion
* @param {mat3} m rotation matrix
* @returns {quat} out
* @function
*/
function fromMat3(out, m) {
// Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
// article "Quaternion Calculus and Fast Animation".
var fTrace = m[0] + m[4] + m[8];
var fRoot = void 0;
if (fTrace > 0.0) {
// |w| > 1/2, may as well choose w > 1/2
fRoot = Math.sqrt(fTrace + 1.0); // 2w
out[3] = 0.5 * fRoot;
fRoot = 0.5 / fRoot; // 1/(4w)
out[0] = (m[5] - m[7]) * fRoot;
out[1] = (m[6] - m[2]) * fRoot;
out[2] = (m[1] - m[3]) * fRoot;
} else {
// |w| <= 1/2
var i = 0;
if (m[4] > m[0]) i = 1;
if (m[8] > m[i * 3 + i]) i = 2;
var j = (i + 1) % 3;
var k = (i + 2) % 3;
fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0);
out[i] = 0.5 * fRoot;
fRoot = 0.5 / fRoot;
out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot;
out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot;
out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot;
}
return out;
}
/**
* Creates a quaternion from the given euler angle x, y, z.
*
* @param {quat} out the receiving quaternion
* @param {x} Angle to rotate around X axis in degrees.
* @param {y} Angle to rotate around Y axis in degrees.
* @param {z} Angle to rotate around Z axis in degrees.
* @returns {quat} out
* @function
*/
function fromEuler(out, x, y, z) {
var halfToRad = 0.5 * Math.PI / 180.0;
x *= halfToRad;
y *= halfToRad;
z *= halfToRad;
var sx = Math.sin(x);
var cx = Math.cos(x);
var sy = Math.sin(y);
var cy = Math.cos(y);
var sz = Math.sin(z);
var cz = Math.cos(z);
out[0] = sx * cy * cz - cx * sy * sz;
out[1] = cx * sy * cz + sx * cy * sz;
out[2] = cx * cy * sz - sx * sy * cz;
out[3] = cx * cy * cz + sx * sy * sz;
return out;
}
/**
* Returns a string representation of a quatenion
*
* @param {quat} a vector to represent as a string
* @returns {String} string representation of the vector
*/
function str(a) {
return 'quat(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';
}
/**
* Creates a new quat initialized with values from an existing quaternion
*
* @param {quat} a quaternion to clone
* @returns {quat} a new quaternion
* @function
*/
var clone = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["clone"];
/**
* Creates a new quat initialized with the given values
*
* @param {Number} x X component
* @param {Number} y Y component
* @param {Number} z Z component
* @param {Number} w W component
* @returns {quat} a new quaternion
* @function
*/
var fromValues = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["fromValues"];
/**
* Copy the values from one quat to another
*
* @param {quat} out the receiving quaternion
* @param {quat} a the source quaternion
* @returns {quat} out
* @function
*/
var copy = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["copy"];
/**
* Set the components of a quat to the given values
*
* @param {quat} out the receiving quaternion
* @param {Number} x X component
* @param {Number} y Y component
* @param {Number} z Z component
* @param {Number} w W component
* @returns {quat} out
* @function
*/
var set = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["set"];
/**
* Adds two quat's
*
* @param {quat} out the receiving quaternion
* @param {quat} a the first operand
* @param {quat} b the second operand
* @returns {quat} out
* @function
*/
var add = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["add"];
/**
* Alias for {@link quat.multiply}
* @function
*/
var mul = multiply;
/**
* Scales a quat by a scalar number
*
* @param {quat} out the receiving vector
* @param {quat} a the vector to scale
* @param {Number} b amount to scale the vector by
* @returns {quat} out
* @function
*/
var scale = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["scale"];
/**
* Calculates the dot product of two quat's
*
* @param {quat} a the first operand
* @param {quat} b the second operand
* @returns {Number} dot product of a and b
* @function
*/
var dot = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["dot"];
/**
* Performs a linear interpolation between two quat's
*
* @param {quat} out the receiving quaternion
* @param {quat} a the first operand
* @param {quat} b the second operand
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
* @returns {quat} out
* @function
*/
var lerp = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["lerp"];
/**
* Calculates the length of a quat
*
* @param {quat} a vector to calculate length of
* @returns {Number} length of a
*/
var length = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["length"];
/**
* Alias for {@link quat.length}
* @function
*/
var len = length;
/**
* Calculates the squared length of a quat
*
* @param {quat} a vector to calculate squared length of
* @returns {Number} squared length of a
* @function
*/
var squaredLength = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["squaredLength"];
/**
* Alias for {@link quat.squaredLength}
* @function
*/
var sqrLen = squaredLength;
/**
* Normalize a quat
*
* @param {quat} out the receiving quaternion
* @param {quat} a quaternion to normalize
* @returns {quat} out
* @function
*/
var normalize = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["normalize"];
/**
* Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)
*
* @param {quat} a The first quaternion.
* @param {quat} b The second quaternion.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/
var exactEquals = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["exactEquals"];
/**
* Returns whether or not the quaternions have approximately the same elements in the same position.
*
* @param {quat} a The first vector.
* @param {quat} b The second vector.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/
var equals = _vec4_js__WEBPACK_IMPORTED_MODULE_3__["equals"];
/**
* Sets a quaternion to represent the shortest rotation from one
* vector to another.
*
* Both vectors are assumed to be unit length.
*
* @param {quat} out the receiving quaternion.
* @param {vec3} a the initial vector
* @param {vec3} b the destination vector
* @returns {quat} out
*/
var rotationTo = function () {
var tmpvec3 = _vec3_js__WEBPACK_IMPORTED_MODULE_2__["create"]();
var xUnitVec3 = _vec3_js__WEBPACK_IMPORTED_MODULE_2__["fromValues"](1, 0, 0);
var yUnitVec3 = _vec3_js__WEBPACK_IMPORTED_MODULE_2__["fromValues"](0, 1, 0);
return function (out, a, b) {
var dot = _vec3_js__WEBPACK_IMPORTED_MODULE_2__["dot"](a, b);
if (dot < -0.999999) {
_vec3_js__WEBPACK_IMPORTED_MODULE_2__["cross"](tmpvec3, xUnitVec3, a);
if (_vec3_js__WEBPACK_IMPORTED_MODULE_2__["len"](tmpvec3) < 0.000001) _vec3_js__WEBPACK_IMPORTED_MODULE_2__["cross"](tmpvec3, yUnitVec3, a);
_vec3_js__WEBPACK_IMPORTED_MODULE_2__["normalize"](tmpvec3, tmpvec3);
setAxisAngle(out, tmpvec3, Math.PI);
return out;
} else if (dot > 0.999999) {
out[0] = 0;
out[1] = 0;
out[2] = 0;
out[3] = 1;
return out;
} else {
_vec3_js__WEBPACK_IMPORTED_MODULE_2__["cross"](tmpvec3, a, b);
out[0] = tmpvec3[0];
out[1] = tmpvec3[1];
out[2] = tmpvec3[2];
out[3] = 1 + dot;
return normalize(out, out);
}
};
}();
/**
* Performs a spherical linear interpolation with two control points
*
* @param {quat} out the receiving quaternion
* @param {quat} a the first operand
* @param {quat} b the second operand
* @param {quat} c the third operand
* @param {quat} d the fourth operand
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
* @returns {quat} out
*/
var sqlerp = function () {
var temp1 = create();
var temp2 = create();
return function (out, a, b, c, d, t) {
slerp(temp1, a, d, t);
slerp(temp2, b, c, t);
slerp(out, temp1, temp2, 2 * t * (1 - t));
return out;
};
}();
/**
* Sets the specified quaternion with values corresponding to the given
* axes. Each axis is a vec3 and is expected to be unit length and
* perpendicular to all other specified axes.
*
* @param {vec3} view the vector representing the viewing direction
* @param {vec3} right the vector representing the local "right" direction
* @param {vec3} up the vector representing the local "up" direction
* @returns {quat} out
*/
var setAxes = function () {
var matr = _mat3_js__WEBPACK_IMPORTED_MODULE_1__["create"]();
return function (out, view, right, up) {
matr[0] = right[0];
matr[3] = right[1];
matr[6] = right[2];
matr[1] = up[0];
matr[4] = up[1];
matr[7] = up[2];
matr[2] = -view[0];
matr[5] = -view[1];
matr[8] = -view[2];
return normalize(out, fromMat3(out, matr));
};
}();
/***/ }),
/***/ "./node_modules/gl-matrix/lib/gl-matrix/quat2.js":
/*!*******************************************************!*\
!*** ./node_modules/gl-matrix/lib/gl-matrix/quat2.js ***!
\*******************************************************/
/*! exports provided: create, clone, fromValues, fromRotationTranslationValues, fromRotationTranslation, fromTranslation, fromRotation, fromMat4, copy, identity, set, getReal, getDual, setReal, setDual, getTranslation, translate, rotateX, rotateY, rotateZ, rotateByQuatAppend, rotateByQuatPrepend, rotateAroundAxis, add, multiply, mul, scale, dot, lerp, invert, conjugate, length, len, squaredLength, sqrLen, normalize, str, exactEquals, equals */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotationTranslationValues", function() { return fromRotationTranslationValues; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotationTranslation", function() { return fromRotationTranslation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromTranslation", function() { return fromTranslation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromRotation", function() { return fromRotation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromMat4", function() { return fromMat4; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getReal", function() { return getReal; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDual", function() { return getDual; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setReal", function() { return setReal; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setDual", function() { return setDual; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTranslation", function() { return getTranslation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "translate", function() { return translate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateX", function() { return rotateX; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateY", function() { return rotateY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateZ", function() { return rotateZ; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateByQuatAppend", function() { return rotateByQuatAppend; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateByQuatPrepend", function() { return rotateByQuatPrepend; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateAroundAxis", function() { return rotateAroundAxis; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dot", function() { return dot; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lerp", function() { return lerp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "invert", function() { return invert; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "conjugate", function() { return conjugate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "length", function() { return length; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredLength", function() { return squaredLength; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalize", function() { return normalize; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/lib/gl-matrix/common.js");
/* harmony import */ var _quat_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./quat.js */ "./node_modules/gl-matrix/lib/gl-matrix/quat.js");
/* harmony import */ var _mat4_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./mat4.js */ "./node_modules/gl-matrix/lib/gl-matrix/mat4.js");
/**
* Dual Quaternion<br>
* Format: [real, dual]<br>
* Quaternion format: XYZW<br>
* Make sure to have normalized dual quaternions, otherwise the functions may not work as intended.<br>
* @module quat2
*/
/**
* Creates a new identity dual quat
*
* @returns {quat2} a new dual quaternion [real -> rotation, dual -> translation]
*/
function create() {
var dq = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](8);
if (_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) {
dq[0] = 0;
dq[1] = 0;
dq[2] = 0;
dq[4] = 0;
dq[5] = 0;
dq[6] = 0;
dq[7] = 0;
}
dq[3] = 1;
return dq;
}
/**
* Creates a new quat initialized with values from an existing quaternion
*
* @param {quat2} a dual quaternion to clone
* @returns {quat2} new dual quaternion
* @function
*/
function clone(a) {
var dq = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](8);
dq[0] = a[0];
dq[1] = a[1];
dq[2] = a[2];
dq[3] = a[3];
dq[4] = a[4];
dq[5] = a[5];
dq[6] = a[6];
dq[7] = a[7];
return dq;
}
/**
* Creates a new dual quat initialized with the given values
*
* @param {Number} x1 X component
* @param {Number} y1 Y component
* @param {Number} z1 Z component
* @param {Number} w1 W component
* @param {Number} x2 X component
* @param {Number} y2 Y component
* @param {Number} z2 Z component
* @param {Number} w2 W component
* @returns {quat2} new dual quaternion
* @function
*/
function fromValues(x1, y1, z1, w1, x2, y2, z2, w2) {
var dq = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](8);
dq[0] = x1;
dq[1] = y1;
dq[2] = z1;
dq[3] = w1;
dq[4] = x2;
dq[5] = y2;
dq[6] = z2;
dq[7] = w2;
return dq;
}
/**
* Creates a new dual quat from the given values (quat and translation)
*
* @param {Number} x1 X component
* @param {Number} y1 Y component
* @param {Number} z1 Z component
* @param {Number} w1 W component
* @param {Number} x2 X component (translation)
* @param {Number} y2 Y component (translation)
* @param {Number} z2 Z component (translation)
* @returns {quat2} new dual quaternion
* @function
*/
function fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) {
var dq = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](8);
dq[0] = x1;
dq[1] = y1;
dq[2] = z1;
dq[3] = w1;
var ax = x2 * 0.5,
ay = y2 * 0.5,
az = z2 * 0.5;
dq[4] = ax * w1 + ay * z1 - az * y1;
dq[5] = ay * w1 + az * x1 - ax * z1;
dq[6] = az * w1 + ax * y1 - ay * x1;
dq[7] = -ax * x1 - ay * y1 - az * z1;
return dq;
}
/**
* Creates a dual quat from a quaternion and a translation
*
* @param {quat2} dual quaternion receiving operation result
* @param {quat} q quaternion
* @param {vec3} t tranlation vector
* @returns {quat2} dual quaternion receiving operation result
* @function
*/
function fromRotationTranslation(out, q, t) {
var ax = t[0] * 0.5,
ay = t[1] * 0.5,
az = t[2] * 0.5,
bx = q[0],
by = q[1],
bz = q[2],
bw = q[3];
out[0] = bx;
out[1] = by;
out[2] = bz;
out[3] = bw;
out[4] = ax * bw + ay * bz - az * by;
out[5] = ay * bw + az * bx - ax * bz;
out[6] = az * bw + ax * by - ay * bx;
out[7] = -ax * bx - ay * by - az * bz;
return out;
}
/**
* Creates a dual quat from a translation
*
* @param {quat2} dual quaternion receiving operation result
* @param {vec3} t translation vector
* @returns {quat2} dual quaternion receiving operation result
* @function
*/
function fromTranslation(out, t) {
out[0] = 0;
out[1] = 0;
out[2] = 0;
out[3] = 1;
out[4] = t[0] * 0.5;
out[5] = t[1] * 0.5;
out[6] = t[2] * 0.5;
out[7] = 0;
return out;
}
/**
* Creates a dual quat from a quaternion
*
* @param {quat2} dual quaternion receiving operation result
* @param {quat} q the quaternion
* @returns {quat2} dual quaternion receiving operation result
* @function
*/
function fromRotation(out, q) {
out[0] = q[0];
out[1] = q[1];
out[2] = q[2];
out[3] = q[3];
out[4] = 0;
out[5] = 0;
out[6] = 0;
out[7] = 0;
return out;
}
/**
* Creates a new dual quat from a matrix (4x4)
*
* @param {quat2} out the dual quaternion
* @param {mat4} a the matrix
* @returns {quat2} dual quat receiving operation result
* @function
*/
function fromMat4(out, a) {
//TODO Optimize this
var outer = _quat_js__WEBPACK_IMPORTED_MODULE_1__["create"]();
_mat4_js__WEBPACK_IMPORTED_MODULE_2__["getRotation"](outer, a);
var t = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](3);
_mat4_js__WEBPACK_IMPORTED_MODULE_2__["getTranslation"](t, a);
fromRotationTranslation(out, outer, t);
return out;
}
/**
* Copy the values from one dual quat to another
*
* @param {quat2} out the receiving dual quaternion
* @param {quat2} a the source dual quaternion
* @returns {quat2} out
* @function
*/
function copy(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
out[4] = a[4];
out[5] = a[5];
out[6] = a[6];
out[7] = a[7];
return out;
}
/**
* Set a dual quat to the identity dual quaternion
*
* @param {quat2} out the receiving quaternion
* @returns {quat2} out
*/
function identity(out) {
out[0] = 0;
out[1] = 0;
out[2] = 0;
out[3] = 1;
out[4] = 0;
out[5] = 0;
out[6] = 0;
out[7] = 0;
return out;
}
/**
* Set the components of a dual quat to the given values
*
* @param {quat2} out the receiving quaternion
* @param {Number} x1 X component
* @param {Number} y1 Y component
* @param {Number} z1 Z component
* @param {Number} w1 W component
* @param {Number} x2 X component
* @param {Number} y2 Y component
* @param {Number} z2 Z component
* @param {Number} w2 W component
* @returns {quat2} out
* @function
*/
function set(out, x1, y1, z1, w1, x2, y2, z2, w2) {
out[0] = x1;
out[1] = y1;
out[2] = z1;
out[3] = w1;
out[4] = x2;
out[5] = y2;
out[6] = z2;
out[7] = w2;
return out;
}
/**
* Gets the real part of a dual quat
* @param {quat} out real part
* @param {quat2} a Dual Quaternion
* @return {quat} real part
*/
var getReal = _quat_js__WEBPACK_IMPORTED_MODULE_1__["copy"];
/**
* Gets the dual part of a dual quat
* @param {quat} out dual part
* @param {quat2} a Dual Quaternion
* @return {quat} dual part
*/
function getDual(out, a) {
out[0] = a[4];
out[1] = a[5];
out[2] = a[6];
out[3] = a[7];
return out;
}
/**
* Set the real component of a dual quat to the given quaternion
*
* @param {quat2} out the receiving quaternion
* @param {quat} q a quaternion representing the real part
* @returns {quat2} out
* @function
*/
var setReal = _quat_js__WEBPACK_IMPORTED_MODULE_1__["copy"];
/**
* Set the dual component of a dual quat to the given quaternion
*
* @param {quat2} out the receiving quaternion
* @param {quat} q a quaternion representing the dual part
* @returns {quat2} out
* @function
*/
function setDual(out, q) {
out[4] = q[0];
out[5] = q[1];
out[6] = q[2];
out[7] = q[3];
return out;
}
/**
* Gets the translation of a normalized dual quat
* @param {vec3} out translation
* @param {quat2} a Dual Quaternion to be decomposed
* @return {vec3} translation
*/
function getTranslation(out, a) {
var ax = a[4],
ay = a[5],
az = a[6],
aw = a[7],
bx = -a[0],
by = -a[1],
bz = -a[2],
bw = a[3];
out[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;
out[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;
out[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;
return out;
}
/**
* Translates a dual quat by the given vector
*
* @param {quat2} out the receiving dual quaternion
* @param {quat2} a the dual quaternion to translate
* @param {vec3} v vector to translate by
* @returns {quat2} out
*/
function translate(out, a, v) {
var ax1 = a[0],
ay1 = a[1],
az1 = a[2],
aw1 = a[3],
bx1 = v[0] * 0.5,
by1 = v[1] * 0.5,
bz1 = v[2] * 0.5,
ax2 = a[4],
ay2 = a[5],
az2 = a[6],
aw2 = a[7];
out[0] = ax1;
out[1] = ay1;
out[2] = az1;
out[3] = aw1;
out[4] = aw1 * bx1 + ay1 * bz1 - az1 * by1 + ax2;
out[5] = aw1 * by1 + az1 * bx1 - ax1 * bz1 + ay2;
out[6] = aw1 * bz1 + ax1 * by1 - ay1 * bx1 + az2;
out[7] = -ax1 * bx1 - ay1 * by1 - az1 * bz1 + aw2;
return out;
}
/**
* Rotates a dual quat around the X axis
*
* @param {quat2} out the receiving dual quaternion
* @param {quat2} a the dual quaternion to rotate
* @param {number} rad how far should the rotation be
* @returns {quat2} out
*/
function rotateX(out, a, rad) {
var bx = -a[0],
by = -a[1],
bz = -a[2],
bw = a[3],
ax = a[4],
ay = a[5],
az = a[6],
aw = a[7],
ax1 = ax * bw + aw * bx + ay * bz - az * by,
ay1 = ay * bw + aw * by + az * bx - ax * bz,
az1 = az * bw + aw * bz + ax * by - ay * bx,
aw1 = aw * bw - ax * bx - ay * by - az * bz;
_quat_js__WEBPACK_IMPORTED_MODULE_1__["rotateX"](out, a, rad);
bx = out[0];
by = out[1];
bz = out[2];
bw = out[3];
out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;
out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;
out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;
out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;
return out;
}
/**
* Rotates a dual quat around the Y axis
*
* @param {quat2} out the receiving dual quaternion
* @param {quat2} a the dual quaternion to rotate
* @param {number} rad how far should the rotation be
* @returns {quat2} out
*/
function rotateY(out, a, rad) {
var bx = -a[0],
by = -a[1],
bz = -a[2],
bw = a[3],
ax = a[4],
ay = a[5],
az = a[6],
aw = a[7],
ax1 = ax * bw + aw * bx + ay * bz - az * by,
ay1 = ay * bw + aw * by + az * bx - ax * bz,
az1 = az * bw + aw * bz + ax * by - ay * bx,
aw1 = aw * bw - ax * bx - ay * by - az * bz;
_quat_js__WEBPACK_IMPORTED_MODULE_1__["rotateY"](out, a, rad);
bx = out[0];
by = out[1];
bz = out[2];
bw = out[3];
out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;
out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;
out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;
out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;
return out;
}
/**
* Rotates a dual quat around the Z axis
*
* @param {quat2} out the receiving dual quaternion
* @param {quat2} a the dual quaternion to rotate
* @param {number} rad how far should the rotation be
* @returns {quat2} out
*/
function rotateZ(out, a, rad) {
var bx = -a[0],
by = -a[1],
bz = -a[2],
bw = a[3],
ax = a[4],
ay = a[5],
az = a[6],
aw = a[7],
ax1 = ax * bw + aw * bx + ay * bz - az * by,
ay1 = ay * bw + aw * by + az * bx - ax * bz,
az1 = az * bw + aw * bz + ax * by - ay * bx,
aw1 = aw * bw - ax * bx - ay * by - az * bz;
_quat_js__WEBPACK_IMPORTED_MODULE_1__["rotateZ"](out, a, rad);
bx = out[0];
by = out[1];
bz = out[2];
bw = out[3];
out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;
out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;
out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;
out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;
return out;
}
/**
* Rotates a dual quat by a given quaternion (a * q)
*
* @param {quat2} out the receiving dual quaternion
* @param {quat2} a the dual quaternion to rotate
* @param {quat} q quaternion to rotate by
* @returns {quat2} out
*/
function rotateByQuatAppend(out, a, q) {
var qx = q[0],
qy = q[1],
qz = q[2],
qw = q[3],
ax = a[0],
ay = a[1],
az = a[2],
aw = a[3];
out[0] = ax * qw + aw * qx + ay * qz - az * qy;
out[1] = ay * qw + aw * qy + az * qx - ax * qz;
out[2] = az * qw + aw * qz + ax * qy - ay * qx;
out[3] = aw * qw - ax * qx - ay * qy - az * qz;
ax = a[4];
ay = a[5];
az = a[6];
aw = a[7];
out[4] = ax * qw + aw * qx + ay * qz - az * qy;
out[5] = ay * qw + aw * qy + az * qx - ax * qz;
out[6] = az * qw + aw * qz + ax * qy - ay * qx;
out[7] = aw * qw - ax * qx - ay * qy - az * qz;
return out;
}
/**
* Rotates a dual quat by a given quaternion (q * a)
*
* @param {quat2} out the receiving dual quaternion
* @param {quat} q quaternion to rotate by
* @param {quat2} a the dual quaternion to rotate
* @returns {quat2} out
*/
function rotateByQuatPrepend(out, q, a) {
var qx = q[0],
qy = q[1],
qz = q[2],
qw = q[3],
bx = a[0],
by = a[1],
bz = a[2],
bw = a[3];
out[0] = qx * bw + qw * bx + qy * bz - qz * by;
out[1] = qy * bw + qw * by + qz * bx - qx * bz;
out[2] = qz * bw + qw * bz + qx * by - qy * bx;
out[3] = qw * bw - qx * bx - qy * by - qz * bz;
bx = a[4];
by = a[5];
bz = a[6];
bw = a[7];
out[4] = qx * bw + qw * bx + qy * bz - qz * by;
out[5] = qy * bw + qw * by + qz * bx - qx * bz;
out[6] = qz * bw + qw * bz + qx * by - qy * bx;
out[7] = qw * bw - qx * bx - qy * by - qz * bz;
return out;
}
/**
* Rotates a dual quat around a given axis. Does the normalisation automatically
*
* @param {quat2} out the receiving dual quaternion
* @param {quat2} a the dual quaternion to rotate
* @param {vec3} axis the axis to rotate around
* @param {Number} rad how far the rotation should be
* @returns {quat2} out
*/
function rotateAroundAxis(out, a, axis, rad) {
//Special case for rad = 0
if (Math.abs(rad) < _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"]) {
return copy(out, a);
}
var axisLength = Math.sqrt(axis[0] * axis[0] + axis[1] * axis[1] + axis[2] * axis[2]);
rad = rad * 0.5;
var s = Math.sin(rad);
var bx = s * axis[0] / axisLength;
var by = s * axis[1] / axisLength;
var bz = s * axis[2] / axisLength;
var bw = Math.cos(rad);
var ax1 = a[0],
ay1 = a[1],
az1 = a[2],
aw1 = a[3];
out[0] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;
out[1] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;
out[2] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;
out[3] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;
var ax = a[4],
ay = a[5],
az = a[6],
aw = a[7];
out[4] = ax * bw + aw * bx + ay * bz - az * by;
out[5] = ay * bw + aw * by + az * bx - ax * bz;
out[6] = az * bw + aw * bz + ax * by - ay * bx;
out[7] = aw * bw - ax * bx - ay * by - az * bz;
return out;
}
/**
* Adds two dual quat's
*
* @param {quat2} out the receiving dual quaternion
* @param {quat2} a the first operand
* @param {quat2} b the second operand
* @returns {quat2} out
* @function
*/
function add(out, a, b) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
out[2] = a[2] + b[2];
out[3] = a[3] + b[3];
out[4] = a[4] + b[4];
out[5] = a[5] + b[5];
out[6] = a[6] + b[6];
out[7] = a[7] + b[7];
return out;
}
/**
* Multiplies two dual quat's
*
* @param {quat2} out the receiving dual quaternion
* @param {quat2} a the first operand
* @param {quat2} b the second operand
* @returns {quat2} out
*/
function multiply(out, a, b) {
var ax0 = a[0],
ay0 = a[1],
az0 = a[2],
aw0 = a[3],
bx1 = b[4],
by1 = b[5],
bz1 = b[6],
bw1 = b[7],
ax1 = a[4],
ay1 = a[5],
az1 = a[6],
aw1 = a[7],
bx0 = b[0],
by0 = b[1],
bz0 = b[2],
bw0 = b[3];
out[0] = ax0 * bw0 + aw0 * bx0 + ay0 * bz0 - az0 * by0;
out[1] = ay0 * bw0 + aw0 * by0 + az0 * bx0 - ax0 * bz0;
out[2] = az0 * bw0 + aw0 * bz0 + ax0 * by0 - ay0 * bx0;
out[3] = aw0 * bw0 - ax0 * bx0 - ay0 * by0 - az0 * bz0;
out[4] = ax0 * bw1 + aw0 * bx1 + ay0 * bz1 - az0 * by1 + ax1 * bw0 + aw1 * bx0 + ay1 * bz0 - az1 * by0;
out[5] = ay0 * bw1 + aw0 * by1 + az0 * bx1 - ax0 * bz1 + ay1 * bw0 + aw1 * by0 + az1 * bx0 - ax1 * bz0;
out[6] = az0 * bw1 + aw0 * bz1 + ax0 * by1 - ay0 * bx1 + az1 * bw0 + aw1 * bz0 + ax1 * by0 - ay1 * bx0;
out[7] = aw0 * bw1 - ax0 * bx1 - ay0 * by1 - az0 * bz1 + aw1 * bw0 - ax1 * bx0 - ay1 * by0 - az1 * bz0;
return out;
}
/**
* Alias for {@link quat2.multiply}
* @function
*/
var mul = multiply;
/**
* Scales a dual quat by a scalar number
*
* @param {quat2} out the receiving dual quat
* @param {quat2} a the dual quat to scale
* @param {Number} b amount to scale the dual quat by
* @returns {quat2} out
* @function
*/
function scale(out, a, b) {
out[0] = a[0] * b;
out[1] = a[1] * b;
out[2] = a[2] * b;
out[3] = a[3] * b;
out[4] = a[4] * b;
out[5] = a[5] * b;
out[6] = a[6] * b;
out[7] = a[7] * b;
return out;
}
/**
* Calculates the dot product of two dual quat's (The dot product of the real parts)
*
* @param {quat2} a the first operand
* @param {quat2} b the second operand
* @returns {Number} dot product of a and b
* @function
*/
var dot = _quat_js__WEBPACK_IMPORTED_MODULE_1__["dot"];
/**
* Performs a linear interpolation between two dual quats's
* NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5)
*
* @param {quat2} out the receiving dual quat
* @param {quat2} a the first operand
* @param {quat2} b the second operand
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
* @returns {quat2} out
*/
function lerp(out, a, b, t) {
var mt = 1 - t;
if (dot(a, b) < 0) t = -t;
out[0] = a[0] * mt + b[0] * t;
out[1] = a[1] * mt + b[1] * t;
out[2] = a[2] * mt + b[2] * t;
out[3] = a[3] * mt + b[3] * t;
out[4] = a[4] * mt + b[4] * t;
out[5] = a[5] * mt + b[5] * t;
out[6] = a[6] * mt + b[6] * t;
out[7] = a[7] * mt + b[7] * t;
return out;
}
/**
* Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper
*
* @param {quat2} out the receiving dual quaternion
* @param {quat2} a dual quat to calculate inverse of
* @returns {quat2} out
*/
function invert(out, a) {
var sqlen = squaredLength(a);
out[0] = -a[0] / sqlen;
out[1] = -a[1] / sqlen;
out[2] = -a[2] / sqlen;
out[3] = a[3] / sqlen;
out[4] = -a[4] / sqlen;
out[5] = -a[5] / sqlen;
out[6] = -a[6] / sqlen;
out[7] = a[7] / sqlen;
return out;
}
/**
* Calculates the conjugate of a dual quat
* If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result.
*
* @param {quat2} out the receiving quaternion
* @param {quat2} a quat to calculate conjugate of
* @returns {quat2} out
*/
function conjugate(out, a) {
out[0] = -a[0];
out[1] = -a[1];
out[2] = -a[2];
out[3] = a[3];
out[4] = -a[4];
out[5] = -a[5];
out[6] = -a[6];
out[7] = a[7];
return out;
}
/**
* Calculates the length of a dual quat
*
* @param {quat2} a dual quat to calculate length of
* @returns {Number} length of a
* @function
*/
var length = _quat_js__WEBPACK_IMPORTED_MODULE_1__["length"];
/**
* Alias for {@link quat2.length}
* @function
*/
var len = length;
/**
* Calculates the squared length of a dual quat
*
* @param {quat2} a dual quat to calculate squared length of
* @returns {Number} squared length of a
* @function
*/
var squaredLength = _quat_js__WEBPACK_IMPORTED_MODULE_1__["squaredLength"];
/**
* Alias for {@link quat2.squaredLength}
* @function
*/
var sqrLen = squaredLength;
/**
* Normalize a dual quat
*
* @param {quat2} out the receiving dual quaternion
* @param {quat2} a dual quaternion to normalize
* @returns {quat2} out
* @function
*/
function normalize(out, a) {
var magnitude = squaredLength(a);
if (magnitude > 0) {
magnitude = Math.sqrt(magnitude);
var a0 = a[0] / magnitude;
var a1 = a[1] / magnitude;
var a2 = a[2] / magnitude;
var a3 = a[3] / magnitude;
var b0 = a[4];
var b1 = a[5];
var b2 = a[6];
var b3 = a[7];
var a_dot_b = a0 * b0 + a1 * b1 + a2 * b2 + a3 * b3;
out[0] = a0;
out[1] = a1;
out[2] = a2;
out[3] = a3;
out[4] = (b0 - a0 * a_dot_b) / magnitude;
out[5] = (b1 - a1 * a_dot_b) / magnitude;
out[6] = (b2 - a2 * a_dot_b) / magnitude;
out[7] = (b3 - a3 * a_dot_b) / magnitude;
}
return out;
}
/**
* Returns a string representation of a dual quatenion
*
* @param {quat2} a dual quaternion to represent as a string
* @returns {String} string representation of the dual quat
*/
function str(a) {
return 'quat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ')';
}
/**
* Returns whether or not the dual quaternions have exactly the same elements in the same position (when compared with ===)
*
* @param {quat2} a the first dual quaternion.
* @param {quat2} b the second dual quaternion.
* @returns {Boolean} true if the dual quaternions are equal, false otherwise.
*/
function exactEquals(a, b) {
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7];
}
/**
* Returns whether or not the dual quaternions have approximately the same elements in the same position.
*
* @param {quat2} a the first dual quat.
* @param {quat2} b the second dual quat.
* @returns {Boolean} true if the dual quats are equal, false otherwise.
*/
function equals(a, b) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3],
a4 = a[4],
a5 = a[5],
a6 = a[6],
a7 = a[7];
var b0 = b[0],
b1 = b[1],
b2 = b[2],
b3 = b[3],
b4 = b[4],
b5 = b[5],
b6 = b[6],
b7 = b[7];
return Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a7), Math.abs(b7));
}
/***/ }),
/***/ "./node_modules/gl-matrix/lib/gl-matrix/vec2.js":
/*!******************************************************!*\
!*** ./node_modules/gl-matrix/lib/gl-matrix/vec2.js ***!
\******************************************************/
/*! exports provided: create, clone, fromValues, copy, set, add, subtract, multiply, divide, ceil, floor, min, max, round, scale, scaleAndAdd, distance, squaredDistance, length, squaredLength, negate, inverse, normalize, dot, cross, lerp, random, transformMat2, transformMat2d, transformMat3, transformMat4, rotate, angle, str, exactEquals, equals, len, sub, mul, div, dist, sqrDist, sqrLen, forEach */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "divide", function() { return divide; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ceil", function() { return ceil; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "floor", function() { return floor; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "min", function() { return min; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "max", function() { return max; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "round", function() { return round; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scaleAndAdd", function() { return scaleAndAdd; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "distance", function() { return distance; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredDistance", function() { return squaredDistance; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "length", function() { return length; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredLength", function() { return squaredLength; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "negate", function() { return negate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inverse", function() { return inverse; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalize", function() { return normalize; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dot", function() { return dot; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cross", function() { return cross; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lerp", function() { return lerp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "random", function() { return random; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat2", function() { return transformMat2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat2d", function() { return transformMat2d; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat3", function() { return transformMat3; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat4", function() { return transformMat4; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotate", function() { return rotate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "angle", function() { return angle; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "div", function() { return div; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dist", function() { return dist; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrDist", function() { return sqrDist; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "forEach", function() { return forEach; });
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/lib/gl-matrix/common.js");
/**
* 2 Dimensional Vector
* @module vec2
*/
/**
* Creates a new, empty vec2
*
* @returns {vec2} a new 2D vector
*/
function create() {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](2);
if (_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) {
out[0] = 0;
out[1] = 0;
}
return out;
}
/**
* Creates a new vec2 initialized with values from an existing vector
*
* @param {vec2} a vector to clone
* @returns {vec2} a new 2D vector
*/
function clone(a) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](2);
out[0] = a[0];
out[1] = a[1];
return out;
}
/**
* Creates a new vec2 initialized with the given values
*
* @param {Number} x X component
* @param {Number} y Y component
* @returns {vec2} a new 2D vector
*/
function fromValues(x, y) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](2);
out[0] = x;
out[1] = y;
return out;
}
/**
* Copy the values from one vec2 to another
*
* @param {vec2} out the receiving vector
* @param {vec2} a the source vector
* @returns {vec2} out
*/
function copy(out, a) {
out[0] = a[0];
out[1] = a[1];
return out;
}
/**
* Set the components of a vec2 to the given values
*
* @param {vec2} out the receiving vector
* @param {Number} x X component
* @param {Number} y Y component
* @returns {vec2} out
*/
function set(out, x, y) {
out[0] = x;
out[1] = y;
return out;
}
/**
* Adds two vec2's
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec2} out
*/
function add(out, a, b) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
return out;
}
/**
* Subtracts vector b from vector a
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec2} out
*/
function subtract(out, a, b) {
out[0] = a[0] - b[0];
out[1] = a[1] - b[1];
return out;
}
/**
* Multiplies two vec2's
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec2} out
*/
function multiply(out, a, b) {
out[0] = a[0] * b[0];
out[1] = a[1] * b[1];
return out;
}
/**
* Divides two vec2's
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec2} out
*/
function divide(out, a, b) {
out[0] = a[0] / b[0];
out[1] = a[1] / b[1];
return out;
}
/**
* Math.ceil the components of a vec2
*
* @param {vec2} out the receiving vector
* @param {vec2} a vector to ceil
* @returns {vec2} out
*/
function ceil(out, a) {
out[0] = Math.ceil(a[0]);
out[1] = Math.ceil(a[1]);
return out;
}
/**
* Math.floor the components of a vec2
*
* @param {vec2} out the receiving vector
* @param {vec2} a vector to floor
* @returns {vec2} out
*/
function floor(out, a) {
out[0] = Math.floor(a[0]);
out[1] = Math.floor(a[1]);
return out;
}
/**
* Returns the minimum of two vec2's
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec2} out
*/
function min(out, a, b) {
out[0] = Math.min(a[0], b[0]);
out[1] = Math.min(a[1], b[1]);
return out;
}
/**
* Returns the maximum of two vec2's
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec2} out
*/
function max(out, a, b) {
out[0] = Math.max(a[0], b[0]);
out[1] = Math.max(a[1], b[1]);
return out;
}
/**
* Math.round the components of a vec2
*
* @param {vec2} out the receiving vector
* @param {vec2} a vector to round
* @returns {vec2} out
*/
function round(out, a) {
out[0] = Math.round(a[0]);
out[1] = Math.round(a[1]);
return out;
}
/**
* Scales a vec2 by a scalar number
*
* @param {vec2} out the receiving vector
* @param {vec2} a the vector to scale
* @param {Number} b amount to scale the vector by
* @returns {vec2} out
*/
function scale(out, a, b) {
out[0] = a[0] * b;
out[1] = a[1] * b;
return out;
}
/**
* Adds two vec2's after scaling the second operand by a scalar value
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @param {Number} scale the amount to scale b by before adding
* @returns {vec2} out
*/
function scaleAndAdd(out, a, b, scale) {
out[0] = a[0] + b[0] * scale;
out[1] = a[1] + b[1] * scale;
return out;
}
/**
* Calculates the euclidian distance between two vec2's
*
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {Number} distance between a and b
*/
function distance(a, b) {
var x = b[0] - a[0],
y = b[1] - a[1];
return Math.sqrt(x * x + y * y);
}
/**
* Calculates the squared euclidian distance between two vec2's
*
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {Number} squared distance between a and b
*/
function squaredDistance(a, b) {
var x = b[0] - a[0],
y = b[1] - a[1];
return x * x + y * y;
}
/**
* Calculates the length of a vec2
*
* @param {vec2} a vector to calculate length of
* @returns {Number} length of a
*/
function length(a) {
var x = a[0],
y = a[1];
return Math.sqrt(x * x + y * y);
}
/**
* Calculates the squared length of a vec2
*
* @param {vec2} a vector to calculate squared length of
* @returns {Number} squared length of a
*/
function squaredLength(a) {
var x = a[0],
y = a[1];
return x * x + y * y;
}
/**
* Negates the components of a vec2
*
* @param {vec2} out the receiving vector
* @param {vec2} a vector to negate
* @returns {vec2} out
*/
function negate(out, a) {
out[0] = -a[0];
out[1] = -a[1];
return out;
}
/**
* Returns the inverse of the components of a vec2
*
* @param {vec2} out the receiving vector
* @param {vec2} a vector to invert
* @returns {vec2} out
*/
function inverse(out, a) {
out[0] = 1.0 / a[0];
out[1] = 1.0 / a[1];
return out;
}
/**
* Normalize a vec2
*
* @param {vec2} out the receiving vector
* @param {vec2} a vector to normalize
* @returns {vec2} out
*/
function normalize(out, a) {
var x = a[0],
y = a[1];
var len = x * x + y * y;
if (len > 0) {
//TODO: evaluate use of glm_invsqrt here?
len = 1 / Math.sqrt(len);
out[0] = a[0] * len;
out[1] = a[1] * len;
}
return out;
}
/**
* Calculates the dot product of two vec2's
*
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {Number} dot product of a and b
*/
function dot(a, b) {
return a[0] * b[0] + a[1] * b[1];
}
/**
* Computes the cross product of two vec2's
* Note that the cross product must by definition produce a 3D vector
*
* @param {vec3} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @returns {vec3} out
*/
function cross(out, a, b) {
var z = a[0] * b[1] - a[1] * b[0];
out[0] = out[1] = 0;
out[2] = z;
return out;
}
/**
* Performs a linear interpolation between two vec2's
*
* @param {vec2} out the receiving vector
* @param {vec2} a the first operand
* @param {vec2} b the second operand
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
* @returns {vec2} out
*/
function lerp(out, a, b, t) {
var ax = a[0],
ay = a[1];
out[0] = ax + t * (b[0] - ax);
out[1] = ay + t * (b[1] - ay);
return out;
}
/**
* Generates a random vector with the given scale
*
* @param {vec2} out the receiving vector
* @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
* @returns {vec2} out
*/
function random(out, scale) {
scale = scale || 1.0;
var r = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2.0 * Math.PI;
out[0] = Math.cos(r) * scale;
out[1] = Math.sin(r) * scale;
return out;
}
/**
* Transforms the vec2 with a mat2
*
* @param {vec2} out the receiving vector
* @param {vec2} a the vector to transform
* @param {mat2} m matrix to transform with
* @returns {vec2} out
*/
function transformMat2(out, a, m) {
var x = a[0],
y = a[1];
out[0] = m[0] * x + m[2] * y;
out[1] = m[1] * x + m[3] * y;
return out;
}
/**
* Transforms the vec2 with a mat2d
*
* @param {vec2} out the receiving vector
* @param {vec2} a the vector to transform
* @param {mat2d} m matrix to transform with
* @returns {vec2} out
*/
function transformMat2d(out, a, m) {
var x = a[0],
y = a[1];
out[0] = m[0] * x + m[2] * y + m[4];
out[1] = m[1] * x + m[3] * y + m[5];
return out;
}
/**
* Transforms the vec2 with a mat3
* 3rd vector component is implicitly '1'
*
* @param {vec2} out the receiving vector
* @param {vec2} a the vector to transform
* @param {mat3} m matrix to transform with
* @returns {vec2} out
*/
function transformMat3(out, a, m) {
var x = a[0],
y = a[1];
out[0] = m[0] * x + m[3] * y + m[6];
out[1] = m[1] * x + m[4] * y + m[7];
return out;
}
/**
* Transforms the vec2 with a mat4
* 3rd vector component is implicitly '0'
* 4th vector component is implicitly '1'
*
* @param {vec2} out the receiving vector
* @param {vec2} a the vector to transform
* @param {mat4} m matrix to transform with
* @returns {vec2} out
*/
function transformMat4(out, a, m) {
var x = a[0];
var y = a[1];
out[0] = m[0] * x + m[4] * y + m[12];
out[1] = m[1] * x + m[5] * y + m[13];
return out;
}
/**
* Rotate a 2D vector
* @param {vec2} out The receiving vec2
* @param {vec2} a The vec2 point to rotate
* @param {vec2} b The origin of the rotation
* @param {Number} c The angle of rotation
* @returns {vec2} out
*/
function rotate(out, a, b, c) {
//Translate point to the origin
var p0 = a[0] - b[0],
p1 = a[1] - b[1],
sinC = Math.sin(c),
cosC = Math.cos(c);
//perform rotation and translate to correct position
out[0] = p0 * cosC - p1 * sinC + b[0];
out[1] = p0 * sinC + p1 * cosC + b[1];
return out;
}
/**
* Get the angle between two 2D vectors
* @param {vec2} a The first operand
* @param {vec2} b The second operand
* @returns {Number} The angle in radians
*/
function angle(a, b) {
var x1 = a[0],
y1 = a[1],
x2 = b[0],
y2 = b[1];
var len1 = x1 * x1 + y1 * y1;
if (len1 > 0) {
//TODO: evaluate use of glm_invsqrt here?
len1 = 1 / Math.sqrt(len1);
}
var len2 = x2 * x2 + y2 * y2;
if (len2 > 0) {
//TODO: evaluate use of glm_invsqrt here?
len2 = 1 / Math.sqrt(len2);
}
var cosine = (x1 * x2 + y1 * y2) * len1 * len2;
if (cosine > 1.0) {
return 0;
} else if (cosine < -1.0) {
return Math.PI;
} else {
return Math.acos(cosine);
}
}
/**
* Returns a string representation of a vector
*
* @param {vec2} a vector to represent as a string
* @returns {String} string representation of the vector
*/
function str(a) {
return 'vec2(' + a[0] + ', ' + a[1] + ')';
}
/**
* Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
*
* @param {vec2} a The first vector.
* @param {vec2} b The second vector.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/
function exactEquals(a, b) {
return a[0] === b[0] && a[1] === b[1];
}
/**
* Returns whether or not the vectors have approximately the same elements in the same position.
*
* @param {vec2} a The first vector.
* @param {vec2} b The second vector.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/
function equals(a, b) {
var a0 = a[0],
a1 = a[1];
var b0 = b[0],
b1 = b[1];
return Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a1), Math.abs(b1));
}
/**
* Alias for {@link vec2.length}
* @function
*/
var len = length;
/**
* Alias for {@link vec2.subtract}
* @function
*/
var sub = subtract;
/**
* Alias for {@link vec2.multiply}
* @function
*/
var mul = multiply;
/**
* Alias for {@link vec2.divide}
* @function
*/
var div = divide;
/**
* Alias for {@link vec2.distance}
* @function
*/
var dist = distance;
/**
* Alias for {@link vec2.squaredDistance}
* @function
*/
var sqrDist = squaredDistance;
/**
* Alias for {@link vec2.squaredLength}
* @function
*/
var sqrLen = squaredLength;
/**
* Perform some operation over an array of vec2s.
*
* @param {Array} a the array of vectors to iterate over
* @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
* @param {Number} offset Number of elements to skip at the beginning of the array
* @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
* @param {Function} fn Function to call for each vector in the array
* @param {Object} [arg] additional argument to pass to fn
* @returns {Array} a
* @function
*/
var forEach = function () {
var vec = create();
return function (a, stride, offset, count, fn, arg) {
var i = void 0,
l = void 0;
if (!stride) {
stride = 2;
}
if (!offset) {
offset = 0;
}
if (count) {
l = Math.min(count * stride + offset, a.length);
} else {
l = a.length;
}
for (i = offset; i < l; i += stride) {
vec[0] = a[i];vec[1] = a[i + 1];
fn(vec, vec, arg);
a[i] = vec[0];a[i + 1] = vec[1];
}
return a;
};
}();
/***/ }),
/***/ "./node_modules/gl-matrix/lib/gl-matrix/vec3.js":
/*!******************************************************!*\
!*** ./node_modules/gl-matrix/lib/gl-matrix/vec3.js ***!
\******************************************************/
/*! exports provided: create, clone, length, fromValues, copy, set, add, subtract, multiply, divide, ceil, floor, min, max, round, scale, scaleAndAdd, distance, squaredDistance, squaredLength, negate, inverse, normalize, dot, cross, lerp, hermite, bezier, random, transformMat4, transformMat3, transformQuat, rotateX, rotateY, rotateZ, angle, str, exactEquals, equals, sub, mul, div, dist, sqrDist, len, sqrLen, forEach */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "length", function() { return length; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "divide", function() { return divide; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ceil", function() { return ceil; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "floor", function() { return floor; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "min", function() { return min; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "max", function() { return max; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "round", function() { return round; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scaleAndAdd", function() { return scaleAndAdd; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "distance", function() { return distance; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredDistance", function() { return squaredDistance; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredLength", function() { return squaredLength; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "negate", function() { return negate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inverse", function() { return inverse; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalize", function() { return normalize; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dot", function() { return dot; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cross", function() { return cross; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lerp", function() { return lerp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hermite", function() { return hermite; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bezier", function() { return bezier; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "random", function() { return random; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat4", function() { return transformMat4; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat3", function() { return transformMat3; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformQuat", function() { return transformQuat; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateX", function() { return rotateX; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateY", function() { return rotateY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotateZ", function() { return rotateZ; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "angle", function() { return angle; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "div", function() { return div; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dist", function() { return dist; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrDist", function() { return sqrDist; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "forEach", function() { return forEach; });
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/lib/gl-matrix/common.js");
/**
* 3 Dimensional Vector
* @module vec3
*/
/**
* Creates a new, empty vec3
*
* @returns {vec3} a new 3D vector
*/
function create() {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](3);
if (_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) {
out[0] = 0;
out[1] = 0;
out[2] = 0;
}
return out;
}
/**
* Creates a new vec3 initialized with values from an existing vector
*
* @param {vec3} a vector to clone
* @returns {vec3} a new 3D vector
*/
function clone(a) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](3);
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
return out;
}
/**
* Calculates the length of a vec3
*
* @param {vec3} a vector to calculate length of
* @returns {Number} length of a
*/
function length(a) {
var x = a[0];
var y = a[1];
var z = a[2];
return Math.sqrt(x * x + y * y + z * z);
}
/**
* Creates a new vec3 initialized with the given values
*
* @param {Number} x X component
* @param {Number} y Y component
* @param {Number} z Z component
* @returns {vec3} a new 3D vector
*/
function fromValues(x, y, z) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](3);
out[0] = x;
out[1] = y;
out[2] = z;
return out;
}
/**
* Copy the values from one vec3 to another
*
* @param {vec3} out the receiving vector
* @param {vec3} a the source vector
* @returns {vec3} out
*/
function copy(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
return out;
}
/**
* Set the components of a vec3 to the given values
*
* @param {vec3} out the receiving vector
* @param {Number} x X component
* @param {Number} y Y component
* @param {Number} z Z component
* @returns {vec3} out
*/
function set(out, x, y, z) {
out[0] = x;
out[1] = y;
out[2] = z;
return out;
}
/**
* Adds two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function add(out, a, b) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
out[2] = a[2] + b[2];
return out;
}
/**
* Subtracts vector b from vector a
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function subtract(out, a, b) {
out[0] = a[0] - b[0];
out[1] = a[1] - b[1];
out[2] = a[2] - b[2];
return out;
}
/**
* Multiplies two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function multiply(out, a, b) {
out[0] = a[0] * b[0];
out[1] = a[1] * b[1];
out[2] = a[2] * b[2];
return out;
}
/**
* Divides two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function divide(out, a, b) {
out[0] = a[0] / b[0];
out[1] = a[1] / b[1];
out[2] = a[2] / b[2];
return out;
}
/**
* Math.ceil the components of a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to ceil
* @returns {vec3} out
*/
function ceil(out, a) {
out[0] = Math.ceil(a[0]);
out[1] = Math.ceil(a[1]);
out[2] = Math.ceil(a[2]);
return out;
}
/**
* Math.floor the components of a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to floor
* @returns {vec3} out
*/
function floor(out, a) {
out[0] = Math.floor(a[0]);
out[1] = Math.floor(a[1]);
out[2] = Math.floor(a[2]);
return out;
}
/**
* Returns the minimum of two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function min(out, a, b) {
out[0] = Math.min(a[0], b[0]);
out[1] = Math.min(a[1], b[1]);
out[2] = Math.min(a[2], b[2]);
return out;
}
/**
* Returns the maximum of two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function max(out, a, b) {
out[0] = Math.max(a[0], b[0]);
out[1] = Math.max(a[1], b[1]);
out[2] = Math.max(a[2], b[2]);
return out;
}
/**
* Math.round the components of a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to round
* @returns {vec3} out
*/
function round(out, a) {
out[0] = Math.round(a[0]);
out[1] = Math.round(a[1]);
out[2] = Math.round(a[2]);
return out;
}
/**
* Scales a vec3 by a scalar number
*
* @param {vec3} out the receiving vector
* @param {vec3} a the vector to scale
* @param {Number} b amount to scale the vector by
* @returns {vec3} out
*/
function scale(out, a, b) {
out[0] = a[0] * b;
out[1] = a[1] * b;
out[2] = a[2] * b;
return out;
}
/**
* Adds two vec3's after scaling the second operand by a scalar value
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @param {Number} scale the amount to scale b by before adding
* @returns {vec3} out
*/
function scaleAndAdd(out, a, b, scale) {
out[0] = a[0] + b[0] * scale;
out[1] = a[1] + b[1] * scale;
out[2] = a[2] + b[2] * scale;
return out;
}
/**
* Calculates the euclidian distance between two vec3's
*
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {Number} distance between a and b
*/
function distance(a, b) {
var x = b[0] - a[0];
var y = b[1] - a[1];
var z = b[2] - a[2];
return Math.sqrt(x * x + y * y + z * z);
}
/**
* Calculates the squared euclidian distance between two vec3's
*
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {Number} squared distance between a and b
*/
function squaredDistance(a, b) {
var x = b[0] - a[0];
var y = b[1] - a[1];
var z = b[2] - a[2];
return x * x + y * y + z * z;
}
/**
* Calculates the squared length of a vec3
*
* @param {vec3} a vector to calculate squared length of
* @returns {Number} squared length of a
*/
function squaredLength(a) {
var x = a[0];
var y = a[1];
var z = a[2];
return x * x + y * y + z * z;
}
/**
* Negates the components of a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to negate
* @returns {vec3} out
*/
function negate(out, a) {
out[0] = -a[0];
out[1] = -a[1];
out[2] = -a[2];
return out;
}
/**
* Returns the inverse of the components of a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to invert
* @returns {vec3} out
*/
function inverse(out, a) {
out[0] = 1.0 / a[0];
out[1] = 1.0 / a[1];
out[2] = 1.0 / a[2];
return out;
}
/**
* Normalize a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to normalize
* @returns {vec3} out
*/
function normalize(out, a) {
var x = a[0];
var y = a[1];
var z = a[2];
var len = x * x + y * y + z * z;
if (len > 0) {
//TODO: evaluate use of glm_invsqrt here?
len = 1 / Math.sqrt(len);
out[0] = a[0] * len;
out[1] = a[1] * len;
out[2] = a[2] * len;
}
return out;
}
/**
* Calculates the dot product of two vec3's
*
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {Number} dot product of a and b
*/
function dot(a, b) {
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}
/**
* Computes the cross product of two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/
function cross(out, a, b) {
var ax = a[0],
ay = a[1],
az = a[2];
var bx = b[0],
by = b[1],
bz = b[2];
out[0] = ay * bz - az * by;
out[1] = az * bx - ax * bz;
out[2] = ax * by - ay * bx;
return out;
}
/**
* Performs a linear interpolation between two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
* @returns {vec3} out
*/
function lerp(out, a, b, t) {
var ax = a[0];
var ay = a[1];
var az = a[2];
out[0] = ax + t * (b[0] - ax);
out[1] = ay + t * (b[1] - ay);
out[2] = az + t * (b[2] - az);
return out;
}
/**
* Performs a hermite interpolation with two control points
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @param {vec3} c the third operand
* @param {vec3} d the fourth operand
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
* @returns {vec3} out
*/
function hermite(out, a, b, c, d, t) {
var factorTimes2 = t * t;
var factor1 = factorTimes2 * (2 * t - 3) + 1;
var factor2 = factorTimes2 * (t - 2) + t;
var factor3 = factorTimes2 * (t - 1);
var factor4 = factorTimes2 * (3 - 2 * t);
out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
return out;
}
/**
* Performs a bezier interpolation with two control points
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @param {vec3} c the third operand
* @param {vec3} d the fourth operand
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
* @returns {vec3} out
*/
function bezier(out, a, b, c, d, t) {
var inverseFactor = 1 - t;
var inverseFactorTimesTwo = inverseFactor * inverseFactor;
var factorTimes2 = t * t;
var factor1 = inverseFactorTimesTwo * inverseFactor;
var factor2 = 3 * t * inverseFactorTimesTwo;
var factor3 = 3 * factorTimes2 * inverseFactor;
var factor4 = factorTimes2 * t;
out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
return out;
}
/**
* Generates a random vector with the given scale
*
* @param {vec3} out the receiving vector
* @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
* @returns {vec3} out
*/
function random(out, scale) {
scale = scale || 1.0;
var r = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2.0 * Math.PI;
var z = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2.0 - 1.0;
var zScale = Math.sqrt(1.0 - z * z) * scale;
out[0] = Math.cos(r) * zScale;
out[1] = Math.sin(r) * zScale;
out[2] = z * scale;
return out;
}
/**
* Transforms the vec3 with a mat4.
* 4th vector component is implicitly '1'
*
* @param {vec3} out the receiving vector
* @param {vec3} a the vector to transform
* @param {mat4} m matrix to transform with
* @returns {vec3} out
*/
function transformMat4(out, a, m) {
var x = a[0],
y = a[1],
z = a[2];
var w = m[3] * x + m[7] * y + m[11] * z + m[15];
w = w || 1.0;
out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
return out;
}
/**
* Transforms the vec3 with a mat3.
*
* @param {vec3} out the receiving vector
* @param {vec3} a the vector to transform
* @param {mat3} m the 3x3 matrix to transform with
* @returns {vec3} out
*/
function transformMat3(out, a, m) {
var x = a[0],
y = a[1],
z = a[2];
out[0] = x * m[0] + y * m[3] + z * m[6];
out[1] = x * m[1] + y * m[4] + z * m[7];
out[2] = x * m[2] + y * m[5] + z * m[8];
return out;
}
/**
* Transforms the vec3 with a quat
* Can also be used for dual quaternions. (Multiply it with the real part)
*
* @param {vec3} out the receiving vector
* @param {vec3} a the vector to transform
* @param {quat} q quaternion to transform with
* @returns {vec3} out
*/
function transformQuat(out, a, q) {
// benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed
var qx = q[0],
qy = q[1],
qz = q[2],
qw = q[3];
var x = a[0],
y = a[1],
z = a[2];
// var qvec = [qx, qy, qz];
// var uv = vec3.cross([], qvec, a);
var uvx = qy * z - qz * y,
uvy = qz * x - qx * z,
uvz = qx * y - qy * x;
// var uuv = vec3.cross([], qvec, uv);
var uuvx = qy * uvz - qz * uvy,
uuvy = qz * uvx - qx * uvz,
uuvz = qx * uvy - qy * uvx;
// vec3.scale(uv, uv, 2 * w);
var w2 = qw * 2;
uvx *= w2;
uvy *= w2;
uvz *= w2;
// vec3.scale(uuv, uuv, 2);
uuvx *= 2;
uuvy *= 2;
uuvz *= 2;
// return vec3.add(out, a, vec3.add(out, uv, uuv));
out[0] = x + uvx + uuvx;
out[1] = y + uvy + uuvy;
out[2] = z + uvz + uuvz;
return out;
}
/**
* Rotate a 3D vector around the x-axis
* @param {vec3} out The receiving vec3
* @param {vec3} a The vec3 point to rotate
* @param {vec3} b The origin of the rotation
* @param {Number} c The angle of rotation
* @returns {vec3} out
*/
function rotateX(out, a, b, c) {
var p = [],
r = [];
//Translate point to the origin
p[0] = a[0] - b[0];
p[1] = a[1] - b[1];
p[2] = a[2] - b[2];
//perform rotation
r[0] = p[0];
r[1] = p[1] * Math.cos(c) - p[2] * Math.sin(c);
r[2] = p[1] * Math.sin(c) + p[2] * Math.cos(c);
//translate to correct position
out[0] = r[0] + b[0];
out[1] = r[1] + b[1];
out[2] = r[2] + b[2];
return out;
}
/**
* Rotate a 3D vector around the y-axis
* @param {vec3} out The receiving vec3
* @param {vec3} a The vec3 point to rotate
* @param {vec3} b The origin of the rotation
* @param {Number} c The angle of rotation
* @returns {vec3} out
*/
function rotateY(out, a, b, c) {
var p = [],
r = [];
//Translate point to the origin
p[0] = a[0] - b[0];
p[1] = a[1] - b[1];
p[2] = a[2] - b[2];
//perform rotation
r[0] = p[2] * Math.sin(c) + p[0] * Math.cos(c);
r[1] = p[1];
r[2] = p[2] * Math.cos(c) - p[0] * Math.sin(c);
//translate to correct position
out[0] = r[0] + b[0];
out[1] = r[1] + b[1];
out[2] = r[2] + b[2];
return out;
}
/**
* Rotate a 3D vector around the z-axis
* @param {vec3} out The receiving vec3
* @param {vec3} a The vec3 point to rotate
* @param {vec3} b The origin of the rotation
* @param {Number} c The angle of rotation
* @returns {vec3} out
*/
function rotateZ(out, a, b, c) {
var p = [],
r = [];
//Translate point to the origin
p[0] = a[0] - b[0];
p[1] = a[1] - b[1];
p[2] = a[2] - b[2];
//perform rotation
r[0] = p[0] * Math.cos(c) - p[1] * Math.sin(c);
r[1] = p[0] * Math.sin(c) + p[1] * Math.cos(c);
r[2] = p[2];
//translate to correct position
out[0] = r[0] + b[0];
out[1] = r[1] + b[1];
out[2] = r[2] + b[2];
return out;
}
/**
* Get the angle between two 3D vectors
* @param {vec3} a The first operand
* @param {vec3} b The second operand
* @returns {Number} The angle in radians
*/
function angle(a, b) {
var tempA = fromValues(a[0], a[1], a[2]);
var tempB = fromValues(b[0], b[1], b[2]);
normalize(tempA, tempA);
normalize(tempB, tempB);
var cosine = dot(tempA, tempB);
if (cosine > 1.0) {
return 0;
} else if (cosine < -1.0) {
return Math.PI;
} else {
return Math.acos(cosine);
}
}
/**
* Returns a string representation of a vector
*
* @param {vec3} a vector to represent as a string
* @returns {String} string representation of the vector
*/
function str(a) {
return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')';
}
/**
* Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
*
* @param {vec3} a The first vector.
* @param {vec3} b The second vector.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/
function exactEquals(a, b) {
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
}
/**
* Returns whether or not the vectors have approximately the same elements in the same position.
*
* @param {vec3} a The first vector.
* @param {vec3} b The second vector.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/
function equals(a, b) {
var a0 = a[0],
a1 = a[1],
a2 = a[2];
var b0 = b[0],
b1 = b[1],
b2 = b[2];
return Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a2), Math.abs(b2));
}
/**
* Alias for {@link vec3.subtract}
* @function
*/
var sub = subtract;
/**
* Alias for {@link vec3.multiply}
* @function
*/
var mul = multiply;
/**
* Alias for {@link vec3.divide}
* @function
*/
var div = divide;
/**
* Alias for {@link vec3.distance}
* @function
*/
var dist = distance;
/**
* Alias for {@link vec3.squaredDistance}
* @function
*/
var sqrDist = squaredDistance;
/**
* Alias for {@link vec3.length}
* @function
*/
var len = length;
/**
* Alias for {@link vec3.squaredLength}
* @function
*/
var sqrLen = squaredLength;
/**
* Perform some operation over an array of vec3s.
*
* @param {Array} a the array of vectors to iterate over
* @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
* @param {Number} offset Number of elements to skip at the beginning of the array
* @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
* @param {Function} fn Function to call for each vector in the array
* @param {Object} [arg] additional argument to pass to fn
* @returns {Array} a
* @function
*/
var forEach = function () {
var vec = create();
return function (a, stride, offset, count, fn, arg) {
var i = void 0,
l = void 0;
if (!stride) {
stride = 3;
}
if (!offset) {
offset = 0;
}
if (count) {
l = Math.min(count * stride + offset, a.length);
} else {
l = a.length;
}
for (i = offset; i < l; i += stride) {
vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2];
fn(vec, vec, arg);
a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2];
}
return a;
};
}();
/***/ }),
/***/ "./node_modules/gl-matrix/lib/gl-matrix/vec4.js":
/*!******************************************************!*\
!*** ./node_modules/gl-matrix/lib/gl-matrix/vec4.js ***!
\******************************************************/
/*! exports provided: create, clone, fromValues, copy, set, add, subtract, multiply, divide, ceil, floor, min, max, round, scale, scaleAndAdd, distance, squaredDistance, length, squaredLength, negate, inverse, normalize, dot, lerp, random, transformMat4, transformQuat, str, exactEquals, equals, sub, mul, div, dist, sqrDist, len, sqrLen, forEach */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return clone; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromValues", function() { return fromValues; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subtract", function() { return subtract; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "divide", function() { return divide; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ceil", function() { return ceil; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "floor", function() { return floor; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "min", function() { return min; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "max", function() { return max; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "round", function() { return round; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scale", function() { return scale; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scaleAndAdd", function() { return scaleAndAdd; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "distance", function() { return distance; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredDistance", function() { return squaredDistance; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "length", function() { return length; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "squaredLength", function() { return squaredLength; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "negate", function() { return negate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inverse", function() { return inverse; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalize", function() { return normalize; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dot", function() { return dot; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lerp", function() { return lerp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "random", function() { return random; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformMat4", function() { return transformMat4; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transformQuat", function() { return transformQuat; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "str", function() { return str; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exactEquals", function() { return exactEquals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "div", function() { return div; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dist", function() { return dist; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrDist", function() { return sqrDist; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "forEach", function() { return forEach; });
/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ "./node_modules/gl-matrix/lib/gl-matrix/common.js");
/**
* 4 Dimensional Vector
* @module vec4
*/
/**
* Creates a new, empty vec4
*
* @returns {vec4} a new 4D vector
*/
function create() {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4);
if (_common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"] != Float32Array) {
out[0] = 0;
out[1] = 0;
out[2] = 0;
out[3] = 0;
}
return out;
}
/**
* Creates a new vec4 initialized with values from an existing vector
*
* @param {vec4} a vector to clone
* @returns {vec4} a new 4D vector
*/
function clone(a) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4);
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
return out;
}
/**
* Creates a new vec4 initialized with the given values
*
* @param {Number} x X component
* @param {Number} y Y component
* @param {Number} z Z component
* @param {Number} w W component
* @returns {vec4} a new 4D vector
*/
function fromValues(x, y, z, w) {
var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__["ARRAY_TYPE"](4);
out[0] = x;
out[1] = y;
out[2] = z;
out[3] = w;
return out;
}
/**
* Copy the values from one vec4 to another
*
* @param {vec4} out the receiving vector
* @param {vec4} a the source vector
* @returns {vec4} out
*/
function copy(out, a) {
out[0] = a[0];
out[1] = a[1];
out[2] = a[2];
out[3] = a[3];
return out;
}
/**
* Set the components of a vec4 to the given values
*
* @param {vec4} out the receiving vector
* @param {Number} x X component
* @param {Number} y Y component
* @param {Number} z Z component
* @param {Number} w W component
* @returns {vec4} out
*/
function set(out, x, y, z, w) {
out[0] = x;
out[1] = y;
out[2] = z;
out[3] = w;
return out;
}
/**
* Adds two vec4's
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {vec4} out
*/
function add(out, a, b) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
out[2] = a[2] + b[2];
out[3] = a[3] + b[3];
return out;
}
/**
* Subtracts vector b from vector a
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {vec4} out
*/
function subtract(out, a, b) {
out[0] = a[0] - b[0];
out[1] = a[1] - b[1];
out[2] = a[2] - b[2];
out[3] = a[3] - b[3];
return out;
}
/**
* Multiplies two vec4's
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {vec4} out
*/
function multiply(out, a, b) {
out[0] = a[0] * b[0];
out[1] = a[1] * b[1];
out[2] = a[2] * b[2];
out[3] = a[3] * b[3];
return out;
}
/**
* Divides two vec4's
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {vec4} out
*/
function divide(out, a, b) {
out[0] = a[0] / b[0];
out[1] = a[1] / b[1];
out[2] = a[2] / b[2];
out[3] = a[3] / b[3];
return out;
}
/**
* Math.ceil the components of a vec4
*
* @param {vec4} out the receiving vector
* @param {vec4} a vector to ceil
* @returns {vec4} out
*/
function ceil(out, a) {
out[0] = Math.ceil(a[0]);
out[1] = Math.ceil(a[1]);
out[2] = Math.ceil(a[2]);
out[3] = Math.ceil(a[3]);
return out;
}
/**
* Math.floor the components of a vec4
*
* @param {vec4} out the receiving vector
* @param {vec4} a vector to floor
* @returns {vec4} out
*/
function floor(out, a) {
out[0] = Math.floor(a[0]);
out[1] = Math.floor(a[1]);
out[2] = Math.floor(a[2]);
out[3] = Math.floor(a[3]);
return out;
}
/**
* Returns the minimum of two vec4's
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {vec4} out
*/
function min(out, a, b) {
out[0] = Math.min(a[0], b[0]);
out[1] = Math.min(a[1], b[1]);
out[2] = Math.min(a[2], b[2]);
out[3] = Math.min(a[3], b[3]);
return out;
}
/**
* Returns the maximum of two vec4's
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {vec4} out
*/
function max(out, a, b) {
out[0] = Math.max(a[0], b[0]);
out[1] = Math.max(a[1], b[1]);
out[2] = Math.max(a[2], b[2]);
out[3] = Math.max(a[3], b[3]);
return out;
}
/**
* Math.round the components of a vec4
*
* @param {vec4} out the receiving vector
* @param {vec4} a vector to round
* @returns {vec4} out
*/
function round(out, a) {
out[0] = Math.round(a[0]);
out[1] = Math.round(a[1]);
out[2] = Math.round(a[2]);
out[3] = Math.round(a[3]);
return out;
}
/**
* Scales a vec4 by a scalar number
*
* @param {vec4} out the receiving vector
* @param {vec4} a the vector to scale
* @param {Number} b amount to scale the vector by
* @returns {vec4} out
*/
function scale(out, a, b) {
out[0] = a[0] * b;
out[1] = a[1] * b;
out[2] = a[2] * b;
out[3] = a[3] * b;
return out;
}
/**
* Adds two vec4's after scaling the second operand by a scalar value
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @param {Number} scale the amount to scale b by before adding
* @returns {vec4} out
*/
function scaleAndAdd(out, a, b, scale) {
out[0] = a[0] + b[0] * scale;
out[1] = a[1] + b[1] * scale;
out[2] = a[2] + b[2] * scale;
out[3] = a[3] + b[3] * scale;
return out;
}
/**
* Calculates the euclidian distance between two vec4's
*
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {Number} distance between a and b
*/
function distance(a, b) {
var x = b[0] - a[0];
var y = b[1] - a[1];
var z = b[2] - a[2];
var w = b[3] - a[3];
return Math.sqrt(x * x + y * y + z * z + w * w);
}
/**
* Calculates the squared euclidian distance between two vec4's
*
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {Number} squared distance between a and b
*/
function squaredDistance(a, b) {
var x = b[0] - a[0];
var y = b[1] - a[1];
var z = b[2] - a[2];
var w = b[3] - a[3];
return x * x + y * y + z * z + w * w;
}
/**
* Calculates the length of a vec4
*
* @param {vec4} a vector to calculate length of
* @returns {Number} length of a
*/
function length(a) {
var x = a[0];
var y = a[1];
var z = a[2];
var w = a[3];
return Math.sqrt(x * x + y * y + z * z + w * w);
}
/**
* Calculates the squared length of a vec4
*
* @param {vec4} a vector to calculate squared length of
* @returns {Number} squared length of a
*/
function squaredLength(a) {
var x = a[0];
var y = a[1];
var z = a[2];
var w = a[3];
return x * x + y * y + z * z + w * w;
}
/**
* Negates the components of a vec4
*
* @param {vec4} out the receiving vector
* @param {vec4} a vector to negate
* @returns {vec4} out
*/
function negate(out, a) {
out[0] = -a[0];
out[1] = -a[1];
out[2] = -a[2];
out[3] = -a[3];
return out;
}
/**
* Returns the inverse of the components of a vec4
*
* @param {vec4} out the receiving vector
* @param {vec4} a vector to invert
* @returns {vec4} out
*/
function inverse(out, a) {
out[0] = 1.0 / a[0];
out[1] = 1.0 / a[1];
out[2] = 1.0 / a[2];
out[3] = 1.0 / a[3];
return out;
}
/**
* Normalize a vec4
*
* @param {vec4} out the receiving vector
* @param {vec4} a vector to normalize
* @returns {vec4} out
*/
function normalize(out, a) {
var x = a[0];
var y = a[1];
var z = a[2];
var w = a[3];
var len = x * x + y * y + z * z + w * w;
if (len > 0) {
len = 1 / Math.sqrt(len);
out[0] = x * len;
out[1] = y * len;
out[2] = z * len;
out[3] = w * len;
}
return out;
}
/**
* Calculates the dot product of two vec4's
*
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {Number} dot product of a and b
*/
function dot(a, b) {
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
}
/**
* Performs a linear interpolation between two vec4's
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
* @returns {vec4} out
*/
function lerp(out, a, b, t) {
var ax = a[0];
var ay = a[1];
var az = a[2];
var aw = a[3];
out[0] = ax + t * (b[0] - ax);
out[1] = ay + t * (b[1] - ay);
out[2] = az + t * (b[2] - az);
out[3] = aw + t * (b[3] - aw);
return out;
}
/**
* Generates a random vector with the given scale
*
* @param {vec4} out the receiving vector
* @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
* @returns {vec4} out
*/
function random(out, scale) {
scale = scale || 1.0;
// Marsaglia, George. Choosing a Point from the Surface of a
// Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646.
// http://projecteuclid.org/euclid.aoms/1177692644;
var v1, v2, v3, v4;
var s1, s2;
do {
v1 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2 - 1;
v2 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2 - 1;
s1 = v1 * v1 + v2 * v2;
} while (s1 >= 1);
do {
v3 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2 - 1;
v4 = _common_js__WEBPACK_IMPORTED_MODULE_0__["RANDOM"]() * 2 - 1;
s2 = v3 * v3 + v4 * v4;
} while (s2 >= 1);
var d = Math.sqrt((1 - s1) / s2);
out[0] = scale * v1;
out[1] = scale * v2;
out[2] = scale * v3 * d;
out[3] = scale * v4 * d;
return out;
}
/**
* Transforms the vec4 with a mat4.
*
* @param {vec4} out the receiving vector
* @param {vec4} a the vector to transform
* @param {mat4} m matrix to transform with
* @returns {vec4} out
*/
function transformMat4(out, a, m) {
var x = a[0],
y = a[1],
z = a[2],
w = a[3];
out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
return out;
}
/**
* Transforms the vec4 with a quat
*
* @param {vec4} out the receiving vector
* @param {vec4} a the vector to transform
* @param {quat} q quaternion to transform with
* @returns {vec4} out
*/
function transformQuat(out, a, q) {
var x = a[0],
y = a[1],
z = a[2];
var qx = q[0],
qy = q[1],
qz = q[2],
qw = q[3];
// calculate quat * vec
var ix = qw * x + qy * z - qz * y;
var iy = qw * y + qz * x - qx * z;
var iz = qw * z + qx * y - qy * x;
var iw = -qx * x - qy * y - qz * z;
// calculate result * inverse quat
out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;
out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;
out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;
out[3] = a[3];
return out;
}
/**
* Returns a string representation of a vector
*
* @param {vec4} a vector to represent as a string
* @returns {String} string representation of the vector
*/
function str(a) {
return 'vec4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';
}
/**
* Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
*
* @param {vec4} a The first vector.
* @param {vec4} b The second vector.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/
function exactEquals(a, b) {
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
}
/**
* Returns whether or not the vectors have approximately the same elements in the same position.
*
* @param {vec4} a The first vector.
* @param {vec4} b The second vector.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/
function equals(a, b) {
var a0 = a[0],
a1 = a[1],
a2 = a[2],
a3 = a[3];
var b0 = b[0],
b1 = b[1],
b2 = b[2],
b3 = b[3];
return Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__["EPSILON"] * Math.max(1.0, Math.abs(a3), Math.abs(b3));
}
/**
* Alias for {@link vec4.subtract}
* @function
*/
var sub = subtract;
/**
* Alias for {@link vec4.multiply}
* @function
*/
var mul = multiply;
/**
* Alias for {@link vec4.divide}
* @function
*/
var div = divide;
/**
* Alias for {@link vec4.distance}
* @function
*/
var dist = distance;
/**
* Alias for {@link vec4.squaredDistance}
* @function
*/
var sqrDist = squaredDistance;
/**
* Alias for {@link vec4.length}
* @function
*/
var len = length;
/**
* Alias for {@link vec4.squaredLength}
* @function
*/
var sqrLen = squaredLength;
/**
* Perform some operation over an array of vec4s.
*
* @param {Array} a the array of vectors to iterate over
* @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed
* @param {Number} offset Number of elements to skip at the beginning of the array
* @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array
* @param {Function} fn Function to call for each vector in the array
* @param {Object} [arg] additional argument to pass to fn
* @returns {Array} a
* @function
*/
var forEach = function () {
var vec = create();
return function (a, stride, offset, count, fn, arg) {
var i = void 0,
l = void 0;
if (!stride) {
stride = 4;
}
if (!offset) {
offset = 0;
}
if (count) {
l = Math.min(count * stride + offset, a.length);
} else {
l = a.length;
}
for (i = offset; i < l; i += stride) {
vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2];vec[3] = a[i + 3];
fn(vec, vec, arg);
a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2];a[i + 3] = vec[3];
}
return a;
};
}();
/***/ }),
/***/ "./node_modules/inherits/inherits_browser.js":
/*!***************************************************!*\
!*** ./node_modules/inherits/inherits_browser.js ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
var TempCtor = function () {}
TempCtor.prototype = superCtor.prototype
ctor.prototype = new TempCtor()
ctor.prototype.constructor = ctor
}
}
/***/ }),
/***/ "./node_modules/jsep/build/jsep.js":
/*!*****************************************!*\
!*** ./node_modules/jsep/build/jsep.js ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
// JavaScript Expression Parser (JSEP) 0.3.4
// JSEP may be freely distributed under the MIT License
// http://jsep.from.so/
/*global module: true, exports: true, console: true */
(function (root) {
'use strict';
// Node Types
// ----------
// This is the full set of types that any JSEP node can be.
// Store them here to save space when minified
var COMPOUND = 'Compound',
IDENTIFIER = 'Identifier',
MEMBER_EXP = 'MemberExpression',
LITERAL = 'Literal',
THIS_EXP = 'ThisExpression',
CALL_EXP = 'CallExpression',
UNARY_EXP = 'UnaryExpression',
BINARY_EXP = 'BinaryExpression',
LOGICAL_EXP = 'LogicalExpression',
CONDITIONAL_EXP = 'ConditionalExpression',
ARRAY_EXP = 'ArrayExpression',
PERIOD_CODE = 46, // '.'
COMMA_CODE = 44, // ','
SQUOTE_CODE = 39, // single quote
DQUOTE_CODE = 34, // double quotes
OPAREN_CODE = 40, // (
CPAREN_CODE = 41, // )
OBRACK_CODE = 91, // [
CBRACK_CODE = 93, // ]
QUMARK_CODE = 63, // ?
SEMCOL_CODE = 59, // ;
COLON_CODE = 58, // :
throwError = function(message, index) {
var error = new Error(message + ' at character ' + index);
error.index = index;
error.description = message;
throw error;
},
// Operations
// ----------
// Set `t` to `true` to save space (when minified, not gzipped)
t = true,
// Use a quickly-accessible map to store all of the unary operators
// Values are set to `true` (it really doesn't matter)
unary_ops = {'-': t, '!': t, '~': t, '+': t},
// Also use a map for the binary operations but set their values to their
// binary precedence for quick reference:
// see [Order of operations](http://en.wikipedia.org/wiki/Order_of_operations#Programming_language)
binary_ops = {
'||': 1, '&&': 2, '|': 3, '^': 4, '&': 5,
'==': 6, '!=': 6, '===': 6, '!==': 6,
'<': 7, '>': 7, '<=': 7, '>=': 7,
'<<':8, '>>': 8, '>>>': 8,
'+': 9, '-': 9,
'*': 10, '/': 10, '%': 10
},
// Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)
additional_identifier_chars = {'$': t, '_': t},
// Get return the longest key length of any object
getMaxKeyLen = function(obj) {
var max_len = 0, len;
for(var key in obj) {
if((len = key.length) > max_len && obj.hasOwnProperty(key)) {
max_len = len;
}
}
return max_len;
},
max_unop_len = getMaxKeyLen(unary_ops),
max_binop_len = getMaxKeyLen(binary_ops),
// Literals
// ----------
// Store the values to return for the various literals we may encounter
literals = {
'true': true,
'false': false,
'null': null
},
// Except for `this`, which is special. This could be changed to something like `'self'` as well
this_str = 'this',
// Returns the precedence of a binary operator or `0` if it isn't a binary operator
binaryPrecedence = function(op_val) {
return binary_ops[op_val] || 0;
},
// Utility function (gets called from multiple places)
// Also note that `a && b` and `a || b` are *logical* expressions, not binary expressions
createBinaryExpression = function (operator, left, right) {
var type = (operator === '||' || operator === '&&') ? LOGICAL_EXP : BINARY_EXP;
return {
type: type,
operator: operator,
left: left,
right: right
};
},
// `ch` is a character code in the next three functions
isDecimalDigit = function(ch) {
return (ch >= 48 && ch <= 57); // 0...9
},
isIdentifierStart = function(ch) {
return (ch >= 65 && ch <= 90) || // A...Z
(ch >= 97 && ch <= 122) || // a...z
(ch >= 128 && !binary_ops[String.fromCharCode(ch)]) || // any non-ASCII that is not an operator
(additional_identifier_chars.hasOwnProperty(String.fromCharCode(ch))); // additional characters
},
isIdentifierPart = function(ch) {
return (ch >= 65 && ch <= 90) || // A...Z
(ch >= 97 && ch <= 122) || // a...z
(ch >= 48 && ch <= 57) || // 0...9
(ch >= 128 && !binary_ops[String.fromCharCode(ch)])|| // any non-ASCII that is not an operator
(additional_identifier_chars.hasOwnProperty(String.fromCharCode(ch))); // additional characters
},
// Parsing
// -------
// `expr` is a string with the passed in expression
jsep = function(expr) {
// `index` stores the character number we are currently at while `length` is a constant
// All of the gobbles below will modify `index` as we move along
var index = 0,
charAtFunc = expr.charAt,
charCodeAtFunc = expr.charCodeAt,
exprI = function(i) { return charAtFunc.call(expr, i); },
exprICode = function(i) { return charCodeAtFunc.call(expr, i); },
length = expr.length,
// Push `index` up to the next non-space character
gobbleSpaces = function() {
var ch = exprICode(index);
// space or tab
while(ch === 32 || ch === 9 || ch === 10 || ch === 13) {
ch = exprICode(++index);
}
},
// The main parsing function. Much of this code is dedicated to ternary expressions
gobbleExpression = function() {
var test = gobbleBinaryExpression(),
consequent, alternate;
gobbleSpaces();
if(exprICode(index) === QUMARK_CODE) {
// Ternary expression: test ? consequent : alternate
index++;
consequent = gobbleExpression();
if(!consequent) {
throwError('Expected expression', index);
}
gobbleSpaces();
if(exprICode(index) === COLON_CODE) {
index++;
alternate = gobbleExpression();
if(!alternate) {
throwError('Expected expression', index);
}
return {
type: CONDITIONAL_EXP,
test: test,
consequent: consequent,
alternate: alternate
};
} else {
throwError('Expected :', index);
}
} else {
return test;
}
},
// Search for the operation portion of the string (e.g. `+`, `===`)
// Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)
// and move down from 3 to 2 to 1 character until a matching binary operation is found
// then, return that binary operation
gobbleBinaryOp = function() {
gobbleSpaces();
var biop, to_check = expr.substr(index, max_binop_len), tc_len = to_check.length;
while(tc_len > 0) {
// Don't accept a binary op when it is an identifier.
// Binary ops that start with a identifier-valid character must be followed
// by a non identifier-part valid character
if(binary_ops.hasOwnProperty(to_check) && (
!isIdentifierStart(exprICode(index)) ||
(index+to_check.length< expr.length && !isIdentifierPart(exprICode(index+to_check.length)))
)) {
index += tc_len;
return to_check;
}
to_check = to_check.substr(0, --tc_len);
}
return false;
},
// This function is responsible for gobbling an individual expression,
// e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`
gobbleBinaryExpression = function() {
var ch_i, node, biop, prec, stack, biop_info, left, right, i, cur_biop;
// First, try to get the leftmost thing
// Then, check to see if there's a binary operator operating on that leftmost thing
left = gobbleToken();
biop = gobbleBinaryOp();
// If there wasn't a binary operator, just return the leftmost node
if(!biop) {
return left;
}
// Otherwise, we need to start a stack to properly place the binary operations in their
// precedence structure
biop_info = { value: biop, prec: binaryPrecedence(biop)};
right = gobbleToken();
if(!right) {
throwError("Expected expression after " + biop, index);
}
stack = [left, biop_info, right];
// Properly deal with precedence using [recursive descent](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm)
while((biop = gobbleBinaryOp())) {
prec = binaryPrecedence(biop);
if(prec === 0) {
break;
}
biop_info = { value: biop, prec: prec };
cur_biop = biop;
// Reduce: make a binary expression from the three topmost entries.
while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) {
right = stack.pop();
biop = stack.pop().value;
left = stack.pop();
node = createBinaryExpression(biop, left, right);
stack.push(node);
}
node = gobbleToken();
if(!node) {
throwError("Expected expression after " + cur_biop, index);
}
stack.push(biop_info, node);
}
i = stack.length - 1;
node = stack[i];
while(i > 1) {
node = createBinaryExpression(stack[i - 1].value, stack[i - 2], node);
i -= 2;
}
return node;
},
// An individual part of a binary expression:
// e.g. `foo.bar(baz)`, `1`, `"abc"`, `(a % 2)` (because it's in parenthesis)
gobbleToken = function() {
var ch, to_check, tc_len;
gobbleSpaces();
ch = exprICode(index);
if(isDecimalDigit(ch) || ch === PERIOD_CODE) {
// Char code 46 is a dot `.` which can start off a numeric literal
return gobbleNumericLiteral();
} else if(ch === SQUOTE_CODE || ch === DQUOTE_CODE) {
// Single or double quotes
return gobbleStringLiteral();
} else if (ch === OBRACK_CODE) {
return gobbleArray();
} else {
to_check = expr.substr(index, max_unop_len);
tc_len = to_check.length;
while(tc_len > 0) {
// Don't accept an unary op when it is an identifier.
// Unary ops that start with a identifier-valid character must be followed
// by a non identifier-part valid character
if(unary_ops.hasOwnProperty(to_check) && (
!isIdentifierStart(exprICode(index)) ||
(index+to_check.length < expr.length && !isIdentifierPart(exprICode(index+to_check.length)))
)) {
index += tc_len;
return {
type: UNARY_EXP,
operator: to_check,
argument: gobbleToken(),
prefix: true
};
}
to_check = to_check.substr(0, --tc_len);
}
if (isIdentifierStart(ch) || ch === OPAREN_CODE) { // open parenthesis
// `foo`, `bar.baz`
return gobbleVariable();
}
}
return false;
},
// Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to
// keep track of everything in the numeric literal and then calling `parseFloat` on that string
gobbleNumericLiteral = function() {
var number = '', ch, chCode;
while(isDecimalDigit(exprICode(index))) {
number += exprI(index++);
}
if(exprICode(index) === PERIOD_CODE) { // can start with a decimal marker
number += exprI(index++);
while(isDecimalDigit(exprICode(index))) {
number += exprI(index++);
}
}
ch = exprI(index);
if(ch === 'e' || ch === 'E') { // exponent marker
number += exprI(index++);
ch = exprI(index);
if(ch === '+' || ch === '-') { // exponent sign
number += exprI(index++);
}
while(isDecimalDigit(exprICode(index))) { //exponent itself
number += exprI(index++);
}
if(!isDecimalDigit(exprICode(index-1)) ) {
throwError('Expected exponent (' + number + exprI(index) + ')', index);
}
}
chCode = exprICode(index);
// Check to make sure this isn't a variable name that start with a number (123abc)
if(isIdentifierStart(chCode)) {
throwError('Variable names cannot start with a number (' +
number + exprI(index) + ')', index);
} else if(chCode === PERIOD_CODE) {
throwError('Unexpected period', index);
}
return {
type: LITERAL,
value: parseFloat(number),
raw: number
};
},
// Parses a string literal, staring with single or double quotes with basic support for escape codes
// e.g. `"hello world"`, `'this is\nJSEP'`
gobbleStringLiteral = function() {
var str = '', quote = exprI(index++), closed = false, ch;
while(index < length) {
ch = exprI(index++);
if(ch === quote) {
closed = true;
break;
} else if(ch === '\\') {
// Check for all of the common escape codes
ch = exprI(index++);
switch(ch) {
case 'n': str += '\n'; break;
case 'r': str += '\r'; break;
case 't': str += '\t'; break;
case 'b': str += '\b'; break;
case 'f': str += '\f'; break;
case 'v': str += '\x0B'; break;
default : str += ch;
}
} else {
str += ch;
}
}
if(!closed) {
throwError('Unclosed quote after "'+str+'"', index);
}
return {
type: LITERAL,
value: str,
raw: quote + str + quote
};
},
// Gobbles only identifiers
// e.g.: `foo`, `_value`, `$x1`
// Also, this function checks if that identifier is a literal:
// (e.g. `true`, `false`, `null`) or `this`
gobbleIdentifier = function() {
var ch = exprICode(index), start = index, identifier;
if(isIdentifierStart(ch)) {
index++;
} else {
throwError('Unexpected ' + exprI(index), index);
}
while(index < length) {
ch = exprICode(index);
if(isIdentifierPart(ch)) {
index++;
} else {
break;
}
}
identifier = expr.slice(start, index);
if(literals.hasOwnProperty(identifier)) {
return {
type: LITERAL,
value: literals[identifier],
raw: identifier
};
} else if(identifier === this_str) {
return { type: THIS_EXP };
} else {
return {
type: IDENTIFIER,
name: identifier
};
}
},
// Gobbles a list of arguments within the context of a function call
// or array literal. This function also assumes that the opening character
// `(` or `[` has already been gobbled, and gobbles expressions and commas
// until the terminator character `)` or `]` is encountered.
// e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`
gobbleArguments = function(termination) {
var ch_i, args = [], node, closed = false;
var separator_count = 0;
while(index < length) {
gobbleSpaces();
ch_i = exprICode(index);
if(ch_i === termination) { // done parsing
closed = true;
index++;
if(termination === CPAREN_CODE && separator_count && separator_count >= args.length){
throwError('Unexpected token ' + String.fromCharCode(termination), index);
}
break;
} else if (ch_i === COMMA_CODE) { // between expressions
index++;
separator_count++;
if(separator_count !== args.length) { // missing argument
if(termination === CPAREN_CODE) {
throwError('Unexpected token ,', index);
}
else if(termination === CBRACK_CODE) {
for(var arg = args.length; arg< separator_count; arg++) {
args.push(null);
}
}
}
} else {
node = gobbleExpression();
if(!node || node.type === COMPOUND) {
throwError('Expected comma', index);
}
args.push(node);
}
}
if (!closed) {
throwError('Expected ' + String.fromCharCode(termination), index);
}
return args;
},
// Gobble a non-literal variable name. This variable name may include properties
// e.g. `foo`, `bar.baz`, `foo['bar'].baz`
// It also gobbles function calls:
// e.g. `Math.acos(obj.angle)`
gobbleVariable = function() {
var ch_i, node;
ch_i = exprICode(index);
if(ch_i === OPAREN_CODE) {
node = gobbleGroup();
} else {
node = gobbleIdentifier();
}
gobbleSpaces();
ch_i = exprICode(index);
while(ch_i === PERIOD_CODE || ch_i === OBRACK_CODE || ch_i === OPAREN_CODE) {
index++;
if(ch_i === PERIOD_CODE) {
gobbleSpaces();
node = {
type: MEMBER_EXP,
computed: false,
object: node,
property: gobbleIdentifier()
};
} else if(ch_i === OBRACK_CODE) {
node = {
type: MEMBER_EXP,
computed: true,
object: node,
property: gobbleExpression()
};
gobbleSpaces();
ch_i = exprICode(index);
if(ch_i !== CBRACK_CODE) {
throwError('Unclosed [', index);
}
index++;
} else if(ch_i === OPAREN_CODE) {
// A function call is being made; gobble all the arguments
node = {
type: CALL_EXP,
'arguments': gobbleArguments(CPAREN_CODE),
callee: node
};
}
gobbleSpaces();
ch_i = exprICode(index);
}
return node;
},
// Responsible for parsing a group of things within parentheses `()`
// This function assumes that it needs to gobble the opening parenthesis
// and then tries to gobble everything within that parenthesis, assuming
// that the next thing it should see is the close parenthesis. If not,
// then the expression probably doesn't have a `)`
gobbleGroup = function() {
index++;
var node = gobbleExpression();
gobbleSpaces();
if(exprICode(index) === CPAREN_CODE) {
index++;
return node;
} else {
throwError('Unclosed (', index);
}
},
// Responsible for parsing Array literals `[1, 2, 3]`
// This function assumes that it needs to gobble the opening bracket
// and then tries to gobble the expressions as arguments.
gobbleArray = function() {
index++;
return {
type: ARRAY_EXP,
elements: gobbleArguments(CBRACK_CODE)
};
},
nodes = [], ch_i, node;
while(index < length) {
ch_i = exprICode(index);
// Expressions can be separated by semicolons, commas, or just inferred without any
// separators
if(ch_i === SEMCOL_CODE || ch_i === COMMA_CODE) {
index++; // ignore separators
} else {
// Try to gobble each expression individually
if((node = gobbleExpression())) {
nodes.push(node);
// If we weren't able to find a binary expression and are out of room, then
// the expression passed in probably has too much
} else if(index < length) {
throwError('Unexpected "' + exprI(index) + '"', index);
}
}
}
// If there's only one expression just try returning the expression
if(nodes.length === 1) {
return nodes[0];
} else {
return {
type: COMPOUND,
body: nodes
};
}
};
// To be filled in by the template
jsep.version = '0.3.4';
jsep.toString = function() { return 'JavaScript Expression Parser (JSEP) v' + jsep.version; };
/**
* @method jsep.addUnaryOp
* @param {string} op_name The name of the unary op to add
* @return jsep
*/
jsep.addUnaryOp = function(op_name) {
max_unop_len = Math.max(op_name.length, max_unop_len);
unary_ops[op_name] = t; return this;
};
/**
* @method jsep.addBinaryOp
* @param {string} op_name The name of the binary op to add
* @param {number} precedence The precedence of the binary op (can be a float)
* @return jsep
*/
jsep.addBinaryOp = function(op_name, precedence) {
max_binop_len = Math.max(op_name.length, max_binop_len);
binary_ops[op_name] = precedence;
return this;
};
/**
* @method jsep.addIdentifierChar
* @param {string} char The additional character to treat as a valid part of an identifier
* @return jsep
*/
jsep.addIdentifierChar = function(char) {
additional_identifier_chars[char] = t;
return this;
};
/**
* @method jsep.addLiteral
* @param {string} literal_name The name of the literal to add
* @param {*} literal_value The value of the literal
* @return jsep
*/
jsep.addLiteral = function(literal_name, literal_value) {
literals[literal_name] = literal_value;
return this;
};
/**
* @method jsep.removeUnaryOp
* @param {string} op_name The name of the unary op to remove
* @return jsep
*/
jsep.removeUnaryOp = function(op_name) {
delete unary_ops[op_name];
if(op_name.length === max_unop_len) {
max_unop_len = getMaxKeyLen(unary_ops);
}
return this;
};
/**
* @method jsep.removeAllUnaryOps
* @return jsep
*/
jsep.removeAllUnaryOps = function() {
unary_ops = {};
max_unop_len = 0;
return this;
};
/**
* @method jsep.removeIdentifierChar
* @param {string} char The additional character to stop treating as a valid part of an identifier
* @return jsep
*/
jsep.removeIdentifierChar = function(char) {
delete additional_identifier_chars[char];
return this;
};
/**
* @method jsep.removeBinaryOp
* @param {string} op_name The name of the binary op to remove
* @return jsep
*/
jsep.removeBinaryOp = function(op_name) {
delete binary_ops[op_name];
if(op_name.length === max_binop_len) {
max_binop_len = getMaxKeyLen(binary_ops);
}
return this;
};
/**
* @method jsep.removeAllBinaryOps
* @return jsep
*/
jsep.removeAllBinaryOps = function() {
binary_ops = {};
max_binop_len = 0;
return this;
};
/**
* @method jsep.removeLiteral
* @param {string} literal_name The name of the literal to remove
* @return jsep
*/
jsep.removeLiteral = function(literal_name) {
delete literals[literal_name];
return this;
};
/**
* @method jsep.removeAllLiterals
* @return jsep
*/
jsep.removeAllLiterals = function() {
literals = {};
return this;
};
// In desktop environments, have a way to restore the old value for `jsep`
if (false) { var old_jsep; } else {
// In Node.JS environments
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = jsep;
} else {
exports.parse = jsep;
}
}
}(this));
/***/ }),
/***/ "./node_modules/lineclip/index.js":
/*!****************************************!*\
!*** ./node_modules/lineclip/index.js ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = lineclip;
lineclip.polyline = lineclip;
lineclip.polygon = polygonclip;
// Cohen-Sutherland line clippign algorithm, adapted to efficiently
// handle polylines rather than just segments
function lineclip(points, bbox, result) {
var len = points.length,
codeA = bitCode(points[0], bbox),
part = [],
i, a, b, codeB, lastCode;
if (!result) result = [];
for (i = 1; i < len; i++) {
a = points[i - 1];
b = points[i];
codeB = lastCode = bitCode(b, bbox);
while (true) {
if (!(codeA | codeB)) { // accept
part.push(a);
if (codeB !== lastCode) { // segment went outside
part.push(b);
if (i < len - 1) { // start a new line
result.push(part);
part = [];
}
} else if (i === len - 1) {
part.push(b);
}
break;
} else if (codeA & codeB) { // trivial reject
break;
} else if (codeA) { // a outside, intersect with clip edge
a = intersect(a, b, codeA, bbox);
codeA = bitCode(a, bbox);
} else { // b outside
b = intersect(a, b, codeB, bbox);
codeB = bitCode(b, bbox);
}
}
codeA = lastCode;
}
if (part.length) result.push(part);
return result;
}
// Sutherland-Hodgeman polygon clipping algorithm
function polygonclip(points, bbox) {
var result, edge, prev, prevInside, i, p, inside;
// clip against each side of the clip rectangle
for (edge = 1; edge <= 8; edge *= 2) {
result = [];
prev = points[points.length - 1];
prevInside = !(bitCode(prev, bbox) & edge);
for (i = 0; i < points.length; i++) {
p = points[i];
inside = !(bitCode(p, bbox) & edge);
// if segment goes through the clip window, add an intersection
if (inside !== prevInside) result.push(intersect(prev, p, edge, bbox));
if (inside) result.push(p); // add a point if it's inside
prev = p;
prevInside = inside;
}
points = result;
if (!points.length) break;
}
return result;
}
// intersect a segment against one of the 4 lines that make up the bbox
function intersect(a, b, edge, bbox) {
return edge & 8 ? [a[0] + (b[0] - a[0]) * (bbox[3] - a[1]) / (b[1] - a[1]), bbox[3]] : // top
edge & 4 ? [a[0] + (b[0] - a[0]) * (bbox[1] - a[1]) / (b[1] - a[1]), bbox[1]] : // bottom
edge & 2 ? [bbox[2], a[1] + (b[1] - a[1]) * (bbox[2] - a[0]) / (b[0] - a[0])] : // right
edge & 1 ? [bbox[0], a[1] + (b[1] - a[1]) * (bbox[0] - a[0]) / (b[0] - a[0])] : // left
null;
}
// bit code reflects the point position relative to the bbox:
// left mid right
// top 1001 1000 1010
// mid 0001 0000 0010
// bottom 0101 0100 0110
function bitCode(p, bbox) {
var code = 0;
if (p[0] < bbox[0]) code |= 1; // left
else if (p[0] > bbox[2]) code |= 2; // right
if (p[1] < bbox[1]) code |= 4; // bottom
else if (p[1] > bbox[3]) code |= 8; // top
return code;
}
/***/ }),
/***/ "./node_modules/lru-cache/index.js":
/*!*****************************************!*\
!*** ./node_modules/lru-cache/index.js ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = LRUCache
// This will be a proper iterable 'Map' in engines that support it,
// or a fakey-fake PseudoMap in older versions.
var Map = __webpack_require__(/*! pseudomap */ "./node_modules/pseudomap/map.js")
var util = __webpack_require__(/*! util */ "./node_modules/util/util.js")
// A linked list to keep track of recently-used-ness
var Yallist = __webpack_require__(/*! yallist */ "./node_modules/lru-cache/node_modules/yallist/yallist.js")
// use symbols if possible, otherwise just _props
var hasSymbol = typeof Symbol === 'function'
var makeSymbol
if (hasSymbol) {
makeSymbol = function (key) {
return Symbol(key)
}
} else {
makeSymbol = function (key) {
return '_' + key
}
}
var MAX = makeSymbol('max')
var LENGTH = makeSymbol('length')
var LENGTH_CALCULATOR = makeSymbol('lengthCalculator')
var ALLOW_STALE = makeSymbol('allowStale')
var MAX_AGE = makeSymbol('maxAge')
var DISPOSE = makeSymbol('dispose')
var NO_DISPOSE_ON_SET = makeSymbol('noDisposeOnSet')
var LRU_LIST = makeSymbol('lruList')
var CACHE = makeSymbol('cache')
function naiveLength () { return 1 }
// lruList is a yallist where the head is the youngest
// item, and the tail is the oldest. the list contains the Hit
// objects as the entries.
// Each Hit object has a reference to its Yallist.Node. This
// never changes.
//
// cache is a Map (or PseudoMap) that matches the keys to
// the Yallist.Node object.
function LRUCache (options) {
if (!(this instanceof LRUCache)) {
return new LRUCache(options)
}
if (typeof options === 'number') {
options = { max: options }
}
if (!options) {
options = {}
}
var max = this[MAX] = options.max
// Kind of weird to have a default max of Infinity, but oh well.
if (!max ||
!(typeof max === 'number') ||
max <= 0) {
this[MAX] = Infinity
}
var lc = options.length || naiveLength
if (typeof lc !== 'function') {
lc = naiveLength
}
this[LENGTH_CALCULATOR] = lc
this[ALLOW_STALE] = options.stale || false
this[MAX_AGE] = options.maxAge || 0
this[DISPOSE] = options.dispose
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false
this.reset()
}
// resize the cache when the max changes.
Object.defineProperty(LRUCache.prototype, 'max', {
set: function (mL) {
if (!mL || !(typeof mL === 'number') || mL <= 0) {
mL = Infinity
}
this[MAX] = mL
trim(this)
},
get: function () {
return this[MAX]
},
enumerable: true
})
Object.defineProperty(LRUCache.prototype, 'allowStale', {
set: function (allowStale) {
this[ALLOW_STALE] = !!allowStale
},
get: function () {
return this[ALLOW_STALE]
},
enumerable: true
})
Object.defineProperty(LRUCache.prototype, 'maxAge', {
set: function (mA) {
if (!mA || !(typeof mA === 'number') || mA < 0) {
mA = 0
}
this[MAX_AGE] = mA
trim(this)
},
get: function () {
return this[MAX_AGE]
},
enumerable: true
})
// resize the cache when the lengthCalculator changes.
Object.defineProperty(LRUCache.prototype, 'lengthCalculator', {
set: function (lC) {
if (typeof lC !== 'function') {
lC = naiveLength
}
if (lC !== this[LENGTH_CALCULATOR]) {
this[LENGTH_CALCULATOR] = lC
this[LENGTH] = 0
this[LRU_LIST].forEach(function (hit) {
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key)
this[LENGTH] += hit.length
}, this)
}
trim(this)
},
get: function () { return this[LENGTH_CALCULATOR] },
enumerable: true
})
Object.defineProperty(LRUCache.prototype, 'length', {
get: function () { return this[LENGTH] },
enumerable: true
})
Object.defineProperty(LRUCache.prototype, 'itemCount', {
get: function () { return this[LRU_LIST].length },
enumerable: true
})
LRUCache.prototype.rforEach = function (fn, thisp) {
thisp = thisp || this
for (var walker = this[LRU_LIST].tail; walker !== null;) {
var prev = walker.prev
forEachStep(this, fn, walker, thisp)
walker = prev
}
}
function forEachStep (self, fn, node, thisp) {
var hit = node.value
if (isStale(self, hit)) {
del(self, node)
if (!self[ALLOW_STALE]) {
hit = undefined
}
}
if (hit) {
fn.call(thisp, hit.value, hit.key, self)
}
}
LRUCache.prototype.forEach = function (fn, thisp) {
thisp = thisp || this
for (var walker = this[LRU_LIST].head; walker !== null;) {
var next = walker.next
forEachStep(this, fn, walker, thisp)
walker = next
}
}
LRUCache.prototype.keys = function () {
return this[LRU_LIST].toArray().map(function (k) {
return k.key
}, this)
}
LRUCache.prototype.values = function () {
return this[LRU_LIST].toArray().map(function (k) {
return k.value
}, this)
}
LRUCache.prototype.reset = function () {
if (this[DISPOSE] &&
this[LRU_LIST] &&
this[LRU_LIST].length) {
this[LRU_LIST].forEach(function (hit) {
this[DISPOSE](hit.key, hit.value)
}, this)
}
this[CACHE] = new Map() // hash of items by key
this[LRU_LIST] = new Yallist() // list of items in order of use recency
this[LENGTH] = 0 // length of items in the list
}
LRUCache.prototype.dump = function () {
return this[LRU_LIST].map(function (hit) {
if (!isStale(this, hit)) {
return {
k: hit.key,
v: hit.value,
e: hit.now + (hit.maxAge || 0)
}
}
}, this).toArray().filter(function (h) {
return h
})
}
LRUCache.prototype.dumpLru = function () {
return this[LRU_LIST]
}
LRUCache.prototype.inspect = function (n, opts) {
var str = 'LRUCache {'
var extras = false
var as = this[ALLOW_STALE]
if (as) {
str += '\n allowStale: true'
extras = true
}
var max = this[MAX]
if (max && max !== Infinity) {
if (extras) {
str += ','
}
str += '\n max: ' + util.inspect(max, opts)
extras = true
}
var maxAge = this[MAX_AGE]
if (maxAge) {
if (extras) {
str += ','
}
str += '\n maxAge: ' + util.inspect(maxAge, opts)
extras = true
}
var lc = this[LENGTH_CALCULATOR]
if (lc && lc !== naiveLength) {
if (extras) {
str += ','
}
str += '\n length: ' + util.inspect(this[LENGTH], opts)
extras = true
}
var didFirst = false
this[LRU_LIST].forEach(function (item) {
if (didFirst) {
str += ',\n '
} else {
if (extras) {
str += ',\n'
}
didFirst = true
str += '\n '
}
var key = util.inspect(item.key).split('\n').join('\n ')
var val = { value: item.value }
if (item.maxAge !== maxAge) {
val.maxAge = item.maxAge
}
if (lc !== naiveLength) {
val.length = item.length
}
if (isStale(this, item)) {
val.stale = true
}
val = util.inspect(val, opts).split('\n').join('\n ')
str += key + ' => ' + val
})
if (didFirst || extras) {
str += '\n'
}
str += '}'
return str
}
LRUCache.prototype.set = function (key, value, maxAge) {
maxAge = maxAge || this[MAX_AGE]
var now = maxAge ? Date.now() : 0
var len = this[LENGTH_CALCULATOR](value, key)
if (this[CACHE].has(key)) {
if (len > this[MAX]) {
del(this, this[CACHE].get(key))
return false
}
var node = this[CACHE].get(key)
var item = node.value
// dispose of the old one before overwriting
// split out into 2 ifs for better coverage tracking
if (this[DISPOSE]) {
if (!this[NO_DISPOSE_ON_SET]) {
this[DISPOSE](key, item.value)
}
}
item.now = now
item.maxAge = maxAge
item.value = value
this[LENGTH] += len - item.length
item.length = len
this.get(key)
trim(this)
return true
}
var hit = new Entry(key, value, len, now, maxAge)
// oversized objects fall out of cache automatically.
if (hit.length > this[MAX]) {
if (this[DISPOSE]) {
this[DISPOSE](key, value)
}
return false
}
this[LENGTH] += hit.length
this[LRU_LIST].unshift(hit)
this[CACHE].set(key, this[LRU_LIST].head)
trim(this)
return true
}
LRUCache.prototype.has = function (key) {
if (!this[CACHE].has(key)) return false
var hit = this[CACHE].get(key).value
if (isStale(this, hit)) {
return false
}
return true
}
LRUCache.prototype.get = function (key) {
return get(this, key, true)
}
LRUCache.prototype.peek = function (key) {
return get(this, key, false)
}
LRUCache.prototype.pop = function () {
var node = this[LRU_LIST].tail
if (!node) return null
del(this, node)
return node.value
}
LRUCache.prototype.del = function (key) {
del(this, this[CACHE].get(key))
}
LRUCache.prototype.load = function (arr) {
// reset the cache
this.reset()
var now = Date.now()
// A previous serialized cache has the most recent items first
for (var l = arr.length - 1; l >= 0; l--) {
var hit = arr[l]
var expiresAt = hit.e || 0
if (expiresAt === 0) {
// the item was created without expiration in a non aged cache
this.set(hit.k, hit.v)
} else {
var maxAge = expiresAt - now
// dont add already expired items
if (maxAge > 0) {
this.set(hit.k, hit.v, maxAge)
}
}
}
}
LRUCache.prototype.prune = function () {
var self = this
this[CACHE].forEach(function (value, key) {
get(self, key, false)
})
}
function get (self, key, doUse) {
var node = self[CACHE].get(key)
if (node) {
var hit = node.value
if (isStale(self, hit)) {
del(self, node)
if (!self[ALLOW_STALE]) hit = undefined
} else {
if (doUse) {
self[LRU_LIST].unshiftNode(node)
}
}
if (hit) hit = hit.value
}
return hit
}
function isStale (self, hit) {
if (!hit || (!hit.maxAge && !self[MAX_AGE])) {
return false
}
var stale = false
var diff = Date.now() - hit.now
if (hit.maxAge) {
stale = diff > hit.maxAge
} else {
stale = self[MAX_AGE] && (diff > self[MAX_AGE])
}
return stale
}
function trim (self) {
if (self[LENGTH] > self[MAX]) {
for (var walker = self[LRU_LIST].tail;
self[LENGTH] > self[MAX] && walker !== null;) {
// We know that we're about to delete this one, and also
// what the next least recently used key will be, so just
// go ahead and set it now.
var prev = walker.prev
del(self, walker)
walker = prev
}
}
}
function del (self, node) {
if (node) {
var hit = node.value
if (self[DISPOSE]) {
self[DISPOSE](hit.key, hit.value)
}
self[LENGTH] -= hit.length
self[CACHE].delete(hit.key)
self[LRU_LIST].removeNode(node)
}
}
// classy, since V8 prefers predictable objects.
function Entry (key, value, length, now, maxAge) {
this.key = key
this.value = value
this.length = length
this.now = now
this.maxAge = maxAge || 0
}
/***/ }),
/***/ "./node_modules/lru-cache/node_modules/yallist/yallist.js":
/*!****************************************************************!*\
!*** ./node_modules/lru-cache/node_modules/yallist/yallist.js ***!
\****************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = Yallist
Yallist.Node = Node
Yallist.create = Yallist
function Yallist (list) {
var self = this
if (!(self instanceof Yallist)) {
self = new Yallist()
}
self.tail = null
self.head = null
self.length = 0
if (list && typeof list.forEach === 'function') {
list.forEach(function (item) {
self.push(item)
})
} else if (arguments.length > 0) {
for (var i = 0, l = arguments.length; i < l; i++) {
self.push(arguments[i])
}
}
return self
}
Yallist.prototype.removeNode = function (node) {
if (node.list !== this) {
throw new Error('removing node which does not belong to this list')
}
var next = node.next
var prev = node.prev
if (next) {
next.prev = prev
}
if (prev) {
prev.next = next
}
if (node === this.head) {
this.head = next
}
if (node === this.tail) {
this.tail = prev
}
node.list.length--
node.next = null
node.prev = null
node.list = null
}
Yallist.prototype.unshiftNode = function (node) {
if (node === this.head) {
return
}
if (node.list) {
node.list.removeNode(node)
}
var head = this.head
node.list = this
node.next = head
if (head) {
head.prev = node
}
this.head = node
if (!this.tail) {
this.tail = node
}
this.length++
}
Yallist.prototype.pushNode = function (node) {
if (node === this.tail) {
return
}
if (node.list) {
node.list.removeNode(node)
}
var tail = this.tail
node.list = this
node.prev = tail
if (tail) {
tail.next = node
}
this.tail = node
if (!this.head) {
this.head = node
}
this.length++
}
Yallist.prototype.push = function () {
for (var i = 0, l = arguments.length; i < l; i++) {
push(this, arguments[i])
}
return this.length
}
Yallist.prototype.unshift = function () {
for (var i = 0, l = arguments.length; i < l; i++) {
unshift(this, arguments[i])
}
return this.length
}
Yallist.prototype.pop = function () {
if (!this.tail) {
return undefined
}
var res = this.tail.value
this.tail = this.tail.prev
if (this.tail) {
this.tail.next = null
} else {
this.head = null
}
this.length--
return res
}
Yallist.prototype.shift = function () {
if (!this.head) {
return undefined
}
var res = this.head.value
this.head = this.head.next
if (this.head) {
this.head.prev = null
} else {
this.tail = null
}
this.length--
return res
}
Yallist.prototype.forEach = function (fn, thisp) {
thisp = thisp || this
for (var walker = this.head, i = 0; walker !== null; i++) {
fn.call(thisp, walker.value, i, this)
walker = walker.next
}
}
Yallist.prototype.forEachReverse = function (fn, thisp) {
thisp = thisp || this
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
fn.call(thisp, walker.value, i, this)
walker = walker.prev
}
}
Yallist.prototype.get = function (n) {
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
// abort out of the list early if we hit a cycle
walker = walker.next
}
if (i === n && walker !== null) {
return walker.value
}
}
Yallist.prototype.getReverse = function (n) {
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
// abort out of the list early if we hit a cycle
walker = walker.prev
}
if (i === n && walker !== null) {
return walker.value
}
}
Yallist.prototype.map = function (fn, thisp) {
thisp = thisp || this
var res = new Yallist()
for (var walker = this.head; walker !== null;) {
res.push(fn.call(thisp, walker.value, this))
walker = walker.next
}
return res
}
Yallist.prototype.mapReverse = function (fn, thisp) {
thisp = thisp || this
var res = new Yallist()
for (var walker = this.tail; walker !== null;) {
res.push(fn.call(thisp, walker.value, this))
walker = walker.prev
}
return res
}
Yallist.prototype.reduce = function (fn, initial) {
var acc
var walker = this.head
if (arguments.length > 1) {
acc = initial
} else if (this.head) {
walker = this.head.next
acc = this.head.value
} else {
throw new TypeError('Reduce of empty list with no initial value')
}
for (var i = 0; walker !== null; i++) {
acc = fn(acc, walker.value, i)
walker = walker.next
}
return acc
}
Yallist.prototype.reduceReverse = function (fn, initial) {
var acc
var walker = this.tail
if (arguments.length > 1) {
acc = initial
} else if (this.tail) {
walker = this.tail.prev
acc = this.tail.value
} else {
throw new TypeError('Reduce of empty list with no initial value')
}
for (var i = this.length - 1; walker !== null; i--) {
acc = fn(acc, walker.value, i)
walker = walker.prev
}
return acc
}
Yallist.prototype.toArray = function () {
var arr = new Array(this.length)
for (var i = 0, walker = this.head; walker !== null; i++) {
arr[i] = walker.value
walker = walker.next
}
return arr
}
Yallist.prototype.toArrayReverse = function () {
var arr = new Array(this.length)
for (var i = 0, walker = this.tail; walker !== null; i++) {
arr[i] = walker.value
walker = walker.prev
}
return arr
}
Yallist.prototype.slice = function (from, to) {
to = to || this.length
if (to < 0) {
to += this.length
}
from = from || 0
if (from < 0) {
from += this.length
}
var ret = new Yallist()
if (to < from || to < 0) {
return ret
}
if (from < 0) {
from = 0
}
if (to > this.length) {
to = this.length
}
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
walker = walker.next
}
for (; walker !== null && i < to; i++, walker = walker.next) {
ret.push(walker.value)
}
return ret
}
Yallist.prototype.sliceReverse = function (from, to) {
to = to || this.length
if (to < 0) {
to += this.length
}
from = from || 0
if (from < 0) {
from += this.length
}
var ret = new Yallist()
if (to < from || to < 0) {
return ret
}
if (from < 0) {
from = 0
}
if (to > this.length) {
to = this.length
}
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
walker = walker.prev
}
for (; walker !== null && i > from; i--, walker = walker.prev) {
ret.push(walker.value)
}
return ret
}
Yallist.prototype.reverse = function () {
var head = this.head
var tail = this.tail
for (var walker = head; walker !== null; walker = walker.prev) {
var p = walker.prev
walker.prev = walker.next
walker.next = p
}
this.head = tail
this.tail = head
return this
}
function push (self, item) {
self.tail = new Node(item, self.tail, null, self)
if (!self.head) {
self.head = self.tail
}
self.length++
}
function unshift (self, item) {
self.head = new Node(item, null, self.head, self)
if (!self.tail) {
self.tail = self.head
}
self.length++
}
function Node (value, prev, next, list) {
if (!(this instanceof Node)) {
return new Node(value, prev, next, list)
}
this.list = list
this.value = value
if (prev) {
prev.next = this
this.prev = prev
} else {
this.prev = null
}
if (next) {
next.prev = this
this.next = next
} else {
this.next = null
}
}
/***/ }),
/***/ "./node_modules/mitt/dist/mitt.es.js":
/*!*******************************************!*\
!*** ./node_modules/mitt/dist/mitt.es.js ***!
\*******************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
//
// An event handler can take an optional event argument
// and should not return a value
// An array of all currently registered event handlers for a type
// A map of event types and their corresponding event handlers.
/** Mitt: Tiny (~200b) functional event emitter / pubsub.
* @name mitt
* @returns {Mitt}
*/
function mitt(all ) {
all = all || Object.create(null);
return {
/**
* Register an event handler for the given type.
*
* @param {String} type Type of event to listen for, or `"*"` for all events
* @param {Function} handler Function to call in response to given event
* @memberOf mitt
*/
on: function on(type , handler ) {
(all[type] || (all[type] = [])).push(handler);
},
/**
* Remove an event handler for the given type.
*
* @param {String} type Type of event to unregister `handler` from, or `"*"`
* @param {Function} handler Handler function to remove
* @memberOf mitt
*/
off: function off(type , handler ) {
if (all[type]) {
all[type].splice(all[type].indexOf(handler) >>> 0, 1);
}
},
/**
* Invoke all handlers for the given type.
* If present, `"*"` handlers are invoked after type-matched handlers.
*
* @param {String} type The event type to invoke
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
* @memberOf mitt
*/
emit: function emit(type , evt ) {
(all[type] || []).slice().map(function (handler) { handler(evt); });
(all['*'] || []).slice().map(function (handler) { handler(type, evt); });
}
};
}
/* harmony default export */ __webpack_exports__["default"] = (mitt);
//# sourceMappingURL=mitt.es.js.map
/***/ }),
/***/ "./node_modules/process/browser.js":
/*!*****************************************!*\
!*** ./node_modules/process/browser.js ***!
\*****************************************/
/*! no static exports found */
/***/ (function(module, exports) {
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ }),
/***/ "./node_modules/pseudomap/map.js":
/*!***************************************!*\
!*** ./node_modules/pseudomap/map.js ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(process) {if (process.env.npm_package_name === 'pseudomap' &&
process.env.npm_lifecycle_script === 'test')
process.env.TEST_PSEUDOMAP = 'true'
if (typeof Map === 'function' && !process.env.TEST_PSEUDOMAP) {
module.exports = Map
} else {
module.exports = __webpack_require__(/*! ./pseudomap */ "./node_modules/pseudomap/pseudomap.js")
}
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../process/browser.js */ "./node_modules/process/browser.js")))
/***/ }),
/***/ "./node_modules/pseudomap/pseudomap.js":
/*!*********************************************!*\
!*** ./node_modules/pseudomap/pseudomap.js ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports) {
var hasOwnProperty = Object.prototype.hasOwnProperty
module.exports = PseudoMap
function PseudoMap (set) {
if (!(this instanceof PseudoMap)) // whyyyyyyy
throw new TypeError("Constructor PseudoMap requires 'new'")
this.clear()
if (set) {
if ((set instanceof PseudoMap) ||
(typeof Map === 'function' && set instanceof Map))
set.forEach(function (value, key) {
this.set(key, value)
}, this)
else if (Array.isArray(set))
set.forEach(function (kv) {
this.set(kv[0], kv[1])
}, this)
else
throw new TypeError('invalid argument')
}
}
PseudoMap.prototype.forEach = function (fn, thisp) {
thisp = thisp || this
Object.keys(this._data).forEach(function (k) {
if (k !== 'size')
fn.call(thisp, this._data[k].value, this._data[k].key)
}, this)
}
PseudoMap.prototype.has = function (k) {
return !!find(this._data, k)
}
PseudoMap.prototype.get = function (k) {
var res = find(this._data, k)
return res && res.value
}
PseudoMap.prototype.set = function (k, v) {
set(this._data, k, v)
}
PseudoMap.prototype.delete = function (k) {
var res = find(this._data, k)
if (res) {
delete this._data[res._index]
this._data.size--
}
}
PseudoMap.prototype.clear = function () {
var data = Object.create(null)
data.size = 0
Object.defineProperty(this, '_data', {
value: data,
enumerable: false,
configurable: true,
writable: false
})
}
Object.defineProperty(PseudoMap.prototype, 'size', {
get: function () {
return this._data.size
},
set: function (n) {},
enumerable: true,
configurable: true
})
PseudoMap.prototype.values =
PseudoMap.prototype.keys =
PseudoMap.prototype.entries = function () {
throw new Error('iterators are not implemented in this version')
}
// Either identical, or both NaN
function same (a, b) {
return a === b || a !== a && b !== b
}
function Entry (k, v, i) {
this.key = k
this.value = v
this._index = i
}
function find (data, k) {
for (var i = 0, s = '_' + k, key = s;
hasOwnProperty.call(data, key);
key = s + i++) {
if (same(data[key].key, k))
return data[key]
}
}
function set (data, k, v) {
for (var i = 0, s = '_' + k, key = s;
hasOwnProperty.call(data, key);
key = s + i++) {
if (same(data[key].key, k)) {
data[key].value = v
return
}
}
data.size++
data[key] = new Entry(k, v, key)
}
/***/ }),
/***/ "./node_modules/util/support/isBufferBrowser.js":
/*!******************************************************!*\
!*** ./node_modules/util/support/isBufferBrowser.js ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = function isBuffer(arg) {
return arg && typeof arg === 'object'
&& typeof arg.copy === 'function'
&& typeof arg.fill === 'function'
&& typeof arg.readUInt8 === 'function';
}
/***/ }),
/***/ "./node_modules/util/util.js":
/*!***********************************!*\
!*** ./node_modules/util/util.js ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var formatRegExp = /%[sdj%]/g;
exports.format = function(f) {
if (!isString(f)) {
var objects = [];
for (var i = 0; i < arguments.length; i++) {
objects.push(inspect(arguments[i]));
}
return objects.join(' ');
}
var i = 1;
var args = arguments;
var len = args.length;
var str = String(f).replace(formatRegExp, function(x) {
if (x === '%%') return '%';
if (i >= len) return x;
switch (x) {
case '%s': return String(args[i++]);
case '%d': return Number(args[i++]);
case '%j':
try {
return JSON.stringify(args[i++]);
} catch (_) {
return '[Circular]';
}
default:
return x;
}
});
for (var x = args[i]; i < len; x = args[++i]) {
if (isNull(x) || !isObject(x)) {
str += ' ' + x;
} else {
str += ' ' + inspect(x);
}
}
return str;
};
// Mark that a method should not be used.
// Returns a modified function which warns once by default.
// If --no-deprecation is set, then it is a no-op.
exports.deprecate = function(fn, msg) {
// Allow for deprecating things in the process of starting up.
if (isUndefined(global.process)) {
return function() {
return exports.deprecate(fn, msg).apply(this, arguments);
};
}
if (process.noDeprecation === true) {
return fn;
}
var warned = false;
function deprecated() {
if (!warned) {
if (process.throwDeprecation) {
throw new Error(msg);
} else if (process.traceDeprecation) {
console.trace(msg);
} else {
console.error(msg);
}
warned = true;
}
return fn.apply(this, arguments);
}
return deprecated;
};
var debugs = {};
var debugEnviron;
exports.debuglog = function(set) {
if (isUndefined(debugEnviron))
debugEnviron = process.env.NODE_DEBUG || '';
set = set.toUpperCase();
if (!debugs[set]) {
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
var pid = process.pid;
debugs[set] = function() {
var msg = exports.format.apply(exports, arguments);
console.error('%s %d: %s', set, pid, msg);
};
} else {
debugs[set] = function() {};
}
}
return debugs[set];
};
/**
* Echos the value of a value. Trys to print the value out
* in the best way possible given the different types.
*
* @param {Object} obj The object to print out.
* @param {Object} opts Optional options object that alters the output.
*/
/* legacy: obj, showHidden, depth, colors*/
function inspect(obj, opts) {
// default options
var ctx = {
seen: [],
stylize: stylizeNoColor
};
// legacy...
if (arguments.length >= 3) ctx.depth = arguments[2];
if (arguments.length >= 4) ctx.colors = arguments[3];
if (isBoolean(opts)) {
// legacy...
ctx.showHidden = opts;
} else if (opts) {
// got an "options" object
exports._extend(ctx, opts);
}
// set default options
if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
if (isUndefined(ctx.depth)) ctx.depth = 2;
if (isUndefined(ctx.colors)) ctx.colors = false;
if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
if (ctx.colors) ctx.stylize = stylizeWithColor;
return formatValue(ctx, obj, ctx.depth);
}
exports.inspect = inspect;
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
inspect.colors = {
'bold' : [1, 22],
'italic' : [3, 23],
'underline' : [4, 24],
'inverse' : [7, 27],
'white' : [37, 39],
'grey' : [90, 39],
'black' : [30, 39],
'blue' : [34, 39],
'cyan' : [36, 39],
'green' : [32, 39],
'magenta' : [35, 39],
'red' : [31, 39],
'yellow' : [33, 39]
};
// Don't use 'blue' not visible on cmd.exe
inspect.styles = {
'special': 'cyan',
'number': 'yellow',
'boolean': 'yellow',
'undefined': 'grey',
'null': 'bold',
'string': 'green',
'date': 'magenta',
// "name": intentionally not styling
'regexp': 'red'
};
function stylizeWithColor(str, styleType) {
var style = inspect.styles[styleType];
if (style) {
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
'\u001b[' + inspect.colors[style][1] + 'm';
} else {
return str;
}
}
function stylizeNoColor(str, styleType) {
return str;
}
function arrayToHash(array) {
var hash = {};
array.forEach(function(val, idx) {
hash[val] = true;
});
return hash;
}
function formatValue(ctx, value, recurseTimes) {
// Provide a hook for user-specified inspect functions.
// Check that value is an object with an inspect function on it
if (ctx.customInspect &&
value &&
isFunction(value.inspect) &&
// Filter out the util module, it's inspect function is special
value.inspect !== exports.inspect &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
var ret = value.inspect(recurseTimes, ctx);
if (!isString(ret)) {
ret = formatValue(ctx, ret, recurseTimes);
}
return ret;
}
// Primitive types cannot have properties
var primitive = formatPrimitive(ctx, value);
if (primitive) {
return primitive;
}
// Look up the keys of the object.
var keys = Object.keys(value);
var visibleKeys = arrayToHash(keys);
if (ctx.showHidden) {
keys = Object.getOwnPropertyNames(value);
}
// IE doesn't make error fields non-enumerable
// http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
if (isError(value)
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
return formatError(value);
}
// Some type of object without properties can be shortcutted.
if (keys.length === 0) {
if (isFunction(value)) {
var name = value.name ? ': ' + value.name : '';
return ctx.stylize('[Function' + name + ']', 'special');
}
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
}
if (isDate(value)) {
return ctx.stylize(Date.prototype.toString.call(value), 'date');
}
if (isError(value)) {
return formatError(value);
}
}
var base = '', array = false, braces = ['{', '}'];
// Make Array say that they are Array
if (isArray(value)) {
array = true;
braces = ['[', ']'];
}
// Make functions say that they are functions
if (isFunction(value)) {
var n = value.name ? ': ' + value.name : '';
base = ' [Function' + n + ']';
}
// Make RegExps say that they are RegExps
if (isRegExp(value)) {
base = ' ' + RegExp.prototype.toString.call(value);
}
// Make dates with properties first say the date
if (isDate(value)) {
base = ' ' + Date.prototype.toUTCString.call(value);
}
// Make error with message first say the error
if (isError(value)) {
base = ' ' + formatError(value);
}
if (keys.length === 0 && (!array || value.length == 0)) {
return braces[0] + base + braces[1];
}
if (recurseTimes < 0) {
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
} else {
return ctx.stylize('[Object]', 'special');
}
}
ctx.seen.push(value);
var output;
if (array) {
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
} else {
output = keys.map(function(key) {
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
});
}
ctx.seen.pop();
return reduceToSingleString(output, base, braces);
}
function formatPrimitive(ctx, value) {
if (isUndefined(value))
return ctx.stylize('undefined', 'undefined');
if (isString(value)) {
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
.replace(/'/g, "\\'")
.replace(/\\"/g, '"') + '\'';
return ctx.stylize(simple, 'string');
}
if (isNumber(value))
return ctx.stylize('' + value, 'number');
if (isBoolean(value))
return ctx.stylize('' + value, 'boolean');
// For some reason typeof null is "object", so special case here.
if (isNull(value))
return ctx.stylize('null', 'null');
}
function formatError(value) {
return '[' + Error.prototype.toString.call(value) + ']';
}
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
var output = [];
for (var i = 0, l = value.length; i < l; ++i) {
if (hasOwnProperty(value, String(i))) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
String(i), true));
} else {
output.push('');
}
}
keys.forEach(function(key) {
if (!key.match(/^\d+$/)) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
key, true));
}
});
return output;
}
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
var name, str, desc;
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
if (desc.get) {
if (desc.set) {
str = ctx.stylize('[Getter/Setter]', 'special');
} else {
str = ctx.stylize('[Getter]', 'special');
}
} else {
if (desc.set) {
str = ctx.stylize('[Setter]', 'special');
}
}
if (!hasOwnProperty(visibleKeys, key)) {
name = '[' + key + ']';
}
if (!str) {
if (ctx.seen.indexOf(desc.value) < 0) {
if (isNull(recurseTimes)) {
str = formatValue(ctx, desc.value, null);
} else {
str = formatValue(ctx, desc.value, recurseTimes - 1);
}
if (str.indexOf('\n') > -1) {
if (array) {
str = str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n').substr(2);
} else {
str = '\n' + str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n');
}
}
} else {
str = ctx.stylize('[Circular]', 'special');
}
}
if (isUndefined(name)) {
if (array && key.match(/^\d+$/)) {
return str;
}
name = JSON.stringify('' + key);
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
name = name.substr(1, name.length - 2);
name = ctx.stylize(name, 'name');
} else {
name = name.replace(/'/g, "\\'")
.replace(/\\"/g, '"')
.replace(/(^"|"$)/g, "'");
name = ctx.stylize(name, 'string');
}
}
return name + ': ' + str;
}
function reduceToSingleString(output, base, braces) {
var numLinesEst = 0;
var length = output.reduce(function(prev, cur) {
numLinesEst++;
if (cur.indexOf('\n') >= 0) numLinesEst++;
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
}, 0);
if (length > 60) {
return braces[0] +
(base === '' ? '' : base + '\n ') +
' ' +
output.join(',\n ') +
' ' +
braces[1];
}
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
}
// NOTE: These type checking functions intentionally don't use `instanceof`
// because it is fragile and can be easily faked with `Object.create()`.
function isArray(ar) {
return Array.isArray(ar);
}
exports.isArray = isArray;
function isBoolean(arg) {
return typeof arg === 'boolean';
}
exports.isBoolean = isBoolean;
function isNull(arg) {
return arg === null;
}
exports.isNull = isNull;
function isNullOrUndefined(arg) {
return arg == null;
}
exports.isNullOrUndefined = isNullOrUndefined;
function isNumber(arg) {
return typeof arg === 'number';
}
exports.isNumber = isNumber;
function isString(arg) {
return typeof arg === 'string';
}
exports.isString = isString;
function isSymbol(arg) {
return typeof arg === 'symbol';
}
exports.isSymbol = isSymbol;
function isUndefined(arg) {
return arg === void 0;
}
exports.isUndefined = isUndefined;
function isRegExp(re) {
return isObject(re) && objectToString(re) === '[object RegExp]';
}
exports.isRegExp = isRegExp;
function isObject(arg) {
return typeof arg === 'object' && arg !== null;
}
exports.isObject = isObject;
function isDate(d) {
return isObject(d) && objectToString(d) === '[object Date]';
}
exports.isDate = isDate;
function isError(e) {
return isObject(e) &&
(objectToString(e) === '[object Error]' || e instanceof Error);
}
exports.isError = isError;
function isFunction(arg) {
return typeof arg === 'function';
}
exports.isFunction = isFunction;
function isPrimitive(arg) {
return arg === null ||
typeof arg === 'boolean' ||
typeof arg === 'number' ||
typeof arg === 'string' ||
typeof arg === 'symbol' || // ES6 symbol
typeof arg === 'undefined';
}
exports.isPrimitive = isPrimitive;
exports.isBuffer = __webpack_require__(/*! ./support/isBuffer */ "./node_modules/util/support/isBufferBrowser.js");
function objectToString(o) {
return Object.prototype.toString.call(o);
}
function pad(n) {
return n < 10 ? '0' + n.toString(10) : n.toString(10);
}
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec'];
// 26 Feb 16:19:34
function timestamp() {
var d = new Date();
var time = [pad(d.getHours()),
pad(d.getMinutes()),
pad(d.getSeconds())].join(':');
return [d.getDate(), months[d.getMonth()], time].join(' ');
}
// log is just a thin wrapper to console.log that prepends a timestamp
exports.log = function() {
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
};
/**
* Inherit the prototype methods from one constructor into another.
*
* The Function.prototype.inherits from lang.js rewritten as a standalone
* function (not on Function.prototype). NOTE: If this file is to be loaded
* during bootstrapping this function needs to be rewritten using some native
* functions as prototype setup using normal JavaScript does not work as
* expected during bootstrapping (see mirror.js in r114903).
*
* @param {function} ctor Constructor function which needs to inherit the
* prototype.
* @param {function} superCtor Constructor function to inherit prototype from.
*/
exports.inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
exports._extend = function(origin, add) {
// Don't do anything if add isn't an object
if (!add || !isObject(add)) return origin;
var keys = Object.keys(add);
var i = keys.length;
while (i--) {
origin[keys[i]] = add[keys[i]];
}
return origin;
};
function hasOwnProperty(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../process/browser.js */ "./node_modules/process/browser.js")))
/***/ }),
/***/ "./node_modules/webpack/buildin/global.js":
/*!***********************************!*\
!*** (webpack)/buildin/global.js ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports) {
var g;
// This works in non-strict mode
g = (function() {
return this;
})();
try {
// This works if eval is allowed (see CSP)
g = g || Function("return this")() || (1, eval)("this");
} catch (e) {
// This works if the window reference is available
if (typeof window === "object") g = window;
}
// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}
module.exports = g;
/***/ }),
/***/ "./node_modules/worker-loader/dist/workers/InlineWorker.js":
/*!*****************************************************************!*\
!*** ./node_modules/worker-loader/dist/workers/InlineWorker.js ***!
\*****************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// http://stackoverflow.com/questions/10343913/how-to-create-a-web-worker-from-a-string
var URL = window.URL || window.webkitURL;
module.exports = function (content, url) {
try {
try {
var blob;
try {
// BlobBuilder = Deprecated, but widely implemented
var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
blob = new BlobBuilder();
blob.append(content);
blob = blob.getBlob();
} catch (e) {
// The proposed API
blob = new Blob([content]);
}
return new Worker(URL.createObjectURL(blob));
} catch (e) {
return new Worker('data:application/javascript,' + encodeURIComponent(content));
}
} catch (e) {
if (!url) {
throw Error('Inline worker is not supported');
}
return new Worker(url);
}
};
/***/ }),
/***/ "./package.json":
/*!**********************!*\
!*** ./package.json ***!
\**********************/
/*! exports provided: name, version, sideEffects, description, repository, author, contributors, license, files, dependencies, devDependencies, main, scripts, browserslist, previousMapboxGLVersions, default */
/***/ (function(module) {
module.exports = {"name":"@carto/carto-vl","version":"1.4.2","sideEffects":false,"description":"CARTO Vector library","repository":{"type":"git","url":"git://github.com/CartoDB/carto-vl.git"},"author":{"name":"CARTO","url":"https://carto.com/"},"contributors":["David Manzanares <dmanzanares@carto.com>","Iago Lastra <iago@carto.com>","Jesús Arroyo Torrens <jarroyo@carto.com>","Javier Goizueta <jgoizueta@carto.com>","Mamata Akella <makella@carto.com>","Raúl Ochoa <rochoa@carto.com>","Ariana Escobar <ariana@carto.com>","Elena Torro <elena@carto.com>","Víctor Velarde <victor@carto.com>","Jesús Botella <jbotella@carto.com>"],"license":"BSD-3-Clause","files":["src","dist"],"dependencies":{"@babel/runtime":"^7.0.0","@mapbox/vector-tile":"^1.3.0","cartocolor":"^4.0.0","earcut":"^2.1.2","gl-matrix":"^2.8.1","jsep":"CartoDB/jsep#additional-char-ids-packaged-update-1","lineclip":"^1.1.5","lru-cache":"^4.1.1","mitt":"^1.1.3","pbf":"^3.1.0"},"devDependencies":{"@babel/core":"^7.0.0","@babel/plugin-transform-runtime":"^7.1.0","@babel/preset-env":"^7.0.0","aws-sdk":"^2.372.0","babel-loader":"^8.0.0","chai":"^4.1.2","chai-as-promised":"^7.1.1","current-git-branch":"^1.1.0","eslint":"^5.7.0","eslint-config-semistandard":"^12.0.1","eslint-config-standard":"^12.0.0","eslint-plugin-import":"^2.13.0","eslint-plugin-node":"^7.0.1","eslint-plugin-promise":"^4.0.1","eslint-plugin-standard":"^4.0.0","exquisite-sst":"^1.6.0","fastly":"^2.2.0","glob":"^7.1.2","http-server":"^0.11.1","jasmine-core":"^3.2.1","jsdoc":"^3.5.5","jsdoc-escape-at":"^1.0.1","karma":"^3.0.0","karma-chrome-launcher":"^2.2.0","karma-falcon-benchmark":"^0.1.1-0","karma-falcon-benchmark-reporter":"^0.1.1-0","karma-jasmine":"^1.1.2","karma-mocha-reporter":"^2.2.5","karma-sourcemap-loader":"^0.3.7","karma-webpack":"^3.0.5","lodash.template":"^4.4.0","mapbox-gl":"1.0.0","mocha":"^5.0.0","puppeteer":"^1.1.0","selenium-webdriver":"3.6.0","serve":"^10.0.2","sloc":"^0.2.0","svg-inline-loader":"^0.8.0","wait-on":"^3.1.0","webpack":"^4.17.1","webpack-bundle-analyzer":"^3.0.3","webpack-cli":"^3.1.1","webpack-glsl-loader":"^1.0.1","worker-loader":"^2.0.0"},"main":"dist/carto-vl.min.js","scripts":{"build":"yarn build:clean && yarn build:dev && yarn build:min","build:clean":"rm -rf dist/","build:dev":"webpack --config webpack/webpack.config.js","build:min":"webpack --config webpack/webpack.min.config.js","build:min:stats":"webpack --config webpack/webpack.min.config.js --profile --json > dist/stats.json && webpack-bundle-analyzer --port 4200 dist/stats.json","build:watch":"webpack -w --config webpack/webpack.config.js","docs":"rm -rf docs/public; jsdoc --configure config/jsdoc/public-conf.json","docs:all":"rm -rf docs/all; jsdoc --configure config/jsdoc/all-conf.json","lint":"eslint .","lint:fix":"eslint . --fix","test":"yarn test:unit && yarn lint && yarn docs","test:unit":"karma start --single-run --browsers ChromeHeadlessNoSandbox test/unit/karma.conf.js","test:unit:min":"MIN=1 yarn test:unit","test:watch":"karma start --no-single-run --auto-watch --browsers ChromeHeadlessNoSandbox test/unit/karma.conf.js","test:watchc":"karma start --no-single-run --auto-watch --browsers Chrome test/unit/karma.conf.js","test:user":"karma start --single-run --browsers ChromeHeadlessNoSandbox test/integration/user/karma.conf.js","test:user:min":"MIN=1 yarn test:user","test:user:watch":"karma start --no-single-run --auto-watch --browsers ChromeHeadlessNoSandbox test/integration/user/karma.conf.js","test:user:watchc":"karma start --no-single-run --browsers Chrome test/integration/user/karma.conf.js","test:browser":"karma start --no-single-run --browsers Chrome test/unit/karma.conf.js","test:browsers:connect":"sc -u $SAUCELABS_USER -k $SAUCELABS_KEY -i cartovl-tunnel --no-autodetect","test:browsers:compatibility":"./scripts/run-cross-browser-tests.sh","test:render":"yarn build:clean && yarn build:dev && mocha test/integration/render/render.test.js --timeout 15000","test:render:min":"yarn build:clean && yarn build:min && MIN=1 mocha test/integration/render/render.test.js --timeout 15000","test:render:clean":"rm -rf test/integration/render/scenarios/**/**/reference.png","test:render:prepare":"yarn build:clean && yarn build:dev && node test/integration/render/render.prepare.js ","test:e2e":"./scripts/run-local-e2e.sh","test:e2e:clean":"rm -rf test/acceptance/e2e/**/reference.png","test:e2e:prepare":"yarn build:clean && yarn build:dev && node test/acceptance/e2e.prepare.js ","test:fps":"node test/benchmark/fps/benchmark.js","test:perf":"karma start --single-run --browsers Chrome test/benchmark/karma.conf.js","serve":"yarn build && yarn docs && http-server --cors -p 8080","preversion":"./scripts/preversion.sh","postversion":"git push origin HEAD --follow-tags","prepublishOnly":"yarn build && ./scripts/release.sh","cdn:branch:publish":"yarn build && ./scripts/publish-branch.sh","ghpublish":"git checkout gh-pages && git pull origin gh-pages && git merge master && yarn build && yarn docs && git commit -a -m \"Auto generated gh-pages\" && git push origin gh-pages && git checkout master","loc":"sloc src/ examples/"},"browserslist":["defaults","not ie <12","not edge <17"],"previousMapboxGLVersions":["v0.53.1","v0.54.0"]};
/***/ }),
/***/ "./src/Layer.js":
/*!**********************!*\
!*** ./src/Layer.js ***!
\**********************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Layer; });
/* harmony import */ var mitt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! mitt */ "./node_modules/mitt/dist/mitt.es.js");
/* harmony import */ var _utils_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils/util */ "./src/utils/util.js");
/* harmony import */ var _Viz__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Viz */ "./src/Viz.js");
/* harmony import */ var _sources_Base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sources/Base */ "./src/sources/Base.js");
/* harmony import */ var _renderer_Renderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./renderer/Renderer */ "./src/renderer/Renderer.js");
/* harmony import */ var _renderer_RenderLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./renderer/RenderLayer */ "./src/renderer/RenderLayer.js");
/* harmony import */ var _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../src/errors/carto-validation-error */ "./src/errors/carto-validation-error.js");
/* harmony import */ var _src_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../src/errors/carto-runtime-error */ "./src/errors/carto-runtime-error.js");
/* harmony import */ var _renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderer/viz/expressions */ "./src/renderer/viz/expressions.js");
/* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! gl-matrix */ "./node_modules/gl-matrix/lib/gl-matrix.js");
/* harmony import */ var _LayerConcurrencyHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./LayerConcurrencyHelper */ "./src/LayerConcurrencyHelper.js");
// There is one renderer per map, so the layers added to the same map
// use the same renderer with each renderLayer
const renderers = new WeakMap();
const states = Object.freeze({
INIT: 'init', // Initial state until the Source is rendered for the first time
IDLE: 'idle', // The Source has been rendered for the first time already, but there are no scheduled updates
UPDATING: 'updating' // The Source has been rendered for the first time already and there is a scheduled update
});
/**
*
* A Layer is the primary way to visualize geospatial data.
*
* To create a layer a {@link carto.source|source} and {@link carto.Viz|viz} are required:
*
* - The {@link carto.source|source} is used to know **what** data will be displayed in the Layer.
* - The {@link carto.Viz|viz} is used to know **how** to draw the data in the Layer, Viz instances can only be bound to one single layer.
*
* Note: This Layer implements {@link https://www.mapbox.com/mapbox-gl-js/api/#customlayerinterface|Mapbox GL JS - Custom Layer Interface}
*
* @param {String} id - The ID of the layer. Can be used in the {@link addTo|addTo} function
* @param {carto.source} source - The source of the data
* @param {carto.Viz} viz - The description of the visualization of the data
* @throws CartoError
*
* @example
* const layer = new carto.Layer('layer0', source, viz);
*
* @constructor Layer
* @name carto.Layer
* @api
*/
class Layer {
constructor (id, source, viz) {
this._checkId(id);
this._checkSource(source);
this._checkViz(viz);
/* Mapbox GL Custom Layer API attributes:
- id: string
- type: "custom"
*/
this.id = id;
this.type = 'custom';
viz._boundLayer = this;
this._context = new Promise(resolve => {
this._contextInitialize = resolve;
});
this._state = states.INIT;
this._visible = true;
this._emitter = Object(mitt__WEBPACK_IMPORTED_MODULE_0__["default"])();
this._renderLayer = new _renderer_RenderLayer__WEBPACK_IMPORTED_MODULE_5__["default"]();
this.concurrencyHelper = new _LayerConcurrencyHelper__WEBPACK_IMPORTED_MODULE_10__["default"]();
this._initialSource = source;
this._initialViz = viz;
this._renderWaiters = [];
this._cameraMatrix = gl_matrix__WEBPACK_IMPORTED_MODULE_9__["mat4"].identity([]);
this._updateLayer = this.update(source, viz);
}
/**
* Layer visibility property.
*
* @type {boolean}
* @memberof carto.Layer
* @instance
* @api
*/
get visible () {
return this._visible;
}
set visible (visible) {
const initial = this._visible;
this.map.setLayoutProperty(this.id, 'visibility', visible ? 'visible' : 'none');
this._visible = visible;
if (visible !== initial) {
this._fire('updated', 'visibility change');
}
}
/**
* Change layer visibility to visible
*
* @memberof carto.Layer
* @instance
* @api
* @fires updated
*/
show () {
this.visible = true;
}
/**
* Change layer visibility to hidden
*
* @memberof carto.Layer
* @instance
* @api
* @fires updated
*/
hide () {
this.visible = false;
}
/**
* Register an event handler for the given event name.
*
* @param {String} eventName - Type of event to listen for. Valid names are: `loaded`, `updated`, and `removed`.
* @param {function} callback - Function to call in response to given event
* @memberof carto.Layer
* @instance
* @api
*/
on (eventName, callback) {
return this._emitter.on(eventName, callback);
}
/**
* Remove an event handler for the given type.
*
* @param {String} eventName - Type of event to unregister. Valid names are: `loaded`, `updated`, and `removed`.
* @param {function} callback - Handler function to unregister
* @memberof carto.Layer
* @instance
* @api
*/
off (eventName, callback) {
return this._emitter.off(eventName, callback);
}
/**
* Add this layer to a map. If the map's style is not loaded yet it will wait for it to add the layer as soon as possible.
*
* @param {mapboxgl.Map} map - The map on which to add the layer
* @param {string?} beforeLayerID - The ID of an existing layer to insert the new layer before. If this values is not passed the layer will be added on the top of the existing layers.
* @memberof carto.Layer
* @instance
* @api
*/
async addTo (map, beforeLayerID) {
// Manage errors, whether they are an Evented Error or a common Error
try {
map.once('error', (data) => {
console.warn(data.error.message);
this._waitForMapToLoad(map, beforeLayerID);
});
map.addLayer(this, beforeLayerID);
} catch (error) {
const STYLE_ERROR_REGEX = /Style is not done loading/;
const NO_STYLE_AT_ALL = /Cannot read property 'addLayer' of undefined/;
if (!(STYLE_ERROR_REGEX.test(error) || NO_STYLE_AT_ALL.test(error))) {
throw new _src_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_7__["default"](`Error adding layer to map: ${error}`);
}
this._waitForMapToLoad(map, beforeLayerID);
}
}
_waitForMapToLoad (map, beforeLayerID) {
map.on('load', () => {
map.addLayer(this, beforeLayerID);
});
}
/**
* Remove this layer from the map. It should be called after the layer is loaded. Otherwise, it will not delete the layer.
*
* @memberof carto.Layer
* @instance
* @api
*/
remove () {
if (this.map) {
this.map.removeLayer(this.id);
}
}
/**
* Update the layer with a new Source and a new Viz object, replacing the current ones. The update is done atomically, i.e.:
* the viz will be changed with the source, not before it.
*
* This method will return a promise that will be resolved once the source and the visualization are validated.
*
* The promise will be rejected if the validation fails, for example
* because the visualization expects a property name that is not present in the source.
*
* The promise will be rejected also if this method is invoked again before the first promise is resolved.
* If the promise is rejected the layer's source and viz won't be changed by this call.
*
* Concurrent calls to `blendToViz` or `blendTo` won't override calls to update (like calls to `update` do).
*
* @param {carto.source} source - The new Source object.
* @param {carto.Viz?} viz - Optional. The new Viz object. Defaults to the current viz.
* @memberof carto.Layer
* @instance
* @async
* @api
*/
async update (source, viz = this._viz) {
return this._update(source, viz, true);
}
async _update (source, viz, majorChange) {
this._checkSource(source);
this._checkViz(viz);
const safeSource = this._cloneSourceIfDifferent(source);
let change = this._initChange(majorChange);
const [, metadata] = await Promise.all([
viz.loadImages(), // start requesting images ASAP
safeSource.requestMetadata(viz)
]);
await this._context;
this._endChange(majorChange, change);
this._commitSuccesfulUpdate(metadata, viz, safeSource);
}
_initChange (majorChange) {
if (majorChange) {
return this.concurrencyHelper.initMajorChange();
}
return this.concurrencyHelper.initMinorChange();
}
_endChange (majorChange, change) {
if (majorChange) {
this.concurrencyHelper.endMajorChange(change);
} else {
this.concurrencyHelper.endMinorChange(change);
}
}
/**
* Updating viz and source, after having checked them and having required new metadata
*
* @param {Metadata} metadata
* @param {carto.Viz} newViz
* @param {carto.source} newSource
*/
_commitSuccesfulUpdate (metadata, newViz, newSource) {
this.metadata = metadata;
this._commitVizChange(newViz);
this._commitSourceChange(newSource);
// to force pre-render (which gives us the matrix to request data from the source...)
this._needRefresh();
}
/**
* Updates the viz with the newViz
*
* @param {carto.Viz} newViz
*/
_commitVizChange (newViz) {
if (this._viz) {
this._viz.onChange(null);
}
newViz.setDefaultsIfRequired(this.metadata.geomType);
newViz.setDefaultsIfRequired(this._renderLayer.type);
newViz.onChange(this._vizChanged.bind(this));
newViz._bindMetadata(this.metadata);
newViz.gl = this.gl;
this._viz = newViz;
}
/**
* Updates the source with the newSource
*
* @param {carto.source} newSource
*/
_commitSourceChange (newSource) {
newSource.bindLayer(this._onDataframeAdded.bind(this));
if (newSource !== this._source) {
this._freeSource();
}
this._source = newSource;
}
/**
* Returns a safe source from the new required source.
*
* @param {carto.source} source
* @returns {carto.source} safeSource
*/
_cloneSourceIfDifferent (source) {
// The cloning allows the source to be safely used in other layers.
// That's because using `source.requestMetadata()` can update later on its internal state (depending on what's required by the viz)
let safeSource;
if (source !== this._source) {
safeSource = source._clone();
} else {
safeSource = source;
}
return safeSource;
}
/**
* Blend the current viz with another viz.
*
* This allows smooth transitions between two different Vizs.
*
* Blending won't be performed when convenient for the attached Source. This
* happens with Maps API sources when the new Viz uses a different set of properties or
* aggregations. In these cases a hard transition will be used instead.
*
* This method returns a promise that will be resolved if validations passed.
*
* The promise will be rejected if the validation fails, for example
* because the visualization expects a property name that is not present in the source.
*
* The promise will be rejected also if this method is invoked again before the first promise is resolved.
* If the promise is rejected the layer's viz won't be changed by this call.
*
* Concurrent calls to `update` will override the effects of `blendToViz`:
* if a call to `blendToViz` is performed after a call to `update`, but the `update` hasn't been resolved yet,
* the call to `update` will override the call to `blendToViz` is it resolves.
*
* @example <caption> Smooth transition variating point size </caption>
* // We create two different vizs varying the width
* const viz0 = new carto.Viz({ width: 10 });
* const viz1 = new carto.Viz({ width: 20 });
* // Create a layer with the first viz
* const layer = new carto.Layer('layer', source, viz0);
* // We add the layer to the map, the points in this layer will have widh 10
* layer.addTo(map, 'layer0');
* // The points will be animated from 10px to 20px for 500ms.
* layer.blendToViz(viz1, 500);
*
* @param {carto.Viz} viz - The final viz
* @param {number} [duration=400] - The animation duration in milliseconds
*
* @memberof carto.Layer
* @instance
* @async
* @api
*/
async blendToViz (viz, ms = 400, interpolator = _renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_8__["cubic"]) {
this._checkViz(viz);
await this._updateLayer;
// It doesn't make sense to blendTo if a new request is required
if (this._viz && !this._source.requiresNewMetadata(viz)) {
Object.keys(this._viz.variables).map(varName => {
viz.variables[varName] = this._viz.variables[varName];
});
viz.color._blendFrom(this._viz.color, ms, interpolator);
viz.strokeColor._blendFrom(this._viz.strokeColor, ms, interpolator);
viz.width._blendFrom(this._viz.width, ms, interpolator);
viz.strokeWidth._blendFrom(this._viz.strokeWidth, ms, interpolator);
viz.filter._blendFrom(this._viz.filter, ms, interpolator);
// FIXME viz.symbol._blendFrom(this._viz.symbol, ms, interpolator);
// FIXME viz.symbolPlacement._blendFrom(this._viz.symbolPlacement, ms, interpolator);
}
return this._update(this._source, viz, false);
}
/**
* Viz attached to this layer.
*
* Calls to `blendToViz` and `update` won't update the viz until those calls "commit",
* having performed and completed all asynchronous necessary sanity checks.
*
* @type {carto.Viz}
* @memberof carto.Layer
* @readonly
* @api
*/
get viz () {
return this._viz;
}
hasDataframes () {
return this._renderLayer.hasDataframes();
}
getNumFeatures () {
return this._renderLayer.getNumFeatures();
}
getFeaturesAtPosition (pos) {
return this.visible
? this._renderLayer.getFeaturesAtPosition(pos).map(this._addLayerIdToFeature.bind(this))
: [];
}
isAnimated () {
return this._viz && this._viz.isAnimated();
}
isPlaying () {
return this._viz && this._viz.isPlaying();
}
/**
* Custom Layer API: `onAdd` function
*/
onAdd (map, gl) {
this.map = map;
this.gl = gl;
this.renderer = _getRenderer(map, gl);
// Initialize render layer
this._renderLayer.setRenderer(this.renderer);
this._contextInitialize();
}
/**
* Custom Layer API: `onRemove` function
*/
onRemove (map, gl) {
this._fire('removed', this);
}
/**
* Custom Layer API: `prerender` function
*/
prerender (gl, matrix) {
const isNewCameraMatrix = this._detectAndSetNewMatrix(matrix);
if (this._source && this.visible) {
this._checkSourceRequestsAndFireEvents(isNewCameraMatrix);
}
}
_detectAndSetNewMatrix (newMatrix) {
const isNewMatrix = !gl_matrix__WEBPACK_IMPORTED_MODULE_9__["mat4"].exactEquals(newMatrix, this._cameraMatrix);
if (isNewMatrix) {
this._cameraMatrix = newMatrix;
this.renderer.matrix = newMatrix; // in case it is not set yet (first layer)
}
return isNewMatrix;
}
_checkSourceRequestsAndFireEvents (isNewMatrix) {
const checkForDataframesUpdate = this._source.requestData(this._getZoom(), this._getViewport());
checkForDataframesUpdate.then(dataframesHaveChanged => {
if (dataframesHaveChanged) {
this._needRefresh().then(() => {
if (this._state === states.INIT) {
this._state = states.IDLE;
this._fire('loaded');
}
this._fire('updated', 'different dataframes required from source');
});
} else {
if (isNewMatrix) {
this._fire('updated', 'new camara view');
}
}
});
}
_getViewport () {
return Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__["computeViewportFromCameraMatrix"])(this._cameraMatrix);
}
/**
* Custom Layer API: `render` function
*/
render (gl, matrix) {
this._paintLayer();
this._renderWaiters.forEach(resolve => resolve());
if (this.isAnimated()) {
if (this.isPlaying()) {
this._needRefresh().then(() => {
this._fire('updated', 'animation is playing');
});
} else {
this._keepTimestampIfPaused();
}
} else {
if (this._state === states.UPDATING) {
this._state = states.IDLE;
this._fire('updated', 'updated viz');
}
}
}
_keepTimestampIfPaused () {
let timestamp = this.renderer.timestamp;
// to avoid 'jumps' after resume playing.
this._viz._getRootStyleExpressions().forEach(vizExpr => {
vizExpr._setTimestamp(timestamp);
});
}
_paintLayer () {
this._renderLayer.setViz(this._viz);
this.renderer.renderLayer(this._renderLayer, {
zoomLevel: this.map.getZoom() // for zoom expressions
});
}
_fire (eventType, eventData) {
// We don't want to fire an event within MGL custom layer callback since an error there
// would crash MGL renderer
// We fire the event asynchronously to be safe
new Promise(resolve => {
this._emitter.emit(eventType, eventData);
resolve();
});
}
/**
* Callback executed when the client adds a new dataframe
* @param {Dataframe} dataframe
*/
_onDataframeAdded (dataframe) {
this._renderLayer.addDataframe(dataframe);
if (this._viz) {
this._viz.setDefaultsIfRequired(dataframe.type);
}
}
_needRefresh () {
if (this._state === states.IDLE) {
this._state = states.UPDATING;
}
return new Promise(resolve => {
this._renderWaiters.push(resolve);
this.map.triggerRepaint();
});
}
_addLayerIdToFeature (feature) {
feature.layerId = this.id;
return feature;
}
async _vizChanged (viz) {
return this._update(this._source, viz, false);
}
_checkId (id) {
if (id === undefined) {
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["default"]('\'id\'', _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["CartoValidationErrorTypes"].MISSING_REQUIRED);
}
if (!_utils_util__WEBPACK_IMPORTED_MODULE_1__["default"].isString(id)) {
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["default"]('\'id\' property must be a string.', _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["CartoValidationErrorTypes"].INCORRECT_TYPE);
}
if (id === '') {
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["default"]('\'id\' property must be not empty.', _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["CartoValidationErrorTypes"].INCORRECT_VALUE);
}
}
_checkSource (source) {
if (source === undefined) {
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["default"]('\'source\'', _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["CartoValidationErrorTypes"].MISSING_REQUIRED);
}
if (!(source instanceof _sources_Base__WEBPACK_IMPORTED_MODULE_3__["default"])) {
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["default"]('The given object is not a valid \'source\'. See "carto.source".', _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["CartoValidationErrorTypes"].INCORRECT_TYPE);
}
}
_checkViz (viz) {
if (_utils_util__WEBPACK_IMPORTED_MODULE_1__["default"].isUndefined(viz)) {
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["default"]('\'viz\'', _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["CartoValidationErrorTypes"].MISSING_REQUIRED);
}
if (!(viz instanceof _Viz__WEBPACK_IMPORTED_MODULE_2__["default"])) {
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["default"](
'The given object is not a valid \'viz\'. See "carto.Viz".',
_src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["CartoValidationErrorTypes"].INCORRECT_TYPE
);
}
if (viz._boundLayer && viz._boundLayer !== this) {
// Note the required 1 on 1 relationship between layer & viz
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["default"](
'The given Viz object is already bound to another layer. Vizs cannot be shared between different layers.',
_src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["CartoValidationErrorTypes"].INCORRECT_VALUE
);
}
}
_getZoom () {
return this.map.getZoom();
}
_freeSource () {
if (this._source) {
this._source.free();
}
this._renderLayer.freeDataframes();
}
}
function _getRenderer (map, gl) {
if (!renderers.get(map)) {
const renderer = new _renderer_Renderer__WEBPACK_IMPORTED_MODULE_4__["default"]();
renderer.initialize(gl);
renderers.set(map, renderer);
}
return renderers.get(map);
}
/***/ }),
/***/ "./src/LayerConcurrencyHelper.js":
/*!***************************************!*\
!*** ./src/LayerConcurrencyHelper.js ***!
\***************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return LayerConcurrencyHelper; });
/* harmony import */ var _src_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../src/errors/carto-runtime-error */ "./src/errors/carto-runtime-error.js");
/**
* Helper to manage concurrent updates to a Layer.
*
* There are 2 type of changes in a layer's source or viz:
* - Major changes. Major changes are performed by the `Layer.update` method and they will override (have priority over) minor changes
* - Minor changes. Minor changes are performed by the `Layer.blendToViz` and `blendTo` method and they won't override concurrent calls to `Layer.update`
*
* @export
* @class LayerConcurrency
*/
class LayerConcurrencyHelper {
constructor () {
this._majorNextUID = 0;
this._majorCurrentUID = null;
this._minorNextUID = 0;
this._minorCurrentUID = null;
}
/**
* Init a Major change
*
* @returns {Object} changeUID
*/
initMajorChange () {
return this._getChangeUID(true);
}
/**
* Init a Minor change
*
* @returns {Object} changeUID
*/
initMinorChange () {
return this._getChangeUID(false);
}
/**
* End a Major change, checking previously for concurrency problems
*
* @param {Object} changeUID
*/
endMajorChange (changeUID) {
this._detectConcurrentChanges(true, changeUID);
this._setUID(changeUID);
}
/**
* End a Minor change, checking previously for concurrency problems
*
* @param {Object} changeUID
*/
endMinorChange (changeUID) {
this._detectConcurrentChanges(false, changeUID);
this._setUID(changeUID);
}
/**
* Get an object with UID counters, that serve as a guard against concurrent changes
* @param {Boolean} majorChange
*/
_getChangeUID (majorChange) {
let uid;
if (majorChange) {
uid = { major: this._majorNextUID, minor: 0 };
this._majorNextUID++;
this._minorNextUID = 1;
} else {
uid = { major: this._majorCurrentUID, minor: this._minorNextUID };
this._minorNextUID++;
}
return uid;
}
/**
* Check against concurrency problems (raise an error if any is found)
* @param {Boolean} majorChange
* @param {Object} changeUID
*/
_detectConcurrentChanges (majorChange, changeUID) {
if (majorChange) {
if (this._majorCurrentUID > changeUID.major) {
throw new _src_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_0__["default"](`Another \`Layer.update()\` finished before this one:
Commit ${changeUID} overridden by commit ${this._majorCurrentUID}.`);
}
} else {
if (this._majorCurrentUID > changeUID.major || (this._majorCurrentUID !== null && changeUID.major === null)) {
throw new _src_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_0__["default"](`Another \`Layer.update()\` finished before this viz change:
Commit ${changeUID} overridden by commit ${this._majorCurrentUID}.${this._minorCurrentUID}`);
}
if (this._minorCurrentUID > changeUID.minor) {
throw new _src_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_0__["default"](`Another \`viz change\` finished before this one:
Commit ${changeUID.major}.${changeUID.minor} overridden by commit ${this._majorCurrentUID}.${this._minorCurrentUID}`);
}
}
}
/**
* Update internal counters
*
* @param {Object} changeUID
*/
_setUID (changeUID) {
this._majorCurrentUID = changeUID.major;
this._minorCurrentUID = changeUID.minor;
}
}
/***/ }),
/***/ "./src/Viz.js":
/*!********************!*\
!*** ./src/Viz.js ***!
\********************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Viz; });
/* harmony import */ var _renderer_schema__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderer/schema */ "./src/renderer/schema.js");
/* harmony import */ var _renderer_shaders_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./renderer/shaders/index */ "./src/renderer/shaders/index.js");
/* harmony import */ var _renderer_shaders_shaderCompiler__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./renderer/shaders/shaderCompiler */ "./src/renderer/shaders/shaderCompiler.js");
/* harmony import */ var _renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./renderer/viz/expressions */ "./src/renderer/viz/expressions.js");
/* harmony import */ var _renderer_viz_expressions_base__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./renderer/viz/expressions/base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _renderer_viz_expressions_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./renderer/viz/expressions/utils */ "./src/renderer/viz/expressions/utils.js");
/* harmony import */ var _renderer_viz_parser__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./renderer/viz/parser */ "./src/renderer/viz/parser.js");
/* harmony import */ var _utils_util__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils/util */ "./src/utils/util.js");
/* harmony import */ var _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../src/errors/carto-validation-error */ "./src/errors/carto-validation-error.js");
/* harmony import */ var _src_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../src/errors/carto-runtime-error */ "./src/errors/carto-runtime-error.js");
/* harmony import */ var _renderer_shaders_geometry_point_pointVertexShader_glsl__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./renderer/shaders/geometry/point/pointVertexShader.glsl */ "./src/renderer/shaders/geometry/point/pointVertexShader.glsl");
/* harmony import */ var _renderer_shaders_geometry_point_pointVertexShader_glsl__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_renderer_shaders_geometry_point_pointVertexShader_glsl__WEBPACK_IMPORTED_MODULE_10__);
/* harmony import */ var _renderer_shaders_geometry_point_pointFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./renderer/shaders/geometry/point/pointFragmentShader.glsl */ "./src/renderer/shaders/geometry/point/pointFragmentShader.glsl");
/* harmony import */ var _renderer_shaders_geometry_point_pointFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_renderer_shaders_geometry_point_pointFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_11__);
/* harmony import */ var _renderer_shaders_geometry_line_lineVertexShader_glsl__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./renderer/shaders/geometry/line/lineVertexShader.glsl */ "./src/renderer/shaders/geometry/line/lineVertexShader.glsl");
/* harmony import */ var _renderer_shaders_geometry_line_lineVertexShader_glsl__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_renderer_shaders_geometry_line_lineVertexShader_glsl__WEBPACK_IMPORTED_MODULE_12__);
/* harmony import */ var _renderer_shaders_geometry_line_lineFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./renderer/shaders/geometry/line/lineFragmentShader.glsl */ "./src/renderer/shaders/geometry/line/lineFragmentShader.glsl");
/* harmony import */ var _renderer_shaders_geometry_line_lineFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(_renderer_shaders_geometry_line_lineFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_13__);
/* harmony import */ var _renderer_shaders_geometry_polygon_polygonVertexShader_glsl__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./renderer/shaders/geometry/polygon/polygonVertexShader.glsl */ "./src/renderer/shaders/geometry/polygon/polygonVertexShader.glsl");
/* harmony import */ var _renderer_shaders_geometry_polygon_polygonVertexShader_glsl__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(_renderer_shaders_geometry_polygon_polygonVertexShader_glsl__WEBPACK_IMPORTED_MODULE_14__);
/* harmony import */ var _renderer_shaders_geometry_polygon_polygonFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderer/shaders/geometry/polygon/polygonFragmentShader.glsl */ "./src/renderer/shaders/geometry/polygon/polygonFragmentShader.glsl");
/* harmony import */ var _renderer_shaders_geometry_polygon_polygonFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_renderer_shaders_geometry_polygon_polygonFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_15__);
/* harmony import */ var _renderer_viz_expressions_Image__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./renderer/viz/expressions/Image */ "./src/renderer/viz/expressions/Image.js");
/* harmony import */ var _renderer_viz_defaultSVGs__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./renderer/viz/defaultSVGs */ "./src/renderer/viz/defaultSVGs.js");
/* harmony import */ var _renderer_viz_expressions_Placement__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./renderer/viz/expressions/Placement */ "./src/renderer/viz/expressions/Placement.js");
/* harmony import */ var _renderer_viz_expressions_transformation_Translate__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./renderer/viz/expressions/transformation/Translate */ "./src/renderer/viz/expressions/transformation/Translate.js");
/* harmony import */ var _utils_geometry__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./utils/geometry */ "./src/utils/geometry.js");
/* harmony import */ var _constants_viz__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./constants/viz */ "./src/constants/viz.js");
const DEFAULT_COLOR_EXPRESSION = () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["rgb"](0, 0, 0));
const DEFAULT_WIDTH_EXPRESSION = () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["number"](1));
const DEFAULT_STROKE_COLOR_EXPRESSION = () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["rgb"](0, 0, 0));
const DEFAULT_STROKE_WIDTH_EXPRESSION = () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["number"](0));
const DEFAULT_ORDER_EXPRESSION = () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["noOrder"]());
const DEFAULT_FILTER_EXPRESSION = () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["constant"](1));
const DEFAULT_SYMBOL_EXPRESSION = () => _markDefault(new _renderer_viz_expressions_Image__WEBPACK_IMPORTED_MODULE_16__["default"](_renderer_viz_defaultSVGs__WEBPACK_IMPORTED_MODULE_17__["default"].circle));
const DEFAULT_SYMBOLPLACEMENT_EXPRESSION = () => _markDefault(new _renderer_viz_expressions_Placement__WEBPACK_IMPORTED_MODULE_18__["default"](_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["constant"](0), _renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["constant"](1)));
const DEFAULT_TRANSFORM_EXPRESSION = () => _markDefault(new _renderer_viz_expressions_transformation_Translate__WEBPACK_IMPORTED_MODULE_19__["default"](_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["constant"](0), _renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["constant"](0)));
const DEFAULT_RESOLUTION = () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["number"](1));
/**
* A `vizSpec` object is used to create a {@link carto.Viz|Viz} and controlling multiple aspects.
*
* @typedef {Object} vizSpec
* @name vizSpec
* @api
*/
/**
* A Viz is one of the core elements of CARTO VL and defines how the data will be styled,
* displayed and processed. A Viz instance can only be bound to one layer.
*
*
* @param {string|vizSpec} definition - The definition of a viz. This parameter could be a `string` or a {@link vizSpec|vizSpec} object
*
* @example <caption> Create a viz with black dots using the string constructor </caption>
* const viz = new carto.Viz(`
* color: rgb(0,0,0)
* `);
*
* @example <caption> Create a viz with black dots using the vizSpec constructor </caption>
* const viz = new carto.Viz({
* color: carto.expressions.rgb(0,0,0)
* });
*
* @constructor Viz
* @name carto.Viz
* @property {Color} color - fill color of points and polygons and color of lines, if used with `symbol` the color will override the original image RGB channels
* @property {Number} width - fill diameter of points, thickness of lines, not applicable to polygons
* @property {Color} strokeColor - stroke/border color of points and polygons, not applicable to lines
* @property {Number} strokeWidth - stroke width of points and polygons, not applicable to lines
* @property {Number} filter - filter features by removing from rendering and interactivity all the features that don't pass the test. In combination with {@link carto.expressions.animation} temporal maps can be created.
* @property {Image} symbol - show an image instead in the place of points. There is a list of built-in icons you can use by default in the {@link https://carto.com/developers/carto-vl/reference/#icons|Icons section}
* @property {Placement} symbolPlacement - when using `symbol`, offset to apply to the image
* @property {Transformation} transform - transformation to apply to the features in pixels. We can assign a {@link carto.expressions.translate|translation}, a {@link carto.expressions.rotate|rotation}, or a chain of those two.
* @property {Order} order - rendering order of the features, only applicable to points. See {@link carto.expressions.asc}, {@link carto.expressions.desc} and {@link carto.expressions.noOrder}
* @property {Number} resolution - resolution of the property-aggregation functions, only applicable to points. Default resolution is 1. Custom values must be greater than 0 and lower than 256, and power of 2 values work better (no visual artifacts). A resolution of N means points are aggregated to grid cells NxN pixels. Unlike {@link https://carto.com/developers/torque-js/guides/how-spatial-aggregation-works/|Torque resolution}, the aggregated points are placed in the centroid of the cluster, not in the center of the grid cell.
* @property {Object} variables - An object describing the variables used.
* @api
*
*/
class Viz {
constructor (definition) {
const vizSpec = this._getVizDefinition(definition);
this._checkVizSpec(vizSpec);
Object.keys(vizSpec).forEach(property => {
this._defineProperty(property, vizSpec[property]);
});
if (!Object.keys(vizSpec).includes('variables')) {
this._defineProperty('variables', {});
}
this.updated = true;
this._changeCallback = null;
this._updateRootExpressionList();
this._updateRootExpressions();
this._resolveAliases();
this._validateAliasDAG();
}
/**
* Get the geometry type of the visualization.
* @readonly
* @memberof carto.Viz
* @api
*/
get geometryType () {
return this._geomType;
}
loadImages () {
return Promise.all(this._getRootExpressions().map(expr => expr.loadImages()));
}
/*
* There are cases when promise rejections are fine, such as when using
* `blendTo` to change the viz synchronously.
*/
_ignoreChangeRejections () {
return {};
}
// Define a viz property, setting all the required getters, setters and creating a proxy for the variables object
// These setters and the proxy allow us to re-render without requiring further action from the user
_defineProperty (propertyName, propertyValue) {
if (propertyName !== 'variables' && !_constants_viz__WEBPACK_IMPORTED_MODULE_21__["SUPPORTED_VIZ_PROPERTIES"].includes(propertyName)) {
return;
}
Object.defineProperty(this, propertyName, {
get: () => this['_' + propertyName],
set: expr => {
this['_' + propertyName] = Object(_renderer_viz_expressions_utils__WEBPACK_IMPORTED_MODULE_5__["implicitCast"])(expr);
this._changed().catch(this._ignoreChangeRejections);
}
});
let property = propertyValue;
if (propertyName === 'variables') {
let init = false;
const handler = {
get: (obj, prop) => {
return obj[prop];
},
set: (obj, prop, value) => {
value = Object(_renderer_viz_expressions_utils__WEBPACK_IMPORTED_MODULE_5__["implicitCast"])(value);
if (value instanceof _renderer_viz_expressions_base__WEBPACK_IMPORTED_MODULE_4__["default"]) {
value._variableName = prop;
}
obj[prop] = value;
this['__cartovl_variable_' + prop] = value;
if (init) {
this._changed().catch(this._ignoreChangeRejections);
}
return true;
}
};
property = new Proxy({}, handler);
Object.keys(propertyValue).map(varName => {
property[varName] = propertyValue[varName];
});
init = true;
}
this['_' + propertyName] = property;
}
_getRootExpressions () {
return this._rootExpressions;
}
_getRootStyleExpressions () {
return this._rootStyleExpressions;
}
_updateRootExpressions () {
this._getRootExpressions().forEach(expr => {
expr.parent = this;
expr.notify = this._changed.bind(this);
});
}
isAnimated () {
return this._getRootStyleExpressions().some(expr => expr.isAnimated());
}
isPlaying () {
return this._getRootStyleExpressions().some(expr => expr.isPlaying());
}
onChange (callback) {
this._changeCallback = callback;
}
_changed () {
this._updateRootExpressionList();
this._resolveAliases();
this._validateAliasDAG();
if (this._changeCallback) {
return this._changeCallback(this);
}
return Promise.resolve(null);
}
_updateRootExpressionList () {
const expressions = [..._constants_viz__WEBPACK_IMPORTED_MODULE_21__["SUPPORTED_VIZ_PROPERTIES"]].map(expression => this[expression]);
const styleExpressions = [..._constants_viz__WEBPACK_IMPORTED_MODULE_21__["STYLE_VIZ_PROPERTIES"]].map(expression => this[expression]);
const variables = [...Object.values(this.variables)];
this._rootExpressions = [...expressions, ...variables];
this._rootStyleExpressions = styleExpressions;
}
getMinimumNeededSchema () {
return this._getRootExpressions()
.filter(x => x && x._getMinimumNeededSchema)
.map(expr => expr._getMinimumNeededSchema())
.reduce(_renderer_schema__WEBPACK_IMPORTED_MODULE_0__["default"].union, _renderer_schema__WEBPACK_IMPORTED_MODULE_0__["default"].IDENTITY);
}
setDefaultsIfRequired (geomType) {
this._geomType = geomType;
if (this._appliedDefaults) {
return;
}
let defaults = this._getDefaultGeomStyle(geomType);
if (defaults) {
this._appliedDefaults = true;
if (this.color.default) {
this.color = defaults.COLOR_EXPRESSION();
}
if (this.width.default) {
this.width = defaults.WIDTH_EXPRESSION();
}
if (this.strokeColor.default) {
this.strokeColor = defaults.STROKE_COLOR_EXPRESSION();
}
if (this.strokeWidth.default) {
this.strokeWidth = defaults.STROKE_WIDTH_EXPRESSION();
}
this._updateRootExpressions();
}
}
_getDefaultGeomStyle (geomType) {
if (geomType === _utils_geometry__WEBPACK_IMPORTED_MODULE_20__["GEOMETRY_TYPE"].POINT) {
return {
COLOR_EXPRESSION: () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["hex"]('#EE4D5A')),
WIDTH_EXPRESSION: () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["number"](7)),
STROKE_COLOR_EXPRESSION: () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["hex"]('#FFF')),
STROKE_WIDTH_EXPRESSION: () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["number"](1))
};
} else if (geomType === _utils_geometry__WEBPACK_IMPORTED_MODULE_20__["GEOMETRY_TYPE"].LINE) {
return {
COLOR_EXPRESSION: () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["hex"]('#4CC8A3')),
WIDTH_EXPRESSION: () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["number"](1.5)),
STROKE_COLOR_EXPRESSION: () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["hex"]('#FFF')), // Not used in lines
STROKE_WIDTH_EXPRESSION: () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["number"](1)) // Not used in lines
};
} else if (geomType === _utils_geometry__WEBPACK_IMPORTED_MODULE_20__["GEOMETRY_TYPE"].POLYGON) {
return {
COLOR_EXPRESSION: () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["hex"]('#826DBA')),
WIDTH_EXPRESSION: () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["number"](1)), // Not used in polygons
STROKE_COLOR_EXPRESSION: () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["hex"]('#FFF')),
STROKE_WIDTH_EXPRESSION: () => _markDefault(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_3__["number"](1))
};
}
}
_resolveAliases () {
this._getRootExpressions().forEach(expr => {
expr._resolveAliases(this.variables);
});
}
_validateAliasDAG () {
const permanentMarkedSet = new Set();
const temporarilyMarkedSet = new Set();
const visit = node => {
if (permanentMarkedSet.has(node)) {
// Node is already a processed dependency
return;
}
if (temporarilyMarkedSet.has(node)) {
throw new _src_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_9__["default"]('Viz contains a circular dependency');
}
temporarilyMarkedSet.add(node);
node._getDependencies().forEach(visit);
permanentMarkedSet.add(node);
};
const unmarked = this._getRootExpressions().map(
expr => expr._getDependencies()
).reduce(
(a, b) => [...a, ...b],
[]
);
while (unmarked.length) {
visit(unmarked.pop());
}
}
_bindMetadata (metadata) {
this._colorShader = null;
this._widthShader = null;
this._strokeColorShader = null;
this._strokeWidthShader = null;
this._filterShader = null;
this._symbolShader = null;
this._pointShader = null;
this._lineShader = null;
this._polygonShader = null;
this.metadata = metadata;
this._getRootExpressions().forEach(expr => expr._bindMetadata(this.metadata));
checkVizPropertyTypes(this);
}
get colorMetaShader () {
return this._compileShader('colorShader', _renderer_shaders_index__WEBPACK_IMPORTED_MODULE_1__["default"].styler.colorShaderGLSL, { color: this.color });
}
get widthMetaShader () {
return this._compileShader('widthShader', _renderer_shaders_index__WEBPACK_IMPORTED_MODULE_1__["default"].styler.widthShaderGLSL, { width: this.width });
}
get strokeColorMetaShader () {
return this._compileShader('strokeColorShader', _renderer_shaders_index__WEBPACK_IMPORTED_MODULE_1__["default"].styler.colorShaderGLSL, { color: this.strokeColor });
}
get strokeWidthMetaShader () {
return this._compileShader('strokeWidthShader', _renderer_shaders_index__WEBPACK_IMPORTED_MODULE_1__["default"].styler.widthShaderGLSL, { width: this.strokeWidth });
}
get filterMetaShader () {
return this._compileShader('filterShader', _renderer_shaders_index__WEBPACK_IMPORTED_MODULE_1__["default"].styler.filterShaderGLSL, { filter: this.filter });
}
get symbolMetaShader () {
return this._compileShader('symbolShader', _renderer_shaders_index__WEBPACK_IMPORTED_MODULE_1__["default"].symbolizer.symbolShaderGLSL, {
symbol: this.symbol,
symbolPlacement: this.symbolPlacement,
transform: this.transform
});
}
get pointMetaShader () {
return this._compileShader('pointShader', { vertexShader: _renderer_shaders_geometry_point_pointVertexShader_glsl__WEBPACK_IMPORTED_MODULE_10___default.a, fragmentShader: _renderer_shaders_geometry_point_pointFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_11___default.a },
{ transform: this.transform });
}
get lineMetaShader () {
return this._compileShader('lineShader', { vertexShader: _renderer_shaders_geometry_line_lineVertexShader_glsl__WEBPACK_IMPORTED_MODULE_12___default.a, fragmentShader: _renderer_shaders_geometry_line_lineFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_13___default.a },
{ transform: this.transform });
}
get polygonMetaShader () {
return this._compileShader('polygonShader', { vertexShader: _renderer_shaders_geometry_polygon_polygonVertexShader_glsl__WEBPACK_IMPORTED_MODULE_14___default.a, fragmentShader: _renderer_shaders_geometry_polygon_polygonFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_15___default.a },
{ transform: this.transform });
}
_compileShader (shaderName, GLSL, expr) {
if (!this['_' + shaderName]) {
this['_' + shaderName] = Object(_renderer_shaders_shaderCompiler__WEBPACK_IMPORTED_MODULE_2__["compileShader"])(this.gl, GLSL, expr, this);
}
return this['_' + shaderName];
}
replaceChild (toReplace, replacer) {
if (Object.values(this.variables).includes(toReplace)) {
const varName = Object.keys(this.variables).find(varName => this.variables[varName] === toReplace);
this.variables[varName] = replacer;
replacer.parent = this;
replacer.notify = toReplace.notify;
} else {
const propertyName = _constants_viz__WEBPACK_IMPORTED_MODULE_21__["SUPPORTED_VIZ_PROPERTIES"].find(propertyName => this[propertyName] === toReplace);
if (propertyName) {
this[propertyName] = replacer;
replacer.parent = this;
replacer.notify = toReplace.notify;
} else {
throw new _src_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_9__["default"]('No child found');
}
}
}
/**
* This function checks the input parameter `definition` returning always an object.
* If the `definition` is an object it returns the same object.
* If the `definition` is a string it returns the parsed string as an object.
* Otherwise it throws an error.
*
* @param {string|object} definition
* @return {vizSpec}
*/
_getVizDefinition (definition) {
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isUndefined(definition)) {
return this._setDefaults({});
}
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isObject(definition)) {
return this._setDefaults(definition);
}
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isString(definition)) {
return this._setDefaults(Object(_renderer_viz_parser__WEBPACK_IMPORTED_MODULE_6__["parseVizDefinition"])(definition));
}
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_8__["default"](
'viz \'definition\' should be a vizSpec object or a valid viz string.',
_src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_8__["CartoValidationErrorTypes"].INCORRECT_VALUE
);
}
/**
* Add default values to a vizSpec object.
*
* @param {vizSpec} vizSpec
* @return {vizSpec}
*/
_setDefaults (vizSpec) {
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isUndefined(vizSpec.color)) {
vizSpec.color = _utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isUndefined(vizSpec.symbol) ? DEFAULT_COLOR_EXPRESSION() : Object(_renderer_viz_expressions_utils__WEBPACK_IMPORTED_MODULE_5__["noOverrideColor"])();
}
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isUndefined(vizSpec.width)) {
vizSpec.width = DEFAULT_WIDTH_EXPRESSION();
}
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isUndefined(vizSpec.strokeColor)) {
vizSpec.strokeColor = DEFAULT_STROKE_COLOR_EXPRESSION();
}
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isUndefined(vizSpec.strokeWidth)) {
vizSpec.strokeWidth = DEFAULT_STROKE_WIDTH_EXPRESSION();
}
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isUndefined(vizSpec.order)) {
vizSpec.order = DEFAULT_ORDER_EXPRESSION();
}
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isUndefined(vizSpec.filter)) {
vizSpec.filter = DEFAULT_FILTER_EXPRESSION();
}
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isUndefined(vizSpec.resolution)) {
vizSpec.resolution = DEFAULT_RESOLUTION();
}
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isUndefined(vizSpec.symbol)) {
vizSpec.symbol = DEFAULT_SYMBOL_EXPRESSION();
}
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isUndefined(vizSpec.symbolPlacement)) {
vizSpec.symbolPlacement = DEFAULT_SYMBOLPLACEMENT_EXPRESSION();
}
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isUndefined(vizSpec.transform)) {
vizSpec.transform = DEFAULT_TRANSFORM_EXPRESSION();
}
vizSpec.variables = vizSpec.variables || {};
return vizSpec;
}
_checkResolution (resolution) {
const resolutionValue = resolution instanceof _renderer_viz_expressions_base__WEBPACK_IMPORTED_MODULE_4__["default"]
? resolution.eval()
: resolution;
if (_utils_util__WEBPACK_IMPORTED_MODULE_7__["default"].isNumber(resolutionValue)) {
if (resolution <= _constants_viz__WEBPACK_IMPORTED_MODULE_21__["MIN_RESOLUTION"]) {
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_8__["default"](
`'resolution' is ${resolution}, must be greater than ${_constants_viz__WEBPACK_IMPORTED_MODULE_21__["MIN_RESOLUTION"]}.`,
_src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_8__["CartoValidationErrorTypes"].INCORRECT_VALUE
);
}
if (resolution >= _constants_viz__WEBPACK_IMPORTED_MODULE_21__["MAX_RESOLUTION"]) {
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_8__["default"](
`'resolution' is ${resolution}, must be lower than ${_constants_viz__WEBPACK_IMPORTED_MODULE_21__["MAX_RESOLUTION"]}.`,
_src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_8__["CartoValidationErrorTypes"].INCORRECT_VALUE
);
}
} else {
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_8__["default"](
'\'resolution\' property must be a number.',
_src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_8__["CartoValidationErrorTypes"].INCORRECT_TYPE
);
}
}
_applyImplitCastToNumericProperties (vizSpec) {
vizSpec.filter = Object(_renderer_viz_expressions_utils__WEBPACK_IMPORTED_MODULE_5__["implicitCast"])(vizSpec.filter);
vizSpec.resolution = Object(_renderer_viz_expressions_utils__WEBPACK_IMPORTED_MODULE_5__["implicitCast"])(vizSpec.resolution);
vizSpec.strokeWidth = Object(_renderer_viz_expressions_utils__WEBPACK_IMPORTED_MODULE_5__["implicitCast"])(vizSpec.strokeWidth);
vizSpec.symbol = Object(_renderer_viz_expressions_utils__WEBPACK_IMPORTED_MODULE_5__["implicitCast"])(vizSpec.symbol);
vizSpec.symbolPlacement = Object(_renderer_viz_expressions_utils__WEBPACK_IMPORTED_MODULE_5__["implicitCast"])(vizSpec.symbolPlacement);
vizSpec.transform = Object(_renderer_viz_expressions_utils__WEBPACK_IMPORTED_MODULE_5__["implicitCast"])(vizSpec.transform);
vizSpec.width = Object(_renderer_viz_expressions_utils__WEBPACK_IMPORTED_MODULE_5__["implicitCast"])(vizSpec.width);
}
_checkVizSpec (vizSpec) {
this._applyImplitCastToNumericProperties(vizSpec);
this._checkResolution(vizSpec.resolution);
_constants_viz__WEBPACK_IMPORTED_MODULE_21__["SUPPORTED_VIZ_PROPERTIES"].forEach((parameter) => {
if (!(vizSpec[parameter] instanceof _renderer_viz_expressions_base__WEBPACK_IMPORTED_MODULE_4__["default"])) {
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_8__["default"](
`'${parameter}' parameter is not a valid viz Expresion.`,
_src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_8__["CartoValidationErrorTypes"].INCORRECT_TYPE);
}
});
for (let key in vizSpec) {
if (key !== 'variables' && _constants_viz__WEBPACK_IMPORTED_MODULE_21__["SUPPORTED_VIZ_PROPERTIES"].indexOf(key) === -1) {
console.warn(`Property '${key}' is not supported`);
}
}
}
/**
* Stringify the visualization
*
* @returns {String}
* @memberof carto.Viz
* @api
*/
toString () {
const variables = Object
.keys(this.variables)
.map(varName => `@${varName}: ${this.variables[varName].toString()}`);
const properties = _constants_viz__WEBPACK_IMPORTED_MODULE_21__["SUPPORTED_VIZ_PROPERTIES"]
.map(property => `${property}: ${this[property].toString()}`);
return [...variables, ...properties].join('\n');
}
}
function checkVizPropertyTypes (viz) {
const expectedTypePerProperty = {
color: 'color',
filter: 'number',
order: 'orderer',
resolution: 'number',
strokeColor: 'color',
strokeWidth: 'number',
symbol: 'image',
symbolPlacement: 'placement',
transform: 'transformation',
width: 'number'
};
Object.keys(expectedTypePerProperty).forEach((property) => {
const currentType = viz[property].type;
const expected = expectedTypePerProperty[property];
if (currentType !== expected) {
throw new _src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_8__["default"](
`Viz property '${property}': must be of type '${expected}' but it was of type '${currentType}'`,
_src_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_8__["CartoValidationErrorTypes"].INCORRECT_TYPE
);
}
});
}
/**
* Mark default expressions to apply the style defaults for each
* geometry (point, line, polygon) when available.
*/
function _markDefault (expression) {
expression.default = true;
return expression;
}
/***/ }),
/***/ "./src/basemaps.js":
/*!*************************!*\
!*** ./src/basemaps.js ***!
\*************************/
/*! exports provided: voyager, darkmatter, positron */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "voyager", function() { return voyager; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "darkmatter", function() { return darkmatter; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "positron", function() { return positron; });
/**
* Voyager vector basemap
*
* @example <caption>Use Voyager vector basemap.</caption>
* const map = new mapboxgl.Map({
* container: 'map',
* style: carto.basemaps.voyager
* })
*
* @example <caption>Use Voyager vector basemap. (String)</caption>
* const map = new mapboxgl.Map({
* container: 'map',
* style: carto.basemaps.voyager
* })
*
* @memberof carto.basemaps
* @name voyager
* @api
*/
const voyager = 'https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json';
/**
* Dark-Matter vector basemap
*
* @example <caption>Use Dark-Matter vector basemap.</caption>
* const map = new mapboxgl.Map({
* container: 'map',
* style: carto.basemaps.darkmatter
* })
*
* @example <caption>Use Dark-Matter vector basemap. (String)</caption>
* const map = new mapboxgl.Map({
* container: 'map',
* style: carto.basemaps.darkmatter
* })
*
* @memberof carto.basemaps
* @name darkmatter
* @api
*/
const darkmatter = 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json';
/**
* Positron vector basemap
*
* @example <caption>Use Positron vector basemap.</caption>
* const map = new mapboxgl.Map({
* container: 'map',
* style: carto.basemaps.positron
* })
*
* @example <caption>Use Positron vector basemap. (String)</caption>
* const map = new mapboxgl.Map({
* container: 'map',
* style: carto.basemaps.positron
* })
*
* @memberof carto.basemaps
* @name positron
* @api
*/
const positron = 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json';
/***/ }),
/***/ "./src/client/WindshaftMetadata.js":
/*!*****************************************!*\
!*** ./src/client/WindshaftMetadata.js ***!
\*****************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return WindshaftMetadata; });
/* harmony import */ var _sources_MVTMetadata__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sources/MVTMetadata */ "./src/sources/MVTMetadata.js");
/* harmony import */ var _codecs_windshaft__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../codecs/windshaft */ "./src/codecs/windshaft/index.js");
// // Windshaft metadata internal structure of properties
// properties: {
// // There's an entry here for every column of the original dataset/SQL query
// simple_value: { type: 'number', min: 10, max: 1000 },
// // Now, that's all there's to it for other sources,
// // but for Windshaft sources things more complicated:
// // There might be multiple aggregated properties derived from one base column
// value: {
// type: 'number' // this is the type of the base column and all aggregated properties
// aggregation: {
// // actual properties received and decoded are _cdb_agg_sum_value and _cdb_avg_sum_value
// sum: '_cdb_agg_sum_value',
// avg: '_cdb_agg_sum_value'
// }
// },
// // Then we can have dimension properties, also derived from a base column
// // here time1 is a date column of the dataset/query; but what we receive is
// // a _cdb_dim_month_time1 property of numeric type.
// // these dimension properties are triggered by clusterMonth/clusterMonthIso etc
// time1: {
// type: 'date' // this is the type of the base column only,
// min: '2017-01-01T00:00:00', // stats of the base column
// max: '2018-12-01T00:00:00',
// dimension: {
// type: 'number', // type of the actual property received and decoded
// grouping: {},// (to be changed to group) grouping parameters
// propertyName: "_cdb_dim_month_time1",
// min: 1, // actual stats of property _cdb_dim_month_time1
// max: 24
// }
// },
// // But wait, there's more, we can transfer a date dimension as an iso string property
// // but then expose it as two date properties, one for the start of each period and
// // one from the end (if not used, any of them may not be present)
// // these dimension properties are triggered by clusterMonthStart/clusterMonthEnd etc.
// time2: {
// type: 'date' // this is the type of the base column only,
// min: '2017-01-01T00:00:00', // stats of the base column
// max: '2018-12-01T00:00:00',
// dimension: {
// type: 'category', // type of the actual (source) property received internally
// grouping: {},// (to be changed to group) grouping parameters
// propertyName: "_cdb_dim_month_time1", // source property
// min: '2017-01', // stats of property _cdb_dim_month_time1
// max: '2017-12',
// range: [
// // here come the actual decoded (internal) properties!!:
// // the types of these properties is 'date'
// '_cdb_dim_month_time1_start',
// '_cdb_dim_month_time1_end'
// }
// }
// }
// }
class WindshaftMetadata extends _sources_MVTMetadata__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (...args) {
super(...args);
this.propertyKeys = [];
this.baseNames = {};
Object.keys(this.properties).forEach(baseName => {
const property = this.properties[baseName];
if (property.aggregations) {
Object.values(property.aggregations).forEach(propName => {
this._addProperty(baseName, propName);
});
} else if (property.dimension) {
if (property.dimension.range) {
property.dimension.range.forEach(rangePropertyName => {
this._addProperty(baseName, rangePropertyName, false);
});
// add source property too, for stats
this._addProperty(baseName, property.dimension.propertyName);
} else {
this._addProperty(baseName, property.dimension.propertyName);
}
} else {
this._addProperty(baseName, baseName);
}
});
}
_addProperty (baseName, propertyName, addToKeys = true) {
this.baseNames[propertyName] = baseName;
if (addToKeys) {
this.propertyKeys.push(propertyName);
}
}
_dimensionInfo (propertyName) {
const baseName = this.baseName(propertyName) || propertyName;
const column = this.properties[baseName];
let dimension = null;
if (baseName !== propertyName) {
if (baseName !== propertyName && column.dimension) {
dimension = column.dimension;
}
}
const baseType = column.type;
const sourceType = dimension ? dimensionBaseType(dimension) : baseType;
// type of the dataframe properties
const dataframeType = dimension ? dimensionType(dimension, propertyName) : sourceType;
return { baseName, column, dimension, dataframeType, baseType, sourceType };
}
baseName (propertyName) {
return this.baseNames[propertyName];
}
decodedProperties (propertyName) {
const { dimension } = this._dimensionInfo(propertyName);
if (dimension && dimension.grouping && dimension.range) {
return dimension.range;
}
return super.decodedProperties(propertyName);
}
// Stats usage: (is internal, external or source representation preferable?)
// * global aggregations
// * coding/decoding
stats (propertyName) {
const { dimension } = this._dimensionInfo(propertyName);
if (dimension && dimension.grouping) {
return dimension;
}
return super.stats(propertyName);
}
setCodecs () {
setMetadataCodecs(this);
}
sourcePropertyName (propertyName) {
const baseName = this.baseName(propertyName);
const dimension = this.properties[baseName].dimension;
if (dimension && dimension.range) {
return dimension.propertyName;
}
return propertyName;
}
}
function dimensionType (dimension, propertyName) {
if (dimension.range) {
return 'date';
}
return dimension.type;
}
function dimensionBaseType (dimension) {
return dimension.type;
}
function setMetadataCodecs (metadata) {
// assign codecs
// a single codec kept per base property
// so, all its aggregations share the same encoding.
// form a dimension, the kept codec is that of the dimension
Object.keys(metadata.properties).forEach(baseName => {
const property = metadata.properties[baseName];
const baseType = property.type;
if (baseType !== 'geometry') {
const dimType = property.dimension ? property.dimension.type : null;
const dimName = dimType ? property.dimension.propertyName : baseName;
const actualDimType = (dimType === 'category' && property.dimension.range) ? 'timerange' : dimType;
property.codec = Object(_codecs_windshaft__WEBPACK_IMPORTED_MODULE_1__["default"])(metadata, actualDimType || baseType, dimName || baseName);
}
});
}
/***/ }),
/***/ "./src/client/WindshaftRequestHelper.js":
/*!**********************************************!*\
!*** ./src/client/WindshaftRequestHelper.js ***!
\**********************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return WindshaftRequestHelper; });
/* harmony import */ var _package__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../package */ "./package.json");
var _package__WEBPACK_IMPORTED_MODULE_0___namespace = /*#__PURE__*/__webpack_require__.t(/*! ../../package */ "./package.json", 1);
/* harmony import */ var _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../errors/carto-maps-api-error */ "./src/errors/carto-maps-api-error.js");
const REQUEST_GET_MAX_URL_LENGTH = 2048;
class WindshaftRequestHelper {
constructor (conf, mapConfig) {
this._conf = conf;
this._mapConfig = mapConfig;
this._auth = this._encodeParameter('api_key', this._conf.apiKey);
this._client = this._encodeParameter('client', `vl-${_package__WEBPACK_IMPORTED_MODULE_0__["version"]}`);
}
/**
* Make a request to Windshaft for a LayerGroup, dealing internally with errors in the Maps API
*/
async getLayerGroup () {
let response;
try {
response = await fetch(this._makeHttpRequest());
} catch (error) {
throw new _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_1__["default"](`Failed to connect to Maps API with your user('${this._conf.username}')`);
}
const layergroup = await response.json();
if (!response.ok) {
this._dealWithWindshaftErrors(response, layergroup);
}
return layergroup;
}
_makeHttpRequest () {
const parameters = [this._auth, this._client, this._encodeParameter('config', this._mapConfigPayload())];
const url = this._generateUrl(this._generateMapsApiUrl(), parameters);
if (url.length < REQUEST_GET_MAX_URL_LENGTH) {
return this._getRequest(url);
}
return this._postRequest();
}
_dealWithWindshaftErrors (response, layergroup) {
if (response.status === 401) {
throw new _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_1__["default"](
`Unauthorized access to Maps API: invalid combination of user('${this._conf.username}') and apiKey('${this._conf.apiKey}')`,
_errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_1__["CartoMapsAPIErrorTypes"].SECURITY
);
} else if (response.status === 403) {
throw new _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_1__["default"](
`Unauthorized access to dataset: the provided apiKey('${this._conf.apiKey}') doesn't provide access to the requested data`,
_errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_1__["CartoMapsAPIErrorTypes"].SECURITY
);
}
throw new _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_1__["default"](`${JSON.stringify(layergroup.errors)}`, _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_1__["CartoMapsAPIErrorTypes"].SQL);
}
_mapConfigPayload () {
return JSON.stringify(this._mapConfig);
}
_getRequest (url) {
return new Request(url, {
method: 'GET',
headers: {
'Accept': 'application/json'
}
});
}
_postRequest () {
const parameters = [this._auth, this._client];
return new Request(this._generateUrl(this._generateMapsApiUrl(), parameters), {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: this._mapConfigPayload()
});
}
_encodeParameter (name, value) {
return `${name}=${encodeURIComponent(value)}`;
}
_generateUrl (url, parameters = []) {
return `${url}?${parameters.join('&')}`;
}
_generateMapsApiUrl (path) {
let url = `${this._conf.serverURL}/api/v1/map`;
if (path) {
url += path;
}
return url;
}
}
/***/ }),
/***/ "./src/client/rsys.js":
/*!****************************!*\
!*** ./src/client/rsys.js ***!
\****************************/
/*! exports provided: wToR, rTiles, getRsysFromTile, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "wToR", function() { return wToR; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rTiles", function() { return rTiles; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getRsysFromTile", function() { return getRsysFromTile; });
/**
* An RSys defines a local coordinate system that maps the coordinates
* in the range -1 <= x <= +1; -1 <= y <= +1 to an arbitrary rectangle
* in an external coordinate system. (e.g. Dataframe coordinates to World coordinates)
* It is the combination of a translation and anisotropic scaling.
* @typedef {Object} RSys - Renderer relative coordinate system
* @property {RPoint} center - Position of the local system in external coordinates
* @property {number} scale - Y-scale (local Y-distance / external Y-distance)
*/
/*
* Random notes
*
* We can redefine Dataframe to use a Rsys instead of center, scale
* and we can use an Rsys for the Renderer's canvas.
*
* Some interesting World coordinate systems:
*
* WM (Webmercator): represents a part of the world (excluding polar regions)
* with coordinates in the range +/-WM_R for both X and Y. (positive orientation: E,N)
*
* NWMC (Normalized Webmercator Coordinates): represents the Webmercator *square*
* with coordinates in the range +/-1. Results from dividing Webmercator coordinates
* by WM_R. (positive orientation: E,N)
*
* TC (Tile coordinates): integers in [0, 2^Z) for zoom level Z. Example: the tile 0/0/0 (zoom, x, y) is the root tile.
* (positive orientation: E,S)
*
* An RSys's rectangle (its bounds) is the area covered by the local coordinates in
* the range +/-1.
*
* When an RSys external coordinate system is WM or NWMC, we can compute:
* * Minimum zoom level for which tiles are no larger than the RSys rectangle:
* Math.ceil(Math.log2(1 / r.scale));
* * Maximum zoom level for which tiles are no smaller than the rectangle:
* Math.floor(Math.log2(1 / r.scale));
* (note that 1 / r.scale is the fraction of the World height that the local rectangle's height represents)
*
* We'll use the term World coordinates below for the *external* reference system
* of an RSys (usually NWMC).
*/
/* eslint no-unused-vars: ["off"] */
/**
* R coordinates to World
* @param {RSys} r - ref. of the passed coordinates
* @param {number} x - x coordinate in r
* @param {number} y - y coordinate in r
* @return {RPoint} World coordinates
*/
function rToW (r, x, y) {
return { x: x * r.scale + r.center.x, y: y * r.scale + r.center.y };
}
/**
* World coordinates to local RSys
* @param {number} x - x W-coordinate
* @param {number} y - y W-coordinate
* @param {RSys} r - target ref. system
* @return {RPoint} R coordinates
*/
function wToR (x, y, r) {
return { x: (x - r.center.x) / r.scale, y: (y - r.center.y) / r.scale };
}
/**
* RSys of a tile (mapping local tile coordinates in +/-1 to NWMC)
* @param {number} x - TC x coordinate
* @param {number} y - TC y coordinate
* @param {number} z - Tile zoom level
* @return {RSys}
*/
function tileRsys (x, y, z) {
let max = Math.pow(2, z);
return { scale: 1 / max, center: { x: 2 * (x + 0.5) / max - 1, y: 1 - 2 * (y + 0.5) / max } };
}
/**
* TC tiles that intersect the local rectangle of an RSys
* (with the largest tile size no larger than the rectangle)
* @param {RSys} rsys
* @return {Array} - array of TC tiles {x, y, z}
*/
function rTiles (zoom, bounds, viewportZoomToSourceZoom = Math.ceil) {
return wRectangleTiles(viewportZoomToSourceZoom(zoom), bounds);
}
/**
* TC tiles of a given zoom level that intersect a W rectangle
* @param {number} z
* @param {Array} - rectangle extents [minx, miny, maxx, maxy]
* @return {Array} - array of TC tiles {x, y, z}
*/
function wRectangleTiles (z, wr) {
const [wMinx, wMiny, wMaxx, wMaxy] = wr;
const n = (1 << z); // for 0 <= z <= 30 equals Math.pow(2, z)
const clamp = x => Math.min(Math.max(x, 0), n - 1);
// compute tile coordinate ranges
const tMinx = clamp(Math.floor(n * (wMinx + 1) * 0.5));
const tMaxx = clamp(Math.ceil(n * (wMaxx + 1) * 0.5) - 1);
const tMiny = clamp(Math.floor(n * (1 - wMaxy) * 0.5));
const tMaxy = clamp(Math.ceil(n * (1 - wMiny) * 0.5) - 1);
let tiles = [];
for (let x = tMinx; x <= tMaxx; ++x) {
for (let y = tMiny; y <= tMaxy; ++y) {
tiles.push({ x: x, y: y, z: z });
}
}
return tiles;
}
/**
* Get the Rsys of a tile where the Rsys's center is the tile center and the Rsys's scale is the tile extent.
* @param {*} x
* @param {*} y
* @param {*} z
* @returns {RSys}
*/
function getRsysFromTile (x, y, z) {
return {
center: {
x: ((x + 0.5) / Math.pow(2, z)) * 2.0 - 1,
y: (1.0 - (y + 0.5) / Math.pow(2, z)) * 2.0 - 1.0
},
scale: 1 / Math.pow(2, z)
};
}
/* harmony default export */ __webpack_exports__["default"] = ({ rTiles, getRsysFromTile, wToR });
/***/ }),
/***/ "./src/client/windshaft-filtering.js":
/*!*******************************************!*\
!*** ./src/client/windshaft-filtering.js ***!
\*******************************************/
/*! exports provided: getFiltering, getSQLWhere, getAggregationFilters */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFiltering", function() { return getFiltering; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getSQLWhere", function() { return getSQLWhere; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAggregationFilters", function() { return getAggregationFilters; });
/* harmony import */ var _renderer_viz_expressions_binary_GreaterThan__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../renderer/viz/expressions/binary/GreaterThan */ "./src/renderer/viz/expressions/binary/GreaterThan.js");
/* harmony import */ var _renderer_viz_expressions_binary_GreaterThanOrEqualTo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../renderer/viz/expressions/binary/GreaterThanOrEqualTo */ "./src/renderer/viz/expressions/binary/GreaterThanOrEqualTo.js");
/* harmony import */ var _renderer_viz_expressions_binary_LessThan__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../renderer/viz/expressions/binary/LessThan */ "./src/renderer/viz/expressions/binary/LessThan.js");
/* harmony import */ var _renderer_viz_expressions_binary_LessThanOrEqualTo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../renderer/viz/expressions/binary/LessThanOrEqualTo */ "./src/renderer/viz/expressions/binary/LessThanOrEqualTo.js");
/* harmony import */ var _renderer_viz_expressions_binary_And__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../renderer/viz/expressions/binary/And */ "./src/renderer/viz/expressions/binary/And.js");
/* harmony import */ var _renderer_viz_expressions_binary_Or__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../renderer/viz/expressions/binary/Or */ "./src/renderer/viz/expressions/binary/Or.js");
/* harmony import */ var _renderer_viz_expressions_binary_Equals__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../renderer/viz/expressions/binary/Equals */ "./src/renderer/viz/expressions/binary/Equals.js");
/* harmony import */ var _renderer_viz_expressions_binary_NotEquals__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../renderer/viz/expressions/binary/NotEquals */ "./src/renderer/viz/expressions/binary/NotEquals.js");
/* harmony import */ var _renderer_viz_expressions_belongs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../renderer/viz/expressions/belongs */ "./src/renderer/viz/expressions/belongs.js");
/* harmony import */ var _renderer_viz_expressions_between__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../renderer/viz/expressions/between */ "./src/renderer/viz/expressions/between.js");
/* harmony import */ var _renderer_viz_expressions_basic_property__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../renderer/viz/expressions/basic/property */ "./src/renderer/viz/expressions/basic/property.js");
/* harmony import */ var _renderer_viz_expressions_blend__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../renderer/viz/expressions/blend */ "./src/renderer/viz/expressions/blend.js");
/* harmony import */ var _renderer_viz_expressions_transition__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../renderer/viz/expressions/transition */ "./src/renderer/viz/expressions/transition.js");
/* harmony import */ var _renderer_viz_expressions_basic_number__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../renderer/viz/expressions/basic/number */ "./src/renderer/viz/expressions/basic/number.js");
/* harmony import */ var _renderer_viz_expressions_basic_constant__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../renderer/viz/expressions/basic/constant */ "./src/renderer/viz/expressions/basic/constant.js");
/* harmony import */ var _renderer_viz_expressions_basic_category__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../renderer/viz/expressions/basic/category */ "./src/renderer/viz/expressions/basic/category.js");
/* harmony import */ var _renderer_viz_expressions_aggregation_cluster_ClusterAvg__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../renderer/viz/expressions/aggregation/cluster/ClusterAvg */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAvg.js");
/* harmony import */ var _renderer_viz_expressions_aggregation_cluster_ClusterMax__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../renderer/viz/expressions/aggregation/cluster/ClusterMax */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterMax.js");
/* harmony import */ var _renderer_viz_expressions_aggregation_cluster_ClusterMin__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../renderer/viz/expressions/aggregation/cluster/ClusterMin */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterMin.js");
/* harmony import */ var _renderer_viz_expressions_aggregation_cluster_ClusterMode__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../renderer/viz/expressions/aggregation/cluster/ClusterMode */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterMode.js");
/* harmony import */ var _renderer_viz_expressions_aggregation_cluster_ClusterSum__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../renderer/viz/expressions/aggregation/cluster/ClusterSum */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterSum.js");
class AggregationFiltering {
/**
* Generate aggregation filters:
* This extracts, from the vizs filters, those compatible to be
* executed through the Maps API aggregation API.
* The extracted filters are in the format admitted by the Maps API
* `filters` parameter.
* Filters affecting dimensions (non-aggregated columns) can optionally
* be extracted too, but it is more efficient to not do so and apply those
* filters before aggregation.
*/
constructor (options) {
// exclusive mode: aggregate filters don't include pre-aggregate conditions (dimensions)
// in that case pre-aggregate filters should always be applied, even with aggregation
// (which can be more efficient)
this._onlyAggregateFilters = options.exclusive;
}
// return (partial) filters as an object (JSON) in the format of the Maps API aggregation interface
getFilters (vizFilter) {
let filters = {};
let filterList = this._and(vizFilter).filter(Boolean);
for (let p of filterList) {
let name = p.property;
let existingFilter = filters[name];
if (existingFilter) {
if (this._compatibleAndFilters(existingFilter, p.filters)) {
// combine inequalities into a range
Object.assign(existingFilter[0], p.filters[0]);
} else {
// can't AND-combine filters for the same property
return {};
}
} else {
filters[name] = p.filters;
}
}
return filters;
}
_and (f) {
if (f.isA(_renderer_viz_expressions_binary_And__WEBPACK_IMPORTED_MODULE_4__["default"])) {
return this._and(f.a).concat(this._and(f.b)).filter(Boolean);
}
return [this._or(f)].filter(Boolean);
}
_or (f) {
if (f.isA(_renderer_viz_expressions_binary_Or__WEBPACK_IMPORTED_MODULE_5__["default"])) {
let a = this._basicCondition(f.a);
let b = this._basicCondition(f.b);
if (a && b) {
if (a.property === b.property) {
a.filters = a.filters.concat(b.filters);
return a;
}
}
}
return this._basicCondition(f);
}
_removeBlend (f) {
if (f.isA(_renderer_viz_expressions_blend__WEBPACK_IMPORTED_MODULE_11__["default"]) && f.originalMix.isA(_renderer_viz_expressions_transition__WEBPACK_IMPORTED_MODULE_12__["default"])) {
return f.b;
}
return f;
}
_basicCondition (f) {
f = this._removeBlend(f);
return this._between(f) ||
this._equals(f) || this._notEquals(f) ||
this._lessThan(f) || this._lessThanOrEqualTo(f) ||
this._greaterThan(f) || this._greaterThanOrEqualTo(f) ||
this._in(f) || this._notIn(f);
}
_value (f) {
f = this._removeBlend(f);
if (f.isA(_renderer_viz_expressions_basic_number__WEBPACK_IMPORTED_MODULE_13__["default"]) || f.isA(_renderer_viz_expressions_basic_constant__WEBPACK_IMPORTED_MODULE_14__["default"]) || f.isA(_renderer_viz_expressions_basic_category__WEBPACK_IMPORTED_MODULE_15__["default"])) {
return f.value;
}
}
_between (f) {
if (f.isA(_renderer_viz_expressions_between__WEBPACK_IMPORTED_MODULE_9__["default"])) {
let p = this._aggregation(f.input);
let lo = p && this._value(f.lowerLimit);
let hi = p && lo && this._value(f.upperLimit);
if (hi) {
p.filters.push({
greater_than_or_equal_to: lo,
less_than_or_equal_to: hi
});
return p;
}
}
}
_in (f) {
if (f.isA(_renderer_viz_expressions_belongs__WEBPACK_IMPORTED_MODULE_8__["In"])) {
let p = this._aggregation(f.input);
let values = f.list.elems.map(c => this._value(c)).filter(v => v !== null);
if (p && values.length > 0 && values.length === f.list.elems.length) {
p.filters.push({
in: values
});
return p;
}
}
}
_notIn (f) {
if (f.isA(_renderer_viz_expressions_belongs__WEBPACK_IMPORTED_MODULE_8__["Nin"])) {
let p = this._aggregation(f.input);
let values = f.list.elems.map(c => this._value(c)).filter(v => v !== null);
if (p && values.length > 0 && values.length === f.list.elems.length) {
p.filters.push({
not_in: values
});
return p;
}
}
}
_equals (f) {
return this._cmpOp(f, _renderer_viz_expressions_binary_Equals__WEBPACK_IMPORTED_MODULE_6__["default"], 'equal');
}
_notEquals (f) {
return this._cmpOp(f, _renderer_viz_expressions_binary_NotEquals__WEBPACK_IMPORTED_MODULE_7__["default"], 'not_equal');
}
_lessThan (f) {
return this._cmpOp(f, _renderer_viz_expressions_binary_LessThan__WEBPACK_IMPORTED_MODULE_2__["default"], 'less_than', 'greater_than');
}
_lessThanOrEqualTo (f) {
return this._cmpOp(f, _renderer_viz_expressions_binary_LessThanOrEqualTo__WEBPACK_IMPORTED_MODULE_3__["default"], 'less_than_or_equal_to', 'greater_than_or_equal_to');
}
_greaterThan (f) {
return this._cmpOp(f, _renderer_viz_expressions_binary_GreaterThan__WEBPACK_IMPORTED_MODULE_0__["default"], 'greater_than', 'less_than');
}
_greaterThanOrEqualTo (f) {
return this._cmpOp(f, _renderer_viz_expressions_binary_GreaterThanOrEqualTo__WEBPACK_IMPORTED_MODULE_1__["default"], 'greater_than_or_equal_to', 'less_than_or_equal_to');
}
_aggregation (f) {
f = this._removeBlend(f);
if (f.isA(_renderer_viz_expressions_aggregation_cluster_ClusterAvg__WEBPACK_IMPORTED_MODULE_16__["default"]) || f.isA(_renderer_viz_expressions_aggregation_cluster_ClusterMax__WEBPACK_IMPORTED_MODULE_17__["default"]) || f.isA(_renderer_viz_expressions_aggregation_cluster_ClusterMin__WEBPACK_IMPORTED_MODULE_18__["default"]) || f.isA(_renderer_viz_expressions_aggregation_cluster_ClusterMode__WEBPACK_IMPORTED_MODULE_19__["default"]) || f.isA(_renderer_viz_expressions_aggregation_cluster_ClusterSum__WEBPACK_IMPORTED_MODULE_20__["default"])) {
let p = this._property(f.property);
if (p) {
p.property = f.propertyName;
return p;
}
}
if (this._onlyAggregateFilters) {
// no filters on non-aggregate columns (i.e. dimensions) are generated
// such filtering should be applied elsewhere
return;
}
return this._property(f);
}
_property (f) {
f = this._removeBlend(f);
if (f.isA(_renderer_viz_expressions_basic_property__WEBPACK_IMPORTED_MODULE_10__["default"])) {
return {
property: f.name,
filters: []
};
}
}
_cmpOp (f, opClass, opParam, inverseOpParam) {
inverseOpParam = inverseOpParam || opParam;
if (f.isA(opClass)) {
let p = this._aggregation(f.a);
let v = p && this._value(f.b);
let op = opParam;
if (!v) {
p = this._aggregation(f.b);
v = p && this._value(f.a);
op = inverseOpParam;
}
if (v) {
let filter = {};
filter[op] = v;
p.filters.push(filter);
return p;
}
}
}
_compatibleAndFilters (a, b) {
// check if a and b can be combined into a range filter
if (a.length === 0 || b.length === 0) {
return true;
}
if (a.length === 1 && b.length === 1) {
const af = a[0];
const bf = b[0];
if (Object.keys(af).length === 1 && Object.keys(bf).length === 1) {
const ka = Object.keys(af)[0];
const kb = Object.keys(bf)[0];
const lessOps = ['less_than', 'less_than_or_equal_to'];
const greaterOps = ['greater_than', 'greater_than_or_equal_to'];
return (lessOps.includes(ka) && greaterOps.includes(kb)) ||
(lessOps.includes(kb) && greaterOps.includes(ka));
}
}
return false;
}
}
class PreaggregationFiltering {
/**
* Generate pre-aggregation filters, i.e. filters that can be
* applied to the dataset before aggregation.
* This extracts, from the vizs filters, those compatible to be
* executed before aggregation.
* The extracted filters are in an internal tree-like format;
* each node has a `type` property and various other parameters
* that depend on the type.
*/
// return (partial) filters as an object (JSON) representing the SQL syntax tree
getFilter (vizFilter) {
return this._filter(vizFilter);
}
_filter (f) {
return this._and(f) || this._or(f) ||
this._in(f) || this._notIn(f) ||
this._between(f) ||
this._equals(f) || this._notEquals(f) ||
this._lessThan(f) || this._lessThanOrEqualTo(f) ||
this._greaterThan(f) || this._greaterThanOrEqualTo(f) ||
this._blend(f) || null;
}
_and (f) {
if (f.isA(_renderer_viz_expressions_binary_And__WEBPACK_IMPORTED_MODULE_4__["default"])) {
// we can ignore nonsupported (null) subexpressions that are combined with AND
// and keep the supported ones as a partial filter
const l = [this._filter(f.a), this._filter(f.b)].filter(Boolean).reduce((x, y) => x.concat(y), []);
if (l.length) {
if (l.length === 1) {
return l[0];
}
return {
type: 'and',
left: l[0],
right: l[1]
};
}
}
}
_or (f) {
if (f.isA(_renderer_viz_expressions_binary_Or__WEBPACK_IMPORTED_MODULE_5__["default"])) {
// if any subexpression is not supported the OR combination isn't supported either
let a = this._filter(f.a);
let b = this._filter(f.b);
if (a && b) {
return {
type: 'or',
left: a,
right: b
};
}
}
}
_lessThan (f) {
return this._cmpOp(f, _renderer_viz_expressions_binary_LessThan__WEBPACK_IMPORTED_MODULE_2__["default"], 'lessThan');
}
_lessThanOrEqualTo (f) {
return this._cmpOp(f, _renderer_viz_expressions_binary_LessThanOrEqualTo__WEBPACK_IMPORTED_MODULE_3__["default"], 'lessThanOrEqualTo');
}
_greaterThan (f) {
return this._cmpOp(f, _renderer_viz_expressions_binary_GreaterThan__WEBPACK_IMPORTED_MODULE_0__["default"], 'greaterThan');
}
_greaterThanOrEqualTo (f) {
return this._cmpOp(f, _renderer_viz_expressions_binary_GreaterThanOrEqualTo__WEBPACK_IMPORTED_MODULE_1__["default"], 'greaterThanOrEqualTo');
}
_equals (f) {
return this._cmpOp(f, _renderer_viz_expressions_binary_Equals__WEBPACK_IMPORTED_MODULE_6__["default"], 'equals');
}
_notEquals (f) {
return this._cmpOp(f, _renderer_viz_expressions_binary_NotEquals__WEBPACK_IMPORTED_MODULE_7__["default"], 'notEquals');
}
_cmpOp (f, opClass, type) {
if (f.isA(opClass)) {
let a = this._property(f.a) || this._value(f.a);
let b = this._property(f.b) || this._value(f.b);
if (a && b) {
return {
type: type,
left: a,
right: b
};
}
}
}
_blend (f) {
if (f.isA(_renderer_viz_expressions_blend__WEBPACK_IMPORTED_MODULE_11__["default"]) && f.originalMix.isA(_renderer_viz_expressions_transition__WEBPACK_IMPORTED_MODULE_12__["default"])) {
return this._filter(f.b);
}
}
_property (f) {
if (f.isA(_renderer_viz_expressions_basic_property__WEBPACK_IMPORTED_MODULE_10__["default"])) {
return {
type: 'property',
property: f.name
};
}
}
_value (f) {
if (f.isA(_renderer_viz_expressions_basic_number__WEBPACK_IMPORTED_MODULE_13__["default"]) || f.isA(_renderer_viz_expressions_basic_constant__WEBPACK_IMPORTED_MODULE_14__["default"]) || f.isA(_renderer_viz_expressions_basic_category__WEBPACK_IMPORTED_MODULE_15__["default"])) {
return {
type: 'value',
value: f.value
};
}
}
_in (f) {
if (f.isA(_renderer_viz_expressions_belongs__WEBPACK_IMPORTED_MODULE_8__["In"])) {
let p = this._property(f.input);
let values = f.list.elems.map(cat => this._value(cat));
if (p && values.length > 0 && values.length === f.list.elems.length) {
return {
type: 'in',
property: p.property,
values: values.map(v => v.value)
};
}
}
}
_notIn (f) {
if (f.isA(_renderer_viz_expressions_belongs__WEBPACK_IMPORTED_MODULE_8__["Nin"])) {
let p = this._property(f.input);
let values = f.list.elems.map(cat => this._value(cat));
if (p && values.length > 0 && values.length === f.list.elems.length) {
return {
type: 'notIn',
property: p.property,
values: values.map(v => v.value)
};
}
}
}
_between (f) {
if (f.isA(_renderer_viz_expressions_between__WEBPACK_IMPORTED_MODULE_9__["default"])) {
let p = this._property(f.input);
let lo = this._value(f.lowerLimit);
let hi = this._value(f.upperLimit);
if (p && lo && hi) {
return {
type: 'between',
property: p.property,
lower: lo.value,
upper: hi.value
};
}
}
}
}
function getSQL (node) {
if (node.type) {
return `(${SQLGenerators[node.type](node)})`;
}
return sqlQ(node);
}
function sqlQ (value) {
if (isFinite(value)) {
return String(value);
}
return `'${value.replace(/\'/g, '\'\'')}'`;
}
function sqlId (id) {
if (!id.match(/^[a-z\d_]+$/)) {
id = `"${id.replace(/\"/g, '""')}"`;
}
return id;
}
function sqlSep (sep, ...args) {
return args.map(arg => getSQL(arg)).join(sep);
}
const SQLGenerators = {
'and': f => sqlSep(' AND ', f.left, f.right),
'or': f => sqlSep(' OR ', f.left, f.right),
'between': f => `${sqlId(f.property)} BETWEEN ${sqlQ(f.lower)} AND ${sqlQ(f.upper)}`,
'in': f => `${sqlId(f.property)} IN (${sqlSep(',', ...f.values)})`,
'notIn': f => `${sqlId(f.property)} NOT IN (${sqlSep(',', ...f.values)})`,
'equals': f => sqlSep(' = ', f.left, f.right),
'notEquals': f => sqlSep(' <> ', f.left, f.right),
'lessThan': f => sqlSep(' < ', f.left, f.right),
'lessThanOrEqualTo': f => sqlSep(' <= ', f.left, f.right),
'greaterThan': f => sqlSep(' > ', f.left, f.right),
'greaterThanOrEqualTo': f => sqlSep(' >= ', f.left, f.right),
'property': f => sqlId(f.property),
'value': f => sqlQ(f.value)
};
/**
* Returns supported windshaft filters for the viz
* @param {*} viz
* @returns {Filtering}
*/
function getFiltering (viz, options = {}) {
const aggrFiltering = new AggregationFiltering(options);
const preFiltering = new PreaggregationFiltering(options);
const filtering = {
preaggregation: preFiltering.getFilter(viz.filter),
aggregation: aggrFiltering.getFilters(viz.filter)
};
if (!filtering.preaggregation && !filtering.aggregation) {
return null;
}
return filtering;
}
/**
* Convert preaggregation filters (as generated by PreaggregationFiltering)
* into an equivalent SQL WHERE expression.
*
* @param {Filtering} filtering
*/
function getSQLWhere (filtering) {
filtering = filtering && filtering.preaggregation;
let sql;
if (filtering && Object.keys(filtering).length > 0) {
sql = getSQL(filtering);
}
return sql ? 'WHERE ' + sql : '';
}
function getAggregationFilters (filtering) {
return filtering && filtering.aggregation;
}
/***/ }),
/***/ "./src/client/windshaft.js":
/*!*********************************!*\
!*** ./src/client/windshaft.js ***!
\*********************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Windshaft; });
/* harmony import */ var _sources_MVT__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sources/MVT */ "./src/sources/MVT.js");
/* harmony import */ var _WindshaftMetadata__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./WindshaftMetadata */ "./src/client/WindshaftMetadata.js");
/* harmony import */ var _renderer_Metadata__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../renderer/Metadata */ "./src/renderer/Metadata.js");
/* harmony import */ var _renderer_schema__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../renderer/schema */ "./src/renderer/schema.js");
/* harmony import */ var _windshaft_filtering__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./windshaft-filtering */ "./src/client/windshaft-filtering.js");
/* harmony import */ var _WindshaftRequestHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./WindshaftRequestHelper */ "./src/client/WindshaftRequestHelper.js");
/* harmony import */ var _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../errors/carto-validation-error */ "./src/errors/carto-validation-error.js");
/* harmony import */ var _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../errors/carto-maps-api-error */ "./src/errors/carto-maps-api-error.js");
/* harmony import */ var _utils_geometry__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/geometry */ "./src/utils/geometry.js");
/* harmony import */ var _constants_metadata__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../constants/metadata */ "./src/constants/metadata.js");
const SAMPLE_ROWS = 1000;
const MIN_FILTERING = 2000000;
const MAX_CATEGORIES = 32768;
const TILE_EXTENT = 2048;
class Windshaft {
constructor (source) {
this._source = source;
this._exclusive = true;
this._MNS = null;
this._promiseMNS = null;
this.inProgressInstantiations = {};
}
bindLayer (addDataframe) {
this._addDataframe = addDataframe;
this._mvtClient.bindLayer(addDataframe);
}
_getInstantiationID (vizInfo, choices) {
const { MNS, resolution, filtering } = vizInfo;
return JSON.stringify({
MNS: _renderer_schema__WEBPACK_IMPORTED_MODULE_3__["default"].simplify(MNS),
resolution,
filtering: choices.backendFilters ? filtering : null,
options: choices
});
}
/**
* Should be called whenever the viz changes, even if metadata is not going to be used.
* This not only computes metadata: it also updates the map (instantiates) for the new viz if needed
* Returns a promise to a Metadata
* @param {*} viz
*/
async getMetadata (viz) {
const vizInfo = this._getServerInfoFrom(viz);
if (this._needToInstantiateMap(vizInfo)) {
const instantiationData = await this._repeatableInstantiate(vizInfo);
this._updateStateAfterInstantiating(instantiationData);
}
return this.metadata;
}
/**
* Get relevant info from Viz related to windshaft requests
*/
_getServerInfoFrom (viz) {
const MNS = this._getMinNeededSchemaFrom(viz);
const resolution = viz.resolution.value;
const filtering = _windshaft_filtering__WEBPACK_IMPORTED_MODULE_4__["getFiltering"](viz, { exclusive: this._exclusive });
// TODO: properly document returned output at jsdoc (with typedef?)
const vizInfo = { MNS, resolution, filtering }; // TODO this looks like a Type or even a Class
return vizInfo;
}
/**
* Get the minimum schema from the viz, validated and with DEFAULT_ID_PROPERTY
*/
_getMinNeededSchemaFrom (viz) {
const MNS = viz.getMinimumNeededSchema();
this._checkAcceptableMNS(MNS);
this._forceIncludeCartodbId(MNS);
return MNS;
}
_forceIncludeCartodbId (MNS) {
// Force to include DEFAULT_ID_PROPERTY in the MNS columns.
// TODO: revisit this request to Maps API
if (!MNS[_renderer_Metadata__WEBPACK_IMPORTED_MODULE_2__["DEFAULT_ID_PROPERTY"]]) {
MNS[_renderer_Metadata__WEBPACK_IMPORTED_MODULE_2__["DEFAULT_ID_PROPERTY"]] = [{ type: _constants_metadata__WEBPACK_IMPORTED_MODULE_9__["aggregationTypes"].UNAGGREGATED }];
}
}
requiresNewMetadata (viz) {
const vizInfo = this._getServerInfoFrom(viz);
return this._needToInstantiateMap(vizInfo);
}
_checkAcceptableMNS (MNS) {
Object.keys(MNS).forEach(propertyName => {
const usages = MNS[propertyName];
const aggregatedUsage = usages.some(x => x.type === _constants_metadata__WEBPACK_IMPORTED_MODULE_9__["aggregationTypes"].AGGREGATED);
const unAggregatedUsage = usages.some(x => x.type === _constants_metadata__WEBPACK_IMPORTED_MODULE_9__["aggregationTypes"].UNAGGREGATED);
if (aggregatedUsage && unAggregatedUsage) {
const aggregationUssages = JSON.stringify(usages.filter(x => x.type !== 'aggregated'));
throw new _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["default"](
`Incompatible combination of cluster aggregation usages (${aggregationUssages}) with unaggregated usage for property '${propertyName}'`,
_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__["CartoValidationErrorTypes"].INCORRECT_VALUE
);
}
});
}
/**
* After calling getMetadata(), data for a viewport can be obtained with this function.
* So long as the viz doesn't change, getData() can be called repeatedly for different
* viewports. If viz changes getMetadata() should be called before requesting data
* for the new viz.
*/
getData (zoom, viewport) {
if (this._mvtClient) {
return this._mvtClient.requestData(zoom, viewport);// FIXME extend
}
}
/**
* Check if the map needs to be reinstantiated
* This happens:
* - When the minimun required schema changed.
* - When the resolution changed.
* - When the filter conditions changed and the dataset should be server-filtered.
*/
_needToInstantiateMap (vizInfo) {
const { MNS, resolution, filtering } = vizInfo;
const schemaChanged = _renderer_schema__WEBPACK_IMPORTED_MODULE_3__["default"].notEquals(this._MNS, MNS);
const resolutionChanged = this.resolution !== resolution;
const filteringChanged = JSON.stringify(this.filtering) !== JSON.stringify(filtering);
const shouldBeServerFiltered = this.metadata && (this.metadata.featureCount > MIN_FILTERING);
return schemaChanged || resolutionChanged || (filteringChanged && shouldBeServerFiltered);
}
_isInstantiated () {
return !!this.metadata;
}
_instantiationChoices (metadata) {
let choices = {
backendFilters: true // default choices
};
const thereAreFeatures = metadata && metadata.featureCount >= 0;
if (thereAreFeatures) {
const shouldBeServerFiltered = metadata.featureCount > MIN_FILTERING;
choices.backendFilters = shouldBeServerFiltered || !metadata.backendFiltersApplied;
}
return choices;
}
async _instantiateUncached (vizInfo, choices = { backendFilters: true }, overrideMetadata = null) {
const { MNS, resolution, filtering } = vizInfo;
const agg = await this._generateAggregation(MNS, resolution);
let select = this._buildSelectClause(MNS);
let aggSQL = this._buildQuery(select);
const query = `(${aggSQL}) AS tmp`;
let backendFilters = choices.backendFilters ? filtering : null;
let backendFiltersApplied = false;
if (backendFilters && this._requiresAggregation(MNS)) {
agg.filters = _windshaft_filtering__WEBPACK_IMPORTED_MODULE_4__["getAggregationFilters"](backendFilters);
if (agg.filters) {
backendFiltersApplied = true;
}
if (!this._exclusive) {
backendFilters = null;
}
}
if (backendFilters) {
const filteredSQL = this._buildQuery(select, backendFilters);
backendFiltersApplied = backendFiltersApplied || filteredSQL !== aggSQL;
aggSQL = filteredSQL;
}
const conf = this._getConfig();
let { urlTemplates, metadata } = await this._getInstantiationPromise(query, conf, agg, aggSQL, select, overrideMetadata, MNS);
metadata.backendFiltersApplied = backendFiltersApplied;
return { MNS, resolution, filtering, metadata, urlTemplates };
}
_updateStateAfterInstantiating ({ MNS, resolution, filtering, metadata, urlTemplates }) {
if (this._mvtClient) {
this._mvtClient.free();
}
metadata.extent = TILE_EXTENT;
this._mvtClient = new _sources_MVT__WEBPACK_IMPORTED_MODULE_0__["default"](urlTemplates, metadata);
this._mvtClient._workerName = 'windshaft';
this._mvtClient.bindLayer(this._addDataframe);
this.urlTemplates = urlTemplates;
this.metadata = metadata;
this._MNS = MNS;
this.filtering = filtering;
this.resolution = resolution;
this._checkLayerMeta(MNS);
}
async _instantiate (vizInfo, choices, metadata) {
const id = this._getInstantiationID(vizInfo, choices);
if (this.inProgressInstantiations[id]) {
return this.inProgressInstantiations[id];
}
const instantiationPromise = this._instantiateUncached(vizInfo, choices, metadata);
this.inProgressInstantiations[id] = instantiationPromise;
return instantiationPromise;
}
async _repeatableInstantiate (vizInfo) {
// TODO: we shouldn't reinstantiate just to not apply backend filters
// (we'd need to add a choice comparison function argument to repeatablePromise)
let finalMetadata = null;
const initialChoices = this._instantiationChoices(this.metadata);
const finalChoices = instantiation => {
// first instantiation metadata is kept
finalMetadata = instantiation.metadata;
return this._instantiationChoices(instantiation.metadata);
};
return repeatablePromise(initialChoices, finalChoices, choices => this._instantiate(vizInfo, choices, finalMetadata));
}
_checkLayerMeta (MNS) {
if (!this._isAggregated() && this._requiresAggregation(MNS)) {
throw new _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_7__["default"]('Aggregation not supported for this dataset', _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_7__["CartoMapsAPIErrorTypes"].NOT_SUPPORTED);
}
}
_isAggregated () {
return this.metadata && this.metadata.isAggregated;
}
_requiresAggregation (MNS) {
return Object.values(MNS).some(propertyUsages =>
propertyUsages.some(u => u.type === _constants_metadata__WEBPACK_IMPORTED_MODULE_9__["aggregationTypes"].AGGREGATED)
);
}
_generateAggregation (MNS, resolution) {
let aggregation = {
columns: {},
dimensions: {},
placement: 'centroid',
resolution: resolution,
threshold: 1
};
Object.keys(MNS)
.forEach(propertyName => {
if (propertyName !== _renderer_Metadata__WEBPACK_IMPORTED_MODULE_2__["DEFAULT_ID_PROPERTY"]) {
const propertyUsages = MNS[propertyName];
propertyUsages.forEach(usage => {
if (usage.type === 'aggregated') {
aggregation.columns[_renderer_schema__WEBPACK_IMPORTED_MODULE_3__["default"].column.aggColumn(propertyName, usage.op)] = {
aggregate_function: usage.op,
aggregated_column: propertyName
};
} else if (usage.type === 'dimension') {
const dimension = usage.dimension;
const { group, format } = dimension;
const parameters = { column: propertyName, group, format };
aggregation.dimensions[dimension.propertyName] = parameters;
} else {
// automatic ungrouped dimension
// TODO:
// we should consider eliminating this and requiring
// all dimensions to be used through clusterXXX functions
aggregation.dimensions[propertyName] = {
column: propertyName
};
}
});
}
});
return aggregation;
}
_buildSelectClause (MNS) {
const columns = Object.keys(MNS).concat(['the_geom_webmercator', _renderer_Metadata__WEBPACK_IMPORTED_MODULE_2__["DEFAULT_ID_PROPERTY"]]);
return columns.filter((item, pos) => columns.indexOf(item) === pos); // get unique values
}
_buildQuery (select, filters) {
const columns = select.map(column => `"${column}"`).join();
const condition = filters ? _windshaft_filtering__WEBPACK_IMPORTED_MODULE_4__["getSQLWhere"](filters) : '';
return `SELECT ${columns} FROM ${this._source._getFromClause()} ${condition}`;
}
_getConfig () {
return {
apiKey: this._source._apiKey,
username: this._source._username,
serverURL: this._source._serverURL
};
}
free () {
if (this._mvtClient) {
this._mvtClient.free();
}
}
async _getInstantiationPromise (query, conf, agg, aggSQL, columns, overrideMetadata, MNS) {
const mapConfigAgg = this._getMapConfigAgg(agg, aggSQL);
if (!overrideMetadata) {
this._completeMapConfigWithColumns(mapConfigAgg, columns);
}
const layergroup = await this._getLayerGroupFromWindshaft(conf, mapConfigAgg);
return {
urlTemplates: layergroup.metadata.tilejson.vector.tiles,
metadata: overrideMetadata || this._adaptMetadata(layergroup.metadata.layers[0].meta, agg, MNS)
};
}
_getMapConfigAgg (agg, aggSQL) {
const mapConfigAgg = {
buffersize: {
mvt: 1
},
layers: [
{
type: 'mapnik',
options: {
sql: aggSQL,
aggregation: agg,
vector_extent: TILE_EXTENT,
vector_simplify_extent: TILE_EXTENT,
dates_as_numbers: true
}
}
]
};
return mapConfigAgg;
}
_completeMapConfigWithColumns (mapConfigAgg, columns) {
const excludedColumns = ['the_geom', 'the_geom_webmercator'];
const includedColumns = columns.filter(name => !excludedColumns.includes(name));
mapConfigAgg.layers[0].options.metadata = {
geometryType: true,
columnStats: {
topCategories: MAX_CATEGORIES,
includeNulls: true
},
dimensions: true,
sample: {
num_rows: SAMPLE_ROWS,
include_columns: includedColumns // TODO: when supported by Maps API: exclude_columns: excludedColumns
}
};
}
async _getLayerGroupFromWindshaft (conf, mapConfigAgg) {
const requestHelper = new _WindshaftRequestHelper__WEBPACK_IMPORTED_MODULE_5__["default"](conf, mapConfigAgg);
return requestHelper.getLayerGroup();
}
_adaptMetadata (meta, agg, MNS) {
meta.datesAsNumbers = meta.dates_as_numbers;
const { stats, aggregation, datesAsNumbers } = meta;
const featureCount = stats.hasOwnProperty('featureCount') ? stats.featureCount : stats.estimatedFeatureCount;
const geomType = stats.geometryType && adaptGeometryType(stats.geometryType);
const properties = stats.columns;
Object.keys(agg.columns).forEach(aggName => {
const basename = agg.columns[aggName].aggregated_column;
const fnName = agg.columns[aggName].aggregate_function;
if (!properties[basename].aggregations) {
properties[basename].aggregations = {};
}
properties[basename].aggregations[fnName] = aggName;
if (basename !== aggName) {
properties[aggName] = JSON.parse(JSON.stringify(properties[basename]));
}
});
Object.keys(agg.dimensions).forEach(dimName => {
const dimension = agg.dimensions[dimName];
if (stats.dimensions && stats.dimensions[dimName].type) {
// otherwise, the dimension is a (legacy) ungrouped dimension
const dimensionStats = stats.dimensions[dimName];
const dimType = adaptColumnType(dimensionStats.type);
const { column, ...params } = dimension;
if (properties[column].dimension) {
throw new _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_7__["default"](`Multiple dimensions based on same column '${column}'.`, _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_7__["CartoMapsAPIErrorTypes"].NOT_SUPPORTED);
}
properties[column].dimension = {
propertyName: dimName,
grouping: Object.keys(params).length === 0 ? undefined : dimensionStats.params,
type: dimType,
// TODO: merge all properties of dimensionStats except params, type
min: dimensionStats.min,
max: dimensionStats.max
};
const range = MNS[column].some(c => c.range);
if (range > 0) {
properties[column].dimension.range = ['start', 'end'].map(mode => `${dimName}_${mode}`);
}
}
});
Object.values(properties).map(property => {
property.type = adaptColumnType(property.type);
});
Object.keys(properties).forEach(propertyName => {
const property = properties[propertyName];
if (property.type === 'category' && property.categories) {
property.categories.forEach(category => {
category.name = category.category;
delete category.category;
});
} else if (datesAsNumbers && datesAsNumbers.includes(propertyName)) {
property.type = 'date';
}
});
if (geomType === _utils_geometry__WEBPACK_IMPORTED_MODULE_8__["GEOMETRY_TYPE"].POINT) {
properties[_constants_metadata__WEBPACK_IMPORTED_MODULE_9__["CLUSTER_FEATURE_COUNT"]] = { type: 'number' };
}
return new _WindshaftMetadata__WEBPACK_IMPORTED_MODULE_1__["default"]({
properties,
featureCount,
sample: stats.sample,
geomType,
isAggregated: aggregation.mvt,
idProperty: _renderer_Metadata__WEBPACK_IMPORTED_MODULE_2__["DEFAULT_ID_PROPERTY"]
});
}
}
function adaptGeometryType (type) {
switch (type) {
case 'ST_MultiPolygon':
case 'ST_Polygon':
return _utils_geometry__WEBPACK_IMPORTED_MODULE_8__["GEOMETRY_TYPE"].POLYGON;
case 'ST_Point':
return _utils_geometry__WEBPACK_IMPORTED_MODULE_8__["GEOMETRY_TYPE"].POINT;
case 'ST_MultiLineString':
case 'ST_LineString':
return _utils_geometry__WEBPACK_IMPORTED_MODULE_8__["GEOMETRY_TYPE"].LINE;
default:
throw new _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_7__["default"](`Unimplemented geometry type '${type}'.`, _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_7__["CartoMapsAPIErrorTypes"].NOT_SUPPORTED);
}
}
function adaptColumnType (type) {
if (type === 'string') {
return 'category';
}
return type;
}
// generate a promise under certain assumptions/choices; then if the result changes the assumptions,
// repeat the generation with the new information
async function repeatablePromise (initialAssumptions, assumptionsFromResult, promiseGenerator) {
let promise = promiseGenerator(initialAssumptions);
let result = await promise;
let finalAssumptions = assumptionsFromResult(result);
if (JSON.stringify(initialAssumptions) === JSON.stringify(finalAssumptions)) {
return promise;
} else {
return promiseGenerator(finalAssumptions);
}
}
/***/ }),
/***/ "./src/codecs/Base.js":
/*!****************************!*\
!*** ./src/codecs/Base.js ***!
\****************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return BaseCodec; });
// A Dataframe property Codec is used to transform between property value encodings.
// Three different encodings are handled:
// * The `source` encoding correspond to the format in which
// the property values appear in the data sources (e.g. in MVT)
// * The `internal` encoding is used in Dataframe properties
// apt for GPU consumption.
// * The `external` encoding is the format in which feature
// properties are presented to the user
// (e.g. `property.eval(feature)` or `globalMin(property)`)
// The Codec base class serves both as a base for derived codecs.
// Codecs are associated to source properties.
// There are two kind of codecs:
// * Scalar (simple) encoder: source value is encoded as a single internal value
// * Range encoder: a source value encodes as a pair [lo, hi] of values.
class BaseCodec {
constructor (metadata, propertyName) {
if (metadata && propertyName) {
this._baseName = metadata.baseName(propertyName);
}
}
isRange () {
return false;
}
isIdentity () {
return false;
}
// Convert source encoding to internal;
// Result is an array [lo, hi] for ranges and a value for scalar codecs
// Used to encode sources into dataframe properties.
sourceToInternal (metadata, v) {
return v;
}
// Convert internal encoding to external;
// Input may be one for scalar, or two values (hi, lo) for ranges.
// Used to present dataframe features.
internalToExternal (metadata, v) {
return v;
}
// Convert external encoding back to source values.
// Used to generate SQL filters: (apply to constant/global)
externalToSource (metadata, v) {
return v;
}
// Convert source encoding to external encoding.
// Used to present source stats values (global aggregations)
// to match the format of constant expressions.
sourceToExternal (metadata, v) {
return this.internalToExternal(metadata, this.sourceToInternal(metadata, v));
}
// Convert external to internal encoding.
// Result is a value for scalar codecs
// and [lo, hi] for range codecs.
// used to to apply filters in GLSL inlined code;
// evaluate binary operations property vs external (constant/global
externalToInternal (metadata, v) {
return this.sourceToInternal(metadata, this.externalToSource(metadata, v));
}
// Generate GLSL inline expression to map a property value
// to the internal encoding of another property.
// Used to bind some binary operations between properties.
inlineInternalMatch (thisValue, _otherCodec) {
return `${thisValue}`;
}
}
/***/ }),
/***/ "./src/codecs/Category.js":
/*!********************************!*\
!*** ./src/codecs/Category.js ***!
\********************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CategoryCodec; });
/* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Base */ "./src/codecs/Base.js");
class CategoryCodec extends _Base__WEBPACK_IMPORTED_MODULE_0__["default"] {
sourceToInternal (metadata, propertyValue) {
return metadata.categorizeString(this._baseName, propertyValue);
}
internalToExternal (metadata, propertyValue) {
return metadata.IDToCategory.get(propertyValue);
}
sourceToExternal (metadata, propertyValue) {
return propertyValue;
}
externalToSource (metadata, v) {
return v;
}
}
/***/ }),
/***/ "./src/codecs/Date.js":
/*!****************************!*\
!*** ./src/codecs/Date.js ***!
\****************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return DateCodec; });
/* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Base */ "./src/codecs/Base.js");
/* harmony import */ var _utils_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/util */ "./src/utils/util.js");
class DateCodec extends _Base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (metadata, propertyName) {
super(metadata, propertyName);
const { min } = metadata.stats(propertyName);
this._min_date = _utils_util__WEBPACK_IMPORTED_MODULE_1__["castDate"](min);
this._min_ms = this._min_date.getTime();
}
sourceToInternal (metadata, propertyValue) {
// numbers (epoch in milliseconds) or Dates are accepted
return _utils_util__WEBPACK_IMPORTED_MODULE_1__["castDate"](propertyValue).getTime() - this._min_ms;
}
internalToExternal (metadata, propertyValue) {
let value = propertyValue;
value += this._min_ms;
return _utils_util__WEBPACK_IMPORTED_MODULE_1__["msToDate"](value);
}
externalToSource (metadata, v) {
return v.getTime();
}
sourceToExternal (metadata, v) {
return _utils_util__WEBPACK_IMPORTED_MODULE_1__["castDate"](v);
}
inlineInternalMatch (thisValue, otherCodec) {
const offset = otherCodec._min_ms - this._min_ms;
return `(${thisValue}-${offset.toFixed(20)})`;
}
}
/***/ }),
/***/ "./src/codecs/Identity.js":
/*!********************************!*\
!*** ./src/codecs/Identity.js ***!
\********************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return IdentityCodec; });
/* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Base */ "./src/codecs/Base.js");
// The Identity codec class serves
// as the default, identity encoding, in which all three
// encodings are exactly the same.
class IdentityCodec extends _Base__WEBPACK_IMPORTED_MODULE_0__["default"] {
isIdentity () {
return true;
}
sourceToInternal (metadata, v) {
return v;
}
internalToExternal (metadata, v) {
return v;
}
sourceToExternal (metadata, v) {
return v;
}
externalToSource (metadata, v) {
return v;
}
externalToInternal (metadata, v) {
return v;
}
}
/***/ }),
/***/ "./src/codecs/Number.js":
/*!******************************!*\
!*** ./src/codecs/Number.js ***!
\******************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return NumberCodec; });
/* harmony import */ var _Identity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Identity */ "./src/codecs/Identity.js");
/* harmony import */ var _renderer_viz_expressions_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../renderer/viz/expressions/constants */ "./src/renderer/viz/expressions/constants.js");
class NumberCodec extends _Identity__WEBPACK_IMPORTED_MODULE_0__["default"] {
sourceToInternal (metadata, propertyValue) {
if (isNaN(propertyValue) || propertyValue == null) {
propertyValue = _renderer_viz_expressions_constants__WEBPACK_IMPORTED_MODULE_1__["FP32_DESIGNATED_NULL_VALUE"];
}
return propertyValue;
}
internalToExternal (metadata, value) {
if (value === _renderer_viz_expressions_constants__WEBPACK_IMPORTED_MODULE_1__["FP32_DESIGNATED_NULL_VALUE"]) {
value = null;
}
return value;
}
externalToInternal (metadata, value) {
if (value === null) {
value = _renderer_viz_expressions_constants__WEBPACK_IMPORTED_MODULE_1__["FP32_DESIGNATED_NULL_VALUE"];
}
return value;
}
}
/***/ }),
/***/ "./src/codecs/index.js":
/*!*****************************!*\
!*** ./src/codecs/index.js ***!
\*****************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return codecFactory; });
/* harmony import */ var _Number__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Number */ "./src/codecs/Number.js");
/* harmony import */ var _Category__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Category */ "./src/codecs/Category.js");
/* harmony import */ var _Date__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Date */ "./src/codecs/Date.js");
/* harmony import */ var _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../errors/carto-runtime-error */ "./src/errors/carto-runtime-error.js");
function codecFactory (metadata, type, propertyName) {
switch (type) {
case 'number':
return new _Number__WEBPACK_IMPORTED_MODULE_0__["default"](metadata, propertyName);
case 'category':
return new _Category__WEBPACK_IMPORTED_MODULE_1__["default"](metadata, propertyName);
case 'date':
return new _Date__WEBPACK_IMPORTED_MODULE_2__["default"](metadata, propertyName);
default:
throw new _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_3__["default"](
`Feature property value of type '${type}' cannot be decoded.`,
_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_3__["CartoRuntimeErrorTypes"].NOT_SUPPORTED
);
}
}
/***/ }),
/***/ "./src/codecs/mvt/Category.js":
/*!************************************!*\
!*** ./src/codecs/mvt/Category.js ***!
\************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return MVTCategoryCodec; });
/* harmony import */ var _Category__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Category */ "./src/codecs/Category.js");
/* harmony import */ var _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../errors/carto-runtime-error */ "./src/errors/carto-runtime-error.js");
class MVTCategoryCodec extends _Category__WEBPACK_IMPORTED_MODULE_0__["default"] {
sourceToInternal (metadata, propertyValue) {
const propertyValueType = typeof propertyValue;
if (propertyValue !== null && propertyValueType !== 'undefined' && propertyValueType !== 'string') {
// In general Codecs are unique per original base property, not per source property,
// but for the generic MVT sources we don't support multiple source properties per base property (e.g. aggregations)
// so it would suffice to keep the property name in the Codec class.
// For more general solutions we'd need to provide the source property name as an argument to this method.
throw new _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_1__["default"](
`MVT decoding error. Metadata property '${this._baseName}' is of type 'category' but the MVT tile contained a feature property of type '${propertyValueType}': '${propertyValue}'`,
_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_1__["CartoRuntimeErrorTypes"].MVT
);
}
return super.sourceToInternal(metadata, propertyValue);
}
}
/***/ }),
/***/ "./src/codecs/mvt/Number.js":
/*!**********************************!*\
!*** ./src/codecs/mvt/Number.js ***!
\**********************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return MVTNumberCodec; });
/* harmony import */ var _Number__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Number */ "./src/codecs/Number.js");
/* harmony import */ var _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../errors/carto-runtime-error */ "./src/errors/carto-runtime-error.js");
class MVTNumberCodec extends _Number__WEBPACK_IMPORTED_MODULE_0__["default"] {
sourceToInternal (metadata, propertyValue) {
const propertyValueType = typeof propertyValue;
if (propertyValue !== null && propertyValueType !== 'undefined' && propertyValueType !== 'number') {
throw new _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_1__["default"](
`MVT decoding error. Metadata property '${this._baseName}' is of type 'number' but the MVT tile contained a feature property of type '${propertyValueType}': '${propertyValue}'`,
_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_1__["CartoRuntimeErrorTypes"].MVT
);
}
return super.sourceToInternal(metadata, propertyValue);
}
}
/***/ }),
/***/ "./src/codecs/mvt/index.js":
/*!*********************************!*\
!*** ./src/codecs/mvt/index.js ***!
\*********************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return MVTCodecFactory; });
/* harmony import */ var _Number__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Number */ "./src/codecs/mvt/Number.js");
/* harmony import */ var _Category__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Category */ "./src/codecs/mvt/Category.js");
/* harmony import */ var _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../errors/carto-runtime-error */ "./src/errors/carto-runtime-error.js");
function MVTCodecFactory (metadata, type, propertyName) {
switch (type) {
case 'number':
return new _Number__WEBPACK_IMPORTED_MODULE_0__["default"](metadata, propertyName);
case 'category':
return new _Category__WEBPACK_IMPORTED_MODULE_1__["default"](metadata, propertyName);
default:
throw new _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_2__["default"](
`MVT decoding error. Feature property value of type '${type}' cannot be decoded.`,
_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_2__["CartoRuntimeErrorTypes"].MVT
);
}
}
/***/ }),
/***/ "./src/codecs/windshaft/TimeRange.js":
/*!*******************************************!*\
!*** ./src/codecs/windshaft/TimeRange.js ***!
\*******************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return TimeRangeCodec; });
/* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Base */ "./src/codecs/Base.js");
/* harmony import */ var _utils_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/util */ "./src/utils/util.js");
class TimeRangeCodec extends _Base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (metadata, propertyName) {
super(metadata, propertyName);
const stats = metadata.stats(propertyName);
const { min } = stats;
const timeZone = stats.grouping && stats.grouping.timezone;
const timeRange = _utils_util__WEBPACK_IMPORTED_MODULE_1__["timeRange"]({ timeZone, iso: min });
this._min = timeRange.startValue / 1000;
this._timeZone = timeZone;
}
isRange () {
return true;
}
sourceToInternal (metadata, propertyValue) {
const timeRange = _utils_util__WEBPACK_IMPORTED_MODULE_1__["timeRange"]({ iso: propertyValue });
return [timeRange.startValue / 1000, timeRange.endValue / 1000].map(v => (v - this._min));
}
internalToExternal (metadata, [lo, hi]) {
return _utils_util__WEBPACK_IMPORTED_MODULE_1__["timeRange"]({
start: (lo + this._min) * 1000,
end: (hi + this._min) * 1000,
timeZone: this._timeZone
});
}
externalToSource (metadata, v) {
return _utils_util__WEBPACK_IMPORTED_MODULE_1__["castTimeRange"](v, this._timeZone)._iso;
}
sourceToExternal (metadata, v) {
return _utils_util__WEBPACK_IMPORTED_MODULE_1__["timeRange"]({ iso: v, timeZone: this._timeZone });
}
inlineInternalMatch (thisValue, otherCodec) {
const offset = otherCodec._min.getTime() - this._min.getTime();
return `(${thisValue}-${offset.toFixed(20)})`;
}
}
/***/ }),
/***/ "./src/codecs/windshaft/WindshaftDate.js":
/*!***********************************************!*\
!*** ./src/codecs/windshaft/WindshaftDate.js ***!
\***********************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return WindshaftDateCodec; });
/* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Base */ "./src/codecs/Base.js");
/* harmony import */ var _utils_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/util */ "./src/utils/util.js");
class WindshaftDateCodec extends _Base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (metadata, propertyName) {
super(metadata, propertyName);
const { min } = metadata.stats(propertyName);
this._min_ms = min * 1000;
this._min_date = _utils_util__WEBPACK_IMPORTED_MODULE_1__["msToDate"](this._min_ms);
}
sourceToInternal (metadata, propertyValue) {
return _utils_util__WEBPACK_IMPORTED_MODULE_1__["msToDate"](propertyValue * 1000) - this._min_date;
}
internalToExternal (metadata, propertyValue) {
let value = propertyValue;
value += this._min_ms;
return _utils_util__WEBPACK_IMPORTED_MODULE_1__["msToDate"](value);
}
externalToSource (metadata, v) {
return v.getTime() / 1000;
}
sourceToExternal (metadata, v) {
return asDate(v);
}
inlineInternalMatch (thisValue, otherCodec) {
const offset = otherCodec._min_ms - this._min_ms;
return `(${thisValue}-${offset.toFixed(20)})`;
}
}
// convert seconds epoch (source encoding) or Date to Date
function asDate (value) {
if (value instanceof Date) {
return value;
}
return _utils_util__WEBPACK_IMPORTED_MODULE_1__["msToDate"](value * 1000);
}
/***/ }),
/***/ "./src/codecs/windshaft/index.js":
/*!***************************************!*\
!*** ./src/codecs/windshaft/index.js ***!
\***************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return windshaftCodecFactory; });
/* harmony import */ var _Number__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Number */ "./src/codecs/Number.js");
/* harmony import */ var _Category__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Category */ "./src/codecs/Category.js");
/* harmony import */ var _WindshaftDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./WindshaftDate */ "./src/codecs/windshaft/WindshaftDate.js");
/* harmony import */ var _TimeRange__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./TimeRange */ "./src/codecs/windshaft/TimeRange.js");
/* harmony import */ var _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../errors/carto-maps-api-error */ "./src/errors/carto-maps-api-error.js");
function windshaftCodecFactory (metadata, type, propertyName) {
switch (type) {
case 'number':
return new _Number__WEBPACK_IMPORTED_MODULE_0__["default"](metadata, propertyName);
case 'category':
return new _Category__WEBPACK_IMPORTED_MODULE_1__["default"](metadata, propertyName);
case 'date':
return new _WindshaftDate__WEBPACK_IMPORTED_MODULE_2__["default"](metadata, propertyName);
case 'timerange':
return new _TimeRange__WEBPACK_IMPORTED_MODULE_3__["default"](metadata, propertyName);
default:
throw new _errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_4__["default"](
`Windshaft MVT decoding error. Feature property value of type '${type}' cannot be decoded.`,
_errors_carto_maps_api_error__WEBPACK_IMPORTED_MODULE_4__["CartoMapsAPIErrorTypes"].NOT_SUPPORTED);
}
}
/***/ }),
/***/ "./src/constants/layer.js":
/*!********************************!*\
!*** ./src/constants/layer.js ***!
\********************************/
/*! exports provided: RESOLUTION_ZOOMLEVEL_ZERO */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RESOLUTION_ZOOMLEVEL_ZERO", function() { return RESOLUTION_ZOOMLEVEL_ZERO; });
const RESOLUTION_ZOOMLEVEL_ZERO = 512;
/***/ }),
/***/ "./src/constants/metadata.js":
/*!***********************************!*\
!*** ./src/constants/metadata.js ***!
\***********************************/
/*! exports provided: AGG_PREFIX, DIM_PREFIX, CLUSTER_FEATURE_COUNT, aggregationTypes */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AGG_PREFIX", function() { return AGG_PREFIX; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DIM_PREFIX", function() { return DIM_PREFIX; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CLUSTER_FEATURE_COUNT", function() { return CLUSTER_FEATURE_COUNT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "aggregationTypes", function() { return aggregationTypes; });
const AGG_PREFIX = '_cdb_agg_';
const DIM_PREFIX = '_cdb_dim_';
const CLUSTER_FEATURE_COUNT = '_cdb_feature_count';
const aggregationTypes = {
AGGREGATED: 'aggregated',
UNAGGREGATED: 'unaggregated',
UNKNOWN: 'unknown'
};
/***/ }),
/***/ "./src/constants/viz.js":
/*!******************************!*\
!*** ./src/constants/viz.js ***!
\******************************/
/*! exports provided: SUPPORTED_VIZ_PROPERTIES, STYLE_VIZ_PROPERTIES, MIN_RESOLUTION, MAX_RESOLUTION */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SUPPORTED_VIZ_PROPERTIES", function() { return SUPPORTED_VIZ_PROPERTIES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "STYLE_VIZ_PROPERTIES", function() { return STYLE_VIZ_PROPERTIES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MIN_RESOLUTION", function() { return MIN_RESOLUTION; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_RESOLUTION", function() { return MAX_RESOLUTION; });
const SUPPORTED_VIZ_PROPERTIES = [
'color',
'filter',
'order',
'resolution',
'strokeColor',
'strokeWidth',
'symbol',
'symbolPlacement',
'transform',
'width'
];
const STYLE_VIZ_PROPERTIES = [
'color',
'filter',
'order',
'strokeColor',
'strokeWidth',
'symbol',
'symbolPlacement',
'transform',
'width'
];
const MIN_RESOLUTION = 0;
const MAX_RESOLUTION = 256;
/***/ }),
/***/ "./src/errors/carto-error.js":
/*!***********************************!*\
!*** ./src/errors/carto-error.js ***!
\***********************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CartoError; });
/**
* Represents an error in the carto library.
*
* @typedef {Object} CartoError
* @property {String} message - A short error description
* @property {String} name - The name of the error "CartoError"
* @property {String} type - The type of the error "CartoError"
* @property {Object} originalError - An object containing the internal/original error
*
* @event CartoError
* @api
*/
/**
* @namespace CartoErrors
* @api
*
*/
class CartoError extends Error {
/**
* Build a cartoError from a generic error.
* @constructor
*
* @return {CartoError} A well formed object representing the error.
*/
constructor (error) {
if (!error) {
throw Error('Invalid CartoError, a message is mandatory');
}
if (!error.message) {
throw Error('Invalid CartoError, a message is mandatory');
}
if (!error.type) {
throw Error('Invalid CartoError, a type is mandatory');
}
super(`${error.type} ${error.message}`);
this.name = 'CartoError';
this.type = error.type;
this.originalError = error;
}
}
/***/ }),
/***/ "./src/errors/carto-maps-api-error.js":
/*!********************************************!*\
!*** ./src/errors/carto-maps-api-error.js ***!
\********************************************/
/*! exports provided: default, CartoMapsAPIErrorTypes */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CartoMapsAPIError; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CartoMapsAPIErrorTypes", function() { return CartoMapsAPIErrorTypes; });
/* harmony import */ var _carto_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./carto-error */ "./src/errors/carto-error.js");
/**
* Utility to build a cartoError related to MapsAPI errors.
*
* @return {CartoError} A well formed object representing the error.
*/
/**
* CartoMapsAPIError types:
* - [Error]
* - [Not supported]
* - [Security]
*
* @name CartoMapsAPIError
* @memberof CartoError
* @api
*/
class CartoMapsAPIError extends _carto_error__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (message, type = CartoMapsAPIErrorTypes.DEFAULT) {
super({ message, type });
this.name = 'CartoMapsAPIError';
}
}
const CartoMapsAPIErrorTypes = {
DEFAULT: '[Error]',
SQL: '[SQL]',
NOT_SUPPORTED: '[Not supported]',
SECURITY: '[Security]'
};
/***/ }),
/***/ "./src/errors/carto-parsing-error.js":
/*!*******************************************!*\
!*** ./src/errors/carto-parsing-error.js ***!
\*******************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CartoParsingError; });
/* harmony import */ var _carto_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./carto-error */ "./src/errors/carto-error.js");
/**
* Utility to build a cartoError related to Parsing errors.
*
* @return {CartoError} A well formed object representing the error.
*/
/**
* CartoParsingError types:
* - [Error]
*
* @name CartoParsingError
* @memberof CartoError
* @api
*/
class CartoParsingError extends _carto_error__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (message) {
const type = '[Error]';
super({ message, type });
this.name = 'CartoParsingError';
}
}
/***/ }),
/***/ "./src/errors/carto-runtime-error.js":
/*!*******************************************!*\
!*** ./src/errors/carto-runtime-error.js ***!
\*******************************************/
/*! exports provided: default, CartoRuntimeErrorTypes */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CartoRuntimeError; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CartoRuntimeErrorTypes", function() { return CartoRuntimeErrorTypes; });
/* harmony import */ var _carto_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./carto-error */ "./src/errors/carto-error.js");
/**
* Utility to build a cartoError related to Runtime errors.
*
* @return {CartoError} A well formed object representing the error.
*/
/**
* CartoRuntimeError types:
* - [Error]
* - [Not supported]
* - [WebGL]
* - [MVT]
*
* @name CartoRuntimeError
* @memberof CartoError
* @api
*/
class CartoRuntimeError extends _carto_error__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (message, type = CartoRuntimeErrorTypes.DEFAULT) {
super({ message, type });
this.name = 'CartoRuntimeError';
}
}
const CartoRuntimeErrorTypes = {
DEFAULT: '[Error]',
NOT_SUPPORTED: '[Not supported]',
WEB_GL: '[WebGL]',
MVT: '[MVT]'
};
/***/ }),
/***/ "./src/errors/carto-validation-error.js":
/*!**********************************************!*\
!*** ./src/errors/carto-validation-error.js ***!
\**********************************************/
/*! exports provided: default, CartoValidationErrorTypes */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CartoValidationError; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CartoValidationErrorTypes", function() { return CartoValidationErrorTypes; });
/* harmony import */ var _carto_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./carto-error */ "./src/errors/carto-error.js");
/**
* Utility to build a cartoError related to validation errors.
*
* @return {CartoError} A well formed object representing the error.
*/
/**
* CartoValidationError types:
* - [Error]
* - [Missing required property]
* - [Property with an incorrect type]
* - [Incorrect value]
* - [Too many arguments]
* - [Not enough arguments]
* - [Wrong number of arguments]
*
* @name CartoValidationError
* @memberof CartoError
* @api
*/
class CartoValidationError extends _carto_error__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (message, type = CartoValidationErrorTypes.DEFAULT) {
super({ message, type });
this.name = 'CartoValidationError';
}
}
const CartoValidationErrorTypes = {
DEFAULT: '[Error]',
MISSING_REQUIRED: '[Missing required property]',
INCORRECT_TYPE: '[Property with an incorrect type]',
INCORRECT_VALUE: '[Incorrect value]',
TOO_MANY_ARGS: '[Too many arguments]',
NOT_ENOUGH_ARGS: '[Not enough arguments]',
WRONG_NUMBER_ARGS: '[Wrong number of arguments]'
};
/***/ }),
/***/ "./src/index.js":
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
/*! exports provided: version, on, off, isBrowserSupported, unsupportedBrowserReasons, setDefaultAuth, setDefaultConfig, source, expressions, Layer, Viz, Interactivity, basemaps, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "source", function() { return source; });
/* harmony import */ var _setup_auth_service__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./setup/auth-service */ "./src/setup/auth-service.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "setDefaultAuth", function() { return _setup_auth_service__WEBPACK_IMPORTED_MODULE_0__["setDefaultAuth"]; });
/* harmony import */ var _setup_config_service__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./setup/config-service */ "./src/setup/config-service.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "setDefaultConfig", function() { return _setup_config_service__WEBPACK_IMPORTED_MODULE_1__["setDefaultConfig"]; });
/* harmony import */ var _Viz__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Viz */ "./src/Viz.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viz", function() { return _Viz__WEBPACK_IMPORTED_MODULE_2__["default"]; });
/* harmony import */ var _interactivity_Interactivity__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./interactivity/Interactivity */ "./src/interactivity/Interactivity.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Interactivity", function() { return _interactivity_Interactivity__WEBPACK_IMPORTED_MODULE_3__["default"]; });
/* harmony import */ var _Layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Layer */ "./src/Layer.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layer__WEBPACK_IMPORTED_MODULE_4__["default"]; });
/* harmony import */ var _renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./renderer/viz/expressions */ "./src/renderer/viz/expressions.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "expressions", function() { return _renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_5__; });
/* harmony import */ var _sources_Dataset__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./sources/Dataset */ "./src/sources/Dataset.js");
/* harmony import */ var _sources_GeoJSON__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sources/GeoJSON */ "./src/sources/GeoJSON.js");
/* harmony import */ var _sources_MVT__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sources/MVT */ "./src/sources/MVT.js");
/* harmony import */ var _sources_SQL__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./sources/SQL */ "./src/sources/SQL.js");
/* harmony import */ var _utils_events__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./utils/events */ "./src/utils/events.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "on", function() { return _utils_events__WEBPACK_IMPORTED_MODULE_10__["on"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "off", function() { return _utils_events__WEBPACK_IMPORTED_MODULE_10__["off"]; });
/* harmony import */ var _renderer_Renderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./renderer/Renderer */ "./src/renderer/Renderer.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "isBrowserSupported", function() { return _renderer_Renderer__WEBPACK_IMPORTED_MODULE_11__["isBrowserSupported"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "unsupportedBrowserReasons", function() { return _renderer_Renderer__WEBPACK_IMPORTED_MODULE_11__["unsupportedBrowserReasons"]; });
/* harmony import */ var _basemaps__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./basemaps */ "./src/basemaps.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "basemaps", function() { return _basemaps__WEBPACK_IMPORTED_MODULE_12__; });
/* harmony import */ var _package_json__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../package.json */ "./package.json");
var _package_json__WEBPACK_IMPORTED_MODULE_13___namespace = /*#__PURE__*/__webpack_require__.t(/*! ../package.json */ "./package.json", 1);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "version", function() { return _package_json__WEBPACK_IMPORTED_MODULE_13__["version"]; });
/**
* @namespace carto
* @api
*
* @description
* The CARTO VL functionality is exposed through the **carto** namespace including:
*
* Current version:
* - {@link carto.version|carto.version}
*
* Setup:
* - {@link carto.setDefaultAuth|carto.setDefaultAuth}
* - {@link carto.setDefaultConfig|carto.setDefaultConfig}
*
* CARTO Basemaps:
* - {@link carto.basemaps.voyager|carto.basemaps.voyager}
* - {@link carto.basemaps.darkmatter|carto.basemaps.darkmatter}
* - {@link carto.basemaps.positron|carto.basemaps.positron}
*
* Source:
* - {@link carto.source.Dataset|carto.source.Dataset}
* - {@link carto.source.GeoJSON|carto.source.GeoJSON}
* - {@link carto.source.MVT|carto.source.MVT}
* - {@link carto.source.SQL|carto.source.SQL}
*
* Layer:
* - {@link carto.Layer|carto.Layer}
*
* Viz:
* - {@link carto.Viz|carto.Viz}
*
* Expressions:
* - {@link carto.expressions|carto.expressions}
*
* Interactivity:
* - {@link carto.Interactivity|carto.Interactivity}
*/
/**
* @namespace carto.basemaps
* @description Use CARTO basemaps for your map visualization. Here you have more information about our {@link https://carto.com/location-data-services/basemaps/|basemaps}.
* @api
*/
/**
* The version of CARTO VL in use as specified in `package.json` and the GitHub release.
*
* @var {String} version
*
* @memberof carto
* @api
*/
const source = { Dataset: _sources_Dataset__WEBPACK_IMPORTED_MODULE_6__["default"], SQL: _sources_SQL__WEBPACK_IMPORTED_MODULE_9__["default"], GeoJSON: _sources_GeoJSON__WEBPACK_IMPORTED_MODULE_7__["default"], MVT: _sources_MVT__WEBPACK_IMPORTED_MODULE_8__["default"] };
/* harmony default export */ __webpack_exports__["default"] = ({ version: _package_json__WEBPACK_IMPORTED_MODULE_13__["version"], on: _utils_events__WEBPACK_IMPORTED_MODULE_10__["on"], off: _utils_events__WEBPACK_IMPORTED_MODULE_10__["off"], setDefaultAuth: _setup_auth_service__WEBPACK_IMPORTED_MODULE_0__["setDefaultAuth"], setDefaultConfig: _setup_config_service__WEBPACK_IMPORTED_MODULE_1__["setDefaultConfig"], source, expressions: _renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_5__, Layer: _Layer__WEBPACK_IMPORTED_MODULE_4__["default"], Viz: _Viz__WEBPACK_IMPORTED_MODULE_2__["default"], Interactivity: _interactivity_Interactivity__WEBPACK_IMPORTED_MODULE_3__["default"], basemaps: _basemaps__WEBPACK_IMPORTED_MODULE_12__ });
/***/ }),
/***/ "./src/interactivity/Interactivity.js":
/*!********************************************!*\
!*** ./src/interactivity/Interactivity.js ***!
\********************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Interactivity; });
/* harmony import */ var mitt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! mitt */ "./node_modules/mitt/dist/mitt.es.js");
/* harmony import */ var _Layer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Layer */ "./src/Layer.js");
/* harmony import */ var _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../errors/carto-validation-error */ "./src/errors/carto-validation-error.js");
const EVENTS = [
'featureClick',
'featureClickOut',
'featureEnter',
'featureHover',
'featureLeave'
];
const MAP_STATE = {
IDLE: 'idle',
MOVING: 'moving'
};
class Interactivity {
/**
*
* Interactivity purpose is to allow the reception and management of user-generated events, like clicking, over layer features.
*
* To create a Interactivity object a {@link carto.Layer} or an array with several {@link carto.Layer} is required.
* Events fired from interactivity objects will refer to the features of these layer/s and only these layer/s.
* Moreover, when using an array of layers, the order of the features in the events will be determined by the order of these layers in the layerList.
*
* @param {carto.Layer|carto.Layer[]} layerList - {@link carto.Layer} or array of {@link carto.Layer}, events will be fired based on the features of these layers. The array cannot be empty, and all the layers must be attached to the same map.
* @param {Object} [options={}] - Object containing interactivity options
* @param {boolean} [options.autoChangePointer=true] - A boolean flag indicating if the cursor should change when the mouse is over a feature.
*
* @example
* const interactivity = new carto.Interactivity(layer);
* interactivity.on('click', event => {
* style(event.features);
* show(event.coordinates);
* });
*
* @fires featureClick
* @fires featureClickOut
* @fires featureHover
* @fires featureEnter
* @fires featureLeave
* @throws CartoError
*
* @constructor Interactivity
* @name carto.Interactivity
* @api
*/
constructor (layerList, options = { autoChangePointer: true }) {
if (layerList instanceof _Layer__WEBPACK_IMPORTED_MODULE_1__["default"]) {
layerList = [layerList]; // Allow one layer as input
}
preCheckLayerList(layerList);
this._init(layerList, options);
}
/**
* Register an event handler for the given type.
*
* @param {String} eventName - Type of event to listen for
* @param {function} callback - Function to call in response to given event, function will be called with a {@link carto.FeatureEvent}
* @memberof carto.Interactivity
* @instance
* @api
*/
on (eventName, callback) {
checkEvent(eventName);
const currentCount = this._numListeners[eventName] || 0;
this._numListeners[eventName] = currentCount + 1;
return this._emitter.on(eventName, callback);
}
/**
* Remove an event handler for the given type.
*
* @param {String} eventName - Type of event to unregister
* @param {function} callback - Handler function to unregister
* @memberof carto.Interactivity
* @instance
* @api
*/
off (eventName, callback) {
checkEvent(eventName);
const currentCount = this._numListeners[eventName];
this._numListeners[eventName] = currentCount - 1;
return this._emitter.off(eventName, callback);
}
/**
* Interactivity enabled property. When enabled, it can emit events
*
* @type {boolean}
* @memberof carto.Interactivity
* @instance
* @api
*/
get isEnabled () {
return this._enabled && this._mapState !== MAP_STATE.MOVING;
}
/**
* Change interactivity state to disabled, so no event will be emitted
*
* @memberof carto.Interactivity
* @instance
* @api
*/
disable () {
this._enabled = false;
}
/**
* Change interactivity state to enabled, so events can be emitted
*
* @memberof carto.Interactivity
* @instance
* @api
*/
enable () {
this._enabled = true;
}
_init (layerList, options) {
this._enabled = true;
this._mapState = MAP_STATE.IDLE;
this._emitter = Object(mitt__WEBPACK_IMPORTED_MODULE_0__["default"])();
this._layerList = layerList;
this._prevHoverFeatures = [];
this._prevClickFeatures = [];
this._numListeners = {};
this._isAutoChangePointerEnabled = options.autoChangePointer;
const allLayersReadyPromises = layerList.map(layer => layer._context);
return Promise.all(allLayersReadyPromises)
.then(() => {
postCheckLayerList(layerList);
this._map = layerList[0].map;
this._subscribeToLayerEvents(layerList);
this._subscribeToMapEvents(this._map);
if (this._isAutoChangePointerEnabled) {
this._setInteractiveCursor();
}
});
}
_setInteractiveCursor () {
if (!this._map.__carto_interactivities) {
this._map.__carto_interactivities = new Set();
}
this.on('featureHover', event => this._onFeatureHover(event, this._map));
}
_onFeatureHover (event, map) {
if (event.features.length) {
map.__carto_interactivities.add(this);
} else {
map.__carto_interactivities.delete(this);
}
map.getCanvas().style.cursor = (map.__carto_interactivities.size > 0) ? 'pointer' : '';
}
_subscribeToMapEvents (map) {
this._onMouseMoveBound = this._onMouseMove.bind(this);
map.on('mousemove', this._onMouseMoveBound);
this._onClickBound = this._onClick.bind(this);
map.on('click', this._onClickBound);
this._disableWhileMovingMap(map);
}
_unsubscribeToMapEvents (map) {
map.off('mousemove', this._onMouseMoveBound);
map.off('click', this._onClickBound);
}
_disableWhileMovingMap (map) {
map.on('movestart', () => {
this._setMapState(MAP_STATE.MOVING);
});
map.on('moveend', () => {
this._setMapState(MAP_STATE.IDLE);
});
}
_setMapState (state) {
this._mapState = state;
}
_subscribeToLayerEvents (layers) {
layers.forEach(layer => {
layer.on('updated', this._onLayerUpdated.bind(this));
layer.on('removed', this._onLayerRemoved.bind(this));
});
}
_onLayerUpdated () {
this._onMouseMove(this._mouseEvent, true);
}
_onLayerRemoved (layer) {
this._removeLayerFromInteractivity(layer);
if (this._isAutoChangePointerEnabled) {
this._onFeatureHover({ features: [] }, this._map);
}
if (!this._layerList.length) {
this._unsubscribeToMapEvents(this._map);
}
}
_removeLayerFromInteractivity (layer) {
const layerIndex = this._layerList.indexOf(layer);
if (layerIndex === -1) {
return;
}
this._layerList.splice(layerIndex, 1);
}
_onMouseMove (event, emulated) {
// Store mouse event to be used in `onLayerUpdated`
this._mouseEvent = event;
if (!this.isEnabled) {
return;
}
if (!event ||
(!this._numListeners['featureEnter'] &&
!this._numListeners['featureHover'] &&
!this._numListeners['featureLeave'])) {
return;
}
const featureEvent = this._createFeatureEvent(event);
const featuresLeft = this._manageFeatureLeaveEvent(featureEvent);
const featuresEntered = this._manageFeatureEnterEvent(featureEvent);
this._prevHoverFeatures = featureEvent.features;
this._manageFeatureHoverEvent(featureEvent, { featuresLeft, featuresEntered }, emulated);
}
_manageFeatureLeaveEvent (featureEvent) {
const featuresLeft = this._getDiffFeatures(this._prevHoverFeatures, featureEvent.features);
this._fireEventIfFeatures('featureLeave', { featureEvent, eventFeatures: featuresLeft });
return featuresLeft;
}
_manageFeatureEnterEvent (featureEvent) {
const featuresEntered = this._getDiffFeatures(featureEvent.features, this._prevHoverFeatures);
this._fireEventIfFeatures('featureEnter', { featureEvent, eventFeatures: featuresEntered });
return featuresEntered;
}
_manageFeatureHoverEvent (featureEvent, { featuresLeft, featuresEntered }, emulated) {
// If the event comes from a real mouse move, trigger always (because coordinates and position have changed)
// If the event comes from an animated event, trigger only when features have changed (because position is the same)
if (!emulated || (emulated && (featuresLeft.length || featuresEntered.length))) {
// Launch hover event
this._fireEvent('featureHover', featureEvent);
}
}
_fireEventIfFeatures (eventName, { featureEvent, eventFeatures }) {
if (eventFeatures.length > 0) {
this._fireEvent(eventName, {
coordinates: featureEvent.coordinates,
position: featureEvent.position,
features: eventFeatures
});
}
}
_onClick (event) {
if (!this.isEnabled) {
return;
}
if (!this._numListeners['featureClick'] &&
!this._numListeners['featureClickOut']) {
return;
}
const featureEvent = this._createFeatureEvent(event);
this._manageClickOutEvent(featureEvent);
this._prevClickFeatures = featureEvent.features;
// Launch click event
this._fireEvent('featureClick', featureEvent);
}
_manageClickOutEvent (featureEvent) {
const featuresClickedOut = this._getDiffFeatures(this._prevClickFeatures, featureEvent.features);
this._fireEventIfFeatures('featureClickOut', { featureEvent, eventFeatures: featuresClickedOut });
return featuresClickedOut;
}
_createFeatureEvent (eventData) {
// a potentially very intensive task
const features = this._getFeaturesAtPosition(eventData.point);
return {
coordinates: eventData.lngLat,
position: eventData.point,
features
};
}
_fireEvent (type, featureEvent) {
this._emitter.emit(type, featureEvent);
}
_getFeaturesAtPosition (point) {
return [].concat(...this._layerList.map(layer => layer.getFeaturesAtPosition(point)));
}
/**
* Return the difference between the feature arrays A and B.
* The output value is also an array of features.
*/
_getDiffFeatures (featuresA, featuresB) {
const IDs = this._getFeatureIDs(featuresB);
return featuresA.filter(feature => !IDs.includes(feature.id));
}
_getFeatureIDs (features) {
return features.map(feature => feature.id);
}
}
function preCheckLayerList (layerList) {
if (!Array.isArray(layerList)) {
throw new _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__["default"](
'Invalid layer list, parameter must be an array of "carto.Layer" objects.',
_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__["CartoValidationErrorTypes"].INCORRECT_TYPE
);
}
if (!layerList.length) {
throw new _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__["default"](
'Invalid argument, layer list must not be empty.',
_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__["CartoValidationErrorTypes"].INCORRECT_VALUE
);
}
if (!layerList.every(layer => layer instanceof _Layer__WEBPACK_IMPORTED_MODULE_1__["default"])) {
throw new _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__["default"](
'Invalid layer, layer must be an instance of "carto.Layer".',
_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__["CartoValidationErrorTypes"].INCORRECT_TYPE
);
}
}
function postCheckLayerList (layerList) {
if (!layerList.every(layer => layer.map === layerList[0].map)) {
throw new _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__["default"](
'Invalid argument, all layers must belong to the same map.',
_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__["CartoValidationErrorTypes"].INCORRECT_VALUE
);
}
}
function checkEvent (eventName) {
if (!EVENTS.includes(eventName)) {
throw new _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__["default"](
`Unrecognized event: '${eventName}'. Available events: ${EVENTS.join(', ')}.`,
_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__["CartoValidationErrorTypes"].INCORRECT_VALUE
);
}
}
/***/ }),
/***/ "./src/interactivity/blendUtils.js":
/*!*****************************************!*\
!*** ./src/interactivity/blendUtils.js ***!
\*****************************************/
/*! exports provided: generateResetFunction, generateBlenderFunction */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "generateResetFunction", function() { return generateResetFunction; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "generateBlenderFunction", function() { return generateBlenderFunction; });
/* harmony import */ var _renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../renderer/viz/expressions */ "./src/renderer/viz/expressions.js");
function generateResetFunction (propertyName, id, customizedFeatures, viz, idProperty) {
return function reset (duration = 500) {
if (customizedFeatures[id] && customizedFeatures[id][propertyName]) {
customizedFeatures[id][propertyName].replaceChild(
customizedFeatures[id][propertyName].mix,
// transition(0) is used to ensure that blend._predraw() "GC" collects it
Object(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_0__["blend"])(Object(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_0__["notEquals"])(Object(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_0__["property"])(idProperty), id), Object(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_0__["transition"])(0), Object(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_0__["transition"])(duration))
);
viz[propertyName].notify();
customizedFeatures[id][propertyName] = undefined;
}
};
}
function generateBlenderFunction (propertyName, id, customizedFeatures, viz, trackFeatureViz, idProperty, parseVizExpression) {
return function generatedBlendTo (newExpression, duration = 500) {
if (typeof newExpression === 'string') {
newExpression = parseVizExpression(newExpression);
}
if (customizedFeatures[id] && customizedFeatures[id][propertyName]) {
customizedFeatures[id][propertyName].a.blendTo(newExpression, duration);
return;
}
const blendExpr = Object(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_0__["blend"])(
newExpression,
viz[propertyName],
Object(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_0__["blend"])(1, Object(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_0__["notEquals"])(Object(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_0__["property"])(idProperty), id), Object(_renderer_viz_expressions__WEBPACK_IMPORTED_MODULE_0__["transition"])(duration))
);
trackFeatureViz(id, propertyName, blendExpr, customizedFeatures);
viz.replaceChild(
viz[propertyName],
blendExpr
);
viz[propertyName].notify();
};
}
/***/ }),
/***/ "./src/interactivity/commonFeature.js":
/*!********************************************!*\
!*** ./src/interactivity/commonFeature.js ***!
\********************************************/
/*! exports provided: getCompoundFeature */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getCompoundFeature", function() { return getCompoundFeature; });
function _getGeomPropertiesFromPieces (pieces) {
const geomPropertiesFromPieces = pieces.map(piece => {
const [x, y] = piece.getRenderedCentroid();
const aabb = piece._rawFeature._dataframe._aabb[piece._rawFeature._index];
return { centroid: { x, y }, aabb };
});
const geomProperties = geomPropertiesFromPieces.filter(piece => {
const { x, y } = piece.centroid;
return !(isNaN(x) || isNaN(y));
});
return geomProperties;
}
/**
* Get a 'compound Feature'. It is a Feature created from a set of 'feature' pieces
* @param {Array} featurePieces
*/
function getCompoundFeature (featurePieces) {
const exemplar = featurePieces[0];
if (featurePieces.length === 1) return exemplar;
const geomProperties = _getGeomPropertiesFromPieces(featurePieces);
Object.defineProperty(exemplar, 'getRenderedCentroid', {
get: function () {
const getRenderedCentroid = () => {
// average of centroids ponderated by aabb size
const [weightedXs, weightedYs, totalSize] = geomProperties.reduce((accumulator, currentValue) => {
const { minx, miny, maxx, maxy } = currentValue.aabb;
const size = (maxx - minx) * (maxy - miny);
const pX = currentValue.centroid.x * size;
const pY = currentValue.centroid.y * size;
return [accumulator[0] + pX, accumulator[1] + pY, accumulator[2] + size];
}, [0, 0, 0]);
return [weightedXs / totalSize, weightedYs / totalSize];
};
return getRenderedCentroid;
}
});
return exemplar;
}
/***/ }),
/***/ "./src/interactivity/feature.js":
/*!**************************************!*\
!*** ./src/interactivity/feature.js ***!
\**************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Feature; });
/* harmony import */ var _featureVizProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./featureVizProperty */ "./src/interactivity/featureVizProperty.js");
/* harmony import */ var _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../errors/carto-validation-error */ "./src/errors/carto-validation-error.js");
/* harmony import */ var _constants_viz__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../constants/viz */ "./src/constants/viz.js");
/**
* @namespace Features
* @description CARTO VL Features are objects that contain information of the visualization.
* @api
*/
/**
*
* FeatureEvent objects are fired by {@link carto.Interactivity|Interactivity} objects.
*
* @typedef {Object} FeatureEvent
* @property {Object} coordinates - LongLat coordinates in { lng, lat } form
* @property {Object} position - Pixel coordinates in { x, y } form
* @property {Feature[]} features - Array of {@link Feature}
* @api
*/
/**
* featureClick events are fired when the user clicks on features. The list of features behind the cursor is provided.
*
* @event featureClick
* @type {FeatureEvent}
* @api
*/
/**
* featureClickOut events are fired when the user clicks outside a feature that was clicked in the last featureClick event.
* The list of features that were clicked before and that are no longer behind this new click is provided.
*
* @event featureClickOut
* @type {FeatureEvent}
* @api
*/
/**
* featureEnter events are fired when the user moves the cursor and the movement implies that a non-previously hovered feature (as reported by featureHover or featureLeave) is now under the cursor.
* The list of features that are now behind the cursor and that weren't before is provided.
*
* @event featureEnter
* @type {FeatureEvent}
* @api
*/
/**
* featureHover events are fired when the user moves the cursor.
* The list of features behind the cursor is provided.
*
* @event featureHover
* @type {FeatureEvent}
* @api
*/
/**
* featureLeave events are fired when the user moves the cursor and the movement implies that a previously hovered feature (as reported by featureHover or featureEnter) is no longer behind the cursor.
* The list of features that are no longer behind the cursor and that were before is provided.
*
* @event featureLeave
* @type {FeatureEvent}
* @api
*/
/**
*
* Feature objects are provided by {@link FeatureEvent} events.
*
* @constructor Feature
* @typedef {Object} Feature
* @property {number} id - Unique identification code
* @property {FeatureVizProperty} color
* @property {FeatureVizProperty} filter
* @property {FeatureVizProperty} order
* @property {FeatureVizProperty} resolution
* @property {FeatureVizProperty} strokeColor
* @property {FeatureVizProperty} strokeWidth
* @property {FeatureVizProperty} symbol
* @property {FeatureVizProperty} symbolPlacement
* @property {FeatureVizProperty} transform
* @property {FeatureVizProperty} width
* @property {FeatureVizProperty[]} variables - Declared variables in the viz object
* @property {function} blendTo - Blend custom feature vizs by fading in `duration` milliseconds
* @property {function} reset - Reset custom feature vizs by fading out `duration` milliseconds, where `duration` is the first parameter to reset
* @property {function} getRenderedCentroid - Get centroid from the displayed geometry as [longitude, latitude]. When using lines and polygons in a MVT source, it can be different from canonical feature's centroid (it can be the centroid from just some client-side pieces). Useful for labeling.
* @api
*/
class Feature {
constructor (rawFeature, { viz, customizedFeatures, trackFeatureViz, idProperty }, publicFeatureProperties = []) {
this.id = rawFeature[idProperty];
this._rawFeature = rawFeature;
this._featureVizParams = { rawFeature, viz, customizedFeatures, trackFeatureViz, idProperty };
this._defineVizProperties();
this._defineVizVariables();
this._defineFeatureProperties(publicFeatureProperties);
}
_defineVizProperties () {
_constants_viz__WEBPACK_IMPORTED_MODULE_2__["SUPPORTED_VIZ_PROPERTIES"].forEach((property) => {
this[property] = this._buildFeatureVizProperty(property);
});
}
_buildFeatureVizProperty (name) {
const { rawFeature, viz, customizedFeatures, trackFeatureViz, idProperty } = this._featureVizParams;
return new _featureVizProperty__WEBPACK_IMPORTED_MODULE_0__["default"](name, rawFeature, viz, customizedFeatures, trackFeatureViz, idProperty);
}
_defineVizVariables () {
const variables = {};
const vizVariables = this._featureVizParams.viz.variables;
Object.keys(vizVariables).forEach(varName => {
const name = `__cartovl_variable_${varName}`;
variables[varName] = this._buildFeatureVizProperty(name);
});
this.variables = variables;
}
_defineFeatureProperties (featurePropertyNames) {
featurePropertyNames.forEach(prop => {
Object.defineProperty(this, prop, {
get: function () {
return this._rawFeature[prop];
}
});
});
}
blendTo (newVizProperties, duration = 500) {
Object.keys(newVizProperties).forEach((property) => {
if (!(_constants_viz__WEBPACK_IMPORTED_MODULE_2__["SUPPORTED_VIZ_PROPERTIES"].includes(property))) {
throw new _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_1__["default"](
`Property '${property}' is not a valid viz property`,
_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_1__["CartoValidationErrorTypes"].INCORRECT_VALUE
);
}
const newValue = newVizProperties[property];
this[property].blendTo(newValue, duration);
});
}
reset (duration = 500) {
_constants_viz__WEBPACK_IMPORTED_MODULE_2__["SUPPORTED_VIZ_PROPERTIES"].forEach((property) => {
this[property].reset(duration);
});
for (let key in this.variables) {
this.variables[key].reset(duration);
}
}
getRenderedCentroid () {
return this._rawFeature._dataframe.getRenderedCentroid(this._rawFeature._index);
}
}
/***/ }),
/***/ "./src/interactivity/featureVizProperty.js":
/*!*************************************************!*\
!*** ./src/interactivity/featureVizProperty.js ***!
\*************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return FeatureVizProperty; });
/* harmony import */ var _blendUtils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./blendUtils */ "./src/interactivity/blendUtils.js");
/* harmony import */ var _renderer_viz_parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../renderer/viz/parser */ "./src/renderer/viz/parser.js");
/**
*
* FeatureVizProperty objects can be accessed through {@link Feature} objects.
*
* @typedef {Object} FeatureVizProperty
* @property {function} blendTo - Change the feature viz by blending to a destination viz expression `expr` in `duration` milliseconds, where `expr` is the first parameter and `duration` the last one
* @property {function} reset - Reset custom feature viz property by fading out `duration` milliseconds, where `duration` is the first parameter to reset
* @property {function} value - Getter that evaluates the property and returns the computed value
* @api
*/
class FeatureVizProperty {
constructor (propertyName, feature, viz, customizedFeatures, trackFeatureViz, idProperty) {
this._propertyName = propertyName;
this._properties = feature;
this._viz = viz;
this.blendTo = Object(_blendUtils__WEBPACK_IMPORTED_MODULE_0__["generateBlenderFunction"])(propertyName, feature[idProperty], customizedFeatures, viz, trackFeatureViz, idProperty, _renderer_viz_parser__WEBPACK_IMPORTED_MODULE_1__["parseVizExpression"]);
this.reset = Object(_blendUtils__WEBPACK_IMPORTED_MODULE_0__["generateResetFunction"])(propertyName, feature[idProperty], customizedFeatures, viz, idProperty);
}
get value () {
return this._viz[this._propertyName].eval(this._properties);
}
eval (...properties) {
const props = [];
properties.forEach((property) => {
const prop = {};
prop[property] = this._properties[property];
props.push(prop);
});
return this._viz[this._propertyName].eval(props);
}
}
/***/ }),
/***/ "./src/interactivity/lightweightFeature.js":
/*!*************************************************!*\
!*** ./src/interactivity/lightweightFeature.js ***!
\*************************************************/
/*! exports provided: genLightweightFeatureClass */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "genLightweightFeatureClass", function() { return genLightweightFeatureClass; });
/* harmony import */ var _blendUtils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./blendUtils */ "./src/interactivity/blendUtils.js");
/* harmony import */ var _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../errors/carto-validation-error */ "./src/errors/carto-validation-error.js");
/* harmony import */ var _constants_viz__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../constants/viz */ "./src/constants/viz.js");
/**
* Generate a lightweight Feature-like class
* Its main purpouse is to define a light class to improve performance when creating a
* high number of features (see `viewportFeatures`)
*
* @param {*} propertyNames
* @param {*} renderLayer
* @returns FeatureLike class
*/
function genLightweightFeatureClass (propertyNames, renderLayer) {
const cls = class LightweightFeature {
constructor (rawFeature) {
this._rawFeature = rawFeature;
this._featureProperties = null;
}
};
_defineIdProperty(cls.prototype, renderLayer);
_defineVizProperties(cls.prototype, renderLayer);
_defineVizVariables(cls.prototype, renderLayer);
_defineFeatureProperties(cls.prototype, propertyNames);
_defineRootBlendToMethod(cls.prototype);
_defineRootResetMethod(cls.prototype);
_defineGetRenderedCentroidMethod(cls.prototype);
return cls;
}
function _defineIdProperty (targetObject, renderLayer) {
Object.defineProperty(targetObject, 'id', {
get: function () {
const idProperty = renderLayer.viz.metadata.idProperty;
return this._rawFeature[idProperty];
},
configurable: true
});
}
function _defineVizProperties (targetObject, renderLayer) {
_constants_viz__WEBPACK_IMPORTED_MODULE_2__["SUPPORTED_VIZ_PROPERTIES"].forEach(property => {
_createLightweightFeatureVizProperty(targetObject, renderLayer, property);
});
}
function _createLightweightFeatureVizProperty (targetObject, renderLayer, prop, propName = prop) {
const { customizedFeatures, viz, trackFeatureViz, parseVizExpression } = renderLayer;
const idProperty = viz.metadata.idProperty;
const blender = (featureId) => {
return Object(_blendUtils__WEBPACK_IMPORTED_MODULE_0__["generateBlenderFunction"])(prop, featureId, customizedFeatures, viz, trackFeatureViz, idProperty, parseVizExpression);
};
const reset = (featureId) => {
return Object(_blendUtils__WEBPACK_IMPORTED_MODULE_0__["generateResetFunction"])(prop, featureId, customizedFeatures, viz, idProperty);
};
Object.defineProperty(targetObject, propName, {
get: function () {
return {
blendTo: (...args) => {
return blender(this.id)(...args);
},
reset: (...args) => {
return reset(this.id)(...args);
},
value: viz[prop].eval(this._rawFeature)
};
}
});
}
function _defineVizVariables (targetObject, renderLayer) {
Object.defineProperty(targetObject, 'variables', {
get: function () {
const variables = {};
// To allow the use of this.id in `_createLightweightFeatureVizProperty`
Object.defineProperty(variables, 'id', {
get: function () { return this.id; }
});
// viz variables
const vizVariables = renderLayer.viz.variables;
Object.keys(vizVariables).forEach(varName => {
const name = `__cartovl_variable_${varName}`;
_createLightweightFeatureVizProperty(variables, renderLayer, name, varName);
});
return variables;
}
});
}
function _defineFeatureProperties (targetObject, propertyNames) {
Object.defineProperty(targetObject, 'properties', {
get: function () {
if (this._featureProperties === null) {
this._featureProperties = {};
propertyNames.forEach(({ property, variable }) => {
const propertyName = variable || property;
this._featureProperties[propertyName] = this._rawFeature[property];
});
}
return this._featureProperties;
}
});
}
function _defineRootBlendToMethod (targetObject) {
Object.defineProperty(targetObject, 'blendTo', {
get: function () {
const blendTo = (newVizProperties, duration = 500) => {
Object.keys(newVizProperties).forEach((property) => {
if (!(_constants_viz__WEBPACK_IMPORTED_MODULE_2__["SUPPORTED_VIZ_PROPERTIES"].includes(property))) {
throw new _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_1__["default"](
`Property '${property}' is not a valid viz property`,
_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_1__["CartoValidationErrorTypes"].INCORRECT_VALUE
);
}
const newValue = newVizProperties[property];
this[property].blendTo(newValue, duration);
});
};
return blendTo;
}
});
}
function _defineRootResetMethod (targetObject) {
Object.defineProperty(targetObject, 'reset', {
get: function () {
const reset = (duration = 500) => {
_constants_viz__WEBPACK_IMPORTED_MODULE_2__["SUPPORTED_VIZ_PROPERTIES"].forEach((property) => {
this[property].reset(duration);
});
for (let key in this.variables) {
this.variables[key].reset(duration);
}
};
return reset;
}
});
}
function _defineGetRenderedCentroidMethod (targetObject) {
Object.defineProperty(targetObject, 'getRenderedCentroid', {
get: function () {
const getRenderedCentroid = () => {
return this._rawFeature._dataframe.getRenderedCentroid(this._rawFeature._index);
};
return getRenderedCentroid;
},
configurable: true
});
}
/***/ }),
/***/ "./src/renderer/Metadata.js":
/*!**********************************!*\
!*** ./src/renderer/Metadata.js ***!
\**********************************/
/*! exports provided: DEFAULT_ID_PROPERTY, IDENTITY, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_ID_PROPERTY", function() { return DEFAULT_ID_PROPERTY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IDENTITY", function() { return IDENTITY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Metadata; });
/* harmony import */ var _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors/carto-runtime-error */ "./src/errors/carto-runtime-error.js");
/* harmony import */ var _codecs_Identity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../codecs/Identity */ "./src/codecs/Identity.js");
/* harmony import */ var _viz_expressions_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./viz/expressions/constants */ "./src/renderer/viz/expressions/constants.js");
const DEFAULT_MVT_EXTENT = 4096;
const DEFAULT_ID_PROPERTY = 'cartodb_id';
// The IDENTITY metadata contains zero properties
const IDENTITY = {
properties: {}
};
class Metadata {
constructor ({ properties, featureCount, sample, geomType, isAggregated, idProperty, extent } = { properties: {} }) {
this.properties = properties;
this.featureCount = featureCount;
this.sample = sample;
this.geomType = geomType;
this.isAggregated = isAggregated;
this.idProperty = idProperty || DEFAULT_ID_PROPERTY;
if (!this.properties.hasOwnProperty(this.idProperty)) {
this.properties[this.idProperty] = { type: 'number' };
}
this.categoryToID = new Map();
this.IDToCategory = new Map();
this.numCategories = 0;
this.extent = extent || DEFAULT_MVT_EXTENT;
Object.values(properties).map(property => {
property.categories = property.categories || [];
property.categories.map(category => this.categorizeString(property, category.name, true));
});
this.propertyKeys = Object.keys(properties);
}
setCodecs () {
throw new _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_0__["default"]('You must call "setCodecs" once you have determined the proper subclass');
}
categorizeString (propertyName, category, init = false) {
if (category === undefined) {
category = null;
}
if (this.categoryToID.has(category)) {
return this.categoryToID.get(category);
}
if (!init && category !== null) {
this.properties[propertyName].categories.push({
name: category,
frequency: Number.NaN
});
}
const categoryId = category === null ? _viz_expressions_constants__WEBPACK_IMPORTED_MODULE_2__["FP32_DESIGNATED_NULL_VALUE"] : this.numCategories;
this.categoryToID.set(category, categoryId);
this.IDToCategory.set(categoryId, category);
this.numCategories++;
return categoryId;
}
// dataframe properties into which a single source property is decoded
// TODO: rename as encodedProperties or dataframeProperties
decodedProperties (propertyName) {
return [propertyName];
}
// property of the data origin (dataset, query) from which
// a (source or dataframe) property is derived
baseName (propertyName) {
return propertyName;
}
// property transferred from the source from which
// a (source or dataframe) property it so be computed
// TODO: move to windshaft metadata
sourcePropertyName (propertyName) {
return propertyName;
}
stats (propertyName) {
return this.properties[propertyName];
}
codec (propertyName) {
const name = this.baseName(propertyName);
return this.properties[name] && this.properties[name].codec
? this.properties[name].codec
: new _codecs_Identity__WEBPACK_IMPORTED_MODULE_1__["default"]();
}
}
/***/ }),
/***/ "./src/renderer/RenderLayer.js":
/*!*************************************!*\
!*** ./src/renderer/RenderLayer.js ***!
\*************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return RenderLayer; });
/* harmony import */ var _interactivity_feature__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../interactivity/feature */ "./src/interactivity/feature.js");
/* harmony import */ var _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../errors/carto-validation-error */ "./src/errors/carto-validation-error.js");
/* harmony import */ var _utils_geometry__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/geometry */ "./src/utils/geometry.js");
/* harmony import */ var _interactivity_commonFeature__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../interactivity/commonFeature */ "./src/interactivity/commonFeature.js");
class RenderLayer {
constructor () {
this.dataframes = [];
this.renderer = null;
this.viz = null;
this.type = null;
this.customizedFeatures = {};
this.idProperty = null;
}
// Performance-intensive. The required allocation and copy of resources will happen synchronously.
// To achieve good performance, avoid multiple calls within the same event, particularly with large dataframes.
addDataframe (dataframe) {
if (this.type) {
this._checkDataframeType(dataframe);
}
this.type = dataframe.type;
if (this.renderer) {
dataframe.bindRenderer(this.renderer);
}
this.dataframes.push(dataframe);
this.idProperty = dataframe.metadata.idProperty;
}
setRenderer (renderer) {
this.renderer = renderer;
this.dataframes.forEach(d => d.bindRenderer(renderer));
}
setViz (viz) {
this.viz = viz;
}
getActiveDataframes () {
this.dataframes = this.dataframes.filter(df => !df.freed);
let active = this.dataframes.filter(df => df.active && df.numVertex);
if (active.length && active[0].orderID !== undefined) {
active = active.sort((a, b) => a.orderID - b.orderID);
}
return active;
}
hasDataframes () {
return this.getActiveDataframes().length > 0;
}
getNumFeatures () {
return this.getActiveDataframes().map(d => d.numFeatures).reduce((x, y) => x + y, 0);
}
_checkDataframeType (dataframe) {
if (this.type !== dataframe.type) {
throw new _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_1__["default"](
'Layer dataframes must always be of the same type',
_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_1__["CartoValidationErrorTypes"].INCORRECT_TYPE
);
}
}
getFeaturesAtPosition (pos) {
if (!this.viz) {
return [];
}
const noPossiblePartialFeatures = (this.viz.geometryType === _utils_geometry__WEBPACK_IMPORTED_MODULE_2__["GEOMETRY_TYPE"].POINT);
if (noPossiblePartialFeatures) {
return this._getPointFeaturesAtPosition(pos);
} else {
return this._getPartialFeaturesAtPosition(pos);
}
}
_getPointFeaturesAtPosition (pos) {
const rawFeatures = this._getRawFeaturesAtPosition(pos);
return rawFeatures.map((raw) => { return this._buildFeatureFromRaw(raw); });
}
_buildFeatureFromRaw (rawFeature) {
const { viz, customizedFeatures, trackFeatureViz, idProperty } = this;
const featureVizParams = { viz, customizedFeatures, trackFeatureViz, idProperty };
return new _interactivity_feature__WEBPACK_IMPORTED_MODULE_0__["default"](rawFeature, featureVizParams);
}
_getRawFeaturesAtPosition (pos) {
const rawFeatures = [].concat(...this.getActiveDataframes().map(df =>
df.getFeaturesAtPosition(pos, this.viz)
));
return rawFeatures;
}
_getPartialFeaturesAtPosition (pos) {
const rawFeatures = this._getRawFeaturesAtPosition(pos);
if (rawFeatures.length === 0) return [];
const rawPartialFeatures = this._getPartialFeaturesFromSingle(rawFeatures);
const compoundFeatures = this._getCompoundFeaturesFrom(rawPartialFeatures);
return compoundFeatures;
}
_getCompoundFeaturesFrom (rawPartialFeatures) {
const features = [];
for (let featureId in rawPartialFeatures) {
const viewporFeaturePieces = rawPartialFeatures[featureId];
const featurePieces = viewporFeaturePieces.map((raw) => { return this._buildFeatureFromRaw(raw); });
features.push(Object(_interactivity_commonFeature__WEBPACK_IMPORTED_MODULE_3__["getCompoundFeature"])(featurePieces));
}
return features;
}
/**
* Get all the pieces from rawFeatures.
* Returns an Object, where each key includes an array with (potentially) several feature pieces
*/
_getPartialFeaturesFromSingle (rawFeatures) {
const featuresIds = new Set(rawFeatures.map(raw => raw[this.idProperty]));
return this.getAllPiecesPerFeature(featuresIds);
}
/**
* Gather all feature pieces in the dataframes
*/
getAllPiecesPerFeature (featureIds) {
const piecesPerFeature = {};
featureIds.forEach((featureId) => { piecesPerFeature[featureId] = []; });
const dataframes = this.getActiveDataframes();
dataframes.forEach(dataframe => {
this._addPartialFeaturesIfExistIn(dataframe, featureIds, piecesPerFeature);
});
return piecesPerFeature;
}
/**
* Add all the feature pieces, with selected featureIds, if present in the dataframe.
*/
_addPartialFeaturesIfExistIn (dataframe, featureIds, result) {
for (let i = 0; i < dataframe.numFeatures; i++) {
const feature = dataframe.getFeature(i);
const currentFeatureId = feature[this.idProperty];
if (featureIds.has(currentFeatureId)) {
const pieces = result[currentFeatureId];
pieces.push(feature);
}
}
}
trackFeatureViz (featureID, vizProperty, newViz, customizedFeatures) {
customizedFeatures[featureID] = customizedFeatures[featureID] || {};
customizedFeatures[featureID][vizProperty] = newViz;
}
freeDataframes () {
this.dataframes.map(df => df.free());
this.dataframes = [];
this.type = null;
}
}
/***/ }),
/***/ "./src/renderer/Renderer.js":
/*!**********************************!*\
!*** ./src/renderer/Renderer.js ***!
\**********************************/
/*! exports provided: FILTERING_THRESHOLD, RTT_WIDTH, MIN_VERTEX_TEXTURE_IMAGE_UNITS_NEEDED, default, isBrowserSupported, unsupportedBrowserReasons */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FILTERING_THRESHOLD", function() { return FILTERING_THRESHOLD; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RTT_WIDTH", function() { return RTT_WIDTH; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MIN_VERTEX_TEXTURE_IMAGE_UNITS_NEEDED", function() { return MIN_VERTEX_TEXTURE_IMAGE_UNITS_NEEDED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Renderer; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isBrowserSupported", function() { return isBrowserSupported; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "unsupportedBrowserReasons", function() { return unsupportedBrowserReasons; });
/* harmony import */ var _shaders__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shaders */ "./src/renderer/shaders/index.js");
/* harmony import */ var _viz_expressions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./viz/expressions */ "./src/renderer/viz/expressions.js");
/* harmony import */ var _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../errors/carto-runtime-error */ "./src/errors/carto-runtime-error.js");
/* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! gl-matrix */ "./node_modules/gl-matrix/lib/gl-matrix.js");
/* harmony import */ var _constants_layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../constants/layer */ "./src/constants/layer.js");
/* harmony import */ var _viz_parser__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viz/parser */ "./src/renderer/viz/parser.js");
/* harmony import */ var _viz_expressions_aggregation_viewport_ViewportAggCalculator__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./viz/expressions/aggregation/viewport/ViewportAggCalculator */ "./src/renderer/viz/expressions/aggregation/viewport/ViewportAggCalculator.js");
/* harmony import */ var _utils_geometry__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/geometry */ "./src/utils/geometry.js");
const INITIAL_TIMESTAMP = Date.now();
let timestamp = INITIAL_TIMESTAMP;
requestAnimationFrame(refreshClock);
function refreshClock () {
timestamp = (Date.now() - INITIAL_TIMESTAMP) / 1000.0;
requestAnimationFrame(refreshClock);
}
/**
* The renderer use fuzzy logic where < 0.5 means false and >= 0.5 means true
*/
const FILTERING_THRESHOLD = 0.5;
/**
* @typedef {Object} RPoint - Point in renderer coordinates space
* @property {number} x
* @property {number} y
*/
/**
* @description The Render To Texture Width limits the maximum number of features per dataframe: *maxFeatureCount = RTT_WIDTH^2*
*
* Large RTT_WIDTH values are unsupported by hardware. Limits vary on each machine.
* Support starts to drop from 2048, with a drastic reduction in support for more than 4096 pixels.
*
* Large values imply a small overhead too.
*/
const RTT_WIDTH = 1024;
const MIN_VERTEX_TEXTURE_IMAGE_UNITS_NEEDED = 8;
/**
* @description Renderer constructor. Use it to create a new renderer bound to the provided canvas.
* Initialization will be done synchronously.
* The function will fail in case that a WebGL context cannot be created this can happen because of the following reasons:
* * The provided canvas element is invalid
* * The browser or the machine doesn't support WebGL or the required WebGL extension and minimum parameter values
* @jsapi
* @memberOf renderer
* @constructor
* @param {HTMLElement} canvas - the WebGL context will be created on this element
*/
class Renderer {
constructor (canvas) {
if (canvas) {
this.gl = getValidWebGLContextOrThrow(canvas);
this._initGL(this.gl);
}
this._center = { x: 0, y: 0 };
this._zoom = 1;
this.RTT_WIDTH = RTT_WIDTH;
this.dataframes = [];
}
/**
* Initialize renderer
* @param {WebGLRenderingContext} gl - WebGL context
*/
initialize (gl) {
gl = getValidWebGLContextOrThrow(null, gl);
this._initGL(gl);
}
_initGL (gl) {
this.gl = gl;
this._initShaders();
this.auxFB = gl.createFramebuffer();
// Create a VBO that covers the entire screen
// Use a "big" triangle instead of a square for performance and simplicity
this.bigTriangleVBO = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, this.bigTriangleVBO);
const vertices = new Float32Array([
10.0, -10.0,
0.0, 10.0,
-10.0, -10.0
]);
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
// Create a 1x1 RGBA texture set to [0,0,0,0]
// Needed because sometimes we don't really use some textures within the shader, but they are declared anyway.
this.zeroTex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, this.zeroTex);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA,
1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE,
new Uint8Array(4));
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
this._AATex = gl.createTexture(); // Antialiasing
this._AAFB = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
gl.bindTexture(gl.TEXTURE_2D, this.zeroTex);
}
_getAspect () {
if (this.gl) {
return this.gl.canvas.width / this.gl.canvas.height;
}
return 1;
}
renderLayer (renderLayer, drawMetadata) {
this.drawMetadata = drawMetadata;
const dataframes = renderLayer.getActiveDataframes();
const viz = renderLayer.viz;
if (!viz) {
return;
}
const gl = this.gl;
this._updateDataframeMatrices(dataframes);
renderLayer.parseVizExpression = _viz_parser__WEBPACK_IMPORTED_MODULE_5__["parseVizExpression"]; // Important! to avoid a circular dependency problem (eg. viewportFeatures)
Object(_viz_expressions_aggregation_viewport_ViewportAggCalculator__WEBPACK_IMPORTED_MODULE_6__["runViewportAggregations"])(renderLayer);
if (!dataframes.length) {
return;
}
viz._getRootExpressions().map(expr => expr._dataReady());
gl.enable(gl.CULL_FACE); // this enables an optimization but it forces a particular vertices orientation
gl.disable(gl.BLEND);
gl.disable(gl.DEPTH_TEST);
gl.disable(gl.STENCIL_TEST);
gl.depthMask(false);
gl.bindFramebuffer(gl.FRAMEBUFFER, this.auxFB);
// To execute once per daframe and style property
// (geometries, properties and ids have been already loaded to GPU)
const styleDataframe = (dataframe, dataframeTexture, metashader, vizExpr) => {
const shader = metashader.shader;
const textureId = metashader.textureIds;
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, dataframeTexture, 0);
gl.viewport(0, 0, RTT_WIDTH, dataframe.getSize().height);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.useProgram(shader.program);
// Enforce that property texture TextureUnit don't clash with auxiliar ones
drawMetadata.freeTexUnit = Object.keys(textureId).length;
vizExpr._setTimestamp(timestamp);
vizExpr._preDraw(shader.program, drawMetadata, gl);
Object.keys(textureId).forEach((name, i) => {
gl.activeTexture(gl.TEXTURE0 + i);
gl.bindTexture(gl.TEXTURE_2D, dataframe.getPropertyTexture(name));
gl.uniform1i(textureId[name], i);
});
gl.enableVertexAttribArray(shader.vertexAttribute);
gl.bindBuffer(gl.ARRAY_BUFFER, this.bigTriangleVBO);
gl.vertexAttribPointer(shader.vertexAttribute, 2, gl.FLOAT, false, 0, 0);
gl.drawArrays(gl.TRIANGLES, 0, 3);
gl.disableVertexAttribArray(shader.vertexAttribute);
};
// Draw dataframe style textures
dataframes.map(dataframe => styleDataframe(dataframe, dataframe.texColor, viz.colorMetaShader, viz.color));
if (dataframes[0].type !== _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].POLYGON) {
dataframes.map(dataframe => styleDataframe(dataframe, dataframe.texWidth, viz.widthMetaShader, viz.width));
}
if (dataframes[0].type !== _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].LINE) {
dataframes.map(dataframe => styleDataframe(dataframe, dataframe.texStrokeColor, viz.strokeColorMetaShader, viz.strokeColor));
dataframes.map(dataframe => styleDataframe(dataframe, dataframe.texStrokeWidth, viz.strokeWidthMetaShader, viz.strokeWidth));
}
dataframes.map(dataframe => styleDataframe(dataframe, dataframe.texFilter, viz.filterMetaShader, viz.filter));
// Final drawing (to screen). In the case of lines / polygons, there is an extra step (for antialiasing)
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
gl.enable(gl.BLEND);
if (renderLayer.type === _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].POINT) {
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
} else {
// lines & polygon (antialiasing)
const antialiasingScale = (window.devicePixelRatio || 1) >= 2 ? 1 : 2;
gl.bindFramebuffer(gl.FRAMEBUFFER, this._AAFB);
const [w, h] = [gl.drawingBufferWidth, gl.drawingBufferHeight];
if (w !== this._width || h !== this._height) {
gl.bindTexture(gl.TEXTURE_2D, this._AATex);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA,
w * antialiasingScale, h * antialiasingScale, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._AATex, 0);
const renderbuffer = gl.createRenderbuffer();
gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, w * antialiasingScale, h * antialiasingScale);
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, renderbuffer);
[this._width, this._height] = [w, h];
}
gl.viewport(0, 0, w * antialiasingScale, h * antialiasingScale);
gl.clear(gl.COLOR_BUFFER_BIT);
}
const { orderingMins, orderingMaxs } = getOrderingRenderBuckets(renderLayer);
if (dataframes[0].type === _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].LINE || dataframes[0].type === _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].POLYGON) {
gl.clearDepth(1);
gl.depthRange(0, 1);
gl.depthFunc(gl.NOTEQUAL);
gl.depthMask(true);
gl.enable(gl.DEPTH_TEST);
}
const renderDrawPass = orderingIndex => dataframes.forEach(dataframe => {
let freeTexUnit = 0;
let metaRenderer = null;
if (!viz.symbol.default) {
metaRenderer = viz.symbolMetaShader;
} else if (dataframe.type === _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].POINT) {
metaRenderer = viz.pointMetaShader;
} else if (dataframe.type === _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].LINE) {
metaRenderer = viz.lineMetaShader;
} else {
metaRenderer = viz.polygonMetaShader;
}
const renderer = metaRenderer.shader;
gl.useProgram(renderer.program);
// Set filtering condition on "... AND feature is in current order bucket"
gl.uniform1f(renderer.orderMinWidth, orderingMins[orderingIndex]);
gl.uniform1f(renderer.orderMaxWidth, orderingMaxs[orderingIndex]);
// Define some scalar uniforms
gl.uniform1f(renderer.normalScale, 1 / (Math.pow(2, drawMetadata.zoomLevel) * _constants_layer__WEBPACK_IMPORTED_MODULE_4__["RESOLUTION_ZOOMLEVEL_ZERO"] * dataframe.scale));
gl.uniform2f(renderer.resolution, gl.canvas.width / window.devicePixelRatio, gl.canvas.height / window.devicePixelRatio);
gl.enableVertexAttribArray(renderer.vertexPositionAttribute);
gl.bindBuffer(gl.ARRAY_BUFFER, dataframe.vertexBuffer);
gl.vertexAttribPointer(renderer.vertexPositionAttribute, 2, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(renderer.featureIdAttr);
gl.bindBuffer(gl.ARRAY_BUFFER, dataframe.featureIDBuffer);
gl.vertexAttribPointer(renderer.featureIdAttr, 2, gl.FLOAT, false, 0, 0);
if (dataframe.type === _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].LINE || dataframe.type === _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].POLYGON) {
gl.enableVertexAttribArray(renderer.normalAttr);
gl.bindBuffer(gl.ARRAY_BUFFER, dataframe.normalBuffer);
gl.vertexAttribPointer(renderer.normalAttr, 2, gl.FLOAT, false, 0, 0);
}
// Common Style textures
gl.activeTexture(gl.TEXTURE0 + freeTexUnit);
gl.bindTexture(gl.TEXTURE_2D, dataframe.texColor);
gl.uniform1i(renderer.colorTexture, freeTexUnit);
freeTexUnit++;
gl.activeTexture(gl.TEXTURE0 + freeTexUnit);
gl.bindTexture(gl.TEXTURE_2D, dataframe.texFilter);
gl.uniform1i(renderer.filterTexture, freeTexUnit);
freeTexUnit++;
// Specific Style textures
if (dataframe.type === 'point' || dataframe.type === 'line') {
gl.activeTexture(gl.TEXTURE0 + freeTexUnit);
gl.bindTexture(gl.TEXTURE_2D, dataframe.texWidth);
gl.uniform1i(renderer.widthTexture, freeTexUnit);
freeTexUnit++;
}
if (!viz.symbol.default) {
const textureId = metaRenderer.textureIds;
// Enforce that property texture and style texture TextureUnits don't clash with auxiliar ones
drawMetadata.freeTexUnit = freeTexUnit + Object.keys(textureId).length;
viz.symbol._setTimestamp(timestamp);
viz.symbol._preDraw(renderer.program, drawMetadata, gl);
viz.symbolPlacement._setTimestamp(timestamp);
viz.symbolPlacement._preDraw(renderer.program, drawMetadata, gl);
freeTexUnit = drawMetadata.freeTexUnit;
Object.keys(textureId).forEach(name => {
gl.activeTexture(gl.TEXTURE0 + freeTexUnit);
gl.bindTexture(gl.TEXTURE_2D, dataframe.getPropertyTexture(name));
gl.uniform1i(textureId[name], freeTexUnit);
freeTexUnit++;
});
} else if (dataframe.type !== _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].LINE) {
// Lines don't support stroke
gl.activeTexture(gl.TEXTURE0 + freeTexUnit);
gl.bindTexture(gl.TEXTURE_2D, dataframe.texStrokeColor);
gl.uniform1i(renderer.strokeColorTexture, freeTexUnit);
freeTexUnit++;
gl.activeTexture(gl.TEXTURE0 + freeTexUnit);
gl.bindTexture(gl.TEXTURE_2D, dataframe.texStrokeWidth);
gl.uniform1i(renderer.strokeWidthTexture, freeTexUnit);
freeTexUnit++;
}
if (dataframe.type === _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].LINE || dataframe.type === _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].POLYGON) {
gl.clear(gl.DEPTH_BUFFER_BIT); // antialising-related
}
if (!viz.transform.default) {
const textureId = metaRenderer.textureIds;
// Enforce that property texture and style texture TextureUnits don't clash with auxiliar ones
drawMetadata.freeTexUnit = freeTexUnit + Object.keys(textureId).length;
viz.transform._setTimestamp(timestamp);
viz.transform._preDraw(renderer.program, drawMetadata, gl);
freeTexUnit = drawMetadata.freeTexUnit;
Object.keys(textureId).forEach(name => {
gl.activeTexture(gl.TEXTURE0 + freeTexUnit);
gl.bindTexture(gl.TEXTURE_2D, dataframe.getPropertyTexture(name));
gl.uniform1i(textureId[name], freeTexUnit);
freeTexUnit++;
});
gl.uniform2f(renderer.resolution, gl.canvas.width, gl.canvas.height); // remove it ? (duplicated)
}
gl.uniformMatrix4fv(renderer.matrix, false, dataframe.matrix);
gl.drawArrays(gl.TRIANGLES, 0, dataframe.numVertex);
// Some cleaning...
gl.disableVertexAttribArray(renderer.vertexPositionAttribute);
gl.disableVertexAttribArray(renderer.featureIdAttr);
if (dataframe.type === _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].LINE || dataframe.type === _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].POLYGON) {
gl.disableVertexAttribArray(renderer.normalAttr);
gl.disable(gl.DEPTH_TEST);
}
});
orderingMins.map((_, orderingIndex) => {
renderDrawPass(orderingIndex);
});
if (renderLayer.type !== _utils_geometry__WEBPACK_IMPORTED_MODULE_7__["GEOMETRY_TYPE"].POINT) {
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
gl.useProgram(this._aaBlendShader.program);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, this._AATex);
gl.uniform1i(this._aaBlendShader.readTU, 0);
gl.enableVertexAttribArray(this._aaBlendShader.vertexAttribute);
gl.bindBuffer(gl.ARRAY_BUFFER, this.bigTriangleVBO);
gl.vertexAttribPointer(this._aaBlendShader.vertexAttribute, 2, gl.FLOAT, false, 0, 0);
gl.drawArrays(gl.TRIANGLES, 0, 3);
gl.disableVertexAttribArray(this._aaBlendShader.vertexAttribute);
}
gl.disable(gl.CULL_FACE); // ? not needed from v0.50?
}
_updateDataframeMatrices (dataframes) {
dataframes.forEach(dataframe => {
let m2 = [];
let m3 = [];
gl_matrix__WEBPACK_IMPORTED_MODULE_3__["mat4"].copy(m2, this.matrix);
gl_matrix__WEBPACK_IMPORTED_MODULE_3__["mat4"].identity(m3);
gl_matrix__WEBPACK_IMPORTED_MODULE_3__["mat4"].translate(m3, m3, [0.5, 0.5, 0]);
gl_matrix__WEBPACK_IMPORTED_MODULE_3__["mat4"].scale(m3, m3, [0.5, -0.5, 1]);
gl_matrix__WEBPACK_IMPORTED_MODULE_3__["mat4"].translate(m3, m3, [dataframe.center.x, dataframe.center.y, 0]);
gl_matrix__WEBPACK_IMPORTED_MODULE_3__["mat4"].scale(m3, m3, [dataframe.scale, dataframe.scale, 1]);
gl_matrix__WEBPACK_IMPORTED_MODULE_3__["mat4"].multiply(m2, m2, m3);
dataframe.matrix = m2;
});
}
/**
* Initialize static shaders
*/
_initShaders () {
this._aaBlendShader = new _shaders__WEBPACK_IMPORTED_MODULE_0__["default"].AABlender(this.gl);
}
}
function getOrderingRenderBuckets (renderLayer) {
const orderer = renderLayer.viz.order;
const MAX_SIZE = 1030;
let orderingMins = [0];
let orderingMaxs = [MAX_SIZE];
// We divide the ordering into 64 buckets of 2 pixels each, since the size limit is 127 pixels
const NUM_BUCKETS = 64;
if (orderer.isA(_viz_expressions__WEBPACK_IMPORTED_MODULE_1__["Asc"])) {
orderingMins = Array.from({ length: NUM_BUCKETS }, (_, i) => ((NUM_BUCKETS - 1) - i) * 2);
orderingMaxs = Array.from({ length: NUM_BUCKETS }, (_, i) => i === 0 ? MAX_SIZE : ((NUM_BUCKETS - 1) - i + 1) * 2);
} else if (orderer.isA(_viz_expressions__WEBPACK_IMPORTED_MODULE_1__["Desc"])) {
orderingMins = Array.from({ length: NUM_BUCKETS }, (_, i) => i * 2);
orderingMaxs = Array.from({ length: NUM_BUCKETS }, (_, i) => i === (NUM_BUCKETS - 1) ? MAX_SIZE : (i + 1) * 2);
}
return {
orderingMins,
orderingMaxs
};
}
function getValidWebGLContextOrThrow (canvas, gl) {
const reasons = unsupportedBrowserReasons(canvas, gl, true);
if (reasons.length > 0) {
throw reasons[0];
}
return gl;
}
function isBrowserSupported (canvas, gl) {
const reasons = unsupportedBrowserReasons(canvas, gl);
return reasons.length === 0;
}
function unsupportedBrowserReasons (canvas, gl, early = false) {
const reasons = [];
if (!gl) {
if (!canvas) {
canvas = document.createElement('canvas');
}
gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
}
if (!gl) {
reasons.push(new _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_2__["default"]('WebGL 1 is unsupported', _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_2__["CartoRuntimeErrorTypes"].WEB_GL));
return reasons;
}
const OESTextureFloat = gl.getExtension('OES_texture_float');
if (!OESTextureFloat) {
reasons.push(new _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_2__["default"]('WebGL extension \'OES_texture_float\' is unsupported', _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_2__["CartoRuntimeErrorTypes"].WEB_GL));
if (early) {
return reasons;
}
}
const supportedRTT = gl.getParameter(gl.MAX_RENDERBUFFER_SIZE);
if (supportedRTT < RTT_WIDTH) {
reasons.push(
new _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_2__["default"](
`WebGL parameter 'gl.MAX_RENDERBUFFER_SIZE' is below the requirement: ${supportedRTT} < ${RTT_WIDTH}`,
_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_2__["CartoRuntimeErrorTypes"].WEB_GL
)
);
}
const vertexTextureImageUnits = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
if (vertexTextureImageUnits < MIN_VERTEX_TEXTURE_IMAGE_UNITS_NEEDED) {
reasons.push(
new _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_2__["default"](
`WebGL parameter 'gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS' is below the requirement: ${vertexTextureImageUnits} < ${MIN_VERTEX_TEXTURE_IMAGE_UNITS_NEEDED}`,
_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_2__["CartoRuntimeErrorTypes"].WEB_GL
)
);
}
return reasons;
}
/***/ }),
/***/ "./src/renderer/dataframe/Dataframe.js":
/*!*********************************************!*\
!*** ./src/renderer/dataframe/Dataframe.js ***!
\*********************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Dataframe; });
/* harmony import */ var _utils_geometry__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils/geometry */ "./src/utils/geometry.js");
/* harmony import */ var _DummyDataframe__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./DummyDataframe */ "./src/renderer/dataframe/DummyDataframe.js");
/* harmony import */ var _utils_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils/util */ "./src/utils/util.js");
/* harmony import */ var _viewportFeature__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./viewportFeature */ "./src/renderer/dataframe/viewportFeature.js");
/* harmony import */ var _FeatureIdsHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./FeatureIdsHelper */ "./src/renderer/dataframe/FeatureIdsHelper.js");
/* harmony import */ var _ViewportHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ViewportHelper */ "./src/renderer/dataframe/ViewportHelper.js");
// Maximum number of property textures that will be uploaded automatically to the GPU
// in a non-lazy manner
const MAX_GPU_AUTO_UPLOAD_TEXTURE_LIMIT = 32;
const featureClassCache = new Map();
class Dataframe extends _DummyDataframe__WEBPACK_IMPORTED_MODULE_1__["default"] {
constructor (...args) {
super(...args);
this._initHelpers();
}
_initHelpers () {
if (!this._featureIdsHelper) {
this._featureIdsHelper = new _FeatureIdsHelper__WEBPACK_IMPORTED_MODULE_4__["default"](this);
}
if (!this._viewportHelper) {
this._viewportHelper = new _ViewportHelper__WEBPACK_IMPORTED_MODULE_5__["default"](this);
}
}
/**
* Loads all the relevant information to the WebGL context, provided by the renderer.
* This includes:
* - the textures for each property
* - the buffers for vertices & normals
* - the auxiliary textures for style properties
*
* This method is very intensive in terms of computations, loading potentially a lot of CPU data to the GPU
*
*/
bindRenderer (renderer) {
this.renderer = renderer;
this._initHelpers();
// Load alphanumeric properties to WebGL textures
this.addProperties();
// Load geometry-related data to WebGL buffers
this._loadVertices();
this._loadNormals();
this._loadFeatureIds();
// Create auxiliary WebGL style textures
this._createEmptyStyleTextures();
}
/**
* Gets width & height size, considering RTT_WIDTH and the number of features
*/
getSize () {
const width = this.renderer.RTT_WIDTH;
const height = Math.ceil(this.numFeatures / width);
return { width, height };
}
/**
* Gets the WebGL context from the renderer
*/
_getGL () {
return this.renderer.gl;
}
/**
* Creates the WebGL `vertexBuffer` and loads there the vertices
*/
_loadVertices () {
const gl = this._getGL();
const vertices = this.decodedGeom.vertices;
this.vertexBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
}
/**
* Creates the WebGL `normalBuffer` and loads there the normals, if they exist
*/
_loadNormals () {
const gl = this._getGL();
const normals = this.decodedGeom.normals;
if (normals) {
this.normalBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, this.normalBuffer);
gl.bufferData(gl.ARRAY_BUFFER, normals, gl.STATIC_DRAW);
}
}
/**
* Creates the WebGL `featureIDBuffer` and loads there the featureIds per vertex
*/
_loadFeatureIds () {
const gl = this._getGL();
const ids = this._featureIdsHelper.getFeatureIds();
this.featureIDBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, this.featureIDBuffer);
gl.bufferData(gl.ARRAY_BUFFER, ids, gl.STATIC_DRAW);
}
getFeaturesAtPosition (position, viz) {
if (!this.matrix) {
return [];
}
switch (this.type) {
case _utils_geometry__WEBPACK_IMPORTED_MODULE_0__["GEOMETRY_TYPE"].POINT:
return this._viewportHelper.getPointsAtPosition(position, viz);
case _utils_geometry__WEBPACK_IMPORTED_MODULE_0__["GEOMETRY_TYPE"].LINE:
case _utils_geometry__WEBPACK_IMPORTED_MODULE_0__["GEOMETRY_TYPE"].POLYGON:
return this._viewportHelper.getFeaturesAtPositionFromTriangles(this.type, position, viz);
default:
return [];
}
}
inViewport (featureIndex) {
if (!this.matrix) {
return false;
}
switch (this.type) {
case _utils_geometry__WEBPACK_IMPORTED_MODULE_0__["GEOMETRY_TYPE"].POINT:
return this._viewportHelper.isPointInViewport(featureIndex);
case _utils_geometry__WEBPACK_IMPORTED_MODULE_0__["GEOMETRY_TYPE"].LINE:
case _utils_geometry__WEBPACK_IMPORTED_MODULE_0__["GEOMETRY_TYPE"].POLYGON:
return this._viewportHelper.isPolygonInViewport(featureIndex);
default:
return false;
}
}
getRenderedCentroid (featureIndex) {
const centroid = { ...this._centroids[featureIndex] };
centroid.x = centroid.x * this.scale + this.center.x;
centroid.y = centroid.y * this.scale + this.center.y;
const g = this._unprojectFromWebMercator(centroid);
return [g.lng, g.lat];
}
getPropertyTexture (propertyName) {
if (this.propertyTex[propertyName]) {
return this.propertyTex[propertyName];
}
this._loadPropertyValuesToTexture(propertyName);
return this.propertyTex[propertyName];
}
/**
* Creates a WebGL texture for that property and loads the property values,
* if they exist
*/
_loadPropertyValuesToTexture (propertyName) {
const gl = this._getGL(); // Dataframe is already bound to this context, "hot update" it
const propertiesFloat32Array = this.properties[propertyName];
const { width, height } = this.getSize();
if (propertiesFloat32Array) {
this.propertyTex[propertyName] = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, this.propertyTex[propertyName]);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.ALPHA,
width, height, 0, gl.ALPHA, gl.FLOAT,
propertiesFloat32Array);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
}
}
free () {
this._freeWebGLElements();
Object.keys(this).forEach(key => {
this[key] = null;
});
this.freed = true;
}
_freeWebGLElements () {
if (!this.propertyTex) {
return;
}
const gl = this._getGL();
this.propertyTex.map(tex => gl.deleteTexture(tex));
gl.deleteTexture(this.texColor);
gl.deleteTexture(this.texStrokeColor);
gl.deleteTexture(this.texWidth);
gl.deleteTexture(this.texStrokeWidth);
gl.deleteTexture(this.texFilter);
gl.deleteBuffer(this.vertexBuffer);
gl.deleteBuffer(this.featureIDBuffer);
}
/**
* Converts a point {x, y} in WebMercator to {lng, lat}
*/
_unprojectFromWebMercator ({ x, y }) {
const DEG2RAD = Math.PI / 180;
const EARTH_RADIUS = 6378137;
return {
lng: x * _utils_util__WEBPACK_IMPORTED_MODULE_2__["WM_R"] / EARTH_RADIUS / DEG2RAD,
lat: (Math.atan(Math.pow(Math.E, y * _utils_util__WEBPACK_IMPORTED_MODULE_2__["WM_R"] / EARTH_RADIUS)) - Math.PI / 4) * 2 / DEG2RAD
};
}
/**
* Defines a `ViewportFeature` class dynamically, with the proper getters
* to access its properties, if that doesn't exist yet in the `featureClassCache`
*/
_genFeatureClass () {
if (featureClassCache.has(this.metadata)) {
this._featureClass = featureClassCache.get(this.metadata);
return;
}
const cls = Object(_viewportFeature__WEBPACK_IMPORTED_MODULE_3__["genViewportFeatureClass"])(this.metadata);
featureClassCache.set(this.metadata, cls);
this._featureClass = cls;
}
/**
* Builds a feature object for an index, copying all the properties.
*/
getFeature (index) {
if (!this.cachedFeatures) {
this.cachedFeatures = new Array(this.numFeatures);
}
if (this.cachedFeatures[index] !== undefined) {
return this.cachedFeatures[index];
}
if (!this._featureClass) {
this._genFeatureClass();
}
const feature = new this._featureClass(index, this);
this.cachedFeatures[index] = feature;
return feature;
}
/**
* Adds new properties to the dataframe or overwrite previously stored ones,
* using metadata properties.
*
* These are all the relevant alphanumeric properties, which have been previously encoded
* in a form like {propertyName: Float32Array}
*
*/
addProperties () {
for (let i = 0; i < this.metadata.propertyKeys.length; i++) {
const propertyName = this.metadata.propertyKeys[i];
this._addProperty(propertyName);
}
this._genFeatureClass();
}
/**
* If below GPU auto upload texture limit, it ensures that a WebGL texture is ready with
* the values for that property already loaded
*/
_addProperty (propertyName) {
if (Object.keys(this.propertyTex).length < MAX_GPU_AUTO_UPLOAD_TEXTURE_LIMIT) {
this.getPropertyTexture(propertyName);
}
}
_createEmptyStyleTextures () {
this.texColor = this._createStyleDataframeTexture();
this.texWidth = this._createStyleDataframeTexture();
this.texStrokeColor = this._createStyleDataframeTexture();
this.texStrokeWidth = this._createStyleDataframeTexture();
this.texFilter = this._createStyleDataframeTexture();
}
/**
* Creates a new empty WebGL texture.
* It just reserves the space for this 'intermediate texture'
*/
_createStyleDataframeTexture () {
// TODO we are wasting 75% of the memory for the scalar attributes (width, strokeWidth),
// since RGB components are discarded
const gl = this._getGL();
const { width, height } = this.getSize();
const texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA,
width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE,
null); // empty!
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
return texture;
}
}
/***/ }),
/***/ "./src/renderer/dataframe/DummyDataframe.js":
/*!**************************************************!*\
!*** ./src/renderer/dataframe/DummyDataframe.js ***!
\**************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return DummyDataframe; });
/* harmony import */ var _decoder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../decoder */ "./src/renderer/decoder/index.js");
/* harmony import */ var _utils_geometry__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/geometry */ "./src/utils/geometry.js");
class DummyDataframe {
constructor ({ active, center, properties, propertiesArrayBuffer, scale, type, geom, size, metadata }) {
this.active = active;
this.center = center;
this.properties = properties;
this.propertiesArrayBuffer = propertiesArrayBuffer;
this.scale = scale;
this.type = type;
this.decodedGeom = Object(_decoder__WEBPACK_IMPORTED_MODULE_0__["decodeGeom"])(type, geom);
this.numVertex = (type === _utils_geometry__WEBPACK_IMPORTED_MODULE_1__["GEOMETRY_TYPE"].POINT) ? size * 3 : this.decodedGeom.vertices.length / 2;
this.numFeatures = type === _utils_geometry__WEBPACK_IMPORTED_MODULE_1__["GEOMETRY_TYPE"].POINT ? size : this.decodedGeom.breakpoints.length || this.numVertex;
this.propertyTex = [];
this.metadata = metadata;
this.propertyCount = 0;
this._aabb = Object(_utils_geometry__WEBPACK_IMPORTED_MODULE_1__["computeAABB"])(geom, type);
this._centroids = Object(_utils_geometry__WEBPACK_IMPORTED_MODULE_1__["computeCentroids"])(this.decodedGeom, type);
this.t1 = [0.1, 0.1, 0.1, 0.1];
this.t2 = [0.1, 0.1, 0.1, 0.1];
this.t3 = [0.1, 0.1, 0.1, 0.1];
this.t4 = [0.1, 0.1, 0.1, 0.1];
}
}
/***/ }),
/***/ "./src/renderer/dataframe/FeatureIdsHelper.js":
/*!****************************************************!*\
!*** ./src/renderer/dataframe/FeatureIdsHelper.js ***!
\****************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return FeatureIdsHelper; });
class FeatureIdsHelper {
constructor (dataframe) {
this.dataframe = dataframe;
}
// References pointing to dataframe, to be in sync with its updates
get decodedGeom () { return this.dataframe.decodedGeom; }
get numFeatures () { return this.dataframe.numFeatures; }
/**
* Gets the featureId per each vertice.
*/
getFeatureIds () {
const breakpoints = this.decodedGeom.breakpoints;
const isPointType = !breakpoints.length;
if (isPointType) {
return this._getFeatureIdsForPoints();
} else {
return this._getFeatureIdsForLinesOrPolygons();
}
}
_getFeatureIdsForPoints () {
const numVertices = this.decodedGeom.vertices.length;
let { tableX, tableY } = this._createTablesXY();
const ids = new Float32Array(numVertices);
const inc = 1 / (1024 * 64);
let index = 0;
for (let i = 0; i < numVertices; i += 6) {
ids[i + 0] = tableX[index];
ids[i + 1] = tableY[index];
if (ids[i + 0] === 0) {
ids[i + 0] += inc;
}
if (ids[i + 1] === 0) {
ids[i + 1] += inc;
}
ids[i + 2] = -ids[i + 0];
ids[i + 3] = ids[i + 1];
ids[i + 4] = ids[i + 0];
ids[i + 5] = -ids[i + 1];
index++;
}
return ids;
}
_getFeatureIdsForLinesOrPolygons () {
const numVertices = this.decodedGeom.vertices.length;
let { tableX, tableY } = this._createTablesXY();
const breakpoints = this.decodedGeom.breakpoints;
const ids = new Float32Array(numVertices);
let index = 0;
for (let i = 0; i < numVertices; i += 2) {
while (i === breakpoints[index]) {
index++;
}
ids[i + 0] = tableX[index];
ids[i + 1] = tableY[index];
}
return ids;
}
_createTablesXY () {
let tableX = {};
let tableY = {};
const { height, width } = this.dataframe.getSize();
for (let k = 0; k < this.numFeatures; k++) {
// Transform integer ID into a `vec2` to overcome WebGL 1 limitations,
// output IDs will be in the `vec2([0,1], [0,1])` range
tableX[k] = (k % width) / (width - 1);
tableY[k] = height > 1 ? Math.floor(k / width) / (height - 1) : 0.5;
}
return { tableX, tableY };
}
}
/***/ }),
/***/ "./src/renderer/dataframe/ProjectionHelper.js":
/*!****************************************************!*\
!*** ./src/renderer/dataframe/ProjectionHelper.js ***!
\****************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ProjectionHelper; });
class ProjectionHelper {
constructor (dataframe) {
this.dataframe = dataframe;
}
// Reference pointing to dataframe, to be in sync with its updates
get matrix () { return this.dataframe.matrix; }
toNDC (x, y) {
const { ox, oy, ow } = this.toClipSpace(x, y);
// Normalize by W
return { x: ox / ow, y: oy / ow };
}
toClipSpace (x, y) {
const matrix = this.matrix;
const ox = matrix[0] * x + matrix[4] * y + matrix[12];
const oy = matrix[1] * x + matrix[5] * y + matrix[13];
const ow = matrix[3] * x + matrix[7] * y + matrix[15];
return { ox, oy, ow };
}
}
/***/ }),
/***/ "./src/renderer/dataframe/ViewportHelper.js":
/*!**************************************************!*\
!*** ./src/renderer/dataframe/ViewportHelper.js ***!
\**************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ViewportHelper; });
/* harmony import */ var _utils_collision__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils/collision */ "./src/utils/collision.js");
/* harmony import */ var _utils_geometry__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/geometry */ "./src/utils/geometry.js");
/* harmony import */ var _Renderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Renderer */ "./src/renderer/Renderer.js");
/* harmony import */ var _constants_layer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../constants/layer */ "./src/constants/layer.js");
/* harmony import */ var _ProjectionHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ProjectionHelper */ "./src/renderer/dataframe/ProjectionHelper.js");
const AABBTestResults = {
INSIDE: 1,
OUTSIDE: -1,
INTERSECTS: 0
};
const SIZE_SATURATION_PX = 1024;
class ViewportHelper {
constructor (dataframe) {
this.dataframe = dataframe;
this.getFeature = dataframe.getFeature.bind(dataframe);
this._getGL = dataframe._getGL.bind(dataframe);
this._projection = new _ProjectionHelper__WEBPACK_IMPORTED_MODULE_4__["default"](dataframe);
}
// References pointing to dataframe, to be in sync with its updates
get decodedGeom () { return this.dataframe.decodedGeom; }
get _aabb () { return this.dataframe._aabb; }
get numFeatures () { return this.dataframe.numFeatures; }
get renderer () { return this.dataframe.renderer; }
get matrix () { return this.dataframe.matrix; }
get scale () { return this.dataframe.scale; }
/**
* Checks if the point is inside the viewport.
*/
isPointInViewport (featureIndex) {
const vertices = this.decodedGeom.vertices;
const x = vertices[6 * featureIndex + 0];
const y = vertices[6 * featureIndex + 1];
const { ox, oy, ow } = this._projection.toClipSpace(x, y);
// Checks in Clip Space if the point is inside the viewport
// See https://www.khronos.org/opengl/wiki/Vertex_Post-Processing#Clipping
const inside = ox > -ow && ox < ow && oy > -ow && oy < ow;
return inside;
}
/**
* Checks if the polygon is inside the viewport.
*/
isPolygonInViewport (featureIndex) {
const featureAABB = this._aabb[featureIndex];
const aabbResult = this._compareAABBs(featureAABB);
if (aabbResult === AABBTestResults.INTERSECTS) {
const vertices = this.decodedGeom.vertices;
const normals = this.decodedGeom.normals;
const range = this.decodedGeom.featureIDToVertexIndex.get(featureIndex);
return this._isPolygonCollidingViewport(vertices, normals, range.start, range.end);
}
return aabbResult === AABBTestResults.INSIDE;
}
/**
* Get canvas size in pixels, in a {WIDTH, HEIGHT} object, using the devicePixelRatio
*/
_getCanvasSizeInPixels () {
const canvas = this._getGL().canvas;
const WIDTH = canvas.width / window.devicePixelRatio;
const HEIGHT = canvas.height / window.devicePixelRatio;
return { WIDTH, HEIGHT };
}
_compareAABBs (featureAABB) {
if (featureAABB === null) {
return AABBTestResults.OUTSIDE;
}
const corners1 = this._projection.toNDC(featureAABB.minx, featureAABB.miny);
const corners2 = this._projection.toNDC(featureAABB.minx, featureAABB.maxy);
const corners3 = this._projection.toNDC(featureAABB.maxx, featureAABB.miny);
const corners4 = this._projection.toNDC(featureAABB.maxx, featureAABB.maxy);
const featureStrokeAABB = {
minx: Math.min(corners1.x, corners2.x, corners3.x, corners4.x),
miny: Math.min(corners1.y, corners2.y, corners3.y, corners4.y),
maxx: Math.max(corners1.x, corners2.x, corners3.x, corners4.x),
maxy: Math.max(corners1.y, corners2.y, corners3.y, corners4.y)
};
const viewportAABB = {
minx: -1,
miny: -1,
maxx: 1,
maxy: 1
};
switch (true) {
case this._isFeatureAABBInsideViewport(featureStrokeAABB, viewportAABB):
return AABBTestResults.INSIDE;
case this._isFeatureAABBOutsideViewport(featureStrokeAABB, viewportAABB):
return AABBTestResults.OUTSIDE;
default:
return AABBTestResults.INTERSECTS;
}
}
_isPolygonCollidingViewport (vertices, normals, start, end) { // NORMALS??? FIXME TODO
if (!this.matrix) {
return false;
}
const aabb = { minx: -1, miny: -1, maxx: 1, maxy: 1 };
for (let i = start; i < end; i += 6) {
const v1 = this._projection.toNDC(vertices[i + 0], vertices[i + 1]);
const v2 = this._projection.toNDC(vertices[i + 2], vertices[i + 3]);
const v3 = this._projection.toNDC(vertices[i + 4], vertices[i + 5]);
const triangle = [{
x: v1.x,
y: v1.y
}, {
x: v2.x,
y: v2.y
}, {
x: v3.x,
y: v3.y
}];
if (Object(_utils_collision__WEBPACK_IMPORTED_MODULE_0__["triangleCollides"])(triangle, aabb)) {
return true;
}
}
return false;
}
_isFeatureAABBInsideViewport (featureAABB, viewportAABB) {
return (featureAABB.minx >= viewportAABB.minx && featureAABB.maxx <= viewportAABB.maxx &&
featureAABB.miny >= viewportAABB.miny && featureAABB.maxy <= viewportAABB.maxy);
}
_isFeatureAABBOutsideViewport (featureAABB, viewportAABB) {
return (featureAABB.minx > viewportAABB.maxx || featureAABB.miny > viewportAABB.maxy ||
featureAABB.maxx < viewportAABB.minx || featureAABB.maxy < viewportAABB.miny);
}
getPointsAtPosition (position, viz) {
const points = this.decodedGeom.vertices;
// FIXME: points.length includes rejected points (out of tile)
// so we use numFeatures here, but should fix the points size
const features = [];
for (let i = 0; i < this.numFeatures * 6; i += 6) {
const featureIndex = i / 6;
const feature = this.getFeature(featureIndex);
if (this._isFeatureFiltered(feature, viz.filter)) {
continue;
}
const point = { x: points[i], y: points[i + 1] };
const { center, radius } = this._getCircleFor(point, feature, viz);
const inside = Object(_utils_geometry__WEBPACK_IMPORTED_MODULE_1__["pointInCircle"])(position, center, radius);
if (inside) {
features.push(feature);
}
}
return features;
}
_isFeatureFiltered (feature, filterExpression) {
return filterExpression.eval(feature) < _Renderer__WEBPACK_IMPORTED_MODULE_2__["FILTERING_THRESHOLD"];
}
/**
* Gets a circle for that point of the feature, considering the viz properties
* (symbolPlacement, transform, width and strokeWidth).
*
* It is expressed as {center, radius}, using pixel coordinates
*/
_getCircleFor (point, feature, viz) {
const { WIDTH, HEIGHT } = this._getCanvasSizeInPixels();
const center = this._projection.toNDC(point.x, point.y);
// Project to pixel space
center.x *= 0.5;
center.y *= -0.5;
center.x += 0.5;
center.y += 0.5;
center.x *= WIDTH;
center.y *= HEIGHT;
const radius = this._computePointRadius(feature, viz);
if (!viz.symbol.default) {
const symbolOffset = viz.symbolPlacement.eval(feature);
center.x += symbolOffset[0] * radius;
center.y -= symbolOffset[1] * radius;
}
if (!viz.transform.default) {
const vizOffset = viz.transform.eval(feature);
center.x += vizOffset.x;
center.y -= vizOffset.y;
}
return { center, radius };
}
getFeaturesAtPositionFromTriangles (geometryType, position, viz) {
const vertices = this.decodedGeom.vertices;
const normals = this.decodedGeom.normals;
const breakpoints = this.decodedGeom.breakpoints;
const features = [];
// Linear search for all features
// Tests triangles since we already have the triangulated form
// Moreover, with an acceleration structure and triangle testing features could be subdivided easily
let featureIndex = -1;
let strokeWidthScale;
const offset = { x: 0, y: 0 };
const { WIDTH, HEIGHT } = this._getCanvasSizeInPixels();
for (let i = 0; i < vertices.length; i += 6) {
if (i === 0 || i >= breakpoints[featureIndex]) {
featureIndex++;
const feature = this.getFeature(featureIndex);
if (!viz.transform.default) {
const vizOffset = viz.transform.eval(feature);
offset.x = vizOffset[0];
offset.y = vizOffset[1];
}
strokeWidthScale = geometryType === _utils_geometry__WEBPACK_IMPORTED_MODULE_1__["GEOMETRY_TYPE"].LINE
? this._computeLineWidthScale(feature, viz)
: this._computePolygonWidthScale(feature, viz);
if (this._isFeatureFiltered(feature, viz.filter) ||
!this._isPointInAABB(position, offset,
geometryType === _utils_geometry__WEBPACK_IMPORTED_MODULE_1__["GEOMETRY_TYPE"].LINE
? viz.width.eval(feature)
: viz.strokeWidth.eval(feature)
,
featureIndex)
) {
i = breakpoints[featureIndex] - 6;
continue;
}
}
const v1 = this._projection.toNDC(
vertices[i + 0] + normals[i + 0] * strokeWidthScale,
vertices[i + 1] + normals[i + 1] * strokeWidthScale
);
const v2 = this._projection.toNDC(
vertices[i + 2] + normals[i + 2] * strokeWidthScale,
vertices[i + 3] + normals[i + 3] * strokeWidthScale
);
const v3 = this._projection.toNDC(
vertices[i + 4] + normals[i + 4] * strokeWidthScale,
vertices[i + 5] + normals[i + 5] * strokeWidthScale
);
v1.x *= 0.5;
v1.y *= -0.5;
v1.x += 0.5;
v1.y += 0.5;
v2.x *= 0.5;
v2.y *= -0.5;
v2.x += 0.5;
v2.y += 0.5;
v3.x *= 0.5;
v3.y *= -0.5;
v3.x += 0.5;
v3.y += 0.5;
const inside = Object(_utils_geometry__WEBPACK_IMPORTED_MODULE_1__["pointInTriangle"])(position,
{ x: v1.x * WIDTH + offset.x, y: v1.y * HEIGHT - offset.y },
{ x: v2.x * WIDTH + offset.x, y: v2.y * HEIGHT - offset.y },
{ x: v3.x * WIDTH + offset.x, y: v3.y * HEIGHT - offset.y });
if (inside) {
features.push(this.getFeature(featureIndex));
// Don't repeat a feature if the point is on a shared (by two triangles) edge
// Also, don't waste CPU cycles
i = breakpoints[featureIndex] - 6;
}
}
return features;
}
_isPointInAABB (point, offset, widthScale, featureIndex) {
// Transform AABB from tile space to NDC space
const aabb = this._aabb[featureIndex];
if (aabb === null || !this.matrix) {
return false;
}
const corners1 = this._projection.toNDC(aabb.minx, aabb.miny);
const corners2 = this._projection.toNDC(aabb.minx, aabb.maxy);
const corners3 = this._projection.toNDC(aabb.maxx, aabb.miny);
const corners4 = this._projection.toNDC(aabb.maxx, aabb.maxy);
const ndcAABB = {
minx: Math.min(corners1.x, corners2.x, corners3.x, corners4.x),
miny: Math.min(corners1.y, corners2.y, corners3.y, corners4.y),
maxx: Math.max(corners1.x, corners2.x, corners3.x, corners4.x),
maxy: Math.max(corners1.y, corners2.y, corners3.y, corners4.y)
};
const { WIDTH, HEIGHT } = this._getCanvasSizeInPixels();
const ox = 2 * offset.x / WIDTH;
const oy = 2 * offset.y / HEIGHT;
const ndcPoint = {
x: point.x / WIDTH * 2 - 1,
y: -(point.y / HEIGHT * 2 - 1)
};
const pointAABB = {
minx: ndcPoint.x + ox - widthScale * 2 / WIDTH,
miny: ndcPoint.y - oy - widthScale * 2 / HEIGHT,
maxx: ndcPoint.x + ox + widthScale * 2 / WIDTH,
maxy: ndcPoint.y - oy + widthScale * 2 / HEIGHT
};
return !this._isFeatureAABBOutsideViewport(ndcAABB, pointAABB);
}
_computePointRadius (feature, viz) {
const widthPixels = Math.min(viz.width.eval(feature), SIZE_SATURATION_PX);
const strokeWidthPixels = Math.min(viz.strokeWidth.eval(feature), SIZE_SATURATION_PX);
const diameter = widthPixels + strokeWidthPixels;
return diameter / 2;
}
_computeLineWidthScale (feature, viz) {
const diameter = Math.min(viz.width.eval(feature), SIZE_SATURATION_PX);
return diameter / 2 / this.scale / this._resolutionForZoomLevel();
}
_computePolygonWidthScale (feature, viz) {
const diameter = Math.min(viz.strokeWidth.eval(feature), SIZE_SATURATION_PX);
return diameter / 2 / this.scale / this._resolutionForZoomLevel();
}
_resolutionForZoomLevel () {
return (Math.pow(2, this.renderer.drawMetadata.zoomLevel) * _constants_layer__WEBPACK_IMPORTED_MODULE_3__["RESOLUTION_ZOOMLEVEL_ZERO"]);
}
}
/***/ }),
/***/ "./src/renderer/dataframe/viewportFeature.js":
/*!***************************************************!*\
!*** ./src/renderer/dataframe/viewportFeature.js ***!
\***************************************************/
/*! exports provided: genViewportFeatureClass */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "genViewportFeatureClass", function() { return genViewportFeatureClass; });
/**
* Function to create dynamically a ViewportFeature class, with the proper getters
* to access its properties, as declared in the `metadata`
*/
function genViewportFeatureClass (metadata) {
const classTemplate = class ViewportFeature {
constructor (index, dataframe) {
this._index = index;
this._dataframe = dataframe;
}
};
Object.defineProperties(classTemplate.prototype, buildGettersFrom(metadata));
return classTemplate;
}
function buildGettersFrom (metadata) {
const getters = {};
metadata.propertyKeys.forEach(propertyName => {
const codec = metadata.codec(propertyName);
if (codec.isRange()) {
const decodedProperties = metadata.decodedProperties(propertyName);
getters[propertyName] = {
get: function () {
const index = this._index;
const args = decodedProperties.map(name => this._dataframe.properties[name][index]);
return codec.internalToExternal(metadata, args);
}
};
} else {
getters[propertyName] = {
get: function () {
const index = this._index;
const value = this._dataframe.properties[propertyName][index];
return codec.internalToExternal(metadata, value);
}
};
}
});
return getters;
}
/***/ }),
/***/ "./src/renderer/decoder/common.js":
/*!****************************************!*\
!*** ./src/renderer/decoder/common.js ***!
\****************************************/
/*! exports provided: addLineString, resizeBuffer */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addLineString", function() { return addLineString; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resizeBuffer", function() { return resizeBuffer; });
/* harmony import */ var _utils_geometry__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils/geometry */ "./src/utils/geometry.js");
/**
* Create a triangulated lineString: zero-sized, vertex-shader expanded triangle list
* with `miter` joins. For angle < 60 joins are automatically adjusted to `bevel`.
* https://github.com/CartoDB/carto-vl/wiki/Line-rendering
*/
function addLineString (lineString, geomBuffer, index, isPolygon, skipCallback) {
let prevPoint, currentPoint;
let prevNormal, nextNormal;
let drawLine;
// We need at least two points
if (lineString.length >= 4) {
// Initialize the first two points
prevPoint = [lineString[0], lineString[1]];
let i = 2;
// The second point may be the same as the first one, iterate to find the first different one
for (;i <= lineString.length; i += 2) {
currentPoint = [lineString[i], lineString[i + 1]];
if (prevPoint[0] !== currentPoint[0] || prevPoint[1] !== currentPoint[1]) {
i += 2;
break;
}
}
prevNormal = Object(_utils_geometry__WEBPACK_IMPORTED_MODULE_0__["getLineNormal"])(prevPoint, currentPoint);
for (;i <= lineString.length; i += 2) {
drawLine = !(skipCallback && skipCallback(i));
let nextPoint;
// With lines, the ending point won't have a nextPoint
if (i <= lineString.length - 2) {
nextPoint = [lineString[i], lineString[i + 1]];
} else if (isPolygon) {
nextPoint = [lineString[2], lineString[3]];
}
if (drawLine &&
!(prevPoint[0] === currentPoint[0] && prevPoint[1] === currentPoint[1])) {
// First triangle
geomBuffer.vertices[index] = prevPoint[0];
geomBuffer.normals[index++] = -prevNormal[0];
geomBuffer.vertices[index] = prevPoint[1];
geomBuffer.normals[index++] = -prevNormal[1];
geomBuffer.vertices[index] = prevPoint[0];
geomBuffer.normals[index++] = prevNormal[0];
geomBuffer.vertices[index] = prevPoint[1];
geomBuffer.normals[index++] = prevNormal[1];
geomBuffer.vertices[index] = currentPoint[0];
geomBuffer.normals[index++] = prevNormal[0];
geomBuffer.vertices[index] = currentPoint[1];
geomBuffer.normals[index++] = prevNormal[1];
// Second triangle
geomBuffer.vertices[index] = prevPoint[0];
geomBuffer.normals[index++] = -prevNormal[0];
geomBuffer.vertices[index] = prevPoint[1];
geomBuffer.normals[index++] = -prevNormal[1];
geomBuffer.vertices[index] = currentPoint[0];
geomBuffer.normals[index++] = prevNormal[0];
geomBuffer.vertices[index] = currentPoint[1];
geomBuffer.normals[index++] = prevNormal[1];
geomBuffer.vertices[index] = currentPoint[0];
geomBuffer.normals[index++] = -prevNormal[0];
geomBuffer.vertices[index] = currentPoint[1];
geomBuffer.normals[index++] = -prevNormal[1];
}
if (nextPoint && !(nextPoint[0] === currentPoint[0] && nextPoint[1] === currentPoint[1])) {
nextNormal = Object(_utils_geometry__WEBPACK_IMPORTED_MODULE_0__["getLineNormal"])(currentPoint, nextPoint);
if (drawLine) {
// `turnLeft` indicates that the nextLine turns to the left
// `joinNormal` contains the direction and size for the `miter` vertex
// If this is not defined means that the join must be `bevel`.
let { turnLeft, joinNormal } = Object(_utils_geometry__WEBPACK_IMPORTED_MODULE_0__["getJoinNormal"])(prevNormal, nextNormal);
let leftNormal = turnLeft ? prevNormal : Object(_utils_geometry__WEBPACK_IMPORTED_MODULE_0__["neg"])(nextNormal);
let rightNormal = turnLeft ? nextNormal : Object(_utils_geometry__WEBPACK_IMPORTED_MODULE_0__["neg"])(prevNormal);
// Third triangle
geomBuffer.vertices[index] = currentPoint[0];
geomBuffer.normals[index++] = 0;
geomBuffer.vertices[index] = currentPoint[1];
// Mark vertex to be stroke in PolygonShader with the
// non-zero value 1e-37, so it validates the expression
// `normal != vec2(0.)` without affecting the vertex position.
geomBuffer.normals[index++] = isPolygon ? 1e-37 : 0;
geomBuffer.vertices[index] = currentPoint[0];
geomBuffer.normals[index++] = leftNormal[0];
geomBuffer.vertices[index] = currentPoint[1];
geomBuffer.normals[index++] = leftNormal[1];
geomBuffer.vertices[index] = currentPoint[0];
geomBuffer.normals[index++] = rightNormal[0];
geomBuffer.vertices[index] = currentPoint[1];
geomBuffer.normals[index++] = rightNormal[1];
if (joinNormal) {
// Forth triangle
geomBuffer.vertices[index] = currentPoint[0];
geomBuffer.normals[index++] = joinNormal[0];
geomBuffer.vertices[index] = currentPoint[1];
geomBuffer.normals[index++] = joinNormal[1];
geomBuffer.vertices[index] = currentPoint[0];
geomBuffer.normals[index++] = rightNormal[0];
geomBuffer.vertices[index] = currentPoint[1];
geomBuffer.normals[index++] = rightNormal[1];
geomBuffer.vertices[index] = currentPoint[0];
geomBuffer.normals[index++] = leftNormal[0];
geomBuffer.vertices[index] = currentPoint[1];
geomBuffer.normals[index++] = leftNormal[1];
}
}
} else {
nextNormal = prevNormal;
}
// Update the variables for the next iteration
prevPoint = currentPoint;
currentPoint = nextPoint;
prevNormal = nextNormal;
}
}
return index;
}
/**
* Resize a Float32Array buffer in an efficient way
*/
function resizeBuffer (oldBuffer, newSize) {
const newBuffer = new Float32Array(newSize);
newBuffer.set(oldBuffer);
return newBuffer;
}
/***/ }),
/***/ "./src/renderer/decoder/index.js":
/*!***************************************!*\
!*** ./src/renderer/decoder/index.js ***!
\***************************************/
/*! exports provided: decodeGeom */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "decodeGeom", function() { return decodeGeom; });
/* harmony import */ var _pointDecoder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointDecoder */ "./src/renderer/decoder/pointDecoder.js");
/* harmony import */ var _lineDecoder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lineDecoder */ "./src/renderer/decoder/lineDecoder.js");
/* harmony import */ var _polygonDecoder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./polygonDecoder */ "./src/renderer/decoder/polygonDecoder.js");
/* harmony import */ var _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../errors/carto-runtime-error */ "./src/errors/carto-runtime-error.js");
/* harmony import */ var _utils_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../utils/geometry */ "./src/utils/geometry.js");
function decodeGeom (geomType, geom) {
switch (geomType) {
case _utils_geometry__WEBPACK_IMPORTED_MODULE_4__["GEOMETRY_TYPE"].POINT:
return Object(_pointDecoder__WEBPACK_IMPORTED_MODULE_0__["decodePoint"])(geom);
case _utils_geometry__WEBPACK_IMPORTED_MODULE_4__["GEOMETRY_TYPE"].LINE:
return Object(_lineDecoder__WEBPACK_IMPORTED_MODULE_1__["decodeLine"])(geom);
case _utils_geometry__WEBPACK_IMPORTED_MODULE_4__["GEOMETRY_TYPE"].POLYGON:
return Object(_polygonDecoder__WEBPACK_IMPORTED_MODULE_2__["decodePolygon"])(geom);
default:
throw new _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_3__["default"](
`Unimplemented geometry type: '${geomType}'.`,
_errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_3__["CartoRuntimeErrorTypes"].NOT_SUPPORTED
);
}
}
/***/ }),
/***/ "./src/renderer/decoder/lineDecoder.js":
/*!*********************************************!*\
!*** ./src/renderer/decoder/lineDecoder.js ***!
\*********************************************/
/*! exports provided: decodeLine */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "decodeLine", function() { return decodeLine; });
/* harmony import */ var _common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common */ "./src/renderer/decoder/common.js");
// If the geometry type is GEOMETRY_TYPE.LINE it will generate the appropriate zero-sized, vertex-shader expanded triangle list with `miter` and `bevel` joins.
// The geom will be an array of coordinates in this case
const STATIC_INITIAL_BUFFER_SIZE = 1024 * 1024; // 4 MB
const MAX_VERTICES_COORDINATES_PER_SEGMENT = 24;
let index = 0;
let geomBuffer = {
vertices: new Float32Array(STATIC_INITIAL_BUFFER_SIZE),
normals: new Float32Array(STATIC_INITIAL_BUFFER_SIZE)
};
function decodeLine (geometry) {
let breakpoints = []; // Array of indices (to vertexArray) that separate each feature
let featureIDToVertexIndex = new Map();
index = 0;
for (let i = 0; i < geometry.length; i++) {
const feature = geometry[i];
for (let j = 0; j < feature.length; j++) {
// Increase buffers size if required
resizeBuffers(MAX_VERTICES_COORDINATES_PER_SEGMENT * feature[j].length);
// Add line string
index = Object(_common__WEBPACK_IMPORTED_MODULE_0__["addLineString"])(feature[j], geomBuffer, index);
}
featureIDToVertexIndex.set(breakpoints.length, breakpoints.length === 0
? { start: 0, end: index }
: { start: featureIDToVertexIndex.get(breakpoints.length - 1).end, end: index });
breakpoints.push(index);
}
const verticesArrayBuffer = new ArrayBuffer(4 * index);
const normalsArrayBuffer = new ArrayBuffer(4 * index);
const vertices = new Float32Array(verticesArrayBuffer);
const normals = new Float32Array(normalsArrayBuffer);
for (let i = 0; i < index; i++) {
vertices[i] = geomBuffer.vertices[i];
normals[i] = geomBuffer.normals[i];
}
return {
vertices,
normals,
verticesArrayBuffer,
normalsArrayBuffer,
featureIDToVertexIndex,
breakpoints
};
}
// Resize buffers as needed if `additionalSize` floats overflow the current buffers.
function resizeBuffers (additionalSize) {
const minimumNeededSize = index + additionalSize;
if (minimumNeededSize > geomBuffer.vertices.length) {
const newSize = 2 * minimumNeededSize;
geomBuffer.vertices = Object(_common__WEBPACK_IMPORTED_MODULE_0__["resizeBuffer"])(geomBuffer.vertices, newSize);
geomBuffer.normals = Object(_common__WEBPACK_IMPORTED_MODULE_0__["resizeBuffer"])(geomBuffer.normals, newSize);
}
}
/***/ }),
/***/ "./src/renderer/decoder/pointDecoder.js":
/*!**********************************************!*\
!*** ./src/renderer/decoder/pointDecoder.js ***!
\**********************************************/
/*! exports provided: decodePoint */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "decodePoint", function() { return decodePoint; });
// If the geometry type is GEOMETRY_TYPE.POINT it will pass through the geom (the vertex array)
function decodePoint (verticesArrayBuffer) {
return {
verticesArrayBuffer: verticesArrayBuffer,
vertices: new Float32Array(verticesArrayBuffer),
breakpoints: []
};
}
/***/ }),
/***/ "./src/renderer/decoder/polygonDecoder.js":
/*!************************************************!*\
!*** ./src/renderer/decoder/polygonDecoder.js ***!
\************************************************/
/*! exports provided: decodePolygon */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "decodePolygon", function() { return decodePolygon; });
/* harmony import */ var earcut__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! earcut */ "./node_modules/earcut/src/earcut.js");
/* harmony import */ var earcut__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(earcut__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./common */ "./src/renderer/decoder/common.js");
// If the geometry type is GEOMETRY_TYPE.POLYGON it will triangulate the polygon list (geom)
// geom will be a list of polygons in which each polygon will have a flat array of vertices and a list of holes indices
// Example:
/* let geom = [{
flat: [
0.,0., 1.,0., 1.,1., 0.,1., 0.,0, //A square
0.25,0.25, 0.75,0.25, 0.75,0.75, 0.25,0.75, 0.25,0.25//A small square
]
holes: [5]
}]
*/
const STATIC_INITIAL_BUFFER_SIZE = 1024 * 1024 * 2; // 8 MB
const VERTEX_COORDINATES_PER_TRIANGLE = 2;
const MAX_VERTICES_COORDINATES_PER_SEGMENT = 24;
let index = 0;
let geomBuffer = {
vertices: new Float32Array(STATIC_INITIAL_BUFFER_SIZE),
normals: new Float32Array(STATIC_INITIAL_BUFFER_SIZE)
};
function decodePolygon (geometry) {
let breakpoints = []; // Array of indices (to vertexArray) that separate each feature
let featureIDToVertexIndex = new Map();
index = 0;
for (let i = 0; i < geometry.length; i++) {
const feature = geometry[i];
for (let j = 0; j < feature.length; j++) {
const polygon = feature[j];
const triangles = earcut__WEBPACK_IMPORTED_MODULE_0__(polygon.flat, polygon.holes);
// Increase buffers size if required
resizeBuffers(VERTEX_COORDINATES_PER_TRIANGLE * triangles.length +
MAX_VERTICES_COORDINATES_PER_SEGMENT * polygon.flat.length);
// Add polygon
for (let k = 0; k < triangles.length; k++) {
addVertex(polygon.flat, 2 * triangles[k]);
}
// Add polygon stroke
index = Object(_common__WEBPACK_IMPORTED_MODULE_1__["addLineString"])(polygon.flat, geomBuffer, index, true, (pointIndex) => {
// Skip adding the line which connects two rings OR is clipped
return polygon.holes.includes((pointIndex - 2) / 2) || isClipped(polygon, pointIndex - 4, pointIndex - 2);
});
}
featureIDToVertexIndex.set(breakpoints.length, breakpoints.length === 0
? { start: 0, end: index }
: { start: featureIDToVertexIndex.get(breakpoints.length - 1).end, end: index });
breakpoints.push(index);
}
const verticesArrayBuffer = new ArrayBuffer(4 * index);
const normalsArrayBuffer = new ArrayBuffer(4 * index);
const vertices = new Float32Array(verticesArrayBuffer);
const normals = new Float32Array(normalsArrayBuffer);
for (let i = 0; i < index; i++) {
vertices[i] = geomBuffer.vertices[i];
normals[i] = geomBuffer.normals[i];
}
return {
vertices,
normals,
verticesArrayBuffer,
normalsArrayBuffer,
featureIDToVertexIndex,
breakpoints
};
}
// Resize buffers as needed if `additionalSize` floats overflow the current buffers
function resizeBuffers (additionalSize) {
const minimumNeededSize = index + additionalSize;
if (minimumNeededSize > geomBuffer.vertices.length) {
const newSize = 2 * minimumNeededSize;
geomBuffer.vertices = Object(_common__WEBPACK_IMPORTED_MODULE_1__["resizeBuffer"])(geomBuffer.vertices, newSize);
geomBuffer.normals = Object(_common__WEBPACK_IMPORTED_MODULE_1__["resizeBuffer"])(geomBuffer.normals, newSize);
}
}
// Add vertex in triangles.
function addVertex (array, vertexIndex) {
geomBuffer.vertices[index] = array[vertexIndex];
geomBuffer.normals[index++] = 0;
geomBuffer.vertices[index] = array[vertexIndex + 1];
geomBuffer.normals[index++] = 0;
}
function isClipped (polygon, i, j) {
if (polygon.clipped.includes(i) && polygon.clipped.includes(j)) {
if (polygon.clippedType[polygon.clipped.indexOf(i)] &
polygon.clippedType[polygon.clipped.indexOf(j)]) {
return true;
}
}
return false;
}
/***/ }),
/***/ "./src/renderer/schema.js":
/*!********************************!*\
!*** ./src/renderer/schema.js ***!
\********************************/
/*! exports provided: IDENTITY, union, equals, notEquals, column, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IDENTITY", function() { return IDENTITY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "union", function() { return union; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "notEquals", function() { return notEquals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "column", function() { return column; });
/* harmony import */ var _constants_metadata__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../constants/metadata */ "./src/constants/metadata.js");
const IDENTITY = {};
/*
const mns = {
price: [{type: 'unaggregated'}],
amount: [{type: 'aggregated', op: 'avg'}, {type: 'aggregated', op: 'max'}}],
dow: [{type: 'dimension', dimension: { group: {units: 'dayOfWeek'}}}]
};
*/
function union (a, b) {
const result = {};
const propertyNames = new Set(Object.keys(a).concat(Object.keys(b)));
propertyNames.forEach(propertyName => {
const aUsages = a[propertyName] || [];
const bUsages = b[propertyName] || [];
const combinedUsage = [...aUsages, ...bUsages];
result[propertyName] = combinedUsage;
});
return result;
}
function equals (a, b) {
if (!a || !b) {
return false;
}
return JSON.stringify(simplify(a)) === JSON.stringify(simplify(b));
}
function notEquals (a, b) {
return !equals(a, b);
}
function simplify (MNS) {
const result = {};
const propertyNames = Object.keys(MNS).sort();
propertyNames.forEach(propertyName => {
// Stringify and Set to remove duplicates
let usage = [...new Set(MNS[propertyName].map(u => JSON.stringify(u)))];
usage.sort();
usage = usage.map(u => JSON.parse(u));
result[propertyName] = usage;
});
return result;
}
// column information functions
const column = {
aggColumn (name, aggFN) {
return `${_constants_metadata__WEBPACK_IMPORTED_MODULE_0__["AGG_PREFIX"]}${aggFN}_${name}`;
},
dimColumn (name, groupBy) {
return `${_constants_metadata__WEBPACK_IMPORTED_MODULE_0__["DIM_PREFIX"]}${groupBy}_${name}`;
}
};
/* harmony default export */ __webpack_exports__["default"] = ({ column, equals, notEquals, union, IDENTITY, simplify });
/***/ }),
/***/ "./src/renderer/shaders/Cache.js":
/*!***************************************!*\
!*** ./src/renderer/shaders/Cache.js ***!
\***************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Cache; });
/**
* Keep a cacheTo avoid recompiling webgl programs and shaders.
* We need a different shader per webgl context so we use a 2 level cache where at the first level
* the webgl context is the key and at the second level the shader code is the cache key.
*/
class Cache {
constructor () {
this.caches = new WeakMap();
}
get (gl, shadercode) {
if (this.caches.has(gl)) {
let cache = this.caches.get(gl);
return cache[shadercode];
}
}
set (gl, shadercode, shader) {
if (this.caches.has(gl)) {
let cache = this.caches.get(gl);
cache[shadercode] = shader;
} else {
let cache = {};
cache[shadercode] = shader;
this.caches.set(gl, cache);
}
}
has (gl, shadercode) {
return this.get(gl, shadercode) !== undefined;
}
}
/***/ }),
/***/ "./src/renderer/shaders/common/antialiasing/AntiAliasingShader.js":
/*!************************************************************************!*\
!*** ./src/renderer/shaders/common/antialiasing/AntiAliasingShader.js ***!
\************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return AntiAliasingShader; });
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils */ "./src/renderer/shaders/utils.js");
/* harmony import */ var _antialiasingFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./antialiasingFragmentShader.glsl */ "./src/renderer/shaders/common/antialiasing/antialiasingFragmentShader.glsl");
/* harmony import */ var _antialiasingFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_antialiasingFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _antialiasingVertexShader_glsl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./antialiasingVertexShader.glsl */ "./src/renderer/shaders/common/antialiasing/antialiasingVertexShader.glsl");
/* harmony import */ var _antialiasingVertexShader_glsl__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_antialiasingVertexShader_glsl__WEBPACK_IMPORTED_MODULE_2__);
class AntiAliasingShader {
constructor (gl) {
Object.assign(this, Object(_utils__WEBPACK_IMPORTED_MODULE_0__["compileProgram"])(gl, _antialiasingVertexShader_glsl__WEBPACK_IMPORTED_MODULE_2___default.a, _antialiasingFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_1___default.a));
this.vertexAttribute = gl.getAttribLocation(this.program, 'vertex');
this.readTU = gl.getUniformLocation(this.program, 'aaTex');
}
}
/***/ }),
/***/ "./src/renderer/shaders/common/antialiasing/antialiasingFragmentShader.glsl":
/*!**********************************************************************************!*\
!*** ./src/renderer/shaders/common/antialiasing/antialiasingFragmentShader.glsl ***!
\**********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "precision highp float;\n\nvarying vec2 uv;\n\nuniform sampler2D aaTex;\n\nvoid main(void) {\n vec4 aa = texture2D(aaTex, uv);\n gl_FragColor = aa;\n}\n"
/***/ }),
/***/ "./src/renderer/shaders/common/antialiasing/antialiasingVertexShader.glsl":
/*!********************************************************************************!*\
!*** ./src/renderer/shaders/common/antialiasing/antialiasingVertexShader.glsl ***!
\********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "precision highp float;\nattribute vec2 vertex;\n\nvarying vec2 uv;\n\nvoid main(void) {\n uv = vertex*0.5+vec2(0.5);\n gl_Position = vec4(vertex, 0.5, 1.);\n}\n"
/***/ }),
/***/ "./src/renderer/shaders/geometry/line/lineFragmentShader.glsl":
/*!********************************************************************!*\
!*** ./src/renderer/shaders/geometry/line/lineFragmentShader.glsl ***!
\********************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "precision highp float;\n\nvarying lowp vec4 color;\n\nvoid main(void) {\n gl_FragColor = color;\n}\n"
/***/ }),
/***/ "./src/renderer/shaders/geometry/line/lineVertexShader.glsl":
/*!******************************************************************!*\
!*** ./src/renderer/shaders/geometry/line/lineVertexShader.glsl ***!
\******************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "// Line Vertex Shader\nprecision highp float;\n\nattribute vec2 vertexPosition;\nattribute vec2 featureID;\nattribute vec2 normal;\n\nuniform float normalScale;\nuniform vec2 resolution;\nuniform mat4 matrix;\n\nuniform sampler2D colorTex;\nuniform sampler2D widthTex;\nuniform sampler2D filterTex;\n\nvarying lowp vec4 color;\n\nfloat decodeWidth(vec2 enc) {\n return enc.x*(255.*4.) + 4.*enc.y;\n}\n\n$propertyPreface\n$transform_preface\n\nvoid main(void) {\n color = texture2D(colorTex, featureID);\n float filtering = texture2D(filterTex, featureID).a;\n color.a *= filtering;\n color.rgb *= color.a; // premultiplied-alpha\n float size = decodeWidth(texture2D(widthTex, featureID).rg);\n\n // 64 is computed based on RTT_WIDTH and the depth buffer precision\n // 64 = 2^(BUFFER_BITS)/RTT_WIDTH = 2^16/1024 = 64\n float z = featureID.y * 63. / 64. + featureID.x / (64.);\n\n // Set z range (-1, 1)\n z = z * 2. - 1.;\n\n vec2 n = normal*size*normalScale;\n vec4 p = matrix*vec4(vertexPosition+n, 0., 1.);\n p/=p.w;\n\n p.xy = $transform_inline(p.xy*resolution)/resolution;\n if (size==0. || color.a==0.){\n p.x=10000.;\n }\n p.z=z;\n gl_Position = p;\n}\n"
/***/ }),
/***/ "./src/renderer/shaders/geometry/point/pointFragmentShader.glsl":
/*!**********************************************************************!*\
!*** ./src/renderer/shaders/geometry/point/pointFragmentShader.glsl ***!
\**********************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "precision highp float;\n\nvarying lowp vec4 color;\nvarying lowp vec4 stroke;\nvarying highp float dp;\nvarying highp float fillScale;\nvarying highp float strokeScale;\nvarying highp vec2 pointCoord;\n\nfloat distanceAntialias(vec2 p){\n // return length(p) > 1 ? 0. : 1. ; // to disable antialias\n return 1. - smoothstep(1.-dp*1.4142, 1.+dp*1.4142, length(p));\n}\n\nvoid main(void) {\n vec2 p = pointCoord;\n vec4 c = color;\n\n vec4 s = stroke;\n\n c.a *= distanceAntialias(p*fillScale);\n c.rgb*=c.a;\n\n s.a *= distanceAntialias(p);\n s.a *= 1.-distanceAntialias((strokeScale)*p);\n s.rgb*=s.a;\n\n c=s+(1.-s.a)*c;\n\n gl_FragColor = c;\n}\n"
/***/ }),
/***/ "./src/renderer/shaders/geometry/point/pointVertexShader.glsl":
/*!********************************************************************!*\
!*** ./src/renderer/shaders/geometry/point/pointVertexShader.glsl ***!
\********************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "precision highp float;\n\nattribute vec2 vertexPosition;\nattribute vec2 featureID;\n\nuniform float orderMinWidth;\nuniform float orderMaxWidth;\nuniform vec2 resolution;\nuniform mat4 matrix;\n\nuniform sampler2D colorTex;\nuniform sampler2D widthTex;\nuniform sampler2D strokeColorTex;\nuniform sampler2D strokeWidthTex;\nuniform sampler2D filterTex;\n\nvarying highp vec4 color;\nvarying highp vec4 stroke;\nvarying highp float dp;\nvarying highp float fillScale;\nvarying highp float strokeScale;\nvarying highp vec2 pointCoord;\n\nfloat decodeWidth(vec2 enc) {\n return enc.x*(255.*4.) + 4.*enc.y;\n}\n\n$propertyPreface\n$transform_preface\n\nvec2 transform(vec2 p){\n return $transform_inline(p*resolution*0.5)/resolution*2.;\n}\n\nvoid main(void) {\n color = texture2D(colorTex, abs(featureID));\n stroke = texture2D(strokeColorTex, abs(featureID));\n float filtering = texture2D(filterTex, abs(featureID)).a;\n color.a *= filtering;\n stroke.a *= filtering;\n float size = decodeWidth(texture2D(widthTex, abs(featureID)).rg);\n float fillSize = size;\n float strokeSize = decodeWidth(texture2D(strokeWidthTex, abs(featureID)).rg);\n size += strokeSize;\n fillScale = min(size / fillSize, 1.);\n strokeScale = size / max(0.001, (fillSize - strokeSize));\n if (fillScale == strokeScale) {\n stroke.a = 0.;\n }\n dp = 1.0 / (size + 1.);\n float sizeNormalizer = (size +1.)/size;\n\n vec4 p = matrix*vec4(vertexPosition, 0., 1.);\n p/=p.w;\n vec2 size2 = (2.*size+4.)/resolution;\n\n if (featureID.y<0.){\n pointCoord = vec2(0.866025, -0.5)*2.*sizeNormalizer;\n p.xy += transform(size2*vec2(0.866025, -0.5));\n }else if (featureID.x<0.){\n pointCoord = vec2(-0.866025, -0.5)*2.*sizeNormalizer;\n p.xy += transform(size2*vec2(-0.866025, -0.5));\n }else{\n pointCoord = vec2(0., 1.)*2.*sizeNormalizer;\n p.xy += transform(vec2(0.,size2.y));\n }\n\n if (size == 0. || (stroke.a == 0. && color.a == 0.) || size < orderMinWidth || size >= orderMaxWidth) {\n p.z = p.w*2.;\n }\n\n gl_Position = p;\n}\n"
/***/ }),
/***/ "./src/renderer/shaders/geometry/polygon/polygonFragmentShader.glsl":
/*!**************************************************************************!*\
!*** ./src/renderer/shaders/geometry/polygon/polygonFragmentShader.glsl ***!
\**************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "precision lowp float;\n\nvarying lowp vec4 color;\n\nvoid main(void) {\n gl_FragColor = color;\n}\n"
/***/ }),
/***/ "./src/renderer/shaders/geometry/polygon/polygonVertexShader.glsl":
/*!************************************************************************!*\
!*** ./src/renderer/shaders/geometry/polygon/polygonVertexShader.glsl ***!
\************************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "precision mediump float;\n\nattribute vec2 vertexPosition;\nattribute vec2 featureID;\nattribute vec2 normal;\n\nuniform float normalScale;\nuniform vec2 resolution;\n\nuniform sampler2D colorTex;\nuniform sampler2D strokeColorTex;\nuniform sampler2D strokeWidthTex;\nuniform sampler2D filterTex;\nuniform mat4 matrix;\n\nvarying lowp vec4 color;\n\nfloat decodeWidth(vec2 enc) {\n return enc.x*(255.*4.) + 4.*enc.y;\n}\n\n$propertyPreface\n$transform_preface\n\nvoid main(void) {\n // 64 is computed based on RTT_WIDTH and the depth buffer precision\n // 64 = 2^(BUFFER_BITS)/RTT_WIDTH = 2^16/1024 = 64\n float z = featureID.y * 63. / 64. + featureID.x / 64.;\n\n vec4 c;\n if (normal == vec2(0.)){\n c = texture2D(colorTex, featureID);\n }else{\n z = mod(z + (z > 0.5 ? -1./64. : 1./64.), 1.);\n c = texture2D(strokeColorTex, featureID);\n }\n z = 2.*z - 1.;\n float filtering = texture2D(filterTex, featureID).a;\n c.a *= filtering;\n float size = decodeWidth(texture2D(strokeWidthTex, featureID).rg);\n\n vec2 n = normal*size*normalScale;\n vec4 p = matrix*vec4(vertexPosition+n, 0., 1.);\n p/=p.w;\n\n p.xy = $transform_inline(p.xy*resolution*0.5)/resolution*2.;\n\n if (c.a==0.){\n p.x=10000.;\n }\n p.z=z;\n color = vec4(c.rgb*c.a, c.a);\n gl_Position = p;\n}\n"
/***/ }),
/***/ "./src/renderer/shaders/index.js":
/*!***************************************!*\
!*** ./src/renderer/shaders/index.js ***!
\***************************************/
/*! exports provided: styler, symbolizer, AABlender, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AABlender", function() { return AABlender; });
/* harmony import */ var _common_antialiasing_AntiAliasingShader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common/antialiasing/AntiAliasingShader */ "./src/renderer/shaders/common/antialiasing/AntiAliasingShader.js");
/* harmony import */ var _styler_stylerShaders__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./styler/stylerShaders */ "./src/renderer/shaders/styler/stylerShaders.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "styler", function() { return _styler_stylerShaders__WEBPACK_IMPORTED_MODULE_1__; });
/* harmony import */ var _symbolizer_symbolizerShaders__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./symbolizer/symbolizerShaders */ "./src/renderer/shaders/symbolizer/symbolizerShaders.js");
/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "symbolizer", function() { return _symbolizer_symbolizerShaders__WEBPACK_IMPORTED_MODULE_2__; });
const AABlender = _common_antialiasing_AntiAliasingShader__WEBPACK_IMPORTED_MODULE_0__["default"];
/* harmony default export */ __webpack_exports__["default"] = ({
styler: _styler_stylerShaders__WEBPACK_IMPORTED_MODULE_1__,
symbolizer: _symbolizer_symbolizerShaders__WEBPACK_IMPORTED_MODULE_2__,
AABlender
});
/***/ }),
/***/ "./src/renderer/shaders/shaderCompiler.js":
/*!************************************************!*\
!*** ./src/renderer/shaders/shaderCompiler.js ***!
\************************************************/
/*! exports provided: compileShader */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compileShader", function() { return compileShader; });
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./src/renderer/shaders/utils.js");
class IDGenerator {
constructor () {
this._ids = new Map();
}
getID (expression) {
if (this._ids.has(expression)) {
return this._ids.get(expression);
}
const id = this._ids.size;
this._ids.set(expression, id);
return id;
}
}
function compileShader (gl, template, expressions) {
let tid = {};
const getPropertyAccessCode = name => {
if (tid[name] === undefined) {
tid[name] = Object.keys(tid).length;
}
return `texture2D(propertyTex${tid[name]}, abs(featureID)).a`;
};
let codes = {};
const idGen = new IDGenerator();
Object.keys(expressions).forEach(exprName => {
const expr = expressions[exprName];
expr._setUID(idGen);
const exprCodes = expr._applyToShaderSource(getPropertyAccessCode);
codes[exprName + '_preface'] = exprCodes.preface;
codes[exprName + '_inline'] = exprCodes.inline;
});
codes.propertyPreface = Object.keys(tid).map(name => `uniform sampler2D propertyTex${tid[name]};`).join('\n');
const shader = Object(_utils__WEBPACK_IMPORTED_MODULE_0__["createShaderFromTemplate"])(gl, template, codes);
Object.keys(tid).map(name => {
tid[name] = gl.getUniformLocation(shader.program, `propertyTex${tid[name]}`);
});
Object.values(expressions).forEach(expr => {
expr._postShaderCompile(shader.program, gl);
});
return {
shader,
textureIds: tid,
_codes: codes,
_template: template
};
}
/***/ }),
/***/ "./src/renderer/shaders/styler/stylerEncodeWidth.glsl":
/*!************************************************************!*\
!*** ./src/renderer/shaders/styler/stylerEncodeWidth.glsl ***!
\************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "vec2 encodeWidth(float x) {\n if (!(x<=0. || x>=0.) ){\n // Convert NaN widths to `0`\n // Do not remove this, some GPUs will convert NaN floats to 1. when\n // packing the shader output to a RGBA UNSIGNED BYTE textures\n x = 0.;\n }\n float high, low;\n x = clamp(x, 0., 1023.);\n high = floor(x/4.);\n low = (x-high*4.)/4.;\n return vec2(high/255., low);\n}\n\n$width_preface\n"
/***/ }),
/***/ "./src/renderer/shaders/styler/stylerFragmentShader.glsl":
/*!***************************************************************!*\
!*** ./src/renderer/shaders/styler/stylerFragmentShader.glsl ***!
\***************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "precision highp float;\n\nvarying vec2 uv;\n\nvec2 featureID;\n\n$propertyPreface\n$style_preface\n\nvoid main(void) {\n featureID = abs(uv);\n gl_FragColor = $style_inline;\n}\n"
/***/ }),
/***/ "./src/renderer/shaders/styler/stylerShaders.js":
/*!******************************************************!*\
!*** ./src/renderer/shaders/styler/stylerShaders.js ***!
\******************************************************/
/*! exports provided: colorShaderGLSL, filterShaderGLSL, widthShaderGLSL */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorShaderGLSL", function() { return colorShaderGLSL; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterShaderGLSL", function() { return filterShaderGLSL; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "widthShaderGLSL", function() { return widthShaderGLSL; });
/* harmony import */ var _stylerEncodeWidth_glsl__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./stylerEncodeWidth.glsl */ "./src/renderer/shaders/styler/stylerEncodeWidth.glsl");
/* harmony import */ var _stylerEncodeWidth_glsl__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_stylerEncodeWidth_glsl__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _stylerFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stylerFragmentShader.glsl */ "./src/renderer/shaders/styler/stylerFragmentShader.glsl");
/* harmony import */ var _stylerFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_stylerFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _stylerVertexShader_glsl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stylerVertexShader.glsl */ "./src/renderer/shaders/styler/stylerVertexShader.glsl");
/* harmony import */ var _stylerVertexShader_glsl__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_stylerVertexShader_glsl__WEBPACK_IMPORTED_MODULE_2__);
const colorShaderGLSL = {
vertexShader: `${_stylerVertexShader_glsl__WEBPACK_IMPORTED_MODULE_2___default.a}`,
fragmentShader: `${_stylerFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_1___default.a}`
.replace('$style_inline', '$color_inline')
.replace('$style_preface', '$color_preface')
};
const filterShaderGLSL = {
vertexShader: `${_stylerVertexShader_glsl__WEBPACK_IMPORTED_MODULE_2___default.a}`,
fragmentShader: `${_stylerFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_1___default.a}`
.replace('$style_inline', 'vec4($filter_inline)')
.replace('$style_preface', '$filter_preface')
};
const widthShaderGLSL = {
vertexShader: `${_stylerVertexShader_glsl__WEBPACK_IMPORTED_MODULE_2___default.a}`,
fragmentShader: `${_stylerFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_1___default.a}`
.replace('$style_inline', 'vec4(encodeWidth($width_inline), vec2(0.))')
.replace('$style_preface', `${_stylerEncodeWidth_glsl__WEBPACK_IMPORTED_MODULE_0___default.a}`)
};
/***/ }),
/***/ "./src/renderer/shaders/styler/stylerVertexShader.glsl":
/*!*************************************************************!*\
!*** ./src/renderer/shaders/styler/stylerVertexShader.glsl ***!
\*************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "precision highp float;\nattribute vec2 vertex;\n\nvarying vec2 uv;\n\nvoid main(void) {\n uv = vertex*0.5+vec2(0.5);\n gl_Position = vec4(vertex, 0.5, 1.);\n}\n"
/***/ }),
/***/ "./src/renderer/shaders/symbolizer/symbolizerFragmentShader.glsl":
/*!***********************************************************************!*\
!*** ./src/renderer/shaders/symbolizer/symbolizerFragmentShader.glsl ***!
\***********************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "precision highp float;\n\nvarying highp vec2 featureIDVar;\nvarying highp vec4 color;\nvarying highp vec2 pointCoord;\nvarying highp float filtering;\n\n$symbol_preface\n$propertyPreface\n\nvoid main(void) {\n vec2 featureID = abs(featureIDVar);\n vec2 imageUV = pointCoord;\n imageUV.x = imageUV.x * 0.5 + 0.5;\n vec4 symbolColor = $symbol_inline;\n vec4 noOverrideColor = vec4(1., 1., 1., 0.);\n\n vec4 c;\n if (color != noOverrideColor){\n c = color * vec4(vec3(1), symbolColor.a);\n }else{\n c = symbolColor;\n }\n c.a *= filtering;\n if (imageUV!=clamp(imageUV, 0.,1.)){\n c.a = 0.;\n }\n\n gl_FragColor = vec4(c.rgb*c.a, c.a);\n}\n"
/***/ }),
/***/ "./src/renderer/shaders/symbolizer/symbolizerShaders.js":
/*!**************************************************************!*\
!*** ./src/renderer/shaders/symbolizer/symbolizerShaders.js ***!
\**************************************************************/
/*! exports provided: symbolShaderGLSL */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "symbolShaderGLSL", function() { return symbolShaderGLSL; });
/* harmony import */ var _symbolizerFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./symbolizerFragmentShader.glsl */ "./src/renderer/shaders/symbolizer/symbolizerFragmentShader.glsl");
/* harmony import */ var _symbolizerFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_symbolizerFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _symbolizerVertexShader_glsl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./symbolizerVertexShader.glsl */ "./src/renderer/shaders/symbolizer/symbolizerVertexShader.glsl");
/* harmony import */ var _symbolizerVertexShader_glsl__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_symbolizerVertexShader_glsl__WEBPACK_IMPORTED_MODULE_1__);
const symbolShaderGLSL = {
vertexShader: `${_symbolizerVertexShader_glsl__WEBPACK_IMPORTED_MODULE_1___default.a}`,
fragmentShader: `${_symbolizerFragmentShader_glsl__WEBPACK_IMPORTED_MODULE_0___default.a}`
};
/***/ }),
/***/ "./src/renderer/shaders/symbolizer/symbolizerVertexShader.glsl":
/*!*********************************************************************!*\
!*** ./src/renderer/shaders/symbolizer/symbolizerVertexShader.glsl ***!
\*********************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "precision highp float;\n\nattribute vec2 vertexPosition;\nattribute vec2 featureID;\n\nuniform float orderMinWidth;\nuniform float orderMaxWidth;\nuniform float devicePixelRatio;\nuniform vec2 resolution;\nuniform mat4 matrix;\n\nuniform sampler2D colorTex;\nuniform sampler2D widthTex;\nuniform sampler2D filterTex;\n\nvarying highp vec2 featureIDVar;\nvarying highp vec4 color;\nvarying highp vec2 pointCoord;\nvarying highp float filtering;\n\nfloat decodeWidth(vec2 enc) {\n return enc.x*(255.*4.) + 4.*enc.y;\n}\n\n$symbolPlacement_preface\n$propertyPreface\n$transform_preface\n\nvec2 transform(vec2 p){\n return $transform_inline(2.*p)/resolution;\n}\n\n// We'll need a square inscribed in a triangle\n// The triangle will be equilateral\n// The square side length will be equal to 1\n// Each triangle edge length will be equal to 1+2*A (by definition of A)\n// The triangle height will be equal to H by definition\n// The square inscription will generate 3 smaller triangles\n// Each one of these will have an hypotenuse equal to Y\n//\n// Therefore:\n// Y*sin(60) = 1 => Y = 2 / sqrt(3)\n// A=Y*cos(60) => A = 1 / sqrt(3)\n// tan(60) = H / (0.5 + A) => H = sqrt(3)*(0.5 + 1 / sqrt(3))\n#define A (0.577350269189625)\n#define H (1.86603)\n\nvoid main(void) {\n featureIDVar = abs(featureID);\n color = texture2D(colorTex, abs(featureID));\n filtering = texture2D(filterTex, abs(featureID)).a;\n\n float size = decodeWidth(texture2D(widthTex, abs(featureID)).rg);\n\n vec4 p = matrix*vec4(vertexPosition, 0., 1.);\n p/=p.w;\n\n if (featureID.y<0.){\n pointCoord = vec2((0.5+A)/(0.5), 0.);\n p.xy += transform(size*vec2(0.5+A, -H/2. + (H/2. - 0.5) ));\n }else if (featureID.x<0.){\n pointCoord = vec2(-(0.5+A)/(0.5), 0.);\n p.xy += transform(size*vec2(-(0.5+A), -H/2. + (H/2. - 0.5)));\n }else{\n pointCoord = vec2(0., H);\n p.xy += transform(size*vec2(0., H/2. + (H/2. - 0.5)));\n }\n pointCoord.y = 1.-pointCoord.y;\n\n\n p.xy += ($symbolPlacement_inline)*size/resolution;\n\n\n vec4 noOverrideColor = vec4(1., 1., 1., 0.);\n bool alphaButNotOverrideColor = (color.a==0. && color != noOverrideColor);\n\n if (size==0. || alphaButNotOverrideColor || size<orderMinWidth || size>=orderMaxWidth){\n p.x=10000.;\n }\n\n gl_Position = p;\n}\n"
/***/ }),
/***/ "./src/renderer/shaders/utils.js":
/*!***************************************!*\
!*** ./src/renderer/shaders/utils.js ***!
\***************************************/
/*! exports provided: compileProgram, createShaderFromTemplate */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compileProgram", function() { return compileProgram; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createShaderFromTemplate", function() { return createShaderFromTemplate; });
/* harmony import */ var _Cache__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cache */ "./src/renderer/shaders/Cache.js");
/* harmony import */ var _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../errors/carto-runtime-error */ "./src/errors/carto-runtime-error.js");
let programID = 1;
const shaderCache = new _Cache__WEBPACK_IMPORTED_MODULE_0__["default"]();
const programCache = new _Cache__WEBPACK_IMPORTED_MODULE_0__["default"]();
/**
* Compile a webgl program.
* Use a cache to improve speed.
*
* @param {WebGLRenderingContext} gl - The context where the program will be executed
* @param {String} glslvertexShader - vertex shader code
* @param {String} glslfragmentShader - fragment shader code
*/
function compileProgram (gl, glslvertexShader, glslfragmentShader) {
const code = glslvertexShader + glslfragmentShader;
if (programCache.has(gl, code)) {
return programCache.get(gl, code);
}
const shader = {};
const vertexShader = _compileShader(gl, glslvertexShader, gl.VERTEX_SHADER);
const fragmentShader = _compileShader(gl, glslfragmentShader, gl.FRAGMENT_SHADER);
shader.program = gl.createProgram();
gl.attachShader(shader.program, vertexShader);
gl.attachShader(shader.program, fragmentShader);
gl.linkProgram(shader.program);
gl.deleteShader(vertexShader);
gl.deleteShader(fragmentShader);
if (!gl.getProgramParameter(shader.program, gl.LINK_STATUS)) {
throw new _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_1__["default"](`Unable to link the shader program: ${gl.getProgramInfoLog(shader.program)}.`, _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_1__["CartoRuntimeErrorTypes"].WEB_GL);
}
shader.programID = programID++;
programCache.set(gl, code, shader);
return shader;
}
function _compileShader (gl, sourceCode, type) {
if (shaderCache.has(gl, sourceCode)) {
return shaderCache.get(gl, sourceCode);
}
const shader = gl.createShader(type);
gl.shaderSource(shader, sourceCode);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
const log = gl.getShaderInfoLog(shader);
gl.deleteShader(shader);
throw new _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_1__["default"](`An error occurred compiling the shaders: ${log}\nSource:\n${sourceCode}`, _errors_carto_runtime_error__WEBPACK_IMPORTED_MODULE_1__["CartoRuntimeErrorTypes"].WEB_GL);
}
shaderCache.set(gl, sourceCode, shader);
return shader;
}
function createShaderFromTemplate (gl, glslTemplate, codes) {
let vertexShader = glslTemplate.vertexShader;
let fragmentShader = glslTemplate.fragmentShader;
Object.keys(codes).forEach(codeName => {
vertexShader = vertexShader.replace('$' + codeName, codes[codeName]);
fragmentShader = fragmentShader.replace('$' + codeName, codes[codeName]);
});
const shader = compileProgram(gl, vertexShader, fragmentShader);
shader.vertexPositionAttribute = gl.getAttribLocation(shader.program, 'vertexPosition');
shader.featureIdAttr = gl.getAttribLocation(shader.program, 'featureID');
shader.normalAttr = gl.getAttribLocation(shader.program, 'normal');
shader.colorTexture = gl.getUniformLocation(shader.program, 'colorTex');
shader.strokeColorTexture = gl.getUniformLocation(shader.program, 'strokeColorTex');
shader.strokeWidthTexture = gl.getUniformLocation(shader.program, 'strokeWidthTex');
shader.widthTexture = gl.getUniformLocation(shader.program, 'widthTex');
shader.orderMinWidth = gl.getUniformLocation(shader.program, 'orderMinWidth');
shader.orderMaxWidth = gl.getUniformLocation(shader.program, 'orderMaxWidth');
shader.filterTexture = gl.getUniformLocation(shader.program, 'filterTex');
shader.normalScale = gl.getUniformLocation(shader.program, 'normalScale');
shader.resolution = gl.getUniformLocation(shader.program, 'resolution');
shader.matrix = gl.getUniformLocation(shader.program, 'matrix');
return shader;
}
/***/ }),
/***/ "./src/renderer/viz/colorspaces.js":
/*!*****************************************!*\
!*** ./src/renderer/viz/colorspaces.js ***!
\*****************************************/
/*! exports provided: sRGBToCielab, cielabToSRGB, interpolateRGBAinCieLAB */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sRGBToCielab", function() { return sRGBToCielab; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cielabToSRGB", function() { return cielabToSRGB; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRGBAinCieLAB", function() { return interpolateRGBAinCieLAB; });
/* harmony import */ var _expressions_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./expressions/utils */ "./src/renderer/viz/expressions/utils.js");
function sRGBToCielab (srgb) {
return XYZToCieLab(sRGBToXYZ(srgb));
}
function cielabToSRGB (cielab) {
return XYZToSRGB(cielabToXYZ(cielab));
}
function interpolateRGBAinCieLAB (rgbColorA, rgbColorB, m) {
const cielabColorA = sRGBToCielab({
r: rgbColorA.r / 255,
g: rgbColorA.g / 255,
b: rgbColorA.b / 255,
a: rgbColorA.a
});
const cielabColorB = sRGBToCielab({
r: rgbColorB.r / 255,
g: rgbColorB.g / 255,
b: rgbColorB.b / 255,
a: rgbColorB.a
});
const cielabInterpolated = {
l: (1 - m) * cielabColorA.l + m * cielabColorB.l,
a: (1 - m) * cielabColorA.a + m * cielabColorB.a,
b: (1 - m) * cielabColorA.b + m * cielabColorB.b,
alpha: (1 - m) * cielabColorA.alpha + m * cielabColorB.alpha
};
const rgbaColor = cielabToSRGB(cielabInterpolated);
return {
r: Math.round(rgbaColor.r * 255),
g: Math.round(rgbaColor.g * 255),
b: Math.round(rgbaColor.b * 255),
a: rgbaColor.a
};
}
// Following functionality has been inspired by http://www.getreuer.info/home/colorspace
// License:
/*
License (BSD)
Copyright © 2005–2010, Pascal Getreuer
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE U
*/
// Convert sRGB to CIE XYZ with the D65 white point
function sRGBToXYZ (srgb) {
// Poynton, "Frequently Asked Questions About Color," page 10
// Wikipedia: http://en.wikipedia.org/wiki/SRGB
// Wikipedia: http://en.wikipedia.org/wiki/CIE_1931_color_space
const { r, g, b, a } = sRGBToLinearRGB(srgb);
return {
x: (0.4123955889674142161 * r + 0.3575834307637148171 * g + 0.1804926473817015735 * b),
y: (0.2125862307855955516 * r + 0.7151703037034108499 * g + 0.07220049864333622685 * b),
z: (0.01929721549174694484 * r + 0.1191838645808485318 * g + 0.9504971251315797660 * b),
a
};
}
function sRGBToLinearRGB ({ r, g, b, a }) {
// http://en.wikipedia.org/wiki/SRGB
const inverseGammaCorrection = t =>
t <= 0.0404482362771076 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4);
return {
r: inverseGammaCorrection(r),
g: inverseGammaCorrection(g),
b: inverseGammaCorrection(b),
a
};
}
function linearRGBToSRGB ({ r, g, b, a }) {
// http://en.wikipedia.org/wiki/SRGB
const gammaCorrection = t =>
t <= 0.0031306684425005883 ? 12.92 * t : 1.055 * Math.pow(t, 0.416666666666666667) - 0.055;
return {
r: gammaCorrection(r),
g: gammaCorrection(g),
b: gammaCorrection(b),
a
};
}
const WHITEPOINT_D65_X = 0.950456;
const WHITEPOINT_D65_Y = 1.0;
const WHITEPOINT_D65_Z = 1.088754;
// Convert CIE XYZ to CIE L*a*b* (CIELAB) with the D65 white point
function XYZToCieLab ({ x, y, z, a }) {
// Wikipedia: http://en.wikipedia.org/wiki/Lab_color_space
const xn = WHITEPOINT_D65_X;
const yn = WHITEPOINT_D65_Y;
const zn = WHITEPOINT_D65_Z;
const f = t =>
t >= 8.85645167903563082e-3
? Math.pow(t, 0.333333333333333) : (841.0 / 108.0) * t + 4.0 / 29.0;
return {
l: 116 * f(y / yn) - 16,
a: 500 * (f(x / xn) - f(y / yn)),
b: 200 * (f(y / yn) - f(z / zn)),
alpha: a
};
}
// Convert CIE XYZ to sRGB with the D65 white point
function XYZToSRGB ({ x, y, z, a }) {
// Poynton, "Frequently Asked Questions About Color," page 10
// Wikipedia: http://en.wikipedia.org/wiki/SRGB
// Wikipedia: http://en.wikipedia.org/wiki/CIE_1931_color_space
// Convert XYZ to linear RGB
const r = Object(_expressions_utils__WEBPACK_IMPORTED_MODULE_0__["clamp"])(3.2406 * x - 1.5372 * y - 0.4986 * z, 0, 1);
const g = Object(_expressions_utils__WEBPACK_IMPORTED_MODULE_0__["clamp"])(-0.9689 * x + 1.8758 * y + 0.0415 * z, 0, 1);
const b = Object(_expressions_utils__WEBPACK_IMPORTED_MODULE_0__["clamp"])(0.0557 * x - 0.2040 * y + 1.0570 * z, 0, 1);
return linearRGBToSRGB({ r, g, b, a });
}
// Convert CIE L*a*b* (CIELAB) to CIE XYZ with the D65 white point
function cielabToXYZ ({ l, a, b, alpha }) {
// Wikipedia: http://en.wikipedia.org/wiki/Lab_color_space
const f = t =>
((t >= 0.206896551724137931)
? ((t) * (t) * (t)) : (108.0 / 841.0) * ((t) - (4.0 / 29.0)));
return {
x: WHITEPOINT_D65_X * f((l + 16) / 116 + a / 500),
y: WHITEPOINT_D65_Y * f((l + 16) / 116),
z: WHITEPOINT_D65_Z * f((l + 16) / 116 - b / 200),
a: alpha
};
}
/***/ }),
/***/ "./src/renderer/viz/defaultSVGs.js":
/*!*****************************************!*\
!*** ./src/renderer/viz/defaultSVGs.js ***!
\*****************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
const DEFAULT_SYMBOLS_URL = 'https://libs.cartocdn.com/carto-vl/assets/symbols';
const bicycle = `${DEFAULT_SYMBOLS_URL}/bicycle.svg`;
const building = `${DEFAULT_SYMBOLS_URL}/building.svg`;
const bus = `${DEFAULT_SYMBOLS_URL}/bus.svg`;
const car = `${DEFAULT_SYMBOLS_URL}/car.svg`;
const circle = `${DEFAULT_SYMBOLS_URL}/circle.svg`;
const circleOutline = `${DEFAULT_SYMBOLS_URL}/circleOutline.svg`;
const cross = `${DEFAULT_SYMBOLS_URL}/cross.svg`;
const house = `${DEFAULT_SYMBOLS_URL}/house.svg`;
const flag = `${DEFAULT_SYMBOLS_URL}/flag.svg`;
const marker = `${DEFAULT_SYMBOLS_URL}/marker.svg`;
const markerOutline = `${DEFAULT_SYMBOLS_URL}/markerOutline.svg`;
const plus = `${DEFAULT_SYMBOLS_URL}/plus.svg`;
const square = `${DEFAULT_SYMBOLS_URL}/square.svg`;
const squareOutline = `${DEFAULT_SYMBOLS_URL}/squareOutline.svg`;
const star = `${DEFAULT_SYMBOLS_URL}/star.svg`;
const starOutline = `${DEFAULT_SYMBOLS_URL}/starOutline.svg`;
const triangle = `${DEFAULT_SYMBOLS_URL}/triangle.svg`;
const triangleOutline = `${DEFAULT_SYMBOLS_URL}/triangleOutline.svg`;
/* harmony default export */ __webpack_exports__["default"] = ({
bicycle,
building,
bus,
car,
circle,
circleOutline,
cross,
house,
flag,
marker,
markerOutline,
plus,
square,
squareOutline,
star,
starOutline,
triangle,
triangleOutline
});
/***/ }),
/***/ "./src/renderer/viz/expressions.js":
/*!*****************************************!*\
!*** ./src/renderer/viz/expressions.js ***!
\*****************************************/
/*! exports provided: number, category, list, rgb, rgba, transition, nin, in, between, mul, div, add, sub, pow, mod, greaterThan, greaterThanOrEqualTo, lessThan, lessThanOrEqualTo, equals, notEquals, and, or, gt, gte, lt, lte, eq, neq, blend, buckets, cielab, clusterAvg, clusterMax, clusterMin, clusterMode, clusterSum, clusterCount, clusterTime, constant, image, svg, hex, hsl, hsla, hsv, hsva, cubic, ilinear, linear, namedColor, now, opacity, asc, desc, noOrder, width, reverse, property, prop, globalQuantiles, viewportQuantiles, globalEqIntervals, viewportEqIntervals, globalStandardDev, viewportStandardDev, ramp, time, date, timeRange, top, fade, animation, log, sqrt, sin, cos, tan, sign, abs, isNull, not, floor, ceil, variable, var, viewportAvg, viewportMax, viewportMin, viewportSum, viewportCount, viewportPercentile, viewportHistogram, viewportFeatures, globalAvg, globalMax, globalMin, globalSum, globalCount, globalPercentile, globalHistogram, zoom, scaled, zoomrange, placement, translate, rotate, alphaNormalize, HOLD, TRUE, FALSE, PI, E, BICYCLE, BUILDING, BUS, CAR, CIRCLE, CIRCLE_OUTLINE, CROSS, FLAG, HOUSE, MARKER, MARKER_OUTLINE, PLUS, SQUARE, SQUARE_OUTLINE, STAR, STAR_OUTLINE, TRIANGLE, TRIANGLE_OUTLINE, ALIGN_CENTER, ALIGN_BOTTOM, palettes, Asc, Desc */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "number", function() { return number; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "category", function() { return category; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "list", function() { return list; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgb", function() { return rgb; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgba", function() { return rgba; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "transition", function() { return transition; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "nin", function() { return nin; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "in", function() { return in_; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "between", function() { return between; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "div", function() { return div; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pow", function() { return pow; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mod", function() { return mod; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "greaterThan", function() { return greaterThan; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "greaterThanOrEqualTo", function() { return greaterThanOrEqualTo; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lessThan", function() { return lessThan; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lessThanOrEqualTo", function() { return lessThanOrEqualTo; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "notEquals", function() { return notEquals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "and", function() { return and; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "or", function() { return or; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gt", function() { return gt; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gte", function() { return gte; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lt", function() { return lt; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lte", function() { return lte; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "eq", function() { return eq; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "neq", function() { return neq; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blend", function() { return blend; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "buckets", function() { return buckets; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cielab", function() { return cielab; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clusterAvg", function() { return clusterAvg; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clusterMax", function() { return clusterMax; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clusterMin", function() { return clusterMin; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clusterMode", function() { return clusterMode; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clusterSum", function() { return clusterSum; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clusterCount", function() { return clusterCount; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clusterTime", function() { return clusterTime; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "constant", function() { return constant; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "image", function() { return image; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "svg", function() { return svg; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hex", function() { return hex; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hsl", function() { return hsl; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hsla", function() { return hsla; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hsv", function() { return hsv; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hsva", function() { return hsva; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cubic", function() { return cubic; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ilinear", function() { return ilinear; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linear", function() { return linear; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "namedColor", function() { return namedColor; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "now", function() { return now; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "opacity", function() { return opacity; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "asc", function() { return asc; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "desc", function() { return desc; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noOrder", function() { return noOrder; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "width", function() { return width; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reverse", function() { return reverse; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "property", function() { return property; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prop", function() { return property; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "globalQuantiles", function() { return globalQuantiles; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "viewportQuantiles", function() { return viewportQuantiles; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "globalEqIntervals", function() { return globalEqIntervals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "viewportEqIntervals", function() { return viewportEqIntervals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "globalStandardDev", function() { return globalStandardDev; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "viewportStandardDev", function() { return viewportStandardDev; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ramp", function() { return ramp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "time", function() { return time; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "date", function() { return time; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "timeRange", function() { return timeRange; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "top", function() { return top; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fade", function() { return fade; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "animation", function() { return animation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "log", function() { return log; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrt", function() { return sqrt; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sin", function() { return sin; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cos", function() { return cos; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tan", function() { return tan; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sign", function() { return sign; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "abs", function() { return abs; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNull", function() { return isNull; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "not", function() { return not; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "floor", function() { return floor; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ceil", function() { return ceil; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "variable", function() { return variable; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "var", function() { return variable; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "viewportAvg", function() { return viewportAvg; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "viewportMax", function() { return viewportMax; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "viewportMin", function() { return viewportMin; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "viewportSum", function() { return viewportSum; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "viewportCount", function() { return viewportCount; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "viewportPercentile", function() { return viewportPercentile; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "viewportHistogram", function() { return viewportHistogram; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "viewportFeatures", function() { return viewportFeatures; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "globalAvg", function() { return globalAvg; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "globalMax", function() { return globalMax; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "globalMin", function() { return globalMin; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "globalSum", function() { return globalSum; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "globalCount", function() { return globalCount; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "globalPercentile", function() { return globalPercentile; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "globalHistogram", function() { return globalHistogram; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "zoom", function() { return zoom; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scaled", function() { return scaled; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "zoomrange", function() { return zoomrange; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "placement", function() { return placement; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "translate", function() { return translate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rotate", function() { return rotate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "alphaNormalize", function() { return alphaNormalize; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HOLD", function() { return HOLD; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TRUE", function() { return TRUE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FALSE", function() { return FALSE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PI", function() { return PI; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "E", function() { return E; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BICYCLE", function() { return BICYCLE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BUILDING", function() { return BUILDING; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BUS", function() { return BUS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CAR", function() { return CAR; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CIRCLE", function() { return CIRCLE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CIRCLE_OUTLINE", function() { return CIRCLE_OUTLINE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CROSS", function() { return CROSS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FLAG", function() { return FLAG; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HOUSE", function() { return HOUSE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MARKER", function() { return MARKER; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MARKER_OUTLINE", function() { return MARKER_OUTLINE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PLUS", function() { return PLUS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SQUARE", function() { return SQUARE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SQUARE_OUTLINE", function() { return SQUARE_OUTLINE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "STAR", function() { return STAR; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "STAR_OUTLINE", function() { return STAR_OUTLINE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TRIANGLE", function() { return TRIANGLE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TRIANGLE_OUTLINE", function() { return TRIANGLE_OUTLINE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ALIGN_CENTER", function() { return ALIGN_CENTER; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ALIGN_BOTTOM", function() { return ALIGN_BOTTOM; });
/* harmony import */ var _expressions_transition__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./expressions/transition */ "./src/renderer/viz/expressions/transition.js");
/* harmony import */ var _expressions_belongs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./expressions/belongs */ "./src/renderer/viz/expressions/belongs.js");
/* harmony import */ var _expressions_between__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./expressions/between */ "./src/renderer/viz/expressions/between.js");
/* harmony import */ var _expressions_binary_Add__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./expressions/binary/Add */ "./src/renderer/viz/expressions/binary/Add.js");
/* harmony import */ var _expressions_binary_And__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./expressions/binary/And */ "./src/renderer/viz/expressions/binary/And.js");
/* harmony import */ var _expressions_binary_Div__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./expressions/binary/Div */ "./src/renderer/viz/expressions/binary/Div.js");
/* harmony import */ var _expressions_binary_Equals__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./expressions/binary/Equals */ "./src/renderer/viz/expressions/binary/Equals.js");
/* harmony import */ var _expressions_binary_GreaterThan__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./expressions/binary/GreaterThan */ "./src/renderer/viz/expressions/binary/GreaterThan.js");
/* harmony import */ var _expressions_binary_GreaterThanOrEqualTo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./expressions/binary/GreaterThanOrEqualTo */ "./src/renderer/viz/expressions/binary/GreaterThanOrEqualTo.js");
/* harmony import */ var _expressions_binary_LessThan__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./expressions/binary/LessThan */ "./src/renderer/viz/expressions/binary/LessThan.js");
/* harmony import */ var _expressions_binary_LessThanOrEqualTo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./expressions/binary/LessThanOrEqualTo */ "./src/renderer/viz/expressions/binary/LessThanOrEqualTo.js");
/* harmony import */ var _expressions_binary_Mod__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./expressions/binary/Mod */ "./src/renderer/viz/expressions/binary/Mod.js");
/* harmony import */ var _expressions_binary_Mul__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./expressions/binary/Mul */ "./src/renderer/viz/expressions/binary/Mul.js");
/* harmony import */ var _expressions_binary_NotEquals__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./expressions/binary/NotEquals */ "./src/renderer/viz/expressions/binary/NotEquals.js");
/* harmony import */ var _expressions_binary_Or__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./expressions/binary/Or */ "./src/renderer/viz/expressions/binary/Or.js");
/* harmony import */ var _expressions_binary_Pow__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./expressions/binary/Pow */ "./src/renderer/viz/expressions/binary/Pow.js");
/* harmony import */ var _expressions_binary_Sub__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./expressions/binary/Sub */ "./src/renderer/viz/expressions/binary/Sub.js");
/* harmony import */ var _expressions_blend__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./expressions/blend */ "./src/renderer/viz/expressions/blend.js");
/* harmony import */ var _expressions_buckets__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./expressions/buckets */ "./src/renderer/viz/expressions/buckets.js");
/* harmony import */ var _expressions_basic_category__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./expressions/basic/category */ "./src/renderer/viz/expressions/basic/category.js");
/* harmony import */ var _expressions_color_CIELab__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./expressions/color/CIELab */ "./src/renderer/viz/expressions/color/CIELab.js");
/* harmony import */ var _expressions_aggregation_cluster_ClusterAvg__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./expressions/aggregation/cluster/ClusterAvg */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAvg.js");
/* harmony import */ var _expressions_aggregation_cluster_ClusterMax__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./expressions/aggregation/cluster/ClusterMax */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterMax.js");
/* harmony import */ var _expressions_aggregation_cluster_ClusterMin__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./expressions/aggregation/cluster/ClusterMin */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterMin.js");
/* harmony import */ var _expressions_aggregation_cluster_ClusterMode__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./expressions/aggregation/cluster/ClusterMode */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterMode.js");
/* harmony import */ var _expressions_aggregation_cluster_ClusterSum__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./expressions/aggregation/cluster/ClusterSum */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterSum.js");
/* harmony import */ var _expressions_aggregation_cluster_ClusterCount__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./expressions/aggregation/cluster/ClusterCount */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterCount.js");
/* harmony import */ var _expressions_aggregation_cluster_ClusterTime__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./expressions/aggregation/cluster/ClusterTime */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterTime.js");
/* harmony import */ var _expressions_basic_constant__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./expressions/basic/constant */ "./src/renderer/viz/expressions/basic/constant.js");
/* harmony import */ var _expressions_color_hex__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./expressions/color/hex */ "./src/renderer/viz/expressions/color/hex.js");
/* harmony import */ var _expressions_color_hsl__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./expressions/color/hsl */ "./src/renderer/viz/expressions/color/hsl.js");
/* harmony import */ var _expressions_color_hsv__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./expressions/color/hsv */ "./src/renderer/viz/expressions/color/hsv.js");
/* harmony import */ var _expressions_interpolators__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./expressions/interpolators */ "./src/renderer/viz/expressions/interpolators.js");
/* harmony import */ var _expressions_linear__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./expressions/linear */ "./src/renderer/viz/expressions/linear.js");
/* harmony import */ var _expressions_color_NamedColor__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./expressions/color/NamedColor */ "./src/renderer/viz/expressions/color/NamedColor.js");
/* harmony import */ var _expressions_now__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./expressions/now */ "./src/renderer/viz/expressions/now.js");
/* harmony import */ var _expressions_basic_number__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./expressions/basic/number */ "./src/renderer/viz/expressions/basic/number.js");
/* harmony import */ var _expressions_color_Opacity__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./expressions/color/Opacity */ "./src/renderer/viz/expressions/color/Opacity.js");
/* harmony import */ var _expressions_ordering__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./expressions/ordering */ "./src/renderer/viz/expressions/ordering.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Asc", function() { return _expressions_ordering__WEBPACK_IMPORTED_MODULE_38__["Asc"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Desc", function() { return _expressions_ordering__WEBPACK_IMPORTED_MODULE_38__["Desc"]; });
/* harmony import */ var _expressions_color_palettes__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./expressions/color/palettes */ "./src/renderer/viz/expressions/color/palettes.js");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "palettes", function() { return _expressions_color_palettes__WEBPACK_IMPORTED_MODULE_39__["default"]; });
/* harmony import */ var _expressions_reverse_Reverse__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./expressions/reverse/Reverse */ "./src/renderer/viz/expressions/reverse/Reverse.js");
/* harmony import */ var _expressions_basic_property__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./expressions/basic/property */ "./src/renderer/viz/expressions/basic/property.js");
/* harmony import */ var _expressions_classification_GlobalEqIntervals__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./expressions/classification/GlobalEqIntervals */ "./src/renderer/viz/expressions/classification/GlobalEqIntervals.js");
/* harmony import */ var _expressions_classification_GlobalQuantiles__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ./expressions/classification/GlobalQuantiles */ "./src/renderer/viz/expressions/classification/GlobalQuantiles.js");
/* harmony import */ var _expressions_classification_GlobalStandardDev__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ./expressions/classification/GlobalStandardDev */ "./src/renderer/viz/expressions/classification/GlobalStandardDev.js");
/* harmony import */ var _expressions_classification_ViewportEqIntervals__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(/*! ./expressions/classification/ViewportEqIntervals */ "./src/renderer/viz/expressions/classification/ViewportEqIntervals.js");
/* harmony import */ var _expressions_classification_ViewportQuantiles__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(/*! ./expressions/classification/ViewportQuantiles */ "./src/renderer/viz/expressions/classification/ViewportQuantiles.js");
/* harmony import */ var _expressions_classification_ViewportStandardDev__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(/*! ./expressions/classification/ViewportStandardDev */ "./src/renderer/viz/expressions/classification/ViewportStandardDev.js");
/* harmony import */ var _expressions_Ramp__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(/*! ./expressions/Ramp */ "./src/renderer/viz/expressions/Ramp.js");
/* harmony import */ var _expressions_basic_List__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(/*! ./expressions/basic/List */ "./src/renderer/viz/expressions/basic/List.js");
/* harmony import */ var _expressions_color_rgb__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(/*! ./expressions/color/rgb */ "./src/renderer/viz/expressions/color/rgb.js");
/* harmony import */ var _expressions_time__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(/*! ./expressions/time */ "./src/renderer/viz/expressions/time.js");
/* harmony import */ var _expressions_timeRange__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(/*! ./expressions/timeRange */ "./src/renderer/viz/expressions/timeRange.js");
/* harmony import */ var _expressions_top__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(/*! ./expressions/top */ "./src/renderer/viz/expressions/top.js");
/* harmony import */ var _expressions_Fade__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(/*! ./expressions/Fade */ "./src/renderer/viz/expressions/Fade.js");
/* harmony import */ var _expressions_Animation__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(/*! ./expressions/Animation */ "./src/renderer/viz/expressions/Animation.js");
/* harmony import */ var _expressions_unary__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(/*! ./expressions/unary */ "./src/renderer/viz/expressions/unary.js");
/* harmony import */ var _expressions_basic_variable__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(/*! ./expressions/basic/variable */ "./src/renderer/viz/expressions/basic/variable.js");
/* harmony import */ var _expressions_aggregation_viewport_ViewportAvg__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(/*! ./expressions/aggregation/viewport/ViewportAvg */ "./src/renderer/viz/expressions/aggregation/viewport/ViewportAvg.js");
/* harmony import */ var _expressions_aggregation_viewport_ViewportMax__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(/*! ./expressions/aggregation/viewport/ViewportMax */ "./src/renderer/viz/expressions/aggregation/viewport/ViewportMax.js");
/* harmony import */ var _expressions_aggregation_viewport_ViewportMin__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(/*! ./expressions/aggregation/viewport/ViewportMin */ "./src/renderer/viz/expressions/aggregation/viewport/ViewportMin.js");
/* harmony import */ var _expressions_aggregation_viewport_ViewportSum__WEBPACK_IMPORTED_MODULE_61__ = __webpack_require__(/*! ./expressions/aggregation/viewport/ViewportSum */ "./src/renderer/viz/expressions/aggregation/viewport/ViewportSum.js");
/* harmony import */ var _expressions_aggregation_viewport_ViewportCount__WEBPACK_IMPORTED_MODULE_62__ = __webpack_require__(/*! ./expressions/aggregation/viewport/ViewportCount */ "./src/renderer/viz/expressions/aggregation/viewport/ViewportCount.js");
/* harmony import */ var _expressions_aggregation_viewport_ViewportPercentile__WEBPACK_IMPORTED_MODULE_63__ = __webpack_require__(/*! ./expressions/aggregation/viewport/ViewportPercentile */ "./src/renderer/viz/expressions/aggregation/viewport/ViewportPercentile.js");
/* harmony import */ var _expressions_histogram_ViewportHistogram__WEBPACK_IMPORTED_MODULE_64__ = __webpack_require__(/*! ./expressions/histogram/ViewportHistogram */ "./src/renderer/viz/expressions/histogram/ViewportHistogram.js");
/* harmony import */ var _expressions_histogram_GlobalHistogram__WEBPACK_IMPORTED_MODULE_65__ = __webpack_require__(/*! ./expressions/histogram/GlobalHistogram */ "./src/renderer/viz/expressions/histogram/GlobalHistogram.js");
/* harmony import */ var _expressions_viewportFeatures__WEBPACK_IMPORTED_MODULE_66__ = __webpack_require__(/*! ./expressions/viewportFeatures */ "./src/renderer/viz/expressions/viewportFeatures.js");
/* harmony import */ var _expressions_aggregation_global_GlobalAvg__WEBPACK_IMPORTED_MODULE_67__ = __webpack_require__(/*! ./expressions/aggregation/global/GlobalAvg */ "./src/renderer/viz/expressions/aggregation/global/GlobalAvg.js");
/* harmony import */ var _expressions_aggregation_global_GlobalCount__WEBPACK_IMPORTED_MODULE_68__ = __webpack_require__(/*! ./expressions/aggregation/global/GlobalCount */ "./src/renderer/viz/expressions/aggregation/global/GlobalCount.js");
/* harmony import */ var _expressions_aggregation_global_GlobalMax__WEBPACK_IMPORTED_MODULE_69__ = __webpack_require__(/*! ./expressions/aggregation/global/GlobalMax */ "./src/renderer/viz/expressions/aggregation/global/GlobalMax.js");
/* harmony import */ var _expressions_aggregation_global_GlobalMin__WEBPACK_IMPORTED_MODULE_70__ = __webpack_require__(/*! ./expressions/aggregation/global/GlobalMin */ "./src/renderer/viz/expressions/aggregation/global/GlobalMin.js");
/* harmony import */ var _expressions_aggregation_global_GlobalSum__WEBPACK_IMPORTED_MODULE_71__ = __webpack_require__(/*! ./expressions/aggregation/global/GlobalSum */ "./src/renderer/viz/expressions/aggregation/global/GlobalSum.js");
/* harmony import */ var _expressions_aggregation_global_GlobalPercentile__WEBPACK_IMPORTED_MODULE_72__ = __webpack_require__(/*! ./expressions/aggregation/global/GlobalPercentile */ "./src/renderer/viz/expressions/aggregation/global/GlobalPercentile.js");
/* harmony import */ var _expressions_zoom__WEBPACK_IMPORTED_MODULE_73__ = __webpack_require__(/*! ./expressions/zoom */ "./src/renderer/viz/expressions/zoom.js");
/* harmony import */ var _expressions_Placement__WEBPACK_IMPORTED_MODULE_74__ = __webpack_require__(/*! ./expressions/Placement */ "./src/renderer/viz/expressions/Placement.js");
/* harmony import */ var _expressions_Image__WEBPACK_IMPORTED_MODULE_75__ = __webpack_require__(/*! ./expressions/Image */ "./src/renderer/viz/expressions/Image.js");
/* harmony import */ var _expressions_SVG__WEBPACK_IMPORTED_MODULE_76__ = __webpack_require__(/*! ./expressions/SVG */ "./src/renderer/viz/expressions/SVG.js");
/* harmony import */ var _defaultSVGs__WEBPACK_IMPORTED_MODULE_77__ = __webpack_require__(/*! ./defaultSVGs */ "./src/renderer/viz/defaultSVGs.js");
/* harmony import */ var _expressions_Zoomrange__WEBPACK_IMPORTED_MODULE_78__ = __webpack_require__(/*! ./expressions/Zoomrange */ "./src/renderer/viz/expressions/Zoomrange.js");
/* harmony import */ var _expressions_Scaled__WEBPACK_IMPORTED_MODULE_79__ = __webpack_require__(/*! ./expressions/Scaled */ "./src/renderer/viz/expressions/Scaled.js");
/* harmony import */ var _expressions_AlphaNormalize__WEBPACK_IMPORTED_MODULE_80__ = __webpack_require__(/*! ./expressions/AlphaNormalize */ "./src/renderer/viz/expressions/AlphaNormalize.js");
/* harmony import */ var _expressions_transformation_Translate__WEBPACK_IMPORTED_MODULE_81__ = __webpack_require__(/*! ./expressions/transformation/Translate */ "./src/renderer/viz/expressions/transformation/Translate.js");
/* harmony import */ var _expressions_transformation_Rotate__WEBPACK_IMPORTED_MODULE_82__ = __webpack_require__(/*! ./expressions/transformation/Rotate */ "./src/renderer/viz/expressions/transformation/Rotate.js");
/**
* Expressions are used to define visualizations, a visualization (viz) is a set named properties and variables and its corresponding values: expressions.
* A viz has the following properties:
*
* - **color**: fill color of points and polygons and color of lines
* - **strokeColor**: stroke/border color of points and polygons, not applicable to lines
* - **width**: fill diameter of points, thickness of lines, not applicable to polygons
* - **strokeWidth**: stroke width of points and polygons, not applicable to lines
* - **filter**: filter features by removing from rendering and interactivity all the features that don't pass the test.
* - **symbol** - show an image instead in the place of points
* - **symbolPlacement** - when using `symbol`, offset to apply to the image
* - **order**: - rendering order of the features, only applicable to points. See {@link carto.expressions.asc}, {@link carto.expressions.desc} and {@link carto.expressions.noOrder}
* - **resolution**: - resolution of the property-aggregation functions, only applicable to points. Default resolution is 1. Custom values must be greater than 0 and lower than 256. A resolution of N means points are aggregated to grid cells NxN pixels. Unlinke {@link https://carto.com/developers/torque-js/guides/how-spatial-aggregation-works/|Torque resolution}, the aggregated points are placed in the centroid of the cluster, not in the center of the grid cell.
*
* For example the point diameter could be using the `add` expression:
*
* ```javascript
* const viz = new carto.Viz({
* width: carto.expressions.add(5, 5) // Equivalent to `width: 10`
* });
* ```
*
* You can use dataset properties inside expressions. Imagine we are representing cities in a map,
* we can make the point width proportional to the population using the `property`/`prop` expression.
*
* ```javascript
* const viz = new carto.Viz({
* width: carto.expressions.prop('population')
* });
* ```
*
* Multiple expressions can be combined to form more powerful ones,
* for example lets divide the population between a number using the `div` expression to make points smaller:
*
* ```javascript
* const s = carto.expressions; // We use this alias along documentation.
* const viz = new carto.Viz({
* width: s.div(
* s.prop('population'),
* 10000
* )
* });
* ```
*
* All these expressions can be used also in a String API form. This API is a more compact way to create and use expressions.
* It has shortcut notation to access your feature properties using the `$` symbol. It also allows inline comments using the JavaScript syntax.
*
* ```javascript
* const viz = new carto.Viz(`
* width: $population / 10000 // Size proportional to the population for each feature
* `);
* ```
*
* Although the combination of expressions is very powerful, you must be aware of the different types to produce valid combinations.
* For example, the previous example is valid since we assumed that 'population' is a numeric property, it won't be valid if
* it was a categorical property. Each expression defines some restrictions regarding their parameters, particularly, the
* type of their parameters.
*
* The most important types are:
* - **Number** expression. Expressions that contains numbers, both integers and floating point numbers. Boolean types are emulated by this type, being 0 false, and 1 true.
* - **Category** expression. Expressions that contains categories. Categories can have a limited set of values, like the country or the region of a feature.
* - **Color** expression. Expressions that contains colors. An alpha or transparency channel is included in this type.
*
* @namespace carto.expressions
* @api
*/
/**
* Depending on the output, each expression has a different type
*
* @namespace Types
* @api
*/
/**
* Type of Numeric Expressions.
*
* Associated to expressions that return is an integer or float. When these expressions are evaluated it should return a JavaScript number.
*
* JavaScript numbers are automatically converted to Numeric Expressions.
*
* @typedef {} Number
* @name Number
* @memberof Types
* @api
*/
/**
* Type of Category Expressions.
*
* Associated to expressions that return is a category string. When these expressions are evaluated it should return a JavaScript string.
*
* JavaScript strings are automatically converted to Category Expressions.
*
* @typedef {} Category
* @name Category
* @memberof Types
* @api
*/
/**
* Type of Color Expressions.
*
* Associated to expressions that return a color. When these expressions are evaluated it should return a RGBA object like:
*
* ```
* { r: 255, g: 255, b: 255, a: 1.0 }
* ```
*
* @typedef {} Color
* @name Color
* @memberof Types
* @api
*/
/**
* Type of Date Expressions.
*
* @typedef {} Date
* @name Date
* @memberof Types
* @api
*/
/**
* Type of Fade Expressions.
*
* @typedef {} Fade
* @name Fade
* @memberof Types
* @api
*/
/**
* Type of Palette Expressions.
*
* More information in {@link carto.expressions.palettes|carto.expressions.palettes}.
*
* @typedef {} Palette
* @name Palette
* @memberof Types
* @api
*/
/**
* Type of Image Expressions.
*
* More information in {@link carto.expressions.image|carto.expressions.image}.
*
* @typedef {} Image
* @name Image
* @memberof Types
* @api
*/
/**
* Type of Transformation expressions.
*
* More information in {@link carto.expressions.rotate|carto.expressions.rotate} and {@link carto.expressions.translate|carto.expressions.translate} expressions.
*
* @typedef {} Transformation
* @name Transformation
* @memberof Types
* @api
*/
/**
* Type of Placement expressions.
*
* More information in {@link carto.expressions.placement|carto.expressions.placement} expression.
*
* @typedef {} Placement
* @name Placement
* @memberof Types
* @api
*/
/**
* Type of Ordered Expressions.
*
* Order expressions are {@link carto.expressions.asc|carto.expressions.asc}, {@link carto.expressions.desc|carto.expressions.desc} and {@link carto.expressions.noOrder|carto.expressions.noOrder}.
*
* @typedef {} Order
* @name Order
* @memberof Types
* @api
*/
/**
* @namespace Constants
* @api
*
*/
/**
* Constant FALSE value. Equivalent to `carto.expressions.constant(0)`
*
* @name FALSE
* @memberof Constants
* @api
*/
/**
* Constant TRUE value. Equivalent to `carto.expressions.constant(1)`
*
* @name TRUE
* @memberof Constants
* @api
*/
/**
* Constant ALIGN_CENTER translation. Equivalent to `carto.expressions.translate(0, 0)`.
* Read more about translation in {@link carto.expressions.translate|carto.expressions.translate}
*
* @name ALIGN_CENTER
* @memberof Constants
* @api
*/
/**
* Constant ALIGN_BOTTOM translation. Equivalent to `carto.expressions.translate(0, 1)`.
* Read more about translation in {@link carto.expressions.translate|carto.expressions.translate}
*
* @name ALIGN_BOTTOM
* @memberof Constants
* @api
*/
/**
* Constant PI number.
*
* @name PI
* @memberof Constants
* @api
*/
/**
* Constant E number.
*
* @name E
* @memberof Constants
* @api
*/
/**
* Constant HOLD number. Max Safe Integer number to be used to "hold" the Fade expression.
* Read more about fading in {@link carto.expressions.fade|carto.expressions.fade}
*
* @name HOLD
* @memberof Constants
* @api
*/
/**
* @namespace Icons
* @api
*
*/
/**
* Constant BICYCLE icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name BICYCLE
* @memberof Icons
* @api
*/
/**
* Constant BUILDING icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name BUILDING
* @memberof Icons
* @api
*/
/**
* Constant BUS icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name BUS
* @memberof Icons
* @api
*/
/**
* Constant CAR icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name CAR
* @memberof Icons
* @api
*/
/**
* Constant CIRCLE icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name CIRCLE
* @memberof Icons
* @api
*/
/**
* Constant CIRCLE_OUTLINE icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name CIRCLE_OUTLINE
* @memberof Icons
* @api
*/
/**
* Constant CROSS icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name CROSS
* @memberof Icons
* @api
*/
/**
* Constant FLAG icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name FLAG
* @memberof Icons
* @api
*/
/**
* Constant HOUSE icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name HOUSE
* @memberof Icons
* @api
*/
/**
* Constant MARKER icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name MARKER
* @memberof Icons
* @api
*/
/**
* Constant MARKER_OUTLINE icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name MARKER_OUTLINE
* @memberof Icons
* @api
*/
/**
* Constant SQUARE icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name SQUARE
* @memberof Icons
* @api
*/
/**
* Constant SQUARE_OUTLINE icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name SQUARE_OUTLINE
* @memberof Icons
* @api
*/
/**
* Constant STAR icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name STAR
* @memberof Icons
* @api
*/
/**
* Constant STAR_OUTLINE icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name STAR_OUTLINE
* @memberof Icons
* @api
*/
/**
* Constant TRIANGLE icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name TRIANGLE
* @memberof Icons
* @api
*/
/**
* Constant TRIANGLE_OUTLINE icon.
* Read more about how to use constant icons in {@link carto.expressions.image|carto.expressions.image}.
* They can also be used in an array, as it is shown in {@link carto.expressions.ramp|carto.expressions.ramp}.
* There is a list with all the default {@link icons.showcase|icons} available.
*
* @name TRIANGLE_OUTLINE
* @memberof Icons
* @api
*/
// Binary Operations
/* Expose classes as constructor functions */
const number = (...args) => new _expressions_basic_number__WEBPACK_IMPORTED_MODULE_36__["default"](...args);
const category = (...args) => new _expressions_basic_category__WEBPACK_IMPORTED_MODULE_19__["default"](...args);
const list = (...args) => new _expressions_basic_List__WEBPACK_IMPORTED_MODULE_49__["default"](...args);
const rgb = (...args) => new _expressions_color_rgb__WEBPACK_IMPORTED_MODULE_50__["RGB"](...args);
const rgba = (...args) => new _expressions_color_rgb__WEBPACK_IMPORTED_MODULE_50__["RGBA"](...args);
const transition = (...args) => new _expressions_transition__WEBPACK_IMPORTED_MODULE_0__["default"](...args);
const in_ = (...args) => new _expressions_belongs__WEBPACK_IMPORTED_MODULE_1__["In"](...args);
const nin = (...args) => new _expressions_belongs__WEBPACK_IMPORTED_MODULE_1__["Nin"](...args);
const between = (...args) => new _expressions_between__WEBPACK_IMPORTED_MODULE_2__["default"](...args);
const mul = (...args) => new _expressions_binary_Mul__WEBPACK_IMPORTED_MODULE_12__["default"](...args);
const div = (...args) => new _expressions_binary_Div__WEBPACK_IMPORTED_MODULE_5__["default"](...args);
const add = (...args) => new _expressions_binary_Add__WEBPACK_IMPORTED_MODULE_3__["default"](...args);
const sub = (...args) => new _expressions_binary_Sub__WEBPACK_IMPORTED_MODULE_16__["default"](...args);
const pow = (...args) => new _expressions_binary_Pow__WEBPACK_IMPORTED_MODULE_15__["default"](...args);
const mod = (...args) => new _expressions_binary_Mod__WEBPACK_IMPORTED_MODULE_11__["default"](...args);
const greaterThan = (...args) => new _expressions_binary_GreaterThan__WEBPACK_IMPORTED_MODULE_7__["default"](...args);
const greaterThanOrEqualTo = (...args) => new _expressions_binary_GreaterThanOrEqualTo__WEBPACK_IMPORTED_MODULE_8__["default"](...args);
const lessThan = (...args) => new _expressions_binary_LessThan__WEBPACK_IMPORTED_MODULE_9__["default"](...args);
const lessThanOrEqualTo = (...args) => new _expressions_binary_LessThanOrEqualTo__WEBPACK_IMPORTED_MODULE_10__["default"](...args);
const equals = (...args) => new _expressions_binary_Equals__WEBPACK_IMPORTED_MODULE_6__["default"](...args);
const notEquals = (...args) => new _expressions_binary_NotEquals__WEBPACK_IMPORTED_MODULE_13__["default"](...args);
const and = (...args) => new _expressions_binary_And__WEBPACK_IMPORTED_MODULE_4__["default"](...args);
const or = (...args) => new _expressions_binary_Or__WEBPACK_IMPORTED_MODULE_14__["default"](...args);
const gt = greaterThan;
const gte = greaterThanOrEqualTo;
const lt = lessThan;
const lte = lessThanOrEqualTo;
const eq = equals;
const neq = notEquals;
const blend = (...args) => new _expressions_blend__WEBPACK_IMPORTED_MODULE_17__["default"](...args);
const buckets = (...args) => new _expressions_buckets__WEBPACK_IMPORTED_MODULE_18__["default"](...args);
const cielab = (...args) => new _expressions_color_CIELab__WEBPACK_IMPORTED_MODULE_20__["default"](...args);
const clusterAvg = (...args) => new _expressions_aggregation_cluster_ClusterAvg__WEBPACK_IMPORTED_MODULE_21__["default"](...args);
const clusterMax = (...args) => new _expressions_aggregation_cluster_ClusterMax__WEBPACK_IMPORTED_MODULE_22__["default"](...args);
const clusterMin = (...args) => new _expressions_aggregation_cluster_ClusterMin__WEBPACK_IMPORTED_MODULE_23__["default"](...args);
const clusterMode = (...args) => new _expressions_aggregation_cluster_ClusterMode__WEBPACK_IMPORTED_MODULE_24__["default"](...args);
const clusterSum = (...args) => new _expressions_aggregation_cluster_ClusterSum__WEBPACK_IMPORTED_MODULE_25__["default"](...args);
const clusterCount = (...args) => new _expressions_aggregation_cluster_ClusterCount__WEBPACK_IMPORTED_MODULE_26__["default"](...args);
const clusterTime = (...args) => new _expressions_aggregation_cluster_ClusterTime__WEBPACK_IMPORTED_MODULE_27__["default"](...args);
const constant = (...args) => new _expressions_basic_constant__WEBPACK_IMPORTED_MODULE_28__["default"](...args);
const image = (...args) => new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](...args);
const svg = (...args) => new _expressions_SVG__WEBPACK_IMPORTED_MODULE_76__["default"](...args);
const hex = (...args) => new _expressions_color_hex__WEBPACK_IMPORTED_MODULE_29__["default"](...args);
const hsl = (...args) => new _expressions_color_hsl__WEBPACK_IMPORTED_MODULE_30__["HSL"](...args);
const hsla = (...args) => new _expressions_color_hsl__WEBPACK_IMPORTED_MODULE_30__["HSLA"](...args);
const hsv = (...args) => new _expressions_color_hsv__WEBPACK_IMPORTED_MODULE_31__["HSV"](...args);
const hsva = (...args) => new _expressions_color_hsv__WEBPACK_IMPORTED_MODULE_31__["HSVA"](...args);
const cubic = (...args) => new _expressions_interpolators__WEBPACK_IMPORTED_MODULE_32__["Cubic"](...args);
const ilinear = (...args) => new _expressions_interpolators__WEBPACK_IMPORTED_MODULE_32__["ILinear"](...args);
const linear = (...args) => new _expressions_linear__WEBPACK_IMPORTED_MODULE_33__["default"](...args);
const namedColor = (...args) => new _expressions_color_NamedColor__WEBPACK_IMPORTED_MODULE_34__["default"](...args);
const now = (...args) => new _expressions_now__WEBPACK_IMPORTED_MODULE_35__["default"](...args);
const opacity = (...args) => new _expressions_color_Opacity__WEBPACK_IMPORTED_MODULE_37__["default"](...args);
const asc = (...args) => new _expressions_ordering__WEBPACK_IMPORTED_MODULE_38__["Asc"](...args);
const desc = (...args) => new _expressions_ordering__WEBPACK_IMPORTED_MODULE_38__["Desc"](...args);
const noOrder = (...args) => new _expressions_ordering__WEBPACK_IMPORTED_MODULE_38__["NoOrder"](...args);
const width = (...args) => new _expressions_ordering__WEBPACK_IMPORTED_MODULE_38__["Width"](...args);
const reverse = (...args) => new _expressions_reverse_Reverse__WEBPACK_IMPORTED_MODULE_40__["default"](...args);
const property = (...args) => new _expressions_basic_property__WEBPACK_IMPORTED_MODULE_41__["default"](...args);
const globalQuantiles = (...args) => new _expressions_classification_GlobalQuantiles__WEBPACK_IMPORTED_MODULE_43__["default"](...args);
const viewportQuantiles = (...args) => new _expressions_classification_ViewportQuantiles__WEBPACK_IMPORTED_MODULE_46__["default"](...args);
const globalEqIntervals = (...args) => new _expressions_classification_GlobalEqIntervals__WEBPACK_IMPORTED_MODULE_42__["default"](...args);
const viewportEqIntervals = (...args) => new _expressions_classification_ViewportEqIntervals__WEBPACK_IMPORTED_MODULE_45__["default"](...args);
const globalStandardDev = (...args) => new _expressions_classification_GlobalStandardDev__WEBPACK_IMPORTED_MODULE_44__["default"](...args);
const viewportStandardDev = (...args) => new _expressions_classification_ViewportStandardDev__WEBPACK_IMPORTED_MODULE_47__["default"](...args);
const ramp = (...args) => new _expressions_Ramp__WEBPACK_IMPORTED_MODULE_48__["default"](...args);
const time = (...args) => new _expressions_time__WEBPACK_IMPORTED_MODULE_51__["default"](...args);
const timeRange = (...args) => new _expressions_timeRange__WEBPACK_IMPORTED_MODULE_52__["default"](...args);
const top = (...args) => new _expressions_top__WEBPACK_IMPORTED_MODULE_53__["default"](...args);
const fade = (...args) => new _expressions_Fade__WEBPACK_IMPORTED_MODULE_54__["Fade"](...args);
const animation = (...args) => new _expressions_Animation__WEBPACK_IMPORTED_MODULE_55__["Animation"](...args);
const log = (...args) => new _expressions_unary__WEBPACK_IMPORTED_MODULE_56__["Log"](...args);
const sqrt = (...args) => new _expressions_unary__WEBPACK_IMPORTED_MODULE_56__["Sqrt"](...args);
const sin = (...args) => new _expressions_unary__WEBPACK_IMPORTED_MODULE_56__["Sin"](...args);
const cos = (...args) => new _expressions_unary__WEBPACK_IMPORTED_MODULE_56__["Cos"](...args);
const tan = (...args) => new _expressions_unary__WEBPACK_IMPORTED_MODULE_56__["Tan"](...args);
const sign = (...args) => new _expressions_unary__WEBPACK_IMPORTED_MODULE_56__["Sign"](...args);
const abs = (...args) => new _expressions_unary__WEBPACK_IMPORTED_MODULE_56__["Abs"](...args);
const isNull = (...args) => new _expressions_unary__WEBPACK_IMPORTED_MODULE_56__["IsNull"](...args);
const not = (...args) => new _expressions_unary__WEBPACK_IMPORTED_MODULE_56__["Not"](...args);
const floor = (...args) => new _expressions_unary__WEBPACK_IMPORTED_MODULE_56__["Floor"](...args);
const ceil = (...args) => new _expressions_unary__WEBPACK_IMPORTED_MODULE_56__["Ceil"](...args);
const variable = (...args) => Object(_expressions_basic_variable__WEBPACK_IMPORTED_MODULE_57__["default"])(...args);
const viewportAvg = (...args) => new _expressions_aggregation_viewport_ViewportAvg__WEBPACK_IMPORTED_MODULE_58__["default"](...args);
const viewportMax = (...args) => new _expressions_aggregation_viewport_ViewportMax__WEBPACK_IMPORTED_MODULE_59__["default"](...args);
const viewportMin = (...args) => new _expressions_aggregation_viewport_ViewportMin__WEBPACK_IMPORTED_MODULE_60__["default"](...args);
const viewportSum = (...args) => new _expressions_aggregation_viewport_ViewportSum__WEBPACK_IMPORTED_MODULE_61__["default"](...args);
const viewportCount = (...args) => new _expressions_aggregation_viewport_ViewportCount__WEBPACK_IMPORTED_MODULE_62__["default"](...args);
const viewportPercentile = (...args) => new _expressions_aggregation_viewport_ViewportPercentile__WEBPACK_IMPORTED_MODULE_63__["default"](...args);
const viewportHistogram = (...args) => new _expressions_histogram_ViewportHistogram__WEBPACK_IMPORTED_MODULE_64__["default"](...args);
const viewportFeatures = (...args) => new _expressions_viewportFeatures__WEBPACK_IMPORTED_MODULE_66__["default"](...args);
const globalAvg = (...args) => new _expressions_aggregation_global_GlobalAvg__WEBPACK_IMPORTED_MODULE_67__["default"](...args);
const globalMax = (...args) => new _expressions_aggregation_global_GlobalMax__WEBPACK_IMPORTED_MODULE_69__["default"](...args);
const globalMin = (...args) => new _expressions_aggregation_global_GlobalMin__WEBPACK_IMPORTED_MODULE_70__["default"](...args);
const globalSum = (...args) => new _expressions_aggregation_global_GlobalSum__WEBPACK_IMPORTED_MODULE_71__["default"](...args);
const globalCount = (...args) => new _expressions_aggregation_global_GlobalCount__WEBPACK_IMPORTED_MODULE_68__["default"](...args);
const globalPercentile = (...args) => new _expressions_aggregation_global_GlobalPercentile__WEBPACK_IMPORTED_MODULE_72__["default"](...args);
const globalHistogram = (...args) => new _expressions_histogram_GlobalHistogram__WEBPACK_IMPORTED_MODULE_65__["default"](...args);
const zoom = (...args) => new _expressions_zoom__WEBPACK_IMPORTED_MODULE_73__["default"](...args);
const scaled = (...args) => new _expressions_Scaled__WEBPACK_IMPORTED_MODULE_79__["default"](...args);
const zoomrange = (...args) => new _expressions_Zoomrange__WEBPACK_IMPORTED_MODULE_78__["default"](...args);
const placement = (...args) => new _expressions_Placement__WEBPACK_IMPORTED_MODULE_74__["default"](...args);
const translate = (...args) => new _expressions_transformation_Translate__WEBPACK_IMPORTED_MODULE_81__["default"](...args);
const rotate = (...args) => new _expressions_transformation_Rotate__WEBPACK_IMPORTED_MODULE_82__["default"](...args);
const alphaNormalize = (...args) => new _expressions_AlphaNormalize__WEBPACK_IMPORTED_MODULE_80__["default"](...args);
const HOLD = new _expressions_basic_constant__WEBPACK_IMPORTED_MODULE_28__["default"](Number.MAX_SAFE_INTEGER);
const TRUE = new _expressions_basic_constant__WEBPACK_IMPORTED_MODULE_28__["default"](1);
const FALSE = new _expressions_basic_constant__WEBPACK_IMPORTED_MODULE_28__["default"](0);
const PI = new _expressions_basic_constant__WEBPACK_IMPORTED_MODULE_28__["default"](Math.PI);
const E = new _expressions_basic_constant__WEBPACK_IMPORTED_MODULE_28__["default"](Math.E);
const BICYCLE = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].bicycle);
const BUILDING = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].building);
const BUS = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].bus);
const CAR = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].car);
const CIRCLE = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].circle);
const CIRCLE_OUTLINE = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].circleOutline);
const CROSS = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].cross);
const FLAG = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].flag);
const HOUSE = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].house);
const MARKER = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].marker);
const MARKER_OUTLINE = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].markerOutline);
const PLUS = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].plus);
const SQUARE = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].square);
const SQUARE_OUTLINE = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].squareOutline);
const STAR = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].star);
const STAR_OUTLINE = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].starOutline);
const TRIANGLE = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].triangle);
const TRIANGLE_OUTLINE = new _expressions_Image__WEBPACK_IMPORTED_MODULE_75__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_77__["default"].triangleOutline);
const ALIGN_CENTER = new _expressions_Placement__WEBPACK_IMPORTED_MODULE_74__["default"](constant(0), constant(0));
const ALIGN_BOTTOM = new _expressions_Placement__WEBPACK_IMPORTED_MODULE_74__["default"](constant(0), constant(1));
/***/ }),
/***/ "./src/renderer/viz/expressions/AlphaNormalize.js":
/*!********************************************************!*\
!*** ./src/renderer/viz/expressions/AlphaNormalize.js ***!
\********************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return AlphaNormalize; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _expressions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../expressions */ "./src/renderer/viz/expressions.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
/* harmony import */ var _basic_property__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./basic/property */ "./src/renderer/viz/expressions/basic/property.js");
/**
* Override the opacity (alpha channel) of a color to normalize the input color by a normalizer property.
*
* This is implemented as `opacity(input, normalizer/globalMax(normalizer))
*
* @param {Color} input - input color to normalize
* @param {Number} normalizer - numeric property that will be used to normalize the input color
* @return {Color}
*
* @example <caption>Normalize an input property ($winner_party) by a second property ($voters).</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* color: s.alphaNormalize(
* s.ramp(s.prop('winner_party'), [red, blue]),
* s.prop('voters')
* )
* });
*
* @example <caption>Normalize an input property ($winner_party) by a second property ($voters). (String)</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* color: alphaNormalize(
* ramp($winner_party, [red, blue]),
* $voters
* )
* });
*
* @memberof carto.expressions
* @name alphaNormalize
* @function
* @api
*/
class AlphaNormalize extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (input, normalizer) {
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkMaxArguments"])(arguments, 2, 'alphaNormalize');
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkExpression"])('alphaNormalize', 'input', 0, input);
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkExpression"])('alphaNormalize', 'normalizer', 1, normalizer);
super({ _impostor: Object(_expressions__WEBPACK_IMPORTED_MODULE_1__["opacity"])(input, Object(_expressions__WEBPACK_IMPORTED_MODULE_1__["div"])(normalizer, Object(_expressions__WEBPACK_IMPORTED_MODULE_1__["globalMax"])(normalizer))) });
this._input = input;
this._normalizer = normalizer;
this.type = 'color';
this.inlineMaker = inline => inline._impostor;
}
_bindMetadata (meta) {
this._input._bindMetadata(meta);
this._normalizer._bindMetadata(meta);
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkType"])('alphaNormalize', 'input', 0, 'color', this._input);
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkType"])('alphaNormalize', 'normalizer', 1, 'number', this._normalizer);
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkInstance"])('alphaNormalize', 'normalizer', 1, _basic_property__WEBPACK_IMPORTED_MODULE_3__["default"], this._normalizer);
super._bindMetadata(meta);
}
get value () {
return this._impostor.value;
}
eval (feature) {
return this._impostor.eval(feature);
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/Animation.js":
/*!***************************************************!*\
!*** ./src/renderer/viz/expressions/Animation.js ***!
\***************************************************/
/*! exports provided: Animation */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
/* harmony import */ var _AnimationGeneral__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./AnimationGeneral */ "./src/renderer/viz/expressions/AnimationGeneral.js");
/* harmony import */ var _AnimationRange__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./AnimationRange */ "./src/renderer/viz/expressions/AnimationRange.js");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _Fade__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Fade */ "./src/renderer/viz/expressions/Fade.js");
/**
* Create an animated temporal filter (animation). Read more about the {@link expression.Animation|Animation Class}
*
* @param {Number} input input to base the temporal filter,
* if input is a property, the beginning and end of the animation will be determined by the minimum and maximum timestamps of the property on the dataset,
* this can be problematic if outliers are present. Otherwise input must be a number expression in which 0 means beginning of the animation and 1 means end.
* If `input` is NULL or NaN the filter won't be passed at any moment of the animation.
*
* It can be combined with linear and time expressions.
* @param {Number} duration duration of the animation in seconds, optional, defaults to 10 seconds
* @param {Fade} fade fadeIn/fadeOut configuration, optional, defaults to 0.15 seconds of fadeIn and 0.15 seconds of fadeOut
* @return {Number}
*
* @example <caption>Temporal map by $day (of numeric type), with a duration of 40 seconds, fadeIn of 0.1 seconds and fadeOut of 0.3 seconds.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* width: 2,
* color: s.ramp(s.linear(s.clusterAvg(s.prop('temp'), 0, 30)), s.palettes.TEALROSE),
* filter: s.animation(s.prop('day'), 40, s.fade(0.1, 0.3))
* });
*
* @example <caption>Temporal map by $day (of numeric type), with a duration of 40 seconds, fadeIn of 0.1 seconds and fadeOut of 0.3 seconds. (String)</caption>
* const viz = new carto.Viz(`
* width: 2
* color: ramp(linear(clusterAvg($temp), 0,30), tealrose)
* filter: animation($day, 40, fade(0.1, 0.3))
* `);
*
* @example <caption>Temporal map by $date (of date type), with a duration of 40 seconds, fadeIn of 0.1 seconds and fadeOut of 0.3 seconds.</caption>
* const viz = new carto.Viz({
* width: 2,
* color: s.ramp(s.linear(s.clusterAvg(s.prop('temp'), 0, 30)), s.palettes.TEALROSE),
* filter: s.animation(s.linear(s.prop('date'), s.time('2022-03-09T00:00:00Z'), s.time('2033-08-12T00:00:00Z')), 40, s.fade(0.1, 0.3))
* });
*
* @example <caption>Temporal map by $date (of date type), with a duration of 40 seconds, fadeIn of 0.1 seconds and fadeOut of 0.3 seconds. (String)</caption>
* const viz = new carto.Viz(`
* width: 2
* color: ramp(linear(clusterAvg($temp), 0,30), tealrose)
* filter: animation(linear($date, time('2022-03-09T00:00:00Z'), time('2033-08-12T00:00:00Z')), 40, fade(0.1, 0.3))
* `);
* Animation class
*
* This class is instanced automatically by using the `animation` function. It is documented for its methods.
*
* @memberof carto.expressions
* @name animation
* @function
* @api
*/
/**
* Animation class
*
* This class is instanced automatically by using the `animation` function. It is documented for its methods.
*
* @name expressions.Animation
* @abstract
* @hideconstructor
* @class
* @api
*/
class Animation extends _base__WEBPACK_IMPORTED_MODULE_3__["default"] {
constructor (input, duration = 10, fade = new _Fade__WEBPACK_IMPORTED_MODULE_4__["Fade"]()) {
Object(_utils__WEBPACK_IMPORTED_MODULE_0__["checkMaxArguments"])(arguments, 3, 'animation');
duration = Object(_utils__WEBPACK_IMPORTED_MODULE_0__["implicitCast"])(duration);
input = Object(_utils__WEBPACK_IMPORTED_MODULE_0__["implicitCast"])(input);
super({ input, duration, fade });
}
_resolveAliases (aliases) {
this._getChildren().map(child => child._resolveAliases(aliases));
if (this.input.type === 'timerange') {
Object.setPrototypeOf(this, _AnimationRange__WEBPACK_IMPORTED_MODULE_2__["default"].prototype);
} else {
Object.setPrototypeOf(this, _AnimationGeneral__WEBPACK_IMPORTED_MODULE_1__["default"].prototype);
}
this._init();
}
_bindMetadata (metadata) {
this._resolveAliases({});
this._bindMetadata(metadata);
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/AnimationGeneral.js":
/*!**********************************************************!*\
!*** ./src/renderer/viz/expressions/AnimationGeneral.js ***!
\**********************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return AnimationGeneral; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _basic_property__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./basic/property */ "./src/renderer/viz/expressions/basic/property.js");
/* harmony import */ var _utils_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../utils/util */ "./src/utils/util.js");
/* harmony import */ var _aggregation_cluster_ClusterTime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./aggregation/cluster/ClusterTime */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterTime.js");
/* harmony import */ var _expressions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../expressions */ "./src/renderer/viz/expressions.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
/* harmony import */ var _Fade__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Fade */ "./src/renderer/viz/expressions/Fade.js");
let waitingForLayer = new Set();
let waitingForOthers = new Set();
class AnimationGeneral extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (input, duration = 10, fade = new _Fade__WEBPACK_IMPORTED_MODULE_6__["Fade"]()) {
Object(_utils__WEBPACK_IMPORTED_MODULE_5__["checkMaxArguments"])(arguments, 3, 'animation');
duration = Object(_utils__WEBPACK_IMPORTED_MODULE_5__["implicitCast"])(duration);
input = Object(_utils__WEBPACK_IMPORTED_MODULE_5__["implicitCast"])(input);
super({ input, duration, fade });
this._init();
}
_init () {
const input = this.input;
const originalInput = input;
if (input.isA(_basic_property__WEBPACK_IMPORTED_MODULE_1__["default"]) || (input.isA(_aggregation_cluster_ClusterTime__WEBPACK_IMPORTED_MODULE_3__["default"]) && input.type === 'timerange')) {
this._input = Object(_expressions__WEBPACK_IMPORTED_MODULE_4__["linear"])(input, Object(_expressions__WEBPACK_IMPORTED_MODULE_4__["globalMin"])(input), Object(_expressions__WEBPACK_IMPORTED_MODULE_4__["globalMax"])(input), 'start');
} else {
this._input = this.input;
}
this.childrenNames = this.childrenNames.filter(x => x === '_input');
this.childrenNames.push('_input');
this.childrenNames.push('fade');
this.childrenNames.push('duration');
this.type = 'number';
this._originalInput = originalInput;
this._paused = false;
this.progress = Object(_expressions__WEBPACK_IMPORTED_MODULE_4__["number"])(0);
this.childrenNames.push('progress');
this.expressionName = 'animation';
this.preface = `
#ifndef ANIMATION
#define ANIMATION
float animation(float _input, float progress, float duration, float fadeIn, float fadeOut){
float x = 0.;
// Check for NaN
if (_input <= 0.0 || 0.0 <= _input){
x = 1. - clamp(abs(_input - progress) * duration / (_input > progress ? fadeIn: fadeOut), 0., 1.);
}
return x;
}
#endif
`;
this.inlineMaker = inline => `animation(${inline._input}, ${inline.progress}, ${inline.duration}, ${inline.fade.in}, ${inline.fade.out})`;
waitingForLayer.add(this);
if (!this._paused) {
this._paused = 'default';
}
}
toString () {
return `${this.expressionName}(${this._input.toString()}, ${this.duration.toString()}, ${this.fade.toString()})`;
}
_bindMetadata (metadata) {
this._input._bindMetadata(metadata);
this.progress._bindMetadata(metadata);
this.fade._bindMetadata(metadata);
this.duration._bindMetadata(metadata);
Object(_utils__WEBPACK_IMPORTED_MODULE_5__["checkType"])('animation', 'input', 0, ['number', 'date', 'timerange'], this._originalInput);
Object(_utils__WEBPACK_IMPORTED_MODULE_5__["checkType"])('animation', 'duration', 1, 'number', this.duration);
Object(_utils__WEBPACK_IMPORTED_MODULE_5__["checkType"])('animation', 'fade', 2, 'fade', this.fade);
Object(_utils__WEBPACK_IMPORTED_MODULE_5__["checkFeatureIndependent"])('animation', 'duration', 1, this.duration);
}
isAnimated () {
return true;
}
_dataReady () {
if (waitingForLayer.has(this)) {
waitingForLayer.delete(this);
waitingForOthers.add(this);
}
// setTimeout is needed to avoid the possibility of a de-synchronization of 1 frame
// if the last layer to be loaded is not the first one on the painting loop
setTimeout(() => {
if (waitingForOthers.has(this)) {
waitingForLayer = new Set([...waitingForLayer].filter(expr => {
while (expr.parent) {
expr = expr.parent;
}
if (expr._getRootExpressions) {
// The animation hasn't been removed from the viz
return true;
}
return false;
}));
if (waitingForLayer.size > 0) {
return;
}
[...waitingForOthers.values()].map(anim => {
if (anim._paused === 'default') {
anim.play();
}
});
waitingForOthers.clear();
}
}, 0);
}
_postShaderCompile (program, gl) {
super._postShaderCompile(program, gl);
}
_setTimestamp (timestamp) {
super._setTimestamp(timestamp);
if (this._paused && this._lastTime === undefined) {
return;
}
let deltaTime = 0;
const speed = 1 / this.duration.value;
if (this._lastTime !== undefined) {
deltaTime = timestamp - this._lastTime;
}
this._lastTime = timestamp;
if (this._paused) {
return;
}
this.progress.value = (this.progress.value + speed * deltaTime) % 1;
}
eval (feature) {
const input = this._input.eval(feature);
if (input === null) {
return 0;
}
const progress = this.progress.value;
const duration = this.duration.value;
const fadeIn = this.fade.fadeIn.eval(feature);
const fadeOut = this.fade.fadeOut.eval(feature);
const output = 1 - Object(_utils__WEBPACK_IMPORTED_MODULE_5__["clamp"])(Math.abs(input - progress) * duration / (input > progress ? fadeIn : fadeOut), 0, 1);
return output;
}
/**
* Get the current time stamp of the animation
*
* @returns {Number|Date} Current time stamp of the animation. If the animation is based on a numeric expression this will output a number, if it is based on a date expression it will output a date
*
* @example <caption>Using the `getProgressValue` method to get the animation current value.</caption>
* const s = carto.expressions;
* let animationExpr = s.animation(s.linear(s.prop('saledate'), 1991, 2017), 20, s.fade(0.7, 0.4));
* const animationStyle = {
* color: s.ramp(s.linear(s.prop('priceperunit'), 2000, 1010000), [s.rgb(0, 255, 0), s.rgb(255, 0, 0)]),
* width: s.mul(s.sqrt(s.prop('priceperunit')), 0.05),
* filter: animationExpr
* };
* layer.on('updated', () => {
* let currTime = Math.floor(animationExpr.getProgressValue());
* document.getElementById('timestamp').innerHTML = currTime;
* });
*
* @memberof expressions.Animation
* @name getProgressValue
* @instance
* @api
*/
getProgressValue () {
const progress = this.progress.value;
return this._input.converse(progress);
}
/**
* Set the time stamp of the animation
* @api
* @memberof expressions.Animation
* @instance
* @name setCurrent
* @param {Date|number} value - A JavaScript Date object with the new animation time
*/
setTimestamp (timestamp) {
const date = Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__["castDate"])(timestamp);
const [tmin, tmax] = this._input.limits();
if (date.getTime() < tmin) {
throw new RangeError('animation.setTimestamp requires the date parameter to be higher than the lower limit');
}
if (date.getTime() > tmax) {
throw new RangeError('animation.setTimestamp requires the date parameter to be lower than the higher limit');
}
this.progress.value = (date.getTime() - tmin) / (tmax - tmin);
}
/**
* Get the animation progress.
*
* @returns {Number} A number representing the progress. 0 when the animation just started and 1 at the end of the cycle.
* @api
* @instance
* @memberof expressions.Animation
* @name getProgressPct
*/
getProgressPct () {
return this.progress.value;
}
/**
* Set the animation progress from 0 to 1.
* @param {number} progress - A number in the [0-1] range setting the animation progress.
* @api
* @instance
* @memberof expressions.Animation
* @name setProgressPct
*/
setProgressPct (progress) {
progress = Number.parseFloat(progress);
if (progress < 0 || progress > 1) {
throw new TypeError(`animation.setProgressPct requires a number between 0 and 1 as parameter but got: ${progress}`);
}
this.progress.value = progress;
}
/**
* Returns whether the animation is playing or not
*
* @api
* @memberof expressions.Animation
* @instance
* @name isPlaying
*/
isPlaying () {
return this._paused === false;
}
/**
* Pause the animation
*
* @api
* @memberof expressions.Animation
* @instance
* @name pause
*/
pause () {
this._paused = true;
}
/**
* Play/resume the animation
*
* @api
* @memberof expressions.Animation
* @instance
* @name play
*/
play () {
this._paused = false;
this.notify();
}
/**
* Stops the animation
*
* @api
* @memberof expressions.Animation
* @instance
* @name stop
*/
stop () {
this.progress.value = 0;
this._paused = true;
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/AnimationRange.js":
/*!********************************************************!*\
!*** ./src/renderer/viz/expressions/AnimationRange.js ***!
\********************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return AnimationRange; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _Fade__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Fade */ "./src/renderer/viz/expressions/Fade.js");
/* harmony import */ var _expressions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../expressions */ "./src/renderer/viz/expressions.js");
/* harmony import */ var _AnimationGeneral__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./AnimationGeneral */ "./src/renderer/viz/expressions/AnimationGeneral.js");
class AnimationRange extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
_init () {
const input = this.input;
const duration = this.duration;
const fade = this.fade;
const start = Object(_expressions__WEBPACK_IMPORTED_MODULE_2__["linear"])(input, Object(_expressions__WEBPACK_IMPORTED_MODULE_2__["globalMin"])(input), Object(_expressions__WEBPACK_IMPORTED_MODULE_2__["globalMax"])(input), 'start');
const input2 = {};
Object.keys(input).forEach(key => { input2[key] = input[key]; });
Object.setPrototypeOf(input2, input);
const end = Object(_expressions__WEBPACK_IMPORTED_MODULE_2__["linear"])(input2, Object(_expressions__WEBPACK_IMPORTED_MODULE_2__["globalMin"])(input2), Object(_expressions__WEBPACK_IMPORTED_MODULE_2__["globalMax"])(input2), 'end');
const startAnim = new _AnimationGeneral__WEBPACK_IMPORTED_MODULE_3__["default"](start, duration, new _Fade__WEBPACK_IMPORTED_MODULE_1__["Fade"](fade.fadeIn, _expressions__WEBPACK_IMPORTED_MODULE_2__["HOLD"]));
const endAnim = new _AnimationGeneral__WEBPACK_IMPORTED_MODULE_3__["default"](end, duration, new _Fade__WEBPACK_IMPORTED_MODULE_1__["Fade"](_expressions__WEBPACK_IMPORTED_MODULE_2__["HOLD"], fade.fadeOut));
const combinedAnimation = Object(_expressions__WEBPACK_IMPORTED_MODULE_2__["mul"])(startAnim, endAnim);
this.combinedAnimation = combinedAnimation;
this.childrenNames.push('combinedAnimation');
combinedAnimation.parent = this;
this.type = 'number';
this._startAnim = startAnim;
this._endAnim = endAnim;
this.expressionName = 'animation';
this.inlineMaker = inline => inline.combinedAnimation;
}
_bindMetadata (metadata) {
this.combinedAnimation._bindMetadata(metadata);
}
eval (feature) {
return this.combinedAnimation.eval(feature);
}
isAnimated () {
return true;
}
isPlaying () {
return this._startAnim.isPlaying();
}
getProgressValue () {
return this._startAnim.getProgressValue();
}
getProgressPct () {
return this._startAnim.getProgressPct();
}
setProgressPct (progress) {
this._startAnim.setProgressPct(progress);
this._endAnim.setProgressPct(progress);
}
pause () {
this._startAnim.pause();
this._endAnim.pause();
}
play () {
this._startAnim.play();
this._endAnim.play();
this._endAnim.setProgressPct(this._startAnim.getProgressPct());
}
stop () {
this._startAnim.stop();
this._endAnim.stop();
}
toString () {
return `${this.expressionName}(${this._input.toString()}, ${this.duration.toString()}, ${this.fade.toString()})`;
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/BucketsGLSLHelper.js":
/*!***********************************************************!*\
!*** ./src/renderer/viz/expressions/BucketsGLSLHelper.js ***!
\***********************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return BucketsGLSLHelper; });
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./src/renderer/viz/expressions/constants.js");
/*
Once the number of buckets exceed 27, 'memory exhausted' problems are common at glsl compile time.
Here we set a little lower value to keep comparisons in just one if-else-if expression.
Beyond that value, N independent if expressions will be created.
That's a bit more inefficient but it consumes less memory, allowing for example a bigger
number of different icons in a viz
*/
const SAFE_NUMBER_ELSE_IF_COMPARISONS = 20;
class BucketsGLSLHelper {
constructor (buckets) {
this.buckets = buckets;
}
applyToShaderSource (getGLSLforProperty) {
// Get children sources
const childSourcesArray = this.buckets.childrenNames.map(name => this.buckets[name]._applyToShaderSource(getGLSLforProperty));
let childSources = {};
childSourcesArray.map((source, index) => {
childSources[this.buckets.childrenNames[index]] = source;
});
// Get coode for buckets comparisons
const funcName = `buckets${this.buckets._uid}`;
const elif = this._getComparisons(childSources);
const funcBody = this.buckets.list.elems.map(elif).join('');
const preface = `float ${funcName}(float x){
${funcBody}
return ${this.buckets.input.type === 'category' ? _constants__WEBPACK_IMPORTED_MODULE_0__["OTHERS_GLSL_VALUE"] : (this.buckets.numCategories - 1).toFixed(20)};
}`;
return {
preface: this.buckets._prefaceCode(childSources.input.preface + childSources.list.preface + preface),
inline: `${funcName}(${childSources.input.inline})`
};
}
/**
* Get if-expressions to compare each value with the corresponding buckets
*/
_getComparisons (childSources) {
const cmp = this.buckets.input.type === 'category' ? '==' : '<';
// When there is "OTHERS" we don't need to take it into account
const divisor = this.buckets.numCategoriesWithoutOthers - 1 || 1;
let elif;
if (divisor <= SAFE_NUMBER_ELSE_IF_COMPARISONS) {
// just one expression, with one 'if' & several 'else if'
elif = (_, index) =>
`${index > 0 ? 'else' : ''} if (x${cmp}(${childSources.list.inline[index]})){
return ${index}./${divisor.toFixed(20)};
}`;
} else {
// multiple, independent, 'if' expressions (order is assumed)
elif = (_, index) =>
`if (x${cmp}(${childSources.list.inline[index]})){
return ${index}./${divisor.toFixed(20)};
}`;
}
return elif;
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/CategoryIndex.js":
/*!*******************************************************!*\
!*** ./src/renderer/viz/expressions/CategoryIndex.js ***!
\*******************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return CategoryIndex; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
const SQRT_MAX_CATEGORIES_PER_PROPERTY = 256;
/**
* Transform a categorical property into a per-property category index. The evaluated result returns a value between 0 and 1.
* The dataset must contain less than 65536 (256 * 256) different categories.
*
* @param {Category} property - The property to be evaluated, must be categorical
* @return {Category}
*
* @example <caption> Color by $city using the CARTOColor Prism by assigning different color in Prism to each category.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* color: s.ramp(s.categoryIndex(s.prop('city')), s.palettes.PRISM)
* });
*
* @example <caption> Color by $city using the CARTOColor Prism by assigning different color in Prism to each category. (String)</caption>
* const viz = new carto.Viz(`
* color: ramp(categoryIndex($city), PRISM)
* `);
*
* @memberof carto.expressions
* @name categoryIndex
* @function
* @api
*/
class CategoryIndex extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (property) {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 1, 'categoryIndex');
property = Object(_utils__WEBPACK_IMPORTED_MODULE_1__["implicitCast"])(property);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkExpression"])('categoryIndex', 'property', 0, property);
super({ property });
this._numTranslatedCategories = null;
this.type = 'category';
this._translatePixels = new Float32Array(SQRT_MAX_CATEGORIES_PER_PROPERTY * SQRT_MAX_CATEGORIES_PER_PROPERTY);
this._translateArray = [];
this._numTranslatedCategories = 0;
this._numTranslatedCategoriesGL = 0;
}
get numCategories () {
return this.metaColumn.categories.length;
}
get metaColumn () {
const propertyName = this.property.propertyName;
return this._metadata.properties[propertyName]
? this._metadata.properties[propertyName]
: this._metadata.properties[this.property.name];
}
get numCategoriesWithoutOthers () {
return this.numCategories;
}
_bindMetadata (metadata) {
super._bindMetadata(metadata);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkType"])('categoryIndex', 'property', 0, 'category', this.property);
this._metadata = metadata;
this._calcTranslated();
}
get value () {
return this.eval();
}
eval (feature) {
const name = this.property.eval(feature);
const id = this._metadata.categoryToID.get(name);
return this._translateArray[id];
}
_preDraw (program, drawMetadata, gl) {
gl.activeTexture(gl.TEXTURE0 + drawMetadata.freeTexUnit);
if (this._numTranslatedCategoriesGL !== this.numCategories) {
this._numTranslatedCategoriesGL = this.numCategories;
this._calcTranslated();
this._translateTexture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, this._translateTexture);
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, SQRT_MAX_CATEGORIES_PER_PROPERTY, SQRT_MAX_CATEGORIES_PER_PROPERTY, 0, gl.ALPHA, gl.FLOAT, this._translatePixels);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
} else {
gl.bindTexture(gl.TEXTURE_2D, this._translateTexture);
}
gl.uniform1i(this._getBinding(program).texRampTranslateLoc, drawMetadata.freeTexUnit);
drawMetadata.freeTexUnit++;
}
_applyToShaderSource (getGLSLforProperty) {
const max = SQRT_MAX_CATEGORIES_PER_PROPERTY.toFixed(20);
const property = this.property._applyToShaderSource(getGLSLforProperty);
return {
inline: `ramp_translate${this._uid}(${property.inline})`,
preface: `
uniform sampler2D texRampTranslate${this._uid};
float ramp_translate${this._uid}(float s){
vec2 v = vec2(mod(s, ${max}), floor(s / ${max}));
return texture2D(texRampTranslate${this._uid}, v/${max}).a;
}`
};
}
_postShaderCompile (program, gl) {
this._getBinding(program).texRampTranslateLoc = gl.getUniformLocation(program, `texRampTranslate${this._uid}`);
}
_calcTranslated () {
const numCategories = this.numCategories;
if (this._numTranslatedCategories !== numCategories) {
this._numTranslatedCategories = numCategories;
for (let i = 0; i < numCategories; i++) {
const id = this._metadata.categoryToID.get(this.metaColumn.categories[i].name);
const value = i / (numCategories - 1);
const vec2Id = {
x: id % SQRT_MAX_CATEGORIES_PER_PROPERTY,
y: Math.floor(id / SQRT_MAX_CATEGORIES_PER_PROPERTY)
};
this._translatePixels[SQRT_MAX_CATEGORIES_PER_PROPERTY * vec2Id.y + vec2Id.x] = value;
this._translateArray.push(value);
}
}
}
getLegendData () {
const categories = this._metadata.properties[this.property.propertyName].categories;
const categoriesLength = categories.length;
const divisor = categoriesLength - 1;
const data = [];
for (let i = 0; i < categoriesLength; i++) {
const category = categories[i];
const key = category.name;
const value = i / divisor;
data.push({ key, value });
}
return { data };
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/Fade.js":
/*!**********************************************!*\
!*** ./src/renderer/viz/expressions/Fade.js ***!
\**********************************************/
/*! exports provided: Fade */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Fade", function() { return Fade; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
/**
* Create a FadeIn/FadeOut configuration. See `animation` for more details.
*
* @param {Number} param1 - Expression of type number or Number
* @param {Number} param2 - Expression of type number or Number
* @return {Fade}
*
* @example <caption>Fade in of 0.1 seconds, fade out of 0.3 seconds.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* filter: s.animation(s.prop('day'), 40, s.fade(0.1, 0.3))
* });
*
* @example <caption>Fade in of 0.1 seconds, fade out of 0.3 seconds. (String)</caption>
* const viz = new carto.Viz(`
* filter: animation($day, 40, fade(0.1, 0.3))
* `);
*
* @example<caption>Fade in and fade out of 0.5 seconds.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* filter: s.animation(s.prop('day'), 40, s.fade(0.5))
* });
*
* @example<caption>Fade in and fade out of 0.5 seconds. (String)</caption>
* const viz = new carto.Viz(`
* filter: animation($day, 40, fade(0.5))
* `);
*
* @example<caption>Fade in of 0.3 seconds without fading out.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* filter: s.animation(s.prop('day'), 40, s.fade(0.1, s.HOLD))
* });
*
* @example<caption>Fade in of 0.3 seconds without fading out. (String)</caption>
* const viz = new carto.Viz(`
* filter: animation($day, 40, fade(0.3, HOLD))
* `);
*
* @memberof carto.expressions
* @name fade
* @function
* @api
*/
const DEFAULT_FADE = 0.15;
const DEFAULT_PARAM = undefined;
class Fade extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (param1 = DEFAULT_PARAM, param2 = DEFAULT_PARAM) {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 2, 'fade');
let fadeIn = param1 === DEFAULT_PARAM
? Object(_utils__WEBPACK_IMPORTED_MODULE_1__["implicitCast"])(DEFAULT_FADE)
: Object(_utils__WEBPACK_IMPORTED_MODULE_1__["implicitCast"])(param1);
let fadeOut = param2 === DEFAULT_PARAM
? fadeIn
: Object(_utils__WEBPACK_IMPORTED_MODULE_1__["implicitCast"])(param2);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkExpression"])('fade', 'param1', 0, fadeIn);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkExpression"])('fade', 'param2', 1, fadeOut);
super({ fadeIn, fadeOut });
this.type = 'fade';
this.inlineMaker = (inline) => ({
in: inline.fadeIn,
out: inline.fadeOut
});
}
get value () {
return {
fadeIn: this.fadeIn.value,
fadeOut: this.fadeOut.value
};
}
eval (feature) {
return {
fadeIn: this.fadeIn.eval(feature),
fadeOut: this.fadeOut.eval(feature)
};
}
_bindMetadata (meta) {
super._bindMetadata(meta);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkType"])('fade', 'param1', 0, 'number', this.fadeIn);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkType"])('fade', 'param2', 1, 'number', this.fadeOut);
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/Image.js":
/*!***********************************************!*\
!*** ./src/renderer/viz/expressions/Image.js ***!
\***********************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Image; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
/**
* Image. Load an image and use it as a symbol.
*
* Note: image RGB color will be overridden if the viz `color` property is set.
*
* @param {String} url - Image path
*
* @example <caption>Load a svg image.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* symbol: s.image('./marker.svg')
* });
*
* @example <caption>Load a svg image. (String)</caption>
* const viz = new carto.Viz(`
* symbol: image('./marker.svg')
* `);
* @memberof carto.expressions
* @name image
* @function
* @api
*/
class Image extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (url) {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 1, 'image');
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkString"])('image', 'url', 0, url);
super({});
this.type = 'image';
this.canvas = null;
this.url = url;
this._promise = new Promise((resolve, reject) => {
this.image = new window.Image();
this.image.onload = () => {
this.canvas = _getCanvasFromImage(this.image);
this.image = null;
resolve();
};
this.image.onerror = reject;
this.image.crossOrigin = 'anonymous';
this.image.src = this.url;
});
}
loadImages () {
this.count = this.count + 1 || 1;
return this._promise;
}
keepDefaultsOnBlend () {
// Keep default image color if setting a symbol after viz initialization with defaults
if (this.default && this.parent.color.default) {
this.parent.color = Object(_utils__WEBPACK_IMPORTED_MODULE_1__["noOverrideColor"])();
}
}
get value () {
return this.url;
}
eval () {
return this.value;
}
getLegendData (options) {
return {
name: 'image',
data: [{
key: 'url',
value: this.url
}]
};
}
_free (gl) {
if (this.texture) {
gl.deleteTexture(this.texture);
}
}
_applyToShaderSource () {
return {
preface: this._prefaceCode(`uniform sampler2D texSprite${this._uid};`),
inline: `texture2D(texSprite${this._uid}, imageUV).rgba`
};
}
_postShaderCompile (program, gl) {
this._getBinding(program)._texLoc = gl.getUniformLocation(program, `texSprite${this._uid}`);
}
_preDraw (program, drawMetadata, gl) {
if (!this.init && this.canvas) {
this.init = true;
gl.activeTexture(gl.TEXTURE0 + drawMetadata.freeTexUnit);
this.texture = gl.createTexture();
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.bindTexture(gl.TEXTURE_2D, this.texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.canvas);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.generateMipmap(gl.TEXTURE_2D);
this.canvas = null;
}
if (this.texture) {
gl.activeTexture(gl.TEXTURE0 + drawMetadata.freeTexUnit);
gl.bindTexture(gl.TEXTURE_2D, this.texture);
gl.uniform1i(this._getBinding(program)._texLoc, drawMetadata.freeTexUnit);
drawMetadata.freeTexUnit++;
}
}
}
function _getCanvasFromImage (img) {
const CANVAS_SIZE = 256;
const canvas = document.createElement('canvas');
canvas.width = CANVAS_SIZE;
canvas.height = CANVAS_SIZE;
const ctx = canvas.getContext('2d');
const max = Math.max(img.width, img.height);
const width = img.width / max * CANVAS_SIZE;
const height = img.height / max * CANVAS_SIZE;
ctx.drawImage(img, (CANVAS_SIZE - width) / 2, (CANVAS_SIZE - height) / 2, width, height);
return canvas;
}
/***/ }),
/***/ "./src/renderer/viz/expressions/ListImage.js":
/*!***************************************************!*\
!*** ./src/renderer/viz/expressions/ListImage.js ***!
\***************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ListImage; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
/**
* ImageList. Load an array of images and use them as a symbols.
*
* Note: images RGB color will be overridden if the viz `color` property is set.
*
* @internal
*/
class ListImage extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
_bindMetadata (meta) {
super._bindMetadata(meta);
this.numImages = this.elems.length;
this._getChildren().forEach((image, i) => Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkType"])('imageArray', `imageArray[${i}]`, 0, 'image', image));
}
eval (feature) {
return this.elems.map(elem => elem.eval(feature));
}
_applyToShaderSource () {
return {
preface: this._prefaceCode(`
uniform sampler2D atlas${this._uid};
vec4 atlas${this._uid}Fn(vec2 imageUV, float category) {
return texture2D(atlas${this._uid}, imageUV/16. + vec2(mod(category, 16.), floor(category/16.))/16. ).rgba;
}
`),
inline: `atlas${this._uid}Fn`
};
}
_postShaderCompile (program, gl) {
this._getBinding(program).texLoc = gl.getUniformLocation(program, `atlas${this._uid}`);
}
_preDraw (program, drawMetadata, gl) {
this.init = true;
for (let i = 0; i < this.numImages; i++) {
const image = this[`image-${i}`];
this.init = this.init && image.canvas;
}
if (this.init && !this.texture) {
const textureAtlasSize = 4096;
const imageSize = 256;
gl.activeTexture(gl.TEXTURE0 + drawMetadata.freeTexUnit);
this.texture = gl.createTexture();
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.bindTexture(gl.TEXTURE_2D, this.texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, textureAtlasSize, textureAtlasSize, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
let offsetX = 0;
let offsetY = 0;
for (let i = 0; i < this.numImages; i++) {
const image = this[`image-${i}`];
// get image, push image to texture atlas
gl.texSubImage2D(gl.TEXTURE_2D, 0, offsetX, offsetY, gl.RGBA, gl.UNSIGNED_BYTE, image.canvas);
offsetX += imageSize;
if (offsetX + imageSize > textureAtlasSize) {
offsetX = 0;
offsetY += imageSize;
}
}
gl.generateMipmap(gl.TEXTURE_2D);
}
if (this.texture) {
gl.activeTexture(gl.TEXTURE0 + drawMetadata.freeTexUnit);
gl.bindTexture(gl.TEXTURE_2D, this.texture);
gl.uniform1i(this._getBinding(program).texLoc, drawMetadata.freeTexUnit);
drawMetadata.freeTexUnit++;
}
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/ListTransform.js":
/*!*******************************************************!*\
!*** ./src/renderer/viz/expressions/ListTransform.js ***!
\*******************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ListTransform; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
class ListTransform extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
_bindMetadata (meta) {
super._bindMetadata(meta);
this._getChildren().forEach((transform, i) => Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkType"])('ListTransformation', `ListTransformation[${i}]`, 0, 'transformation', transform));
this.type = 'transformation';
}
eval (feature) {
return this.elems.map(elem => elem.eval(feature));
}
_applyToShaderSource (getGLSLforProperty) {
const childGLSL = this.elems.map(elem => elem._applyToShaderSource(getGLSLforProperty));
return {
preface: this._prefaceCode(`
${childGLSL.map(c => c.preface).join('\n')}
vec2 listTransform${this._uid}(vec2 p) {
${childGLSL.map(c => `p = ${c.inline}(p);`).join('\n')}
return p;
}
`),
inline: `listTransform${this._uid}`
};
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/Placement.js":
/*!***************************************************!*\
!*** ./src/renderer/viz/expressions/Placement.js ***!
\***************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Placement; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
/**
* Placement. Define an image offset relative to its size. Where:
* - `symbolPlacement: placement(1,1)` means to align the bottom left corner of the image with the point center.
* - `symbolPlacement: placement(0,0)` means to align the center of the image with the point center.
* - `symbolPlacement: placement(-1,-1)` means to align the top right corner of the image with the point center.
*
* ```
* |1
* |
* |
* -1 -------+------- 1
* |
* |
* -1|
* ```
*
* You can also use `align_center` and `align_bottom` to set the simbol placement as follows:
* - `symbolPlacement: align_bottom` is equivalent to `symbolPlacement: placement(0, 1)`
* - `symbolPlacement: align_center` is equivalent to `symbolPlacement: placement(0, 0)`
*
* @param {number} x - first numeric expression that indicates the image offset in the X direction.
* @param {number} y - second numeric expression that indicates the image offset in the Y direction.
* @return {Placement} Numeric expression
*
* @example <caption>Setting the aligment to the top corner of the image.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* symbol: s.image('./marker.svg').
* symbolPlacement: s.placement(1, 0)
* });
*
* @example <caption>Setting the aligment to the top corner of the image. (String)</caption>
* const viz = new carto.Viz(`
* symbol: image('./marker.svg')
* symbolPlacement: placement(1, 0)
* `);
*
* @memberof carto.expressions
* @name placement
* @function
* @api
*/
class Placement extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (x, y) {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 2, 'placement');
x = Object(_utils__WEBPACK_IMPORTED_MODULE_1__["implicitCast"])(x);
y = Object(_utils__WEBPACK_IMPORTED_MODULE_1__["implicitCast"])(y);
super({ x, y });
this.inlineMaker = inline => `vec2(${inline.x}, ${inline.y})`;
this.type = 'placement';
}
get value () {
return [this.x.value, this.y.value];
}
eval (feature) {
return [this.x.eval(feature), this.y.eval(feature)];
}
_bindMetadata (meta) {
super._bindMetadata(meta);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkType"])('placement', 'x', 0, 'number', this.x);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkType"])('placement', 'y', 1, 'number', this.y);
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/Ramp.js":
/*!**********************************************!*\
!*** ./src/renderer/viz/expressions/Ramp.js ***!
\**********************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Ramp; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
/* harmony import */ var _RampImage__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./RampImage */ "./src/renderer/viz/expressions/RampImage.js");
/* harmony import */ var _RampGeneric__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./RampGeneric */ "./src/renderer/viz/expressions/RampGeneric.js");
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./constants */ "./src/renderer/viz/expressions/constants.js");
/**
* Create a ramp: a mapping between an input (numeric or categorical) and an output (number, colors and/or images)
*
* When the input has the same number of categories (without taking the "others" category into account).
* Then, each input category will have a one to one match with an output value.
*
* Some case examples:
* `ramp(buckets($product, ['A, 'B', 'C']), [house, car, bus])`
* `ramp(buckets($price, [20, 50, 120]), [1, 10, 4, 12])`
* `ramp(top($product, 3), [blue, yellow, green])`
* `ramp(globalQuantiles($price, 3), [red, yellow, green])`
*
* When the input has different number of categories or the input is a linear expression.
* Then it will interpolate the output values (Note: this is not supported if output values are images)
*
* Some case examples:
* `ramp(linear($price, 1, 10) [green, yellow, red])`
* `ramp(buckets($product, ['A, 'B', 'C'], [red, blue]))
* - When the input is a categorical property, we wrap it automatically in a CategoryIndex expression
* `ramp($product, Prism)` (equivalent to `ramp($categoryIndex($product)), Prism)`
* - When the input is a numeric property, we wrap it automatically in a Linear expression.
* `ramp($price, Prism)` (equivalent to `ramp($linear($price)), Prism)`
*
* The "others" value is setted by default, depending on the output type:
* - If it is "Number", the "others" value is 1.
* - If it is "Color" from a color array (i.e: [red, yellow, green]), the "others" value is the gray color.
* - If it is "Color" from a cartocolor palette (i.e: Prism), the "others" value is the last color of the palette.
* - If it is "Image", the "others" value is a circle.
*
* If we add a third parameter, the "others" default value will be overridden by this one
*
* @param {Number|Category} input - The input expression to give a color
* @param {Palette|Color[]|Number[]} palette - The color palette that is going to be used
* @param {Number|Color|Image} [others] - Value that overrides the default value for "others"
* @return {Number|Color|Image}
*
* @example <caption>Mapping categories to numbers, colors and images.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* width: s.ramp(s.buckets(s.prop('product'), ['A, 'B', 'C']), [1, 2, 3])
* color: s.ramp(s.buckets(s.prop('product'), ['A, 'B', 'C']), s.palettes.PRISM)
* strokeColor: s.ramp(s.buckets(s.prop('product'), ['A, 'B', 'C']), [s.namedColor('red'), s.namedColor('yellow'), s.namedColor('green')])
* symbol: s.ramp(s.buckets(s.prop('product'), ['A, 'B', 'C']), [s.HOUSE, s.CAR, s.BUS])
* });
*
* @example <caption>Mapping categories to numbers, colors and images. (String)</caption>
* const viz = new carto.Viz(`
* width: ramp(buckets($product), ['A, 'B', 'C']), [1, 2, 3])
* color: ramp(buckets($product), ['A, 'B', 'C']), Prism)
* strokeColor: ramp(buckets($product), ['A, 'B', 'C']), [red, yellow, green])
* symbol: ramp(buckets($product), ['A, 'B', 'C']), [house, car, bus])
* `);
*
* @example <caption>Mapping classified numeric properties to numbers, colors and images.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* width: s.ramp(s.buckets(s.prop('price'), [40, 100]), [1, 2, 3])
* color: s.ramp(s.buckets(s.prop('price'), [40, 100]), s.palettes.PRISM)
* strokeColor: s.ramp(s.buckets(s.prop('price'), [40, 100]), [s.namedColor('red'), s.namedColor('yellow'), s.namedColor(green)])
* symbol: s.ramp(s.buckets(s.prop('price'), [40, 100]), [s.HOUSE), s.CAR, s.BUS])
* });
*
* @example <caption>Mapping classified numeric properties to numbers, colors and images. (String)</caption>
* const viz = new carto.Viz(`
* width: ramp(buckets($price, [40, 100]), [1, 2, 3])
* color: ramp(buckets($price, [40, 100]), Prism)
* strokeColor: ramp(buckets($price, [40, 100]), [red, yellow, green])
* symbol: ramp(buckets($price, [40, 100]), [house, car, bus])
* `);
*
* @example <caption>Override default values.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* width: s.ramp(s.top(s.prop('price'), 3), [1, 2, 3], 0)
* strokeColor: s.ramp(s.top(s.prop('price'), 3), Prism, s.namedColor('red'))
* color: s.ramp(s.top(s.prop('price'), 3), [s.namedColor('blue'), s.namedColor('red'), s.namedColor('yellow')], s.namedColor(black))
* symbol: s.ramp(s.top(s.prop('price'), 3), [s.HOUSE, s.CAR, s.BUS], s.CROSS)
* });
*
* @example <caption>Override default values. (String)</caption>
* const viz = new carto.Viz(`
* width: ramp(top($price, 3), [1, 2, 3], 0)
* strokeColor: ramp(top($price, 3), Prism, red)
* color: ramp(top($price, 3), [blue, red, yellow], black)
* symbol: ramp(top($price, 3), [house, car, bus], cross)
* `);
*
* @memberof carto.expressions
* @name ramp
* @function
* @api
*/
/**
* Ramp Class
*
* A mapping between an input (numeric or categorical) and an output (number, colors and/or images)
* This class is instanced automatically by using the `ramp` function. It is documented for its methods.
* Read more about ramp expression at {@link carto.expressions.ramp}.
*
* @name expressions.Ramp
* @abstract
* @hideconstructor
* @class
* @api
*/
class Ramp extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (input, palette, others = _constants__WEBPACK_IMPORTED_MODULE_4__["DEFAULT_RAMP_OTHERS"]) {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 3, 'ramp');
input = Object(_utils__WEBPACK_IMPORTED_MODULE_1__["implicitCast"])(input);
palette = Object(_utils__WEBPACK_IMPORTED_MODULE_1__["implicitCast"])(palette);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkExpression"])('ramp', 'input', 0, input);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkExpression"])('ramp', 'palette', 1, palette);
if (others !== _constants__WEBPACK_IMPORTED_MODULE_4__["DEFAULT_RAMP_OTHERS"]) {
others = Object(_utils__WEBPACK_IMPORTED_MODULE_1__["implicitCast"])(others);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkExpression"])('ramp', 'others', 2, others);
}
super({ input, palette });
this.palette = palette;
this.others = others;
this.type = palette.type;
this._defaultOthers = others === _constants__WEBPACK_IMPORTED_MODULE_4__["DEFAULT_RAMP_OTHERS"];
}
_bindMetadata (metadata) {
super._bindMetadata(metadata);
switch (this.palette.type) {
case 'image-list':
Object.setPrototypeOf(this, _RampImage__WEBPACK_IMPORTED_MODULE_2__["default"].prototype);
break;
default:
Object.setPrototypeOf(this, _RampGeneric__WEBPACK_IMPORTED_MODULE_3__["default"].prototype);
break;
}
return this._bindMetadata(metadata);
}
/**
* Get a legend for the ramp.
*
* Note: This method works only for feature property independent outputs.
* Example:
* - This works: `ramp($price, [5, 15])`
* - This does not work: `ramp($price, [5, $amount])`
*
* @param {Object} config - Optional configuration
* @param {String} config.othersLabel - Name for other category values. Defaults to 'CARTO_VL_OTHERS'.
* @param {Number} config.samples - Number of samples for numeric values to be returned. Defaults to 10. The maximum number of samples is 100.
* @return {Object} - `{ type, data }`. 'type' could be category or number. Data is an array of { key, value } objects. 'key' depends on the expression type. 'value' is the result evaluated by the ramp. There is more information in the examples.
* @api
* @example <caption>Get legend for a color ramp of a categorical property.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* color: s.ramp(s.prop('vehicles'), s.palettes.PRISM)
* });
*
* layer.on('loaded', () => {
* const legend = layer.viz.color.getLegendData();
* // legend = {
* // type: 'category',
* // name: '$vehicles',
* // data: [
* // { key: 'Bicycle', value: { r: 95, g: 70, b: 144, a: 1 } },
* // { key: 'Car', value: { r: 29, g: 105, b: 150, a: 1 } },
* // { key: 'Bus', value: { r: 56, g: 166, b: 165, a: 1 } },
* // { key: 'CARTO_VL_OTHERS', value: { r: 15, g: 133, b: 84, a: 1 } }
* // ]
* // }
* });
*
* @example <caption>Get legend for a color ramp of a categorical property. (String)</caption>
* const viz = new carto.Viz(`
* color: ramp($vehicles, PRISM)
* ´);
*
* layer.on('loaded', () => {
* const legend = layer.viz.color.getLegendData();
* // legend = {
* // type: 'category',
* // name: '$vehicles',
* // data: [
* // { key: 'Bicycle', value: { r: 95, g: 70, b: 144, a: 1 } },
* // { key: 'Car', value: { r: 29, g: 105, b: 150, a: 1 } },
* // { key: 'Bus', value: { r: 56, g: 166, b: 165, a: 1 } },
* // { key: 'CARTO_VL_OTHERS', value: { r: 15, g: 133, b: 84, a: 1 } }
* // ]
* // }
* });
*
* @example <caption>Get legend for an image ramp of a categorical property.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* symbol: s.ramp(s.prop('vehicles'), [s.BICYCLE, s.CAR, s.BUS])
* });
*
* layer.on('loaded', () => {
* const legend = layer.viz.symbol.getLegendData();
* // legend = {
* // type: 'category',
* // name: '$vehicles',
* // data: [
* // { key: 'Bicycle', value: bicycleImageUrl },
* // { key: 'Car', value: carImageUrl },
* // { key: 'Bus', value: busImageUrl },
* // { key: 'CARTO_VL_OTHERS', value: circleImageUrl }
* // ]
* // }
* });
*
* @example <caption>Get legend for an image ramp of a categorical property. (String)</caption>
* const viz = new carto.Viz(`
* symbol: ramp('$vehicles'), [BICYCLE, CAR, BUS])
* `);
*
* layer.on('loaded', () => {
* const legend = layer.viz.symbol.getLegendData();
* // legend = {
* // type: 'category',
* // name: '$vehicles',
* // data: [
* // { key: 'Bicycle', value: bicycleImageUrl },
* // { key: 'Car', value: carImageUrl },
* // { key: 'Bus', value: busImageUrl },
* // { key: 'CARTO_VL_OTHERS', value: circleImageUrl }
* // ]
* // }
* });
*
* @example <caption>Get legend of a ramp top expression and set "others" label.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* color: s.ramp(s.top(s.prop('vehicles')), s.palettes.PRISM)
* });
*
* layer.on('loaded', () => {
* const legend = layer.viz.color.getLegendData({
* othersLabel: 'Other Vehicles'
* });
*
* // legend = {
* // type: 'category',
* // name: 'top($vehicles)',
* // data: [
* // { key: 'Bicycle', value: { r: 95, g: 70, b: 144, a: 1 } },
* // { key: 'Car', value: { r: 29, g: 105, b: 150, a: 1 } },
* // { key: 'Bus', value: { r: 56, g: 166, b: 165, a: 1 } },
* // { key: 'Other Vehicles', value: { r: 15, g: 133, b: 84, a: 1 } }
* // ]
* // }
* });
*
* @example <caption>Get legend of a ramp top expression and set "others" label. (String)</caption>
* const viz = new carto.Viz(`
* color: ramp(top($vehicles, 5), PRISM)
* `);
*
* layer.on('loaded', () => {
* const legend = layer.viz.color.getLegendData({
* othersLabel: 'Other Vehicles'
* });
*
* // legend = {
* // type: 'category',
* // name: 'top($vehicles)',
* // data: [
* // { key: 'Bicycle', value: { r: 95, g: 70, b: 144, a: 1 } },
* // { key: 'Car', value: { r: 29, g: 105, b: 150, a: 1 } },
* // { key: 'Bus', value: { r: 56, g: 166, b: 165, a: 1 } },
* // { key: 'Other Vehicles', value: { r: 15, g: 133, b: 84, a: 1 } }
* // ]
* // }
* });
*
* @example <caption>Get legend for a linear ramp expression and set number of samples.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* color: s.ramp(s.linear(s.prop('numvehicles'), 1, 100), s.palettes.PRISM)
* });
*
* layer.on('loaded', () => {
* const legend = layer.viz.color.getLegendData({
* samples: 4
* });
*
* // legend = {
* // type: 'number',
* // name: 'linear($numvehicles, 1, 100)',
* // data: [
* // { key: 25, value: { r: 95, g: 70, b: 144, a: 1 } },
* // { key: 50, value: { r: 29, g: 105, b: 150, a: 1 } },
* // { key: 75, value: { r: 56, g: 166, b: 165, a: 1 } },
* // { key: 100, value: { r: 15, g: 133, b: 84, a: 1 } }
* // ]
* // }
* });
*
* @example <caption>Get legend for a linear ramp expression and set number of samples. (String)</caption>
* const viz = new carto.Viz(`
* color: ramp(linear($numvehicles, 1, 100), PRISM)
* `);
*
* layer.on('loaded', () => {
* const legend = layer.viz.color.getLegendData({
* samples: 4
* });
*
* // legend = {
* // type: 'number',
* // name: 'linear($numvehicles, 1, 100)',
* // data: [
* // { key: 25, value: { r: 95, g: 70, b: 144, a: 1 } },
* // { key: 50, value: { r: 29, g: 105, b: 150, a: 1 } },
* // { key: 75, value: { r: 56, g: 166, b: 165, a: 1 } },
* // { key: 100, value: { r: 15, g: 133, b: 84, a: 1 } }
* // ]
* // }
* });
*
* @example <caption>Get legend for a buckets ramp expression.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* color: s.ramp(s.buckets((s.prop('numvehicles'), [1, 2, 3]), s.palettes.PRISM))
* });
*
* layer.on('loaded', () => {
* const legend = layer.viz.color.getLegendData();
*
* // legend = {
* // type: 'number',
* // name: 'buckets($numvehicles, [1, 2, 3])',
* // data: [
* // { key: [-Infinity, 1], value: { r: 95, g: 70, b: 144, a: 1 } },
* // { key: [1, 2], value: { r: 29, g: 105, b: 150, a: 1 } },
* // { key: [2, 3], value: { r: 56, g: 166, b: 165, a: 1 } },
* // { key: [3, +Infinity], value: { r: 15, g: 133, b: 84, a: 1 } }
* // ]
* // }
* });
*
* @example <caption>Get legend for a buckets ramp expression. (String)</caption>
* const s = carto.expressions;
* const viz = new carto.Viz(`
* color: ramp(buckets($numvehicles', [1, 2, 3]), Prism))
* `);
*
* layer.on('loaded', () => {
* const legend = layer.viz.color.getLegendData();
*
* // legend = {
* // type: 'number',
* // name: 'buckets($numvehicles, [1, 2, 3])',
* // data: [
* // { key: [-Infinity, 1], value: { r: 95, g: 70, b: 144, a: 1 } },
* // { key: [1, 2], value: { r: 29, g: 105, b: 150, a: 1 } },
* // { key: [2, 3], value: { r: 56, g: 166, b: 165, a: 1 } },
* // { key: [3, +Infinity], value: { r: 15, g: 133, b: 84, a: 1 } }
* // ]
* // }
* });
*
* @example <caption>Get legend for a classifier ramp expression.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* color: s.ramp(s.globalEqIntervals(s.prop('numvehicles'), 4), s.palettes.PRISM)
* });
*
* layer.on('loaded', () => {
* const legend = layer.viz.color.getLegendData();
*
* // legend = {
* // type: 'number',
* // name: 'globalEqIntervals($numvehicles, 4)',
* // data: [
* // { key: [-Infinity, 25], value: { r: 95, g: 70, b: 144, a: 1 } },
* // { key: [25, 50], value: { r: 29, g: 105, b: 150, a: 1 } },
* // { key: [50, 75], value: { r: 56, g: 166, b: 165, a: 1 } },
* // { key: [100, +Infinity], value: { r: 15, g: 133, b: 84, a: 1 } }
* // ]
* // }
* });
*
* @example <caption>Get legend for a classifier ramp expression. (String)</caption>
* const s = carto.expressions;
* const viz = new carto.Viz(`
* color: ramp(globalEqIntervals($numvehicles, 4), Prism)
* `);
*
* layer.on('loaded', () => {
* const legend = layer.viz.color.getLegendData();
*
* // legend = {
* // type: 'number',
* // name: 'globalEqIntervals($numvehicles, 4)',
* // data: [
* // { key: [-Infinity, 25], value: { r: 95, g: 70, b: 144, a: 1 } },
* // { key: [25, 50], value: { r: 29, g: 105, b: 150, a: 1 } },
* // { key: [50, 75], value: { r: 56, g: 166, b: 165, a: 1 } },
* // { key: [100, +Infinity], value: { r: 15, g: 133, b: 84, a: 1 } }
* // ]
* // }
* });
*
* @memberof expressions.Ramp
* @name getLegendData
* @instance
* @api
*/
}
/***/ }),
/***/ "./src/renderer/viz/expressions/RampGeneric.js":
/*!*****************************************************!*\
!*** ./src/renderer/viz/expressions/RampGeneric.js ***!
\*****************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return RampGeneric; });
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
/* harmony import */ var _basic_property__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./basic/property */ "./src/renderer/viz/expressions/basic/property.js");
/* harmony import */ var _linear__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./linear */ "./src/renderer/viz/expressions/linear.js");
/* harmony import */ var _color_CIELab_glsl__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./color/CIELab.glsl */ "./src/renderer/viz/expressions/color/CIELab.glsl");
/* harmony import */ var _color_CIELab_glsl__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_color_CIELab_glsl__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _CategoryIndex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./CategoryIndex */ "./src/renderer/viz/expressions/CategoryIndex.js");
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./src/renderer/viz/expressions/constants.js");
/* harmony import */ var _color_palettes_Palette__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./color/palettes/Palette */ "./src/renderer/viz/expressions/color/palettes/Palette.js");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _basic_constant__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./basic/constant */ "./src/renderer/viz/expressions/basic/constant.js");
/* harmony import */ var _color_NamedColor__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./color/NamedColor */ "./src/renderer/viz/expressions/color/NamedColor.js");
/* harmony import */ var _aggregation_cluster_ClusterAggregation__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./aggregation/cluster/ClusterAggregation */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAggregation.js");
class RampGeneric extends _base__WEBPACK_IMPORTED_MODULE_7__["default"] {
_bindMetadata (metadata) {
const DEFAULT_RAMP_OTHERS_NUMBER = new _basic_constant__WEBPACK_IMPORTED_MODULE_8__["default"](1);
const DEFAULT_RAMP_OTHERS_COLOR = new _color_NamedColor__WEBPACK_IMPORTED_MODULE_9__["default"]('gray');
super._bindMetadata(metadata);
this.type = this.palette.childType;
if (this.others === _constants__WEBPACK_IMPORTED_MODULE_5__["DEFAULT_RAMP_OTHERS"]) {
this.others = this.palette.type === 'number-list'
? DEFAULT_RAMP_OTHERS_NUMBER
: DEFAULT_RAMP_OTHERS_COLOR;
this.others._bindMetadata(metadata);
} else {
this.others._bindMetadata(metadata);
Object(_utils__WEBPACK_IMPORTED_MODULE_0__["checkType"])('ramp', 'others', 2, this.palette.childType, this.others);
}
if (this.input.isA(_basic_property__WEBPACK_IMPORTED_MODULE_1__["default"]) || this.input.isA(_aggregation_cluster_ClusterAggregation__WEBPACK_IMPORTED_MODULE_10__["default"])) {
this.input = this.input.type === 'number'
? new _linear__WEBPACK_IMPORTED_MODULE_2__["default"](this.input)
: new _CategoryIndex__WEBPACK_IMPORTED_MODULE_4__["default"](this.input);
this.input._bindMetadata(metadata);
}
Object(_utils__WEBPACK_IMPORTED_MODULE_0__["checkType"])('ramp', 'input', 0, ['number', 'category'], this.input);
this.childrenNames.push('others');
this._metadata = metadata;
}
eval (feature) {
const input = this.input.eval(feature);
return this._calcEval(input, feature);
}
_calcEval (input, feature) {
const { palette, others } = this._getPalette();
const paletteValues = this.palette.isA(_color_palettes_Palette__WEBPACK_IMPORTED_MODULE_6__["default"])
? palette.map((color) => color.eval(feature))
: this.palette.eval(feature);
if (input === _constants__WEBPACK_IMPORTED_MODULE_5__["OTHERS_INDEX"]) {
return others.eval(feature);
}
const maxValues = paletteValues.length - 1;
const min = Math.floor(input * maxValues);
const max = Math.ceil(input * maxValues);
const clampMin = Object(_utils__WEBPACK_IMPORTED_MODULE_0__["clamp"])(min, 0, maxValues);
const clampMax = Object(_utils__WEBPACK_IMPORTED_MODULE_0__["clamp"])(max, 0, maxValues);
const m = Object(_utils__WEBPACK_IMPORTED_MODULE_0__["fract"])(input * maxValues);
return Object(_utils__WEBPACK_IMPORTED_MODULE_0__["mix"])(paletteValues[clampMin], paletteValues[clampMax], m);
}
get value () {
return this.eval();
}
getLegendData (options) {
const config = Object.assign({}, _constants__WEBPACK_IMPORTED_MODULE_5__["DEFAULT_OPTIONS"], options);
const type = this.input.type;
const legendData = this.input.getLegendData(config);
const data = legendData.data.map(({ key, value }) => {
value = this._calcEval(value, undefined);
return { key, value };
});
return { type, ...legendData, data };
}
_applyToShaderSource (getGLSLforProperty) {
const input = this.input._applyToShaderSource(getGLSLforProperty);
const { palette, others } = this._getPalette();
const GLSLPalette = palette.map(color => color._applyToShaderSource(getGLSLforProperty));
const GLSLOthers = others._applyToShaderSource(getGLSLforProperty);
const GLSLBlend = this.palette.type === 'number-list'
? _getInlineGLSLBlend(GLSLPalette)
: _getInlineColorGLSLBlend(GLSLPalette);
const rampFnReturnType = this.palette.type === 'number-list' ? 'float' : 'vec4';
const inline = `ramp_color${this._uid}(${input.inline})`;
const preface = this._prefaceCode(`
${input.preface}
${_color_CIELab_glsl__WEBPACK_IMPORTED_MODULE_3___default.a}
${GLSLPalette.map(elem => elem.preface).join('\n')}
${GLSLOthers.preface}
${rampFnReturnType} ramp_color${this._uid}(float x){
return x==${_constants__WEBPACK_IMPORTED_MODULE_5__["OTHERS_GLSL_VALUE"]}
? ${GLSLOthers.inline}
: ${GLSLBlend};
}`
);
console.log('PREFACE: ' + preface);
console.log('INLINE: ' + inline);
return { preface, inline };
}
_getPalette () {
return this.palette.isA(_color_palettes_Palette__WEBPACK_IMPORTED_MODULE_6__["default"])
? this._getColorPalette()
: { palette: this.palette.elems, others: this.others };
}
_getColorPalette () {
const subPalette = this.palette.getColors(this.input.numCategoriesWithoutOthers);
return {
palette: subPalette.colors,
others: this._defaultOthers && subPalette.othersColor ? subPalette.othersColor : this.others
};
}
}
function _getInlineGLSLBlend (GLSLPalette) {
return _generateGLSLBlend(GLSLPalette.map(elem => elem.inline));
}
function _getInlineColorGLSLBlend (GLSLPalette) {
return `cielabToSRGBA(${_generateGLSLBlend(GLSLPalette.map(elem => `sRGBAToCieLAB(${elem.inline})`))})`;
}
function _generateGLSLBlend (list, index = 0) {
const currentValue = list[index];
if (index === list.length - 1) {
return currentValue;
}
const nextBlend = _generateGLSLBlend(list, index + 1);
return _mixClampGLSL(currentValue, nextBlend, index, list.length);
}
function _mixClampGLSL (currentValue, nextBlend, index, listLength) {
const min = (index / (listLength - 1)).toFixed(20);
const max = (1 / (listLength - 1)).toFixed(20);
const clamp = `clamp((x - ${min})/${max}, 0., 1.)`;
return `mix(${currentValue}, ${nextBlend}, ${clamp})`;
}
/***/ }),
/***/ "./src/renderer/viz/expressions/RampImage.js":
/*!***************************************************!*\
!*** ./src/renderer/viz/expressions/RampImage.js ***!
\***************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return RampImage; });
/* harmony import */ var _defaultSVGs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../defaultSVGs */ "./src/renderer/viz/defaultSVGs.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
/* harmony import */ var _basic_property__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./basic/property */ "./src/renderer/viz/expressions/basic/property.js");
/* harmony import */ var _CategoryIndex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./CategoryIndex */ "./src/renderer/viz/expressions/CategoryIndex.js");
/* harmony import */ var _ListImage__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ListImage */ "./src/renderer/viz/expressions/ListImage.js");
/* harmony import */ var _Image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Image */ "./src/renderer/viz/expressions/Image.js");
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./constants */ "./src/renderer/viz/expressions/constants.js");
const DEFAULT_RAMP_OTHERS_IMAGE = new _Image__WEBPACK_IMPORTED_MODULE_5__["default"](_defaultSVGs__WEBPACK_IMPORTED_MODULE_0__["default"].circle);
class RampImage extends _base__WEBPACK_IMPORTED_MODULE_6__["default"] {
_bindMetadata (metadata) {
_base__WEBPACK_IMPORTED_MODULE_6__["default"].prototype._bindMetadata.call(this, metadata);
this.type = this.palette.childType;
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkType"])('ramp', 'input', 0, 'category', this.input);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkInstance"])('ramp', 'palette', 1, _ListImage__WEBPACK_IMPORTED_MODULE_4__["default"], this.palette);
if (this.others === _constants__WEBPACK_IMPORTED_MODULE_7__["DEFAULT_RAMP_OTHERS"]) {
this.others = DEFAULT_RAMP_OTHERS_IMAGE;
} else {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkType"])('ramp', 'others', 2, 'image', this.others);
}
if (this.input.isA(_basic_property__WEBPACK_IMPORTED_MODULE_2__["default"])) {
this.input = new _CategoryIndex__WEBPACK_IMPORTED_MODULE_3__["default"](this.input);
this.input._bindMetadata(metadata);
}
this.others._bindMetadata(metadata);
this.childrenNames.push('others');
}
get value () {
return this.eval();
}
eval (feature) {
const index = this.input.eval(feature);
return this._calcEval(index);
}
_calcEval (input) {
const index = Math.round(input * (this.input.numCategoriesWithoutOthers - 1));
const paletteValues = this.palette.eval();
return paletteValues[index] || this.others.eval();
}
getLegendData (options) {
const type = this.input.type;
const legendData = this.input.getLegendData(options);
const data = legendData.data.map(({ key, value }) => {
value = this._calcEval(value);
return { key, value };
});
return { type, ...legendData, data };
}
_applyToShaderSource (getGLSLforProperty) {
const input = this.input._applyToShaderSource(getGLSLforProperty);
const images = this.palette._applyToShaderSource(getGLSLforProperty);
const others = this.others._applyToShaderSource(getGLSLforProperty);
return {
preface: this._prefaceCode(`
uniform float rampImageMultiplier${this._uid};
${input.preface}
${images.preface}
${others.preface}
vec4 rampImage${this._uid}(vec2 imageUV, float index){
if (index == ${_constants__WEBPACK_IMPORTED_MODULE_7__["OTHERS_GLSL_VALUE"]}){
return ${others.inline};
}
return ${images.inline}(imageUV, rampImageMultiplier${this._uid}*index);
}
`),
inline: `rampImage${this._uid}(imageUV, ${input.inline})`
};
}
_postShaderCompile (program, gl) {
super._postShaderCompile(program, gl);
this._getBinding(program)._multiplierLoc = gl.getUniformLocation(program, `rampImageMultiplier${this._uid}`);
}
_preDraw (program, drawMetadata, gl) {
super._preDraw(program, drawMetadata, gl);
gl.uniform1f(this._getBinding(program)._multiplierLoc, this.input.numCategoriesWithoutOthers - 1);
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/SVG.js":
/*!*********************************************!*\
!*** ./src/renderer/viz/expressions/SVG.js ***!
\*********************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return SVG; });
/* harmony import */ var _Image__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Image */ "./src/renderer/viz/expressions/Image.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
class SVG extends _Image__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (svg) {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 1, 'svg');
// This doesn't work in Firefox for local SVG images
super(`data:image/svg+xml,${encodeURIComponent(svg)}`);
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/Scaled.js":
/*!************************************************!*\
!*** ./src/renderer/viz/expressions/Scaled.js ***!
\************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Scaled; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _expressions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../expressions */ "./src/renderer/viz/expressions.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
/**
* Scale a width value to keep feature width constant in real space (meters).
* This will change the width in pixels at different zoom levels to enforce the previous condition.
*
* @param {Number} width - pixel width at zoom level `zoomlevel`
* @param {Number} [zoomlevel=0] - zoomlevel at which `width` is relative to
* @return {Number}
*
* @example <caption>Keep feature width in meters constant with 25 pixels at zoom level 7.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* width: s.scaled(25, 7)
* });
*
* @example <caption>Keep feature width in meters constant with 25 pixels at zoom level 7. (String)</caption>
* const viz = new carto.Viz(`
* width: s.scaled(25, 7)
* `);
*
* @memberof carto.expressions
* @name scaled
* @function
* @api
*/
class Scaled extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (width, zoomlevel = 0) {
width = Object(_utils__WEBPACK_IMPORTED_MODULE_2__["implicitCast"])(width);
zoomlevel = Object(_utils__WEBPACK_IMPORTED_MODULE_2__["implicitCast"])(zoomlevel);
super({
scale: Object(_expressions__WEBPACK_IMPORTED_MODULE_1__["div"])(Object(_expressions__WEBPACK_IMPORTED_MODULE_1__["mul"])(width, 0), Object(_expressions__WEBPACK_IMPORTED_MODULE_1__["pow"])(2, zoomlevel))
});
this.type = 'number';
this.inlineMaker = inline => inline.scale;
}
get value () {
return this.scale.value;
}
eval (feature) {
return this.scale.eval(feature);
}
_bindMetadata (metadata) {
super._bindMetadata(metadata);
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkType"])('scaled', 'width', 0, 'number', this.scale.a.a);
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkType"])('scaled', 'zoomlevel', 1, 'number', this.scale.b);
}
_preDraw (program, drawMetadata, gl) {
this.scale.a.b.value = Math.pow(2, drawMetadata.zoomLevel);
super._preDraw(program, drawMetadata, gl);
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/Zoomrange.js":
/*!***************************************************!*\
!*** ./src/renderer/viz/expressions/Zoomrange.js ***!
\***************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Zoomrange; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _expressions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../expressions */ "./src/renderer/viz/expressions.js");
/* harmony import */ var _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../errors/carto-validation-error */ "./src/errors/carto-validation-error.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils */ "./src/renderer/viz/expressions/utils.js");
/**
* Define a list of interpolated zoom ranges based on an input breakpoint list. Useful in combination with ramp (see examples).
*
* @param {Number[]} _zoomBreakpointList - list of zoom breakpoints with at least two elements
* @return {Number}
*
* @example <caption>Set the width to 1 at zoom levels < 7, set the width at 20 at zoom levels > 10, interpolate between 1 and 20 at zoom levels in the [7,10] range.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* width: s.ramp(s.zoomrange([7, 10]), [1, 20])
* });
*
* @example <caption>Set the width to 1 at zoom levels < 7, set the width at 20 at zoom levels > 10, interpolate between 1 and 20 at zoom levels in the [7,10] range. (String)</caption>
* const viz = new carto.Viz(`
* width: width: ramp(zoomrange([7, 10]), [1, 20])
* `);
*
* @memberof carto.expressions
* @name zoomrange
* @function
* @api
*/
class Zoomrange extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (zoomBreakpointList) {
zoomBreakpointList = Object(_utils__WEBPACK_IMPORTED_MODULE_3__["implicitCast"])(zoomBreakpointList);
super({});
Object(_utils__WEBPACK_IMPORTED_MODULE_3__["checkExpression"])('zoomrange', 'zoomBreakpointList', 0, zoomBreakpointList);
this.type = 'number';
this._zoomBreakpointList = zoomBreakpointList;
this.inlineMaker = inline => inline._impostor;
}
_bindMetadata (metadata) {
this._zoomBreakpointList._bindMetadata(metadata);
Object(_utils__WEBPACK_IMPORTED_MODULE_3__["checkType"])('zoomrange', 'zoomBreakpointList', 0, 'number-list', this._zoomBreakpointList);
if (this._zoomBreakpointList.elems.length < 2) {
throw new _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__["default"]('zoomrange() function must receive a list with at least two elements.', _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_2__["CartoValidationErrorTypes"].INCORRECT_VALUE);
}
const breakpointListCopy = [...this._zoomBreakpointList.elems];
this._impostor = _genImpostor(breakpointListCopy, 0, breakpointListCopy.length - 1);
this.childrenNames.push('_impostor');
super._bindMetadata(metadata);
}
eval (feature) {
return this._impostor.eval(feature);
}
/**
* Get the zoomrange value
*
* @api
* @memberof expressions.Zoomrange
* @name value
* @return {Array} - Zoom range breakpoint list
*/
get value () {
return this._zoomBreakpointList.elems.map(elem => elem.value);
}
}
function _genImpostor (list, numerator, denominator) {
if (list.length === 1) {
return 1;
}
const a = list[0];
const b = list[1];
list.shift();
return Object(_expressions__WEBPACK_IMPORTED_MODULE_1__["blend"])(numerator / denominator,
_genImpostor(list, numerator + 1, denominator),
Object(_expressions__WEBPACK_IMPORTED_MODULE_1__["linear"])(Object(_expressions__WEBPACK_IMPORTED_MODULE_1__["pow"])(2, Object(_expressions__WEBPACK_IMPORTED_MODULE_1__["zoom"])()), Object(_expressions__WEBPACK_IMPORTED_MODULE_1__["pow"])(2, a), Object(_expressions__WEBPACK_IMPORTED_MODULE_1__["pow"])(2, b))
);
}
/***/ }),
/***/ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAggregation.js":
/*!********************************************************************************!*\
!*** ./src/renderer/viz/expressions/aggregation/cluster/ClusterAggregation.js ***!
\********************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ClusterAggregation; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _basic_property__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../basic/property */ "./src/renderer/viz/expressions/basic/property.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils */ "./src/renderer/viz/expressions/utils.js");
/* harmony import */ var _schema__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../../schema */ "./src/renderer/schema.js");
/* harmony import */ var _constants_metadata__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../../constants/metadata */ "./src/constants/metadata.js");
class ClusterAggregation extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor ({ property, expressionName, aggName, aggType }) {
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkExpression"])(expressionName, 'property', 0, property);
super({ property });
this._aggName = aggName;
this._expressionName = expressionName;
this.type = aggType;
}
get name () {
return this.property.name;
}
get propertyName () {
return _schema__WEBPACK_IMPORTED_MODULE_3__["column"].aggColumn(this.property.name, this._aggName);
}
get aggName () {
return this._aggName;
}
get numCategories () {
return this.property.numCategories;
}
get categories () {
return this.property.categories;
}
get value () {
return this.propertyName;
}
eval (feature) {
return feature[this.propertyName];
}
_bindMetadata (metadata) {
super._bindMetadata(metadata);
this._metadata = metadata;
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkInstance"])(this._expressionName, 'property', 0, _basic_property__WEBPACK_IMPORTED_MODULE_1__["default"], this.property);
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkType"])(this._expressionName, 'property', 0, this.type, this.property);
}
_applyToShaderSource (getGLSLforProperty) {
return {
preface: '',
inline: `${getGLSLforProperty(this.propertyName)}`
};
}
_postShaderCompile () {}
_getMinimumNeededSchema () {
return {
[this.property.name]: [{
type: _constants_metadata__WEBPACK_IMPORTED_MODULE_4__["aggregationTypes"].AGGREGATED,
op: this._aggName
}]
};
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAvg.js":
/*!************************************************************************!*\
!*** ./src/renderer/viz/expressions/aggregation/cluster/ClusterAvg.js ***!
\************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ClusterAvg; });
/* harmony import */ var _ClusterAggregation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ClusterAggregation */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAggregation.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils */ "./src/renderer/viz/expressions/utils.js");
/**
* Aggregate using the average. This operation disables the access to the property
* except within other cluster aggregate functions.
*
* Note: `clusterAvg` can only be created by {@link carto.expressions.prop|carto.expressions.prop}, not other expressions.
*
* @param {Number} property - Column of the table to be aggregated
* @return {Number} Aggregated column
*
* @example <caption>Use cluster average of the population as width.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* width: s.clusterAvg(s.prop('population'))
* });
*
* @example <caption>Use cluster average of the population as width. (String)</caption>
* const viz = new carto.Viz(`
* width: clusterAvg($population)
* `);
*
* @memberof carto.expressions
* @name clusterAvg
* @function
* @api
*/
class ClusterAvg extends _ClusterAggregation__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (property) {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 1, 'clusterAvg');
super({ property, expressionName: 'clusterAvg', aggName: 'avg', aggType: 'number' });
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/aggregation/cluster/ClusterCount.js":
/*!**************************************************************************!*\
!*** ./src/renderer/viz/expressions/aggregation/cluster/ClusterCount.js ***!
\**************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ClusterCount; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils */ "./src/renderer/viz/expressions/utils.js");
/* harmony import */ var _constants_metadata__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../../../constants/metadata */ "./src/constants/metadata.js");
/**
* Count of features per cluster.
*
* The `clusterCount` expression has no input parameters and if data is not aggregated, it always returns 1.
* It is not possible to use it as an input in global aggregations such as `globalMin` or `globalQuantiles`.
*
* @return {Number} Cluster feature count
*
* @example <caption>Use cluster count for width.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* width: s.clusterCount() / 50
* });
*
* @example <caption>Use cluster count for width. (String)</caption>
* const viz = new carto.Viz(`
* width: clusterCount() / 50
* `);
*
* @example <caption>Use cluster count with viewportQuantiles in a ramp for width and color.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* color: s.ramp(s.viewportQuantiles(s.clusterCount(), 5), [1, 20])
* width: s.ramp(s.viewportQuantiles(s.clusterCount(), 5), s.palettes.PINKYL))
* });
* // Note: this is not possible with globalQuantiles
*
* @example <caption>Use cluster count with viewportQuantiles in a ramp for width and color. (String)</caption>
* const viz = new carto.Viz(`
* width: ramp(viewportQuantiles(clusterCount(), 5), [1, 20])
* color: ramp(viewportQuantiles(clusterCount(), 5), Pinkyl)
* `);
* // Note: this is not possible with globalQuantiles
*
* @memberof carto.expressions
* @name clusterCount
* @function
* @api
*/
class ClusterCount extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor () {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 0, 'clusterCount');
super({});
this.type = 'number';
this._hasClusterFeatureCount = false;
}
get propertyName () {
return _constants_metadata__WEBPACK_IMPORTED_MODULE_2__["CLUSTER_FEATURE_COUNT"];
}
isFeatureDependent () {
return true;
}
eval (feature) {
return Number(feature[_constants_metadata__WEBPACK_IMPORTED_MODULE_2__["CLUSTER_FEATURE_COUNT"]]) || 1;
}
getLegendData () {
return {
data: this._hasClusterFeatureCount
? this._metadata.properties[_constants_metadata__WEBPACK_IMPORTED_MODULE_2__["CLUSTER_FEATURE_COUNT"]]
: []
};
}
_bindMetadata (metadata) {
super._bindMetadata(metadata);
this._metadata = metadata;
this._hasClusterFeatureCount = metadata.properties[_constants_metadata__WEBPACK_IMPORTED_MODULE_2__["CLUSTER_FEATURE_COUNT"]] !== undefined;
}
_applyToShaderSource (getGLSLforProperty) {
return {
preface: '',
inline: this._hasClusterFeatureCount ? getGLSLforProperty(_constants_metadata__WEBPACK_IMPORTED_MODULE_2__["CLUSTER_FEATURE_COUNT"]) : '1.'
};
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/aggregation/cluster/ClusterMax.js":
/*!************************************************************************!*\
!*** ./src/renderer/viz/expressions/aggregation/cluster/ClusterMax.js ***!
\************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ClusterMax; });
/* harmony import */ var _ClusterAggregation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ClusterAggregation */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAggregation.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils */ "./src/renderer/viz/expressions/utils.js");
/**
* Aggregate using the maximum. This operation disables the access to the property
* except within other cluster aggregate functions.
*
* Note: `clusterMax` can only be created by {@link carto.expressions.prop|carto.expressions.prop}, not other expressions.
*
* @param {Number} property - Column of the table to be aggregated
* @return {Number} Aggregated column
*
* @example <caption>Use cluster maximum of the population as width.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* width: s.clusterMax(s.prop('population'))
* });
*
* @example <caption>Use cluster maximum of the population as width. (String)</caption>
* const viz = new carto.Viz(`
* width: clusterMax($population)
* `);
*
* @memberof carto.expressions
* @name clusterMax
* @function
* @api
*/
class ClusterMax extends _ClusterAggregation__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (property) {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 1, 'clusterMax');
super({ property, expressionName: 'clusterMax', aggName: 'max', aggType: 'number' });
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/aggregation/cluster/ClusterMin.js":
/*!************************************************************************!*\
!*** ./src/renderer/viz/expressions/aggregation/cluster/ClusterMin.js ***!
\************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ClusterMin; });
/* harmony import */ var _ClusterAggregation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ClusterAggregation */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAggregation.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils */ "./src/renderer/viz/expressions/utils.js");
/**
* Aggregate using the minimum. This operation disables the access to the property
* except within other cluster aggregate functions.
*
* Note: `clusterMin` can only be created by {@link carto.expressions.prop|carto.expressions.prop}, not other expressions.
*
* @param {Number} property - Column of the table to be aggregated
* @return {Number} Aggregated column
*
* @example <caption>Use cluster minimum of the population as width.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* width: s.clusterMin(s.prop('population'))
* });
*
* @example <caption>Use cluster minimum of the population as width. (String)</caption>
* const viz = new carto.Viz(`
* width: clusterMin($population)
* `);
*
* @memberof carto.expressions
* @name clusterMin
* @function
* @api
*/
class ClusterMin extends _ClusterAggregation__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (property) {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 1, 'clusterMin');
super({ property, expressionName: 'clusterMin', aggName: 'min', aggType: 'number' });
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/aggregation/cluster/ClusterMode.js":
/*!*************************************************************************!*\
!*** ./src/renderer/viz/expressions/aggregation/cluster/ClusterMode.js ***!
\*************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ClusterMode; });
/* harmony import */ var _ClusterAggregation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ClusterAggregation */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAggregation.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils */ "./src/renderer/viz/expressions/utils.js");
/**
* Aggregate using the mode. This operation disables the access to the property
* except within other cluster aggregate functions.
*
* Note: `clusterMode` can only be created by {@link carto.expressions.prop|carto.expressions.prop}, not other expressions.
*
* @param {Category} property - Column of the table to be aggregated
* @return {Category} Aggregated column
*
* @example <caption>Use cluster mode of the population in a color ramp.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* color: s.ramp(s.clusterMode(s.prop('category')), s.palettes.PRISM)
* });
*
* @example <caption>Use cluster mode of the population in a color ramp. (String)</caption>
* const viz = new carto.Viz(`
* color: ramp(clusterMode($category), PRISM)
* `);
*
* @memberof carto.expressions
* @name clusterMode
* @function
* @api
*/
class ClusterMode extends _ClusterAggregation__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (property) {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 1, 'clusterMode');
super({ property, expressionName: 'clusterMode', aggName: 'mode', aggType: 'category' });
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/aggregation/cluster/ClusterSum.js":
/*!************************************************************************!*\
!*** ./src/renderer/viz/expressions/aggregation/cluster/ClusterSum.js ***!
\************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ClusterSum; });
/* harmony import */ var _ClusterAggregation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ClusterAggregation */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAggregation.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils */ "./src/renderer/viz/expressions/utils.js");
/**
* Aggregate using the sum. This operation disables the access to the property
* except within other cluster aggregate functions.
*
* Note: `clusterSum` can only be created by {@link carto.expressions.prop|carto.expressions.prop}, not other expressions.
*
* @param {Number} property - Column of the table to be aggregated
* @return {Number} Aggregated column
*
* @example <caption>Use cluster sum of the population as width.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* width: s.clusterSum(s.prop('population'))
* });
*
* @example <caption>Use cluster sum of the population as width. (String)</caption>
* const viz = new carto.Viz(`
* width: clusterSum($population)
* `);
*
* @memberof carto.expressions
* @name clusterSum
* @function
* @api
*/
class ClusterSum extends _ClusterAggregation__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (property) {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 1, 'clusterSum');
super({ property, expressionName: 'clusterSum', aggName: 'sum', aggType: 'number' });
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/aggregation/cluster/ClusterTime.js":
/*!*************************************************************************!*\
!*** ./src/renderer/viz/expressions/aggregation/cluster/ClusterTime.js ***!
\*************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ClusterTime; });
/* harmony import */ var _ClusterTimeDimension__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ClusterTimeDimension */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterTimeDimension.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils */ "./src/renderer/viz/expressions/utils.js");
/**
* Use discretised property as aggregate dimension. This operation disables the access to the property
* except within `clusterTime` expressions with the same parameters.
*
* Note: `clusterTime` can only be created with a {@link carto.expressions.prop|carto.expressions.prop},
* as the first parameter, not other expressions.
*
* When the units of resolution are cyclic periods such as 'dayOfWeek' (day of the week) or 'monthOfYear' (month of the year),
* the resulting expression takes a numeric value to represent the period, e.g. 1 for Monday or January.
*
* When the units are not cyclic (e.g. 'week' or 'month'), the resulting expression is a `TimeRange` that
* encompass each individual calendar period, for example week 2018-W03 (third week of 2018 from 2018-01-15 to 2018-01-21)
* or 2018-03 (March 2018, from 2018-03-01 to 2018-04-01).
*
* Accepted values for cyclic resolution periods are:
* - `semesterOfYear` (6-month term) takes values from 1 to 2
* - `trimesterOfYear` (4-month term) takes values from 1 to 3
* - `quarterOfYear` (3-month term) takes values from 1 to 4
* - `monthOfYear` takes values from 1 (January) to 12 (December)
* - `weekOfYear` follows [ISO 8601 numbering](https://en.wikipedia.org/wiki/ISO_week_date) taking values from 1 up to 53
* - `dayOfWeek` (as per ISO 8601, 1 = Monday, to 7 = Sunday
* - `dayOfMonth` takes values from 1 to 31
* - `dayOfYear` takes values from 1 to 366
* - `hourOfDay` takes values from 0 to 23
* - `minuteOfHour` takes values from 0 to 59
*
* Accepted values for serial resolution units are:
*
* - `year`, e.g. '2017'
* - `month`, e.g. '2017-03'
* - `day`, e.g. '2017-03-01'
* - `hour`, e.g. '2017-03-01T13'
* - `minute`, e.g. '2017-03-01T13:22'
* - `second`, e.g. '2017-03-01T13:22:31'
* - `week` represented as '2018-W03' (third week of 2018:, 2018-01-15 to 2018-01-21)
* - `quarter` as '2018-Q2' (second quarter of 2018, i.e. 2018-04 to 2018-06)
* - `semester` as '2018S2' (second semester of 2018, i.e. 2018-07 to 2018-12)
* - `trimester` as '2018t2' (second trimester of 2018, i.e. 2018-05 to 2018-08)
* - `decade` as 'D201' (decade 201, i.e. 2010 to 2019)
* - `century` as 'C21' (21st century, ie. 2001 to 2100)
* - `millennium` as 'M3' (3rd millennium: 2001 to 3000)
*
* The time zone is optional. By default UTC time will be used.
* It admits a fixed offset from UTC as a signed number of seconds,
* or [IANA](https://www.iana.org/time-zones) timezone [names](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
* such as `America/New_York` or `Europe/Madrid`, which not only define a time offset,
* but also rules for DST (daylight savings time).
*
* @param {Date} property - Column of the table to be discretised as dimension
* @param {String} units - Units of resolution for the discretization
* @param {String} timezone - Time zone in which the dates are discretised. UTC by default.
* @return {TimeRange|Number} Dimension column; takes time range values (intervals) for serial units of resolutions and numbers for recurrent units.
*
* @example <caption>Use months as a dimension of the cluster aggregations as `month`.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* month: s.clusterTime(s.prop('date', 'month', 'America/New_York'))
* });
*
* @example <caption>Use months as a dimension of the cluster aggregations as `month`. (String)</caption>
* const viz = new carto.Viz(`
* month: clusterTime($date, 'month', 'America/New_York')
* `);
*
* @memberof carto.expressions
* @name clusterTime
* @function
* @api
*/
class ClusterTime extends _ClusterTimeDimension__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (property, units, timezone) {
const expressionName = 'clusterTime';
const isCyclic = _ClusterTimeDimension__WEBPACK_IMPORTED_MODULE_0__["default"].cyclicUnits.includes(units);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 3, expressionName);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkExpression"])(expressionName, 'property', 0, property);
const validUnits = isCyclic ? _ClusterTimeDimension__WEBPACK_IMPORTED_MODULE_0__["default"].cyclicUnits : _ClusterTimeDimension__WEBPACK_IMPORTED_MODULE_0__["default"].serialUnits;
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkStringValue"])(expressionName, 'units', 1, units, validUnits);
super({
property,
expressionName,
dimension: {
group: {
units: units,
timezone
},
format: isCyclic ? 'number' : 'iso'
},
type: isCyclic ? 'number' : 'timerange',
range: isCyclic ? undefined : []
});
}
converse (v) {
return v;
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/aggregation/cluster/ClusterTimeDimension.js":
/*!**********************************************************************************!*\
!*** ./src/renderer/viz/expressions/aggregation/cluster/ClusterTimeDimension.js ***!
\**********************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return clusterTimeDimension; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _basic_property__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../basic/property */ "./src/renderer/viz/expressions/basic/property.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils */ "./src/renderer/viz/expressions/utils.js");
/* harmony import */ var _schema__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../../schema */ "./src/renderer/schema.js");
const SERIAL_UNITS = [
'second', 'minute', 'hour',
'day', 'month', 'year',
'week', 'quarter', 'trimester', 'semester',
'decade', 'century', 'millennium'
];
const CYCLIC_UNITS = [
'dayOfYear', 'weekOfYear', 'monthOfYear', 'quarterOfYear',
'dayOfMonth', 'dayOfWeek',
'hourOfDay', 'minuteOfHour'
];
// TODO: generalize with base clusterDimension
class clusterTimeDimension extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor ({ property, expressionName, dimension, type, range }) {
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkExpression"])(expressionName, 'property', 0, property);
super({ property });
this._dimension = dimension;
this._dimension.propertyName = _schema__WEBPACK_IMPORTED_MODULE_3__["column"].dimColumn(this.property.propertyName, this._dimension.group.units);
this._expressionName = expressionName;
this.type = type;
this._range = range;
}
static get serialUnits () {
return SERIAL_UNITS;
}
static get cyclicUnits () {
return CYCLIC_UNITS;
}
get name () {
return this.property.propertyName;
}
get propertyName () {
return this._dimension.propertyName;
}
get value () {
return {
name: this.propertyName,
range: this._range,
dimension: this._dimension
};
}
eval (feature) {
return feature[this.propertyName];
}
_bindMetadata (metadata) {
super._bindMetadata(metadata);
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkInstance"])(this._expressionName, 'property', 0, _basic_property__WEBPACK_IMPORTED_MODULE_1__["default"], this.property);
Object(_utils__WEBPACK_IMPORTED_MODULE_2__["checkType"])(this._expressionName, 'property', 0, 'date', this.property);
this._range = metadata.properties[metadata.baseName(this.propertyName)].dimension.range;
}
_resolveAliases () {}
_applyToShaderSource (getGLSLforProperty) {
const inline = this._range
? this._range.map(propertyName => [
`${getGLSLforProperty(propertyName)}`
])
: `${getGLSLforProperty(this.propertyName)}`;
return {
preface: '',
inline
};
}
_postShaderCompile () {}
_getMinimumNeededSchema () {
return {
[this.name]: [{
type: 'dimension',
dimension: this._dimension,
range: !!this._range
}]
};
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/aggregation/global/GlobalAggregation.js":
/*!******************************************************************************!*\
!*** ./src/renderer/viz/expressions/aggregation/global/GlobalAggregation.js ***!
\******************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return GlobalAggregation; });
/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../base */ "./src/renderer/viz/expressions/base.js");
/* harmony import */ var _expressions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../expressions */ "./src/renderer/viz/expressions.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils */ "./src/renderer/viz/expressions/utils.js");
/* harmony import */ var _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../../../errors/carto-validation-error */ "./src/errors/carto-validation-error.js");
/* harmony import */ var _constants_metadata__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../../constants/metadata */ "./src/constants/metadata.js");
/**
* Global aggregation expressions compute summary stats of properties for the whole dataset.
* As such, they rely on data provided by the backend, and not on the possibly incomplete
* set of features transferred to the client.
*
* In addition, the properties used in the visualization may have been aggregated into
* clusters, if *cluster* aggregation expressions have been used.
*
* Since cluster aggregation is zoom-level-dependant (because the cluster size varies with
* the zoom level), global aggregates cannot be assigned definite values for
* cluster-aggregated properties in general.
*
* In some specific cases it possible to assign a defined value to the combination of a
* global aggregation and a cluster aggregation. Such is the case with
* `globalMin(clusterMin($p))`, `globalMax(clusterMax($p))`,
* `globalSum(clusterCount($column))` and `globalSum(clusterSum($column))`.
*
* In the interest of allowing the use of `linear` without explicit limits in as many cases
* as possible, we should make `globalMin()` and `globalMax()`, which are used
* to compute the automatic linear limits, work with as many cluster expressions as possible,
* to allow the convenient use of cluster aggregations in simple linear expressions.
*
* For that reason we'll allow global aggregations to work not only with those cluster
* aggregations that yield definite values, but also for other cases in which we can
* efficiently compute (with the available backend stats) the limit value for high zoom
* level; and only in cases with fast monotonic convergence (which is not the case for example
* for `globalSum(clusterMin($p)))` or `globalMin(clusterSum($p))`).
*
* Here's a table of global-cluster aggregation combinations showing which cases
* have been implemented (the rest produce invalid input errors). Columns are cluster
* aggregations and rows are global aggregations. Each cell shows the metadata stat
* used to compute the combinations. For the cases varying per zoom level a tilde prefixes
* the stat, two tildes for the more questionable cases.
*
* | | c-Avg | c-Count | c-Max | c-Min | c-Mode | c-Sum |
* |---------|---------|---------|---------|---------|--------|-------|
* | g-Avg | ~avg | ERR | ERR | ERR | ERR | ERR |
* | g-Max | ~max | ERR | max | ~~max | ERR | ERR |
* | g-Min | ~min | ERR | ~~min | min | ERR | ERR |
* | g-Sum | ERR | count | ERR | ERR | ERR | sum |
*
*/
class GlobalAggregation extends _base__WEBPACK_IMPORTED_MODULE_0__["default"] {
/**
* @param {*} property
* @param {*} name
*/
constructor ({ property, name, type, baseStats = false }) {
super({ _value: Object(_expressions__WEBPACK_IMPORTED_MODULE_1__["number"])(0) });
this.property = Object(_utils__WEBPACK_IMPORTED_MODULE_2__["implicitCast"])(property);
this._name = name;
this.type = type;
this.baseStats = baseStats;
super.inlineMaker = inline => inline._value;
}
toString () {
return `${this.expressionName}(${this.property.toString()})`;
}
isFeatureDependent () {
return false;
}
get value () {
return this._value.value;
}
eval () {
return this.value;
}
_resolveAliases (aliases) {
if (this.property) {
this.property._resolveAliases(aliases);
}
}
_bindMetadata (metadata) {
super._bindMetadata(metadata);
this.property._bindMetadata(metadata);
const propertyName = this.property.name || this.property.propertyName;
const value = this._getValueFromStats(metadata, propertyName);
this._value.value = metadata.codec(propertyName).sourceToExternal(metadata, value);
}
_getValueFromStats (metadata, propertyName) {
let value;
if (this.baseStats) {
if (this.baseStats === '_count') {
value = metadata.featureCount;
} else {
const stats = metadata.stats(this.property.name);
value = stats && stats[this.baseStats];
}
} else {
if (propertyName === _constants_metadata__WEBPACK_IMPORTED_MODULE_4__["CLUSTER_FEATURE_COUNT"]) {
throw new _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_3__["default"](_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_3__["CartoValidationErrorTypes"].INCORRECT_TYPE, `'clusterCount' can not be used in ${this.expressionName}.`);
}
const stats = metadata.stats(propertyName);
value = stats && stats[this._name];
}
if (value === undefined) {
throw new _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_3__["default"](
`Metadata ${this._name} for property ${propertyName} is not defined`,
_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_3__["CartoValidationErrorTypes"].MISSING_REQUIRED
);
}
return value;
}
_getMinimumNeededSchema () {
return this.property._getMinimumNeededSchema();
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/aggregation/global/GlobalAvg.js":
/*!**********************************************************************!*\
!*** ./src/renderer/viz/expressions/aggregation/global/GlobalAvg.js ***!
\**********************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return GlobalAvg; });
/* harmony import */ var _GlobalAggregation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./GlobalAggregation */ "./src/renderer/viz/expressions/aggregation/global/GlobalAggregation.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils */ "./src/renderer/viz/expressions/utils.js");
/* harmony import */ var _cluster_ClusterAggregation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../cluster/ClusterAggregation */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAggregation.js");
/* harmony import */ var _cluster_ClusterAvg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../cluster/ClusterAvg */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAvg.js");
/* harmony import */ var _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../../../errors/carto-validation-error */ "./src/errors/carto-validation-error.js");
/**
* Return the average of the feature property for the entire source data.
*
* Note: `globalAvg` can only be created by {@link carto.expressions.prop|carto.expressions.prop}, not other expressions.
*
* @param {Number} property - property expression of number type
* @return {Number} Result of the aggregation
*
* @example <caption>Assign the global average of the `amount` property to a variable.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* variables: {
* g_avg: s.globalAvg(s.prop('amount'))
* }
* });
*
* @example <caption>Assign the global average of the `amount` property to a variable. (String)</caption>
* const viz = new carto.Viz(`
* \@g_avg: globalAvg($amount)
* `);
*
* @memberof carto.expressions
* @name globalAvg
* @function
* @api
*/
class GlobalAvg extends _GlobalAggregation__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (property) {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 1, 'globalAvg');
let baseStats = false;
if (property && property.isA(_cluster_ClusterAggregation__WEBPACK_IMPORTED_MODULE_2__["default"])) {
if (property.isA(_cluster_ClusterAvg__WEBPACK_IMPORTED_MODULE_3__["default"])) {
// This is not strictly correct (the average of cluster averages is not the average of data)
// but we'll allow it
baseStats = 'avg';
} else {
throw new _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_4__["default"](
'Invalid globlalAvg input',
_errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_4__["CartoValidationErrorTypes"].INCORRECT_TYPE
);
}
}
super({ property, name: 'avg', type: 'number', baseStats });
}
_bindMetadata (metadata) {
super._bindMetadata(metadata);
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkType"])(this.expressionName, 'property', 0, 'number', this.property);
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/aggregation/global/GlobalCount.js":
/*!************************************************************************!*\
!*** ./src/renderer/viz/expressions/aggregation/global/GlobalCount.js ***!
\************************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return GlobalCount; });
/* harmony import */ var _GlobalAggregation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./GlobalAggregation */ "./src/renderer/viz/expressions/aggregation/global/GlobalAggregation.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils */ "./src/renderer/viz/expressions/utils.js");
/**
* Return the feature count for the entire source data.
*
* @return {Number} feature count
*
* @example <caption>Assign the global count of features to a variable.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* variables: {
* g_count: s.globalCount()
* }
* });
*
* @example <caption>Assign the global count of features. (String)</caption>
* const viz = new carto.Viz(`
* \@g_count: globalCount()
* `);
*
* @memberof carto.expressions
* @name globalCount
* @function
* @api
*/
class GlobalCount extends _GlobalAggregation__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor () {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 0, 'globalCount');
super({ name: 'count', type: 'number' });
}
toString () {
return `${this.expressionName}()`;
}
_bindMetadata (metadata) {
this._value.value = metadata.featureCount;
}
_getMinimumNeededSchema () {
return {};
}
}
/***/ }),
/***/ "./src/renderer/viz/expressions/aggregation/global/GlobalMax.js":
/*!**********************************************************************!*\
!*** ./src/renderer/viz/expressions/aggregation/global/GlobalMax.js ***!
\**********************************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return GlobalMax; });
/* harmony import */ var _GlobalAggregation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./GlobalAggregation */ "./src/renderer/viz/expressions/aggregation/global/GlobalAggregation.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils */ "./src/renderer/viz/expressions/utils.js");
/* harmony import */ var _cluster_ClusterAggregation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../cluster/ClusterAggregation */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAggregation.js");
/* harmony import */ var _cluster_ClusterAvg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../cluster/ClusterAvg */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterAvg.js");
/* harmony import */ var _cluster_ClusterMax__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../cluster/ClusterMax */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterMax.js");
/* harmony import */ var _cluster_ClusterMin__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../cluster/ClusterMin */ "./src/renderer/viz/expressions/aggregation/cluster/ClusterMin.js");
/* harmony import */ var _errors_carto_validation_error__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../../../errors/carto-validation-error */ "./src/errors/carto-validation-error.js");
/**
* Return the maximum of the feature property for the entire source data.
*
* Note: `globalMax` can only be created by {@link carto.expressions.prop|carto.expressions.prop}, not other expressions.
*
* @param {Number|Date} property - property expression of date or number type
* @return {Number|Date} Result of the aggregation
*
* @example <caption>Assign the global maximum of the `amount` property to a variable.</caption>
* const s = carto.expressions;
* const viz = new carto.Viz({
* variables: {
* g_max: s.globalMax(s.prop('amount'))
* }
* });
*
* @example <caption>Assign the global maximum of the `amount` property to a variable. (String)</caption>
* const viz = new carto.Viz(`
* \@g_max: globalMax($amount)
* `);
*
* @memberof carto.expressions
* @name globalMax
* @function
* @api
*/
class GlobalMax extends _GlobalAggregation__WEBPACK_IMPORTED_MODULE_0__["default"] {
constructor (property) {
Object(_utils__WEBPACK_IMPORTED_MODULE_1__["checkMaxArguments"])(arguments, 1, 'globalMax');
let baseStats = false;
if (property && property.isA(_cluster_ClusterAggregation__WEBPACK_IMPORTED_MODULE_2__["default"])) {
if (property.isA(_cluster_ClusterAvg__WEBPACK_IMPORTED_MODULE_3__["default"]) || property.isA(_cluster_ClusterMin__WEBPACK_IMPORTED_MODULE_5__["default"]) || property.isA(_cluster_ClusterMax__WEBPACK_IMPORTED_MODULE_4__["default"])) {
// This is not correct for ClusterAvg, and specially not for clusterMin...
// but we allow for it
baseStats = 'max';
} else {
throw new _errors_carto_
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment