diff --git a/dist/echarts-gl.js b/dist/echarts-gl.js index 2b20dd78..09910548 100644 --- a/dist/echarts-gl.js +++ b/dist/echarts-gl.js @@ -70,7 +70,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 99); +/******/ return __webpack_require__(__webpack_require__.s = 106); /******/ }) /************************************************************************/ /******/ ([ @@ -81,14812 +81,12581 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_0__; /***/ }), /* 1 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, __webpack_exports__, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(global) {/** - * @fileoverview gl-matrix - High performance matrix and vector operations - * @author Brandon Jones - * @author Colin MacKenzie IV - * @version 2.2.2 - */ +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Mesh__ = __webpack_require__(40); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Renderer__ = __webpack_require__(52); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_Material__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_Node__ = __webpack_require__(35); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_claygl_src_Geometry__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__ = __webpack_require__(36); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_zrender_lib_core_LRU__ = __webpack_require__(60); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_zrender_lib_core_LRU___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_10_zrender_lib_core_LRU__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_claygl_src_util_texture__ = __webpack_require__(61); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__EChartsSurface__ = __webpack_require__(124); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13_claygl_src_light_AmbientCubemap__ = __webpack_require__(125); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14_claygl_src_light_AmbientSH__ = __webpack_require__(129); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15_claygl_src_util_sh__ = __webpack_require__(130); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__retrieve__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17_claygl_src_geometry_Sphere__ = __webpack_require__(132); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18_claygl_src_geometry_Plane__ = __webpack_require__(43); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19_claygl_src_geometry_Cube__ = __webpack_require__(76); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20_claygl_src_light_Ambient__ = __webpack_require__(133); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21_claygl_src_light_Directional__ = __webpack_require__(134); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22_claygl_src_light_Point__ = __webpack_require__(135); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23_claygl_src_light_Spot__ = __webpack_require__(136); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24_claygl_src_camera_Perspective__ = __webpack_require__(41); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25_claygl_src_camera_Orthographic__ = __webpack_require__(37); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26_claygl_src_math_Vector2__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27_claygl_src_math_Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_28_claygl_src_math_Vector4__ = __webpack_require__(137); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_29_claygl_src_math_Quaternion__ = __webpack_require__(56); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_30_claygl_src_math_Matrix2__ = __webpack_require__(138); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_31_claygl_src_math_Matrix2d__ = __webpack_require__(139); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_32_claygl_src_math_Matrix3__ = __webpack_require__(140); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_33_claygl_src_math_Matrix4__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_34_claygl_src_math_Plane__ = __webpack_require__(74); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_35_claygl_src_math_Ray__ = __webpack_require__(54); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_36_claygl_src_math_BoundingBox__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_37_claygl_src_math_Frustum__ = __webpack_require__(59); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_38__animatableMixin__ = __webpack_require__(141); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_39_claygl_src_shader_source_util_glsl_js__ = __webpack_require__(146); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_40_claygl_src_shader_source_prez_glsl_js__ = __webpack_require__(71); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_41__shader_common_glsl_js__ = __webpack_require__(147); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_42__shader_color_glsl_js__ = __webpack_require__(148); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_43__shader_lambert_glsl_js__ = __webpack_require__(149); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_44__shader_realistic_glsl_js__ = __webpack_require__(150); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_45__shader_hatching_glsl_js__ = __webpack_require__(151); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_46__shader_shadow_glsl_js__ = __webpack_require__(152); -/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. 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 HOLDER 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 USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -(function(_global) { - "use strict"; - var shim = {}; - if (false) { - if(typeof define == 'function' && typeof define.amd == 'object' && define.amd) { - shim.exports = {}; - define(function() { - return shim.exports; - }); - } else { - // gl-matrix lives in a browser, define its namespaces in global - shim.exports = typeof(window) !== 'undefined' ? window : _global; - } - } - else { - // gl-matrix lives in commonjs, define its namespaces in exports - shim.exports = exports; - } - (function(exports) { - /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. 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 HOLDER 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 USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -var g = typeof window === 'undefined' ? global : window; -var GLMAT_EPSILON = g.GLMAT_EPSILON; -if(GLMAT_EPSILON == null) { - GLMAT_EPSILON = 0.000001; -} -// Use Array instead of Float32Array. It seems to be much faster and higher precision. -var GLMAT_ARRAY_TYPE = g.GLMAT_ARRAY_TYPE || Array; -// if(!GLMAT_ARRAY_TYPE) { -// GLMAT_ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array; -// } -var GLMAT_RANDOM = g.GLMAT_RANDOM; -if(!GLMAT_RANDOM) { - GLMAT_RANDOM = Math.random; -} -/** - * @class Common utilities - * @name glMatrix - */ -var glMatrix = {}; -/** - * Sets the type of array used when creating new vectors and matrices - * - * @param {Type} type Array type, such as Float32Array or Array - */ -glMatrix.setMatrixArrayType = function(type) { - GLMAT_ARRAY_TYPE = type; -} -if(typeof(exports) !== 'undefined') { - exports.glMatrix = glMatrix; -} -var degree = Math.PI / 180; -/** -* Convert Degree To Radian -* -* @param {Number} Angle in Degrees -*/ -glMatrix.toRadian = function(a){ - return a * degree; -} -; -/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. 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 HOLDER 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 USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/** - * @class 2 Dimensional Vector - * @name vec2 - */ -var vec2 = {}; -/** - * Creates a new, empty vec2 - * - * @returns {vec2} a new 2D vector - */ -vec2.create = function() { - var out = new GLMAT_ARRAY_TYPE(2); - 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 - */ -vec2.clone = function(a) { - var out = new GLMAT_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 - */ -vec2.fromValues = function(x, y) { - var out = new GLMAT_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 - */ -vec2.copy = function(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 - */ -vec2.set = function(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 - */ -vec2.add = function(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - return out; -}; +// Math -/** - * 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 - */ -vec2.subtract = function(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - return out; -}; -/** - * Alias for {@link vec2.subtract} - * @function - */ -vec2.sub = vec2.subtract; -/** - * 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 - */ -vec2.multiply = function(out, a, b) { - out[0] = a[0] * b[0]; - out[1] = a[1] * b[1]; - return out; -}; -/** - * Alias for {@link vec2.multiply} - * @function - */ -vec2.mul = vec2.multiply; -/** - * 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 - */ -vec2.divide = function(out, a, b) { - out[0] = a[0] / b[0]; - out[1] = a[1] / b[1]; - return out; -}; -/** - * Alias for {@link vec2.divide} - * @function - */ -vec2.div = vec2.divide; -/** - * 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 - */ -vec2.min = function(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 - */ -vec2.max = function(out, a, b) { - out[0] = Math.max(a[0], b[0]); - out[1] = Math.max(a[1], b[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 - */ -vec2.scale = function(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 - */ -vec2.scaleAndAdd = function(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 - */ -vec2.distance = function(a, b) { - var x = b[0] - a[0], - y = b[1] - a[1]; - return Math.sqrt(x*x + y*y); -}; -/** - * Alias for {@link vec2.distance} - * @function - */ -vec2.dist = vec2.distance; -/** - * 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 - */ -vec2.squaredDistance = function(a, b) { - var x = b[0] - a[0], - y = b[1] - a[1]; - return x*x + y*y; -}; -/** - * Alias for {@link vec2.squaredDistance} - * @function - */ -vec2.sqrDist = vec2.squaredDistance; -/** - * Calculates the length of a vec2 - * - * @param {vec2} a vector to calculate length of - * @returns {Number} length of a - */ -vec2.length = function (a) { - var x = a[0], - y = a[1]; - return Math.sqrt(x*x + y*y); -}; -/** - * Alias for {@link vec2.length} - * @function - */ -vec2.len = vec2.length; -/** - * Calculates the squared length of a vec2 - * - * @param {vec2} a vector to calculate squared length of - * @returns {Number} squared length of a - */ -vec2.squaredLength = function (a) { - var x = a[0], - y = a[1]; - return x*x + y*y; -}; +// Some common shaders -/** - * Alias for {@link vec2.squaredLength} - * @function - */ -vec2.sqrLen = vec2.squaredLength; -/** - * Negates the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {vec2} a vector to negate - * @returns {vec2} out - */ -vec2.negate = function(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 - */ -vec2.inverse = function(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 - */ -vec2.normalize = function(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; + + + + + + +__WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts___default.a.util.extend(__WEBPACK_IMPORTED_MODULE_6_claygl_src_Node__["a" /* default */].prototype, __WEBPACK_IMPORTED_MODULE_38__animatableMixin__["a" /* default */]); + +__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_39_claygl_src_shader_source_util_glsl_js__["a" /* default */]); +__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_40_claygl_src_shader_source_prez_glsl_js__["a" /* default */]); +__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_41__shader_common_glsl_js__["a" /* default */]); +__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_42__shader_color_glsl_js__["a" /* default */]); +__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_43__shader_lambert_glsl_js__["a" /* default */]); +__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_44__shader_realistic_glsl_js__["a" /* default */]); +__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_45__shader_hatching_glsl_js__["a" /* default */]); +__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_46__shader_shadow_glsl_js__["a" /* default */]); + +function isValueNone(value) { + return !value || value === 'none'; +} + +function isValueImage(value) { + return value instanceof HTMLCanvasElement + || value instanceof HTMLImageElement + || value instanceof Image; +} + +function isECharts(value) { + return value.getZr && value.setOption; +} + +// Overwrite addToScene and removeFromScene +var oldAddToScene = __WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__["a" /* default */].prototype.addToScene; +var oldRemoveFromScene = __WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__["a" /* default */].prototype.removeFromScene; + +__WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__["a" /* default */].prototype.addToScene = function (node) { + oldAddToScene.call(this, node); + + if (this.__zr) { + var zr = this.__zr; + node.traverse(function (child) { + child.__zr = zr; + if (child.addAnimatorsToZr) { + child.addAnimatorsToZr(zr); + } + }); } - 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 - */ -vec2.dot = function (a, b) { - return a[0] * b[0] + a[1] * b[1]; -}; +__WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__["a" /* default */].prototype.removeFromScene = function (node) { + oldRemoveFromScene.call(this, node); -/** - * 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 - */ -vec2.cross = function(out, a, b) { - var z = a[0] * b[1] - a[1] * b[0]; - out[0] = out[1] = 0; - out[2] = z; - return out; + node.traverse(function (child) { + var zr = child.__zr; + child.__zr = null; + if (zr && child.removeAnimatorsFromZr) { + child.removeAnimatorsFromZr(zr); + } + }); }; /** - * 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 between the two inputs - * @returns {vec2} out + * @param {string} textureName + * @param {string|HTMLImageElement|HTMLCanvasElement} imgValue + * @param {module:echarts/ExtensionAPI} api + * @param {Object} [textureOpts] */ -vec2.lerp = function (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; -}; +__WEBPACK_IMPORTED_MODULE_5_claygl_src_Material__["a" /* default */].prototype.setTextureImage = function (textureName, imgValue, api, textureOpts) { + if (!this.shader) { + return; + } -/** - * 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 - */ -vec2.random = function (out, scale) { - scale = scale || 1.0; - var r = GLMAT_RANDOM() * 2.0 * Math.PI; - out[0] = Math.cos(r) * scale; - out[1] = Math.sin(r) * scale; - return out; + var zr = api.getZr(); + var material = this; + var texture; + material.autoUpdateTextureStatus = false; + // disableTexture first + material.disableTexture(textureName); + if (!isValueNone(imgValue)) { + texture = graphicGL.loadTexture(imgValue, api, textureOpts, function (texture) { + material.enableTexture(textureName); + zr && zr.refresh(); + }); + // Set texture immediately for other code to verify if have this texture. + material.set(textureName, texture); + } + + return texture; }; -/** - * 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 - */ -vec2.transformMat2 = function(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; -}; +var graphicGL = {}; -/** - * 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 - */ -vec2.transformMat2d = function(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; -}; +graphicGL.Renderer = __WEBPACK_IMPORTED_MODULE_1_claygl_src_Renderer__["a" /* default */]; -/** - * 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 - */ -vec2.transformMat3 = function(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; -}; +graphicGL.Node = __WEBPACK_IMPORTED_MODULE_6_claygl_src_Node__["a" /* default */]; + +graphicGL.Mesh = __WEBPACK_IMPORTED_MODULE_0_claygl_src_Mesh__["a" /* default */]; + +graphicGL.Shader = __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */]; + +graphicGL.Material = __WEBPACK_IMPORTED_MODULE_5_claygl_src_Material__["a" /* default */]; + +graphicGL.Texture = __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */]; + +graphicGL.Texture2D = __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__["a" /* default */]; + +// Geometries +graphicGL.Geometry = __WEBPACK_IMPORTED_MODULE_7_claygl_src_Geometry__["a" /* default */]; +graphicGL.SphereGeometry = __WEBPACK_IMPORTED_MODULE_17_claygl_src_geometry_Sphere__["a" /* default */]; +graphicGL.PlaneGeometry = __WEBPACK_IMPORTED_MODULE_18_claygl_src_geometry_Plane__["a" /* default */]; +graphicGL.CubeGeometry = __WEBPACK_IMPORTED_MODULE_19_claygl_src_geometry_Cube__["a" /* default */]; + +// Lights +graphicGL.AmbientLight = __WEBPACK_IMPORTED_MODULE_20_claygl_src_light_Ambient__["a" /* default */]; +graphicGL.DirectionalLight = __WEBPACK_IMPORTED_MODULE_21_claygl_src_light_Directional__["a" /* default */]; +graphicGL.PointLight = __WEBPACK_IMPORTED_MODULE_22_claygl_src_light_Point__["a" /* default */]; +graphicGL.SpotLight = __WEBPACK_IMPORTED_MODULE_23_claygl_src_light_Spot__["a" /* default */]; + +// Cameras +graphicGL.PerspectiveCamera = __WEBPACK_IMPORTED_MODULE_24_claygl_src_camera_Perspective__["a" /* default */]; +graphicGL.OrthographicCamera = __WEBPACK_IMPORTED_MODULE_25_claygl_src_camera_Orthographic__["a" /* default */]; + +// Math +graphicGL.Vector2 = __WEBPACK_IMPORTED_MODULE_26_claygl_src_math_Vector2__["a" /* default */]; +graphicGL.Vector3 = __WEBPACK_IMPORTED_MODULE_27_claygl_src_math_Vector3__["a" /* default */]; +graphicGL.Vector4 = __WEBPACK_IMPORTED_MODULE_28_claygl_src_math_Vector4__["a" /* default */]; + +graphicGL.Quaternion = __WEBPACK_IMPORTED_MODULE_29_claygl_src_math_Quaternion__["a" /* default */]; + +graphicGL.Matrix2 = __WEBPACK_IMPORTED_MODULE_30_claygl_src_math_Matrix2__["a" /* default */]; +graphicGL.Matrix2d = __WEBPACK_IMPORTED_MODULE_31_claygl_src_math_Matrix2d__["a" /* default */]; +graphicGL.Matrix3 = __WEBPACK_IMPORTED_MODULE_32_claygl_src_math_Matrix3__["a" /* default */]; +graphicGL.Matrix4 = __WEBPACK_IMPORTED_MODULE_33_claygl_src_math_Matrix4__["a" /* default */]; + +graphicGL.Plane = __WEBPACK_IMPORTED_MODULE_34_claygl_src_math_Plane__["a" /* default */]; +graphicGL.Ray = __WEBPACK_IMPORTED_MODULE_35_claygl_src_math_Ray__["a" /* default */]; +graphicGL.BoundingBox = __WEBPACK_IMPORTED_MODULE_36_claygl_src_math_BoundingBox__["a" /* default */]; +graphicGL.Frustum = __WEBPACK_IMPORTED_MODULE_37_claygl_src_math_Frustum__["a" /* default */]; + +// Texture utilities + +var blankImage = __WEBPACK_IMPORTED_MODULE_11_claygl_src_util_texture__["a" /* default */].createBlank('rgba(255,255,255,0)').image; -/** - * 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 - */ -vec2.transformMat4 = function(out, a, m) { - var x = a[0], - 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; -}; +function nearestPowerOfTwo(val) { + return Math.pow(2, Math.round(Math.log(val) / Math.LN2)); +} +function convertTextureToPowerOfTwo(texture) { + if ((texture.wrapS === __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].REPEAT || texture.wrapT === __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].REPEAT) + && texture.image + ) { + // var canvas = document.createElement('canvas'); + var width = nearestPowerOfTwo(texture.width); + var height = nearestPowerOfTwo(texture.height); + if (width !== texture.width || height !== texture.height) { + var canvas = document.createElement('canvas'); + canvas.width = width; + canvas.height = height; + var ctx = canvas.getContext('2d'); + ctx.drawImage(texture.image, 0, 0, width, height); + texture.image = canvas; + } + } +} /** - * 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 + * @param {string|HTMLImageElement|HTMLCanvasElement} imgValue + * @param {module:echarts/ExtensionAPI} api + * @param {Object} [textureOpts] + * @param {Function} cb */ -vec2.forEach = (function() { - var vec = vec2.create(); +// TODO Promise, test +graphicGL.loadTexture = function (imgValue, api, textureOpts, cb) { + if (typeof textureOpts === 'function') { + cb = textureOpts; + textureOpts = {}; + } + textureOpts = textureOpts || {}; - return function(a, stride, offset, count, fn, arg) { - var i, l; - if(!stride) { - stride = 2; + var keys = Object.keys(textureOpts).sort(); + var prefix = ''; + for (var i = 0; i < keys.length; i++) { + prefix += keys[i] + '_' + textureOpts[keys[i]] + '_'; + } + + var textureCache = api.__textureCache = api.__textureCache || new __WEBPACK_IMPORTED_MODULE_10_zrender_lib_core_LRU___default.a(20); + + if (isECharts(imgValue)) { + var id = imgValue.__textureid__; + var textureObj = textureCache.get(prefix + id); + if (!textureObj) { + var surface = new __WEBPACK_IMPORTED_MODULE_12__EChartsSurface__["a" /* default */](imgValue); + surface.onupdate = function () { + api.getZr().refresh(); + }; + textureObj = { + texture: surface.getTexture() + }; + for (var i = 0; i < keys.length; i++) { + textureObj.texture[keys[i]] = textureOpts[keys[i]]; + } + id = imgValue.__textureid__ || '__ecgl_ec__' + textureObj.texture.__uid__; + imgValue.__textureid__ = id; + textureCache.put(prefix + id, textureObj); + cb && cb(textureObj.texture); } + else { + textureObj.texture.surface.setECharts(imgValue); - if(!offset) { - offset = 0; + cb && cb(textureObj.texture); } + return textureObj.texture; + } + else if (isValueImage(imgValue)) { + var id = imgValue.__textureid__; + var textureObj = textureCache.get(prefix + id); + if (!textureObj) { + textureObj = { + texture: new graphicGL.Texture2D({ + image: imgValue + }) + }; + for (var i = 0; i < keys.length; i++) { + textureObj.texture[keys[i]] = textureOpts[keys[i]]; + } + id = imgValue.__textureid__ || '__ecgl_image__' + textureObj.texture.__uid__; + imgValue.__textureid__ = id; + textureCache.put(prefix + id, textureObj); - if(count) { - l = Math.min((count * stride) + offset, a.length); - } else { - l = a.length; + convertTextureToPowerOfTwo(textureObj.texture); + // TODO Next tick? + cb && cb(textureObj.texture); + } + return textureObj.texture; + } + else { + var textureObj = textureCache.get(prefix + imgValue); + if (textureObj) { + if (textureObj.callbacks) { + // Add to pending callbacks + textureObj.callbacks.push(cb); + } + else { + // TODO Next tick? + cb && cb(textureObj.texture); + } } + else { + // Maybe base64 + if (imgValue.match(/.hdr$|^data:application\/octet-stream/)) { + textureObj = { + callbacks: [cb] + }; + var texture = __WEBPACK_IMPORTED_MODULE_11_claygl_src_util_texture__["a" /* default */].loadTexture(imgValue, { + exposure: textureOpts.exposure, + fileType: 'hdr' + }, function () { + texture.dirty(); + textureObj.callbacks.forEach(function (cb) { + cb && cb(texture); + }); + textureObj.callbacks = null; + }); + textureObj.texture = texture; + textureCache.put(prefix + imgValue, textureObj); + } + else { + var texture = new graphicGL.Texture2D({ + image: new Image() + }); + for (var i = 0; i < keys.length; i++) { + texture[keys[i]] = textureOpts[keys[i]]; + } - 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]; + textureObj = { + texture: texture, + callbacks: [cb] + }; + var originalImage = texture.image; + originalImage.onload = function () { + texture.image = originalImage; + convertTextureToPowerOfTwo(texture); + + texture.dirty(); + textureObj.callbacks.forEach(function (cb) { + cb && cb(texture); + }); + textureObj.callbacks = null; + }; + originalImage.src = imgValue; + // Use blank image as place holder. + texture.image = blankImage; + + textureCache.put(prefix + imgValue, textureObj); + } } - return a; - }; -})(); + return textureObj.texture; + } +}; /** - * Returns a string representation of a vector - * - * @param {vec2} vec vector to represent as a string - * @returns {String} string representation of the vector + * Create ambientCubemap and ambientSH light. respectively to have specular and diffuse light + * @return {Object} { specular, diffuse } */ -vec2.str = function (a) { - return 'vec2(' + a[0] + ', ' + a[1] + ')'; -}; - -if(typeof(exports) !== 'undefined') { - exports.vec2 = vec2; -} -; -/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. +graphicGL.createAmbientCubemap = function (opt, renderer, api, cb) { + opt = opt || {}; + var textureUrl = opt.texture; + var exposure = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(opt.exposure, 1.0); -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: + var ambientCubemap = new __WEBPACK_IMPORTED_MODULE_13_claygl_src_light_AmbientCubemap__["a" /* default */]({ + intensity: __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(opt.specularIntensity, 1.0) + }); + var ambientSH = new __WEBPACK_IMPORTED_MODULE_14_claygl_src_light_AmbientSH__["a" /* default */]({ + intensity: __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(opt.diffuseIntensity, 1.0), + coefficients: [0.844, 0.712, 0.691, -0.037, 0.083, 0.167, 0.343, 0.288, 0.299, -0.041, -0.021, -0.009, -0.003, -0.041, -0.064, -0.011, -0.007, -0.004, -0.031, 0.034, 0.081, -0.060, -0.049, -0.060, 0.046, 0.056, 0.050] + }); - * 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 HOLDER 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 USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + ambientCubemap.cubemap = graphicGL.loadTexture(textureUrl, api, { + exposure: exposure + }, function () { + // TODO Performance when multiple view + ambientCubemap.cubemap.flipY = false; + if (true) { + var time = Date.now(); + } + ambientCubemap.prefilter(renderer, 32); + if (true) { + var dTime = Date.now() - time; + console.log('Prefilter environment map: ' + dTime + 'ms'); + } + ambientSH.coefficients = __WEBPACK_IMPORTED_MODULE_15_claygl_src_util_sh__["a" /* default */].projectEnvironmentMap(renderer, ambientCubemap.cubemap, { + lod: 1 + }); -/** - * @class 3 Dimensional Vector - * @name vec3 - */ + cb && cb(); -var vec3 = {}; + // TODO Refresh ? + }); -/** - * Creates a new, empty vec3 - * - * @returns {vec3} a new 3D vector - */ -vec3.create = function() { - var out = new GLMAT_ARRAY_TYPE(3); - out[0] = 0; - out[1] = 0; - out[2] = 0; - return out; + return { + specular: ambientCubemap, + diffuse: ambientSH + }; }; /** - * Creates a new vec3 initialized with values from an existing vector - * - * @param {vec3} a vector to clone - * @returns {vec3} a new 3D vector + * Create a blank texture for placeholder */ -vec3.clone = function(a) { - var out = new GLMAT_ARRAY_TYPE(3); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - return out; -}; +graphicGL.createBlankTexture = __WEBPACK_IMPORTED_MODULE_11_claygl_src_util_texture__["a" /* default */].createBlank; /** - * 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 + * If value is image + * @param {*} + * @return {boolean} */ -vec3.fromValues = function(x, y, z) { - var out = new GLMAT_ARRAY_TYPE(3); - out[0] = x; - out[1] = y; - out[2] = z; - return out; -}; +graphicGL.isImage = isValueImage; -/** - * Copy the values from one vec3 to another - * - * @param {vec3} out the receiving vector - * @param {vec3} a the source vector - * @returns {vec3} out - */ -vec3.copy = function(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - return out; +graphicGL.additiveBlend = function (gl) { + gl.blendEquation(gl.FUNC_ADD); + gl.blendFunc(gl.SRC_ALPHA, gl.ONE); }; /** - * 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 + * @param {string|Array.} colorStr + * @param {Array.} [rgba] + * @return {Array.} rgba */ -vec3.set = function(out, x, y, z) { - out[0] = x; - out[1] = y; - out[2] = z; - return out; +graphicGL.parseColor = function (colorStr, rgba) { + if (colorStr instanceof Array) { + if (!rgba) { + rgba = []; + } + // Color has been parsed. + rgba[0] = colorStr[0]; + rgba[1] = colorStr[1]; + rgba[2] = colorStr[2]; + if (colorStr.length > 3) { + rgba[3] = colorStr[3]; + } + else { + rgba[3] = 1; + } + return rgba; + } + + rgba = __WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts___default.a.color.parse(colorStr || '#000', rgba) || [0, 0, 0, 0]; + rgba[0] /= 255; + rgba[1] /= 255; + rgba[2] /= 255; + return rgba; }; /** - * 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 + * Convert alpha beta rotation to direction. + * @param {number} alpha + * @param {number} beta + * @return {Array.} */ -vec3.add = function(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - return out; -}; +graphicGL.directionFromAlphaBeta = function (alpha, beta) { + var theta = alpha / 180 * Math.PI + Math.PI / 2; + var phi = -beta / 180 * Math.PI + Math.PI / 2; + + var dir = []; + var r = Math.sin(theta); + dir[0] = r * Math.cos(phi); + dir[1] = -Math.cos(theta); + dir[2] = r * Math.sin(phi); + return dir; +}; /** - * 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 + * Get shadow resolution from shadowQuality configuration */ -vec3.subtract = function(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - return out; +graphicGL.getShadowResolution = function (shadowQuality) { + var shadowResolution = 1024; + switch (shadowQuality) { + case 'low': + shadowResolution = 512; + break; + case 'medium': + break; + case 'high': + shadowResolution = 2048; + break; + case 'ultra': + shadowResolution = 4096; + break; + } + return shadowResolution; }; /** - * Alias for {@link vec3.subtract} - * @function + * Shading utilities */ -vec3.sub = vec3.subtract; +graphicGL.COMMON_SHADERS = ['lambert', 'color', 'realistic', 'hatching']; /** - * 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 + * Create shader including vertex and fragment + * @param {string} prefix. */ -vec3.multiply = function(out, a, b) { - out[0] = a[0] * b[0]; - out[1] = a[1] * b[1]; - out[2] = a[2] * b[2]; - return out; +graphicGL.createShader = function (prefix) { + var vertexShaderStr = __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source(prefix + '.vertex'); + var fragmentShaderStr = __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source(prefix + '.fragment'); + if (!vertexShaderStr) { + console.error('Vertex shader of \'%s\' not exits', prefix); + } + if (!fragmentShaderStr) { + console.error('Fragment shader of \'%s\' not exits', prefix); + } + var shader = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */](vertexShaderStr, fragmentShaderStr); + shader.name = prefix; + return shader; }; -/** - * Alias for {@link vec3.multiply} - * @function - */ -vec3.mul = vec3.multiply; - -/** - * 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 - */ -vec3.divide = function(out, a, b) { - out[0] = a[0] / b[0]; - out[1] = a[1] / b[1]; - out[2] = a[2] / b[2]; - return out; +graphicGL.createMaterial = function (prefix, defines) { + if (!(defines instanceof Array)) { + defines = [defines]; + } + var shader = graphicGL.createShader(prefix); + var material = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_Material__["a" /* default */]({ + shader: shader + }); + defines.forEach(function (defineName) { + if (typeof defineName === 'string') { + material.define(defineName); + } + }); + return material; }; - -/** - * Alias for {@link vec3.divide} - * @function - */ -vec3.div = vec3.divide; - /** - * 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 + * Set material from model. + * @param {clay.Material} material + * @param {module:echarts/model/Model} model + * @param {module:echarts/ExtensionAPI} api */ -vec3.min = function(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; -}; +graphicGL.setMaterialFromModel = function (shading, material, model, api) { + material.autoUpdateTextureStatus = false; -/** - * 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 - */ -vec3.max = function(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; + var materialModel = model.getModel(shading + 'Material'); + var detailTexture = materialModel.get('detailTexture'); + var uvRepeat = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(materialModel.get('textureTiling'), 1.0); + var uvOffset = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(materialModel.get('textureOffset'), 0.0); + if (typeof uvRepeat === 'number') { + uvRepeat = [uvRepeat, uvRepeat]; + } + if (typeof uvOffset === 'number') { + uvOffset = [uvOffset, uvOffset]; + } + var repeatParam = (uvRepeat[0] > 1 || uvRepeat[1] > 1) ? graphicGL.Texture.REPEAT : graphicGL.Texture.CLAMP_TO_EDGE; + var textureOpt = { + anisotropic: 8, + wrapS: repeatParam, + wrapT: repeatParam + }; + if (shading === 'realistic') { + var roughness = materialModel.get('roughness'); + var metalness = materialModel.get('metalness'); + if (metalness != null) { + // Try to treat as a texture, TODO More check + if (isNaN(metalness)) { + material.setTextureImage('metalnessMap', metalness, api, textureOpt); + metalness = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(materialModel.get('metalnessAdjust'), 0.5); + } + } + else { + // Default metalness. + metalness = 0; + } + if (roughness != null) { + // Try to treat as a texture, TODO More check + if (isNaN(roughness)) { + material.setTextureImage('roughnessMap', roughness, api, textureOpt); + roughness = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(materialModel.get('roughnessAdjust'), 0.5); + } + } + else { + // Default roughness. + roughness = 0.5; + } + var normalTextureVal = materialModel.get('normalTexture'); + material.setTextureImage('detailMap', detailTexture, api, textureOpt); + material.setTextureImage('normalMap', normalTextureVal, api, textureOpt); + material.set({ + roughness: roughness, + metalness: metalness, + detailUvRepeat: uvRepeat, + detailUvOffset: uvOffset + }); + // var normalTexture = material.get('normalMap'); + // if (normalTexture) { + // PENDING + // normalTexture.format = Texture.SRGB; + // } + } + else if (shading === 'lambert') { + material.setTextureImage('detailMap', detailTexture, api, textureOpt); + material.set({ + detailUvRepeat: uvRepeat, + detailUvOffset: uvOffset + }); + } + else if (shading === 'color') { + material.setTextureImage('detailMap', detailTexture, api, textureOpt); + material.set({ + detailUvRepeat: uvRepeat, + detailUvOffset: uvOffset + }); + } + else if (shading === 'hatching') { + var tams = materialModel.get('hatchingTextures') || []; + if (tams.length < 6) { + if (true) { + console.error('Invalid hatchingTextures.'); + } + } + for (var i = 0; i < 6; i++) { + material.setTextureImage('hatch' + (i + 1), tams[i], api, { + anisotropic: 8, + wrapS: graphicGL.Texture.REPEAT, + wrapT: graphicGL.Texture.REPEAT + }); + } + material.set({ + detailUvRepeat: uvRepeat, + detailUvOffset: uvOffset + }); + } }; -/** - * 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 - */ -vec3.scale = function(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - return out; -}; +graphicGL.updateVertexAnimation = function ( + mappingAttributes, previousMesh, currentMesh, seriesModel +) { + var enableAnimation = seriesModel.get('animation'); + var duration = seriesModel.get('animationDurationUpdate'); + var easing = seriesModel.get('animationEasingUpdate'); + var shadowDepthMaterial = currentMesh.shadowDepthMaterial; -/** - * 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 - */ -vec3.scaleAndAdd = function(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; + if (enableAnimation && previousMesh && duration > 0 + // Only animate when bar count are not changed + && previousMesh.geometry.vertexCount === currentMesh.geometry.vertexCount + ) { + currentMesh.material.define('vertex', 'VERTEX_ANIMATION'); + currentMesh.ignorePreZ = true; + if (shadowDepthMaterial) { + shadowDepthMaterial.define('vertex', 'VERTEX_ANIMATION'); + } + for (var i = 0; i < mappingAttributes.length; i++) { + currentMesh.geometry.attributes[mappingAttributes[i][0]].value = + previousMesh.geometry.attributes[mappingAttributes[i][1]].value; + } + currentMesh.geometry.dirty(); + currentMesh.__percent = 0; + currentMesh.material.set('percent', 0); + currentMesh.stopAnimation(); + currentMesh.animate() + .when(duration, { + __percent: 1 + }) + .during(function () { + currentMesh.material.set('percent', currentMesh.__percent); + if (shadowDepthMaterial) { + shadowDepthMaterial.set('percent', currentMesh.__percent); + } + }) + .done(function () { + currentMesh.ignorePreZ = false; + currentMesh.material.undefine('vertex', 'VERTEX_ANIMATION'); + if (shadowDepthMaterial) { + shadowDepthMaterial.undefine('vertex', 'VERTEX_ANIMATION'); + } + }) + .start(easing); + } + else { + currentMesh.material.undefine('vertex', 'VERTEX_ANIMATION'); + if (shadowDepthMaterial) { + shadowDepthMaterial.undefine('vertex', 'VERTEX_ANIMATION'); + } + } }; -/** - * 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 - */ -vec3.distance = function(a, b) { - var x = b[0] - a[0], - y = b[1] - a[1], - z = b[2] - a[2]; - return Math.sqrt(x*x + y*y + z*z); -}; +/* harmony default export */ __webpack_exports__["a"] = (graphicGL); -/** - * Alias for {@link vec3.distance} - * @function - */ -vec3.dist = vec3.distance; +/***/ }), +/* 2 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -/** - * 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 - */ -vec3.squaredDistance = function(a, b) { - var x = b[0] - a[0], - y = b[1] - a[1], - z = b[2] - a[2]; - return x*x + y*y + z*z; -}; +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/** - * Alias for {@link vec3.squaredDistance} - * @function - */ -vec3.sqrDist = vec3.squaredDistance; -/** - * Calculates the length of a vec3 - * - * @param {vec3} a vector to calculate length of - * @returns {Number} length of a - */ -vec3.length = function (a) { - var x = a[0], - y = a[1], - z = a[2]; - return Math.sqrt(x*x + y*y + z*z); -}; +var retrieve = { -/** - * Alias for {@link vec3.length} - * @function - */ -vec3.len = vec3.length; + firstNotNull: function () { + for (var i = 0, len = arguments.length; i < len; i++) { + if (arguments[i] != null) { + return arguments[i]; + } + } + }, -/** - * Calculates the squared length of a vec3 - * - * @param {vec3} a vector to calculate squared length of - * @returns {Number} squared length of a - */ -vec3.squaredLength = function (a) { - var x = a[0], - y = a[1], - z = a[2]; - return x*x + y*y + z*z; + /** + * @param {module:echarts/data/List} data + * @param {Object} payload Contains dataIndex (means rawIndex) / dataIndexInside / name + * each of which can be Array or primary type. + * @return {number|Array.} dataIndex If not found, return undefined/null. + */ + queryDataIndex: function (data, payload) { + if (payload.dataIndexInside != null) { + return payload.dataIndexInside; + } + else if (payload.dataIndex != null) { + return __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(payload.dataIndex) + ? __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.map(payload.dataIndex, function (value) { + return data.indexOfRawIndex(value); + }) + : data.indexOfRawIndex(payload.dataIndex); + } + else if (payload.name != null) { + return __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(payload.name) + ? __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.map(payload.name, function (value) { + return data.indexOfName(value); + }) + : data.indexOfName(payload.name); + } + } }; -/** - * Alias for {@link vec3.squaredLength} - * @function - */ -vec3.sqrLen = vec3.squaredLength; +/* harmony default export */ __webpack_exports__["a"] = (retrieve); -/** - * Negates the components of a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to negate - * @returns {vec3} out - */ -vec3.negate = function(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - out[2] = -a[2]; - return out; -}; +/***/ }), +/* 3 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -/** - * Returns the inverse of the components of a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to invert - * @returns {vec3} out - */ -vec3.inverse = function(out, a) { - out[0] = 1.0 / a[0]; - out[1] = 1.0 / a[1]; - out[2] = 1.0 / a[2]; - return out; -}; +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__ = __webpack_require__(12); -/** - * Normalize a vec3 - * - * @param {vec3} out the receiving vector - * @param {vec3} a vector to normalize - * @returns {vec3} out - */ -vec3.normalize = function(out, a) { - var x = a[0], - y = a[1], - 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 + * @constructor + * @alias clay.Vector3 + * @param {number} x + * @param {number} y + * @param {number} z */ -vec3.dot = function (a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; -}; +var Vector3 = function(x, y, z) { -/** - * 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 - */ -vec3.cross = function(out, a, b) { - var ax = a[0], ay = a[1], az = a[2], - bx = b[0], by = b[1], bz = b[2]; + x = x || 0; + y = y || 0; + z = z || 0; - out[0] = ay * bz - az * by; - out[1] = az * bx - ax * bz; - out[2] = ax * by - ay * bx; - return out; -}; + /** + * Storage of Vector3, read and write of x, y, z will change the values in array + * All methods also operate on the array instead of x, y, z components + * @name array + * @type {Float32Array} + * @memberOf clay.Vector3# + */ + this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].fromValues(x, y, z); -/** - * 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 between the two inputs - * @returns {vec3} out - */ -vec3.lerp = function (out, a, b, t) { - var ax = a[0], - ay = a[1], - 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; + /** + * Dirty flag is used by the Node to determine + * if the matrix is updated to latest + * @name _dirty + * @type {boolean} + * @memberOf clay.Vector3# + */ + this._dirty = true; }; -/** - * 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 - */ -vec3.random = function (out, scale) { - scale = scale || 1.0; +Vector3.prototype = { - var r = GLMAT_RANDOM() * 2.0 * Math.PI; - var z = (GLMAT_RANDOM() * 2.0) - 1.0; - var zScale = Math.sqrt(1.0-z*z) * scale; + constructor: Vector3, - out[0] = Math.cos(r) * zScale; - out[1] = Math.sin(r) * zScale; - out[2] = z * scale; - return out; -}; + /** + * Add b to self + * @param {clay.Vector3} b + * @return {clay.Vector3} + */ + add: function (b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].add(this.array, this.array, b.array); + this._dirty = true; + return this; + }, -/** - * 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 - */ -vec3.transformMat4 = function(out, a, m) { - var x = a[0], y = a[1], z = a[2], - 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; -}; + /** + * Set x, y and z components + * @param {number} x + * @param {number} y + * @param {number} z + * @return {clay.Vector3} + */ + set: function (x, y, z) { + this.array[0] = x; + this.array[1] = y; + this.array[2] = z; + this._dirty = true; + return this; + }, -/** - * Transforms the vec3 with a mat3. - * - * @param {vec3} out the receiving vector - * @param {vec3} a the vector to transform - * @param {mat4} m the 3x3 matrix to transform with - * @returns {vec3} out - */ -vec3.transformMat3 = function(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; -}; + /** + * Set x, y and z components from array + * @param {Float32Array|number[]} arr + * @return {clay.Vector3} + */ + setArray: function (arr) { + this.array[0] = arr[0]; + this.array[1] = arr[1]; + this.array[2] = arr[2]; -/** - * Transforms the vec3 with a quat - * - * @param {vec3} out the receiving vector - * @param {vec3} a the vector to transform - * @param {quat} q quaternion to transform with - * @returns {vec3} out - */ -vec3.transformQuat = function(out, a, q) { - // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + this._dirty = true; + return this; + }, - var x = a[0], y = a[1], z = a[2], - qx = q[0], qy = q[1], qz = q[2], qw = q[3], + /** + * Clone a new Vector3 + * @return {clay.Vector3} + */ + clone: function () { + return new Vector3(this.x, this.y, this.z); + }, - // calculate quat * vec - ix = qw * x + qy * z - qz * y, - iy = qw * y + qz * x - qx * z, - iz = qw * z + qx * y - qy * x, - iw = -qx * x - qy * y - qz * z; + /** + * Copy from b + * @param {clay.Vector3} b + * @return {clay.Vector3} + */ + copy: function (b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].copy(this.array, b.array); + this._dirty = true; + return this; + }, - // 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; - return out; -}; + /** + * Cross product of self and b, written to a Vector3 out + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {clay.Vector3} + */ + cross: function (a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].cross(this.array, a.array, b.array); + this._dirty = true; + return this; + }, -/** - * 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 - */ -vec3.rotateX = function(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]; + /** + * Alias for distance + * @param {clay.Vector3} b + * @return {number} + */ + dist: function (b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].dist(this.array, b.array); + }, - //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); + /** + * Distance between self and b + * @param {clay.Vector3} b + * @return {number} + */ + distance: function (b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].distance(this.array, b.array); + }, - //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; + /** + * Alias for divide + * @param {clay.Vector3} b + * @return {clay.Vector3} + */ + div: function (b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].div(this.array, this.array, b.array); + this._dirty = true; + return this; + }, - return out; -}; + /** + * Divide self by b + * @param {clay.Vector3} b + * @return {clay.Vector3} + */ + divide: function (b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].divide(this.array, this.array, b.array); + this._dirty = true; + return this; + }, -/** - * 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 - */ -vec3.rotateY = function(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]; + /** + * Dot product of self and b + * @param {clay.Vector3} b + * @return {number} + */ + dot: function (b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].dot(this.array, b.array); + }, - //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); + /** + * Alias of length + * @return {number} + */ + len: function () { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].len(this.array); + }, - //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; + /** + * Calculate the length + * @return {number} + */ + length: function () { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].length(this.array); + }, + /** + * Linear interpolation between a and b + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @param {number} t + * @return {clay.Vector3} + */ + lerp: function (a, b, t) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].lerp(this.array, a.array, b.array, t); + this._dirty = true; + return this; + }, - return out; -}; + /** + * Minimum of self and b + * @param {clay.Vector3} b + * @return {clay.Vector3} + */ + min: function (b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].min(this.array, this.array, b.array); + this._dirty = true; + return this; + }, -/** - * 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 - */ -vec3.rotateZ = function(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]; + /** + * Maximum of self and b + * @param {clay.Vector3} b + * @return {clay.Vector3} + */ + max: function (b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].max(this.array, this.array, b.array); + this._dirty = true; + return this; + }, - //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]; + /** + * Alias for multiply + * @param {clay.Vector3} b + * @return {clay.Vector3} + */ + mul: function (b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].mul(this.array, this.array, b.array); + this._dirty = true; + return this; + }, - //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; + /** + * Mutiply self and b + * @param {clay.Vector3} b + * @return {clay.Vector3} + */ + multiply: function (b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].multiply(this.array, this.array, b.array); + this._dirty = true; + return this; + }, - return out; -}; + /** + * Negate self + * @return {clay.Vector3} + */ + negate: function () { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].negate(this.array, this.array); + this._dirty = true; + return this; + }, -/** - * 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 - */ -vec3.forEach = (function() { - var vec = vec3.create(); + /** + * Normalize self + * @return {clay.Vector3} + */ + normalize: function () { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].normalize(this.array, this.array); + this._dirty = true; + return this; + }, - return function(a, stride, offset, count, fn, arg) { - var i, l; - if(!stride) { - stride = 3; - } + /** + * Generate random x, y, z components with a given scale + * @param {number} scale + * @return {clay.Vector3} + */ + random: function (scale) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].random(this.array, scale); + this._dirty = true; + return this; + }, - if(!offset) { - offset = 0; - } + /** + * Scale self + * @param {number} scale + * @return {clay.Vector3} + */ + scale: function (s) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].scale(this.array, this.array, s); + this._dirty = true; + return this; + }, - if(count) { - l = Math.min((count * stride) + offset, a.length); - } else { - l = a.length; - } + /** + * Scale b and add to self + * @param {clay.Vector3} b + * @param {number} scale + * @return {clay.Vector3} + */ + scaleAndAdd: function (b, s) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].scaleAndAdd(this.array, this.array, b.array, s); + this._dirty = true; + return this; + }, - 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]; - } + /** + * Alias for squaredDistance + * @param {clay.Vector3} b + * @return {number} + */ + sqrDist: function (b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].sqrDist(this.array, b.array); + }, - return a; - }; -})(); + /** + * Squared distance between self and b + * @param {clay.Vector3} b + * @return {number} + */ + squaredDistance: function (b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].squaredDistance(this.array, b.array); + }, -/** - * 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 - */ -vec3.angle = function(a, b) { + /** + * Alias for squaredLength + * @return {number} + */ + sqrLen: function () { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].sqrLen(this.array); + }, - var tempA = vec3.fromValues(a[0], a[1], a[2]); - var tempB = vec3.fromValues(b[0], b[1], b[2]); + /** + * Squared length of self + * @return {number} + */ + squaredLength: function () { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].squaredLength(this.array); + }, - vec3.normalize(tempA, tempA); - vec3.normalize(tempB, tempB); + /** + * Alias for subtract + * @param {clay.Vector3} b + * @return {clay.Vector3} + */ + sub: function (b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].sub(this.array, this.array, b.array); + this._dirty = true; + return this; + }, - var cosine = vec3.dot(tempA, tempB); + /** + * Subtract b from self + * @param {clay.Vector3} b + * @return {clay.Vector3} + */ + subtract: function (b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].subtract(this.array, this.array, b.array); + this._dirty = true; + return this; + }, - if(cosine > 1.0){ - return 0; - } else { - return Math.acos(cosine); - } -}; + /** + * Transform self with a Matrix3 m + * @param {clay.Matrix3} m + * @return {clay.Vector3} + */ + transformMat3: function (m) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].transformMat3(this.array, this.array, m.array); + this._dirty = true; + return this; + }, -/** - * Returns a string representation of a vector - * - * @param {vec3} vec vector to represent as a string - * @returns {String} string representation of the vector - */ -vec3.str = function (a) { - return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')'; -}; + /** + * Transform self with a Matrix4 m + * @param {clay.Matrix4} m + * @return {clay.Vector3} + */ + transformMat4: function (m) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].transformMat4(this.array, this.array, m.array); + this._dirty = true; + return this; + }, + /** + * Transform self with a Quaternion q + * @param {clay.Quaternion} q + * @return {clay.Vector3} + */ + transformQuat: function (q) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].transformQuat(this.array, this.array, q.array); + this._dirty = true; + return this; + }, -if(typeof(exports) !== 'undefined') { - exports.vec3 = vec3; -} -; -/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. + /** + * Trasnform self into projection space with m + * @param {clay.Matrix4} m + * @return {clay.Vector3} + */ + applyProjection: function (m) { + var v = this.array; + m = m.array; -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: + // Perspective projection + if (m[15] === 0) { + var w = -1 / v[2]; + v[0] = m[0] * v[0] * w; + v[1] = m[5] * v[1] * w; + v[2] = (m[10] * v[2] + m[14]) * w; + } + else { + v[0] = m[0] * v[0] + m[12]; + v[1] = m[5] * v[1] + m[13]; + v[2] = m[10] * v[2] + m[14]; + } + this._dirty = true; - * 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. + return this; + }, -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 HOLDER 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 USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + eulerFromQuat: function(q, order) { + Vector3.eulerFromQuat(this, q, order); + }, -/** - * @class 4 Dimensional Vector - * @name vec4 - */ + eulerFromMat3: function (m, order) { + Vector3.eulerFromMat3(this, m, order); + }, -var vec4 = {}; + toString: function() { + return '[' + Array.prototype.join.call(this.array, ',') + ']'; + }, -/** - * Creates a new, empty vec4 - * - * @returns {vec4} a new 4D vector - */ -vec4.create = function() { - var out = new GLMAT_ARRAY_TYPE(4); - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 0; - return out; + toArray: function () { + return Array.prototype.slice.call(this.array); + } }; -/** - * Creates a new vec4 initialized with values from an existing vector - * - * @param {vec4} a vector to clone - * @returns {vec4} a new 4D vector - */ -vec4.clone = function(a) { - var out = new GLMAT_ARRAY_TYPE(4); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - return out; -}; +var defineProperty = Object.defineProperty; +// Getter and Setter +if (defineProperty) { + + var proto = Vector3.prototype; + /** + * @name x + * @type {number} + * @memberOf clay.Vector3 + * @instance + */ + defineProperty(proto, 'x', { + get: function () { + return this.array[0]; + }, + set: function (value) { + this.array[0] = value; + this._dirty = true; + } + }); + + /** + * @name y + * @type {number} + * @memberOf clay.Vector3 + * @instance + */ + defineProperty(proto, 'y', { + get: function () { + return this.array[1]; + }, + set: function (value) { + this.array[1] = value; + this._dirty = true; + } + }); + + /** + * @name z + * @type {number} + * @memberOf clay.Vector3 + * @instance + */ + defineProperty(proto, 'z', { + get: function () { + return this.array[2]; + }, + set: function (value) { + this.array[2] = value; + this._dirty = true; + } + }); +} + + +// Supply methods that are not in place /** - * 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 + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {clay.Vector3} */ -vec4.fromValues = function(x, y, z, w) { - var out = new GLMAT_ARRAY_TYPE(4); - out[0] = x; - out[1] = y; - out[2] = z; - out[3] = w; +Vector3.add = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].add(out.array, a.array, b.array); + out._dirty = true; 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 + * @param {clay.Vector3} out + * @param {number} x + * @param {number} y + * @param {number} z + * @return {clay.Vector3} */ -vec4.copy = function(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - return out; +Vector3.set = function(out, x, y, z) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].set(out.array, x, y, z); + out._dirty = true; }; /** - * 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 + * @param {clay.Vector3} out + * @param {clay.Vector3} b + * @return {clay.Vector3} */ -vec4.set = function(out, x, y, z, w) { - out[0] = x; - out[1] = y; - out[2] = z; - out[3] = w; +Vector3.copy = function(out, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].copy(out.array, b.array); + out._dirty = true; 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 + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {clay.Vector3} */ -vec4.add = function(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]; +Vector3.cross = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].cross(out.array, a.array, b.array); + out._dirty = true; 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 + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {number} */ -vec4.subtract = function(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; +Vector3.dist = function(a, b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].distance(a.array, b.array); }; /** - * Alias for {@link vec4.subtract} * @function + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {number} */ -vec4.sub = vec4.subtract; +Vector3.distance = Vector3.dist; /** - * 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 + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {clay.Vector3} */ -vec4.multiply = function(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]; +Vector3.div = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].divide(out.array, a.array, b.array); + out._dirty = true; return out; }; /** - * Alias for {@link vec4.multiply} * @function + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {clay.Vector3} */ -vec4.mul = vec4.multiply; +Vector3.divide = Vector3.div; /** - * 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 + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {number} */ -vec4.divide = function(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; +Vector3.dot = function(a, b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].dot(a.array, b.array); }; /** - * Alias for {@link vec4.divide} - * @function + * @param {clay.Vector3} a + * @return {number} */ -vec4.div = vec4.divide; +Vector3.len = function(b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].length(b.array); +}; + +// Vector3.length = Vector3.len; /** - * 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 + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @param {number} t + * @return {clay.Vector3} */ -vec4.min = function(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]); +Vector3.lerp = function(out, a, b, t) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].lerp(out.array, a.array, b.array, t); + out._dirty = true; 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 + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {clay.Vector3} */ -vec4.max = function(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]); +Vector3.min = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].min(out.array, a.array, b.array); + out._dirty = true; 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 + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {clay.Vector3} */ -vec4.scale = function(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; +Vector3.max = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].max(out.array, a.array, b.array); + out._dirty = true; 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 + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {clay.Vector3} */ -vec4.scaleAndAdd = function(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); +Vector3.mul = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].multiply(out.array, a.array, b.array); + out._dirty = true; 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 + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {clay.Vector3} */ -vec4.distance = function(a, b) { - var x = b[0] - a[0], - y = b[1] - a[1], - z = b[2] - a[2], - w = b[3] - a[3]; - return Math.sqrt(x*x + y*y + z*z + w*w); +Vector3.multiply = Vector3.mul; +/** + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @return {clay.Vector3} + */ +Vector3.negate = function(out, a) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].negate(out.array, a.array); + out._dirty = true; + return out; }; - /** - * Alias for {@link vec4.distance} - * @function + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @return {clay.Vector3} */ -vec4.dist = vec4.distance; - +Vector3.normalize = function(out, a) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].normalize(out.array, a.array); + out._dirty = true; + return out; +}; /** - * 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 + * @param {clay.Vector3} out + * @param {number} scale + * @return {clay.Vector3} */ -vec4.squaredDistance = function(a, b) { - var x = b[0] - a[0], - y = b[1] - a[1], - z = b[2] - a[2], - w = b[3] - a[3]; - return x*x + y*y + z*z + w*w; +Vector3.random = function(out, scale) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].random(out.array, scale); + out._dirty = true; + return out; }; - /** - * Alias for {@link vec4.squaredDistance} - * @function + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {number} scale + * @return {clay.Vector3} */ -vec4.sqrDist = vec4.squaredDistance; - +Vector3.scale = function(out, a, scale) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].scale(out.array, a.array, scale); + out._dirty = true; + return out; +}; /** - * Calculates the length of a vec4 - * - * @param {vec4} a vector to calculate length of - * @returns {Number} length of a + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @param {number} scale + * @return {clay.Vector3} */ -vec4.length = function (a) { - var x = a[0], - y = a[1], - z = a[2], - w = a[3]; - return Math.sqrt(x*x + y*y + z*z + w*w); +Vector3.scaleAndAdd = function(out, a, b, scale) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, a.array, b.array, scale); + out._dirty = true; + return out; +}; +/** + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {number} + */ +Vector3.sqrDist = function(a, b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].sqrDist(a.array, b.array); }; - /** - * Alias for {@link vec4.length} * @function + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {number} */ -vec4.len = vec4.length; - +Vector3.squaredDistance = Vector3.sqrDist; /** - * Calculates the squared length of a vec4 - * - * @param {vec4} a vector to calculate squared length of - * @returns {Number} squared length of a + * @param {clay.Vector3} a + * @return {number} */ -vec4.squaredLength = function (a) { - var x = a[0], - y = a[1], - z = a[2], - w = a[3]; - return x*x + y*y + z*z + w*w; +Vector3.sqrLen = function(a) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].sqrLen(a.array); }; - /** - * Alias for {@link vec4.squaredLength} * @function + * @param {clay.Vector3} a + * @return {number} */ -vec4.sqrLen = vec4.squaredLength; +Vector3.squaredLength = Vector3.sqrLen; /** - * Negates the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to negate - * @returns {vec4} out + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {clay.Vector3} */ -vec4.negate = function(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - out[2] = -a[2]; - out[3] = -a[3]; +Vector3.sub = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].subtract(out.array, a.array, b.array); + out._dirty = true; 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 + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @return {clay.Vector3} */ -vec4.inverse = function(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; -}; +Vector3.subtract = Vector3.sub; /** - * Normalize a vec4 - * - * @param {vec4} out the receiving vector - * @param {vec4} a vector to normalize - * @returns {vec4} out + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {Matrix3} m + * @return {clay.Vector3} */ -vec4.normalize = function(out, a) { - var x = a[0], - y = a[1], - z = a[2], - w = a[3]; - var len = x*x + y*y + z*z + w*w; - if (len > 0) { - len = 1 / Math.sqrt(len); - out[0] = a[0] * len; - out[1] = a[1] * len; - out[2] = a[2] * len; - out[3] = a[3] * len; - } +Vector3.transformMat3 = function(out, a, m) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].transformMat3(out.array, a.array, m.array); + out._dirty = true; 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 + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Matrix4} m + * @return {clay.Vector3} */ -vec4.dot = function (a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; +Vector3.transformMat4 = function(out, a, m) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].transformMat4(out.array, a.array, m.array); + out._dirty = true; + return out; }; - /** - * 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 between the two inputs - * @returns {vec4} out + * @param {clay.Vector3} out + * @param {clay.Vector3} a + * @param {clay.Quaternion} q + * @return {clay.Vector3} */ -vec4.lerp = function (out, a, b, t) { - var ax = a[0], - ay = a[1], - az = a[2], - 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); +Vector3.transformQuat = function(out, a, q) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].transformQuat(out.array, a.array, q.array); + out._dirty = true; return out; }; +function clamp(val, min, max) { + return val < min ? min : (val > max ? max : val); +} +var atan2 = Math.atan2; +var asin = Math.asin; +var abs = Math.abs; /** - * 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 + * Convert quaternion to euler angle + * Quaternion must be normalized + * From three.js */ -vec4.random = function (out, scale) { - scale = scale || 1.0; +Vector3.eulerFromQuat = function (out, q, order) { + out._dirty = true; + q = q.array; - //TODO: This is a pretty awful way of doing this. Find something better. - out[0] = GLMAT_RANDOM(); - out[1] = GLMAT_RANDOM(); - out[2] = GLMAT_RANDOM(); - out[3] = GLMAT_RANDOM(); - vec4.normalize(out, out); - vec4.scale(out, out, scale); - return out; -}; + var target = out.array; + 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 w2 = w * w; -/** - * 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 - */ -vec4.transformMat4 = function(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; + var order = (order || 'XYZ').toUpperCase(); + + switch (order) { + case 'XYZ': + target[0] = atan2(2 * (x * w - y * z), (w2 - x2 - y2 + z2)); + target[1] = asin(clamp(2 * (x * z + y * w), - 1, 1)); + target[2] = atan2(2 * (z * w - x * y), (w2 + x2 - y2 - z2)); + break; + case 'YXZ': + target[0] = asin(clamp(2 * (x * w - y * z), - 1, 1)); + target[1] = atan2(2 * (x * z + y * w), (w2 - x2 - y2 + z2)); + target[2] = atan2(2 * (x * y + z * w), (w2 - x2 + y2 - z2)); + break; + case 'ZXY': + target[0] = asin(clamp(2 * (x * w + y * z), - 1, 1)); + target[1] = atan2(2 * (y * w - z * x), (w2 - x2 - y2 + z2)); + target[2] = atan2(2 * (z * w - x * y), (w2 - x2 + y2 - z2)); + break; + case 'ZYX': + target[0] = atan2(2 * (x * w + z * y), (w2 - x2 - y2 + z2)); + target[1] = asin(clamp(2 * (y * w - x * z), - 1, 1)); + target[2] = atan2(2 * (x * y + z * w), (w2 + x2 - y2 - z2)); + break; + case 'YZX': + target[0] = atan2(2 * (x * w - z * y), (w2 - x2 + y2 - z2)); + target[1] = atan2(2 * (y * w - x * z), (w2 + x2 - y2 - z2)); + target[2] = asin(clamp(2 * (x * y + z * w), - 1, 1)); + break; + case 'XZY': + target[0] = atan2(2 * (x * w + y * z), (w2 - x2 + y2 - z2)); + target[1] = atan2(2 * (x * z + y * w), (w2 + x2 - y2 - z2)); + target[2] = asin(clamp(2 * (z * w - x * y), - 1, 1)); + break; + default: + console.warn('Unkown order: ' + order); + } 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 + * Convert rotation matrix to euler angle + * from three.js */ -vec4.transformQuat = function(out, a, q) { - var x = a[0], y = a[1], z = a[2], - qx = q[0], qy = q[1], qz = q[2], qw = q[3], +Vector3.eulerFromMat3 = function (out, m, order) { + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + var te = m.array; + var m11 = te[0], m12 = te[3], m13 = te[6]; + var m21 = te[1], m22 = te[4], m23 = te[7]; + var m31 = te[2], m32 = te[5], m33 = te[8]; + var target = out.array; - // calculate quat * vec - ix = qw * x + qy * z - qz * y, - iy = qw * y + qz * x - qx * z, - iz = qw * z + qx * y - qy * x, - iw = -qx * x - qy * y - qz * z; + var order = (order || 'XYZ').toUpperCase(); + + switch (order) { + case 'XYZ': + target[1] = asin(clamp(m13, -1, 1)); + if (abs(m13) < 0.99999) { + target[0] = atan2(-m23, m33); + target[2] = atan2(-m12, m11); + } + else { + target[0] = atan2(m32, m22); + target[2] = 0; + } + break; + case 'YXZ': + target[0] = asin(-clamp(m23, -1, 1)); + if (abs(m23) < 0.99999) { + target[1] = atan2(m13, m33); + target[2] = atan2(m21, m22); + } + else { + target[1] = atan2(-m31, m11); + target[2] = 0; + } + break; + case 'ZXY': + target[0] = asin(clamp(m32, -1, 1)); + if (abs(m32) < 0.99999) { + target[1] = atan2(-m31, m33); + target[2] = atan2(-m12, m22); + } + else { + target[1] = 0; + target[2] = atan2(m21, m11); + } + break; + case 'ZYX': + target[1] = asin(-clamp(m31, -1, 1)); + if (abs(m31) < 0.99999) { + target[0] = atan2(m32, m33); + target[2] = atan2(m21, m11); + } + else { + target[0] = 0; + target[2] = atan2(-m12, m22); + } + break; + case 'YZX': + target[2] = asin(clamp(m21, -1, 1)); + if (abs(m21) < 0.99999) { + target[0] = atan2(-m23, m22); + target[1] = atan2(-m31, m11); + } + else { + target[0] = 0; + target[1] = atan2(m13, m33); + } + break; + case 'XZY': + target[2] = asin(-clamp(m12, -1, 1)); + if (abs(m12) < 0.99999) { + target[0] = atan2(m32, m22); + target[1] = atan2(m13, m11); + } + else { + target[0] = atan2(-m23, m33); + target[1] = 0; + } + break; + default: + console.warn('Unkown order: ' + order); + } + out._dirty = true; - // 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; return out; }; -/** - * 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 - */ -vec4.forEach = (function() { - var vec = vec4.create(); - - return function(a, stride, offset, count, fn, arg) { - var i, l; - if(!stride) { - stride = 4; +Object.defineProperties(Vector3, { + /** + * @type {clay.Vector3} + * @readOnly + * @memberOf clay.Vector3 + */ + POSITIVE_X: { + get: function () { + return new Vector3(1, 0, 0); } - - if(!offset) { - offset = 0; + }, + /** + * @type {clay.Vector3} + * @readOnly + * @memberOf clay.Vector3 + */ + NEGATIVE_X: { + get: function () { + return new Vector3(-1, 0, 0); } - - if(count) { - l = Math.min((count * stride) + offset, a.length); - } else { - l = a.length; + }, + /** + * @type {clay.Vector3} + * @readOnly + * @memberOf clay.Vector3 + */ + POSITIVE_Y: { + get: function () { + return new Vector3(0, 1, 0); } - - 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]; + }, + /** + * @type {clay.Vector3} + * @readOnly + * @memberOf clay.Vector3 + */ + NEGATIVE_Y: { + get: function () { + return new Vector3(0, -1, 0); } + }, + /** + * @type {clay.Vector3} + * @readOnly + * @memberOf clay.Vector3 + */ + POSITIVE_Z: { + get: function () { + return new Vector3(0, 0, 1); + } + }, + /** + * @type {clay.Vector3} + * @readOnly + */ + NEGATIVE_Z: { + get: function () { + return new Vector3(0, 0, -1); + } + }, + /** + * @type {clay.Vector3} + * @readOnly + * @memberOf clay.Vector3 + */ + UP: { + get: function () { + return new Vector3(0, 1, 0); + } + }, + /** + * @type {clay.Vector3} + * @readOnly + * @memberOf clay.Vector3 + */ + ZERO: { + get: function () { + return new Vector3(); + } + } +}); - return a; - }; -})(); - -/** - * Returns a string representation of a vector - * - * @param {vec4} vec vector to represent as a string - * @returns {String} string representation of the vector - */ -vec4.str = function (a) { - return 'vec4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; -}; - -if(typeof(exports) !== 'undefined') { - exports.vec4 = vec4; -} -; -/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: +/* harmony default export */ __webpack_exports__["a"] = (Vector3); - * 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 HOLDER 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 USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/***/ }), +/* 4 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_Cache__ = __webpack_require__(57); /** - * @class 2x2 Matrix - * @name mat2 + * Base class for all textures like compressed texture, texture2d, texturecube + * TODO mapping */ -var mat2 = {}; - -/** - * Creates a new identity mat2 - * - * @returns {mat2} a new 2x2 matrix - */ -mat2.create = function() { - var out = new GLMAT_ARRAY_TYPE(4); - out[0] = 1; - out[1] = 0; - out[2] = 0; - 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 - */ -mat2.clone = function(a) { - var out = new GLMAT_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 - */ -mat2.copy = function(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 + * @constructor + * @alias clay.Texture + * @extends clay.core.Base */ -mat2.identity = function(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - return out; -}; +var Texture = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend( /** @lends clay.Texture# */ { + /** + * Texture width, readonly when the texture source is image + * @type {number} + */ + width: 512, + /** + * Texture height, readonly when the texture source is image + * @type {number} + */ + height: 512, + /** + * Texel data type. + * Possible values: + * + {@link clay.Texture.UNSIGNED_BYTE} + * + {@link clay.Texture.HALF_FLOAT} + * + {@link clay.Texture.FLOAT} + * + {@link clay.Texture.UNSIGNED_INT_24_8_WEBGL} + * + {@link clay.Texture.UNSIGNED_INT} + * @type {number} + */ + type: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_BYTE, + /** + * Format of texel data + * Possible values: + * + {@link clay.Texture.RGBA} + * + {@link clay.Texture.DEPTH_COMPONENT} + * + {@link clay.Texture.DEPTH_STENCIL} + * @type {number} + */ + format: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].RGBA, + /** + * Texture wrap. Default to be REPEAT. + * Possible values: + * + {@link clay.Texture.CLAMP_TO_EDGE} + * + {@link clay.Texture.REPEAT} + * + {@link clay.Texture.MIRRORED_REPEAT} + * @type {number} + */ + wrapS: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].REPEAT, + /** + * Texture wrap. Default to be REPEAT. + * Possible values: + * + {@link clay.Texture.CLAMP_TO_EDGE} + * + {@link clay.Texture.REPEAT} + * + {@link clay.Texture.MIRRORED_REPEAT} + * @type {number} + */ + wrapT: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].REPEAT, + /** + * Possible values: + * + {@link clay.Texture.NEAREST} + * + {@link clay.Texture.LINEAR} + * + {@link clay.Texture.NEAREST_MIPMAP_NEAREST} + * + {@link clay.Texture.LINEAR_MIPMAP_NEAREST} + * + {@link clay.Texture.NEAREST_MIPMAP_LINEAR} + * + {@link clay.Texture.LINEAR_MIPMAP_LINEAR} + * @type {number} + */ + minFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR, + /** + * Possible values: + * + {@link clay.Texture.NEAREST} + * + {@link clay.Texture.LINEAR} + * @type {number} + */ + magFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR, + /** + * If enable mimap. + * @type {boolean} + */ + useMipmap: true, -/** - * Transpose the values of a mat2 - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the source matrix - * @returns {mat2} out - */ -mat2.transpose = function(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]; - } + /** + * Anisotropic filtering, enabled if value is larger than 1 + * @see https://developer.mozilla.org/en-US/docs/Web/API/EXT_texture_filter_anisotropic + * @type {number} + */ + anisotropic: 1, + // pixelStorei parameters, not available when texture is used as render target + // http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml + /** + * If flip in y axis for given image source + * @type {boolean} + * @default true + */ + flipY: true, - return out; -}; + /** + * A flag to indicate if texture source is sRGB + */ + sRGB: true, + /** + * @type {number} + * @default 4 + */ + unpackAlignment: 4, + /** + * @type {boolean} + * @default false + */ + premultiplyAlpha: false, -/** - * Inverts a mat2 - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the source matrix - * @returns {mat2} out - */ -mat2.invert = function(out, a) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], + /** + * Dynamic option for texture like video + * @type {boolean} + */ + dynamic: false, - // Calculate the determinant - det = a0 * a3 - a2 * a1; + NPOT: false, - if (!det) { - return null; - } - det = 1.0 / det; + // PENDING + // Init it here to avoid deoptimization when it's assigned in application dynamically + __used: 0 - out[0] = a3 * det; - out[1] = -a1 * det; - out[2] = -a2 * det; - out[3] = a0 * det; +}, function () { + this._cache = new __WEBPACK_IMPORTED_MODULE_2__core_Cache__["a" /* default */](); +}, +/** @lends clay.Texture.prototype */ +{ - return out; -}; + getWebGLTexture: function (renderer) { + var _gl = renderer.gl; + var cache = this._cache; + cache.use(renderer.__uid__); -/** - * Calculates the adjugate of a mat2 - * - * @param {mat2} out the receiving matrix - * @param {mat2} a the source matrix - * @returns {mat2} out - */ -mat2.adjoint = function(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; + if (cache.miss('webgl_texture')) { + // In a new gl context, create new texture and set dirty true + cache.put('webgl_texture', _gl.createTexture()); + } + if (this.dynamic) { + this.update(renderer); + } + else if (cache.isDirty()) { + this.update(renderer); + cache.fresh(); + } - return out; -}; + return cache.get('webgl_texture'); + }, + + bind: function () {}, + unbind: function () {}, + + /** + * Mark texture is dirty and update in the next frame + */ + dirty: function () { + if (this._cache) { + this._cache.dirtyAll(); + } + }, + + update: function (renderer) {}, + + // Update the common parameters of texture + updateCommon: function (renderer) { + var _gl = renderer.gl; + _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, this.flipY); + _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha); + _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, this.unpackAlignment); + + // Use of none-power of two texture + // http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences + if (this.format === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DEPTH_COMPONENT) { + this.useMipmap = false; + } + + var sRGBExt = renderer.getGLExtension('EXT_sRGB'); + // Fallback + if (this.format === Texture.SRGB && !sRGBExt) { + this.format = Texture.RGB; + } + if (this.format === Texture.SRGB_ALPHA && !sRGBExt) { + this.format = Texture.RGBA; + } + + this.NPOT = !this.isPowerOfTwo(); + }, + + getAvailableWrapS: function () { + if (this.NPOT) { + return __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE; + } + return this.wrapS; + }, + getAvailableWrapT: function () { + if (this.NPOT) { + return __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE; + } + return this.wrapT; + }, + getAvailableMinFilter: function () { + var minFilter = this.minFilter; + if (this.NPOT || !this.useMipmap) { + if (minFilter === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_NEAREST || + minFilter === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_LINEAR + ) { + return __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST; + } + else if (minFilter === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR || + minFilter === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_NEAREST + ) { + return __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR; + } + else { + return minFilter; + } + } + else { + return minFilter; + } + }, + getAvailableMagFilter: function () { + return this.magFilter; + }, + + nextHighestPowerOfTwo: function (x) { + --x; + for (var i = 1; i < 32; i <<= 1) { + x = x | x >> i; + } + return x + 1; + }, + /** + * @param {clay.Renderer} renderer + */ + dispose: function (renderer) { + + var cache = this._cache; + + cache.use(renderer.__uid__); + + var webglTexture = cache.get('webgl_texture'); + if (webglTexture){ + renderer.gl.deleteTexture(webglTexture); + } + cache.deleteContext(renderer.__uid__); + + }, + /** + * Test if image of texture is valid and loaded. + * @return {boolean} + */ + isRenderable: function () {}, + + /** + * Test if texture size is power of two + * @return {boolean} + */ + isPowerOfTwo: function () {} +}); + +Object.defineProperty(Texture.prototype, 'width', { + get: function () { + return this._width; + }, + set: function (value) { + this._width = value; + } +}); +Object.defineProperty(Texture.prototype, 'height', { + get: function () { + return this._height; + }, + set: function (value) { + this._height = value; + } +}); + +/* DataType */ /** - * Calculates the determinant of a mat2 - * - * @param {mat2} a the source matrix - * @returns {Number} determinant of a + * @type {number} */ -mat2.determinant = function (a) { - return a[0] * a[3] - a[2] * a[1]; -}; - +Texture.BYTE = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].BYTE; /** - * 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 + * @type {number} */ -mat2.multiply = function (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; -}; - +Texture.UNSIGNED_BYTE = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_BYTE; /** - * Alias for {@link mat2.multiply} - * @function + * @type {number} */ -mat2.mul = mat2.multiply; - +Texture.SHORT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].SHORT; /** - * 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 + * @type {number} */ -mat2.rotate = function (out, a, rad) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], - s = Math.sin(rad), - 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; -}; - +Texture.UNSIGNED_SHORT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_SHORT; /** - * 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 - **/ -mat2.scale = function(out, a, v) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], - v0 = v[0], v1 = v[1]; - out[0] = a0 * v0; - out[1] = a1 * v0; - out[2] = a2 * v1; - out[3] = a3 * v1; - return out; -}; - + * @type {number} + */ +Texture.INT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].INT; /** - * Returns a string representation of a mat2 - * - * @param {mat2} mat matrix to represent as a string - * @returns {String} string representation of the matrix + * @type {number} */ -mat2.str = function (a) { - return 'mat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; -}; - +Texture.UNSIGNED_INT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_INT; /** - * Returns Frobenius norm of a mat2 - * - * @param {mat2} a the matrix to calculate Frobenius norm of - * @returns {Number} Frobenius norm + * @type {number} */ -mat2.frob = function (a) { - return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2))) -}; - +Texture.FLOAT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FLOAT; /** - * 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 + * @type {number} */ - -mat2.LDU = function (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]; -}; - -if(typeof(exports) !== 'undefined') { - exports.mat2 = mat2; -} -; -/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. 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 HOLDER 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 USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +Texture.HALF_FLOAT = 0x8D61; /** - * @class 2x3 Matrix - * @name mat2d - * - * @description - * A mat2d contains six elements defined as: - *
- * [a, c, tx,
- *  b, d, ty]
- * 
- * This is a short form for the 3x3 matrix: - *
- * [a, c, tx,
- *  b, d, ty,
- *  0, 0, 1]
- * 
- * The last row is ignored so the array is shorter and operations are faster. + * UNSIGNED_INT_24_8_WEBGL for WEBGL_depth_texture extension + * @type {number} */ +Texture.UNSIGNED_INT_24_8_WEBGL = 34042; -var mat2d = {}; - +/* PixelFormat */ /** - * Creates a new identity mat2d - * - * @returns {mat2d} a new 2x3 matrix + * @type {number} */ -mat2d.create = function() { - var out = new GLMAT_ARRAY_TYPE(6); - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = 0; - out[5] = 0; - return out; -}; - +Texture.DEPTH_COMPONENT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DEPTH_COMPONENT; /** - * Creates a new mat2d initialized with values from an existing matrix - * - * @param {mat2d} a matrix to clone - * @returns {mat2d} a new 2x3 matrix + * @type {number} */ -mat2d.clone = function(a) { - var out = new GLMAT_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; -}; - +Texture.DEPTH_STENCIL = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DEPTH_STENCIL; /** - * Copy the values from one mat2d to another - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the source matrix - * @returns {mat2d} out + * @type {number} */ -mat2d.copy = function(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; -}; - +Texture.ALPHA = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].ALPHA; /** - * Set a mat2d to the identity matrix - * - * @param {mat2d} out the receiving matrix - * @returns {mat2d} out + * @type {number} */ -mat2d.identity = function(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = 0; - out[5] = 0; - return out; -}; - +Texture.RGB = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].RGB; /** - * Inverts a mat2d - * - * @param {mat2d} out the receiving matrix - * @param {mat2d} a the source matrix - * @returns {mat2d} out + * @type {number} */ -mat2d.invert = function(out, a) { - var aa = a[0], ab = a[1], ac = a[2], ad = a[3], - 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; -}; - +Texture.RGBA = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].RGBA; /** - * Calculates the determinant of a mat2d - * - * @param {mat2d} a the source matrix - * @returns {Number} determinant of a + * @type {number} */ -mat2d.determinant = function (a) { - return a[0] * a[3] - a[1] * a[2]; -}; - +Texture.LUMINANCE = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LUMINANCE; /** - * 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 + * @type {number} */ -mat2d.multiply = function (out, a, b) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], - 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; -}; +Texture.LUMINANCE_ALPHA = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LUMINANCE_ALPHA; /** - * Alias for {@link mat2d.multiply} - * @function + * @see https://www.khronos.org/registry/webgl/extensions/EXT_sRGB/ + * @type {number} */ -mat2d.mul = mat2d.multiply; - - +Texture.SRGB = 0x8C40; /** - * 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 + * @see https://www.khronos.org/registry/webgl/extensions/EXT_sRGB/ + * @type {number} */ -mat2d.rotate = function (out, a, rad) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], - s = Math.sin(rad), - 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; -}; +Texture.SRGB_ALPHA = 0x8C42; -/** - * 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 - **/ -mat2d.scale = function(out, a, v) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], - 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; -}; +/* Compressed Texture */ +Texture.COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; +Texture.COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1; +Texture.COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; +Texture.COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; +/* TextureMagFilter */ /** - * 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 - **/ -mat2d.translate = function(out, a, v) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], - 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; -}; - + * @type {number} + */ +Texture.NEAREST = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST; /** - * Returns a string representation of a mat2d - * - * @param {mat2d} a matrix to represent as a string - * @returns {String} string representation of the matrix + * @type {number} */ -mat2d.str = function (a) { - return 'mat2d(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + - a[3] + ', ' + a[4] + ', ' + a[5] + ')'; -}; +Texture.LINEAR = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR; +/* TextureMinFilter */ /** - * Returns Frobenius norm of a mat2d - * - * @param {mat2d} a the matrix to calculate Frobenius norm of - * @returns {Number} Frobenius norm + * @type {number} */ -mat2d.frob = function (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)) -}; - -if(typeof(exports) !== 'undefined') { - exports.mat2d = mat2d; -} -; -/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. 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 HOLDER 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 USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - +Texture.NEAREST_MIPMAP_NEAREST = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_NEAREST; /** - * @class 3x3 Matrix - * @name mat3 + * @type {number} */ - -var mat3 = {}; - +Texture.LINEAR_MIPMAP_NEAREST = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_NEAREST; /** - * Creates a new identity mat3 - * - * @returns {mat3} a new 3x3 matrix + * @type {number} */ -mat3.create = function() { - var out = new GLMAT_ARRAY_TYPE(9); - 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; -}; - +Texture.NEAREST_MIPMAP_LINEAR = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_LINEAR; /** - * 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 + * @type {number} */ -mat3.fromMat4 = function(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; -}; +Texture.LINEAR_MIPMAP_LINEAR = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR; +/* TextureWrapMode */ /** - * Creates a new mat3 initialized with values from an existing matrix - * - * @param {mat3} a matrix to clone - * @returns {mat3} a new 3x3 matrix + * @type {number} */ -mat3.clone = function(a) { - var out = new GLMAT_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; -}; - +Texture.REPEAT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].REPEAT; /** - * Copy the values from one mat3 to another - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the source matrix - * @returns {mat3} out + * @type {number} */ -mat3.copy = function(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; -}; - +Texture.CLAMP_TO_EDGE = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE; /** - * Set a mat3 to the identity matrix - * - * @param {mat3} out the receiving matrix - * @returns {mat3} out + * @type {number} */ -mat3.identity = function(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; -}; +Texture.MIRRORED_REPEAT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].MIRRORED_REPEAT; -/** - * Transpose the values of a mat3 - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the source matrix - * @returns {mat3} out - */ -mat3.transpose = function(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; -}; +/* harmony default export */ __webpack_exports__["a"] = (Texture); -/** - * Inverts a mat3 - * - * @param {mat3} out the receiving matrix - * @param {mat3} a the source matrix - * @returns {mat3} out - */ -mat3.invert = function(out, a) { - 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], - b01 = a22 * a11 - a12 * a21, - b11 = -a22 * a10 + a12 * a20, - b21 = a21 * a10 - a11 * a20, +/***/ }), +/* 5 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - // Calculate the determinant - det = a00 * b01 + a01 * b11 + a02 * b21; +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_vendor__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_util__ = __webpack_require__(73); - 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 - */ -mat3.adjoint = function(out, a) { - 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]; - 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; -}; +var isPowerOfTwo = __WEBPACK_IMPORTED_MODULE_3__math_util__["a" /* default */].isPowerOfTwo; -/** - * Calculates the determinant of a mat3 - * - * @param {mat3} a the source matrix - * @returns {Number} determinant of a - */ -mat3.determinant = function (a) { - 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]; +function nearestPowerOfTwo(val) { + return Math.pow(2, Math.round(Math.log(val) / Math.LN2)); +} +function convertTextureToPowerOfTwo(texture, canvas) { + // var canvas = document.createElement('canvas'); + var width = nearestPowerOfTwo(texture.width); + var height = nearestPowerOfTwo(texture.height); + canvas = canvas || document.createElement('canvas'); + canvas.width = width; + canvas.height = height; + var ctx = canvas.getContext('2d'); + ctx.drawImage(texture.image, 0, 0, width, height); - return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); -}; + return canvas; +} /** - * Multiplies two mat3's + * @constructor clay.Texture2D + * @extends clay.Texture * - * @param {mat3} out the receiving matrix - * @param {mat3} a the first operand - * @param {mat3} b the second operand - * @returns {mat3} out + * @example + * ... + * var mat = new clay.Material({ + * shader: clay.shader.library.get('clay.phong', 'diffuseMap') + * }); + * var diffuseMap = new clay.Texture2D(); + * diffuseMap.load('assets/textures/diffuse.jpg'); + * mat.set('diffuseMap', diffuseMap); + * ... + * diffuseMap.success(function () { + * // Wait for the diffuse texture loaded + * animation.on('frame', function (frameTime) { + * renderer.render(scene, camera); + * }); + * }); */ -mat3.multiply = function (out, a, b) { - 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], - - b00 = b[0], b01 = b[1], b02 = b[2], - b10 = b[3], b11 = b[4], b12 = b[5], - b20 = b[6], b21 = b[7], b22 = b[8]; +var Texture2D = __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].extend(function () { + return /** @lends clay.Texture2D# */ { + /** + * @type {?HTMLImageElement|HTMLCanvasElemnet} + */ + // TODO mark dirty when assigned. + image: null, + /** + * Pixels data. Will be ignored if image is set. + * @type {?Uint8Array|Float32Array} + */ + pixels: null, + /** + * @type {Array.} + * @example + * [{ + * image: mipmap0, + * pixels: null + * }, { + * image: mipmap1, + * pixels: null + * }, ....] + */ + mipmaps: [], - out[0] = b00 * a00 + b01 * a10 + b02 * a20; - out[1] = b00 * a01 + b01 * a11 + b02 * a21; - out[2] = b00 * a02 + b01 * a12 + b02 * a22; + /** + * If convert texture to power-of-two + * @type {boolean} + */ + convertToPOT: false + }; +}, { - out[3] = b10 * a00 + b11 * a10 + b12 * a20; - out[4] = b10 * a01 + b11 * a11 + b12 * a21; - out[5] = b10 * a02 + b11 * a12 + b12 * a22; + textureType: 'texture2D', - 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; -}; + update: function (renderer) { -/** - * Alias for {@link mat3.multiply} - * @function - */ -mat3.mul = mat3.multiply; + var _gl = renderer.gl; + _gl.bindTexture(_gl.TEXTURE_2D, this._cache.get('webgl_texture')); -/** - * 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 - */ -mat3.translate = function(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]; + this.updateCommon(renderer); - out[0] = a00; - out[1] = a01; - out[2] = a02; + var glFormat = this.format; + var glType = this.type; - out[3] = a10; - out[4] = a11; - out[5] = a12; + // Convert to pot is only available when using image/canvas/video element. + var convertToPOT = !!(this.convertToPOT + && !this.mipmaps.length && this.image + && (this.wrapS === __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].REPEAT || this.wrapT === __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].REPEAT) + && this.NPOT + ); - out[6] = x * a00 + y * a10 + a20; - out[7] = x * a01 + y * a11 + a21; - out[8] = x * a02 + y * a12 + a22; - return out; -}; + _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, convertToPOT ? this.wrapS : this.getAvailableWrapS()); + _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, convertToPOT ? this.wrapT : this.getAvailableWrapT()); -/** - * 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 - */ -mat3.rotate = function (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], + _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_MAG_FILTER, convertToPOT ? this.magFilter : this.getAvailableMagFilter()); + _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, convertToPOT ? this.minFilter : this.getAvailableMinFilter()); - s = Math.sin(rad), - c = Math.cos(rad); + var anisotropicExt = renderer.getGLExtension('EXT_texture_filter_anisotropic'); + if (anisotropicExt && this.anisotropic > 1) { + _gl.texParameterf(_gl.TEXTURE_2D, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, this.anisotropic); + } - out[0] = c * a00 + s * a10; - out[1] = c * a01 + s * a11; - out[2] = c * a02 + s * a12; + // Fallback to float type if browser don't have half float extension + if (glType === 36193) { + var halfFloatExt = renderer.getGLExtension('OES_texture_half_float'); + if (!halfFloatExt) { + glType = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FLOAT; + } + } - out[3] = c * a10 - s * a00; - out[4] = c * a11 - s * a01; - out[5] = c * a12 - s * a02; + if (this.mipmaps.length) { + var width = this.width; + var height = this.height; + for (var i = 0; i < this.mipmaps.length; i++) { + var mipmap = this.mipmaps[i]; + this._updateTextureData(_gl, mipmap, i, width, height, glFormat, glType, false); + width /= 2; + height /= 2; + } + } + else { + this._updateTextureData(_gl, this, 0, this.width, this.height, glFormat, glType, convertToPOT); - out[6] = a20; - out[7] = a21; - out[8] = a22; - return out; -}; + if (this.useMipmap && (!this.NPOT || convertToPOT)) { + _gl.generateMipmap(_gl.TEXTURE_2D); + } + } -/** - * 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 - **/ -mat3.scale = function(out, a, v) { - var x = v[0], y = v[1]; + _gl.bindTexture(_gl.TEXTURE_2D, null); + }, - out[0] = x * a[0]; - out[1] = x * a[1]; - out[2] = x * a[2]; + _updateTextureData: function (_gl, data, level, width, height, glFormat, glType, convertToPOT) { + if (data.image) { + var imgData = data.image; + if (convertToPOT) { + this._potCanvas = convertTextureToPowerOfTwo(this, this._potCanvas); + imgData = this._potCanvas; + } + _gl.texImage2D(_gl.TEXTURE_2D, level, glFormat, glFormat, glType, imgData); + } + else { + // Can be used as a blank texture when writing render to texture(RTT) + if ( + glFormat <= __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].COMPRESSED_RGBA_S3TC_DXT5_EXT + && glFormat >= __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].COMPRESSED_RGB_S3TC_DXT1_EXT + ) { + _gl.compressedTexImage2D(_gl.TEXTURE_2D, level, glFormat, width, height, 0, data.pixels); + } + else { + // Is a render target if pixels is null + _gl.texImage2D(_gl.TEXTURE_2D, level, glFormat, width, height, 0, glFormat, glType, data.pixels); + } + } + }, - out[3] = y * a[3]; - out[4] = y * a[4]; - out[5] = y * a[5]; + /** + * @param {clay.Renderer} renderer + * @memberOf clay.Texture2D.prototype + */ + generateMipmap: function (renderer) { + var _gl = renderer.gl; + if (this.useMipmap && !this.NPOT) { + _gl.bindTexture(_gl.TEXTURE_2D, this._cache.get('webgl_texture')); + _gl.generateMipmap(_gl.TEXTURE_2D); + } + }, - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - return out; -}; + isPowerOfTwo: function () { + return isPowerOfTwo(this.width) && isPowerOfTwo(this.height); + }, -/** - * 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 - **/ -mat3.fromMat2d = function(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = 0; + isRenderable: function () { + if (this.image) { + return this.image.nodeName === 'CANVAS' + || this.image.nodeName === 'VIDEO' + || this.image.complete; + } + else { + return !!(this.width && this.height); + } + }, - out[3] = a[2]; - out[4] = a[3]; - out[5] = 0; + bind: function (renderer) { + renderer.gl.bindTexture(renderer.gl.TEXTURE_2D, this.getWebGLTexture(renderer)); + }, - out[6] = a[4]; - out[7] = a[5]; - out[8] = 1; - return out; -}; + unbind: function (renderer) { + renderer.gl.bindTexture(renderer.gl.TEXTURE_2D, null); + }, -/** -* 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 -*/ -mat3.fromQuat = function (out, q) { - var x = q[0], y = q[1], z = q[2], w = q[3], - x2 = x + x, - y2 = y + y, - z2 = z + z, + load: function (src, crossOrigin) { + var image = __WEBPACK_IMPORTED_MODULE_2__core_vendor__["a" /* default */].createImage(); + if (crossOrigin) { + image.crossOrigin = crossOrigin; + } + var self = this; + image.onload = function () { + self.dirty(); + self.trigger('success', self); + image.onload = null; + }; + image.onerror = function () { + self.trigger('error', self); + image.onerror = null; + }; - xx = x * x2, - yx = y * x2, - yy = y * y2, - zx = z * x2, - zy = z * y2, - zz = z * z2, - wx = w * x2, - wy = w * y2, - wz = w * z2; + image.src = src; + this.image = image; - out[0] = 1 - yy - zz; - out[3] = yx - wz; - out[6] = zx + wy; + return this; + } +}); - out[1] = yx + wz; - out[4] = 1 - xx - zz; - out[7] = zy - wx; +Object.defineProperty(Texture2D.prototype, 'width', { + get: function () { + if (this.image) { + return this.image.width; + } + return this._width; + }, + set: function (value) { + if (this.image) { + console.warn('Texture from image can\'t set width'); + } + else { + if (this._width !== value) { + this.dirty(); + } + this._width = value; + } + } +}); +Object.defineProperty(Texture2D.prototype, 'height', { + get: function () { + if (this.image) { + return this.image.height; + } + return this._height; + }, + set: function (value) { + if (this.image) { + console.warn('Texture from image can\'t set height'); + } + else { + if (this._height !== value) { + this.dirty(); + } + this._height = value; + } + } +}); - out[2] = zx - wy; - out[5] = zy + wx; - out[8] = 1 - xx - yy; +/* harmony default export */ __webpack_exports__["a"] = (Texture2D); - 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 -*/ -mat3.normalFromMat4 = function (out, a) { - var 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], - a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], +/***/ }), +/* 6 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - b00 = a00 * a11 - a01 * a10, - b01 = a00 * a12 - a02 * a10, - b02 = a00 * a13 - a03 * a10, - b03 = a01 * a12 - a02 * a11, - b04 = a01 * a13 - a03 * a11, - b05 = a02 * a13 - a03 * a12, - b06 = a20 * a31 - a21 * a30, - b07 = a20 * a32 - a22 * a30, - b08 = a20 * a33 - a23 * a30, - b09 = a21 * a32 - a22 * a31, - b10 = a21 * a33 - a23 * a31, - b11 = a22 * a33 - a23 * a32, +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix__ = __webpack_require__(161); +// DEPRECATED - // Calculate the determinant - det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - if (!det) { - return null; - } - det = 1.0 / det; +/* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__glmatrix__["a" /* default */]); - 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; +/***/ }), +/* 7 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mixin_extend__ = __webpack_require__(110); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__mixin_notifier__ = __webpack_require__(53); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util__ = __webpack_require__(23); - 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; -}; -/** - * Returns a string representation of a mat3 - * - * @param {mat3} mat matrix to represent as a string - * @returns {String} string representation of the matrix - */ -mat3.str = function (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 + * Base class of all objects + * @constructor + * @alias clay.core.Base + * @mixes clay.core.mixin.notifier */ -mat3.frob = function (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))) +var Base = function () { + /** + * @type {number} + */ + this.__uid__ = __WEBPACK_IMPORTED_MODULE_2__util__["a" /* default */].genGUID(); }; +Base.__initializers__ = [ + function (opts) { + __WEBPACK_IMPORTED_MODULE_2__util__["a" /* default */].extend(this, opts); + } +]; -if(typeof(exports) !== 'undefined') { - exports.mat3 = mat3; -} -; -/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. +__WEBPACK_IMPORTED_MODULE_2__util__["a" /* default */].extend(Base, __WEBPACK_IMPORTED_MODULE_0__mixin_extend__["a" /* default */]); +__WEBPACK_IMPORTED_MODULE_2__util__["a" /* default */].extend(Base.prototype, __WEBPACK_IMPORTED_MODULE_1__mixin_notifier__["a" /* default */]); -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: +/* harmony default export */ __webpack_exports__["a"] = (Base); - * 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 HOLDER 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 USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/***/ }), +/* 8 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_util__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_vendor__ = __webpack_require__(14); /** - * @class 4x4 Matrix - * @name mat4 + * Mainly do the parse and compile of shader string + * Support shader code chunk import and export + * Support shader semantics + * http://www.nvidia.com/object/using_sas.html + * https://github.com/KhronosGroup/collada2json/issues/45 */ -var mat4 = {}; -/** - * Creates a new identity mat4 - * - * @returns {mat4} a new 4x4 matrix - */ -mat4.create = function() { - var out = new GLMAT_ARRAY_TYPE(16); - 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; -}; -/** - * Creates a new mat4 initialized with values from an existing matrix - * - * @param {mat4} a matrix to clone - * @returns {mat4} a new 4x4 matrix - */ -mat4.clone = function(a) { - var out = new GLMAT_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; -}; +var uniformRegex = /uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g; +var attributeRegex = /attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g; +// Only parse number define. +var defineRegex = /#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g; -/** - * Copy the values from one mat4 to another - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out - */ -mat4.copy = function(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; +var uniformTypeMap = { + 'bool': '1i', + 'int': '1i', + 'sampler2D': 't', + 'samplerCube': 't', + 'float': '1f', + 'vec2': '2f', + 'vec3': '3f', + 'vec4': '4f', + 'ivec2': '2i', + 'ivec3': '3i', + 'ivec4': '4i', + 'mat2': 'm2', + 'mat3': 'm3', + 'mat4': 'm4' }; -/** - * Set a mat4 to the identity matrix - * - * @param {mat4} out the receiving matrix - * @returns {mat4} out - */ -mat4.identity = function(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; -}; +function createZeroArray(len) { + var arr = []; + for (var i = 0; i < len; i++) { + arr[i] = 0; + } + return arr; +} -/** - * Transpose the values of a mat4 - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out - */ -mat4.transpose = function(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], - a12 = a[6], a13 = a[7], - a23 = a[11]; +var uniformValueConstructor = { + 'bool': function () { return true; }, + 'int': function () { return 0; }, + 'float': function () { return 0; }, + 'sampler2D': function () { return null; }, + 'samplerCube': function () { return null; }, - 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]; - } + 'vec2': function () { return createZeroArray(2); }, + 'vec3': function () { return createZeroArray(3); }, + 'vec4': function () { return createZeroArray(4); }, - return out; + 'ivec2': function () { return createZeroArray(2); }, + 'ivec3': function () { return createZeroArray(3); }, + 'ivec4': function () { return createZeroArray(4); }, + + 'mat2': function () { return createZeroArray(4); }, + 'mat3': function () { return createZeroArray(9); }, + 'mat4': function () { return createZeroArray(16); }, + + 'array': function () { return []; } }; -/** - * Inverts a mat4 - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out - */ -mat4.invert = function(out, a) { - var 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], - a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], +var attributeSemantics = [ + 'POSITION', + 'NORMAL', + 'BINORMAL', + 'TANGENT', + 'TEXCOORD', + 'TEXCOORD_0', + 'TEXCOORD_1', + 'COLOR', + // Skinning + // https://github.com/KhronosGroup/glTF/blob/master/specification/README.md#semantics + 'JOINT', + 'WEIGHT' +]; +var uniformSemantics = [ + 'SKIN_MATRIX', + // Information about viewport + 'VIEWPORT_SIZE', + 'VIEWPORT', + 'DEVICEPIXELRATIO', + // Window size for window relative coordinate + // https://www.opengl.org/sdk/docs/man/html/gl_FragCoord.xhtml + 'WINDOW_SIZE', + // Infomation about camera + 'NEAR', + 'FAR', + // Time + 'TIME' +]; +var matrixSemantics = [ + 'WORLD', + 'VIEW', + 'PROJECTION', + 'WORLDVIEW', + 'VIEWPROJECTION', + 'WORLDVIEWPROJECTION', + 'WORLDINVERSE', + 'VIEWINVERSE', + 'PROJECTIONINVERSE', + 'WORLDVIEWINVERSE', + 'VIEWPROJECTIONINVERSE', + 'WORLDVIEWPROJECTIONINVERSE', + 'WORLDTRANSPOSE', + 'VIEWTRANSPOSE', + 'PROJECTIONTRANSPOSE', + 'WORLDVIEWTRANSPOSE', + 'VIEWPROJECTIONTRANSPOSE', + 'WORLDVIEWPROJECTIONTRANSPOSE', + 'WORLDINVERSETRANSPOSE', + 'VIEWINVERSETRANSPOSE', + 'PROJECTIONINVERSETRANSPOSE', + 'WORLDVIEWINVERSETRANSPOSE', + 'VIEWPROJECTIONINVERSETRANSPOSE', + 'WORLDVIEWPROJECTIONINVERSETRANSPOSE' +]; - b00 = a00 * a11 - a01 * a10, - b01 = a00 * a12 - a02 * a10, - b02 = a00 * a13 - a03 * a10, - b03 = a01 * a12 - a02 * a11, - b04 = a01 * a13 - a03 * a11, - b05 = a02 * a13 - a03 * a12, - b06 = a20 * a31 - a21 * a30, - b07 = a20 * a32 - a22 * a30, - b08 = a20 * a33 - a23 * a30, - b09 = a21 * a32 - a22 * a31, - b10 = a21 * a33 - a23 * a31, - b11 = a22 * a33 - a23 * a32, +var attributeSizeMap = { + // WebGL does not support integer attributes + 'vec4': 4, + 'vec3': 3, + 'vec2': 2, + 'float': 1 +}; - // Calculate the determinant - det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - if (!det) { - return null; +var shaderIDCache = {}; +var shaderCodeCache = {}; + +function getShaderID(vertex, fragment) { + var key = 'vertex:' + vertex + 'fragment:' + fragment; + if (shaderIDCache[key]) { + return shaderIDCache[key]; } - det = 1.0 / det; + var id = __WEBPACK_IMPORTED_MODULE_0__core_util__["a" /* default */].genGUID(); + shaderIDCache[key] = id; - 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; + shaderCodeCache[id] = { + vertex: vertex, + fragment: fragment + }; - return out; -}; + return id; +} -/** - * Calculates the adjugate of a mat4 - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the source matrix - * @returns {mat4} out - */ -mat4.adjoint = function(out, a) { - var 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], - a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; +function removeComment(code) { + return code.replace(/[ \t]*\/\/.*\n/g, '' ) // remove // + .replace(/[ \t]*\/\*[\s\S]*?\*\//g, '' ); // remove /* */ +} - 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; -}; +function logSyntaxError() { + console.error('Wrong uniform/attributes syntax'); +} -/** - * Calculates the determinant of a mat4 - * - * @param {mat4} a the source matrix - * @returns {Number} determinant of a - */ -mat4.determinant = function (a) { - var 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], - a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], +function parseDeclarations(type, line) { + var speratorsRegexp = /[,=\(\):]/; + var tokens = line + // Convert `symbol: [1,2,3]` to `symbol: vec3(1,2,3)` + .replace(/:\s*\[\s*(.*)\s*\]/g, '=' + type + '($1)') + .replace(/\s+/g, '') + .split(/(?=[,=\(\):])/g); - b00 = a00 * a11 - a01 * a10, - b01 = a00 * a12 - a02 * a10, - b02 = a00 * a13 - a03 * a10, - b03 = a01 * a12 - a02 * a11, - b04 = a01 * a13 - a03 * a11, - b05 = a02 * a13 - a03 * a12, - b06 = a20 * a31 - a21 * a30, - b07 = a20 * a32 - a22 * a30, - b08 = a20 * a33 - a23 * a30, - b09 = a21 * a32 - a22 * a31, - b10 = a21 * a33 - a23 * a31, - b11 = a22 * a33 - a23 * a32; + var newTokens = []; + for (var i = 0; i < tokens.length; i++) { + if (tokens[i].match(speratorsRegexp)) { + newTokens.push( + tokens[i].charAt(0), + tokens[i].slice(1) + ); + } + else { + newTokens.push(tokens[i]); + } + } + tokens = newTokens; - // Calculate the determinant - return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; -}; + var TYPE_SYMBOL = 0; + var TYPE_ASSIGN = 1; + var TYPE_VEC = 2; + var TYPE_ARR = 3; + var TYPE_SEMANTIC = 4; + var TYPE_NORMAL = 5; -/** - * Multiplies two mat4's - * - * @param {mat4} out the receiving matrix - * @param {mat4} a the first operand - * @param {mat4} b the second operand - * @returns {mat4} out - */ -mat4.multiply = function (out, a, b) { - var 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], - a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + var opType = TYPE_SYMBOL; + var declarations = {}; + var declarationValue = null; + var currentDeclaration; - // 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; + addSymbol(tokens[0]); - 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; + function addSymbol(symbol) { + if (!symbol) { + logSyntaxError(); + } + var arrResult = symbol.match(/\[(.*?)\]/); + currentDeclaration = symbol.replace(/\[(.*?)\]/, ''); + declarations[currentDeclaration] = {}; + if (arrResult) { + declarations[currentDeclaration].isArray = true; + declarations[currentDeclaration].arraySize = arrResult[1]; + } + } - 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; + for (var i = 1; i < tokens.length; i++) { + var token = tokens[i]; + if (!token) { // Empty token; + continue; + } + if (token === '=') { + if (opType !== TYPE_SYMBOL + && opType !== TYPE_ARR) { + logSyntaxError(); + break; + } + opType = TYPE_ASSIGN; - 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; -}; + continue; + } + else if (token === ':') { + opType = TYPE_SEMANTIC; -/** - * Multiplies two affine mat4's - * Add by https://github.com/pissang - * @param {mat4} out the receiving matrix - * @param {mat4} a the first operand - * @param {mat4} b the second operand - * @returns {mat4} out - */ -mat4.multiplyAffine = function (out, a, b) { - var a00 = a[0], a01 = a[1], a02 = a[2], - a10 = a[4], a11 = a[5], a12 = a[6], - a20 = a[8], a21 = a[9], a22 = a[10], - a30 = a[12], a31 = a[13], a32 = a[14]; + continue; + } + else if (token === ',') { + if (opType === TYPE_VEC) { + if (!(declarationValue instanceof Array)) { + logSyntaxError(); + break; + } + declarationValue.push(+tokens[++i]); + } + else { + opType = TYPE_NORMAL; + } - // Cache only the current line of the second matrix - var b0 = b[0], b1 = b[1], b2 = b[2]; - out[0] = b0*a00 + b1*a10 + b2*a20; - out[1] = b0*a01 + b1*a11 + b2*a21; - out[2] = b0*a02 + b1*a12 + b2*a22; - // out[3] = 0; + continue; + } + else if (token === ')') { + declarations[currentDeclaration].value = new __WEBPACK_IMPORTED_MODULE_1__core_vendor__["a" /* default */].Float32Array(declarationValue); + declarationValue = null; + opType = TYPE_NORMAL; + continue; + } + else if (token === '(') { + if (opType !== TYPE_VEC) { + logSyntaxError(); + break; + } + if (!(declarationValue instanceof Array)) { + logSyntaxError(); + break; + } + declarationValue.push(+tokens[++i]); + continue; + } + else if (token.indexOf('vec') >= 0) { + if (opType !== TYPE_ASSIGN + // Compatitable with old syntax `symbol: [1,2,3]` + && opType !== TYPE_SEMANTIC) { + logSyntaxError(); + break; + } + opType = TYPE_VEC; + declarationValue = []; + continue; + } + else if (opType === TYPE_ASSIGN) { + if (type === 'bool') { + declarations[currentDeclaration].value = token === 'true'; + } + else { + declarations[currentDeclaration].value = parseFloat(token); + } + declarationValue = null; + continue; + } + else if (opType === TYPE_SEMANTIC) { + var semantic = token; + if (attributeSemantics.indexOf(semantic) >= 0 + || uniformSemantics.indexOf(semantic) >= 0 + || matrixSemantics.indexOf(semantic) >= 0 + ) { + declarations[currentDeclaration].semantic = semantic; + } + else if (semantic === 'ignore' || semantic === 'unconfigurable') { + declarations[currentDeclaration].ignore = true; + } + else { + // Try to parse as a default tvalue. + if (type === 'bool') { + declarations[currentDeclaration].value = semantic === 'true'; + } + else { + declarations[currentDeclaration].value = parseFloat(semantic); + } + } + continue; + } - b0 = b[4]; b1 = b[5]; b2 = b[6]; - out[4] = b0*a00 + b1*a10 + b2*a20; - out[5] = b0*a01 + b1*a11 + b2*a21; - out[6] = b0*a02 + b1*a12 + b2*a22; - // out[7] = 0; + // treat as symbol. + addSymbol(token); + opType = TYPE_SYMBOL; + } - b0 = b[8]; b1 = b[9]; b2 = b[10]; - out[8] = b0*a00 + b1*a10 + b2*a20; - out[9] = b0*a01 + b1*a11 + b2*a21; - out[10] = b0*a02 + b1*a12 + b2*a22; - // out[11] = 0; + return declarations; +} - b0 = b[12]; b1 = b[13]; b2 = b[14]; - out[12] = b0*a00 + b1*a10 + b2*a20 + a30; - out[13] = b0*a01 + b1*a11 + b2*a21 + a31; - out[14] = b0*a02 + b1*a12 + b2*a22 + a32; - // out[15] = 1; - return out; -}; /** - * Alias for {@link mat4.multiply} - * @function + * @constructor + * @extends clay.core.Base + * @alias clay.Shader + * @param {string} vertex + * @param {string} fragment + * @example + * // Create a phong shader + * var shader = new clay.Shader( + * clay.Shader.source('clay.standard.vertex'), + * clay.Shader.source('clay.standard.fragment') + * ); */ -mat4.mul = mat4.multiply; +function Shader(vertex, fragment) { + // First argument can be { vertex, fragment } + if (typeof vertex === 'object') { + fragment = vertex.fragment; + vertex = vertex.vertex; + } -/** - * Alias for {@link mat4.multiplyAffine} - * @function - */ -mat4.mulAffine = mat4.multiplyAffine; -/** - * 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 - */ -mat4.translate = function (out, a, v) { - var x = v[0], y = v[1], z = v[2], - a00, a01, a02, a03, - a10, a11, a12, a13, - a20, a21, a22, a23; + vertex = removeComment(vertex); + fragment = removeComment(fragment); - 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]; + this._shaderID = getShaderID(vertex, fragment); - 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; + this._vertexCode = Shader.parseImport(vertex); + this._fragmentCode = Shader.parseImport(fragment); - 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]; - } + /** + * @readOnly + */ + this.attributeSemantics = {}; + /** + * @readOnly + */ + this.matrixSemantics = {}; + /** + * @readOnly + */ + this.uniformSemantics = {}; + /** + * @readOnly + */ + this.matrixSemanticKeys = []; + /** + * @readOnly + */ + this.uniformTemplates = {}; + /** + * @readOnly + */ + this.attributes = {}; + /** + * @readOnly + */ + this.textures = {}; + /** + * @readOnly + */ + this.vertexDefines = {}; + /** + * @readOnly + */ + this.fragmentDefines = {}; - return out; -}; + this._parseAttributes(); + this._parseUniforms(); + this._parseDefines(); +} -/** - * Scales the mat4 by the dimensions in the given vec3 - * - * @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 - **/ -mat4.scale = function(out, a, v) { - var x = v[0], y = v[1], z = v[2]; +Shader.prototype = { - 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; -}; + constructor: Shader, -/** - * Rotates a mat4 by the given angle - * - * @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 - */ -mat4.rotate = function (out, a, rad, axis) { - var x = axis[0], y = axis[1], z = axis[2], - len = Math.sqrt(x * x + y * y + z * z), - s, c, t, - a00, a01, a02, a03, - a10, a11, a12, a13, - a20, a21, a22, a23, - b00, b01, b02, - b10, b11, b12, - b20, b21, b22; + // Create a new uniform instance for material + createUniforms: function () { + var uniforms = {}; - if (Math.abs(len) < GLMAT_EPSILON) { return null; } + for (var symbol in this.uniformTemplates){ + var uniformTpl = this.uniformTemplates[symbol]; + uniforms[symbol] = { + type: uniformTpl.type, + value: uniformTpl.value() + }; + } - len = 1 / len; - x *= len; - y *= len; - z *= len; + return uniforms; + }, - s = Math.sin(rad); - c = Math.cos(rad); - t = 1 - c; + _parseImport: function () { + this._vertexCode = Shader.parseImport(this.vertex); + this._fragmentCode = Shader.parseImport(this.fragment); + }, - 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]; + _addSemanticUniform: function (symbol, uniformType, semantic) { + // This case is only for SKIN_MATRIX + // TODO + if (attributeSemantics.indexOf(semantic) >= 0) { + this.attributeSemantics[semantic] = { + symbol: symbol, + type: uniformType + }; + } + else if (matrixSemantics.indexOf(semantic) >= 0) { + var isTranspose = false; + var semanticNoTranspose = semantic; + if (semantic.match(/TRANSPOSE$/)) { + isTranspose = true; + semanticNoTranspose = semantic.slice(0, -9); + } + this.matrixSemantics[semantic] = { + symbol: symbol, + type: uniformType, + isTranspose: isTranspose, + semanticNoTranspose: semanticNoTranspose + }; + } + else if (uniformSemantics.indexOf(semantic) >= 0) { + this.uniformSemantics[semantic] = { + symbol: symbol, + type: uniformType + }; + } + }, - // 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; + _addMaterialUniform: function (symbol, type, uniformType, defaultValueFunc, isArray, materialUniforms) { + materialUniforms[symbol] = { + type: uniformType, + value: isArray ? uniformValueConstructor['array'] : (defaultValueFunc || uniformValueConstructor[type]), + semantic: null + }; + }, - // 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; + _parseUniforms: function () { + var uniforms = {}; + var self = this; + var shaderType = 'vertex'; + this._uniformList = []; - 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; -}; + this._vertexCode = this._vertexCode.replace(uniformRegex, _uniformParser); + shaderType = 'fragment'; + this._fragmentCode = this._fragmentCode.replace(uniformRegex, _uniformParser); -/** - * 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 - */ -mat4.rotateX = function (out, a, rad) { - var s = Math.sin(rad), - c = Math.cos(rad), - a10 = a[4], - a11 = a[5], - a12 = a[6], - a13 = a[7], - a20 = a[8], - a21 = a[9], - a22 = a[10], - 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]; - } + self.matrixSemanticKeys = Object.keys(this.matrixSemantics); - // 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; -}; + function makeDefaultValueFunc(value) { + return value != null ? function () { return value; } : null; + } -/** - * 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 - */ -mat4.rotateY = function (out, a, rad) { - var s = Math.sin(rad), - c = Math.cos(rad), - a00 = a[0], - a01 = a[1], - a02 = a[2], - a03 = a[3], - a20 = a[8], - a21 = a[9], - a22 = a[10], - a23 = a[11]; + function _uniformParser(str, type, content) { + var declaredUniforms = parseDeclarations(type, content); + var uniformMainStr = []; + for (var symbol in declaredUniforms) { - 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]; - } + var uniformInfo = declaredUniforms[symbol]; + var semantic = uniformInfo.semantic; + var tmpStr = symbol; + var uniformType = uniformTypeMap[type]; + var defaultValueFunc = makeDefaultValueFunc(declaredUniforms[symbol].value); + if (declaredUniforms[symbol].isArray) { + tmpStr += '[' + declaredUniforms[symbol].arraySize + ']'; + uniformType += 'v'; + } - // 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; -}; + uniformMainStr.push(tmpStr); -/** - * 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 - */ -mat4.rotateZ = function (out, a, rad) { - var s = Math.sin(rad), - c = Math.cos(rad), - a00 = a[0], - a01 = a[1], - a02 = a[2], - a03 = a[3], - a10 = a[4], - a11 = a[5], - a12 = a[6], - a13 = a[7]; + self._uniformList.push(symbol); - 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]; - } + if (!uniformInfo.ignore) { + if (type === 'sampler2D' || type === 'samplerCube') { + // Texture is default disabled + self.textures[symbol] = { + shaderType: shaderType, + type: type + }; + } - // 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; -}; + if (semantic) { + // TODO Should not declare multiple symbols if have semantic. + self._addSemanticUniform(symbol, uniformType, semantic); + } + else { + self._addMaterialUniform( + symbol, type, uniformType, defaultValueFunc, + declaredUniforms[symbol].isArray, uniforms + ); + } + } + } + return uniformMainStr.length > 0 + ? 'uniform ' + type + ' ' + uniformMainStr.join(',') + ';\n' : ''; + } -/** - * 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); - * var 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 - */ -mat4.fromRotationTranslation = function (out, q, v) { - // Quaternion math - var x = q[0], y = q[1], z = q[2], w = q[3], - x2 = x + x, - y2 = y + y, - z2 = z + z, + this.uniformTemplates = uniforms; + }, - xx = x * x2, - xy = x * y2, - xz = x * z2, - yy = y * y2, - yz = y * z2, - zz = z * z2, - wx = w * x2, - wy = w * y2, - wz = w * z2; + _parseAttributes: function () { + var attributes = {}; + var self = this; + this._vertexCode = this._vertexCode.replace(attributeRegex, _attributeParser); - 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; + function _attributeParser(str, type, content) { + var declaredAttributes = parseDeclarations(type, content); - return out; -}; + var size = attributeSizeMap[type] || 1; + var attributeMainStr = []; + for (var symbol in declaredAttributes) { + var semantic = declaredAttributes[symbol].semantic; + attributes[symbol] = { + // TODO Can only be float + type: 'float', + size: size, + semantic: semantic || null + }; + // TODO Should not declare multiple symbols if have semantic. + if (semantic) { + if (attributeSemantics.indexOf(semantic) < 0) { + throw new Error('Unkown semantic "' + semantic + '"'); + } + else { + self.attributeSemantics[semantic] = { + symbol: symbol, + type: type + }; + } + } + attributeMainStr.push(symbol); + } -mat4.fromQuat = function (out, q) { - var x = q[0], y = q[1], z = q[2], w = q[3], - x2 = x + x, - y2 = y + y, - z2 = z + z, + return 'attribute ' + type + ' ' + attributeMainStr.join(',') + ';\n'; + } - xx = x * x2, - yx = y * x2, - yy = y * y2, - zx = z * x2, - zy = z * y2, - zz = z * z2, - wx = w * x2, - wy = w * y2, - wz = w * z2; + this.attributes = attributes; + }, - out[0] = 1 - yy - zz; - out[1] = yx + wz; - out[2] = zx - wy; - out[3] = 0; + _parseDefines: function () { + var self = this; + var shaderType = 'vertex'; + this._vertexCode = this._vertexCode.replace(defineRegex, _defineParser); + shaderType = 'fragment'; + this._fragmentCode = this._fragmentCode.replace(defineRegex, _defineParser); - out[4] = yx - wz; - out[5] = 1 - xx - zz; - out[6] = zy + wx; - out[7] = 0; + function _defineParser(str, symbol, value) { + var defines = shaderType === 'vertex' ? self.vertexDefines : self.fragmentDefines; + if (!defines[symbol]) { // Haven't been defined by user + if (value === 'false') { + defines[symbol] = false; + } + else if (value === 'true') { + defines[symbol] = true; + } + else { + defines[symbol] = value + // If can parse to float + ? (isNaN(parseFloat(value)) ? value.trim() : parseFloat(value)) + : null; + } + } + return ''; + } + }, - out[8] = zx + wy; - out[9] = zy - wx; - out[10] = 1 - xx - yy; - out[11] = 0; + /** + * Clone a new shader + * @return {clay.Shader} + */ + clone: function () { + var code = shaderCodeCache[this._shaderID]; + var shader = new Shader(code.vertex, code.fragment); + return shader; + } +}; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; +if (Object.defineProperty) { + Object.defineProperty(Shader.prototype, 'shaderID', { + get: function () { + return this._shaderID; + } + }); + Object.defineProperty(Shader.prototype, 'vertex', { + get: function () { + return this._vertexCode; + } + }); + Object.defineProperty(Shader.prototype, 'fragment', { + get: function () { + return this._fragmentCode; + } + }); + Object.defineProperty(Shader.prototype, 'uniforms', { + get: function () { + return this._uniformList; + } + }); +} - return out; +var importRegex = /(@import)\s*([0-9a-zA-Z_\-\.]*)/g; +Shader.parseImport = function (shaderStr) { + shaderStr = shaderStr.replace(importRegex, function (str, importSymbol, importName) { + var str = Shader.source(importName); + if (str) { + // Recursively parse + return Shader.parseImport(str); + } + else { + console.error('Shader chunk "' + importName + '" not existed in library'); + return ''; + } + }); + return shaderStr; }; -/** - * 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 - */ -mat4.frustum = function (out, left, right, bottom, top, near, far) { - var rl = 1 / (right - left), - tb = 1 / (top - bottom), - 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; -}; +var exportRegex = /(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g; /** - * Generates a perspective projection matrix with the given bounds - * - * @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 - * @returns {mat4} out + * Import shader source + * @param {string} shaderStr + * @memberOf clay.Shader */ -mat4.perspective = function (out, fovy, aspect, near, far) { - var f = 1.0 / Math.tan(fovy / 2), - nf = 1 / (near - far); - 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[10] = (far + near) * nf; - out[11] = -1; - out[12] = 0; - out[13] = 0; - out[14] = (2 * far * near) * nf; - out[15] = 0; - return out; +Shader['import'] = function (shaderStr) { + shaderStr.replace(exportRegex, function (str, exportSymbol, exportName, code) { + var code = code.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g, ''); + if (code) { + var parts = exportName.split('.'); + var obj = Shader.codes; + var i = 0; + var key; + while (i < parts.length - 1) { + key = parts[i++]; + if (!obj[key]) { + obj[key] = {}; + } + obj = obj[key]; + } + key = parts[i]; + obj[key] = code; + } + return code; + }); }; /** - * 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 + * Library to store all the loaded shader codes + * @type {Object} + * @readOnly + * @memberOf clay.Shader */ -mat4.ortho = function (out, left, right, bottom, top, near, far) { - var lr = 1 / (left - right), - bt = 1 / (bottom - top), - 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; -}; +Shader.codes = {}; /** - * Generates a look-at matrix with the given eye position, focal point, and up axis - * - * @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 + * Get shader source + * @param {string} name + * @return {string} */ -mat4.lookAt = function (out, eye, center, up) { - var x0, x1, x2, y0, y1, y2, z0, z1, z2, len, - eyex = eye[0], - eyey = eye[1], - eyez = eye[2], - upx = up[0], - upy = up[1], - upz = up[2], - centerx = center[0], - centery = center[1], - centerz = center[2]; - - if (Math.abs(eyex - centerx) < GLMAT_EPSILON && - Math.abs(eyey - centery) < GLMAT_EPSILON && - Math.abs(eyez - centerz) < GLMAT_EPSILON) { - return mat4.identity(out); +Shader.source = function (name) { + var parts = name.split('.'); + var obj = Shader.codes; + var i = 0; + while (obj && i < parts.length) { + var key = parts[i++]; + obj = obj[key]; } + if (typeof obj !== 'string') { + // FIXME Use default instead + console.error('Shader "' + name + '" not existed in library'); + return ''; + } + return obj; +}; - z0 = eyex - centerx; - z1 = eyey - centery; - z2 = eyez - centerz; +/* harmony default export */ __webpack_exports__["a"] = (Shader); - 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; -}; - -/** - * Returns a string representation of a mat4 - * - * @param {mat4} mat matrix to represent as a string - * @returns {String} string representation of the matrix - */ -mat4.str = function (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] + ')'; -}; +/***/ }), +/* 9 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -/** - * Returns Frobenius norm of a mat4 - * - * @param {mat4} a the matrix to calculate Frobenius norm of - * @returns {Number} Frobenius norm - */ -mat4.frob = function (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) )) -}; +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__glmatrix_quat__ = __webpack_require__(55); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__glmatrix_mat3__ = __webpack_require__(34); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Vector3__ = __webpack_require__(3); -if(typeof(exports) !== 'undefined') { - exports.mat4 = mat4; -} -; -/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. 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 HOLDER 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 USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** - * @class Quaternion - * @name quat + * @constructor + * @alias clay.Matrix4 */ +var Matrix4 = function() { -var quat = {}; + this._axisX = new __WEBPACK_IMPORTED_MODULE_4__Vector3__["a" /* default */](); + this._axisY = new __WEBPACK_IMPORTED_MODULE_4__Vector3__["a" /* default */](); + this._axisZ = new __WEBPACK_IMPORTED_MODULE_4__Vector3__["a" /* default */](); -/** - * Creates a new identity quat - * - * @returns {quat} a new quaternion - */ -quat.create = function() { - var out = new GLMAT_ARRAY_TYPE(4); - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - return out; + /** + * Storage of Matrix4 + * @name array + * @type {Float32Array} + * @memberOf clay.Matrix4# + */ + this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].create(); + + /** + * @name _dirty + * @type {boolean} + * @memberOf clay.Matrix4# + */ + this._dirty = true; }; -/** - * 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 - */ -quat.rotationTo = (function() { - var tmpvec3 = vec3.create(); - var xUnitVec3 = vec3.fromValues(1,0,0); - var yUnitVec3 = vec3.fromValues(0,1,0); +Matrix4.prototype = { - return function(out, a, b) { - var dot = vec3.dot(a, b); - if (dot < -0.999999) { - vec3.cross(tmpvec3, xUnitVec3, a); - if (vec3.length(tmpvec3) < 0.000001) - vec3.cross(tmpvec3, yUnitVec3, a); - vec3.normalize(tmpvec3, tmpvec3); - quat.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.cross(tmpvec3, a, b); - out[0] = tmpvec3[0]; - out[1] = tmpvec3[1]; - out[2] = tmpvec3[2]; - out[3] = 1 + dot; - return quat.normalize(out, out); + constructor: Matrix4, + + /** + * Set components from array + * @param {Float32Array|number[]} arr + */ + setArray: function (arr) { + for (var i = 0; i < this.array.length; i++) { + this.array[i] = arr[i]; } - }; -})(); + this._dirty = true; + return this; + }, + /** + * Calculate the adjugate of self, in-place + * @return {clay.Matrix4} + */ + adjoint: function() { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].adjoint(this.array, this.array); + this._dirty = true; + return this; + }, -/** - * 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 - */ -quat.setAxes = (function() { - var matr = mat3.create(); + /** + * Clone a new Matrix4 + * @return {clay.Matrix4} + */ + clone: function() { + return (new Matrix4()).copy(this); + }, - return function(out, view, right, up) { - matr[0] = right[0]; - matr[3] = right[1]; - matr[6] = right[2]; + /** + * Copy from b + * @param {clay.Matrix4} b + * @return {clay.Matrix4} + */ + copy: function(a) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].copy(this.array, a.array); + this._dirty = true; + return this; + }, - matr[1] = up[0]; - matr[4] = up[1]; - matr[7] = up[2]; + /** + * Calculate matrix determinant + * @return {number} + */ + determinant: function() { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].determinant(this.array); + }, - matr[2] = -view[0]; - matr[5] = -view[1]; - matr[8] = -view[2]; + /** + * Set upper 3x3 part from quaternion + * @param {clay.Quaternion} q + * @return {clay.Matrix4} + */ + fromQuat: function(q) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].fromQuat(this.array, q.array); + this._dirty = true; + return this; + }, - return quat.normalize(out, quat.fromMat3(out, matr)); - }; -})(); + /** + * Set from a quaternion rotation and a vector translation + * @param {clay.Quaternion} q + * @param {clay.Vector3} v + * @return {clay.Matrix4} + */ + fromRotationTranslation: function(q, v) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].fromRotationTranslation(this.array, q.array, v.array); + this._dirty = true; + return this; + }, -/** - * Creates a new quat initialized with values from an existing quaternion - * - * @param {quat} a quaternion to clone - * @returns {quat} a new quaternion - * @function - */ -quat.clone = vec4.clone; + /** + * Set from Matrix2d, it is used when converting a 2d shape to 3d space. + * In 3d space it is equivalent to ranslate on xy plane and rotate about z axis + * @param {clay.Matrix2d} m2d + * @return {clay.Matrix4} + */ + fromMat2d: function(m2d) { + Matrix4.fromMat2d(this, m2d); + return this; + }, -/** - * 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 - */ -quat.fromValues = vec4.fromValues; + /** + * Set from frustum bounds + * @param {number} left + * @param {number} right + * @param {number} bottom + * @param {number} top + * @param {number} near + * @param {number} far + * @return {clay.Matrix4} + */ + frustum: function (left, right, bottom, top, near, far) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].frustum(this.array, left, right, bottom, top, near, far); + this._dirty = true; + return this; + }, -/** - * Copy the values from one quat to another - * - * @param {quat} out the receiving quaternion - * @param {quat} a the source quaternion - * @returns {quat} out - * @function - */ -quat.copy = vec4.copy; + /** + * Set to a identity matrix + * @return {clay.Matrix4} + */ + identity: function() { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].identity(this.array); + this._dirty = true; + return this; + }, -/** - * 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 - */ -quat.set = vec4.set; + /** + * Invert self + * @return {clay.Matrix4} + */ + invert: function() { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].invert(this.array, this.array); + this._dirty = true; + return this; + }, -/** - * Set a quat to the identity quaternion - * - * @param {quat} out the receiving quaternion - * @returns {quat} out - */ -quat.identity = function(out) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - return out; -}; + /** + * Set as a matrix with the given eye position, focal point, and up axis + * @param {clay.Vector3} eye + * @param {clay.Vector3} center + * @param {clay.Vector3} up + * @return {clay.Matrix4} + */ + lookAt: function(eye, center, up) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].lookAt(this.array, eye.array, center.array, up.array); + this._dirty = true; + return this; + }, -/** - * 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 - **/ -quat.setAxisAngle = function(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; -}; + /** + * Alias for mutiply + * @param {clay.Matrix4} b + * @return {clay.Matrix4} + */ + mul: function(b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].mul(this.array, this.array, b.array); + this._dirty = true; + return this; + }, -/** - * 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 - */ -quat.add = vec4.add; + /** + * Alias for multiplyLeft + * @param {clay.Matrix4} a + * @return {clay.Matrix4} + */ + mulLeft: function(a) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].mul(this.array, a.array, this.array); + this._dirty = true; + return this; + }, -/** - * 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 - */ -quat.multiply = function(out, a, b) { - var ax = a[0], ay = a[1], az = a[2], aw = a[3], - bx = b[0], by = b[1], bz = b[2], bw = b[3]; + /** + * Multiply self and b + * @param {clay.Matrix4} b + * @return {clay.Matrix4} + */ + multiply: function(b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].multiply(this.array, this.array, b.array); + this._dirty = true; + return this; + }, - 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; -}; + /** + * Multiply a and self, a is on the left + * @param {clay.Matrix3} a + * @return {clay.Matrix3} + */ + multiplyLeft: function(a) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].multiply(this.array, a.array, this.array); + this._dirty = true; + return this; + }, -/** - * Alias for {@link quat.multiply} - * @function - */ -quat.mul = quat.multiply; + /** + * Set as a orthographic projection matrix + * @param {number} left + * @param {number} right + * @param {number} bottom + * @param {number} top + * @param {number} near + * @param {number} far + * @return {clay.Matrix4} + */ + ortho: function(left, right, bottom, top, near, far) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].ortho(this.array, left, right, bottom, top, near, far); + this._dirty = true; + return this; + }, + /** + * Set as a perspective projection matrix + * @param {number} fovy + * @param {number} aspect + * @param {number} near + * @param {number} far + * @return {clay.Matrix4} + */ + perspective: function(fovy, aspect, near, far) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].perspective(this.array, fovy, aspect, near, far); + this._dirty = true; + return this; + }, -/** - * 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 - */ -quat.scale = vec4.scale; + /** + * Rotate self by rad about axis. + * Equal to right-multiply a rotaion matrix + * @param {number} rad + * @param {clay.Vector3} axis + * @return {clay.Matrix4} + */ + rotate: function(rad, axis) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotate(this.array, this.array, rad, axis.array); + this._dirty = true; + return this; + }, -/** - * 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 - */ -quat.rotateX = function (out, a, rad) { - rad *= 0.5; + /** + * Rotate self by a given radian about X axis. + * Equal to right-multiply a rotaion matrix + * @param {number} rad + * @return {clay.Matrix4} + */ + rotateX: function(rad) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotateX(this.array, this.array, rad); + this._dirty = true; + return this; + }, - var ax = a[0], ay = a[1], az = a[2], aw = a[3], - bx = Math.sin(rad), bw = Math.cos(rad); + /** + * Rotate self by a given radian about Y axis. + * Equal to right-multiply a rotaion matrix + * @param {number} rad + * @return {clay.Matrix4} + */ + rotateY: function(rad) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotateY(this.array, this.array, rad); + this._dirty = true; + return this; + }, - 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; -}; + /** + * Rotate self by a given radian about Z axis. + * Equal to right-multiply a rotaion matrix + * @param {number} rad + * @return {clay.Matrix4} + */ + rotateZ: function(rad) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotateZ(this.array, this.array, rad); + this._dirty = true; + return this; + }, -/** - * 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 - */ -quat.rotateY = function (out, a, rad) { - rad *= 0.5; + /** + * Scale self by s + * Equal to right-multiply a scale matrix + * @param {clay.Vector3} s + * @return {clay.Matrix4} + */ + scale: function(v) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].scale(this.array, this.array, v.array); + this._dirty = true; + return this; + }, - var ax = a[0], ay = a[1], az = a[2], aw = a[3], - by = Math.sin(rad), bw = Math.cos(rad); + /** + * Translate self by v. + * Equal to right-multiply a translate matrix + * @param {clay.Vector3} v + * @return {clay.Matrix4} + */ + translate: function(v) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].translate(this.array, this.array, v.array); + this._dirty = true; + return this; + }, - 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; + /** + * Transpose self, in-place. + * @return {clay.Matrix2} + */ + transpose: function() { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].transpose(this.array, this.array); + this._dirty = true; + return this; + }, + + /** + * Decompose a matrix to SRT + * @param {clay.Vector3} [scale] + * @param {clay.Quaternion} rotation + * @param {clay.Vector} position + * @see http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.matrix.decompose.aspx + */ + decomposeMatrix: (function() { + + var x = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); + var y = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); + var z = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); + + var m3 = __WEBPACK_IMPORTED_MODULE_3__glmatrix_mat3__["a" /* default */].create(); + + return function(scale, rotation, position) { + + var el = this.array; + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set(x, el[0], el[1], el[2]); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set(y, el[4], el[5], el[6]); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set(z, el[8], el[9], el[10]); + + var sx = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].length(x); + var sy = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].length(y); + var sz = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].length(z); + + // if determine is negative, we need to invert one scale + var det = this.determinant(); + if (det < 0) { + sx = -sx; + } + + if (scale) { + scale.set(sx, sy, sz); + } + + position.set(el[12], el[13], el[14]); + + __WEBPACK_IMPORTED_MODULE_3__glmatrix_mat3__["a" /* default */].fromMat4(m3, el); + // Not like mat4, mat3 in glmatrix seems to be row-based + // Seems fixed in gl-matrix 2.2.2 + // https://github.com/toji/gl-matrix/issues/114 + // mat3.transpose(m3, m3); + + m3[0] /= sx; + m3[1] /= sx; + m3[2] /= sx; + + m3[3] /= sy; + m3[4] /= sy; + m3[5] /= sy; + + m3[6] /= sz; + m3[7] /= sz; + m3[8] /= sz; + + __WEBPACK_IMPORTED_MODULE_2__glmatrix_quat__["a" /* default */].fromMat3(rotation.array, m3); + __WEBPACK_IMPORTED_MODULE_2__glmatrix_quat__["a" /* default */].normalize(rotation.array, rotation.array); + + rotation._dirty = true; + position._dirty = true; + }; + })(), + + toString: function() { + return '[' + Array.prototype.join.call(this.array, ',') + ']'; + }, + + toArray: function () { + return Array.prototype.slice.call(this.array); + } }; -/** - * 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 - */ -quat.rotateZ = function (out, a, rad) { - rad *= 0.5; +var defineProperty = Object.defineProperty; - var ax = a[0], ay = a[1], az = a[2], aw = a[3], - bz = Math.sin(rad), bw = Math.cos(rad); +if (defineProperty) { + var proto = Matrix4.prototype; + /** + * Z Axis of local transform + * @name z + * @type {clay.Vector3} + * @memberOf clay.Matrix4 + * @instance + */ + defineProperty(proto, 'z', { + get: function () { + var el = this.array; + this._axisZ.set(el[8], el[9], el[10]); + return this._axisZ; + }, + set: function (v) { + // TODO Here has a problem + // If only set an item of vector will not work + var el = this.array; + v = v.array; + el[8] = v[0]; + el[9] = v[1]; + el[10] = v[2]; - out[0] = ax * bw + ay * bz; - out[1] = ay * bw - ax * bz; - out[2] = az * bw + aw * bz; - out[3] = aw * bw - az * bz; + this._dirty = true; + } + }); + + /** + * Y Axis of local transform + * @name y + * @type {clay.Vector3} + * @memberOf clay.Matrix4 + * @instance + */ + defineProperty(proto, 'y', { + get: function () { + var el = this.array; + this._axisY.set(el[4], el[5], el[6]); + return this._axisY; + }, + set: function (v) { + var el = this.array; + v = v.array; + el[4] = v[0]; + el[5] = v[1]; + el[6] = v[2]; + + this._dirty = true; + } + }); + + /** + * X Axis of local transform + * @name x + * @type {clay.Vector3} + * @memberOf clay.Matrix4 + * @instance + */ + defineProperty(proto, 'x', { + get: function () { + var el = this.array; + this._axisX.set(el[0], el[1], el[2]); + return this._axisX; + }, + set: function (v) { + var el = this.array; + v = v.array; + el[0] = v[0]; + el[1] = v[1]; + el[2] = v[2]; + + this._dirty = true; + } + }) +} + +/** + * @param {clay.Matrix4} out + * @param {clay.Matrix4} a + * @return {clay.Matrix4} + */ +Matrix4.adjoint = function(out, a) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].adjoint(out.array, a.array); + out._dirty = true; 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 + * @param {clay.Matrix4} out + * @param {clay.Matrix4} a + * @return {clay.Matrix4} */ -quat.calculateW = function (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)); +Matrix4.copy = function(out, a) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].copy(out.array, a.array); + out._dirty = true; return out; }; /** - * 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 + * @param {clay.Matrix4} a + * @return {number} */ -quat.dot = vec4.dot; +Matrix4.determinant = function(a) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].determinant(a.array); +}; /** - * 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 between the two inputs - * @returns {quat} out - * @function + * @param {clay.Matrix4} out + * @return {clay.Matrix4} */ -quat.lerp = vec4.lerp; +Matrix4.identity = function(out) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].identity(out.array); + out._dirty = true; + 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 between the two inputs - * @returns {quat} out + * @param {clay.Matrix4} out + * @param {number} left + * @param {number} right + * @param {number} bottom + * @param {number} top + * @param {number} near + * @param {number} far + * @return {clay.Matrix4} */ -quat.slerp = function (out, a, b, t) { - // benchmarks: - // http://jsperf.com/quaternion-slerp-implementations - - var ax = a[0], ay = a[1], az = a[2], aw = a[3], - bx = b[0], by = b[1], bz = b[2], bw = b[3]; - - var omega, cosom, sinom, scale0, scale1; - - // 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) > 0.000001 ) { - // 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; - +Matrix4.ortho = function(out, left, right, bottom, top, near, far) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].ortho(out.array, left, right, bottom, top, near, far); + out._dirty = true; 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 + * @param {clay.Matrix4} out + * @param {number} fovy + * @param {number} aspect + * @param {number} near + * @param {number} far + * @return {clay.Matrix4} */ -quat.invert = function(out, a) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], - dot = a0*a0 + a1*a1 + a2*a2 + a3*a3, - 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; +Matrix4.perspective = function(out, fovy, aspect, near, far) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].perspective(out.array, fovy, aspect, near, far); + out._dirty = true; 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 + * @param {clay.Matrix4} out + * @param {clay.Vector3} eye + * @param {clay.Vector3} center + * @param {clay.Vector3} up + * @return {clay.Matrix4} */ -quat.conjugate = function (out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - out[2] = -a[2]; - out[3] = a[3]; +Matrix4.lookAt = function(out, eye, center, up) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].lookAt(out.array, eye.array, center.array, up.array); + out._dirty = true; return out; }; /** - * Calculates the length of a quat - * - * @param {quat} a vector to calculate length of - * @returns {Number} length of a - * @function + * @param {clay.Matrix4} out + * @param {clay.Matrix4} a + * @return {clay.Matrix4} */ -quat.length = vec4.length; +Matrix4.invert = function(out, a) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].invert(out.array, a.array); + out._dirty = true; + return out; +}; /** - * Alias for {@link quat.length} - * @function + * @param {clay.Matrix4} out + * @param {clay.Matrix4} a + * @param {clay.Matrix4} b + * @return {clay.Matrix4} */ -quat.len = quat.length; +Matrix4.mul = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].mul(out.array, a.array, b.array); + out._dirty = true; + return out; +}; /** - * Calculates the squared length of a quat - * - * @param {quat} a vector to calculate squared length of - * @returns {Number} squared length of a * @function + * @param {clay.Matrix4} out + * @param {clay.Matrix4} a + * @param {clay.Matrix4} b + * @return {clay.Matrix4} */ -quat.squaredLength = vec4.squaredLength; +Matrix4.multiply = Matrix4.mul; /** - * Alias for {@link quat.squaredLength} - * @function + * @param {clay.Matrix4} out + * @param {clay.Quaternion} q + * @return {clay.Matrix4} */ -quat.sqrLen = quat.squaredLength; +Matrix4.fromQuat = function(out, q) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].fromQuat(out.array, q.array); + out._dirty = true; + return out; +}; /** - * Normalize a quat - * - * @param {quat} out the receiving quaternion - * @param {quat} a quaternion to normalize - * @returns {quat} out - * @function + * @param {clay.Matrix4} out + * @param {clay.Quaternion} q + * @param {clay.Vector3} v + * @return {clay.Matrix4} */ -quat.normalize = vec4.normalize; +Matrix4.fromRotationTranslation = function(out, q, v) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].fromRotationTranslation(out.array, q.array, v.array); + out._dirty = true; + 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 + * @param {clay.Matrix4} m4 + * @param {clay.Matrix2d} m2d + * @return {clay.Matrix4} */ -quat.fromMat3 = function(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; +Matrix4.fromMat2d = function(m4, m2d) { + m4._dirty = true; + var m2d = m2d.array; + var m4 = m4.array; - 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; + m4[0] = m2d[0]; + m4[4] = m2d[2]; + m4[12] = m2d[4]; - 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; - } + m4[1] = m2d[1]; + m4[5] = m2d[3]; + m4[13] = m2d[5]; - return out; + return m4; }; /** - * Returns a string representation of a quatenion - * - * @param {quat} vec vector to represent as a string - * @returns {String} string representation of the vector + * @param {clay.Matrix4} out + * @param {clay.Matrix4} a + * @param {number} rad + * @param {clay.Vector3} axis + * @return {clay.Matrix4} */ -quat.str = function (a) { - return 'quat(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')'; +Matrix4.rotate = function(out, a, rad, axis) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotate(out.array, a.array, rad, axis.array); + out._dirty = true; + return out; }; -if(typeof(exports) !== 'undefined') { - exports.quat = quat; -} -; - - - - - - +/** + * @param {clay.Matrix4} out + * @param {clay.Matrix4} a + * @param {number} rad + * @return {clay.Matrix4} + */ +Matrix4.rotateX = function(out, a, rad) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotateX(out.array, a.array, rad); + out._dirty = true; + return out; +}; +/** + * @param {clay.Matrix4} out + * @param {clay.Matrix4} a + * @param {number} rad + * @return {clay.Matrix4} + */ +Matrix4.rotateY = function(out, a, rad) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotateY(out.array, a.array, rad); + out._dirty = true; + return out; +}; +/** + * @param {clay.Matrix4} out + * @param {clay.Matrix4} a + * @param {number} rad + * @return {clay.Matrix4} + */ +Matrix4.rotateZ = function(out, a, rad) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotateZ(out.array, a.array, rad); + out._dirty = true; + return out; +}; +/** + * @param {clay.Matrix4} out + * @param {clay.Matrix4} a + * @param {clay.Vector3} v + * @return {clay.Matrix4} + */ +Matrix4.scale = function(out, a, v) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].scale(out.array, a.array, v.array); + out._dirty = true; + return out; +}; +/** + * @param {clay.Matrix4} out + * @param {clay.Matrix4} a + * @return {clay.Matrix4} + */ +Matrix4.transpose = function(out, a) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].transpose(out.array, a.array); + out._dirty = true; + return out; +}; +/** + * @param {clay.Matrix4} out + * @param {clay.Matrix4} a + * @param {clay.Vector3} v + * @return {clay.Matrix4} + */ +Matrix4.translate = function(out, a, v) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].translate(out.array, a.array, v.array); + out._dirty = true; + return out; +}; +/* harmony default export */ __webpack_exports__["a"] = (Matrix4); - })(shim.exports); -})(this); -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(63))) /***/ }), -/* 2 */ +/* 10 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Mesh__ = __webpack_require__(31); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Renderer__ = __webpack_require__(46); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_Material__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_Node__ = __webpack_require__(30); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_claygl_src_Geometry__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__ = __webpack_require__(32); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_zrender_lib_core_LRU__ = __webpack_require__(53); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_zrender_lib_core_LRU___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_10_zrender_lib_core_LRU__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_claygl_src_util_texture__ = __webpack_require__(54); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__EChartsSurface__ = __webpack_require__(116); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13_claygl_src_light_AmbientCubemap__ = __webpack_require__(117); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14_claygl_src_light_AmbientSH__ = __webpack_require__(122); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15_claygl_src_util_sh__ = __webpack_require__(123); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__retrieve__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17_claygl_src_geometry_Sphere__ = __webpack_require__(69); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18_claygl_src_geometry_Plane__ = __webpack_require__(37); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19_claygl_src_geometry_Cube__ = __webpack_require__(71); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20_claygl_src_light_Ambient__ = __webpack_require__(125); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21_claygl_src_light_Directional__ = __webpack_require__(126); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22_claygl_src_light_Point__ = __webpack_require__(127); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23_claygl_src_light_Spot__ = __webpack_require__(128); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24_claygl_src_camera_Perspective__ = __webpack_require__(36); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25_claygl_src_camera_Orthographic__ = __webpack_require__(33); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26_claygl_src_math_Vector2__ = __webpack_require__(23); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27_claygl_src_math_Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_28_claygl_src_math_Vector4__ = __webpack_require__(129); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_29_claygl_src_math_Quaternion__ = __webpack_require__(50); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_30_claygl_src_math_Matrix2__ = __webpack_require__(130); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_31_claygl_src_math_Matrix2d__ = __webpack_require__(131); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_32_claygl_src_math_Matrix3__ = __webpack_require__(132); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_33_claygl_src_math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_34_claygl_src_math_Plane__ = __webpack_require__(68); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_35_claygl_src_math_Ray__ = __webpack_require__(49); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_36_claygl_src_math_BoundingBox__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_37_claygl_src_math_Frustum__ = __webpack_require__(52); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_38__animatableMixin__ = __webpack_require__(133); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_39_claygl_src_shader_source_util_glsl_js__ = __webpack_require__(138); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_40_claygl_src_shader_source_prez_glsl_js__ = __webpack_require__(65); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_41__shader_common_glsl_js__ = __webpack_require__(139); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_42__shader_color_glsl_js__ = __webpack_require__(140); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_43__shader_lambert_glsl_js__ = __webpack_require__(141); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_44__shader_realistic_glsl_js__ = __webpack_require__(142); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_45__shader_hatching_glsl_js__ = __webpack_require__(143); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_46__shader_shadow_glsl_js__ = __webpack_require__(144); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Texture__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__TextureCube__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_glenum__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_Cache__ = __webpack_require__(57); +var KEY_FRAMEBUFFER = 'framebuffer'; +var KEY_RENDERBUFFER = 'renderbuffer'; +var KEY_RENDERBUFFER_WIDTH = KEY_RENDERBUFFER + '_width'; +var KEY_RENDERBUFFER_HEIGHT = KEY_RENDERBUFFER + '_height'; +var KEY_RENDERBUFFER_ATTACHED = KEY_RENDERBUFFER + '_attached'; +var KEY_DEPTHTEXTURE_ATTACHED = 'depthtexture_attached'; +var GL_FRAMEBUFFER = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].FRAMEBUFFER; +var GL_RENDERBUFFER = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].RENDERBUFFER; +var GL_DEPTH_ATTACHMENT = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_ATTACHMENT; +var GL_COLOR_ATTACHMENT0 = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].COLOR_ATTACHMENT0; +/** + * @constructor clay.FrameBuffer + * @extends clay.core.Base + */ +var FrameBuffer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend( +/** @lends clay.FrameBuffer# */ +{ + /** + * If use depth buffer + * @type {boolean} + */ + depthBuffer: true, + /** + * @type {Object} + */ + viewport: null, + _width: 0, + _height: 0, + _textures: null, + _boundRenderer: null, +}, function () { + // Use cache + this._cache = new __WEBPACK_IMPORTED_MODULE_4__core_Cache__["a" /* default */](); + this._textures = {}; +}, +/**@lends clay.FrameBuffer.prototype. */ +{ + /** + * Get attached texture width + * {number} + */ + // FIXME Can't use before #bind + getTextureWidth: function () { + return this._width; + }, + /** + * Get attached texture height + * {number} + */ + getTextureHeight: function () { + return this._height; + }, + /** + * Bind the framebuffer to given renderer before rendering + * @param {clay.Renderer} renderer + */ + bind: function (renderer) { + if (renderer.__currentFrameBuffer) { + // Already bound + if (renderer.__currentFrameBuffer === this) { + return; + } + console.warn('Renderer already bound with another framebuffer. Unbind it first'); + } + renderer.__currentFrameBuffer = this; + var _gl = renderer.gl; + _gl.bindFramebuffer(GL_FRAMEBUFFER, this._getFrameBufferGL(renderer)); + this._boundRenderer = renderer; + var cache = this._cache; + cache.put('viewport', renderer.viewport); + var hasTextureAttached = false; + var width; + var height; + for (var attachment in this._textures) { + hasTextureAttached = true; + var obj = this._textures[attachment]; + if (obj) { + // TODO Do width, height checking, make sure size are same + width = obj.texture.width; + height = obj.texture.height; + // Attach textures + this._doAttach(renderer, obj.texture, attachment, obj.target); + } + } + this._width = width; + this._height = height; + if (!hasTextureAttached && this.depthBuffer) { + console.error('Must attach texture before bind, or renderbuffer may have incorrect width and height.') + } + if (this.viewport) { + renderer.setViewport(this.viewport); + } + else { + renderer.setViewport(0, 0, width, height, 1); + } + var attachedTextures = cache.get('attached_textures'); + if (attachedTextures) { + for (var attachment in attachedTextures) { + if (!this._textures[attachment]) { + var target = attachedTextures[attachment]; + this._doDetach(_gl, attachment, target); + } + } + } + if (!cache.get(KEY_DEPTHTEXTURE_ATTACHED) && this.depthBuffer) { + // Create a new render buffer + if (cache.miss(KEY_RENDERBUFFER)) { + cache.put(KEY_RENDERBUFFER, _gl.createRenderbuffer()); + } + var renderbuffer = cache.get(KEY_RENDERBUFFER); + if (width !== cache.get(KEY_RENDERBUFFER_WIDTH) + || height !== cache.get(KEY_RENDERBUFFER_HEIGHT)) { + _gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer); + _gl.renderbufferStorage(GL_RENDERBUFFER, _gl.DEPTH_COMPONENT16, width, height); + cache.put(KEY_RENDERBUFFER_WIDTH, width); + cache.put(KEY_RENDERBUFFER_HEIGHT, height); + _gl.bindRenderbuffer(GL_RENDERBUFFER, null); + } + if (!cache.get(KEY_RENDERBUFFER_ATTACHED)) { + _gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbuffer); + cache.put(KEY_RENDERBUFFER_ATTACHED, true); + } + } + }, + /** + * Unbind the frame buffer after rendering + * @param {clay.Renderer} renderer + */ + unbind: function (renderer) { + // Remove status record on renderer + renderer.__currentFrameBuffer = null; + var _gl = renderer.gl; + _gl.bindFramebuffer(GL_FRAMEBUFFER, null); + this._boundRenderer = null; -// Math + this._cache.use(renderer.__uid__); + var viewport = this._cache.get('viewport'); + // Reset viewport; + if (viewport) { + renderer.setViewport(viewport); + } + this.updateMipmap(renderer); + }, + // Because the data of texture is changed over time, + // Here update the mipmaps of texture each time after rendered; + updateMipmap: function (renderer) { + var _gl = renderer.gl; + for (var attachment in this._textures) { + var obj = this._textures[attachment]; + if (obj) { + var texture = obj.texture; + // FIXME some texture format can't generate mipmap + if (!texture.NPOT && texture.useMipmap + && texture.minFilter === __WEBPACK_IMPORTED_MODULE_1__Texture__["a" /* default */].LINEAR_MIPMAP_LINEAR) { + var target = texture.textureType === 'textureCube' ? __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].TEXTURE_CUBE_MAP : __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].TEXTURE_2D; + _gl.bindTexture(target, texture.getWebGLTexture(renderer)); + _gl.generateMipmap(target); + _gl.bindTexture(target, null); + } + } + } + }, + // 0x8CD5, 36053, FRAMEBUFFER_COMPLETE + // 0x8CD6, 36054, FRAMEBUFFER_INCOMPLETE_ATTACHMENT + // 0x8CD7, 36055, FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT + // 0x8CD9, 36057, FRAMEBUFFER_INCOMPLETE_DIMENSIONS + // 0x8CDD, 36061, FRAMEBUFFER_UNSUPPORTED + checkStatus: function (_gl) { + return _gl.checkFramebufferStatus(GL_FRAMEBUFFER); + }, + _getFrameBufferGL: function (renderer) { + var cache = this._cache; + cache.use(renderer.__uid__); + if (cache.miss(KEY_FRAMEBUFFER)) { + cache.put(KEY_FRAMEBUFFER, renderer.gl.createFramebuffer()); + } + return cache.get(KEY_FRAMEBUFFER); + }, + /** + * Attach a texture(RTT) to the framebuffer + * @param {clay.Texture} texture + * @param {number} [attachment=gl.COLOR_ATTACHMENT0] + * @param {number} [target=gl.TEXTURE_2D] + */ + attach: function (texture, attachment, target) { + if (!texture.width) { + throw new Error('The texture attached to color buffer is not a valid.'); + } + // TODO width and height check + // If the depth_texture extension is enabled, developers + // Can attach a depth texture to the depth buffer + // http://blog.tojicode.com/2012/07/using-webgldepthtexture.html + attachment = attachment || GL_COLOR_ATTACHMENT0; + target = target || __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].TEXTURE_2D; + var boundRenderer = this._boundRenderer; + var _gl = boundRenderer && boundRenderer.gl; + var attachedTextures; + if (_gl) { + var cache = this._cache; + cache.use(boundRenderer.__uid__); + attachedTextures = cache.get('attached_textures'); + } + // Check if texture attached + var previous = this._textures[attachment]; + if (previous && previous.target === target + && previous.texture === texture + && (attachedTextures && attachedTextures[attachment] != null) + ) { + return; + } + var canAttach = true; + if (boundRenderer) { + canAttach = this._doAttach(boundRenderer, texture, attachment, target); + // Set viewport again incase attached to different size textures. + if (!this.viewport) { + boundRenderer.setViewport(0, 0, texture.width, texture.height, 1); + } + } + if (canAttach) { + this._textures[attachment] = this._textures[attachment] || {}; + this._textures[attachment].texture = texture; + this._textures[attachment].target = target; + } + }, + _doAttach: function (renderer, texture, attachment, target) { + var _gl = renderer.gl; + // Make sure texture is always updated + // Because texture width or height may be changed and in this we can't be notified + // FIXME awkward; + var webglTexture = texture.getWebGLTexture(renderer); + // Assume cache has been used. + var attachedTextures = this._cache.get('attached_textures'); + if (attachedTextures && attachedTextures[attachment]) { + var obj = attachedTextures[attachment]; + // Check if texture and target not changed + if (obj.texture === texture && obj.target === target) { + return; + } + } + attachment = +attachment; -// Some common shaders + var canAttach = true; + if (attachment === GL_DEPTH_ATTACHMENT || attachment === __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_STENCIL_ATTACHMENT) { + var extension = renderer.getGLExtension('WEBGL_depth_texture'); + if (!extension) { + console.error('Depth texture is not supported by the browser'); + canAttach = false; + } + if (texture.format !== __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_COMPONENT + && texture.format !== __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_STENCIL + ) { + console.error('The texture attached to depth buffer is not a valid.'); + canAttach = false; + } + // Dispose render buffer created previous + if (canAttach) { + var renderbuffer = this._cache.get(KEY_RENDERBUFFER); + if (renderbuffer) { + _gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, null); + _gl.deleteRenderbuffer(renderbuffer); + this._cache.put(KEY_RENDERBUFFER, false); + } + this._cache.put(KEY_RENDERBUFFER_ATTACHED, false); + this._cache.put(KEY_DEPTHTEXTURE_ATTACHED, true); + } + } + // Mipmap level can only be 0 + _gl.framebufferTexture2D(GL_FRAMEBUFFER, attachment, target, webglTexture, 0); + if (!attachedTextures) { + attachedTextures = {}; + this._cache.put('attached_textures', attachedTextures); + } + attachedTextures[attachment] = attachedTextures[attachment] || {}; + attachedTextures[attachment].texture = texture; + attachedTextures[attachment].target = target; + return canAttach; + }, + _doDetach: function (_gl, attachment, target) { + // Detach a texture from framebuffer + // https://github.com/KhronosGroup/WebGL/blob/master/conformance-suites/1.0.0/conformance/framebuffer-test.html#L145 + _gl.framebufferTexture2D(GL_FRAMEBUFFER, attachment, target, null, 0); + // Assume cache has been used. + var attachedTextures = this._cache.get('attached_textures'); + if (attachedTextures && attachedTextures[attachment]) { + attachedTextures[attachment] = null; + } + if (attachment === GL_DEPTH_ATTACHMENT || attachment === __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_STENCIL_ATTACHMENT) { + this._cache.put(KEY_DEPTHTEXTURE_ATTACHED, false); + } + }, -__WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts___default.a.util.extend(__WEBPACK_IMPORTED_MODULE_6_claygl_src_Node__["a" /* default */].prototype, __WEBPACK_IMPORTED_MODULE_38__animatableMixin__["a" /* default */]); + /** + * Detach a texture + * @param {number} [attachment=gl.COLOR_ATTACHMENT0] + * @param {number} [target=gl.TEXTURE_2D] + */ + detach: function (attachment, target) { + // TODO depth extension check ? + this._textures[attachment] = null; + if (this._boundRenderer) { + var cache = this._cache; + cache.use(this._boundRenderer.__uid__); + this._doDetach(this._boundRenderer.gl, attachment, target); + } + }, + /** + * Dispose + * @param {WebGLRenderingContext} _gl + */ + dispose: function (renderer) { -__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_39_claygl_src_shader_source_util_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_40_claygl_src_shader_source_prez_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_41__shader_common_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_42__shader_color_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_43__shader_lambert_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_44__shader_realistic_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_45__shader_hatching_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_46__shader_shadow_glsl_js__["a" /* default */]); + var _gl = renderer.gl; + var cache = this._cache; -function isValueNone(value) { - return !value || value === 'none'; -} + cache.use(renderer.__uid__); -function isValueImage(value) { - return value instanceof HTMLCanvasElement - || value instanceof HTMLImageElement - || value instanceof Image; -} + var renderBuffer = cache.get(KEY_RENDERBUFFER); + if (renderBuffer) { + _gl.deleteRenderbuffer(renderBuffer); + } + var frameBuffer = cache.get(KEY_FRAMEBUFFER); + if (frameBuffer) { + _gl.deleteFramebuffer(frameBuffer); + } + cache.deleteContext(renderer.__uid__); -function isECharts(value) { - return value.getZr && value.setOption; -} + // Clear cache for reusing + this._textures = {}; -// Overwrite addToScene and removeFromScene -var oldAddToScene = __WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__["a" /* default */].prototype.addToScene; -var oldRemoveFromScene = __WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__["a" /* default */].prototype.removeFromScene; + } +}); -__WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__["a" /* default */].prototype.addToScene = function (node) { - oldAddToScene.call(this, node); +FrameBuffer.DEPTH_ATTACHMENT = GL_DEPTH_ATTACHMENT; +FrameBuffer.COLOR_ATTACHMENT0 = GL_COLOR_ATTACHMENT0; +FrameBuffer.STENCIL_ATTACHMENT = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].STENCIL_ATTACHMENT; +FrameBuffer.DEPTH_STENCIL_ATTACHMENT = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_STENCIL_ATTACHMENT; - if (this.__zr) { - var zr = this.__zr; - node.traverse(function (child) { - child.__zr = zr; - if (child.addAnimatorsToZr) { - child.addAnimatorsToZr(zr); - } - }); - } -}; +/* harmony default export */ __webpack_exports__["a"] = (FrameBuffer); -__WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__["a" /* default */].prototype.removeFromScene = function (node) { - oldRemoveFromScene.call(this, node); - node.traverse(function (child) { - var zr = child.__zr; - child.__zr = null; - if (zr && child.removeAnimatorsFromZr) { - child.removeAnimatorsFromZr(zr); - } - }); -}; +/***/ }), +/* 11 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; /** - * @param {string} textureName - * @param {string|HTMLImageElement|HTMLCanvasElement} imgValue - * @param {module:echarts/ExtensionAPI} api - * @param {Object} [textureOpts] + * @namespace clay.core.glenum + * @see http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14 */ -__WEBPACK_IMPORTED_MODULE_5_claygl_src_Material__["a" /* default */].prototype.setTextureImage = function (textureName, imgValue, api, textureOpts) { - if (!this.shader) { - return; - } +/* harmony default export */ __webpack_exports__["a"] = ({ + /* ClearBufferMask */ + DEPTH_BUFFER_BIT : 0x00000100, + STENCIL_BUFFER_BIT : 0x00000400, + COLOR_BUFFER_BIT : 0x00004000, - var zr = api.getZr(); - var material = this; - var texture; - material.autoUpdateTextureStatus = false; - // disableTexture first - material.disableTexture(textureName); - if (!isValueNone(imgValue)) { - texture = graphicGL.loadTexture(imgValue, api, textureOpts, function (texture) { - material.enableTexture(textureName); - zr && zr.refresh(); - }); - // Set texture immediately for other code to verify if have this texture. - material.set(textureName, texture); - } + /* BeginMode */ + POINTS : 0x0000, + LINES : 0x0001, + LINE_LOOP : 0x0002, + LINE_STRIP : 0x0003, + TRIANGLES : 0x0004, + TRIANGLE_STRIP : 0x0005, + TRIANGLE_FAN : 0x0006, - return texture; -}; + /* AlphaFunction (not supported in ES20) */ + /* NEVER */ + /* LESS */ + /* EQUAL */ + /* LEQUAL */ + /* GREATER */ + /* NOTEQUAL */ + /* GEQUAL */ + /* ALWAYS */ -var graphicGL = {}; + /* BlendingFactorDest */ + ZERO : 0, + ONE : 1, + SRC_COLOR : 0x0300, + ONE_MINUS_SRC_COLOR : 0x0301, + SRC_ALPHA : 0x0302, + ONE_MINUS_SRC_ALPHA : 0x0303, + DST_ALPHA : 0x0304, + ONE_MINUS_DST_ALPHA : 0x0305, -graphicGL.Renderer = __WEBPACK_IMPORTED_MODULE_1_claygl_src_Renderer__["a" /* default */]; + /* BlendingFactorSrc */ + /* ZERO */ + /* ONE */ + DST_COLOR : 0x0306, + ONE_MINUS_DST_COLOR : 0x0307, + SRC_ALPHA_SATURATE : 0x0308, + /* SRC_ALPHA */ + /* ONE_MINUS_SRC_ALPHA */ + /* DST_ALPHA */ + /* ONE_MINUS_DST_ALPHA */ -graphicGL.Node = __WEBPACK_IMPORTED_MODULE_6_claygl_src_Node__["a" /* default */]; + /* BlendEquationSeparate */ + FUNC_ADD : 0x8006, + BLEND_EQUATION : 0x8009, + BLEND_EQUATION_RGB : 0x8009, /* same as BLEND_EQUATION */ + BLEND_EQUATION_ALPHA : 0x883D, -graphicGL.Mesh = __WEBPACK_IMPORTED_MODULE_0_claygl_src_Mesh__["a" /* default */]; + /* BlendSubtract */ + FUNC_SUBTRACT : 0x800A, + FUNC_REVERSE_SUBTRACT : 0x800B, -graphicGL.Shader = __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */]; + /* Separate Blend Functions */ + BLEND_DST_RGB : 0x80C8, + BLEND_SRC_RGB : 0x80C9, + BLEND_DST_ALPHA : 0x80CA, + BLEND_SRC_ALPHA : 0x80CB, + CONSTANT_COLOR : 0x8001, + ONE_MINUS_CONSTANT_COLOR : 0x8002, + CONSTANT_ALPHA : 0x8003, + ONE_MINUS_CONSTANT_ALPHA : 0x8004, + BLEND_COLOR : 0x8005, -graphicGL.Material = __WEBPACK_IMPORTED_MODULE_5_claygl_src_Material__["a" /* default */]; + /* Buffer Objects */ + ARRAY_BUFFER : 0x8892, + ELEMENT_ARRAY_BUFFER : 0x8893, + ARRAY_BUFFER_BINDING : 0x8894, + ELEMENT_ARRAY_BUFFER_BINDING : 0x8895, -graphicGL.Texture = __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */]; + STREAM_DRAW : 0x88E0, + STATIC_DRAW : 0x88E4, + DYNAMIC_DRAW : 0x88E8, -graphicGL.Texture2D = __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__["a" /* default */]; + BUFFER_SIZE : 0x8764, + BUFFER_USAGE : 0x8765, -// Geometries -graphicGL.Geometry = __WEBPACK_IMPORTED_MODULE_7_claygl_src_Geometry__["a" /* default */]; -graphicGL.SphereGeometry = __WEBPACK_IMPORTED_MODULE_17_claygl_src_geometry_Sphere__["a" /* default */]; -graphicGL.PlaneGeometry = __WEBPACK_IMPORTED_MODULE_18_claygl_src_geometry_Plane__["a" /* default */]; -graphicGL.CubeGeometry = __WEBPACK_IMPORTED_MODULE_19_claygl_src_geometry_Cube__["a" /* default */]; + CURRENT_VERTEX_ATTRIB : 0x8626, -// Lights -graphicGL.AmbientLight = __WEBPACK_IMPORTED_MODULE_20_claygl_src_light_Ambient__["a" /* default */]; -graphicGL.DirectionalLight = __WEBPACK_IMPORTED_MODULE_21_claygl_src_light_Directional__["a" /* default */]; -graphicGL.PointLight = __WEBPACK_IMPORTED_MODULE_22_claygl_src_light_Point__["a" /* default */]; -graphicGL.SpotLight = __WEBPACK_IMPORTED_MODULE_23_claygl_src_light_Spot__["a" /* default */]; + /* CullFaceMode */ + FRONT : 0x0404, + BACK : 0x0405, + FRONT_AND_BACK : 0x0408, -// Cameras -graphicGL.PerspectiveCamera = __WEBPACK_IMPORTED_MODULE_24_claygl_src_camera_Perspective__["a" /* default */]; -graphicGL.OrthographicCamera = __WEBPACK_IMPORTED_MODULE_25_claygl_src_camera_Orthographic__["a" /* default */]; + /* DepthFunction */ + /* NEVER */ + /* LESS */ + /* EQUAL */ + /* LEQUAL */ + /* GREATER */ + /* NOTEQUAL */ + /* GEQUAL */ + /* ALWAYS */ -// Math -graphicGL.Vector2 = __WEBPACK_IMPORTED_MODULE_26_claygl_src_math_Vector2__["a" /* default */]; -graphicGL.Vector3 = __WEBPACK_IMPORTED_MODULE_27_claygl_src_math_Vector3__["a" /* default */]; -graphicGL.Vector4 = __WEBPACK_IMPORTED_MODULE_28_claygl_src_math_Vector4__["a" /* default */]; + /* EnableCap */ + /* TEXTURE_2D */ + CULL_FACE : 0x0B44, + BLEND : 0x0BE2, + DITHER : 0x0BD0, + STENCIL_TEST : 0x0B90, + DEPTH_TEST : 0x0B71, + SCISSOR_TEST : 0x0C11, + POLYGON_OFFSET_FILL : 0x8037, + SAMPLE_ALPHA_TO_COVERAGE : 0x809E, + SAMPLE_COVERAGE : 0x80A0, -graphicGL.Quaternion = __WEBPACK_IMPORTED_MODULE_29_claygl_src_math_Quaternion__["a" /* default */]; + /* ErrorCode */ + NO_ERROR : 0, + INVALID_ENUM : 0x0500, + INVALID_VALUE : 0x0501, + INVALID_OPERATION : 0x0502, + OUT_OF_MEMORY : 0x0505, -graphicGL.Matrix2 = __WEBPACK_IMPORTED_MODULE_30_claygl_src_math_Matrix2__["a" /* default */]; -graphicGL.Matrix2d = __WEBPACK_IMPORTED_MODULE_31_claygl_src_math_Matrix2d__["a" /* default */]; -graphicGL.Matrix3 = __WEBPACK_IMPORTED_MODULE_32_claygl_src_math_Matrix3__["a" /* default */]; -graphicGL.Matrix4 = __WEBPACK_IMPORTED_MODULE_33_claygl_src_math_Matrix4__["a" /* default */]; + /* FrontFaceDirection */ + CW : 0x0900, + CCW : 0x0901, -graphicGL.Plane = __WEBPACK_IMPORTED_MODULE_34_claygl_src_math_Plane__["a" /* default */]; -graphicGL.Ray = __WEBPACK_IMPORTED_MODULE_35_claygl_src_math_Ray__["a" /* default */]; -graphicGL.BoundingBox = __WEBPACK_IMPORTED_MODULE_36_claygl_src_math_BoundingBox__["a" /* default */]; -graphicGL.Frustum = __WEBPACK_IMPORTED_MODULE_37_claygl_src_math_Frustum__["a" /* default */]; + /* GetPName */ + LINE_WIDTH : 0x0B21, + ALIASED_POINT_SIZE_RANGE : 0x846D, + ALIASED_LINE_WIDTH_RANGE : 0x846E, + CULL_FACE_MODE : 0x0B45, + FRONT_FACE : 0x0B46, + DEPTH_RANGE : 0x0B70, + DEPTH_WRITEMASK : 0x0B72, + DEPTH_CLEAR_VALUE : 0x0B73, + DEPTH_FUNC : 0x0B74, + STENCIL_CLEAR_VALUE : 0x0B91, + STENCIL_FUNC : 0x0B92, + STENCIL_FAIL : 0x0B94, + STENCIL_PASS_DEPTH_FAIL : 0x0B95, + STENCIL_PASS_DEPTH_PASS : 0x0B96, + STENCIL_REF : 0x0B97, + STENCIL_VALUE_MASK : 0x0B93, + STENCIL_WRITEMASK : 0x0B98, + STENCIL_BACK_FUNC : 0x8800, + STENCIL_BACK_FAIL : 0x8801, + STENCIL_BACK_PASS_DEPTH_FAIL : 0x8802, + STENCIL_BACK_PASS_DEPTH_PASS : 0x8803, + STENCIL_BACK_REF : 0x8CA3, + STENCIL_BACK_VALUE_MASK : 0x8CA4, + STENCIL_BACK_WRITEMASK : 0x8CA5, + VIEWPORT : 0x0BA2, + SCISSOR_BOX : 0x0C10, + /* SCISSOR_TEST */ + COLOR_CLEAR_VALUE : 0x0C22, + COLOR_WRITEMASK : 0x0C23, + UNPACK_ALIGNMENT : 0x0CF5, + PACK_ALIGNMENT : 0x0D05, + MAX_TEXTURE_SIZE : 0x0D33, + MAX_VIEWPORT_DIMS : 0x0D3A, + SUBPIXEL_BITS : 0x0D50, + RED_BITS : 0x0D52, + GREEN_BITS : 0x0D53, + BLUE_BITS : 0x0D54, + ALPHA_BITS : 0x0D55, + DEPTH_BITS : 0x0D56, + STENCIL_BITS : 0x0D57, + POLYGON_OFFSET_UNITS : 0x2A00, + /* POLYGON_OFFSET_FILL */ + POLYGON_OFFSET_FACTOR : 0x8038, + TEXTURE_BINDING_2D : 0x8069, + SAMPLE_BUFFERS : 0x80A8, + SAMPLES : 0x80A9, + SAMPLE_COVERAGE_VALUE : 0x80AA, + SAMPLE_COVERAGE_INVERT : 0x80AB, -// Texture utilities + /* GetTextureParameter */ + /* TEXTURE_MAG_FILTER */ + /* TEXTURE_MIN_FILTER */ + /* TEXTURE_WRAP_S */ + /* TEXTURE_WRAP_T */ -var blankImage = __WEBPACK_IMPORTED_MODULE_11_claygl_src_util_texture__["a" /* default */].createBlank('rgba(255,255,255,0)').image; + COMPRESSED_TEXTURE_FORMATS : 0x86A3, + /* HintMode */ + DONT_CARE : 0x1100, + FASTEST : 0x1101, + NICEST : 0x1102, -function nearestPowerOfTwo(val) { - return Math.pow(2, Math.round(Math.log(val) / Math.LN2)); -} -function convertTextureToPowerOfTwo(texture) { - if ((texture.wrapS === __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].REPEAT || texture.wrapT === __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].REPEAT) - && texture.image - ) { - // var canvas = document.createElement('canvas'); - var width = nearestPowerOfTwo(texture.width); - var height = nearestPowerOfTwo(texture.height); - if (width !== texture.width || height !== texture.height) { - var canvas = document.createElement('canvas'); - canvas.width = width; - canvas.height = height; - var ctx = canvas.getContext('2d'); - ctx.drawImage(texture.image, 0, 0, width, height); - texture.image = canvas; - } - } -} -/** - * @param {string|HTMLImageElement|HTMLCanvasElement} imgValue - * @param {module:echarts/ExtensionAPI} api - * @param {Object} [textureOpts] - * @param {Function} cb - */ -// TODO Promise, test -graphicGL.loadTexture = function (imgValue, api, textureOpts, cb) { - if (typeof textureOpts === 'function') { - cb = textureOpts; - textureOpts = {}; - } - textureOpts = textureOpts || {}; + /* HintTarget */ + GENERATE_MIPMAP_HINT : 0x8192, - var keys = Object.keys(textureOpts).sort(); - var prefix = ''; - for (var i = 0; i < keys.length; i++) { - prefix += keys[i] + '_' + textureOpts[keys[i]] + '_'; - } + /* DataType */ + BYTE : 0x1400, + UNSIGNED_BYTE : 0x1401, + SHORT : 0x1402, + UNSIGNED_SHORT : 0x1403, + INT : 0x1404, + UNSIGNED_INT : 0x1405, + FLOAT : 0x1406, - var textureCache = api.__textureCache = api.__textureCache || new __WEBPACK_IMPORTED_MODULE_10_zrender_lib_core_LRU___default.a(20); + /* PixelFormat */ + DEPTH_COMPONENT : 0x1902, + ALPHA : 0x1906, + RGB : 0x1907, + RGBA : 0x1908, + LUMINANCE : 0x1909, + LUMINANCE_ALPHA : 0x190A, - if (isECharts(imgValue)) { - var id = imgValue.__textureid__; - var textureObj = textureCache.get(prefix + id); - if (!textureObj) { - var surface = new __WEBPACK_IMPORTED_MODULE_12__EChartsSurface__["a" /* default */](imgValue); - surface.onupdate = function () { - api.getZr().refresh(); - }; - textureObj = { - texture: surface.getTexture() - }; - for (var i = 0; i < keys.length; i++) { - textureObj.texture[keys[i]] = textureOpts[keys[i]]; - } - id = imgValue.__textureid__ || '__ecgl_ec__' + textureObj.texture.__uid__; - imgValue.__textureid__ = id; - textureCache.put(prefix + id, textureObj); - cb && cb(textureObj.texture); - } - else { - textureObj.texture.surface.setECharts(imgValue); + /* PixelType */ + /* UNSIGNED_BYTE */ + UNSIGNED_SHORT_4_4_4_4 : 0x8033, + UNSIGNED_SHORT_5_5_5_1 : 0x8034, + UNSIGNED_SHORT_5_6_5 : 0x8363, - cb && cb(textureObj.texture); - } - return textureObj.texture; - } - else if (isValueImage(imgValue)) { - var id = imgValue.__textureid__; - var textureObj = textureCache.get(prefix + id); - if (!textureObj) { - textureObj = { - texture: new graphicGL.Texture2D({ - image: imgValue - }) - }; - for (var i = 0; i < keys.length; i++) { - textureObj.texture[keys[i]] = textureOpts[keys[i]]; - } - id = imgValue.__textureid__ || '__ecgl_image__' + textureObj.texture.__uid__; - imgValue.__textureid__ = id; - textureCache.put(prefix + id, textureObj); + /* Shaders */ + FRAGMENT_SHADER : 0x8B30, + VERTEX_SHADER : 0x8B31, + MAX_VERTEX_ATTRIBS : 0x8869, + MAX_VERTEX_UNIFORM_VECTORS : 0x8DFB, + MAX_VARYING_VECTORS : 0x8DFC, + MAX_COMBINED_TEXTURE_IMAGE_UNITS : 0x8B4D, + MAX_VERTEX_TEXTURE_IMAGE_UNITS : 0x8B4C, + MAX_TEXTURE_IMAGE_UNITS : 0x8872, + MAX_FRAGMENT_UNIFORM_VECTORS : 0x8DFD, + SHADER_TYPE : 0x8B4F, + DELETE_STATUS : 0x8B80, + LINK_STATUS : 0x8B82, + VALIDATE_STATUS : 0x8B83, + ATTACHED_SHADERS : 0x8B85, + ACTIVE_UNIFORMS : 0x8B86, + ACTIVE_ATTRIBUTES : 0x8B89, + SHADING_LANGUAGE_VERSION : 0x8B8C, + CURRENT_PROGRAM : 0x8B8D, - convertTextureToPowerOfTwo(textureObj.texture); - // TODO Next tick? - cb && cb(textureObj.texture); - } - return textureObj.texture; - } - else { - var textureObj = textureCache.get(prefix + imgValue); - if (textureObj) { - if (textureObj.callbacks) { - // Add to pending callbacks - textureObj.callbacks.push(cb); - } - else { - // TODO Next tick? - cb && cb(textureObj.texture); - } - } - else { - // Maybe base64 - if (imgValue.match(/.hdr$|^data:application\/octet-stream/)) { - textureObj = { - callbacks: [cb] - }; - var texture = __WEBPACK_IMPORTED_MODULE_11_claygl_src_util_texture__["a" /* default */].loadTexture(imgValue, { - exposure: textureOpts.exposure, - fileType: 'hdr' - }, function () { - texture.dirty(); - textureObj.callbacks.forEach(function (cb) { - cb && cb(texture); - }); - textureObj.callbacks = null; - }); - textureObj.texture = texture; - textureCache.put(prefix + imgValue, textureObj); - } - else { - var texture = new graphicGL.Texture2D({ - image: new Image() - }); - for (var i = 0; i < keys.length; i++) { - texture[keys[i]] = textureOpts[keys[i]]; - } + /* StencilFunction */ + NEVER : 0x0200, + LESS : 0x0201, + EQUAL : 0x0202, + LEQUAL : 0x0203, + GREATER : 0x0204, + NOTEQUAL : 0x0205, + GEQUAL : 0x0206, + ALWAYS : 0x0207, - textureObj = { - texture: texture, - callbacks: [cb] - }; - var originalImage = texture.image; - originalImage.onload = function () { - texture.image = originalImage; - convertTextureToPowerOfTwo(texture); + /* StencilOp */ + /* ZERO */ + KEEP : 0x1E00, + REPLACE : 0x1E01, + INCR : 0x1E02, + DECR : 0x1E03, + INVERT : 0x150A, + INCR_WRAP : 0x8507, + DECR_WRAP : 0x8508, - texture.dirty(); - textureObj.callbacks.forEach(function (cb) { - cb && cb(texture); - }); - textureObj.callbacks = null; - }; - originalImage.src = imgValue; - // Use blank image as place holder. - texture.image = blankImage; + /* StringName */ + VENDOR : 0x1F00, + RENDERER : 0x1F01, + VERSION : 0x1F02, - textureCache.put(prefix + imgValue, textureObj); - } - } + /* TextureMagFilter */ + NEAREST : 0x2600, + LINEAR : 0x2601, - return textureObj.texture; - } -}; + /* TextureMinFilter */ + /* NEAREST */ + /* LINEAR */ + NEAREST_MIPMAP_NEAREST : 0x2700, + LINEAR_MIPMAP_NEAREST : 0x2701, + NEAREST_MIPMAP_LINEAR : 0x2702, + LINEAR_MIPMAP_LINEAR : 0x2703, -/** - * Create ambientCubemap and ambientSH light. respectively to have specular and diffuse light - * @return {Object} { specular, diffuse } - */ -graphicGL.createAmbientCubemap = function (opt, renderer, api, cb) { - opt = opt || {}; - var textureUrl = opt.texture; - var exposure = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(opt.exposure, 1.0); + /* TextureParameterName */ + TEXTURE_MAG_FILTER : 0x2800, + TEXTURE_MIN_FILTER : 0x2801, + TEXTURE_WRAP_S : 0x2802, + TEXTURE_WRAP_T : 0x2803, - var ambientCubemap = new __WEBPACK_IMPORTED_MODULE_13_claygl_src_light_AmbientCubemap__["a" /* default */]({ - intensity: __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(opt.specularIntensity, 1.0) - }); - var ambientSH = new __WEBPACK_IMPORTED_MODULE_14_claygl_src_light_AmbientSH__["a" /* default */]({ - intensity: __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(opt.diffuseIntensity, 1.0), - coefficients: [0.844, 0.712, 0.691, -0.037, 0.083, 0.167, 0.343, 0.288, 0.299, -0.041, -0.021, -0.009, -0.003, -0.041, -0.064, -0.011, -0.007, -0.004, -0.031, 0.034, 0.081, -0.060, -0.049, -0.060, 0.046, 0.056, 0.050] - }); + /* TextureTarget */ + TEXTURE_2D : 0x0DE1, + TEXTURE : 0x1702, + TEXTURE_CUBE_MAP : 0x8513, + TEXTURE_BINDING_CUBE_MAP : 0x8514, + TEXTURE_CUBE_MAP_POSITIVE_X : 0x8515, + TEXTURE_CUBE_MAP_NEGATIVE_X : 0x8516, + TEXTURE_CUBE_MAP_POSITIVE_Y : 0x8517, + TEXTURE_CUBE_MAP_NEGATIVE_Y : 0x8518, + TEXTURE_CUBE_MAP_POSITIVE_Z : 0x8519, + TEXTURE_CUBE_MAP_NEGATIVE_Z : 0x851A, + MAX_CUBE_MAP_TEXTURE_SIZE : 0x851C, - ambientCubemap.cubemap = graphicGL.loadTexture(textureUrl, api, { - exposure: exposure - }, function () { - // TODO Performance when multiple view - ambientCubemap.cubemap.flipY = false; - if (true) { - var time = Date.now(); - } - ambientCubemap.prefilter(renderer, 32); - if (true) { - var dTime = Date.now() - time; - console.log('Prefilter environment map: ' + dTime + 'ms'); - } - ambientSH.coefficients = __WEBPACK_IMPORTED_MODULE_15_claygl_src_util_sh__["a" /* default */].projectEnvironmentMap(renderer, ambientCubemap.cubemap, { - lod: 1 - }); + /* TextureUnit */ + TEXTURE0 : 0x84C0, + TEXTURE1 : 0x84C1, + TEXTURE2 : 0x84C2, + TEXTURE3 : 0x84C3, + TEXTURE4 : 0x84C4, + TEXTURE5 : 0x84C5, + TEXTURE6 : 0x84C6, + TEXTURE7 : 0x84C7, + TEXTURE8 : 0x84C8, + TEXTURE9 : 0x84C9, + TEXTURE10 : 0x84CA, + TEXTURE11 : 0x84CB, + TEXTURE12 : 0x84CC, + TEXTURE13 : 0x84CD, + TEXTURE14 : 0x84CE, + TEXTURE15 : 0x84CF, + TEXTURE16 : 0x84D0, + TEXTURE17 : 0x84D1, + TEXTURE18 : 0x84D2, + TEXTURE19 : 0x84D3, + TEXTURE20 : 0x84D4, + TEXTURE21 : 0x84D5, + TEXTURE22 : 0x84D6, + TEXTURE23 : 0x84D7, + TEXTURE24 : 0x84D8, + TEXTURE25 : 0x84D9, + TEXTURE26 : 0x84DA, + TEXTURE27 : 0x84DB, + TEXTURE28 : 0x84DC, + TEXTURE29 : 0x84DD, + TEXTURE30 : 0x84DE, + TEXTURE31 : 0x84DF, + ACTIVE_TEXTURE : 0x84E0, - cb && cb(); + /* TextureWrapMode */ + REPEAT : 0x2901, + CLAMP_TO_EDGE : 0x812F, + MIRRORED_REPEAT : 0x8370, - // TODO Refresh ? - }); + /* Uniform Types */ + FLOAT_VEC2 : 0x8B50, + FLOAT_VEC3 : 0x8B51, + FLOAT_VEC4 : 0x8B52, + INT_VEC2 : 0x8B53, + INT_VEC3 : 0x8B54, + INT_VEC4 : 0x8B55, + BOOL : 0x8B56, + BOOL_VEC2 : 0x8B57, + BOOL_VEC3 : 0x8B58, + BOOL_VEC4 : 0x8B59, + FLOAT_MAT2 : 0x8B5A, + FLOAT_MAT3 : 0x8B5B, + FLOAT_MAT4 : 0x8B5C, + SAMPLER_2D : 0x8B5E, + SAMPLER_CUBE : 0x8B60, - return { - specular: ambientCubemap, - diffuse: ambientSH - }; -}; + /* Vertex Arrays */ + VERTEX_ATTRIB_ARRAY_ENABLED : 0x8622, + VERTEX_ATTRIB_ARRAY_SIZE : 0x8623, + VERTEX_ATTRIB_ARRAY_STRIDE : 0x8624, + VERTEX_ATTRIB_ARRAY_TYPE : 0x8625, + VERTEX_ATTRIB_ARRAY_NORMALIZED : 0x886A, + VERTEX_ATTRIB_ARRAY_POINTER : 0x8645, + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING : 0x889F, -/** - * Create a blank texture for placeholder - */ -graphicGL.createBlankTexture = __WEBPACK_IMPORTED_MODULE_11_claygl_src_util_texture__["a" /* default */].createBlank; + /* Shader Source */ + COMPILE_STATUS : 0x8B81, -/** - * If value is image - * @param {*} - * @return {boolean} - */ -graphicGL.isImage = isValueImage; + /* Shader Precision-Specified Types */ + LOW_FLOAT : 0x8DF0, + MEDIUM_FLOAT : 0x8DF1, + HIGH_FLOAT : 0x8DF2, + LOW_INT : 0x8DF3, + MEDIUM_INT : 0x8DF4, + HIGH_INT : 0x8DF5, -graphicGL.additiveBlend = function (gl) { - gl.blendEquation(gl.FUNC_ADD); - gl.blendFunc(gl.SRC_ALPHA, gl.ONE); -}; + /* Framebuffer Object. */ + FRAMEBUFFER : 0x8D40, + RENDERBUFFER : 0x8D41, -/** - * @param {string|Array.} colorStr - * @param {Array.} [rgba] - * @return {Array.} rgba - */ -graphicGL.parseColor = function (colorStr, rgba) { - if (colorStr instanceof Array) { - if (!rgba) { - rgba = []; - } - // Color has been parsed. - rgba[0] = colorStr[0]; - rgba[1] = colorStr[1]; - rgba[2] = colorStr[2]; - if (colorStr.length > 3) { - rgba[3] = colorStr[3]; - } - else { - rgba[3] = 1; - } - return rgba; - } + RGBA4 : 0x8056, + RGB5_A1 : 0x8057, + RGB565 : 0x8D62, + DEPTH_COMPONENT16 : 0x81A5, + STENCIL_INDEX : 0x1901, + STENCIL_INDEX8 : 0x8D48, + DEPTH_STENCIL : 0x84F9, - rgba = __WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts___default.a.color.parse(colorStr || '#000', rgba) || [0, 0, 0, 0]; - rgba[0] /= 255; - rgba[1] /= 255; - rgba[2] /= 255; - return rgba; -}; - -/** - * Convert alpha beta rotation to direction. - * @param {number} alpha - * @param {number} beta - * @return {Array.} - */ -graphicGL.directionFromAlphaBeta = function (alpha, beta) { - var theta = alpha / 180 * Math.PI + Math.PI / 2; - var phi = -beta / 180 * Math.PI + Math.PI / 2; - - var dir = []; - var r = Math.sin(theta); - dir[0] = r * Math.cos(phi); - dir[1] = -Math.cos(theta); - dir[2] = r * Math.sin(phi); + RENDERBUFFER_WIDTH : 0x8D42, + RENDERBUFFER_HEIGHT : 0x8D43, + RENDERBUFFER_INTERNAL_FORMAT : 0x8D44, + RENDERBUFFER_RED_SIZE : 0x8D50, + RENDERBUFFER_GREEN_SIZE : 0x8D51, + RENDERBUFFER_BLUE_SIZE : 0x8D52, + RENDERBUFFER_ALPHA_SIZE : 0x8D53, + RENDERBUFFER_DEPTH_SIZE : 0x8D54, + RENDERBUFFER_STENCIL_SIZE : 0x8D55, - return dir; -}; -/** - * Get shadow resolution from shadowQuality configuration - */ -graphicGL.getShadowResolution = function (shadowQuality) { - var shadowResolution = 1024; - switch (shadowQuality) { - case 'low': - shadowResolution = 512; - break; - case 'medium': - break; - case 'high': - shadowResolution = 2048; - break; - case 'ultra': - shadowResolution = 4096; - break; - } - return shadowResolution; -}; + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE : 0x8CD0, + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME : 0x8CD1, + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL : 0x8CD2, + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE : 0x8CD3, -/** - * Shading utilities - */ -graphicGL.COMMON_SHADERS = ['lambert', 'color', 'realistic', 'hatching']; + COLOR_ATTACHMENT0 : 0x8CE0, + DEPTH_ATTACHMENT : 0x8D00, + STENCIL_ATTACHMENT : 0x8D20, + DEPTH_STENCIL_ATTACHMENT : 0x821A, -/** - * Create shader including vertex and fragment - * @param {string} prefix. - */ -graphicGL.createShader = function (prefix) { - var vertexShaderStr = __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source(prefix + '.vertex'); - var fragmentShaderStr = __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source(prefix + '.fragment'); - if (!vertexShaderStr) { - console.error('Vertex shader of \'%s\' not exits', prefix); - } - if (!fragmentShaderStr) { - console.error('Fragment shader of \'%s\' not exits', prefix); - } - var shader = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */](vertexShaderStr, fragmentShaderStr); - shader.name = prefix; - return shader; -}; + NONE : 0, -graphicGL.createMaterial = function (prefix, defines) { - if (!(defines instanceof Array)) { - defines = [defines]; - } - var shader = graphicGL.createShader(prefix); - var material = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_Material__["a" /* default */]({ - shader: shader - }); - defines.forEach(function (defineName) { - if (typeof defineName === 'string') { - material.define(defineName); - } - }); - return material; -}; -/** - * Set material from model. - * @param {clay.Material} material - * @param {module:echarts/model/Model} model - * @param {module:echarts/ExtensionAPI} api - */ -graphicGL.setMaterialFromModel = function (shading, material, model, api) { - material.autoUpdateTextureStatus = false; + FRAMEBUFFER_COMPLETE : 0x8CD5, + FRAMEBUFFER_INCOMPLETE_ATTACHMENT : 0x8CD6, + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : 0x8CD7, + FRAMEBUFFER_INCOMPLETE_DIMENSIONS : 0x8CD9, + FRAMEBUFFER_UNSUPPORTED : 0x8CDD, - var materialModel = model.getModel(shading + 'Material'); - var detailTexture = materialModel.get('detailTexture'); - var uvRepeat = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(materialModel.get('textureTiling'), 1.0); - var uvOffset = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(materialModel.get('textureOffset'), 0.0); - if (typeof uvRepeat === 'number') { - uvRepeat = [uvRepeat, uvRepeat]; - } - if (typeof uvOffset === 'number') { - uvOffset = [uvOffset, uvOffset]; - } - var repeatParam = (uvRepeat[0] > 1 || uvRepeat[1] > 1) ? graphicGL.Texture.REPEAT : graphicGL.Texture.CLAMP_TO_EDGE; - var textureOpt = { - anisotropic: 8, - wrapS: repeatParam, - wrapT: repeatParam - }; - if (shading === 'realistic') { - var roughness = materialModel.get('roughness'); - var metalness = materialModel.get('metalness'); - if (metalness != null) { - // Try to treat as a texture, TODO More check - if (isNaN(metalness)) { - material.setTextureImage('metalnessMap', metalness, api, textureOpt); - metalness = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(materialModel.get('metalnessAdjust'), 0.5); - } - } - else { - // Default metalness. - metalness = 0; - } - if (roughness != null) { - // Try to treat as a texture, TODO More check - if (isNaN(roughness)) { - material.setTextureImage('roughnessMap', roughness, api, textureOpt); - roughness = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(materialModel.get('roughnessAdjust'), 0.5); - } - } - else { - // Default roughness. - roughness = 0.5; - } - var normalTextureVal = materialModel.get('normalTexture'); - material.setTextureImage('detailMap', detailTexture, api, textureOpt); - material.setTextureImage('normalMap', normalTextureVal, api, textureOpt); - material.set({ - roughness: roughness, - metalness: metalness, - detailUvRepeat: uvRepeat, - detailUvOffset: uvOffset - }); - // var normalTexture = material.get('normalMap'); - // if (normalTexture) { - // PENDING - // normalTexture.format = Texture.SRGB; - // } - } - else if (shading === 'lambert') { - material.setTextureImage('detailMap', detailTexture, api, textureOpt); - material.set({ - detailUvRepeat: uvRepeat, - detailUvOffset: uvOffset - }); - } - else if (shading === 'color') { - material.setTextureImage('detailMap', detailTexture, api, textureOpt); - material.set({ - detailUvRepeat: uvRepeat, - detailUvOffset: uvOffset - }); - } - else if (shading === 'hatching') { - var tams = materialModel.get('hatchingTextures') || []; - if (tams.length < 6) { - if (true) { - console.error('Invalid hatchingTextures.'); - } - } - for (var i = 0; i < 6; i++) { - material.setTextureImage('hatch' + (i + 1), tams[i], api, { - anisotropic: 8, - wrapS: graphicGL.Texture.REPEAT, - wrapT: graphicGL.Texture.REPEAT - }); - } - material.set({ - detailUvRepeat: uvRepeat, - detailUvOffset: uvOffset - }); - } -}; + FRAMEBUFFER_BINDING : 0x8CA6, + RENDERBUFFER_BINDING : 0x8CA7, + MAX_RENDERBUFFER_SIZE : 0x84E8, -graphicGL.updateVertexAnimation = function ( - mappingAttributes, previousMesh, currentMesh, seriesModel -) { - var enableAnimation = seriesModel.get('animation'); - var duration = seriesModel.get('animationDurationUpdate'); - var easing = seriesModel.get('animationEasingUpdate'); - var shadowDepthMaterial = currentMesh.shadowDepthMaterial; + INVALID_FRAMEBUFFER_OPERATION : 0x0506, - if (enableAnimation && previousMesh && duration > 0 - // Only animate when bar count are not changed - && previousMesh.geometry.vertexCount === currentMesh.geometry.vertexCount - ) { - currentMesh.material.define('vertex', 'VERTEX_ANIMATION'); - currentMesh.ignorePreZ = true; - if (shadowDepthMaterial) { - shadowDepthMaterial.define('vertex', 'VERTEX_ANIMATION'); - } - for (var i = 0; i < mappingAttributes.length; i++) { - currentMesh.geometry.attributes[mappingAttributes[i][0]].value = - previousMesh.geometry.attributes[mappingAttributes[i][1]].value; - } - currentMesh.geometry.dirty(); - currentMesh.__percent = 0; - currentMesh.material.set('percent', 0); - currentMesh.stopAnimation(); - currentMesh.animate() - .when(duration, { - __percent: 1 - }) - .during(function () { - currentMesh.material.set('percent', currentMesh.__percent); - if (shadowDepthMaterial) { - shadowDepthMaterial.set('percent', currentMesh.__percent); - } - }) - .done(function () { - currentMesh.ignorePreZ = false; - currentMesh.material.undefine('vertex', 'VERTEX_ANIMATION'); - if (shadowDepthMaterial) { - shadowDepthMaterial.undefine('vertex', 'VERTEX_ANIMATION'); - } - }) - .start(easing); - } - else { - currentMesh.material.undefine('vertex', 'VERTEX_ANIMATION'); - if (shadowDepthMaterial) { - shadowDepthMaterial.undefine('vertex', 'VERTEX_ANIMATION'); - } - } -}; + /* WebGL-specific enums */ + UNPACK_FLIP_Y_WEBGL : 0x9240, + UNPACK_PREMULTIPLY_ALPHA_WEBGL : 0x9241, + CONTEXT_LOST_WEBGL : 0x9242, + UNPACK_COLORSPACE_CONVERSION_WEBGL : 0x9243, + BROWSER_DEFAULT_WEBGL : 0x9244, +}); -/* harmony default export */ __webpack_exports__["a"] = (graphicGL); /***/ }), -/* 3 */ +/* 12 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20); +/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. -var retrieve = { +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: - firstNotNull: function () { - for (var i = 0, len = arguments.length; i < len; i++) { - if (arguments[i] != null) { - return arguments[i]; - } - } - }, + * 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. - /** - * @param {module:echarts/data/List} data - * @param {Object} payload Contains dataIndex (means rawIndex) / dataIndexInside / name - * each of which can be Array or primary type. - * @return {number|Array.} dataIndex If not found, return undefined/null. - */ - queryDataIndex: function (data, payload) { - if (payload.dataIndexInside != null) { - return payload.dataIndexInside; - } - else if (payload.dataIndex != null) { - return __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(payload.dataIndex) - ? __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.map(payload.dataIndex, function (value) { - return data.indexOfRawIndex(value); - }) - : data.indexOfRawIndex(payload.dataIndex); - } - else if (payload.name != null) { - return __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(payload.name) - ? __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.map(payload.name, function (value) { - return data.indexOfName(value); - }) - : data.indexOfName(payload.name); - } - } -}; +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 HOLDER 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 USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* harmony default export */ __webpack_exports__["a"] = (retrieve); -/***/ }), -/* 4 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__); +/** + * @class 3 Dimensional Vector + * @name vec3 + */ -var vec3 = __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default.a.vec3; +var vec3 = {}; /** - * @constructor - * @alias clay.Vector3 - * @param {number} x - * @param {number} y - * @param {number} z + * Creates a new, empty vec3 + * + * @returns {vec3} a new 3D vector */ -var Vector3 = function(x, y, z) { - - x = x || 0; - y = y || 0; - z = z || 0; +vec3.create = function() { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](3); + out[0] = 0; + out[1] = 0; + out[2] = 0; + return out; +}; - /** - * Storage of Vector3, read and write of x, y, z will change the values in array - * All methods also operate on the array instead of x, y, z components - * @name array - * @type {Float32Array} - * @memberOf clay.Vector3# - */ - this.array = vec3.fromValues(x, y, z); +/** + * Creates a new vec3 initialized with values from an existing vector + * + * @param {vec3} a vector to clone + * @returns {vec3} a new 3D vector + */ +vec3.clone = function(a) { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](3); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + return out; +}; - /** - * Dirty flag is used by the Node to determine - * if the matrix is updated to latest - * @name _dirty - * @type {boolean} - * @memberOf clay.Vector3# - */ - this._dirty = true; +/** + * 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 + */ +vec3.fromValues = function(x, y, z) { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](3); + out[0] = x; + out[1] = y; + out[2] = z; + return out; }; -Vector3.prototype = { +/** + * Copy the values from one vec3 to another + * + * @param {vec3} out the receiving vector + * @param {vec3} a the source vector + * @returns {vec3} out + */ +vec3.copy = function(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + return out; +}; - constructor: Vector3, +/** + * 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 + */ +vec3.set = function(out, x, y, z) { + out[0] = x; + out[1] = y; + out[2] = z; + return out; +}; - /** - * Add b to self - * @param {clay.Vector3} b - * @return {clay.Vector3} - */ - add: function (b) { - vec3.add(this.array, this.array, b.array); - this._dirty = true; - return this; - }, +/** + * 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 + */ +vec3.add = function(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + return out; +}; - /** - * Set x, y and z components - * @param {number} x - * @param {number} y - * @param {number} z - * @return {clay.Vector3} - */ - set: function (x, y, z) { - this.array[0] = x; - this.array[1] = y; - this.array[2] = z; - this._dirty = true; - return this; - }, +/** + * 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 + */ +vec3.subtract = function(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + return out; +}; - /** - * Set x, y and z components from array - * @param {Float32Array|number[]} arr - * @return {clay.Vector3} - */ - setArray: function (arr) { - this.array[0] = arr[0]; - this.array[1] = arr[1]; - this.array[2] = arr[2]; +/** + * Alias for {@link vec3.subtract} + * @function + */ +vec3.sub = vec3.subtract; - this._dirty = true; - return this; - }, +/** + * 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 + */ +vec3.multiply = function(out, a, b) { + out[0] = a[0] * b[0]; + out[1] = a[1] * b[1]; + out[2] = a[2] * b[2]; + return out; +}; - /** - * Clone a new Vector3 - * @return {clay.Vector3} - */ - clone: function () { - return new Vector3(this.x, this.y, this.z); - }, +/** + * Alias for {@link vec3.multiply} + * @function + */ +vec3.mul = vec3.multiply; - /** - * Copy from b - * @param {clay.Vector3} b - * @return {clay.Vector3} - */ - copy: function (b) { - vec3.copy(this.array, b.array); - this._dirty = true; - return this; - }, - - /** - * Cross product of self and b, written to a Vector3 out - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {clay.Vector3} - */ - cross: function (a, b) { - vec3.cross(this.array, a.array, b.array); - this._dirty = true; - return this; - }, - - /** - * Alias for distance - * @param {clay.Vector3} b - * @return {number} - */ - dist: function (b) { - return vec3.dist(this.array, b.array); - }, - - /** - * Distance between self and b - * @param {clay.Vector3} b - * @return {number} - */ - distance: function (b) { - return vec3.distance(this.array, b.array); - }, - - /** - * Alias for divide - * @param {clay.Vector3} b - * @return {clay.Vector3} - */ - div: function (b) { - vec3.div(this.array, this.array, b.array); - this._dirty = true; - return this; - }, - - /** - * Divide self by b - * @param {clay.Vector3} b - * @return {clay.Vector3} - */ - divide: function (b) { - vec3.divide(this.array, this.array, b.array); - this._dirty = true; - return this; - }, - - /** - * Dot product of self and b - * @param {clay.Vector3} b - * @return {number} - */ - dot: function (b) { - return vec3.dot(this.array, b.array); - }, - - /** - * Alias of length - * @return {number} - */ - len: function () { - return vec3.len(this.array); - }, - - /** - * Calculate the length - * @return {number} - */ - length: function () { - return vec3.length(this.array); - }, - /** - * Linear interpolation between a and b - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @param {number} t - * @return {clay.Vector3} - */ - lerp: function (a, b, t) { - vec3.lerp(this.array, a.array, b.array, t); - this._dirty = true; - return this; - }, - - /** - * Minimum of self and b - * @param {clay.Vector3} b - * @return {clay.Vector3} - */ - min: function (b) { - vec3.min(this.array, this.array, b.array); - this._dirty = true; - return this; - }, - - /** - * Maximum of self and b - * @param {clay.Vector3} b - * @return {clay.Vector3} - */ - max: function (b) { - vec3.max(this.array, this.array, b.array); - this._dirty = true; - return this; - }, - - /** - * Alias for multiply - * @param {clay.Vector3} b - * @return {clay.Vector3} - */ - mul: function (b) { - vec3.mul(this.array, this.array, b.array); - this._dirty = true; - return this; - }, - - /** - * Mutiply self and b - * @param {clay.Vector3} b - * @return {clay.Vector3} - */ - multiply: function (b) { - vec3.multiply(this.array, this.array, b.array); - this._dirty = true; - return this; - }, - - /** - * Negate self - * @return {clay.Vector3} - */ - negate: function () { - vec3.negate(this.array, this.array); - this._dirty = true; - return this; - }, - - /** - * Normalize self - * @return {clay.Vector3} - */ - normalize: function () { - vec3.normalize(this.array, this.array); - this._dirty = true; - return this; - }, - - /** - * Generate random x, y, z components with a given scale - * @param {number} scale - * @return {clay.Vector3} - */ - random: function (scale) { - vec3.random(this.array, scale); - this._dirty = true; - return this; - }, - - /** - * Scale self - * @param {number} scale - * @return {clay.Vector3} - */ - scale: function (s) { - vec3.scale(this.array, this.array, s); - this._dirty = true; - return this; - }, - - /** - * Scale b and add to self - * @param {clay.Vector3} b - * @param {number} scale - * @return {clay.Vector3} - */ - scaleAndAdd: function (b, s) { - vec3.scaleAndAdd(this.array, this.array, b.array, s); - this._dirty = true; - return this; - }, - - /** - * Alias for squaredDistance - * @param {clay.Vector3} b - * @return {number} - */ - sqrDist: function (b) { - return vec3.sqrDist(this.array, b.array); - }, - - /** - * Squared distance between self and b - * @param {clay.Vector3} b - * @return {number} - */ - squaredDistance: function (b) { - return vec3.squaredDistance(this.array, b.array); - }, - - /** - * Alias for squaredLength - * @return {number} - */ - sqrLen: function () { - return vec3.sqrLen(this.array); - }, - - /** - * Squared length of self - * @return {number} - */ - squaredLength: function () { - return vec3.squaredLength(this.array); - }, - - /** - * Alias for subtract - * @param {clay.Vector3} b - * @return {clay.Vector3} - */ - sub: function (b) { - vec3.sub(this.array, this.array, b.array); - this._dirty = true; - return this; - }, - - /** - * Subtract b from self - * @param {clay.Vector3} b - * @return {clay.Vector3} - */ - subtract: function (b) { - vec3.subtract(this.array, this.array, b.array); - this._dirty = true; - return this; - }, - - /** - * Transform self with a Matrix3 m - * @param {clay.Matrix3} m - * @return {clay.Vector3} - */ - transformMat3: function (m) { - vec3.transformMat3(this.array, this.array, m.array); - this._dirty = true; - return this; - }, - - /** - * Transform self with a Matrix4 m - * @param {clay.Matrix4} m - * @return {clay.Vector3} - */ - transformMat4: function (m) { - vec3.transformMat4(this.array, this.array, m.array); - this._dirty = true; - return this; - }, - /** - * Transform self with a Quaternion q - * @param {clay.Quaternion} q - * @return {clay.Vector3} - */ - transformQuat: function (q) { - vec3.transformQuat(this.array, this.array, q.array); - this._dirty = true; - return this; - }, - - /** - * Trasnform self into projection space with m - * @param {clay.Matrix4} m - * @return {clay.Vector3} - */ - applyProjection: function (m) { - var v = this.array; - m = m.array; - - // Perspective projection - if (m[15] === 0) { - var w = -1 / v[2]; - v[0] = m[0] * v[0] * w; - v[1] = m[5] * v[1] * w; - v[2] = (m[10] * v[2] + m[14]) * w; - } - else { - v[0] = m[0] * v[0] + m[12]; - v[1] = m[5] * v[1] + m[13]; - v[2] = m[10] * v[2] + m[14]; - } - this._dirty = true; - - return this; - }, - - eulerFromQuat: function(q, order) { - Vector3.eulerFromQuat(this, q, order); - }, - - eulerFromMat3: function (m, order) { - Vector3.eulerFromMat3(this, m, order); - }, - - toString: function() { - return '[' + Array.prototype.join.call(this.array, ',') + ']'; - }, - - toArray: function () { - return Array.prototype.slice.call(this.array); - } +/** + * 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 + */ +vec3.divide = function(out, a, b) { + out[0] = a[0] / b[0]; + out[1] = a[1] / b[1]; + out[2] = a[2] / b[2]; + return out; }; -var defineProperty = Object.defineProperty; -// Getter and Setter -if (defineProperty) { - - var proto = Vector3.prototype; - /** - * @name x - * @type {number} - * @memberOf clay.Vector3 - * @instance - */ - defineProperty(proto, 'x', { - get: function () { - return this.array[0]; - }, - set: function (value) { - this.array[0] = value; - this._dirty = true; - } - }); - - /** - * @name y - * @type {number} - * @memberOf clay.Vector3 - * @instance - */ - defineProperty(proto, 'y', { - get: function () { - return this.array[1]; - }, - set: function (value) { - this.array[1] = value; - this._dirty = true; - } - }); - - /** - * @name z - * @type {number} - * @memberOf clay.Vector3 - * @instance - */ - defineProperty(proto, 'z', { - get: function () { - return this.array[2]; - }, - set: function (value) { - this.array[2] = value; - this._dirty = true; - } - }); -} - - -// Supply methods that are not in place +/** + * Alias for {@link vec3.divide} + * @function + */ +vec3.div = vec3.divide; /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {clay.Vector3} + * 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 */ -Vector3.add = function(out, a, b) { - vec3.add(out.array, a.array, b.array); - out._dirty = true; +vec3.min = function(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; }; /** - * @param {clay.Vector3} out - * @param {number} x - * @param {number} y - * @param {number} z - * @return {clay.Vector3} + * 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 */ -Vector3.set = function(out, x, y, z) { - vec3.set(out.array, x, y, z); - out._dirty = true; +vec3.max = function(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; }; /** - * @param {clay.Vector3} out - * @param {clay.Vector3} b - * @return {clay.Vector3} + * 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 */ -Vector3.copy = function(out, b) { - vec3.copy(out.array, b.array); - out._dirty = true; +vec3.scale = function(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; return out; }; /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {clay.Vector3} + * 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 */ -Vector3.cross = function(out, a, b) { - vec3.cross(out.array, a.array, b.array); - out._dirty = true; +vec3.scaleAndAdd = function(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; }; /** - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {number} + * 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 */ -Vector3.dist = function(a, b) { - return vec3.distance(a.array, b.array); +vec3.distance = function(a, b) { + var x = b[0] - a[0], + y = b[1] - a[1], + z = b[2] - a[2]; + return Math.sqrt(x*x + y*y + z*z); }; /** + * Alias for {@link vec3.distance} * @function - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {number} */ -Vector3.distance = Vector3.dist; +vec3.dist = vec3.distance; /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {clay.Vector3} + * 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 */ -Vector3.div = function(out, a, b) { - vec3.divide(out.array, a.array, b.array); - out._dirty = true; - return out; +vec3.squaredDistance = function(a, b) { + var x = b[0] - a[0], + y = b[1] - a[1], + z = b[2] - a[2]; + return x*x + y*y + z*z; }; /** + * Alias for {@link vec3.squaredDistance} * @function - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {clay.Vector3} */ -Vector3.divide = Vector3.div; +vec3.sqrDist = vec3.squaredDistance; /** - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {number} + * Calculates the length of a vec3 + * + * @param {vec3} a vector to calculate length of + * @returns {Number} length of a */ -Vector3.dot = function(a, b) { - return vec3.dot(a.array, b.array); +vec3.length = function (a) { + var x = a[0], + y = a[1], + z = a[2]; + return Math.sqrt(x*x + y*y + z*z); }; /** - * @param {clay.Vector3} a - * @return {number} + * Alias for {@link vec3.length} + * @function */ -Vector3.len = function(b) { - return vec3.length(b.array); -}; - -// Vector3.length = Vector3.len; +vec3.len = vec3.length; /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @param {number} t - * @return {clay.Vector3} + * Calculates the squared length of a vec3 + * + * @param {vec3} a vector to calculate squared length of + * @returns {Number} squared length of a */ -Vector3.lerp = function(out, a, b, t) { - vec3.lerp(out.array, a.array, b.array, t); - out._dirty = true; - return out; +vec3.squaredLength = function (a) { + var x = a[0], + y = a[1], + z = a[2]; + return x*x + y*y + z*z; }; + /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {clay.Vector3} + * Alias for {@link vec3.squaredLength} + * @function */ -Vector3.min = function(out, a, b) { - vec3.min(out.array, a.array, b.array); - out._dirty = true; - return out; -}; +vec3.sqrLen = vec3.squaredLength; /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {clay.Vector3} + * Negates the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to negate + * @returns {vec3} out */ -Vector3.max = function(out, a, b) { - vec3.max(out.array, a.array, b.array); - out._dirty = true; +vec3.negate = function(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; return out; }; + /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {clay.Vector3} + * Returns the inverse of the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to invert + * @returns {vec3} out */ -Vector3.mul = function(out, a, b) { - vec3.multiply(out.array, a.array, b.array); - out._dirty = true; - return out; +vec3.inverse = function(out, a) { + out[0] = 1.0 / a[0]; + out[1] = 1.0 / a[1]; + out[2] = 1.0 / a[2]; + return out; }; + /** - * @function - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {clay.Vector3} - */ -Vector3.multiply = Vector3.mul; -/** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @return {clay.Vector3} + * Normalize a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to normalize + * @returns {vec3} out */ -Vector3.negate = function(out, a) { - vec3.negate(out.array, a.array); - out._dirty = true; +vec3.normalize = function(out, a) { + var x = a[0], + y = a[1], + 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; }; + /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @return {clay.Vector3} + * 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 */ -Vector3.normalize = function(out, a) { - vec3.normalize(out.array, a.array); - out._dirty = true; - return out; +vec3.dot = function (a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; }; + /** - * @param {clay.Vector3} out - * @param {number} scale - * @return {clay.Vector3} + * 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 */ -Vector3.random = function(out, scale) { - vec3.random(out.array, scale); - out._dirty = true; +vec3.cross = function(out, a, b) { + var ax = a[0], ay = a[1], az = a[2], + 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; }; + /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {number} scale - * @return {clay.Vector3} + * 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 between the two inputs + * @returns {vec3} out */ -Vector3.scale = function(out, a, scale) { - vec3.scale(out.array, a.array, scale); - out._dirty = true; +vec3.lerp = function (out, a, b, t) { + var ax = a[0], + ay = a[1], + 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; }; + /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @param {number} scale - * @return {clay.Vector3} + * 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 */ -Vector3.scaleAndAdd = function(out, a, b, scale) { - vec3.scaleAndAdd(out.array, a.array, b.array, scale); - out._dirty = true; +vec3.random = function (out, scale) { + scale = scale || 1.0; + + var r = Object(__WEBPACK_IMPORTED_MODULE_0__common__["c" /* GLMAT_RANDOM */])() * 2.0 * Math.PI; + var z = (Object(__WEBPACK_IMPORTED_MODULE_0__common__["c" /* GLMAT_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; }; -/** - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {number} - */ -Vector3.sqrDist = function(a, b) { - return vec3.sqrDist(a.array, b.array); -}; -/** - * @function - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {number} - */ -Vector3.squaredDistance = Vector3.sqrDist; -/** - * @param {clay.Vector3} a - * @return {number} - */ -Vector3.sqrLen = function(a) { - return vec3.sqrLen(a.array); -}; -/** - * @function - * @param {clay.Vector3} a - * @return {number} - */ -Vector3.squaredLength = Vector3.sqrLen; /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {clay.Vector3} + * 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 */ -Vector3.sub = function(out, a, b) { - vec3.subtract(out.array, a.array, b.array); - out._dirty = true; +vec3.transformMat4 = function(out, a, m) { + var x = a[0], y = a[1], z = a[2], + 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; }; -/** - * @function - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @return {clay.Vector3} - */ -Vector3.subtract = Vector3.sub; /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {Matrix3} m - * @return {clay.Vector3} + * Transforms the vec3 with a mat3. + * + * @param {vec3} out the receiving vector + * @param {vec3} a the vector to transform + * @param {mat4} m the 3x3 matrix to transform with + * @returns {vec3} out */ -Vector3.transformMat3 = function(out, a, m) { - vec3.transformMat3(out.array, a.array, m.array); - out._dirty = true; +vec3.transformMat3 = function(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; }; /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Matrix4} m - * @return {clay.Vector3} + * Transforms the vec3 with a quat + * + * @param {vec3} out the receiving vector + * @param {vec3} a the vector to transform + * @param {quat} q quaternion to transform with + * @returns {vec3} out */ -Vector3.transformMat4 = function(out, a, m) { - vec3.transformMat4(out.array, a.array, m.array); - out._dirty = true; +vec3.transformQuat = function(out, a, q) { + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + + var x = a[0], y = a[1], z = a[2], + qx = q[0], qy = q[1], qz = q[2], qw = q[3], + + // calculate quat * vec + ix = qw * x + qy * z - qz * y, + iy = qw * y + qz * x - qx * z, + iz = qw * z + qx * y - qy * x, + 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; return out; }; + /** - * @param {clay.Vector3} out - * @param {clay.Vector3} a - * @param {clay.Quaternion} q - * @return {clay.Vector3} + * 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 */ -Vector3.transformQuat = function(out, a, q) { - vec3.transformQuat(out.array, a.array, q.array); - out._dirty = true; +vec3.rotateX = function(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; }; -function clamp(val, min, max) { - return val < min ? min : (val > max ? max : val); -} -var atan2 = Math.atan2; -var asin = Math.asin; -var abs = Math.abs; /** - * Convert quaternion to euler angle - * Quaternion must be normalized - * From three.js + * 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 */ -Vector3.eulerFromQuat = function (out, q, order) { - out._dirty = true; - q = q.array; +vec3.rotateY = function(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]; - var target = out.array; - 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 w2 = w * w; + //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); - var order = (order || 'XYZ').toUpperCase(); + //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; - switch (order) { - case 'XYZ': - target[0] = atan2(2 * (x * w - y * z), (w2 - x2 - y2 + z2)); - target[1] = asin(clamp(2 * (x * z + y * w), - 1, 1)); - target[2] = atan2(2 * (z * w - x * y), (w2 + x2 - y2 - z2)); - break; - case 'YXZ': - target[0] = asin(clamp(2 * (x * w - y * z), - 1, 1)); - target[1] = atan2(2 * (x * z + y * w), (w2 - x2 - y2 + z2)); - target[2] = atan2(2 * (x * y + z * w), (w2 - x2 + y2 - z2)); - break; - case 'ZXY': - target[0] = asin(clamp(2 * (x * w + y * z), - 1, 1)); - target[1] = atan2(2 * (y * w - z * x), (w2 - x2 - y2 + z2)); - target[2] = atan2(2 * (z * w - x * y), (w2 - x2 + y2 - z2)); - break; - case 'ZYX': - target[0] = atan2(2 * (x * w + z * y), (w2 - x2 - y2 + z2)); - target[1] = asin(clamp(2 * (y * w - x * z), - 1, 1)); - target[2] = atan2(2 * (x * y + z * w), (w2 + x2 - y2 - z2)); - break; - case 'YZX': - target[0] = atan2(2 * (x * w - z * y), (w2 - x2 + y2 - z2)); - target[1] = atan2(2 * (y * w - x * z), (w2 + x2 - y2 - z2)); - target[2] = asin(clamp(2 * (x * y + z * w), - 1, 1)); - break; - case 'XZY': - target[0] = atan2(2 * (x * w + y * z), (w2 - x2 + y2 - z2)); - target[1] = atan2(2 * (x * z + y * w), (w2 + x2 - y2 - z2)); - target[2] = asin(clamp(2 * (z * w - x * y), - 1, 1)); - break; - default: - console.warn('Unkown order: ' + order); - } return out; }; /** - * Convert rotation matrix to euler angle - * from three.js + * 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 */ -Vector3.eulerFromMat3 = function (out, m, order) { - // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) - var te = m.array; - var m11 = te[0], m12 = te[3], m13 = te[6]; - var m21 = te[1], m22 = te[4], m23 = te[7]; - var m31 = te[2], m32 = te[5], m33 = te[8]; - var target = out.array; +vec3.rotateZ = function(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]; - var order = (order || 'XYZ').toUpperCase(); + //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]; - switch (order) { - case 'XYZ': - target[1] = asin(clamp(m13, -1, 1)); - if (abs(m13) < 0.99999) { - target[0] = atan2(-m23, m33); - target[2] = atan2(-m12, m11); - } - else { - target[0] = atan2(m32, m22); - target[2] = 0; - } - break; - case 'YXZ': - target[0] = asin(-clamp(m23, -1, 1)); - if (abs(m23) < 0.99999) { - target[1] = atan2(m13, m33); - target[2] = atan2(m21, m22); - } - else { - target[1] = atan2(-m31, m11); - target[2] = 0; - } - break; - case 'ZXY': - target[0] = asin(clamp(m32, -1, 1)); - if (abs(m32) < 0.99999) { - target[1] = atan2(-m31, m33); - target[2] = atan2(-m12, m22); - } - else { - target[1] = 0; - target[2] = atan2(m21, m11); - } - break; - case 'ZYX': - target[1] = asin(-clamp(m31, -1, 1)); - if (abs(m31) < 0.99999) { - target[0] = atan2(m32, m33); - target[2] = atan2(m21, m11); - } - else { - target[0] = 0; - target[2] = atan2(-m12, m22); - } - break; - case 'YZX': - target[2] = asin(clamp(m21, -1, 1)); - if (abs(m21) < 0.99999) { - target[0] = atan2(-m23, m22); - target[1] = atan2(-m31, m11); - } - else { - target[0] = 0; - target[1] = atan2(m13, m33); - } - break; - case 'XZY': - target[2] = asin(-clamp(m12, -1, 1)); - if (abs(m12) < 0.99999) { - target[0] = atan2(m32, m22); - target[1] = atan2(m13, m11); - } - else { - target[0] = atan2(-m23, m33); - target[1] = 0; - } - break; - default: - console.warn('Unkown order: ' + order); - } - out._dirty = true; + //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; return out; }; -// TODO return new. -/** - * @type {clay.Vector3} - */ -Vector3.POSITIVE_X = new Vector3(1, 0, 0); -/** - * @type {clay.Vector3} - */ -Vector3.NEGATIVE_X = new Vector3(-1, 0, 0); -/** - * @type {clay.Vector3} - */ -Vector3.POSITIVE_Y = new Vector3(0, 1, 0); -/** - * @type {clay.Vector3} - */ -Vector3.NEGATIVE_Y = new Vector3(0, -1, 0); -/** - * @type {clay.Vector3} - */ -Vector3.POSITIVE_Z = new Vector3(0, 0, 1); -/** - * @type {clay.Vector3} - */ -Vector3.NEGATIVE_Z = new Vector3(0, 0, -1); -/** - * @type {clay.Vector3} - */ -Vector3.UP = new Vector3(0, 1, 0); /** - * @type {clay.Vector3} + * 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 */ -Vector3.ZERO = new Vector3(0, 0, 0); +vec3.forEach = (function() { + var vec = vec3.create(); -/* harmony default export */ __webpack_exports__["a"] = (Vector3); + return function(a, stride, offset, count, fn, arg) { + var i, l; + if(!stride) { + stride = 3; + } + if(!offset) { + offset = 0; + } -/***/ }), -/* 5 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + if(count) { + l = Math.min((count * stride) + offset, a.length); + } else { + l = a.length; + } -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_util__ = __webpack_require__(67); + 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; + }; +})(); +/** + * 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 + */ +vec3.angle = function(a, b) { -var isPowerOfTwo = __WEBPACK_IMPORTED_MODULE_2__math_util__["a" /* default */].isPowerOfTwo; + var tempA = vec3.fromValues(a[0], a[1], a[2]); + var tempB = vec3.fromValues(b[0], b[1], b[2]); -function nearestPowerOfTwo(val) { - return Math.pow(2, Math.round(Math.log(val) / Math.LN2)); -} -function convertTextureToPowerOfTwo(texture, canvas) { - // var canvas = document.createElement('canvas'); - var width = nearestPowerOfTwo(texture.width); - var height = nearestPowerOfTwo(texture.height); - canvas = canvas || document.createElement('canvas'); - canvas.width = width; - canvas.height = height; - var ctx = canvas.getContext('2d'); - ctx.drawImage(texture.image, 0, 0, width, height); + vec3.normalize(tempA, tempA); + vec3.normalize(tempB, tempB); - return canvas; -} + var cosine = vec3.dot(tempA, tempB); + + if(cosine > 1.0){ + return 0; + } else { + return Math.acos(cosine); + } +}; + +/* harmony default export */ __webpack_exports__["a"] = (vec3); + +/***/ }), +/* 13 */ +/***/ (function(module, exports) { /** - * @constructor clay.Texture2D - * @extends clay.Texture - * - * @example - * ... - * var mat = new clay.Material({ - * shader: clay.shader.library.get('clay.phong', 'diffuseMap') - * }); - * var diffuseMap = new clay.Texture2D(); - * diffuseMap.load('assets/textures/diffuse.jpg'); - * mat.set('diffuseMap', diffuseMap); - * ... - * diffuseMap.success(function () { - * // Wait for the diffuse texture loaded - * animation.on('frame', function (frameTime) { - * renderer.render(scene, camera); - * }); - * }); + * @module zrender/core/util */ -var Texture2D = __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].extend(function () { - return /** @lends clay.Texture2D# */ { - /** - * @type {?HTMLImageElement|HTMLCanvasElemnet} - */ - image: null, - /** - * Pixels data. Will be ignored if image is set. - * @type {?Uint8Array|Float32Array} - */ - pixels: null, - /** - * @type {Array.} - * @example - * [{ - * image: mipmap0, - * pixels: null - * }, { - * image: mipmap1, - * pixels: null - * }, ....] - */ - mipmaps: [], +// 用于处理merge时无法遍历Date等对象的问题 +var BUILTIN_OBJECT = { + '[object Function]': 1, + '[object RegExp]': 1, + '[object Date]': 1, + '[object Error]': 1, + '[object CanvasGradient]': 1, + '[object CanvasPattern]': 1, + // For node-canvas + '[object Image]': 1, + '[object Canvas]': 1 +}; +var TYPED_ARRAY = { + '[object Int8Array]': 1, + '[object Uint8Array]': 1, + '[object Uint8ClampedArray]': 1, + '[object Int16Array]': 1, + '[object Uint16Array]': 1, + '[object Int32Array]': 1, + '[object Uint32Array]': 1, + '[object Float32Array]': 1, + '[object Float64Array]': 1 +}; +var objToString = Object.prototype.toString; +var arrayProto = Array.prototype; +var nativeForEach = arrayProto.forEach; +var nativeFilter = arrayProto.filter; +var nativeSlice = arrayProto.slice; +var nativeMap = arrayProto.map; +var nativeReduce = arrayProto.reduce; // Avoid assign to an exported variable, for transforming to cjs. - /** - * If convert texture to power-of-two - * @type {boolean} - */ - convertToPOT: false - }; -}, { +var methods = {}; - textureType: 'texture2D', +function $override(name, fn) { + // Clear ctx instance for different environment + if (name === 'createCanvas') { + _ctx = null; + } - update: function (renderer) { + methods[name] = fn; +} +/** + * Those data types can be cloned: + * Plain object, Array, TypedArray, number, string, null, undefined. + * Those data types will be assgined using the orginal data: + * BUILTIN_OBJECT + * Instance of user defined class will be cloned to a plain object, without + * properties in prototype. + * Other data types is not supported (not sure what will happen). + * + * Caution: do not support clone Date, for performance consideration. + * (There might be a large number of date in `series.data`). + * So date should not be modified in and out of echarts. + * + * @param {*} source + * @return {*} new + */ - var _gl = renderer.gl; - _gl.bindTexture(_gl.TEXTURE_2D, this._cache.get('webgl_texture')); - this.updateCommon(renderer); +function clone(source) { + if (source == null || typeof source != 'object') { + return source; + } - var glFormat = this.format; - var glType = this.type; + var result = source; + var typeStr = objToString.call(source); - // Convert to pot is only available when using image/canvas/video element. - var convertToPOT = !!(this.convertToPOT - && !this.mipmaps.length && this.image - && (this.wrapS === __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].REPEAT || this.wrapT === __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].REPEAT) - && this.NPOT - ); + if (typeStr === '[object Array]') { + if (!isPrimitive(source)) { + result = []; - _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, convertToPOT ? this.wrapS : this.getAvailableWrapS()); - _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, convertToPOT ? this.wrapT : this.getAvailableWrapT()); + for (var i = 0, len = source.length; i < len; i++) { + result[i] = clone(source[i]); + } + } + } else if (TYPED_ARRAY[typeStr]) { + if (!isPrimitive(source)) { + var Ctor = source.constructor; - _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_MAG_FILTER, convertToPOT ? this.magFilter : this.getAvailableMagFilter()); - _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, convertToPOT ? this.minFilter : this.getAvailableMinFilter()); + if (source.constructor.from) { + result = Ctor.from(source); + } else { + result = new Ctor(source.length); - var anisotropicExt = renderer.getGLExtension('EXT_texture_filter_anisotropic'); - if (anisotropicExt && this.anisotropic > 1) { - _gl.texParameterf(_gl.TEXTURE_2D, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, this.anisotropic); + for (var i = 0, len = source.length; i < len; i++) { + result[i] = clone(source[i]); } + } + } + } else if (!BUILTIN_OBJECT[typeStr] && !isPrimitive(source) && !isDom(source)) { + result = {}; - // Fallback to float type if browser don't have half float extension - if (glType === 36193) { - var halfFloatExt = renderer.getGLExtension('OES_texture_half_float'); - if (!halfFloatExt) { - glType = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FLOAT; - } - } + for (var key in source) { + if (source.hasOwnProperty(key)) { + result[key] = clone(source[key]); + } + } + } - if (this.mipmaps.length) { - var width = this.width; - var height = this.height; - for (var i = 0; i < this.mipmaps.length; i++) { - var mipmap = this.mipmaps[i]; - this._updateTextureData(_gl, mipmap, i, width, height, glFormat, glType, false); - width /= 2; - height /= 2; - } - } - else { - this._updateTextureData(_gl, this, 0, this.width, this.height, glFormat, glType, convertToPOT); + return result; +} +/** + * @memberOf module:zrender/core/util + * @param {*} target + * @param {*} source + * @param {boolean} [overwrite=false] + */ - if (this.useMipmap && (!this.NPOT || convertToPOT)) { - _gl.generateMipmap(_gl.TEXTURE_2D); - } - } - _gl.bindTexture(_gl.TEXTURE_2D, null); - }, +function merge(target, source, overwrite) { + // We should escapse that source is string + // and enter for ... in ... + if (!isObject(source) || !isObject(target)) { + return overwrite ? clone(source) : target; + } - _updateTextureData: function (_gl, data, level, width, height, glFormat, glType, convertToPOT) { - if (data.image) { - var imgData = data.image; - if (convertToPOT) { - this._potCanvas = convertTextureToPowerOfTwo(this, this._potCanvas); - imgData = this._potCanvas; - } - _gl.texImage2D(_gl.TEXTURE_2D, level, glFormat, glFormat, glType, imgData); - } - else { - // Can be used as a blank texture when writing render to texture(RTT) - if ( - glFormat <= __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].COMPRESSED_RGBA_S3TC_DXT5_EXT - && glFormat >= __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].COMPRESSED_RGB_S3TC_DXT1_EXT - ) { - _gl.compressedTexImage2D(_gl.TEXTURE_2D, level, glFormat, width, height, 0, data.pixels); - } - else { - // Is a render target if pixels is null - _gl.texImage2D(_gl.TEXTURE_2D, level, glFormat, width, height, 0, glFormat, glType, data.pixels); - } - } - }, + for (var key in source) { + if (source.hasOwnProperty(key)) { + var targetProp = target[key]; + var sourceProp = source[key]; - /** - * @param {clay.Renderer} renderer - * @memberOf clay.Texture2D.prototype - */ - generateMipmap: function (renderer) { - var _gl = renderer.gl; - if (this.useMipmap && !this.NPOT) { - _gl.bindTexture(_gl.TEXTURE_2D, this._cache.get('webgl_texture')); - _gl.generateMipmap(_gl.TEXTURE_2D); - } - }, + if (isObject(sourceProp) && isObject(targetProp) && !isArray(sourceProp) && !isArray(targetProp) && !isDom(sourceProp) && !isDom(targetProp) && !isBuiltInObject(sourceProp) && !isBuiltInObject(targetProp) && !isPrimitive(sourceProp) && !isPrimitive(targetProp)) { + // 如果需要递归覆盖,就递归调用merge + merge(targetProp, sourceProp, overwrite); + } else if (overwrite || !(key in target)) { + // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况 + // NOTE,在 target[key] 不存在的时候也是直接覆盖 + target[key] = clone(source[key], true); + } + } + } - isPowerOfTwo: function () { - return isPowerOfTwo(this.width) && isPowerOfTwo(this.height); - }, + return target; +} +/** + * @param {Array} targetAndSources The first item is target, and the rests are source. + * @param {boolean} [overwrite=false] + * @return {*} target + */ - isRenderable: function () { - if (this.image) { - return this.image.nodeName === 'CANVAS' - || this.image.nodeName === 'VIDEO' - || this.image.complete; - } - else { - return !!(this.width && this.height); - } - }, - bind: function (renderer) { - renderer.gl.bindTexture(renderer.gl.TEXTURE_2D, this.getWebGLTexture(renderer)); - }, +function mergeAll(targetAndSources, overwrite) { + var result = targetAndSources[0]; - unbind: function (renderer) { - renderer.gl.bindTexture(renderer.gl.TEXTURE_2D, null); - }, + for (var i = 1, len = targetAndSources.length; i < len; i++) { + result = merge(result, targetAndSources[i], overwrite); + } - load: function (src, crossOrigin) { - var image = new Image(); - if (crossOrigin) { - image.crossOrigin = crossOrigin; - } - var self = this; - image.onload = function () { - self.dirty(); - self.trigger('success', self); - image.onload = null; - }; - image.onerror = function () { - self.trigger('error', self); - image.onerror = null; - }; + return result; +} +/** + * @param {*} target + * @param {*} source + * @memberOf module:zrender/core/util + */ - image.src = src; - this.image = image; - return this; +function extend(target, source) { + for (var key in source) { + if (source.hasOwnProperty(key)) { + target[key] = source[key]; } -}); + } -Object.defineProperty(Texture2D.prototype, 'width', { - get: function () { - if (this.image) { - return this.image.width; - } - return this._width; - }, - set: function (value) { - if (this.image) { - console.warn('Texture from image can\'t set width'); - } - else { - if (this._width !== value) { - this.dirty(); - } - this._width = value; - } + return target; +} +/** + * @param {*} target + * @param {*} source + * @param {boolean} [overlay=false] + * @memberOf module:zrender/core/util + */ + + +function defaults(target, source, overlay) { + for (var key in source) { + if (source.hasOwnProperty(key) && (overlay ? source[key] != null : target[key] == null)) { + target[key] = source[key]; } -}); -Object.defineProperty(Texture2D.prototype, 'height', { - get: function () { - if (this.image) { - return this.image.height; - } - return this._height; - }, - set: function (value) { - if (this.image) { - console.warn('Texture from image can\'t set height'); - } - else { - if (this._height !== value) { - this.dirty(); - } - this._height = value; - } + } + + return target; +} + +var createCanvas = function () { + return methods.createCanvas(); +}; + +methods.createCanvas = function () { + return document.createElement('canvas'); +}; // FIXME + + +var _ctx; + +function getContext() { + if (!_ctx) { + // Use util.createCanvas instead of createCanvas + // because createCanvas may be overwritten in different environment + _ctx = createCanvas().getContext('2d'); + } + + return _ctx; +} +/** + * 查询数组中元素的index + * @memberOf module:zrender/core/util + */ + + +function indexOf(array, value) { + if (array) { + if (array.indexOf) { + return array.indexOf(value); } -}); -/* harmony default export */ __webpack_exports__["a"] = (Texture2D); + for (var i = 0, len = array.length; i < len; i++) { + if (array[i] === value) { + return i; + } + } + } + return -1; +} +/** + * 构造类继承关系 + * + * @memberOf module:zrender/core/util + * @param {Function} clazz 源类 + * @param {Function} baseClazz 基类 + */ -/***/ }), -/* 6 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_Cache__ = __webpack_require__(48); +function inherits(clazz, baseClazz) { + var clazzPrototype = clazz.prototype; + + function F() {} + + F.prototype = baseClazz.prototype; + clazz.prototype = new F(); + + for (var prop in clazzPrototype) { + clazz.prototype[prop] = clazzPrototype[prop]; + } + + clazz.prototype.constructor = clazz; + clazz.superClass = baseClazz; +} /** - * Base class for all textures like compressed texture, texture2d, texturecube - * TODO mapping + * @memberOf module:zrender/core/util + * @param {Object|Function} target + * @param {Object|Function} sorce + * @param {boolean} overlay + */ + + +function mixin(target, source, overlay) { + target = 'prototype' in target ? target.prototype : target; + source = 'prototype' in source ? source.prototype : source; + defaults(target, source, overlay); +} +/** + * Consider typed array. + * @param {Array|TypedArray} data */ +function isArrayLike(data) { + if (!data) { + return; + } + if (typeof data == 'string') { + return false; + } + return typeof data.length == 'number'; +} /** - * @constructor - * @alias clay.Texture - * @extends clay.core.Base + * 数组或对象遍历 + * @memberOf module:zrender/core/util + * @param {Object|Array} obj + * @param {Function} cb + * @param {*} [context] */ -var Texture = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend( /** @lends clay.Texture# */ { - /** - * Texture width, readonly when the texture source is image - * @type {number} - */ - width: 512, - /** - * Texture height, readonly when the texture source is image - * @type {number} - */ - height: 512, - /** - * Texel data type. - * Possible values: - * + {@link clay.Texture.UNSIGNED_BYTE} - * + {@link clay.Texture.HALF_FLOAT} - * + {@link clay.Texture.FLOAT} - * + {@link clay.Texture.UNSIGNED_INT_24_8_WEBGL} - * + {@link clay.Texture.UNSIGNED_INT} - * @type {number} - */ - type: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_BYTE, - /** - * Format of texel data - * Possible values: - * + {@link clay.Texture.RGBA} - * + {@link clay.Texture.DEPTH_COMPONENT} - * + {@link clay.Texture.DEPTH_STENCIL} - * @type {number} - */ - format: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].RGBA, - /** - * Texture wrap. Default to be REPEAT. - * Possible values: - * + {@link clay.Texture.CLAMP_TO_EDGE} - * + {@link clay.Texture.REPEAT} - * + {@link clay.Texture.MIRRORED_REPEAT} - * @type {number} - */ - wrapS: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].REPEAT, - /** - * Texture wrap. Default to be REPEAT. - * Possible values: - * + {@link clay.Texture.CLAMP_TO_EDGE} - * + {@link clay.Texture.REPEAT} - * + {@link clay.Texture.MIRRORED_REPEAT} - * @type {number} - */ - wrapT: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].REPEAT, - /** - * Possible values: - * + {@link clay.Texture.NEAREST} - * + {@link clay.Texture.LINEAR} - * + {@link clay.Texture.NEAREST_MIPMAP_NEAREST} - * + {@link clay.Texture.LINEAR_MIPMAP_NEAREST} - * + {@link clay.Texture.NEAREST_MIPMAP_LINEAR} - * + {@link clay.Texture.LINEAR_MIPMAP_LINEAR} - * @type {number} - */ - minFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR, - /** - * Possible values: - * + {@link clay.Texture.NEAREST} - * + {@link clay.Texture.LINEAR} - * @type {number} - */ - magFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR, - /** - * If enable mimap. - * @type {boolean} - */ - useMipmap: true, - - /** - * Anisotropic filtering, enabled if value is larger than 1 - * @see https://developer.mozilla.org/en-US/docs/Web/API/EXT_texture_filter_anisotropic - * @type {number} - */ - anisotropic: 1, - // pixelStorei parameters, not available when texture is used as render target - // http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml - /** - * If flip in y axis for given image source - * @type {boolean} - * @default true - */ - flipY: true, - - /** - * A flag to indicate if texture source is sRGB - */ - sRGB: true, - /** - * @type {number} - * @default 4 - */ - unpackAlignment: 4, - /** - * @type {boolean} - * @default false - */ - premultiplyAlpha: false, - - /** - * Dynamic option for texture like video - * @type {boolean} - */ - dynamic: false, - NPOT: false, - - // PENDING - // Init it here to avoid deoptimization when it's assigned in application dynamically - __used: 0 -}, function () { - this._cache = new __WEBPACK_IMPORTED_MODULE_2__core_Cache__["a" /* default */](); -}, -/** @lends clay.Texture.prototype */ -{ +function each(obj, cb, context) { + if (!(obj && cb)) { + return; + } - getWebGLTexture: function (renderer) { - var _gl = renderer.gl; - var cache = this._cache; - cache.use(renderer.__uid__); + if (obj.forEach && obj.forEach === nativeForEach) { + obj.forEach(cb, context); + } else if (obj.length === +obj.length) { + for (var i = 0, len = obj.length; i < len; i++) { + cb.call(context, obj[i], i, obj); + } + } else { + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + cb.call(context, obj[key], key, obj); + } + } + } +} +/** + * 数组映射 + * @memberOf module:zrender/core/util + * @param {Array} obj + * @param {Function} cb + * @param {*} [context] + * @return {Array} + */ - if (cache.miss('webgl_texture')) { - // In a new gl context, create new texture and set dirty true - cache.put('webgl_texture', _gl.createTexture()); - } - if (this.dynamic) { - this.update(renderer); - } - else if (cache.isDirty()) { - this.update(renderer); - cache.fresh(); - } - return cache.get('webgl_texture'); - }, +function map(obj, cb, context) { + if (!(obj && cb)) { + return; + } - bind: function () {}, - unbind: function () {}, + if (obj.map && obj.map === nativeMap) { + return obj.map(cb, context); + } else { + var result = []; - /** - * Mark texture is dirty and update in the next frame - */ - dirty: function () { - if (this._cache) { - this._cache.dirtyAll(); - } - }, + for (var i = 0, len = obj.length; i < len; i++) { + result.push(cb.call(context, obj[i], i, obj)); + } - update: function (renderer) {}, + return result; + } +} +/** + * @memberOf module:zrender/core/util + * @param {Array} obj + * @param {Function} cb + * @param {Object} [memo] + * @param {*} [context] + * @return {Array} + */ - // Update the common parameters of texture - updateCommon: function (renderer) { - var _gl = renderer.gl; - _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, this.flipY); - _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha); - _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, this.unpackAlignment); - // Use of none-power of two texture - // http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences - if (this.format === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DEPTH_COMPONENT) { - this.useMipmap = false; - } +function reduce(obj, cb, memo, context) { + if (!(obj && cb)) { + return; + } - var sRGBExt = renderer.getGLExtension('EXT_sRGB'); - // Fallback - if (this.format === Texture.SRGB && !sRGBExt) { - this.format = Texture.RGB; - } - if (this.format === Texture.SRGB_ALPHA && !sRGBExt) { - this.format = Texture.RGBA; - } + if (obj.reduce && obj.reduce === nativeReduce) { + return obj.reduce(cb, memo, context); + } else { + for (var i = 0, len = obj.length; i < len; i++) { + memo = cb.call(context, memo, obj[i], i, obj); + } - this.NPOT = !this.isPowerOfTwo(); - }, + return memo; + } +} +/** + * 数组过滤 + * @memberOf module:zrender/core/util + * @param {Array} obj + * @param {Function} cb + * @param {*} [context] + * @return {Array} + */ - getAvailableWrapS: function () { - if (this.NPOT) { - return __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE; - } - return this.wrapS; - }, - getAvailableWrapT: function () { - if (this.NPOT) { - return __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE; - } - return this.wrapT; - }, - getAvailableMinFilter: function () { - var minFilter = this.minFilter; - if (this.NPOT || !this.useMipmap) { - if (minFilter === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_NEAREST || - minFilter === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_LINEAR - ) { - return __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST; - } - else if (minFilter === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR || - minFilter === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_NEAREST - ) { - return __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR; - } - else { - return minFilter; - } - } - else { - return minFilter; - } - }, - getAvailableMagFilter: function () { - return this.magFilter; - }, - nextHighestPowerOfTwo: function (x) { - --x; - for (var i = 1; i < 32; i <<= 1) { - x = x | x >> i; - } - return x + 1; - }, - /** - * @param {clay.Renderer} renderer - */ - dispose: function (renderer) { +function filter(obj, cb, context) { + if (!(obj && cb)) { + return; + } - var cache = this._cache; + if (obj.filter && obj.filter === nativeFilter) { + return obj.filter(cb, context); + } else { + var result = []; - cache.use(renderer.__uid__); + for (var i = 0, len = obj.length; i < len; i++) { + if (cb.call(context, obj[i], i, obj)) { + result.push(obj[i]); + } + } - var webglTexture = cache.get('webgl_texture'); - if (webglTexture){ - renderer.gl.deleteTexture(webglTexture); - } - cache.deleteContext(renderer.__uid__); + return result; + } +} +/** + * 数组项查找 + * @memberOf module:zrender/core/util + * @param {Array} obj + * @param {Function} cb + * @param {*} [context] + * @return {*} + */ - }, - /** - * Test if image of texture is valid and loaded. - * @return {boolean} - */ - isRenderable: function () {}, - /** - * Test if texture size is power of two - * @return {boolean} - */ - isPowerOfTwo: function () {} -}); +function find(obj, cb, context) { + if (!(obj && cb)) { + return; + } -Object.defineProperty(Texture.prototype, 'width', { - get: function () { - return this._width; - }, - set: function (value) { - this._width = value; - } -}); -Object.defineProperty(Texture.prototype, 'height', { - get: function () { - return this._height; - }, - set: function (value) { - this._height = value; + for (var i = 0, len = obj.length; i < len; i++) { + if (cb.call(context, obj[i], i, obj)) { + return obj[i]; } -}); - -/* DataType */ - -/** - * @type {number} - */ -Texture.BYTE = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].BYTE; -/** - * @type {number} - */ -Texture.UNSIGNED_BYTE = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_BYTE; -/** - * @type {number} - */ -Texture.SHORT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].SHORT; -/** - * @type {number} - */ -Texture.UNSIGNED_SHORT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_SHORT; -/** - * @type {number} - */ -Texture.INT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].INT; -/** - * @type {number} - */ -Texture.UNSIGNED_INT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_INT; + } +} /** - * @type {number} + * @memberOf module:zrender/core/util + * @param {Function} func + * @param {*} context + * @return {Function} */ -Texture.FLOAT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FLOAT; + + +function bind(func, context) { + var args = nativeSlice.call(arguments, 2); + return function () { + return func.apply(context, args.concat(nativeSlice.call(arguments))); + }; +} /** - * @type {number} + * @memberOf module:zrender/core/util + * @param {Function} func + * @return {Function} */ -Texture.HALF_FLOAT = 0x8D61; + +function curry(func) { + var args = nativeSlice.call(arguments, 1); + return function () { + return func.apply(this, args.concat(nativeSlice.call(arguments))); + }; +} /** - * UNSIGNED_INT_24_8_WEBGL for WEBGL_depth_texture extension - * @type {number} + * @memberOf module:zrender/core/util + * @param {*} value + * @return {boolean} */ -Texture.UNSIGNED_INT_24_8_WEBGL = 34042; -/* PixelFormat */ + +function isArray(value) { + return objToString.call(value) === '[object Array]'; +} /** - * @type {number} + * @memberOf module:zrender/core/util + * @param {*} value + * @return {boolean} */ -Texture.DEPTH_COMPONENT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DEPTH_COMPONENT; + + +function isFunction(value) { + return typeof value === 'function'; +} /** - * @type {number} + * @memberOf module:zrender/core/util + * @param {*} value + * @return {boolean} */ -Texture.DEPTH_STENCIL = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DEPTH_STENCIL; + + +function isString(value) { + return objToString.call(value) === '[object String]'; +} /** - * @type {number} + * @memberOf module:zrender/core/util + * @param {*} value + * @return {boolean} */ -Texture.ALPHA = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].ALPHA; + + +function isObject(value) { + // Avoid a V8 JIT bug in Chrome 19-20. + // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. + var type = typeof value; + return type === 'function' || !!value && type == 'object'; +} /** - * @type {number} + * @memberOf module:zrender/core/util + * @param {*} value + * @return {boolean} */ -Texture.RGB = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].RGB; + + +function isBuiltInObject(value) { + return !!BUILTIN_OBJECT[objToString.call(value)]; +} /** - * @type {number} + * @memberOf module:zrender/core/util + * @param {*} value + * @return {boolean} */ -Texture.RGBA = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].RGBA; + + +function isTypedArray(value) { + return !!TYPED_ARRAY[objToString.call(value)]; +} /** - * @type {number} + * @memberOf module:zrender/core/util + * @param {*} value + * @return {boolean} */ -Texture.LUMINANCE = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LUMINANCE; + + +function isDom(value) { + return typeof value === 'object' && typeof value.nodeType === 'number' && typeof value.ownerDocument === 'object'; +} /** - * @type {number} + * Whether is exactly NaN. Notice isNaN('a') returns true. + * @param {*} value + * @return {boolean} */ -Texture.LUMINANCE_ALPHA = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LUMINANCE_ALPHA; + +function eqNaN(value) { + return value !== value; +} /** - * @see https://www.khronos.org/registry/webgl/extensions/EXT_sRGB/ - * @type {number} + * If value1 is not null, then return value1, otherwise judget rest of values. + * Low performance. + * @memberOf module:zrender/core/util + * @return {*} Final value */ -Texture.SRGB = 0x8C40; + + +function retrieve(values) { + for (var i = 0, len = arguments.length; i < len; i++) { + if (arguments[i] != null) { + return arguments[i]; + } + } +} + +function retrieve2(value0, value1) { + return value0 != null ? value0 : value1; +} + +function retrieve3(value0, value1, value2) { + return value0 != null ? value0 : value1 != null ? value1 : value2; +} /** - * @see https://www.khronos.org/registry/webgl/extensions/EXT_sRGB/ - * @type {number} + * @memberOf module:zrender/core/util + * @param {Array} arr + * @param {number} startIndex + * @param {number} endIndex + * @return {Array} */ -Texture.SRGB_ALPHA = 0x8C42; -/* Compressed Texture */ -Texture.COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; -Texture.COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1; -Texture.COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; -Texture.COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; -/* TextureMagFilter */ +function slice() { + return Function.call.apply(nativeSlice, arguments); +} /** - * @type {number} - */ -Texture.NEAREST = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST; -/** - * @type {number} + * Normalize css liked array configuration + * e.g. + * 3 => [3, 3, 3, 3] + * [4, 2] => [4, 2, 4, 2] + * [4, 3, 2] => [4, 3, 2, 3] + * @param {number|Array.} val + * @return {Array.} */ -Texture.LINEAR = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR; -/* TextureMinFilter */ -/** - * @type {number} - */ -Texture.NEAREST_MIPMAP_NEAREST = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_NEAREST; -/** - * @type {number} - */ -Texture.LINEAR_MIPMAP_NEAREST = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_NEAREST; -/** - * @type {number} - */ -Texture.NEAREST_MIPMAP_LINEAR = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_LINEAR; -/** - * @type {number} - */ -Texture.LINEAR_MIPMAP_LINEAR = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR; -/* TextureWrapMode */ -/** - * @type {number} - */ -Texture.REPEAT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].REPEAT; -/** - * @type {number} - */ -Texture.CLAMP_TO_EDGE = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE; +function normalizeCssArray(val) { + if (typeof val === 'number') { + return [val, val, val, val]; + } + + var len = val.length; + + if (len === 2) { + // vertical | horizontal + return [val[0], val[1], val[0], val[1]]; + } else if (len === 3) { + // top | horizontal | bottom + return [val[0], val[1], val[2], val[1]]; + } + + return val; +} /** - * @type {number} + * @memberOf module:zrender/core/util + * @param {boolean} condition + * @param {string} message */ -Texture.MIRRORED_REPEAT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].MIRRORED_REPEAT; -/* harmony default export */ __webpack_exports__["a"] = (Texture); - +function assert(condition, message) { + if (!condition) { + throw new Error(message); + } +} +/** + * @memberOf module:zrender/core/util + * @param {string} str string to be trimed + * @return {string} trimed string + */ -/***/ }), -/* 7 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Vector3__ = __webpack_require__(4); +function trim(str) { + if (str == null) { + return null; + } else if (typeof str.trim === 'function') { + return str.trim(); + } else { + return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); + } +} +var primitiveKey = '__ec_primitive__'; +/** + * Set an object as primitive to be ignored traversing children in clone or merge + */ -var mat4 = __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default.a.mat4; -var vec3 = __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default.a.vec3; -var mat3 = __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default.a.mat3; -var quat = __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default.a.quat; +function setAsPrimitive(obj) { + obj[primitiveKey] = true; +} +function isPrimitive(obj) { + return obj[primitiveKey]; +} /** * @constructor - * @alias clay.Matrix4 + * @param {Object} obj Only apply `ownProperty`. */ -var Matrix4 = function() { - this._axisX = new __WEBPACK_IMPORTED_MODULE_1__Vector3__["a" /* default */](); - this._axisY = new __WEBPACK_IMPORTED_MODULE_1__Vector3__["a" /* default */](); - this._axisZ = new __WEBPACK_IMPORTED_MODULE_1__Vector3__["a" /* default */](); - /** - * Storage of Matrix4 - * @name array - * @type {Float32Array} - * @memberOf clay.Matrix4# - */ - this.array = mat4.create(); +function HashMap(obj) { + var isArr = isArray(obj); + var thisMap = this; + obj instanceof HashMap ? obj.each(visit) : obj && each(obj, visit); - /** - * @name _dirty - * @type {boolean} - * @memberOf clay.Matrix4# - */ - this._dirty = true; -}; + function visit(value, key) { + isArr ? thisMap.set(value, key) : thisMap.set(key, value); + } +} // Add prefix to avoid conflict with Object.prototype. -Matrix4.prototype = { - constructor: Matrix4, +HashMap.prototype = { + constructor: HashMap, + // Do not provide `has` method to avoid defining what is `has`. + // (We usually treat `null` and `undefined` as the same, different + // from ES6 Map). + get: function (key) { + return this.hasOwnProperty(key) ? this[key] : null; + }, + set: function (key, value) { + // Comparing with invocation chaining, `return value` is more commonly + // used in this case: `var someVal = map.set('a', genVal());` + return this[key] = value; + }, + // Although util.each can be performed on this hashMap directly, user + // should not use the exposed keys, who are prefixed. + each: function (cb, context) { + context !== void 0 && (cb = bind(cb, context)); - /** - * Set components from array - * @param {Float32Array|number[]} arr - */ - setArray: function (arr) { - for (var i = 0; i < this.array.length; i++) { - this.array[i] = arr[i]; - } - this._dirty = true; - return this; - }, - /** - * Calculate the adjugate of self, in-place - * @return {clay.Matrix4} - */ - adjoint: function() { - mat4.adjoint(this.array, this.array); - this._dirty = true; - return this; - }, + for (var key in this) { + this.hasOwnProperty(key) && cb(this[key], key); + } + }, + // Do not use this method if performance sensitive. + removeKey: function (key) { + delete this[key]; + } +}; - /** - * Clone a new Matrix4 - * @return {clay.Matrix4} - */ - clone: function() { - return (new Matrix4()).copy(this); - }, +function createHashMap(obj) { + return new HashMap(obj); +} - /** - * Copy from b - * @param {clay.Matrix4} b - * @return {clay.Matrix4} - */ - copy: function(a) { - mat4.copy(this.array, a.array); - this._dirty = true; - return this; - }, +function concatArray(a, b) { + var newArray = new a.constructor(a.length + b.length); - /** - * Calculate matrix determinant - * @return {number} - */ - determinant: function() { - return mat4.determinant(this.array); - }, + for (var i = 0; i < a.length; i++) { + newArray[i] = a[i]; + } - /** - * Set upper 3x3 part from quaternion - * @param {clay.Quaternion} q - * @return {clay.Matrix4} - */ - fromQuat: function(q) { - mat4.fromQuat(this.array, q.array); - this._dirty = true; - return this; - }, + var offset = a.length; - /** - * Set from a quaternion rotation and a vector translation - * @param {clay.Quaternion} q - * @param {clay.Vector3} v - * @return {clay.Matrix4} - */ - fromRotationTranslation: function(q, v) { - mat4.fromRotationTranslation(this.array, q.array, v.array); - this._dirty = true; - return this; - }, + for (i = 0; i < b.length; i++) { + newArray[i + offset] = b[i]; + } - /** - * Set from Matrix2d, it is used when converting a 2d shape to 3d space. - * In 3d space it is equivalent to ranslate on xy plane and rotate about z axis - * @param {clay.Matrix2d} m2d - * @return {clay.Matrix4} - */ - fromMat2d: function(m2d) { - Matrix4.fromMat2d(this, m2d); - return this; - }, + return newArray; +} - /** - * Set from frustum bounds - * @param {number} left - * @param {number} right - * @param {number} bottom - * @param {number} top - * @param {number} near - * @param {number} far - * @return {clay.Matrix4} - */ - frustum: function (left, right, bottom, top, near, far) { - mat4.frustum(this.array, left, right, bottom, top, near, far); - this._dirty = true; - return this; - }, +function noop() {} - /** - * Set to a identity matrix - * @return {clay.Matrix4} - */ - identity: function() { - mat4.identity(this.array); - this._dirty = true; - return this; - }, +exports.$override = $override; +exports.clone = clone; +exports.merge = merge; +exports.mergeAll = mergeAll; +exports.extend = extend; +exports.defaults = defaults; +exports.createCanvas = createCanvas; +exports.getContext = getContext; +exports.indexOf = indexOf; +exports.inherits = inherits; +exports.mixin = mixin; +exports.isArrayLike = isArrayLike; +exports.each = each; +exports.map = map; +exports.reduce = reduce; +exports.filter = filter; +exports.find = find; +exports.bind = bind; +exports.curry = curry; +exports.isArray = isArray; +exports.isFunction = isFunction; +exports.isString = isString; +exports.isObject = isObject; +exports.isBuiltInObject = isBuiltInObject; +exports.isTypedArray = isTypedArray; +exports.isDom = isDom; +exports.eqNaN = eqNaN; +exports.retrieve = retrieve; +exports.retrieve2 = retrieve2; +exports.retrieve3 = retrieve3; +exports.slice = slice; +exports.normalizeCssArray = normalizeCssArray; +exports.assert = assert; +exports.trim = trim; +exports.setAsPrimitive = setAsPrimitive; +exports.isPrimitive = isPrimitive; +exports.createHashMap = createHashMap; +exports.concatArray = concatArray; +exports.noop = noop; - /** - * Invert self - * @return {clay.Matrix4} - */ - invert: function() { - mat4.invert(this.array, this.array); - this._dirty = true; - return this; - }, +/***/ }), +/* 14 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - /** - * Set as a matrix with the given eye position, focal point, and up axis - * @param {clay.Vector3} eye - * @param {clay.Vector3} center - * @param {clay.Vector3} up - * @return {clay.Matrix4} - */ - lookAt: function(eye, center, up) { - mat4.lookAt(this.array, eye.array, center.array, up.array); - this._dirty = true; - return this; - }, +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__request__ = __webpack_require__(112); - /** - * Alias for mutiply - * @param {clay.Matrix4} b - * @return {clay.Matrix4} - */ - mul: function(b) { - mat4.mul(this.array, this.array, b.array); - this._dirty = true; - return this; - }, - /** - * Alias for multiplyLeft - * @param {clay.Matrix4} a - * @return {clay.Matrix4} - */ - mulLeft: function(a) { - mat4.mul(this.array, a.array, this.array); - this._dirty = true; - return this; - }, +var supportWebGL; - /** - * Multiply self and b - * @param {clay.Matrix4} b - * @return {clay.Matrix4} - */ - multiply: function(b) { - mat4.multiply(this.array, this.array, b.array); - this._dirty = true; - return this; - }, +var vendor = {}; - /** - * Multiply a and self, a is on the left - * @param {clay.Matrix3} a - * @return {clay.Matrix3} - */ - multiplyLeft: function(a) { - mat4.multiply(this.array, a.array, this.array); - this._dirty = true; - return this; - }, +/** + * If support WebGL + * @return {boolean} + */ +vendor.supportWebGL = function () { + if (supportWebGL == null) { + try { + var canvas = document.createElement('canvas'); + var gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); + if (!gl) { + throw new Error(); + } + } + catch (e) { + supportWebGL = false; + } - /** - * Set as a orthographic projection matrix - * @param {number} left - * @param {number} right - * @param {number} bottom - * @param {number} top - * @param {number} near - * @param {number} far - * @return {clay.Matrix4} - */ - ortho: function(left, right, bottom, top, near, far) { - mat4.ortho(this.array, left, right, bottom, top, near, far); - this._dirty = true; - return this; - }, - /** - * Set as a perspective projection matrix - * @param {number} fovy - * @param {number} aspect - * @param {number} near - * @param {number} far - * @return {clay.Matrix4} - */ - perspective: function(fovy, aspect, near, far) { - mat4.perspective(this.array, fovy, aspect, near, far); - this._dirty = true; - return this; - }, + } + return supportWebGL; +}; - /** - * Rotate self by rad about axis. - * Equal to right-multiply a rotaion matrix - * @param {number} rad - * @param {clay.Vector3} axis - * @return {clay.Matrix4} - */ - rotate: function(rad, axis) { - mat4.rotate(this.array, this.array, rad, axis.array); - this._dirty = true; - return this; - }, +vendor.Int8Array = typeof Int8Array === 'undefined' ? Array : Int8Array; - /** - * Rotate self by a given radian about X axis. - * Equal to right-multiply a rotaion matrix - * @param {number} rad - * @return {clay.Matrix4} - */ - rotateX: function(rad) { - mat4.rotateX(this.array, this.array, rad); - this._dirty = true; - return this; - }, +vendor.Uint8Array = typeof Uint8Array === 'undefined' ? Array : Uint8Array; - /** - * Rotate self by a given radian about Y axis. - * Equal to right-multiply a rotaion matrix - * @param {number} rad - * @return {clay.Matrix4} - */ - rotateY: function(rad) { - mat4.rotateY(this.array, this.array, rad); - this._dirty = true; - return this; - }, +vendor.Uint16Array = typeof Uint16Array === 'undefined' ? Array : Uint16Array; - /** - * Rotate self by a given radian about Z axis. - * Equal to right-multiply a rotaion matrix - * @param {number} rad - * @return {clay.Matrix4} - */ - rotateZ: function(rad) { - mat4.rotateZ(this.array, this.array, rad); - this._dirty = true; - return this; - }, +vendor.Uint32Array = typeof Uint32Array === 'undefined' ? Array : Uint32Array; - /** - * Scale self by s - * Equal to right-multiply a scale matrix - * @param {clay.Vector3} s - * @return {clay.Matrix4} - */ - scale: function(v) { - mat4.scale(this.array, this.array, v.array); - this._dirty = true; - return this; - }, +vendor.Int16Array = typeof Int16Array === 'undefined' ? Array : Int16Array; - /** - * Translate self by v. - * Equal to right-multiply a translate matrix - * @param {clay.Vector3} v - * @return {clay.Matrix4} - */ - translate: function(v) { - mat4.translate(this.array, this.array, v.array); - this._dirty = true; - return this; - }, +vendor.Float32Array = typeof Float32Array === 'undefined' ? Array : Float32Array; - /** - * Transpose self, in-place. - * @return {clay.Matrix2} - */ - transpose: function() { - mat4.transpose(this.array, this.array); - this._dirty = true; - return this; - }, +vendor.Float64Array = typeof Float64Array === 'undefined' ? Array : Float64Array; - /** - * Decompose a matrix to SRT - * @param {clay.Vector3} [scale] - * @param {clay.Quaternion} rotation - * @param {clay.Vector} position - * @see http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.matrix.decompose.aspx - */ - decomposeMatrix: (function() { +var g = {}; +if (typeof window !== 'undefined') { + g = window; +} +else if (typeof global !== 'undefined') { + g = global; +} +vendor.requestAnimationFrame = g.requestAnimationFrame + || g.msRequestAnimationFrame + || g.mozRequestAnimationFrame + || g.webkitRequestAnimationFrame + || function (func){ setTimeout(func, 16); }; - var x = vec3.create(); - var y = vec3.create(); - var z = vec3.create(); +vendor.createCanvas = function () { + return document.createElement('canvas'); +}; - var m3 = mat3.create(); +vendor.createImage = function () { + return new g.Image(); +}; - return function(scale, rotation, position) { +vendor.request = { + get: __WEBPACK_IMPORTED_MODULE_0__request__["a" /* default */].get +}; - var el = this.array; - vec3.set(x, el[0], el[1], el[2]); - vec3.set(y, el[4], el[5], el[6]); - vec3.set(z, el[8], el[9], el[10]); +/* harmony default export */ __webpack_exports__["a"] = (vendor); - var sx = vec3.length(x); - var sy = vec3.length(y); - var sz = vec3.length(z); +/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(68))) - // if determine is negative, we need to invert one scale - var det = this.determinant(); - if (det < 0) { - sx = -sx; - } +/***/ }), +/* 15 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - if (scale) { - scale.set(sx, sy, sz); - } +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_vendor__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__glmatrix_mat4__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__GeometryBase__ = __webpack_require__(118); - position.set(el[12], el[13], el[14]); - mat3.fromMat4(m3, el); - // Not like mat4, mat3 in glmatrix seems to be row-based - // Seems fixed in gl-matrix 2.2.2 - // https://github.com/toji/gl-matrix/issues/114 - // mat3.transpose(m3, m3); - m3[0] /= sx; - m3[1] /= sx; - m3[2] /= sx; - m3[3] /= sy; - m3[4] /= sy; - m3[5] /= sy; - m3[6] /= sz; - m3[7] /= sz; - m3[8] /= sz; - quat.fromMat3(rotation.array, m3); - quat.normalize(rotation.array, rotation.array); +var vec3Create = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create; +var vec3Add = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].add; +var vec3Set = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set; - rotation._dirty = true; - position._dirty = true; - }; - })(), +var Attribute = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].Attribute; - toString: function() { - return '[' + Array.prototype.join.call(this.array, ',') + ']'; - }, +/** + * Geometry in ClayGL contains vertex attributes of mesh. These vertex attributes will be finally provided to the {@link clay.Shader}. + * Different {@link clay.Shader} needs different attributes. Here is a list of attributes used in the builtin shaders. + * + * + position: `clay.basic`, `clay.lambert`, `clay.standard` + * + texcoord0: `clay.basic`, `clay.lambert`, `clay.standard` + * + color: `clay.basic`, `clay.lambert`, `clay.standard` + * + weight: `clay.basic`, `clay.lambert`, `clay.standard` + * + joint: `clay.basic`, `clay.lambert`, `clay.standard` + * + normal: `clay.lambert`, `clay.standard` + * + tangent: `clay.standard` + * + * #### Create a procedural geometry + * + * ClayGL provides a couple of builtin procedural geometries. Inlcuding: + * + * + {@link clay.geometry.Cube} + * + {@link clay.geometry.Sphere} + * + {@link clay.geometry.Plane} + * + {@link clay.geometry.Cylinder} + * + {@link clay.geometry.Cone} + * + {@link clay.geometry.ParametricSurface} + * + * It's simple to create a basic geometry with these classes. + * +```js +var sphere = new clay.geometry.Sphere({ + radius: 2 +}); +``` + * + * #### Create the geometry data by yourself + * + * Usually the vertex attributes data are created by the {@link clay.loader.GLTF} or procedural geometries like {@link clay.geometry.Sphere}. + * Besides these, you can create the data manually. Here is a simple example to create a triangle. +```js +var TRIANGLE_POSITIONS = [ + [-0.5, -0.5, 0], + [0.5, -0.5, 0], + [0, 0.5, 0] +]; +var geometry = new clay.StaticGeometryBase(); +// Add triangle vertices to position attribute. +geometry.attributes.position.fromArray(TRIANGLE_POSITIONS); +``` + * Then you can use the utility methods like `generateVertexNormals`, `generateTangents` to create the remaining necessary attributes. + * + * + * #### Use with custom shaders + * + * If you wan't to write custom shaders. Don't forget to add SEMANTICS to these attributes. For example + * + ```glsl +uniform mat4 worldViewProjection : WORLDVIEWPROJECTION; +uniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE; +uniform mat4 world : WORLD; - toArray: function () { - return Array.prototype.slice.call(this.array); - } -}; +attribute vec3 position : POSITION; +attribute vec2 texcoord : TEXCOORD_0; +attribute vec3 normal : NORMAL; +``` + * These `POSITION`, `TEXCOORD_0`, `NORMAL` are SEMANTICS which will map the attributes in shader to the attributes in the GeometryBase + * + * Available attributes SEMANTICS includes `POSITION`, `TEXCOORD_0`, `TEXCOORD_1` `NORMAL`, `TANGENT`, `COLOR`, `WEIGHT`, `JOINT`. + * + * + * @constructor clay.Geometry + * @extends clay.GeometryBase + */ +var Geometry = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].extend(function () { + return /** @lends clay.Geometry# */ { + /** + * Attributes of geometry. Including: + * + `position` + * + `texcoord0` + * + `texcoord1` + * + `normal` + * + `tangent` + * + `color` + * + `weight` + * + `joint` + * + `barycentric` + * + * @type {Object.} + */ + attributes: { + position: new Attribute('position', 'float', 3, 'POSITION'), + texcoord0: new Attribute('texcoord0', 'float', 2, 'TEXCOORD_0'), + texcoord1: new Attribute('texcoord1', 'float', 2, 'TEXCOORD_1'), + normal: new Attribute('normal', 'float', 3, 'NORMAL'), + tangent: new Attribute('tangent', 'float', 4, 'TANGENT'), + color: new Attribute('color', 'float', 4, 'COLOR'), + // Skinning attributes + // Each vertex can be bind to 4 bones, because the + // sum of weights is 1, so the weights is stored in vec3 and the last + // can be calculated by 1-w.x-w.y-w.z + weight: new Attribute('weight', 'float', 3, 'WEIGHT'), + joint: new Attribute('joint', 'float', 4, 'JOINT'), + // For wireframe display + // http://codeflow.org/entries/2012/aug/02/easy-wireframe-display-with-barycentric-coordinates/ + barycentric: new Attribute('barycentric', 'float', 3, null), + }, + /** + * Calculated bounding box of geometry. + * @type {clay.BoundingBox} + */ + boundingBox: null + }; +}, +/** @lends clay.Geometry.prototype */ +{ -var defineProperty = Object.defineProperty; + mainAttribute: 'position', -if (defineProperty) { - var proto = Matrix4.prototype; /** - * Z Axis of local transform - * @name z - * @type {clay.Vector3} - * @memberOf clay.Matrix4 - * @instance + * Update boundingBox of Geometry */ - defineProperty(proto, 'z', { - get: function () { - var el = this.array; - this._axisZ.set(el[8], el[9], el[10]); - return this._axisZ; - }, - set: function (v) { - // TODO Here has a problem - // If only set an item of vector will not work - var el = this.array; - v = v.array; - el[8] = v[0]; - el[9] = v[1]; - el[10] = v[2]; + updateBoundingBox: function () { + var bbox = this.boundingBox; + if (!bbox) { + bbox = this.boundingBox = new __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__["a" /* default */](); + } + var posArr = this.attributes.position.value; + if (posArr && posArr.length) { + var min = bbox.min; + var max = bbox.max; + var minArr = min.array; + var maxArr = max.array; + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set(minArr, posArr[0], posArr[1], posArr[2]); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set(maxArr, posArr[0], posArr[1], posArr[2]); + for (var i = 3; i < posArr.length;) { + var x = posArr[i++]; + var y = posArr[i++]; + var z = posArr[i++]; + if (x < minArr[0]) { minArr[0] = x; } + if (y < minArr[1]) { minArr[1] = y; } + if (z < minArr[2]) { minArr[2] = z; } - this._dirty = true; + if (x > maxArr[0]) { maxArr[0] = x; } + if (y > maxArr[1]) { maxArr[1] = y; } + if (z > maxArr[2]) { maxArr[2] = z; } + } + min._dirty = true; + max._dirty = true; } - }); + }, /** - * Y Axis of local transform - * @name y - * @type {clay.Vector3} - * @memberOf clay.Matrix4 - * @instance + * Generate normals per vertex. */ - defineProperty(proto, 'y', { - get: function () { - var el = this.array; - this._axisY.set(el[4], el[5], el[6]); - return this._axisY; - }, - set: function (v) { - var el = this.array; - v = v.array; - el[4] = v[0]; - el[5] = v[1]; - el[6] = v[2]; - - this._dirty = true; + generateVertexNormals: function () { + if (!this.vertexCount) { + return; } - }); - /** - * X Axis of local transform - * @name x - * @type {clay.Vector3} - * @memberOf clay.Matrix4 - * @instance - */ - defineProperty(proto, 'x', { - get: function () { - var el = this.array; - this._axisX.set(el[0], el[1], el[2]); - return this._axisX; - }, - set: function (v) { - var el = this.array; - v = v.array; - el[0] = v[0]; - el[1] = v[1]; - el[2] = v[2]; + var indices = this.indices; + var attributes = this.attributes; + var positions = attributes.position.value; + var normals = attributes.normal.value; - this._dirty = true; + if (!normals || normals.length !== positions.length) { + normals = attributes.normal.value = new __WEBPACK_IMPORTED_MODULE_0__core_vendor__["a" /* default */].Float32Array(positions.length); + } + else { + // Reset + for (var i = 0; i < normals.length; i++) { + normals[i] = 0; + } } - }) -} -/** - * @param {clay.Matrix4} out - * @param {clay.Matrix4} a - * @return {clay.Matrix4} - */ -Matrix4.adjoint = function(out, a) { - mat4.adjoint(out.array, a.array); - out._dirty = true; - return out; -}; + var p1 = vec3Create(); + var p2 = vec3Create(); + var p3 = vec3Create(); -/** - * @param {clay.Matrix4} out - * @param {clay.Matrix4} a - * @return {clay.Matrix4} - */ -Matrix4.copy = function(out, a) { - mat4.copy(out.array, a.array); - out._dirty = true; - return out; -}; + var v21 = vec3Create(); + var v32 = vec3Create(); -/** - * @param {clay.Matrix4} a - * @return {number} - */ -Matrix4.determinant = function(a) { - return mat4.determinant(a.array); -}; + var n = vec3Create(); -/** - * @param {clay.Matrix4} out - * @return {clay.Matrix4} - */ -Matrix4.identity = function(out) { - mat4.identity(out.array); - out._dirty = true; - return out; -}; + var len = indices ? indices.length : this.vertexCount; + var i1, i2, i3; + for (var f = 0; f < len;) { + if (indices) { + i1 = indices[f++]; + i2 = indices[f++]; + i3 = indices[f++]; + } + else { + i1 = f++; + i2 = f++; + i3 = f++; + } -/** - * @param {clay.Matrix4} out - * @param {number} left - * @param {number} right - * @param {number} bottom - * @param {number} top - * @param {number} near - * @param {number} far - * @return {clay.Matrix4} - */ -Matrix4.ortho = function(out, left, right, bottom, top, near, far) { - mat4.ortho(out.array, left, right, bottom, top, near, far); - out._dirty = true; - return out; -}; + vec3Set(p1, positions[i1*3], positions[i1*3+1], positions[i1*3+2]); + vec3Set(p2, positions[i2*3], positions[i2*3+1], positions[i2*3+2]); + vec3Set(p3, positions[i3*3], positions[i3*3+1], positions[i3*3+2]); -/** - * @param {clay.Matrix4} out - * @param {number} fovy - * @param {number} aspect - * @param {number} near - * @param {number} far - * @return {clay.Matrix4} - */ -Matrix4.perspective = function(out, fovy, aspect, near, far) { - mat4.perspective(out.array, fovy, aspect, near, far); - out._dirty = true; - return out; -}; + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(v21, p1, p2); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(v32, p2, p3); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].cross(n, v21, v32); + // Already be weighted by the triangle area + for (var i = 0; i < 3; i++) { + normals[i1*3+i] = normals[i1*3+i] + n[i]; + normals[i2*3+i] = normals[i2*3+i] + n[i]; + normals[i3*3+i] = normals[i3*3+i] + n[i]; + } + } -/** - * @param {clay.Matrix4} out - * @param {clay.Vector3} eye - * @param {clay.Vector3} center - * @param {clay.Vector3} up - * @return {clay.Matrix4} - */ -Matrix4.lookAt = function(out, eye, center, up) { - mat4.lookAt(out.array, eye.array, center.array, up.array); - out._dirty = true; - return out; -}; + for (var i = 0; i < normals.length;) { + vec3Set(n, normals[i], normals[i+1], normals[i+2]); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].normalize(n, n); + normals[i++] = n[0]; + normals[i++] = n[1]; + normals[i++] = n[2]; + } + this.dirty(); + }, -/** - * @param {clay.Matrix4} out - * @param {clay.Matrix4} a - * @return {clay.Matrix4} - */ -Matrix4.invert = function(out, a) { - mat4.invert(out.array, a.array); - out._dirty = true; - return out; -}; + /** + * Generate normals per face. + */ + generateFaceNormals: function () { + if (!this.vertexCount) { + return; + } -/** - * @param {clay.Matrix4} out - * @param {clay.Matrix4} a - * @param {clay.Matrix4} b - * @return {clay.Matrix4} - */ -Matrix4.mul = function(out, a, b) { - mat4.mul(out.array, a.array, b.array); - out._dirty = true; - return out; -}; + if (!this.isUniqueVertex()) { + this.generateUniqueVertex(); + } -/** - * @function - * @param {clay.Matrix4} out - * @param {clay.Matrix4} a - * @param {clay.Matrix4} b - * @return {clay.Matrix4} - */ -Matrix4.multiply = Matrix4.mul; + var indices = this.indices; + var attributes = this.attributes; + var positions = attributes.position.value; + var normals = attributes.normal.value; -/** - * @param {clay.Matrix4} out - * @param {clay.Quaternion} q - * @return {clay.Matrix4} - */ -Matrix4.fromQuat = function(out, q) { - mat4.fromQuat(out.array, q.array); - out._dirty = true; - return out; -}; + var p1 = vec3Create(); + var p2 = vec3Create(); + var p3 = vec3Create(); -/** - * @param {clay.Matrix4} out - * @param {clay.Quaternion} q - * @param {clay.Vector3} v - * @return {clay.Matrix4} - */ -Matrix4.fromRotationTranslation = function(out, q, v) { - mat4.fromRotationTranslation(out.array, q.array, v.array); - out._dirty = true; - return out; -}; + var v21 = vec3Create(); + var v32 = vec3Create(); + var n = vec3Create(); -/** - * @param {clay.Matrix4} m4 - * @param {clay.Matrix2d} m2d - * @return {clay.Matrix4} - */ -Matrix4.fromMat2d = function(m4, m2d) { - m4._dirty = true; - var m2d = m2d.array; - var m4 = m4.array; + if (!normals) { + normals = attributes.normal.value = new Float32Array(positions.length); + } + var len = indices ? indices.length : this.vertexCount; + var i1, i2, i3; + for (var f = 0; f < len;) { + if (indices) { + i1 = indices[f++]; + i2 = indices[f++]; + i3 = indices[f++]; + } + else { + i1 = f++; + i2 = f++; + i3 = f++; + } - m4[0] = m2d[0]; - m4[4] = m2d[2]; - m4[12] = m2d[4]; + vec3Set(p1, positions[i1*3], positions[i1*3+1], positions[i1*3+2]); + vec3Set(p2, positions[i2*3], positions[i2*3+1], positions[i2*3+2]); + vec3Set(p3, positions[i3*3], positions[i3*3+1], positions[i3*3+2]); - m4[1] = m2d[1]; - m4[5] = m2d[3]; - m4[13] = m2d[5]; + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(v21, p1, p2); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(v32, p2, p3); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].cross(n, v21, v32); - return m4; -}; + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].normalize(n, n); -/** - * @param {clay.Matrix4} out - * @param {clay.Matrix4} a - * @param {number} rad - * @param {clay.Vector3} axis - * @return {clay.Matrix4} - */ -Matrix4.rotate = function(out, a, rad, axis) { - mat4.rotate(out.array, a.array, rad, axis.array); - out._dirty = true; - return out; -}; + for (var i = 0; i < 3; i++) { + normals[i1*3 + i] = n[i]; + normals[i2*3 + i] = n[i]; + normals[i3*3 + i] = n[i]; + } + } + this.dirty(); + }, -/** - * @param {clay.Matrix4} out - * @param {clay.Matrix4} a - * @param {number} rad - * @return {clay.Matrix4} - */ -Matrix4.rotateX = function(out, a, rad) { - mat4.rotateX(out.array, a.array, rad); - out._dirty = true; - return out; -}; + /** + * Generate tangents attributes. + */ + generateTangents: function () { + if (!this.vertexCount) { + return; + } -/** - * @param {clay.Matrix4} out - * @param {clay.Matrix4} a - * @param {number} rad - * @return {clay.Matrix4} - */ -Matrix4.rotateY = function(out, a, rad) { - mat4.rotateY(out.array, a.array, rad); - out._dirty = true; - return out; -}; + var nVertex = this.vertexCount; + var attributes = this.attributes; + if (!attributes.tangent.value) { + attributes.tangent.value = new Float32Array(nVertex * 4); + } + var texcoords = attributes.texcoord0.value; + var positions = attributes.position.value; + var tangents = attributes.tangent.value; + var normals = attributes.normal.value; -/** - * @param {clay.Matrix4} out - * @param {clay.Matrix4} a - * @param {number} rad - * @return {clay.Matrix4} - */ -Matrix4.rotateZ = function(out, a, rad) { - mat4.rotateZ(out.array, a.array, rad); - out._dirty = true; - return out; -}; + if (!texcoords) { + console.warn('Geometry without texcoords can\'t generate tangents.'); + return; + } -/** - * @param {clay.Matrix4} out - * @param {clay.Matrix4} a - * @param {clay.Vector3} v - * @return {clay.Matrix4} - */ -Matrix4.scale = function(out, a, v) { - mat4.scale(out.array, a.array, v.array); - out._dirty = true; - return out; -}; - -/** - * @param {clay.Matrix4} out - * @param {clay.Matrix4} a - * @return {clay.Matrix4} - */ -Matrix4.transpose = function(out, a) { - mat4.transpose(out.array, a.array); - out._dirty = true; - return out; -}; - -/** - * @param {clay.Matrix4} out - * @param {clay.Matrix4} a - * @param {clay.Vector3} v - * @return {clay.Matrix4} - */ -Matrix4.translate = function(out, a, v) { - mat4.translate(out.array, a.array, v.array); - out._dirty = true; - return out; -}; - -/* harmony default export */ __webpack_exports__["a"] = (Matrix4); - - -/***/ }), -/* 8 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_util__ = __webpack_require__(20); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_vendor__ = __webpack_require__(18); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__dep_glmatrix__); -/** - * Mainly do the parse and compile of shader string - * Support shader code chunk import and export - * Support shader semantics - * http://www.nvidia.com/object/using_sas.html - * https://github.com/KhronosGroup/collada2json/issues/45 - * - * TODO: Use etpl or other string template engine - */ + var tan1 = []; + var tan2 = []; + for (var i = 0; i < nVertex; i++) { + tan1[i] = [0.0, 0.0, 0.0]; + tan2[i] = [0.0, 0.0, 0.0]; + } + var sdir = [0.0, 0.0, 0.0]; + var tdir = [0.0, 0.0, 0.0]; + var indices = this.indices; + var len = indices ? indices.length : this.vertexCount; + var i1, i2, i3; + for (var i = 0; i < len;) { + if (indices) { + i1 = indices[i++]; + i2 = indices[i++]; + i3 = indices[i++]; + } + else { + i1 = i++; + i2 = i++; + i3 = i++; + } -var mat2 = __WEBPACK_IMPORTED_MODULE_2__dep_glmatrix___default.a.mat2; -var mat3 = __WEBPACK_IMPORTED_MODULE_2__dep_glmatrix___default.a.mat3; -var mat4 = __WEBPACK_IMPORTED_MODULE_2__dep_glmatrix___default.a.mat4; + var st1s = texcoords[i1 * 2], + st2s = texcoords[i2 * 2], + st3s = texcoords[i3 * 2], + st1t = texcoords[i1 * 2 + 1], + st2t = texcoords[i2 * 2 + 1], + st3t = texcoords[i3 * 2 + 1], -var uniformRegex = /uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g; -var attributeRegex = /attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g; -var defineRegex = /#define\s+(\w+)?(\s+[\w-.]+)?\s*;?\s*\n/g; + p1x = positions[i1 * 3], + p2x = positions[i2 * 3], + p3x = positions[i3 * 3], + p1y = positions[i1 * 3 + 1], + p2y = positions[i2 * 3 + 1], + p3y = positions[i3 * 3 + 1], + p1z = positions[i1 * 3 + 2], + p2z = positions[i2 * 3 + 2], + p3z = positions[i3 * 3 + 2]; -var uniformTypeMap = { - 'bool': '1i', - 'int': '1i', - 'sampler2D': 't', - 'samplerCube': 't', - 'float': '1f', - 'vec2': '2f', - 'vec3': '3f', - 'vec4': '4f', - 'ivec2': '2i', - 'ivec3': '3i', - 'ivec4': '4i', - 'mat2': 'm2', - 'mat3': 'm3', - 'mat4': 'm4' -}; + var x1 = p2x - p1x, + x2 = p3x - p1x, + y1 = p2y - p1y, + y2 = p3y - p1y, + z1 = p2z - p1z, + z2 = p3z - p1z; -var uniformValueConstructor = { - 'bool': function () { return true; }, - 'int': function () { return 0; }, - 'float': function () { return 0; }, - 'sampler2D': function () { return null; }, - 'samplerCube': function () { return null; }, + var s1 = st2s - st1s, + s2 = st3s - st1s, + t1 = st2t - st1t, + t2 = st3t - st1t; - 'vec2': function () { return [0, 0]; }, - 'vec3': function () { return [0, 0, 0]; }, - 'vec4': function () { return [0, 0, 0, 0]; }, + var r = 1.0 / (s1 * t2 - t1 * s2); + sdir[0] = (t2 * x1 - t1 * x2) * r; + sdir[1] = (t2 * y1 - t1 * y2) * r; + sdir[2] = (t2 * z1 - t1 * z2) * r; - 'ivec2': function () { return [0, 0]; }, - 'ivec3': function () { return [0, 0, 0]; }, - 'ivec4': function () { return [0, 0, 0, 0]; }, + tdir[0] = (s1 * x2 - s2 * x1) * r; + tdir[1] = (s1 * y2 - s2 * y1) * r; + tdir[2] = (s1 * z2 - s2 * z1) * r; - 'mat2': function () { return mat2.create(); }, - 'mat3': function () { return mat3.create(); }, - 'mat4': function () { return mat4.create(); }, + vec3Add(tan1[i1], tan1[i1], sdir); + vec3Add(tan1[i2], tan1[i2], sdir); + vec3Add(tan1[i3], tan1[i3], sdir); + vec3Add(tan2[i1], tan2[i1], tdir); + vec3Add(tan2[i2], tan2[i2], tdir); + vec3Add(tan2[i3], tan2[i3], tdir); + } + var tmp = vec3Create(); + var nCrossT = vec3Create(); + var n = vec3Create(); + for (var i = 0; i < nVertex; i++) { + n[0] = normals[i * 3]; + n[1] = normals[i * 3 + 1]; + n[2] = normals[i * 3 + 2]; + var t = tan1[i]; - 'array': function () { return []; } -}; + // Gram-Schmidt orthogonalize + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scale(tmp, n, __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(n, t)); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(tmp, t, tmp); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].normalize(tmp, tmp); + // Calculate handedness. + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].cross(nCrossT, n, t); + tangents[i * 4] = tmp[0]; + tangents[i * 4 + 1] = tmp[1]; + tangents[i * 4 + 2] = tmp[2]; + // PENDING can config ? + tangents[i * 4 + 3] = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(nCrossT, tan2[i]) < 0.0 ? -1.0 : 1.0; + } + this.dirty(); + }, -var attributeSemantics = [ - 'POSITION', - 'NORMAL', - 'BINORMAL', - 'TANGENT', - 'TEXCOORD', - 'TEXCOORD_0', - 'TEXCOORD_1', - 'COLOR', - // Skinning - // https://github.com/KhronosGroup/glTF/blob/master/specification/README.md#semantics - 'JOINT', - 'WEIGHT' -]; -var uniformSemantics = [ - 'SKIN_MATRIX', - // Information about viewport - 'VIEWPORT_SIZE', - 'VIEWPORT', - 'DEVICEPIXELRATIO', - // Window size for window relative coordinate - // https://www.opengl.org/sdk/docs/man/html/gl_FragCoord.xhtml - 'WINDOW_SIZE', - // Infomation about camera - 'NEAR', - 'FAR', - // Time - 'TIME' -]; -var matrixSemantics = [ - 'WORLD', - 'VIEW', - 'PROJECTION', - 'WORLDVIEW', - 'VIEWPROJECTION', - 'WORLDVIEWPROJECTION', - 'WORLDINVERSE', - 'VIEWINVERSE', - 'PROJECTIONINVERSE', - 'WORLDVIEWINVERSE', - 'VIEWPROJECTIONINVERSE', - 'WORLDVIEWPROJECTIONINVERSE', - 'WORLDTRANSPOSE', - 'VIEWTRANSPOSE', - 'PROJECTIONTRANSPOSE', - 'WORLDVIEWTRANSPOSE', - 'VIEWPROJECTIONTRANSPOSE', - 'WORLDVIEWPROJECTIONTRANSPOSE', - 'WORLDINVERSETRANSPOSE', - 'VIEWINVERSETRANSPOSE', - 'PROJECTIONINVERSETRANSPOSE', - 'WORLDVIEWINVERSETRANSPOSE', - 'VIEWPROJECTIONINVERSETRANSPOSE', - 'WORLDVIEWPROJECTIONINVERSETRANSPOSE' -]; + /** + * If vertices are not shared by different indices. + */ + isUniqueVertex: function () { + if (this.isUseIndices()) { + return this.vertexCount === this.indices.length; + } + else { + return true; + } + }, + /** + * Create a unique vertex for each index. + */ + generateUniqueVertex: function () { + if (!this.vertexCount || !this.indices) { + return; + } -var attributeSizeMap = { - // WebGL does not support integer attributes - 'vec4': 4, - 'vec3': 3, - 'vec2': 2, - 'float': 1 -}; + if (this.indices.length > 0xffff) { + this.indices = new __WEBPACK_IMPORTED_MODULE_0__core_vendor__["a" /* default */].Uint32Array(this.indices); + } + var attributes = this.attributes; + var indices = this.indices; -var shaderIDCache = {}; -var shaderCodeCache = {}; + var attributeNameList = this.getEnabledAttributes(); -function getShaderID(vertex, fragment) { - var key = 'vertex:' + vertex + 'fragment:' + fragment; - if (shaderIDCache[key]) { - return shaderIDCache[key]; - } - var id = __WEBPACK_IMPORTED_MODULE_0__core_util__["a" /* default */].genGUID(); - shaderIDCache[key] = id; + var oldAttrValues = {}; + for (var a = 0; a < attributeNameList.length; a++) { + var name = attributeNameList[a]; + oldAttrValues[name] = attributes[name].value; + attributes[name].init(this.indices.length); + } - shaderCodeCache[id] = { - vertex: vertex, - fragment: fragment - }; + var cursor = 0; + for (var i = 0; i < indices.length; i++) { + var ii = indices[i]; + for (var a = 0; a < attributeNameList.length; a++) { + var name = attributeNameList[a]; + var array = attributes[name].value; + var size = attributes[name].size; - return id; -} + for (var k = 0; k < size; k++) { + array[cursor * size + k] = oldAttrValues[name][ii * size + k]; + } + } + indices[i] = cursor; + cursor++; + } -function removeComment(code) { - return code.replace(/[ \t]*\/\/.*\n/g, '' ) // remove // - .replace(/[ \t]*\/\*[\s\S]*?\*\//g, '' ); // remove /* */ -} + this.dirty(); + }, -function logSyntaxError() { - console.error('Wrong uniform/attributes syntax'); -} + /** + * Generate barycentric coordinates for wireframe draw. + */ + generateBarycentric: function () { + if (!this.vertexCount) { + return; + } -function parseDeclarations(type, line) { - var speratorsRegexp = /[,=\(\):]/; - var tokens = line - // Convert `symbol: [1,2,3]` to `symbol: vec3(1,2,3)` - .replace(/:\s*\[\s*(.*)\s*\]/g, '=' + type + '($1)') - .replace(/\s+/g, '') - .split(/(?=[,=\(\):])/g); + if (!this.isUniqueVertex()) { + this.generateUniqueVertex(); + } - var newTokens = []; - for (var i = 0; i < tokens.length; i++) { - if (tokens[i].match(speratorsRegexp)) { - newTokens.push( - tokens[i].charAt(0), - tokens[i].slice(1) - ); + var attributes = this.attributes; + var array = attributes.barycentric.value; + var indices = this.indices; + // Already existed; + if (array && array.length === indices.length * 3) { + return; } - else { - newTokens.push(tokens[i]); + array = attributes.barycentric.value = new Float32Array(indices.length * 3); + + for (var i = 0; i < (indices ? indices.length : this.vertexCount / 3);) { + for (var j = 0; j < 3; j++) { + var ii = indices ? indices[i++] : (i * 3 + j); + array[ii * 3 + j] = 1; + } } - } - tokens = newTokens; + this.dirty(); + }, - var TYPE_SYMBOL = 0; - var TYPE_ASSIGN = 1; - var TYPE_VEC = 2; - var TYPE_ARR = 3; - var TYPE_SEMANTIC = 4; - var TYPE_NORMAL = 5; + /** + * Apply transform to geometry attributes. + * @param {clay.Matrix4} matrix + */ + applyTransform: function (matrix) { - var opType = TYPE_SYMBOL; - var declarations = {}; - var declarationValue = null; - var currentDeclaration; + var attributes = this.attributes; + var positions = attributes.position.value; + var normals = attributes.normal.value; + var tangents = attributes.tangent.value; - addSymbol(tokens[0]); + matrix = matrix.array; + // Normal Matrix + var inverseTransposeMatrix = __WEBPACK_IMPORTED_MODULE_2__glmatrix_mat4__["a" /* default */].create(); + __WEBPACK_IMPORTED_MODULE_2__glmatrix_mat4__["a" /* default */].invert(inverseTransposeMatrix, matrix); + __WEBPACK_IMPORTED_MODULE_2__glmatrix_mat4__["a" /* default */].transpose(inverseTransposeMatrix, inverseTransposeMatrix); - function addSymbol(symbol) { - if (!symbol) { - logSyntaxError(); + var vec3TransformMat4 = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].transformMat4; + var vec3ForEach = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].forEach; + vec3ForEach(positions, 3, 0, null, vec3TransformMat4, matrix); + if (normals) { + vec3ForEach(normals, 3, 0, null, vec3TransformMat4, inverseTransposeMatrix); } - var arrResult = symbol.match(/\[(.*?)\]/); - currentDeclaration = symbol.replace(/\[(.*?)\]/, ''); - declarations[currentDeclaration] = {}; - if (arrResult) { - declarations[currentDeclaration].isArray = true; - declarations[currentDeclaration].arraySize = arrResult[1]; + if (tangents) { + vec3ForEach(tangents, 4, 0, null, vec3TransformMat4, inverseTransposeMatrix); } - } - for (var i = 1; i < tokens.length; i++) { - var token = tokens[i]; - if (!token) { // Empty token; - continue; + if (this.boundingBox) { + this.updateBoundingBox(); } - if (token === '=') { - if (opType !== TYPE_SYMBOL - && opType !== TYPE_ARR) { - logSyntaxError(); - break; - } - opType = TYPE_ASSIGN; + }, + /** + * Dispose geometry data in GL context. + * @param {clay.Renderer} renderer + */ + dispose: function (renderer) { - continue; - } - else if (token === ':') { - opType = TYPE_SEMANTIC; + var cache = this._cache; - continue; - } - else if (token === ',') { - if (opType === TYPE_VEC) { - if (!(declarationValue instanceof Array)) { - logSyntaxError(); - break; + cache.use(renderer.__uid__); + var chunks = cache.get('chunks'); + if (chunks) { + for (var c = 0; c < chunks.length; c++) { + var chunk = chunks[c]; + + for (var k = 0; k < chunk.attributeBuffers.length; k++) { + var attribs = chunk.attributeBuffers[k]; + renderer.gl.deleteBuffer(attribs.buffer); } - declarationValue.push(+tokens[++i]); - } - else { - opType = TYPE_NORMAL; - } - continue; - } - else if (token === ')') { - declarations[currentDeclaration].value = new __WEBPACK_IMPORTED_MODULE_1__core_vendor__["a" /* default */].Float32Array(declarationValue); - declarationValue = null; - opType = TYPE_NORMAL; - continue; - } - else if (token === '(') { - if (opType !== TYPE_VEC) { - logSyntaxError(); - break; - } - if (!(declarationValue instanceof Array)) { - logSyntaxError(); - break; - } - declarationValue.push(+tokens[++i]); - continue; - } - else if (token.indexOf('vec') >= 0) { - if (opType !== TYPE_ASSIGN - // Compatitable with old syntax `symbol: [1,2,3]` - && opType !== TYPE_SEMANTIC) { - logSyntaxError(); - break; - } - opType = TYPE_VEC; - declarationValue = []; - continue; - } - else if (opType === TYPE_ASSIGN) { - if (type === 'bool') { - declarations[currentDeclaration].value = token === 'true'; - } - else { - declarations[currentDeclaration].value = parseFloat(token); + if (chunk.indicesBuffer) { + renderer.gl.deleteBuffer(chunk.indicesBuffer.buffer); + } } - declarationValue = null; - continue; } - else if (opType === TYPE_SEMANTIC) { - var semantic = token; - if (attributeSemantics.indexOf(semantic) >= 0 - || uniformSemantics.indexOf(semantic) >= 0 - || matrixSemantics.indexOf(semantic) >= 0 - ) { - declarations[currentDeclaration].semantic = semantic; - } - else if (semantic === 'ignore' || semantic === 'unconfigurable') { - declarations[currentDeclaration].ignore = true; - } - else { - // Try to parse as a default tvalue. - if (type === 'bool') { - declarations[currentDeclaration].value = semantic === 'true'; - } - else { - declarations[currentDeclaration].value = parseFloat(semantic); + if (this.__vaoCache) { + var vaoExt = renderer.getGLExtension('OES_vertex_array_object'); + for (var id in this.__vaoCache) { + var vao = this.__vaoCache[id].vao; + if (vao) { + vaoExt.deleteVertexArrayOES(vao); } } - continue; } - - // treat as symbol. - addSymbol(token); - opType = TYPE_SYMBOL; + this.__vaoCache = {}; + cache.deleteContext(renderer.__uid__); } - return declarations; -} +}); +Geometry.STATIC_DRAW = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].STATIC_DRAW; +Geometry.DYNAMIC_DRAW = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].DYNAMIC_DRAW; +Geometry.STREAM_DRAW = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].STREAM_DRAW; -/** - * @constructor - * @extends clay.core.Base - * @alias clay.Shader - * @param {string} vertex - * @param {string} fragment - * @example - * // Create a phong shader - * var shader = new clay.Shader( - * clay.Shader.source('clay.standard.vertex'), - * clay.Shader.source('clay.standard.fragment') - * ); - */ -function Shader(vertex, fragment) { - // First argument can be { vertex, fragment } - if (typeof vertex === 'object') { - fragment = vertex.fragment; - vertex = vertex.vertex; - } +Geometry.AttributeBuffer = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].AttributeBuffer; +Geometry.IndicesBuffer = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].IndicesBuffer; - vertex = removeComment(vertex); - fragment = removeComment(fragment); +Geometry.Attribute = Attribute; - this._shaderID = getShaderID(vertex, fragment); +/* harmony default export */ __webpack_exports__["a"] = (Geometry); - this._vertexCode = Shader.parseImport(vertex); - this._fragmentCode = Shader.parseImport(fragment); - /** - * @readOnly - */ - this.attributeSemantics = {}; - /** - * @readOnly - */ - this.matrixSemantics = {}; - /** - * @readOnly - */ - this.uniformSemantics = {}; - /** - * @readOnly - */ - this.matrixSemanticKeys = []; - /** - * @readOnly - */ - this.uniformTemplates = {}; - /** - * @readOnly - */ - this.attributes = {}; - /** - * @readOnly - */ - this.textures = {}; - /** - * @readOnly - */ - this.vertexDefines = {}; - /** - * @readOnly - */ - this.fragmentDefines = {}; +/***/ }), +/* 16 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - this._parseAttributes(); - this._parseUniforms(); - this._parseDefines(); -} +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__camera_Orthographic__ = __webpack_require__(37); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geometry_Plane__ = __webpack_require__(43); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Shader__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Material__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Mesh__ = __webpack_require__(40); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__core_glenum__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__shader_source_compositor_vertex_glsl_js__ = __webpack_require__(126); -Shader.prototype = { - constructor: Shader, - // Create a new uniform instance for material - createUniforms: function () { - var uniforms = {}; - for (var symbol in this.uniformTemplates){ - var uniformTpl = this.uniformTemplates[symbol]; - uniforms[symbol] = { - type: uniformTpl.type, - value: uniformTpl.value() - }; - } - return uniforms; - }, - _parseImport: function () { - this._vertexCode = Shader.parseImport(this.vertex); - this._fragmentCode = Shader.parseImport(this.fragment); - }, - _addSemanticUniform: function (symbol, uniformType, semantic) { - // This case is only for SKIN_MATRIX - // TODO - if (attributeSemantics.indexOf(semantic) >= 0) { - this.attributeSemantics[semantic] = { - symbol: symbol, - type: uniformType - }; - } - else if (matrixSemantics.indexOf(semantic) >= 0) { - var isTranspose = false; - var semanticNoTranspose = semantic; - if (semantic.match(/TRANSPOSE$/)) { - isTranspose = true; - semanticNoTranspose = semantic.slice(0, -9); - } - this.matrixSemantics[semantic] = { - symbol: symbol, - type: uniformType, - isTranspose: isTranspose, - semanticNoTranspose: semanticNoTranspose - }; - } - else if (uniformSemantics.indexOf(semantic) >= 0) { - this.uniformSemantics[semantic] = { - symbol: symbol, - type: uniformType - }; - } - }, - _addMaterialUniform: function (symbol, type, uniformType, defaultValueFunc, isArray, materialUniforms) { - materialUniforms[symbol] = { - type: uniformType, - value: isArray ? uniformValueConstructor['array'] : (defaultValueFunc || uniformValueConstructor[type]), - semantic: null - }; - }, - _parseUniforms: function () { - var uniforms = {}; - var self = this; - var shaderType = 'vertex'; - this._uniformList = []; +__WEBPACK_IMPORTED_MODULE_3__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_7__shader_source_compositor_vertex_glsl_js__["a" /* default */]); - this._vertexCode = this._vertexCode.replace(uniformRegex, _uniformParser); - shaderType = 'fragment'; - this._fragmentCode = this._fragmentCode.replace(uniformRegex, _uniformParser); +var planeGeo = new __WEBPACK_IMPORTED_MODULE_2__geometry_Plane__["a" /* default */](); +var mesh = new __WEBPACK_IMPORTED_MODULE_5__Mesh__["a" /* default */]({ + geometry: planeGeo, + frustumCulling: false +}); +var camera = new __WEBPACK_IMPORTED_MODULE_1__camera_Orthographic__["a" /* default */](); - self.matrixSemanticKeys = Object.keys(this.matrixSemantics); +/** + * @constructor clay.compositor.Pass + * @extends clay.core.Base + */ +var Pass = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () { + return /** @lends clay.compositor.Pass# */ { + /** + * Fragment shader string + * @type {string} + */ + // PENDING shader or fragment ? + fragment: '', - function makeDefaultValueFunc(value) { - return value != null ? function () { return value; } : null; - } + /** + * @type {Object} + */ + outputs: null, - function _uniformParser(str, type, content) { - var declaredUniforms = parseDeclarations(type, content); - var uniformMainStr = []; - for (var symbol in declaredUniforms) { + /** + * @type {clay.Material} + */ + material: null, - var uniformInfo = declaredUniforms[symbol]; - var semantic = uniformInfo.semantic; - var tmpStr = symbol; - var uniformType = uniformTypeMap[type]; - var defaultValueFunc = makeDefaultValueFunc(declaredUniforms[symbol].value); - if (declaredUniforms[symbol].isArray) { - tmpStr += '[' + declaredUniforms[symbol].arraySize + ']'; - uniformType += 'v'; - } + /** + * @type {Boolean} + */ + blendWithPrevious: false, - uniformMainStr.push(tmpStr); + /** + * @type {Boolean} + */ + clearColor: false, - self._uniformList.push(symbol); + /** + * @type {Boolean} + */ + clearDepth: true + }; +}, function() { - if (!uniformInfo.ignore) { - if (type === 'sampler2D' || type === 'samplerCube') { - // Texture is default disabled - self.textures[symbol] = { - shaderType: shaderType, - type: type - }; - } + var shader = new __WEBPACK_IMPORTED_MODULE_3__Shader__["a" /* default */](__WEBPACK_IMPORTED_MODULE_3__Shader__["a" /* default */].source('clay.compositor.vertex'), this.fragment); + var material = new __WEBPACK_IMPORTED_MODULE_4__Material__["a" /* default */]({ + shader: shader + }); + material.enableTexturesAll(); - if (semantic) { - // TODO Should not declare multiple symbols if have semantic. - self._addSemanticUniform(symbol, uniformType, semantic); - } - else { - self._addMaterialUniform( - symbol, type, uniformType, defaultValueFunc, - declaredUniforms[symbol].isArray, uniforms - ); - } - } + this.material = material; + +}, +/** @lends clay.compositor.Pass.prototype */ +{ + /** + * @param {string} name + * @param {} value + */ + setUniform: function(name, value) { + this.material.setUniform(name, value); + }, + /** + * @param {string} name + * @return {} + */ + getUniform: function(name) { + var uniform = this.material.uniforms[name]; + if (uniform) { + return uniform.value; + } + }, + /** + * @param {clay.Texture} texture + * @param {number} attachment + */ + attachOutput: function(texture, attachment) { + if (!this.outputs) { + this.outputs = {}; + } + attachment = attachment || __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].COLOR_ATTACHMENT0; + this.outputs[attachment] = texture; + }, + /** + * @param {clay.Texture} texture + */ + detachOutput: function(texture) { + for (var attachment in this.outputs) { + if (this.outputs[attachment] === texture) { + this.outputs[attachment] = null; } - return uniformMainStr.length > 0 - ? 'uniform ' + type + ' ' + uniformMainStr.join(',') + ';\n' : ''; } - - this.uniformTemplates = uniforms; }, - _parseAttributes: function () { - var attributes = {}; - var self = this; - this._vertexCode = this._vertexCode.replace(attributeRegex, _attributeParser); - - function _attributeParser(str, type, content) { - var declaredAttributes = parseDeclarations(type, content); + bind: function(renderer, frameBuffer) { - var size = attributeSizeMap[type] || 1; - var attributeMainStr = []; - for (var symbol in declaredAttributes) { - var semantic = declaredAttributes[symbol].semantic; - attributes[symbol] = { - // TODO Can only be float - type: 'float', - size: size, - semantic: semantic || null - }; - // TODO Should not declare multiple symbols if have semantic. - if (semantic) { - if (attributeSemantics.indexOf(semantic) < 0) { - throw new Error('Unkown semantic "' + semantic + '"'); - } - else { - self.attributeSemantics[semantic] = { - symbol: symbol, - type: type - }; - } + if (this.outputs) { + for (var attachment in this.outputs) { + var texture = this.outputs[attachment]; + if (texture) { + frameBuffer.attach(texture, attachment); } - attributeMainStr.push(symbol); } + } - return 'attribute ' + type + ' ' + attributeMainStr.join(',') + ';\n'; + if (frameBuffer) { + frameBuffer.bind(renderer); } + }, - this.attributes = attributes; + unbind: function(renderer, frameBuffer) { + frameBuffer.unbind(renderer); }, + /** + * @param {clay.Renderer} renderer + * @param {clay.FrameBuffer} [frameBuffer] + */ + render: function(renderer, frameBuffer) { - _parseDefines: function () { - var self = this; - var shaderType = 'vertex'; - this._vertexCode = this._vertexCode.replace(defineRegex, _defineParser); - shaderType = 'fragment'; - this._fragmentCode = this._fragmentCode.replace(defineRegex, _defineParser); + var _gl = renderer.gl; - function _defineParser(str, symbol, value) { - var defines = shaderType === 'vertex' ? self.vertexDefines : self.fragmentDefines; - if (!defines[symbol]) { // Haven't been defined by user - if (value === 'false') { - defines[symbol] = false; - } - else if (value === 'true') { - defines[symbol] = true; - } - else { - defines[symbol] = value - // If can parse to float - ? (isNaN(parseFloat(value)) ? value.trim() : parseFloat(value)) - : null; + if (frameBuffer) { + this.bind(renderer, frameBuffer); + // MRT Support in chrome + // https://www.khronos.org/registry/webgl/sdk/tests/conformance/extensions/ext-draw-buffers.html + var ext = renderer.getGLExtension('EXT_draw_buffers'); + if (ext && this.outputs) { + var bufs = []; + for (var attachment in this.outputs) { + attachment = +attachment; + if (attachment >= _gl.COLOR_ATTACHMENT0 && attachment <= _gl.COLOR_ATTACHMENT0 + 8) { + bufs.push(attachment); + } } + ext.drawBuffersEXT(bufs); } - return ''; } - }, - /** - * Clone a new shader - * @return {clay.Shader} - */ - clone: function () { - var code = shaderCodeCache[this._shaderID]; - var shader = new Shader(code.vertex, code.fragment); - return shader; - } -}; + this.trigger('beforerender', this, renderer); -if (Object.defineProperty) { - Object.defineProperty(Shader.prototype, 'shaderID', { - get: function () { - return this._shaderID; - } - }); - Object.defineProperty(Shader.prototype, 'vertex', { - get: function () { - return this._vertexCode; - } - }); - Object.defineProperty(Shader.prototype, 'fragment', { - get: function () { - return this._fragmentCode; - } - }); - Object.defineProperty(Shader.prototype, 'uniforms', { - get: function () { - return this._uniformList; + // FIXME Don't clear in each pass in default, let the color overwrite the buffer + // FIXME pixels may be discard + var clearBit = this.clearDepth ? _gl.DEPTH_BUFFER_BIT : 0; + _gl.depthMask(true); + if (this.clearColor) { + clearBit = clearBit | _gl.COLOR_BUFFER_BIT; + _gl.colorMask(true, true, true, true); + var cc = this.clearColor; + if (Array.isArray(cc)) { + _gl.clearColor(cc[0], cc[1], cc[2], cc[3]); + } } - }); -} + _gl.clear(clearBit); -var importRegex = /(@import)\s*([0-9a-zA-Z_\-\.]*)/g; -Shader.parseImport = function (shaderStr) { - shaderStr = shaderStr.replace(importRegex, function (str, importSymbol, importName) { - var str = Shader.source(importName); - if (str) { - // Recursively parse - return Shader.parseImport(str); + if (this.blendWithPrevious) { + // Blend with previous rendered scene in the final output + // FIXME Configure blend. + // FIXME It will cause screen blink? + _gl.enable(_gl.BLEND); + this.material.transparent = true; } else { - console.error('Shader chunk "' + importName + '" not existed in library'); - return ''; + _gl.disable(_gl.BLEND); + this.material.transparent = false; } - }); - return shaderStr; -}; -var exportRegex = /(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g; + this.renderQuad(renderer); -/** - * Import shader source - * @param {string} shaderStr - * @memberOf clay.Shader - */ -Shader['import'] = function (shaderStr) { - shaderStr.replace(exportRegex, function (str, exportSymbol, exportName, code) { - var code = code.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g, ''); - if (code) { - var parts = exportName.split('.'); - var obj = Shader.codes; - var i = 0; - var key; - while (i < parts.length - 1) { - key = parts[i++]; - if (!obj[key]) { - obj[key] = {}; - } - obj = obj[key]; - } - key = parts[i]; - obj[key] = code; + this.trigger('afterrender', this, renderer); + + if (frameBuffer) { + this.unbind(renderer, frameBuffer); } - return code; - }); -}; + }, -/** - * Library to store all the loaded shader codes - * @type {Object} - * @readOnly - * @memberOf clay.Shader - */ -Shader.codes = {}; + /** + * Simply do quad rendering + */ + renderQuad: function (renderer) { + mesh.material = this.material; + renderer.renderPass([mesh], camera); + }, -/** - * Get shader source - * @param {string} name - * @return {string} - */ -Shader.source = function (name) { - var parts = name.split('.'); - var obj = Shader.codes; - var i = 0; - while (obj && i < parts.length) { - var key = parts[i++]; - obj = obj[key]; - } - if (typeof obj !== 'string') { - // FIXME Use default instead - console.error('Shader "' + name + '" not existed in library'); - return ''; - } - return obj; -}; + /** + * @param {clay.Renderer} renderer + */ + dispose: function (renderer) {} +}); -/* harmony default export */ __webpack_exports__["a"] = (Shader); +/* harmony default export */ __webpack_exports__["a"] = (Pass); /***/ }), -/* 9 */ +/* 17 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mixin_extend__ = __webpack_require__(103); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__mixin_notifier__ = __webpack_require__(47); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util__ = __webpack_require__(20); - - - - -/** - * Base class of all objects - * @constructor - * @alias clay.core.Base - * @mixes clay.core.mixin.notifier - */ -var Base = function () { - /** - * @type {number} - */ - this.__uid__ = __WEBPACK_IMPORTED_MODULE_2__util__["a" /* default */].genGUID(); -}; +/* harmony default export */ __webpack_exports__["a"] = (function (seriesType, ecModel, api) { + return { + seriesType: seriesType, + reset: function (seriesModel, ecModel) { + var data = seriesModel.getData(); + var opacityAccessPath = seriesModel.visualColorAccessPath.split('.'); + opacityAccessPath[opacityAccessPath.length - 1] ='opacity'; -Base.__initializers__ = [ - function (opts) { - __WEBPACK_IMPORTED_MODULE_2__util__["a" /* default */].extend(this, opts); - } -]; + var opacity = seriesModel.get(opacityAccessPath); -__WEBPACK_IMPORTED_MODULE_2__util__["a" /* default */].extend(Base, __WEBPACK_IMPORTED_MODULE_0__mixin_extend__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_2__util__["a" /* default */].extend(Base.prototype, __WEBPACK_IMPORTED_MODULE_1__mixin_notifier__["a" /* default */]); + data.setVisual('opacity', opacity == null ? 1 : opacity); -/* harmony default export */ __webpack_exports__["a"] = (Base); + function dataEach(data, idx) { + var itemModel = data.getItemModel(idx); + var opacity = itemModel.get(opacityAccessPath, true); + if (opacity != null) { + data.setItemVisual(idx, 'opacity', opacity); + } + } + return { + dataEach: data.hasItemOption ? dataEach : null + }; + } + }; +}); /***/ }), -/* 10 */ +/* 18 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Texture__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__TextureCube__ = __webpack_require__(24); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_glenum__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_Cache__ = __webpack_require__(48); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__ = __webpack_require__(12); +var vec3Set = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set; +var vec3Copy = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].copy; - - -var KEY_FRAMEBUFFER = 'framebuffer'; -var KEY_RENDERBUFFER = 'renderbuffer'; -var KEY_RENDERBUFFER_WIDTH = KEY_RENDERBUFFER + '_width'; -var KEY_RENDERBUFFER_HEIGHT = KEY_RENDERBUFFER + '_height'; -var KEY_RENDERBUFFER_ATTACHED = KEY_RENDERBUFFER + '_attached'; -var KEY_DEPTHTEXTURE_ATTACHED = 'depthtexture_attached'; - -var GL_FRAMEBUFFER = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].FRAMEBUFFER; -var GL_RENDERBUFFER = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].RENDERBUFFER; -var GL_DEPTH_ATTACHMENT = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_ATTACHMENT; -var GL_COLOR_ATTACHMENT0 = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].COLOR_ATTACHMENT0; /** - * @constructor clay.FrameBuffer - * @extends clay.core.Base + * Axis aligned bounding box + * @constructor + * @alias clay.BoundingBox + * @param {clay.Vector3} [min] + * @param {clay.Vector3} [max] */ -var FrameBuffer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend( -/** @lends clay.FrameBuffer# */ -{ +var BoundingBox = function (min, max) { + /** - * If use depth buffer - * @type {boolean} + * Minimum coords of bounding box + * @type {clay.Vector3} */ - depthBuffer: true, + this.min = min || new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](Infinity, Infinity, Infinity); /** - * @type {Object} + * Maximum coords of bounding box + * @type {clay.Vector3} */ - viewport: null, + this.max = max || new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](-Infinity, -Infinity, -Infinity); - _width: 0, - _height: 0, + this.vertices = null; +}; - _textures: null, +BoundingBox.prototype = { - _boundRenderer: null, -}, function () { - // Use cache - this._cache = new __WEBPACK_IMPORTED_MODULE_4__core_Cache__["a" /* default */](); + constructor: BoundingBox, + /** + * Update min and max coords from a vertices array + * @param {array} vertices + */ + updateFromVertices: function (vertices) { + if (vertices.length > 0) { + var min = this.min; + var max = this.max; + var minArr = min.array; + var maxArr = max.array; + vec3Copy(minArr, vertices[0]); + vec3Copy(maxArr, vertices[0]); + for (var i = 1; i < vertices.length; i++) { + var vertex = vertices[i]; - this._textures = {}; -}, + if (vertex[0] < minArr[0]) { minArr[0] = vertex[0]; } + if (vertex[1] < minArr[1]) { minArr[1] = vertex[1]; } + if (vertex[2] < minArr[2]) { minArr[2] = vertex[2]; } + + if (vertex[0] > maxArr[0]) { maxArr[0] = vertex[0]; } + if (vertex[1] > maxArr[1]) { maxArr[1] = vertex[1]; } + if (vertex[2] > maxArr[2]) { maxArr[2] = vertex[2]; } + } + min._dirty = true; + max._dirty = true; + } + }, -/**@lends clay.FrameBuffer.prototype. */ -{ /** - * Get attached texture width - * {number} + * Union operation with another bounding box + * @param {clay.BoundingBox} bbox */ - // FIXME Can't use before #bind - getTextureWidth: function () { - return this._width; + union: function (bbox) { + var min = this.min; + var max = this.max; + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].min(min.array, min.array, bbox.min.array); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].max(max.array, max.array, bbox.max.array); + min._dirty = true; + max._dirty = true; + return this; }, /** - * Get attached texture height - * {number} + * Intersection operation with another bounding box + * @param {clay.BoundingBox} bbox */ - getTextureHeight: function () { - return this._height; + intersection: function (bbox) { + var min = this.min; + var max = this.max; + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].max(min.array, min.array, bbox.min.array); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].min(max.array, max.array, bbox.max.array); + min._dirty = true; + max._dirty = true; + return this; }, /** - * Bind the framebuffer to given renderer before rendering - * @param {clay.Renderer} renderer + * If intersect with another bounding box + * @param {clay.BoundingBox} bbox + * @return {boolean} */ - bind: function (renderer) { - - if (renderer.__currentFrameBuffer) { - // Already bound - if (renderer.__currentFrameBuffer === this) { - return; - } - - console.warn('Renderer already bound with another framebuffer. Unbind it first'); - } - renderer.__currentFrameBuffer = this; - - var _gl = renderer.gl; - - _gl.bindFramebuffer(GL_FRAMEBUFFER, this._getFrameBufferGL(renderer)); - this._boundRenderer = renderer; - var cache = this._cache; - - cache.put('viewport', renderer.viewport); - - var hasTextureAttached = false; - var width; - var height; - for (var attachment in this._textures) { - hasTextureAttached = true; - var obj = this._textures[attachment]; - if (obj) { - // TODO Do width, height checking, make sure size are same - width = obj.texture.width; - height = obj.texture.height; - // Attach textures - this._doAttach(renderer, obj.texture, attachment, obj.target); - } - } - - this._width = width; - this._height = height; - - if (!hasTextureAttached && this.depthBuffer) { - console.error('Must attach texture before bind, or renderbuffer may have incorrect width and height.') - } - - if (this.viewport) { - renderer.setViewport(this.viewport); - } - else { - renderer.setViewport(0, 0, width, height, 1); - } + intersectBoundingBox: function (bbox) { + var _min = this.min.array; + var _max = this.max.array; - var attachedTextures = cache.get('attached_textures'); - if (attachedTextures) { - for (var attachment in attachedTextures) { - if (!this._textures[attachment]) { - var target = attachedTextures[attachment]; - this._doDetach(_gl, attachment, target); - } - } - } - if (!cache.get(KEY_DEPTHTEXTURE_ATTACHED) && this.depthBuffer) { - // Create a new render buffer - if (cache.miss(KEY_RENDERBUFFER)) { - cache.put(KEY_RENDERBUFFER, _gl.createRenderbuffer()); - } - var renderbuffer = cache.get(KEY_RENDERBUFFER); + var _min2 = bbox.min.array; + var _max2 = bbox.max.array; - if (width !== cache.get(KEY_RENDERBUFFER_WIDTH) - || height !== cache.get(KEY_RENDERBUFFER_HEIGHT)) { - _gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer); - _gl.renderbufferStorage(GL_RENDERBUFFER, _gl.DEPTH_COMPONENT16, width, height); - cache.put(KEY_RENDERBUFFER_WIDTH, width); - cache.put(KEY_RENDERBUFFER_HEIGHT, height); - _gl.bindRenderbuffer(GL_RENDERBUFFER, null); - } - if (!cache.get(KEY_RENDERBUFFER_ATTACHED)) { - _gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbuffer); - cache.put(KEY_RENDERBUFFER_ATTACHED, true); - } - } + return ! (_min[0] > _max2[0] || _min[1] > _max2[1] || _min[2] > _max2[2] + || _max[0] < _min2[0] || _max[1] < _min2[1] || _max[2] < _min2[2]); }, /** - * Unbind the frame buffer after rendering - * @param {clay.Renderer} renderer + * If contain another bounding box entirely + * @param {clay.BoundingBox} bbox + * @return {boolean} */ - unbind: function (renderer) { - // Remove status record on renderer - renderer.__currentFrameBuffer = null; - - var _gl = renderer.gl; + containBoundingBox: function (bbox) { - _gl.bindFramebuffer(GL_FRAMEBUFFER, null); - this._boundRenderer = null; + var _min = this.min.array; + var _max = this.max.array; - this._cache.use(renderer.__uid__); - var viewport = this._cache.get('viewport'); - // Reset viewport; - if (viewport) { - renderer.setViewport(viewport); - } + var _min2 = bbox.min.array; + var _max2 = bbox.max.array; - this.updateMipmap(renderer); + return _min[0] <= _min2[0] && _min[1] <= _min2[1] && _min[2] <= _min2[2] + && _max[0] >= _max2[0] && _max[1] >= _max2[1] && _max[2] >= _max2[2]; }, - // Because the data of texture is changed over time, - // Here update the mipmaps of texture each time after rendered; - updateMipmap: function (renderer) { - var _gl = renderer.gl; - for (var attachment in this._textures) { - var obj = this._textures[attachment]; - if (obj) { - var texture = obj.texture; - // FIXME some texture format can't generate mipmap - if (!texture.NPOT && texture.useMipmap - && texture.minFilter === __WEBPACK_IMPORTED_MODULE_1__Texture__["a" /* default */].LINEAR_MIPMAP_LINEAR) { - var target = texture.textureType === 'textureCube' ? __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].TEXTURE_CUBE_MAP : __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].TEXTURE_2D; - _gl.bindTexture(target, texture.getWebGLTexture(renderer)); - _gl.generateMipmap(target); - _gl.bindTexture(target, null); - } - } - } - }, + /** + * If contain point entirely + * @param {clay.Vector3} point + * @return {boolean} + */ + containPoint: function (p) { + var _min = this.min.array; + var _max = this.max.array; + var _p = p.array; - // 0x8CD5, 36053, FRAMEBUFFER_COMPLETE - // 0x8CD6, 36054, FRAMEBUFFER_INCOMPLETE_ATTACHMENT - // 0x8CD7, 36055, FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT - // 0x8CD9, 36057, FRAMEBUFFER_INCOMPLETE_DIMENSIONS - // 0x8CDD, 36061, FRAMEBUFFER_UNSUPPORTED - checkStatus: function (_gl) { - return _gl.checkFramebufferStatus(GL_FRAMEBUFFER); + return _min[0] <= _p[0] && _min[1] <= _p[1] && _min[2] <= _p[2] + && _max[0] >= _p[0] && _max[1] >= _p[1] && _max[2] >= _p[2]; }, - _getFrameBufferGL: function (renderer) { - var cache = this._cache; - cache.use(renderer.__uid__); - - if (cache.miss(KEY_FRAMEBUFFER)) { - cache.put(KEY_FRAMEBUFFER, renderer.gl.createFramebuffer()); - } + /** + * If bounding box is finite + */ + isFinite: function () { + var _min = this.min.array; + var _max = this.max.array; + return isFinite(_min[0]) && isFinite(_min[1]) && isFinite(_min[2]) + && isFinite(_max[0]) && isFinite(_max[1]) && isFinite(_max[2]); + }, - return cache.get(KEY_FRAMEBUFFER); + /** + * Apply an affine transform matrix to the bounding box + * @param {clay.Matrix4} matrix + */ + applyTransform: function (matrix) { + this.transformFrom(this, matrix); }, /** - * Attach a texture(RTT) to the framebuffer - * @param {clay.Texture} texture - * @param {number} [attachment=gl.COLOR_ATTACHMENT0] - * @param {number} [target=gl.TEXTURE_2D] + * Get from another bounding box and an affine transform matrix. + * @param {clay.BoundingBox} source + * @param {clay.Matrix4} matrix */ - attach: function (texture, attachment, target) { + transformFrom: (function () { + // http://dev.theomader.com/transform-bounding-boxes/ + var xa = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); + var xb = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); + var ya = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); + var yb = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); + var za = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); + var zb = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); - if (!texture.width) { - throw new Error('The texture attached to color buffer is not a valid.'); - } - // TODO width and height check + return function (source, matrix) { + var min = source.min.array; + var max = source.max.array; - // If the depth_texture extension is enabled, developers - // Can attach a depth texture to the depth buffer - // http://blog.tojicode.com/2012/07/using-webgldepthtexture.html - attachment = attachment || GL_COLOR_ATTACHMENT0; - target = target || __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].TEXTURE_2D; + var m = matrix.array; - var boundRenderer = this._boundRenderer; - var _gl = boundRenderer && boundRenderer.gl; - var attachedTextures; + xa[0] = m[0] * min[0]; xa[1] = m[1] * min[0]; xa[2] = m[2] * min[0]; + xb[0] = m[0] * max[0]; xb[1] = m[1] * max[0]; xb[2] = m[2] * max[0]; - if (_gl) { - var cache = this._cache; - cache.use(boundRenderer.__uid__); - attachedTextures = cache.get('attached_textures'); - } + ya[0] = m[4] * min[1]; ya[1] = m[5] * min[1]; ya[2] = m[6] * min[1]; + yb[0] = m[4] * max[1]; yb[1] = m[5] * max[1]; yb[2] = m[6] * max[1]; - // Check if texture attached - var previous = this._textures[attachment]; - if (previous && previous.target === target - && previous.texture === texture - && (attachedTextures && attachedTextures[attachment] != null) - ) { - return; - } + za[0] = m[8] * min[2]; za[1] = m[9] * min[2]; za[2] = m[10] * min[2]; + zb[0] = m[8] * max[2]; zb[1] = m[9] * max[2]; zb[2] = m[10] * max[2]; - var canAttach = true; - if (boundRenderer) { - canAttach = this._doAttach(boundRenderer, texture, attachment, target); - // Set viewport again incase attached to different size textures. - if (!this.viewport) { - boundRenderer.setViewport(0, 0, texture.width, texture.height, 1); - } - } + min = this.min.array; + max = this.max.array; + min[0] = Math.min(xa[0], xb[0]) + Math.min(ya[0], yb[0]) + Math.min(za[0], zb[0]) + m[12]; + min[1] = Math.min(xa[1], xb[1]) + Math.min(ya[1], yb[1]) + Math.min(za[1], zb[1]) + m[13]; + min[2] = Math.min(xa[2], xb[2]) + Math.min(ya[2], yb[2]) + Math.min(za[2], zb[2]) + m[14]; - if (canAttach) { - this._textures[attachment] = this._textures[attachment] || {}; - this._textures[attachment].texture = texture; - this._textures[attachment].target = target; - } - }, + max[0] = Math.max(xa[0], xb[0]) + Math.max(ya[0], yb[0]) + Math.max(za[0], zb[0]) + m[12]; + max[1] = Math.max(xa[1], xb[1]) + Math.max(ya[1], yb[1]) + Math.max(za[1], zb[1]) + m[13]; + max[2] = Math.max(xa[2], xb[2]) + Math.max(ya[2], yb[2]) + Math.max(za[2], zb[2]) + m[14]; - _doAttach: function (renderer, texture, attachment, target) { - var _gl = renderer.gl; - // Make sure texture is always updated - // Because texture width or height may be changed and in this we can't be notified - // FIXME awkward; - var webglTexture = texture.getWebGLTexture(renderer); - // Assume cache has been used. - var attachedTextures = this._cache.get('attached_textures'); - if (attachedTextures && attachedTextures[attachment]) { - var obj = attachedTextures[attachment]; - // Check if texture and target not changed - if (obj.texture === texture && obj.target === target) { - return; - } - } - attachment = +attachment; + this.min._dirty = true; + this.max._dirty = true; - var canAttach = true; - if (attachment === GL_DEPTH_ATTACHMENT || attachment === __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_STENCIL_ATTACHMENT) { - var extension = renderer.getGLExtension('WEBGL_depth_texture'); + return this; + }; + })(), - if (!extension) { - console.error('Depth texture is not supported by the browser'); - canAttach = false; - } - if (texture.format !== __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_COMPONENT - && texture.format !== __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_STENCIL - ) { - console.error('The texture attached to depth buffer is not a valid.'); - canAttach = false; - } + /** + * Apply a projection matrix to the bounding box + * @param {clay.Matrix4} matrix + */ + applyProjection: function (matrix) { + var min = this.min.array; + var max = this.max.array; - // Dispose render buffer created previous - if (canAttach) { - var renderbuffer = this._cache.get(KEY_RENDERBUFFER); - if (renderbuffer) { - _gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, null); - _gl.deleteRenderbuffer(renderbuffer); - this._cache.put(KEY_RENDERBUFFER, false); - } + var m = matrix.array; + // min in min z + var v10 = min[0]; + var v11 = min[1]; + var v12 = min[2]; + // max in min z + var v20 = max[0]; + var v21 = max[1]; + var v22 = min[2]; + // max in max z + var v30 = max[0]; + var v31 = max[1]; + var v32 = max[2]; - this._cache.put(KEY_RENDERBUFFER_ATTACHED, false); - this._cache.put(KEY_DEPTHTEXTURE_ATTACHED, true); - } + if (m[15] === 1) { // Orthographic projection + min[0] = m[0] * v10 + m[12]; + min[1] = m[5] * v11 + m[13]; + max[2] = m[10] * v12 + m[14]; + + max[0] = m[0] * v30 + m[12]; + max[1] = m[5] * v31 + m[13]; + min[2] = m[10] * v32 + m[14]; } + else { + var w = -1 / v12; + min[0] = m[0] * v10 * w; + min[1] = m[5] * v11 * w; + max[2] = (m[10] * v12 + m[14]) * w; - // Mipmap level can only be 0 - _gl.framebufferTexture2D(GL_FRAMEBUFFER, attachment, target, webglTexture, 0); + w = -1 / v22; + max[0] = m[0] * v20 * w; + max[1] = m[5] * v21 * w; - if (!attachedTextures) { - attachedTextures = {}; - this._cache.put('attached_textures', attachedTextures); + w = -1 / v32; + min[2] = (m[10] * v32 + m[14]) * w; } - attachedTextures[attachment] = attachedTextures[attachment] || {}; - attachedTextures[attachment].texture = texture; - attachedTextures[attachment].target = target; + this.min._dirty = true; + this.max._dirty = true; - return canAttach; + return this; }, - _doDetach: function (_gl, attachment, target) { - // Detach a texture from framebuffer - // https://github.com/KhronosGroup/WebGL/blob/master/conformance-suites/1.0.0/conformance/framebuffer-test.html#L145 - _gl.framebufferTexture2D(GL_FRAMEBUFFER, attachment, target, null, 0); + updateVertices: function () { + var vertices = this.vertices; + if (!vertices) { + // Cube vertices + vertices = []; + for (var i = 0; i < 8; i++) { + vertices[i] = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].fromValues(0, 0, 0); + } - // Assume cache has been used. - var attachedTextures = this._cache.get('attached_textures'); - if (attachedTextures && attachedTextures[attachment]) { - attachedTextures[attachment] = null; + /** + * Eight coords of bounding box + * @type {Float32Array[]} + */ + this.vertices = vertices; } + var min = this.min.array; + var max = this.max.array; + //--- min z + // min x + vec3Set(vertices[0], min[0], min[1], min[2]); + vec3Set(vertices[1], min[0], max[1], min[2]); + // max x + vec3Set(vertices[2], max[0], min[1], min[2]); + vec3Set(vertices[3], max[0], max[1], min[2]); - if (attachment === GL_DEPTH_ATTACHMENT || attachment === __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_STENCIL_ATTACHMENT) { - this._cache.put(KEY_DEPTHTEXTURE_ATTACHED, false); - } - }, + //-- max z + vec3Set(vertices[4], min[0], min[1], max[2]); + vec3Set(vertices[5], min[0], max[1], max[2]); + vec3Set(vertices[6], max[0], min[1], max[2]); + vec3Set(vertices[7], max[0], max[1], max[2]); + return this; + }, /** - * Detach a texture - * @param {number} [attachment=gl.COLOR_ATTACHMENT0] - * @param {number} [target=gl.TEXTURE_2D] + * Copy values from another bounding box + * @param {clay.BoundingBox} bbox */ - detach: function (attachment, target) { - // TODO depth extension check ? - this._textures[attachment] = null; - if (this._boundRenderer) { - var cache = this._cache; - cache.use(this._boundRenderer.__uid__); - this._doDetach(this._boundRenderer.gl, attachment, target); - } + copy: function (bbox) { + var min = this.min; + var max = this.max; + vec3Copy(min.array, bbox.min.array); + vec3Copy(max.array, bbox.max.array); + min._dirty = true; + max._dirty = true; + return this; }, + /** - * Dispose - * @param {WebGLRenderingContext} _gl + * Clone a new bounding box + * @return {clay.BoundingBox} */ - dispose: function (renderer) { - - var _gl = renderer.gl; - var cache = this._cache; + clone: function () { + var boundingBox = new BoundingBox(); + boundingBox.copy(this); + return boundingBox; + } +}; - cache.use(renderer.__uid__); +/* harmony default export */ __webpack_exports__["a"] = (BoundingBox); - var renderBuffer = cache.get(KEY_RENDERBUFFER); - if (renderBuffer) { - _gl.deleteRenderbuffer(renderBuffer); - } - var frameBuffer = cache.get(KEY_FRAMEBUFFER); - if (frameBuffer) { - _gl.deleteFramebuffer(frameBuffer); - } - cache.deleteContext(renderer.__uid__); - // Clear cache for reusing - this._textures = {}; +/***/ }), +/* 19 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - } -}); +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_util__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_color__ = __webpack_require__(113); -FrameBuffer.DEPTH_ATTACHMENT = GL_DEPTH_ATTACHMENT; -FrameBuffer.COLOR_ATTACHMENT0 = GL_COLOR_ATTACHMENT0; -FrameBuffer.STENCIL_ATTACHMENT = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].STENCIL_ATTACHMENT; -FrameBuffer.DEPTH_STENCIL_ATTACHMENT = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_STENCIL_ATTACHMENT; -/* harmony default export */ __webpack_exports__["a"] = (FrameBuffer); +var parseColor = __WEBPACK_IMPORTED_MODULE_2__core_color__["a" /* default */].parseToFloat; -/***/ }), -/* 11 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +var programKeyCache = {}; -"use strict"; -/** - * @namespace clay.core.glenum - * @see http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14 - */ -/* harmony default export */ __webpack_exports__["a"] = ({ - /* ClearBufferMask */ - DEPTH_BUFFER_BIT : 0x00000100, - STENCIL_BUFFER_BIT : 0x00000400, - COLOR_BUFFER_BIT : 0x00004000, +function getDefineCode(defines) { + var defineKeys = Object.keys(defines); + defineKeys.sort(); + var defineStr = []; + // Custom Defines + for (var i = 0; i < defineKeys.length; i++) { + var key = defineKeys[i]; + var value = defines[key]; + if (value === null) { + defineStr.push(key); + } + else{ + defineStr.push(key + ' ' + value.toString()); + } + } + return defineStr.join('\n'); +} - /* BeginMode */ - POINTS : 0x0000, - LINES : 0x0001, - LINE_LOOP : 0x0002, - LINE_STRIP : 0x0003, - TRIANGLES : 0x0004, - TRIANGLE_STRIP : 0x0005, - TRIANGLE_FAN : 0x0006, +function getProgramKey(vertexDefines, fragmentDefines, enabledTextures) { + enabledTextures.sort(); + var defineStr = []; + for (var i = 0; i < enabledTextures.length; i++) { + var symbol = enabledTextures[i]; + defineStr.push(symbol); + } + var key = getDefineCode(vertexDefines) + '\n' + + getDefineCode(fragmentDefines) + '\n' + + defineStr.join('\n'); - /* AlphaFunction (not supported in ES20) */ - /* NEVER */ - /* LESS */ - /* EQUAL */ - /* LEQUAL */ - /* GREATER */ - /* NOTEQUAL */ - /* GEQUAL */ - /* ALWAYS */ + if (programKeyCache[key]) { + return programKeyCache[key]; + } - /* BlendingFactorDest */ - ZERO : 0, - ONE : 1, - SRC_COLOR : 0x0300, - ONE_MINUS_SRC_COLOR : 0x0301, - SRC_ALPHA : 0x0302, - ONE_MINUS_SRC_ALPHA : 0x0303, - DST_ALPHA : 0x0304, - ONE_MINUS_DST_ALPHA : 0x0305, + var id = __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].genGUID(); + programKeyCache[key] = id; + return id; +} - /* BlendingFactorSrc */ - /* ZERO */ - /* ONE */ - DST_COLOR : 0x0306, - ONE_MINUS_DST_COLOR : 0x0307, - SRC_ALPHA_SATURATE : 0x0308, - /* SRC_ALPHA */ - /* ONE_MINUS_SRC_ALPHA */ - /* DST_ALPHA */ - /* ONE_MINUS_DST_ALPHA */ +/** + * Material defines the appearance of mesh surface, like `color`, `roughness`, `metalness`, etc. + * It contains a {@link clay.Shader} and corresponding uniforms. + * + * Here is a basic example to create a standard material +```js +var material = new clay.Material({ + shader: new clay.Shader( + clay.Shader.source('clay.vertex'), + clay.Shader.source('clay.fragment') + ) +}); +``` + * @constructor clay.Material + * @extends clay.core.Base + */ +var Material = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () { + return /** @lends clay.Material# */ { + /** + * @type {string} + */ + name: '', - /* BlendEquationSeparate */ - FUNC_ADD : 0x8006, - BLEND_EQUATION : 0x8009, - BLEND_EQUATION_RGB : 0x8009, /* same as BLEND_EQUATION */ - BLEND_EQUATION_ALPHA : 0x883D, + /** + * @type {Object} + */ + // uniforms: null, - /* BlendSubtract */ - FUNC_SUBTRACT : 0x800A, - FUNC_REVERSE_SUBTRACT : 0x800B, + /** + * @type {clay.Shader} + */ + // shader: null, - /* Separate Blend Functions */ - BLEND_DST_RGB : 0x80C8, - BLEND_SRC_RGB : 0x80C9, - BLEND_DST_ALPHA : 0x80CA, - BLEND_SRC_ALPHA : 0x80CB, - CONSTANT_COLOR : 0x8001, - ONE_MINUS_CONSTANT_COLOR : 0x8002, - CONSTANT_ALPHA : 0x8003, - ONE_MINUS_CONSTANT_ALPHA : 0x8004, - BLEND_COLOR : 0x8005, + /** + * @type {boolean} + */ + depthTest: true, - /* Buffer Objects */ - ARRAY_BUFFER : 0x8892, - ELEMENT_ARRAY_BUFFER : 0x8893, - ARRAY_BUFFER_BINDING : 0x8894, - ELEMENT_ARRAY_BUFFER_BINDING : 0x8895, + /** + * @type {boolean} + */ + depthMask: true, - STREAM_DRAW : 0x88E0, - STATIC_DRAW : 0x88E4, - DYNAMIC_DRAW : 0x88E8, + /** + * @type {boolean} + */ + transparent: false, + /** + * Blend func is a callback function when the material + * have custom blending + * The gl context will be the only argument passed in tho the + * blend function + * Detail of blend function in WebGL: + * http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf + * + * Example : + * function(_gl) { + * _gl.blendEquation(_gl.FUNC_ADD); + * _gl.blendFunc(_gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA); + * } + */ + blend: null, - BUFFER_SIZE : 0x8764, - BUFFER_USAGE : 0x8765, + /** + * If update texture status automatically. + */ + autoUpdateTextureStatus: true, - CURRENT_VERTEX_ATTRIB : 0x8626, + uniforms: {}, + vertexDefines: {}, + fragmentDefines: {}, + _textureStatus: {}, - /* CullFaceMode */ - FRONT : 0x0404, - BACK : 0x0405, - FRONT_AND_BACK : 0x0408, + // shadowTransparentMap : null - /* DepthFunction */ - /* NEVER */ - /* LESS */ - /* EQUAL */ - /* LEQUAL */ - /* GREATER */ - /* NOTEQUAL */ - /* GEQUAL */ - /* ALWAYS */ + // PENDING enable the uniform that only used in shader. + _enabledUniforms: null, + }; +}, function () { + if (!this.name) { + this.name = 'MATERIAL_' + this.__uid__; + } - /* EnableCap */ - /* TEXTURE_2D */ - CULL_FACE : 0x0B44, - BLEND : 0x0BE2, - DITHER : 0x0BD0, - STENCIL_TEST : 0x0B90, - DEPTH_TEST : 0x0B71, - SCISSOR_TEST : 0x0C11, - POLYGON_OFFSET_FILL : 0x8037, - SAMPLE_ALPHA_TO_COVERAGE : 0x809E, - SAMPLE_COVERAGE : 0x80A0, + if (this.shader) { + // Keep status, mainly preset uniforms, vertexDefines and fragmentDefines + this.attachShader(this.shader, true); + } +}, +/** @lends clay.Material.prototype */ +{ + precision: 'highp', - /* ErrorCode */ - NO_ERROR : 0, - INVALID_ENUM : 0x0500, - INVALID_VALUE : 0x0501, - INVALID_OPERATION : 0x0502, - OUT_OF_MEMORY : 0x0505, + /** + * Set material uniform + * @example + * mat.setUniform('color', [1, 1, 1, 1]); + * @param {string} symbol + * @param {number|array|clay.Texture|ArrayBufferView} value + */ + setUniform: function (symbol, value) { + if (value === undefined) { + console.warn('Uniform value "' + symbol + '" is undefined'); + } + var uniform = this.uniforms[symbol]; + if (uniform) { - /* FrontFaceDirection */ - CW : 0x0900, - CCW : 0x0901, + if (typeof value === 'string') { + // Try to parse as a color. Invalid color string will return null. + value = parseColor(value) || value; + } - /* GetPName */ - LINE_WIDTH : 0x0B21, - ALIASED_POINT_SIZE_RANGE : 0x846D, - ALIASED_LINE_WIDTH_RANGE : 0x846E, - CULL_FACE_MODE : 0x0B45, - FRONT_FACE : 0x0B46, - DEPTH_RANGE : 0x0B70, - DEPTH_WRITEMASK : 0x0B72, - DEPTH_CLEAR_VALUE : 0x0B73, - DEPTH_FUNC : 0x0B74, - STENCIL_CLEAR_VALUE : 0x0B91, - STENCIL_FUNC : 0x0B92, - STENCIL_FAIL : 0x0B94, - STENCIL_PASS_DEPTH_FAIL : 0x0B95, - STENCIL_PASS_DEPTH_PASS : 0x0B96, - STENCIL_REF : 0x0B97, - STENCIL_VALUE_MASK : 0x0B93, - STENCIL_WRITEMASK : 0x0B98, - STENCIL_BACK_FUNC : 0x8800, - STENCIL_BACK_FAIL : 0x8801, - STENCIL_BACK_PASS_DEPTH_FAIL : 0x8802, - STENCIL_BACK_PASS_DEPTH_PASS : 0x8803, - STENCIL_BACK_REF : 0x8CA3, - STENCIL_BACK_VALUE_MASK : 0x8CA4, - STENCIL_BACK_WRITEMASK : 0x8CA5, - VIEWPORT : 0x0BA2, - SCISSOR_BOX : 0x0C10, - /* SCISSOR_TEST */ - COLOR_CLEAR_VALUE : 0x0C22, - COLOR_WRITEMASK : 0x0C23, - UNPACK_ALIGNMENT : 0x0CF5, - PACK_ALIGNMENT : 0x0D05, - MAX_TEXTURE_SIZE : 0x0D33, - MAX_VIEWPORT_DIMS : 0x0D3A, - SUBPIXEL_BITS : 0x0D50, - RED_BITS : 0x0D52, - GREEN_BITS : 0x0D53, - BLUE_BITS : 0x0D54, - ALPHA_BITS : 0x0D55, - DEPTH_BITS : 0x0D56, - STENCIL_BITS : 0x0D57, - POLYGON_OFFSET_UNITS : 0x2A00, - /* POLYGON_OFFSET_FILL */ - POLYGON_OFFSET_FACTOR : 0x8038, - TEXTURE_BINDING_2D : 0x8069, - SAMPLE_BUFFERS : 0x80A8, - SAMPLES : 0x80A9, - SAMPLE_COVERAGE_VALUE : 0x80AA, - SAMPLE_COVERAGE_INVERT : 0x80AB, + uniform.value = value; - /* GetTextureParameter */ - /* TEXTURE_MAG_FILTER */ - /* TEXTURE_MIN_FILTER */ - /* TEXTURE_WRAP_S */ - /* TEXTURE_WRAP_T */ + if (this.autoUpdateTextureStatus && uniform.type === 't') { + if (value) { + this.enableTexture(symbol); + } + else { + this.disableTexture(symbol); + } + } + } + }, - COMPRESSED_TEXTURE_FORMATS : 0x86A3, + /** + * @param {Object} obj + */ + setUniforms: function(obj) { + for (var key in obj) { + var val = obj[key]; + this.setUniform(key, val); + } + }, - /* HintMode */ - DONT_CARE : 0x1100, - FASTEST : 0x1101, - NICEST : 0x1102, + /** + * @param {string} symbol + * @return {boolean} + */ + isUniformEnabled: function (symbol) { + return this._enabledUniforms.indexOf(symbol) >= 0; + }, - /* HintTarget */ - GENERATE_MIPMAP_HINT : 0x8192, + getEnabledUniforms: function () { + return this._enabledUniforms; + }, + getTextureUniforms: function () { + return this._textureUniforms; + }, - /* DataType */ - BYTE : 0x1400, - UNSIGNED_BYTE : 0x1401, - SHORT : 0x1402, - UNSIGNED_SHORT : 0x1403, - INT : 0x1404, - UNSIGNED_INT : 0x1405, - FLOAT : 0x1406, + /** + * Alias of setUniform and setUniforms + * @param {object|string} symbol + * @param {number|array|clay.Texture|ArrayBufferView} [value] + */ + set: function (symbol, value) { + if (typeof(symbol) === 'object') { + for (var key in symbol) { + var val = symbol[key]; + this.setUniform(key, val); + } + } + else { + this.setUniform(symbol, value); + } + }, + /** + * Get uniform value + * @param {string} symbol + * @return {number|array|clay.Texture|ArrayBufferView} + */ + get: function (symbol) { + var uniform = this.uniforms[symbol]; + if (uniform) { + return uniform.value; + } + }, + /** + * Attach a shader instance + * @param {clay.Shader} shader + * @param {boolean} keepStatus If try to keep uniform and texture + */ + attachShader: function(shader, keepStatus) { + var originalUniforms = this.uniforms; - /* PixelFormat */ - DEPTH_COMPONENT : 0x1902, - ALPHA : 0x1906, - RGB : 0x1907, - RGBA : 0x1908, - LUMINANCE : 0x1909, - LUMINANCE_ALPHA : 0x190A, + // Ignore if uniform can use in shader. + this.uniforms = shader.createUniforms(); + this.shader = shader; - /* PixelType */ - /* UNSIGNED_BYTE */ - UNSIGNED_SHORT_4_4_4_4 : 0x8033, - UNSIGNED_SHORT_5_5_5_1 : 0x8034, - UNSIGNED_SHORT_5_6_5 : 0x8363, + var uniforms = this.uniforms; + this._enabledUniforms = Object.keys(uniforms); + // Make sure uniforms are set in same order to avoid texture slot wrong + this._enabledUniforms.sort(); + this._textureUniforms = this._enabledUniforms.filter(function (uniformName) { + var type = this.uniforms[uniformName].type; + return type === 't' || type === 'tv'; + }, this); - /* Shaders */ - FRAGMENT_SHADER : 0x8B30, - VERTEX_SHADER : 0x8B31, - MAX_VERTEX_ATTRIBS : 0x8869, - MAX_VERTEX_UNIFORM_VECTORS : 0x8DFB, - MAX_VARYING_VECTORS : 0x8DFC, - MAX_COMBINED_TEXTURE_IMAGE_UNITS : 0x8B4D, - MAX_VERTEX_TEXTURE_IMAGE_UNITS : 0x8B4C, - MAX_TEXTURE_IMAGE_UNITS : 0x8872, - MAX_FRAGMENT_UNIFORM_VECTORS : 0x8DFD, - SHADER_TYPE : 0x8B4F, - DELETE_STATUS : 0x8B80, - LINK_STATUS : 0x8B82, - VALIDATE_STATUS : 0x8B83, - ATTACHED_SHADERS : 0x8B85, - ACTIVE_UNIFORMS : 0x8B86, - ACTIVE_ATTRIBUTES : 0x8B89, - SHADING_LANGUAGE_VERSION : 0x8B8C, - CURRENT_PROGRAM : 0x8B8D, + var originalVertexDefines = this.vertexDefines; + var originalFragmentDefines = this.fragmentDefines; - /* StencilFunction */ - NEVER : 0x0200, - LESS : 0x0201, - EQUAL : 0x0202, - LEQUAL : 0x0203, - GREATER : 0x0204, - NOTEQUAL : 0x0205, - GEQUAL : 0x0206, - ALWAYS : 0x0207, + this.vertexDefines = __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].clone(shader.vertexDefines); + this.fragmentDefines = __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].clone(shader.fragmentDefines); - /* StencilOp */ - /* ZERO */ - KEEP : 0x1E00, - REPLACE : 0x1E01, - INCR : 0x1E02, - DECR : 0x1E03, - INVERT : 0x150A, - INCR_WRAP : 0x8507, - DECR_WRAP : 0x8508, + if (keepStatus) { + for (var symbol in originalUniforms) { + if (uniforms[symbol]) { + uniforms[symbol].value = originalUniforms[symbol].value; + } + } - /* StringName */ - VENDOR : 0x1F00, - RENDERER : 0x1F01, - VERSION : 0x1F02, + __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].defaults(this.vertexDefines, originalVertexDefines); + __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].defaults(this.fragmentDefines, originalFragmentDefines); + } - /* TextureMagFilter */ - NEAREST : 0x2600, - LINEAR : 0x2601, + var textureStatus = {}; + for (var key in shader.textures) { + textureStatus[key] = { + shaderType: shader.textures[key].shaderType, + type: shader.textures[key].type, + enabled: (keepStatus && this._textureStatus[key]) ? this._textureStatus[key].enabled : false + }; + } - /* TextureMinFilter */ - /* NEAREST */ - /* LINEAR */ - NEAREST_MIPMAP_NEAREST : 0x2700, - LINEAR_MIPMAP_NEAREST : 0x2701, - NEAREST_MIPMAP_LINEAR : 0x2702, - LINEAR_MIPMAP_LINEAR : 0x2703, + this._textureStatus = textureStatus; - /* TextureParameterName */ - TEXTURE_MAG_FILTER : 0x2800, - TEXTURE_MIN_FILTER : 0x2801, - TEXTURE_WRAP_S : 0x2802, - TEXTURE_WRAP_T : 0x2803, + this._programKey = ''; + }, - /* TextureTarget */ - TEXTURE_2D : 0x0DE1, - TEXTURE : 0x1702, + /** + * Clone a new material and keep uniforms, shader will not be cloned + * @return {clay.Material} + */ + clone: function () { + var material = new this.constructor({ + name: this.name, + shader: this.shader + }); + for (var symbol in this.uniforms) { + material.uniforms[symbol].value = this.uniforms[symbol].value; + } + material.depthTest = this.depthTest; + material.depthMask = this.depthMask; + material.transparent = this.transparent; + material.blend = this.blend; - TEXTURE_CUBE_MAP : 0x8513, - TEXTURE_BINDING_CUBE_MAP : 0x8514, - TEXTURE_CUBE_MAP_POSITIVE_X : 0x8515, - TEXTURE_CUBE_MAP_NEGATIVE_X : 0x8516, - TEXTURE_CUBE_MAP_POSITIVE_Y : 0x8517, - TEXTURE_CUBE_MAP_NEGATIVE_Y : 0x8518, - TEXTURE_CUBE_MAP_POSITIVE_Z : 0x8519, - TEXTURE_CUBE_MAP_NEGATIVE_Z : 0x851A, - MAX_CUBE_MAP_TEXTURE_SIZE : 0x851C, + material.vertexDefines = __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].clone(this.vertexDefines); + material.fragmentDefines = __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].clone(this.fragmentDefines); + material.enableTexture(this.getEnabledTextures()); + material.precision = this.precision; - /* TextureUnit */ - TEXTURE0 : 0x84C0, - TEXTURE1 : 0x84C1, - TEXTURE2 : 0x84C2, - TEXTURE3 : 0x84C3, - TEXTURE4 : 0x84C4, - TEXTURE5 : 0x84C5, - TEXTURE6 : 0x84C6, - TEXTURE7 : 0x84C7, - TEXTURE8 : 0x84C8, - TEXTURE9 : 0x84C9, - TEXTURE10 : 0x84CA, - TEXTURE11 : 0x84CB, - TEXTURE12 : 0x84CC, - TEXTURE13 : 0x84CD, - TEXTURE14 : 0x84CE, - TEXTURE15 : 0x84CF, - TEXTURE16 : 0x84D0, - TEXTURE17 : 0x84D1, - TEXTURE18 : 0x84D2, - TEXTURE19 : 0x84D3, - TEXTURE20 : 0x84D4, - TEXTURE21 : 0x84D5, - TEXTURE22 : 0x84D6, - TEXTURE23 : 0x84D7, - TEXTURE24 : 0x84D8, - TEXTURE25 : 0x84D9, - TEXTURE26 : 0x84DA, - TEXTURE27 : 0x84DB, - TEXTURE28 : 0x84DC, - TEXTURE29 : 0x84DD, - TEXTURE30 : 0x84DE, - TEXTURE31 : 0x84DF, - ACTIVE_TEXTURE : 0x84E0, - - /* TextureWrapMode */ - REPEAT : 0x2901, - CLAMP_TO_EDGE : 0x812F, - MIRRORED_REPEAT : 0x8370, - - /* Uniform Types */ - FLOAT_VEC2 : 0x8B50, - FLOAT_VEC3 : 0x8B51, - FLOAT_VEC4 : 0x8B52, - INT_VEC2 : 0x8B53, - INT_VEC3 : 0x8B54, - INT_VEC4 : 0x8B55, - BOOL : 0x8B56, - BOOL_VEC2 : 0x8B57, - BOOL_VEC3 : 0x8B58, - BOOL_VEC4 : 0x8B59, - FLOAT_MAT2 : 0x8B5A, - FLOAT_MAT3 : 0x8B5B, - FLOAT_MAT4 : 0x8B5C, - SAMPLER_2D : 0x8B5E, - SAMPLER_CUBE : 0x8B60, - - /* Vertex Arrays */ - VERTEX_ATTRIB_ARRAY_ENABLED : 0x8622, - VERTEX_ATTRIB_ARRAY_SIZE : 0x8623, - VERTEX_ATTRIB_ARRAY_STRIDE : 0x8624, - VERTEX_ATTRIB_ARRAY_TYPE : 0x8625, - VERTEX_ATTRIB_ARRAY_NORMALIZED : 0x886A, - VERTEX_ATTRIB_ARRAY_POINTER : 0x8645, - VERTEX_ATTRIB_ARRAY_BUFFER_BINDING : 0x889F, - - /* Shader Source */ - COMPILE_STATUS : 0x8B81, - - /* Shader Precision-Specified Types */ - LOW_FLOAT : 0x8DF0, - MEDIUM_FLOAT : 0x8DF1, - HIGH_FLOAT : 0x8DF2, - LOW_INT : 0x8DF3, - MEDIUM_INT : 0x8DF4, - HIGH_INT : 0x8DF5, + return material; + }, - /* Framebuffer Object. */ - FRAMEBUFFER : 0x8D40, - RENDERBUFFER : 0x8D41, + /** + * Add a #define macro in shader code + * @param {string} shaderType Can be vertex, fragment or both + * @param {string} symbol + * @param {number} [val] + */ + define: function (shaderType, symbol, val) { + var vertexDefines = this.vertexDefines; + var fragmentDefines = this.fragmentDefines; + if (shaderType !== 'vertex' && shaderType !== 'fragment' && shaderType !== 'both' + && arguments.length < 3 + ) { + // shaderType default to be 'both' + val = symbol; + symbol = shaderType; + shaderType = 'both'; + } + val = val != null ? val : null; + if (shaderType === 'vertex' || shaderType === 'both') { + if (vertexDefines[symbol] !== val) { + vertexDefines[symbol] = val; + // Mark as dirty + this._programKey = ''; + } + } + if (shaderType === 'fragment' || shaderType === 'both') { + if (fragmentDefines[symbol] !== val) { + fragmentDefines[symbol] = val; + if (shaderType !== 'both') { + this._programKey = ''; + } + } + } + }, - RGBA4 : 0x8056, - RGB5_A1 : 0x8057, - RGB565 : 0x8D62, - DEPTH_COMPONENT16 : 0x81A5, - STENCIL_INDEX : 0x1901, - STENCIL_INDEX8 : 0x8D48, - DEPTH_STENCIL : 0x84F9, + /** + * Remove a #define macro in shader code + * @param {string} shaderType Can be vertex, fragment or both + * @param {string} symbol + */ + undefine: function (shaderType, symbol) { + if (shaderType !== 'vertex' && shaderType !== 'fragment' && shaderType !== 'both' + && arguments.length < 2 + ) { + // shaderType default to be 'both' + symbol = shaderType; + shaderType = 'both'; + } + if (shaderType === 'vertex' || shaderType === 'both') { + if (this.isDefined('vertex', symbol)) { + delete this.vertexDefines[symbol]; + // Mark as dirty + this._programKey = ''; + } + } + if (shaderType === 'fragment' || shaderType === 'both') { + if (this.isDefined('fragment', symbol)) { + delete this.fragmentDefines[symbol]; + if (shaderType !== 'both') { + this._programKey = ''; + } + } + } + }, - RENDERBUFFER_WIDTH : 0x8D42, - RENDERBUFFER_HEIGHT : 0x8D43, - RENDERBUFFER_INTERNAL_FORMAT : 0x8D44, - RENDERBUFFER_RED_SIZE : 0x8D50, - RENDERBUFFER_GREEN_SIZE : 0x8D51, - RENDERBUFFER_BLUE_SIZE : 0x8D52, - RENDERBUFFER_ALPHA_SIZE : 0x8D53, - RENDERBUFFER_DEPTH_SIZE : 0x8D54, - RENDERBUFFER_STENCIL_SIZE : 0x8D55, + /** + * If macro is defined in shader. + * @param {string} shaderType Can be vertex, fragment or both + * @param {string} symbol + */ + isDefined: function (shaderType, symbol) { + // PENDING hasOwnProperty ? + switch (shaderType) { + case 'vertex': + return this.vertexDefines[symbol] !== undefined; + case 'fragment': + return this.fragmentDefines[symbol] !== undefined; + } + }, + /** + * Get macro value defined in shader. + * @param {string} shaderType Can be vertex, fragment or both + * @param {string} symbol + */ + getDefine: function (shaderType, symbol) { + switch(shaderType) { + case 'vertex': + return this.vertexDefines[symbol]; + case 'fragment': + return this.fragmentDefines[symbol]; + } + }, + /** + * Enable a texture, actually it will add a #define macro in the shader code + * For example, if texture symbol is diffuseMap, it will add a line `#define DIFFUSEMAP_ENABLED` in the shader code + * @param {string} symbol + */ + enableTexture: function (symbol) { + if (Array.isArray(symbol)) { + for (var i = 0; i < symbol.length; i++) { + this.enableTexture(symbol[i]); + } + return; + } - FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE : 0x8CD0, - FRAMEBUFFER_ATTACHMENT_OBJECT_NAME : 0x8CD1, - FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL : 0x8CD2, - FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE : 0x8CD3, + var status = this._textureStatus[symbol]; + if (status) { + var isEnabled = status.enabled; + if (!isEnabled) { + status.enabled = true; + this._programKey = ''; + } + } + }, + /** + * Enable all textures used in the shader + */ + enableTexturesAll: function () { + var textureStatus = this._textureStatus; + for (var symbol in textureStatus) { + textureStatus[symbol].enabled = true; + } - COLOR_ATTACHMENT0 : 0x8CE0, - DEPTH_ATTACHMENT : 0x8D00, - STENCIL_ATTACHMENT : 0x8D20, - DEPTH_STENCIL_ATTACHMENT : 0x821A, + this._programKey = ''; + }, + /** + * Disable a texture, it remove a #define macro in the shader + * @param {string} symbol + */ + disableTexture: function (symbol) { + if (Array.isArray(symbol)) { + for (var i = 0; i < symbol.length; i++) { + this.disableTexture(symbol[i]); + } + return; + } - NONE : 0, + var status = this._textureStatus[symbol]; + if (status) { + var isDisabled = ! status.enabled; + if (!isDisabled) { + status.enabled = false; + this._programKey = ''; + } + } + }, + /** + * Disable all textures used in the shader + */ + disableTexturesAll: function () { + var textureStatus = this._textureStatus; + for (var symbol in textureStatus) { + textureStatus[symbol].enabled = false; + } - FRAMEBUFFER_COMPLETE : 0x8CD5, - FRAMEBUFFER_INCOMPLETE_ATTACHMENT : 0x8CD6, - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : 0x8CD7, - FRAMEBUFFER_INCOMPLETE_DIMENSIONS : 0x8CD9, - FRAMEBUFFER_UNSUPPORTED : 0x8CDD, + this._programKey = ''; + }, + /** + * If texture of given type is enabled. + * @param {string} symbol + * @return {boolean} + */ + isTextureEnabled: function (symbol) { + var textureStatus = this._textureStatus; + return !!textureStatus[symbol] + && textureStatus[symbol].enabled; + }, - FRAMEBUFFER_BINDING : 0x8CA6, - RENDERBUFFER_BINDING : 0x8CA7, - MAX_RENDERBUFFER_SIZE : 0x84E8, + /** + * Get all enabled textures + * @return {string[]} + */ + getEnabledTextures: function () { + var enabledTextures = []; + var textureStatus = this._textureStatus; + for (var symbol in textureStatus) { + if (textureStatus[symbol].enabled) { + enabledTextures.push(symbol); + } + } + return enabledTextures; + }, - INVALID_FRAMEBUFFER_OPERATION : 0x0506, + /** + * Mark defines are updated. + */ + dirtyDefines: function () { + this._programKey = ''; + }, - /* WebGL-specific enums */ - UNPACK_FLIP_Y_WEBGL : 0x9240, - UNPACK_PREMULTIPLY_ALPHA_WEBGL : 0x9241, - CONTEXT_LOST_WEBGL : 0x9242, - UNPACK_COLORSPACE_CONVERSION_WEBGL : 0x9243, - BROWSER_DEFAULT_WEBGL : 0x9244, + getProgramKey: function () { + if (!this._programKey) { + this._programKey = getProgramKey( + this.vertexDefines, this.fragmentDefines, this.getEnabledTextures() + ); + } + return this._programKey; + } }); +/* harmony default export */ __webpack_exports__["a"] = (Material); -/***/ }), -/* 12 */ -/***/ (function(module, exports) { - -/** - * @module zrender/core/util - */ -// 用于处理merge时无法遍历Date等对象的问题 -var BUILTIN_OBJECT = { - '[object Function]': 1, - '[object RegExp]': 1, - '[object Date]': 1, - '[object Error]': 1, - '[object CanvasGradient]': 1, - '[object CanvasPattern]': 1, - // For node-canvas - '[object Image]': 1, - '[object Canvas]': 1 -}; -var TYPED_ARRAY = { - '[object Int8Array]': 1, - '[object Uint8Array]': 1, - '[object Uint8ClampedArray]': 1, - '[object Int16Array]': 1, - '[object Uint16Array]': 1, - '[object Int32Array]': 1, - '[object Uint32Array]': 1, - '[object Float32Array]': 1, - '[object Float64Array]': 1 -}; -var objToString = Object.prototype.toString; -var arrayProto = Array.prototype; -var nativeForEach = arrayProto.forEach; -var nativeFilter = arrayProto.filter; -var nativeSlice = arrayProto.slice; -var nativeMap = arrayProto.map; -var nativeReduce = arrayProto.reduce; // Avoid assign to an exported variable, for transforming to cjs. - -var methods = {}; - -function $override(name, fn) { - // Clear ctx instance for different environment - if (name === 'createCanvas') { - _ctx = null; - } - methods[name] = fn; -} -/** - * Those data types can be cloned: - * Plain object, Array, TypedArray, number, string, null, undefined. - * Those data types will be assgined using the orginal data: - * BUILTIN_OBJECT - * Instance of user defined class will be cloned to a plain object, without - * properties in prototype. - * Other data types is not supported (not sure what will happen). - * - * Caution: do not support clone Date, for performance consideration. - * (There might be a large number of date in `series.data`). - * So date should not be modified in and out of echarts. - * - * @param {*} source - * @return {*} new - */ +/***/ }), +/* 20 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return GLMAT_EPSILON; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return GLMAT_ARRAY_TYPE; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return GLMAT_RANDOM; }); -function clone(source) { - if (source == null || typeof source != 'object') { - return source; - } +var GLMAT_EPSILON = 0.000001; - var result = source; - var typeStr = objToString.call(source); +// Use Array instead of Float32Array. It seems to be much faster and higher precision. +var GLMAT_ARRAY_TYPE = Array; +// if(!GLMAT_ARRAY_TYPE) { +// GLMAT_ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array; +// } - if (typeStr === '[object Array]') { - if (!isPrimitive(source)) { - result = []; +var GLMAT_RANDOM = Math.random; - for (var i = 0, len = source.length; i < len; i++) { - result[i] = clone(source[i]); - } - } - } else if (TYPED_ARRAY[typeStr]) { - if (!isPrimitive(source)) { - var Ctor = source.constructor; - if (source.constructor.from) { - result = Ctor.from(source); - } else { - result = new Ctor(source.length); +/***/ }), +/* 21 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - for (var i = 0, len = source.length; i < len; i++) { - result[i] = clone(source[i]); - } - } - } - } else if (!BUILTIN_OBJECT[typeStr] && !isPrimitive(source) && !isDom(source)) { - result = {}; +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20); - for (var key in source) { - if (source.hasOwnProperty(key)) { - result[key] = clone(source[key]); - } - } - } +/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. - return result; -} -/** - * @memberOf module:zrender/core/util - * @param {*} target - * @param {*} source - * @param {boolean} [overwrite=false] - */ +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. -function merge(target, source, overwrite) { - // We should escapse that source is string - // and enter for ... in ... - if (!isObject(source) || !isObject(target)) { - return overwrite ? clone(source) : target; - } +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 HOLDER 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 USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - for (var key in source) { - if (source.hasOwnProperty(key)) { - var targetProp = target[key]; - var sourceProp = source[key]; - if (isObject(sourceProp) && isObject(targetProp) && !isArray(sourceProp) && !isArray(targetProp) && !isDom(sourceProp) && !isDom(targetProp) && !isBuiltInObject(sourceProp) && !isBuiltInObject(targetProp) && !isPrimitive(sourceProp) && !isPrimitive(targetProp)) { - // 如果需要递归覆盖,就递归调用merge - merge(targetProp, sourceProp, overwrite); - } else if (overwrite || !(key in target)) { - // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况 - // NOTE,在 target[key] 不存在的时候也是直接覆盖 - target[key] = clone(source[key], true); - } - } - } - return target; -} /** - * @param {Array} targetAndSources The first item is target, and the rests are source. - * @param {boolean} [overwrite=false] - * @return {*} target + * @class 4x4 Matrix + * @name mat4 */ +var mat4 = {}; -function mergeAll(targetAndSources, overwrite) { - var result = targetAndSources[0]; - - for (var i = 1, len = targetAndSources.length; i < len; i++) { - result = merge(result, targetAndSources[i], overwrite); - } - - return result; -} /** - * @param {*} target - * @param {*} source - * @memberOf module:zrender/core/util + * Creates a new identity mat4 + * + * @returns {mat4} a new 4x4 matrix */ +mat4.create = function() { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](16); + 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; +}; - -function extend(target, source) { - for (var key in source) { - if (source.hasOwnProperty(key)) { - target[key] = source[key]; - } - } - - return target; -} /** - * @param {*} target - * @param {*} source - * @param {boolean} [overlay=false] - * @memberOf module:zrender/core/util - */ - - -function defaults(target, source, overlay) { - for (var key in source) { - if (source.hasOwnProperty(key) && (overlay ? source[key] != null : target[key] == null)) { - target[key] = source[key]; - } - } - - return target; -} - -var createCanvas = function () { - return methods.createCanvas(); + * Creates a new mat4 initialized with values from an existing matrix + * + * @param {mat4} a matrix to clone + * @returns {mat4} a new 4x4 matrix + */ +mat4.clone = function(a) { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_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; }; -methods.createCanvas = function () { - return document.createElement('canvas'); -}; // FIXME - - -var _ctx; - -function getContext() { - if (!_ctx) { - // Use util.createCanvas instead of createCanvas - // because createCanvas may be overwritten in different environment - _ctx = createCanvas().getContext('2d'); - } +/** + * Copy the values from one mat4 to another + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the source matrix + * @returns {mat4} out + */ +mat4.copy = function(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; +}; - return _ctx; -} /** - * 查询数组中元素的index - * @memberOf module:zrender/core/util + * Set a mat4 to the identity matrix + * + * @param {mat4} out the receiving matrix + * @returns {mat4} out */ +mat4.identity = function(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 + */ +mat4.transpose = function(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], + a12 = a[6], a13 = a[7], + a23 = a[11]; -function indexOf(array, value) { - if (array) { - if (array.indexOf) { - return array.indexOf(value); + 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]; } - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] === value) { - return i; - } - } - } + return out; +}; - return -1; -} /** - * 构造类继承关系 + * Inverts a mat4 * - * @memberOf module:zrender/core/util - * @param {Function} clazz 源类 - * @param {Function} baseClazz 基类 + * @param {mat4} out the receiving matrix + * @param {mat4} a the source matrix + * @returns {mat4} out */ +mat4.invert = function(out, a) { + var 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], + a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], + b00 = a00 * a11 - a01 * a10, + b01 = a00 * a12 - a02 * a10, + b02 = a00 * a13 - a03 * a10, + b03 = a01 * a12 - a02 * a11, + b04 = a01 * a13 - a03 * a11, + b05 = a02 * a13 - a03 * a12, + b06 = a20 * a31 - a21 * a30, + b07 = a20 * a32 - a22 * a30, + b08 = a20 * a33 - a23 * a30, + b09 = a21 * a32 - a22 * a31, + b10 = a21 * a33 - a23 * a31, + b11 = a22 * a33 - a23 * a32, -function inherits(clazz, baseClazz) { - var clazzPrototype = clazz.prototype; + // Calculate the determinant + det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - function F() {} + if (!det) { + return null; + } + det = 1.0 / det; - F.prototype = baseClazz.prototype; - clazz.prototype = new F(); + 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; - for (var prop in clazzPrototype) { - clazz.prototype[prop] = clazzPrototype[prop]; - } + return out; +}; - clazz.prototype.constructor = clazz; - clazz.superClass = baseClazz; -} /** - * @memberOf module:zrender/core/util - * @param {Object|Function} target - * @param {Object|Function} sorce - * @param {boolean} overlay + * Calculates the adjugate of a mat4 + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the source matrix + * @returns {mat4} out */ +mat4.adjoint = function(out, a) { + var 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], + 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; +}; -function mixin(target, source, overlay) { - target = 'prototype' in target ? target.prototype : target; - source = 'prototype' in source ? source.prototype : source; - defaults(target, source, overlay); -} /** - * Consider typed array. - * @param {Array|TypedArray} data + * Calculates the determinant of a mat4 + * + * @param {mat4} a the source matrix + * @returns {Number} determinant of a */ +mat4.determinant = function (a) { + var 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], + a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], + b00 = a00 * a11 - a01 * a10, + b01 = a00 * a12 - a02 * a10, + b02 = a00 * a13 - a03 * a10, + b03 = a01 * a12 - a02 * a11, + b04 = a01 * a13 - a03 * a11, + b05 = a02 * a13 - a03 * a12, + b06 = a20 * a31 - a21 * a30, + b07 = a20 * a32 - a22 * a30, + b08 = a20 * a33 - a23 * a30, + b09 = a21 * a32 - a22 * a31, + b10 = a21 * a33 - a23 * a31, + b11 = a22 * a33 - a23 * a32; -function isArrayLike(data) { - if (!data) { - return; - } - - if (typeof data == 'string') { - return false; - } + // Calculate the determinant + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; +}; - return typeof data.length == 'number'; -} /** - * 数组或对象遍历 - * @memberOf module:zrender/core/util - * @param {Object|Array} obj - * @param {Function} cb - * @param {*} [context] + * Multiplies two mat4's + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @returns {mat4} out */ +mat4.multiply = function (out, a, b) { + var 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], + 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; -function each(obj, cb, context) { - if (!(obj && cb)) { - return; - } + 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; +}; - if (obj.forEach && obj.forEach === nativeForEach) { - obj.forEach(cb, context); - } else if (obj.length === +obj.length) { - for (var i = 0, len = obj.length; i < len; i++) { - cb.call(context, obj[i], i, obj); - } - } else { - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - cb.call(context, obj[key], key, obj); - } - } - } -} /** - * 数组映射 - * @memberOf module:zrender/core/util - * @param {Array} obj - * @param {Function} cb - * @param {*} [context] - * @return {Array} + * Multiplies two affine mat4's + * Add by https://github.com/pissang + * @param {mat4} out the receiving matrix + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @returns {mat4} out */ +mat4.multiplyAffine = function (out, a, b) { + var a00 = a[0], a01 = a[1], a02 = a[2], + a10 = a[4], a11 = a[5], a12 = a[6], + a20 = a[8], a21 = a[9], a22 = a[10], + a30 = a[12], a31 = a[13], a32 = a[14]; + // Cache only the current line of the second matrix + var b0 = b[0], b1 = b[1], b2 = b[2]; + out[0] = b0*a00 + b1*a10 + b2*a20; + out[1] = b0*a01 + b1*a11 + b2*a21; + out[2] = b0*a02 + b1*a12 + b2*a22; + // out[3] = 0; -function map(obj, cb, context) { - if (!(obj && cb)) { - return; - } + b0 = b[4]; b1 = b[5]; b2 = b[6]; + out[4] = b0*a00 + b1*a10 + b2*a20; + out[5] = b0*a01 + b1*a11 + b2*a21; + out[6] = b0*a02 + b1*a12 + b2*a22; + // out[7] = 0; - if (obj.map && obj.map === nativeMap) { - return obj.map(cb, context); - } else { - var result = []; + b0 = b[8]; b1 = b[9]; b2 = b[10]; + out[8] = b0*a00 + b1*a10 + b2*a20; + out[9] = b0*a01 + b1*a11 + b2*a21; + out[10] = b0*a02 + b1*a12 + b2*a22; + // out[11] = 0; - for (var i = 0, len = obj.length; i < len; i++) { - result.push(cb.call(context, obj[i], i, obj)); - } + b0 = b[12]; b1 = b[13]; b2 = b[14]; + out[12] = b0*a00 + b1*a10 + b2*a20 + a30; + out[13] = b0*a01 + b1*a11 + b2*a21 + a31; + out[14] = b0*a02 + b1*a12 + b2*a22 + a32; + // out[15] = 1; + return out; +}; - return result; - } -} /** - * @memberOf module:zrender/core/util - * @param {Array} obj - * @param {Function} cb - * @param {Object} [memo] - * @param {*} [context] - * @return {Array} + * Alias for {@link mat4.multiply} + * @function */ +mat4.mul = mat4.multiply; - -function reduce(obj, cb, memo, context) { - if (!(obj && cb)) { - return; - } - - if (obj.reduce && obj.reduce === nativeReduce) { - return obj.reduce(cb, memo, context); - } else { - for (var i = 0, len = obj.length; i < len; i++) { - memo = cb.call(context, memo, obj[i], i, obj); - } - - return memo; - } -} /** - * 数组过滤 - * @memberOf module:zrender/core/util - * @param {Array} obj - * @param {Function} cb - * @param {*} [context] - * @return {Array} + * Alias for {@link mat4.multiplyAffine} + * @function */ - - -function filter(obj, cb, context) { - if (!(obj && cb)) { - return; - } - - if (obj.filter && obj.filter === nativeFilter) { - return obj.filter(cb, context); - } else { - var result = []; - - for (var i = 0, len = obj.length; i < len; i++) { - if (cb.call(context, obj[i], i, obj)) { - result.push(obj[i]); - } - } - - return result; - } -} +mat4.mulAffine = mat4.multiplyAffine; /** - * 数组项查找 - * @memberOf module:zrender/core/util - * @param {Array} obj - * @param {Function} cb - * @param {*} [context] - * @return {*} + * 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 */ +mat4.translate = function (out, a, v) { + var x = v[0], y = v[1], z = v[2], + a00, a01, a02, a03, + a10, a11, a12, a13, + a20, a21, a22, a23; + 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]; -function find(obj, cb, context) { - if (!(obj && cb)) { - return; - } + 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; - for (var i = 0, len = obj.length; i < len; i++) { - if (cb.call(context, obj[i], i, obj)) { - return obj[i]; + 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]; } - } -} -/** - * @memberOf module:zrender/core/util - * @param {Function} func - * @param {*} context - * @return {Function} - */ + return out; +}; -function bind(func, context) { - var args = nativeSlice.call(arguments, 2); - return function () { - return func.apply(context, args.concat(nativeSlice.call(arguments))); - }; -} /** - * @memberOf module:zrender/core/util - * @param {Function} func - * @return {Function} - */ + * Scales the mat4 by the dimensions in the given vec3 + * + * @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 + **/ +mat4.scale = function(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; +}; -function curry(func) { - var args = nativeSlice.call(arguments, 1); - return function () { - return func.apply(this, args.concat(nativeSlice.call(arguments))); - }; -} /** - * @memberOf module:zrender/core/util - * @param {*} value - * @return {boolean} + * Rotates a mat4 by the given angle + * + * @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 */ +mat4.rotate = function (out, a, rad, axis) { + var x = axis[0], y = axis[1], z = axis[2], + len = Math.sqrt(x * x + y * y + z * z), + s, c, t, + a00, a01, a02, a03, + a10, a11, a12, a13, + a20, a21, a22, a23, + b00, b01, b02, + b10, b11, b12, + b20, b21, b22; + if (Math.abs(len) < __WEBPACK_IMPORTED_MODULE_0__common__["b" /* GLMAT_EPSILON */]) { return null; } -function isArray(value) { - return objToString.call(value) === '[object Array]'; -} -/** - * @memberOf module:zrender/core/util - * @param {*} value - * @return {boolean} - */ + len = 1 / len; + x *= len; + y *= len; + z *= len; + s = Math.sin(rad); + c = Math.cos(rad); + t = 1 - c; -function isFunction(value) { - return typeof value === 'function'; -} -/** - * @memberOf module:zrender/core/util - * @param {*} value - * @return {boolean} - */ + 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; -function isString(value) { - return objToString.call(value) === '[object String]'; -} -/** - * @memberOf module:zrender/core/util - * @param {*} value - * @return {boolean} - */ + // 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; +}; -function isObject(value) { - // Avoid a V8 JIT bug in Chrome 19-20. - // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. - var type = typeof value; - return type === 'function' || !!value && type == 'object'; -} /** - * @memberOf module:zrender/core/util - * @param {*} value - * @return {boolean} + * 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 */ +mat4.rotateX = function (out, a, rad) { + var s = Math.sin(rad), + c = Math.cos(rad), + a10 = a[4], + a11 = a[5], + a12 = a[6], + a13 = a[7], + a20 = a[8], + a21 = a[9], + a22 = a[10], + 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]; + } -function isBuiltInObject(value) { - return !!BUILTIN_OBJECT[objToString.call(value)]; -} -/** - * @memberOf module:zrender/core/util - * @param {*} value - * @return {boolean} - */ - + // 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; +}; -function isTypedArray(value) { - return !!TYPED_ARRAY[objToString.call(value)]; -} /** - * @memberOf module:zrender/core/util - * @param {*} value - * @return {boolean} + * 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 */ +mat4.rotateY = function (out, a, rad) { + var s = Math.sin(rad), + c = Math.cos(rad), + a00 = a[0], + a01 = a[1], + a02 = a[2], + a03 = a[3], + a20 = a[8], + a21 = a[9], + a22 = a[10], + 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]; + } -function isDom(value) { - return typeof value === 'object' && typeof value.nodeType === 'number' && typeof value.ownerDocument === 'object'; -} -/** - * Whether is exactly NaN. Notice isNaN('a') returns true. - * @param {*} value - * @return {boolean} - */ - + // 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; +}; -function eqNaN(value) { - return value !== value; -} /** - * If value1 is not null, then return value1, otherwise judget rest of values. - * Low performance. - * @memberOf module:zrender/core/util - * @return {*} Final value + * 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 */ +mat4.rotateZ = function (out, a, rad) { + var s = Math.sin(rad), + c = Math.cos(rad), + a00 = a[0], + a01 = a[1], + a02 = a[2], + a03 = a[3], + a10 = a[4], + a11 = a[5], + a12 = a[6], + a13 = a[7]; - -function retrieve(values) { - for (var i = 0, len = arguments.length; i < len; i++) { - if (arguments[i] != null) { - return arguments[i]; + 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]; } - } -} -function retrieve2(value0, value1) { - return value0 != null ? value0 : value1; -} + // 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; +}; -function retrieve3(value0, value1, value2) { - return value0 != null ? value0 : value1 != null ? value1 : value2; -} /** - * @memberOf module:zrender/core/util - * @param {Array} arr - * @param {number} startIndex - * @param {number} endIndex - * @return {Array} + * 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); + * var 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 */ +mat4.fromRotationTranslation = function (out, q, v) { + // Quaternion math + var x = q[0], y = q[1], z = q[2], w = q[3], + x2 = x + x, + y2 = y + y, + z2 = z + z, + xx = x * x2, + xy = x * y2, + xz = x * z2, + yy = y * y2, + yz = y * z2, + zz = z * z2, + wx = w * x2, + wy = w * y2, + wz = w * z2; -function slice() { - return Function.call.apply(nativeSlice, arguments); -} -/** - * Normalize css liked array configuration - * e.g. - * 3 => [3, 3, 3, 3] - * [4, 2] => [4, 2, 4, 2] - * [4, 3, 2] => [4, 3, 2, 3] - * @param {number|Array.} val - * @return {Array.} - */ - + 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; -function normalizeCssArray(val) { - if (typeof val === 'number') { - return [val, val, val, val]; - } + return out; +}; - var len = val.length; +mat4.fromQuat = function (out, q) { + var x = q[0], y = q[1], z = q[2], w = q[3], + x2 = x + x, + y2 = y + y, + z2 = z + z, - if (len === 2) { - // vertical | horizontal - return [val[0], val[1], val[0], val[1]]; - } else if (len === 3) { - // top | horizontal | bottom - return [val[0], val[1], val[2], val[1]]; - } + xx = x * x2, + yx = y * x2, + yy = y * y2, + zx = z * x2, + zy = z * y2, + zz = z * z2, + wx = w * x2, + wy = w * y2, + wz = w * z2; - return val; -} -/** - * @memberOf module:zrender/core/util - * @param {boolean} condition - * @param {string} message - */ + 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; -function assert(condition, message) { - if (!condition) { - throw new Error(message); - } -} -/** - * @memberOf module:zrender/core/util - * @param {string} str string to be trimed - * @return {string} trimed string - */ + 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; -function trim(str) { - if (str == null) { - return null; - } else if (typeof str.trim === 'function') { - return str.trim(); - } else { - return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); - } -} + return out; +}; -var primitiveKey = '__ec_primitive__'; /** - * Set an object as primitive to be ignored traversing children in clone or merge + * 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 */ +mat4.frustum = function (out, left, right, bottom, top, near, far) { + var rl = 1 / (right - left), + tb = 1 / (top - bottom), + 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; +}; -function setAsPrimitive(obj) { - obj[primitiveKey] = true; -} - -function isPrimitive(obj) { - return obj[primitiveKey]; -} /** - * @constructor - * @param {Object} obj Only apply `ownProperty`. + * Generates a perspective projection matrix with the given bounds + * + * @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 + * @returns {mat4} out */ +mat4.perspective = function (out, fovy, aspect, near, far) { + var f = 1.0 / Math.tan(fovy / 2), + nf = 1 / (near - far); + 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[10] = (far + near) * nf; + out[11] = -1; + out[12] = 0; + out[13] = 0; + out[14] = (2 * far * near) * nf; + out[15] = 0; + return out; +}; - -function HashMap(obj) { - var isArr = isArray(obj); - var thisMap = this; - obj instanceof HashMap ? obj.each(visit) : obj && each(obj, visit); - - function visit(value, key) { - isArr ? thisMap.set(value, key) : thisMap.set(key, value); - } -} // Add prefix to avoid conflict with Object.prototype. - - -HashMap.prototype = { - constructor: HashMap, - // Do not provide `has` method to avoid defining what is `has`. - // (We usually treat `null` and `undefined` as the same, different - // from ES6 Map). - get: function (key) { - return this.hasOwnProperty(key) ? this[key] : null; - }, - set: function (key, value) { - // Comparing with invocation chaining, `return value` is more commonly - // used in this case: `var someVal = map.set('a', genVal());` - return this[key] = value; - }, - // Although util.each can be performed on this hashMap directly, user - // should not use the exposed keys, who are prefixed. - each: function (cb, context) { - context !== void 0 && (cb = bind(cb, context)); - - for (var key in this) { - this.hasOwnProperty(key) && cb(this[key], key); - } - }, - // Do not use this method if performance sensitive. - removeKey: function (key) { - delete this[key]; - } +/** + * 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 + */ +mat4.ortho = function (out, left, right, bottom, top, near, far) { + var lr = 1 / (left - right), + bt = 1 / (bottom - top), + 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; }; -function createHashMap(obj) { - return new HashMap(obj); -} - -function concatArray(a, b) { - var newArray = new a.constructor(a.length + b.length); - - for (var i = 0; i < a.length; i++) { - newArray[i] = a[i]; - } - - var offset = a.length; - - for (i = 0; i < b.length; i++) { - newArray[i + offset] = b[i]; - } - - return newArray; -} - -function noop() {} - -exports.$override = $override; -exports.clone = clone; -exports.merge = merge; -exports.mergeAll = mergeAll; -exports.extend = extend; -exports.defaults = defaults; -exports.createCanvas = createCanvas; -exports.getContext = getContext; -exports.indexOf = indexOf; -exports.inherits = inherits; -exports.mixin = mixin; -exports.isArrayLike = isArrayLike; -exports.each = each; -exports.map = map; -exports.reduce = reduce; -exports.filter = filter; -exports.find = find; -exports.bind = bind; -exports.curry = curry; -exports.isArray = isArray; -exports.isFunction = isFunction; -exports.isString = isString; -exports.isObject = isObject; -exports.isBuiltInObject = isBuiltInObject; -exports.isTypedArray = isTypedArray; -exports.isDom = isDom; -exports.eqNaN = eqNaN; -exports.retrieve = retrieve; -exports.retrieve2 = retrieve2; -exports.retrieve3 = retrieve3; -exports.slice = slice; -exports.normalizeCssArray = normalizeCssArray; -exports.assert = assert; -exports.trim = trim; -exports.setAsPrimitive = setAsPrimitive; -exports.isPrimitive = isPrimitive; -exports.createHashMap = createHashMap; -exports.concatArray = concatArray; -exports.noop = noop; - -/***/ }), -/* 13 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_Cache__ = __webpack_require__(48); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_vendor__ = __webpack_require__(18); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4__dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__math_BoundingBox__ = __webpack_require__(15); - - - - - - - -var vec3 = __WEBPACK_IMPORTED_MODULE_4__dep_glmatrix___default.a.vec3; -var mat4 = __WEBPACK_IMPORTED_MODULE_4__dep_glmatrix___default.a.mat4; - -var vec3Create = vec3.create; -var vec3Add = vec3.add; -var vec3Set = vec3.set; - -function getArrayCtorByType (type) { - return ({ - 'byte': __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Int8Array, - 'ubyte': __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Uint8Array, - 'short': __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Int16Array, - 'ushort': __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Uint16Array - })[type] || __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Float32Array; -} - -function makeAttrKey(attrName) { - return 'attr_' + attrName; -} /** - * Geometry attribute - * @alias clay.Geometry.Attribute - * @constructor + * Generates a look-at matrix with the given eye position, focal point, and up axis + * + * @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 Attribute(name, type, size, semantic) { - /** - * Attribute name - * @type {string} - */ - this.name = name; - /** - * Attribute type - * Possible values: - * + `'byte'` - * + `'ubyte'` - * + `'short'` - * + `'ushort'` - * + `'float'` Most commonly used. - * @type {string} - */ - this.type = type; - /** - * Size of attribute component. 1 - 4. - * @type {number} - */ - this.size = size; - /** - * Semantic of this attribute. - * Possible values: - * + `'POSITION'` - * + `'NORMAL'` - * + `'BINORMAL'` - * + `'TANGENT'` - * + `'TEXCOORD'` - * + `'TEXCOORD_0'` - * + `'TEXCOORD_1'` - * + `'COLOR'` - * + `'JOINT'` - * + `'WEIGHT'` - * - * In shader, attribute with same semantic will be automatically mapped. For example: - * ```glsl - * attribute vec3 pos: POSITION - * ``` - * will use the attribute value with semantic POSITION in geometry, no matter what name it used. - * @type {string} - */ - this.semantic = semantic || ''; - - /** - * Value of the attribute. - * @type {TypedArray} - */ - this.value = null; +mat4.lookAt = function (out, eye, center, up) { + var x0, x1, x2, y0, y1, y2, z0, z1, z2, len, + eyex = eye[0], + eyey = eye[1], + eyez = eye[2], + upx = up[0], + upy = up[1], + upz = up[2], + centerx = center[0], + centery = center[1], + centerz = center[2]; - // Init getter setter - switch (size) { - case 1: - this.get = function (idx) { - return this.value[idx]; - }; - this.set = function (idx, value) { - this.value[idx] = value; - }; - // Copy from source to target - this.copy = function (target, source) { - this.value[target] = this.value[target]; - }; - break; - case 2: - this.get = function (idx, out) { - var arr = this.value; - out[0] = arr[idx * 2]; - out[1] = arr[idx * 2 + 1]; - return out; - }; - this.set = function (idx, val) { - var arr = this.value; - arr[idx * 2] = val[0]; - arr[idx * 2 + 1] = val[1]; - }; - this.copy = function (target, source) { - var arr = this.value; - source *= 2; - target *= 2; - arr[target] = arr[source]; - arr[target + 1] = arr[source + 1]; - }; - break; - case 3: - this.get = function (idx, out) { - var idx3 = idx * 3; - var arr = this.value; - out[0] = arr[idx3]; - out[1] = arr[idx3 + 1]; - out[2] = arr[idx3 + 2]; - return out; - }; - this.set = function (idx, val) { - var idx3 = idx * 3; - var arr = this.value; - arr[idx3] = val[0]; - arr[idx3 + 1] = val[1]; - arr[idx3 + 2] = val[2]; - }; - this.copy = function (target, source) { - var arr = this.value; - source *= 3; - target *= 3; - arr[target] = arr[source]; - arr[target + 1] = arr[source + 1]; - arr[target + 2] = arr[source + 2]; - }; - break; - case 4: - this.get = function (idx, out) { - var arr = this.value; - var idx4 = idx * 4; - out[0] = arr[idx4]; - out[1] = arr[idx4 + 1]; - out[2] = arr[idx4 + 2]; - out[3] = arr[idx4 + 3]; - return out; - }; - this.set = function (idx, val) { - var arr = this.value; - var idx4 = idx * 4; - arr[idx4] = val[0]; - arr[idx4 + 1] = val[1]; - arr[idx4 + 2] = val[2]; - arr[idx4 + 3] = val[3]; - }; - this.copy = function (target, source) { - var arr = this.value; - source *= 4; - target *= 4; - // copyWithin is extremely slow - arr[target] = arr[source]; - arr[target + 1] = arr[source + 1]; - arr[target + 2] = arr[source + 2]; - arr[target + 3] = arr[source + 3]; - }; + if (Math.abs(eyex - centerx) < __WEBPACK_IMPORTED_MODULE_0__common__["b" /* GLMAT_EPSILON */] && + Math.abs(eyey - centery) < __WEBPACK_IMPORTED_MODULE_0__common__["b" /* GLMAT_EPSILON */] && + Math.abs(eyez - centerz) < __WEBPACK_IMPORTED_MODULE_0__common__["b" /* GLMAT_EPSILON */]) { + return mat4.identity(out); } -} -/** - * Set item value at give index. Second parameter val is number if size is 1 - * @function - * @name clay.Geometry.Attribute#set - * @param {number} idx - * @param {number[]|number} val - * @example - * geometry.getAttribute('position').set(0, [1, 1, 1]); - */ + z0 = eyex - centerx; + z1 = eyey - centery; + z2 = eyez - centerz; -/** - * Get item value at give index. Second parameter out is no need if size is 1 - * @function - * @name clay.Geometry.Attribute#set - * @param {number} idx - * @param {number[]} [out] - * @example - * geometry.getAttribute('position').get(0, out); - */ + len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); + z0 *= len; + z1 *= len; + z2 *= len; -/** - * Initialize attribute with given vertex count - * @param {number} nVertex - */ -Attribute.prototype.init = function (nVertex) { - if (!this.value || this.value.length != nVertex * this.size) { - var ArrayConstructor = getArrayCtorByType(this.type); - this.value = new ArrayConstructor(nVertex * this.size); + 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; } -}; -/** - * Initialize attribute with given array. Which can be 1 dimensional or 2 dimensional - * @param {Array} array - * @example - * geometry.getAttribute('position').fromArray( - * [-1, 0, 0, 1, 0, 0, 0, 1, 0] - * ); - * geometry.getAttribute('position').fromArray( - * [ [-1, 0, 0], [1, 0, 0], [0, 1, 0] ] - * ); - */ -Attribute.prototype.fromArray = function (array) { - var ArrayConstructor = getArrayCtorByType(this.type); - var value; - // Convert 2d array to flat - if (array[0] && (array[0].length)) { - var n = 0; - var size = this.size; - value = new ArrayConstructor(array.length * size); - for (var i = 0; i < array.length; i++) { - for (var j = 0; j < size; j++) { - value[n++] = array[i][j]; - } - } - } - else { - value = new ArrayConstructor(array); - } - this.value = value; -}; + y0 = z1 * x2 - z2 * x1; + y1 = z2 * x0 - z0 * x2; + y2 = z0 * x1 - z1 * x0; -Attribute.prototype.clone = function(copyValue) { - var ret = new Attribute(this.name, this.type, this.size, this.semantic); - // FIXME - if (copyValue) { - console.warn('todo'); + 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; } - return ret; -}; - -function AttributeBuffer(name, type, buffer, size, semantic) { - this.name = name; - this.type = type; - this.buffer = buffer; - this.size = size; - this.semantic = semantic; - // To be set in mesh - // symbol in the shader - this.symbol = ''; - - // Needs remove flag - this.needsRemove = false; -} + 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; -function IndicesBuffer(buffer) { - this.buffer = buffer; - this.count = 0; -} + return out; +}; /** - * Geometry in ClayGL contains vertex attributes of mesh. These vertex attributes will be finally provided to the {@link clay.Shader}. - * Different {@link clay.Shader} needs different attributes. Here is a list of attributes used in the builtin shaders. - * - * + position: `clay.basic`, `clay.lambert`, `clay.standard` - * + texcoord0: `clay.basic`, `clay.lambert`, `clay.standard` - * + color: `clay.basic`, `clay.lambert`, `clay.standard` - * + weight: `clay.basic`, `clay.lambert`, `clay.standard` - * + joint: `clay.basic`, `clay.lambert`, `clay.standard` - * + normal: `clay.lambert`, `clay.standard` - * + tangent: `clay.standard` - * - * #### Create a procedural geometry - * - * ClayGL provides a couple of builtin procedural geometries. Inlcuding: - * - * + {@link clay.geometry.Cube} - * + {@link clay.geometry.Sphere} - * + {@link clay.geometry.Plane} - * + {@link clay.geometry.Cylinder} - * + {@link clay.geometry.Cone} - * + {@link clay.geometry.ParametricSurface} - * - * It's simple to create a basic geometry with these classes. - * -```js -var sphere = new clay.geometry.Sphere({ - radius: 2 -}); -``` - * - * #### Create the geometry data by yourself - * - * Usually the vertex attributes data are created by the {@link clay.loader.GLTF} or procedural geometries like {@link clay.geometry.Sphere}. - * Besides these, you can create the data manually. Here is a simple example to create a triangle. -```js -var TRIANGLE_POSITIONS = [ - [-0.5, -0.5, 0], - [0.5, -0.5, 0], - [0, 0.5, 0] -]; -var geometry = new clay.StaticGeometry(); -// Add triangle vertices to position attribute. -geometry.attributes.position.fromArray(TRIANGLE_POSITIONS); -``` - * Then you can use the utility methods like `generateVertexNormals`, `generateTangents` to create the remaining necessary attributes. - * - * - * #### Use with custom shaders - * - * If you wan't to write custom shaders. Don't forget to add SEMANTICS to these attributes. For example - * - ```glsl -uniform mat4 worldViewProjection : WORLDVIEWPROJECTION; -uniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE; -uniform mat4 world : WORLD; - -attribute vec3 position : POSITION; -attribute vec2 texcoord : TEXCOORD_0; -attribute vec3 normal : NORMAL; -``` - * These `POSITION`, `TEXCOORD_0`, `NORMAL` are SEMANTICS which will map the attributes in shader to the attributes in the Geometry - * - * Available attributes SEMANTICS includes `POSITION`, `TEXCOORD_0`, `TEXCOORD_1` `NORMAL`, `TANGENT`, `COLOR`, `WEIGHT`, `JOINT`. - * + * Returns Frobenius norm of a mat4 * - * @constructor clay.Geometry - * @extends clay.core.Base + * @param {mat4} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm */ -var Geometry = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () { - return /** @lends clay.Geometry# */ { - /** - * Attributes of geometry. Including: - * + `position` - * + `texcoord0` - * + `texcoord1` - * + `normal` - * + `tangent` - * + `color` - * + `weight` - * + `joint` - * + `barycentric` - * - * @type {Object.} - */ - attributes: { - position: new Attribute('position', 'float', 3, 'POSITION'), - texcoord0: new Attribute('texcoord0', 'float', 2, 'TEXCOORD_0'), - texcoord1: new Attribute('texcoord1', 'float', 2, 'TEXCOORD_1'), - normal: new Attribute('normal', 'float', 3, 'NORMAL'), - tangent: new Attribute('tangent', 'float', 4, 'TANGENT'), - color: new Attribute('color', 'float', 4, 'COLOR'), - // Skinning attributes - // Each vertex can be bind to 4 bones, because the - // sum of weights is 1, so the weights is stored in vec3 and the last - // can be calculated by 1-w.x-w.y-w.z - weight: new Attribute('weight', 'float', 3, 'WEIGHT'), - joint: new Attribute('joint', 'float', 4, 'JOINT'), - // For wireframe display - // http://codeflow.org/entries/2012/aug/02/easy-wireframe-display-with-barycentric-coordinates/ - barycentric: new Attribute('barycentric', 'float', 3, null), - }, - /** - * Calculated bounding box of geometry. - * @type {clay.BoundingBox} - */ - boundingBox: null, - - /** - * Indices of geometry. - * @type {Uint16Array|Uint32Array} - */ - indices: null, - - /** - * Is vertices data dynamically updated. - * Attributes value can't be changed after first render if dyanmic is false. - * @type {boolean} - */ - dynamic: true, - - _enabledAttributes: null, - - // PENDING - // Init it here to avoid deoptimization when it's assigned in application dynamically - __used: 0 - }; -}, function() { - // Use cache - this._cache = new __WEBPACK_IMPORTED_MODULE_2__core_Cache__["a" /* default */](); - - this._attributeList = Object.keys(this.attributes); - - this.__vaoCache = {}; -}, -/** @lends clay.Geometry.prototype */ -{ - /** - * Main attribute will be used to count vertex number - * @type {string} - */ - mainAttribute: 'position', - /** - * User defined picking algorithm instead of default - * triangle ray intersection - * x, y are NDC. - * ```typescript - * (x, y, renderer, camera, renderable, out) => boolean - * ``` - * @type {?Function} - */ - pick: null, - - /** - * User defined ray picking algorithm instead of default - * triangle ray intersection - * ```typescript - * (ray: clay.Ray, renderable: clay.Renderable, out: Array) => boolean - * ``` - * @type {?Function} - */ - pickByRay: null, - - /** - * Update boundingBox of Geometry - */ - updateBoundingBox: function () { - var bbox = this.boundingBox; - if (!bbox) { - bbox = this.boundingBox = new __WEBPACK_IMPORTED_MODULE_5__math_BoundingBox__["a" /* default */](); - } - var posArr = this.attributes.position.value; - if (posArr && posArr.length) { - var min = bbox.min; - var max = bbox.max; - var minArr = min.array; - var maxArr = max.array; - vec3.set(minArr, posArr[0], posArr[1], posArr[2]); - vec3.set(maxArr, posArr[0], posArr[1], posArr[2]); - for (var i = 3; i < posArr.length;) { - var x = posArr[i++]; - var y = posArr[i++]; - var z = posArr[i++]; - if (x < minArr[0]) { minArr[0] = x; } - if (y < minArr[1]) { minArr[1] = y; } - if (z < minArr[2]) { minArr[2] = z; } - - if (x > maxArr[0]) { maxArr[0] = x; } - if (y > maxArr[1]) { maxArr[1] = y; } - if (z > maxArr[2]) { maxArr[2] = z; } - } - min._dirty = true; - max._dirty = true; - } - }, - /** - * Mark attributes and indices in geometry needs to update. - * Usually called after you change the data in attributes. - */ - dirty: function () { - var enabledAttributes = this.getEnabledAttributes(); - for (var i = 0; i < enabledAttributes.length; i++) { - this.dirtyAttribute(enabledAttributes[i]); - } - this.dirtyIndices(); - this._enabledAttributes = null; - - this._cache.dirty('any'); - }, - /** - * Mark the indices needs to update. - */ - dirtyIndices: function () { - this._cache.dirtyAll('indices'); - }, - /** - * Mark the attributes needs to update. - * @param {string} [attrName] - */ - dirtyAttribute: function (attrName) { - this._cache.dirtyAll(makeAttrKey(attrName)); - this._cache.dirtyAll('attributes'); - }, - /** - * Get indices of triangle at given index. - * @param {number} idx - * @param {Array.} out - * @return {Array.} - */ - getTriangleIndices: function (idx, out) { - if (idx < this.triangleCount && idx >= 0) { - if (!out) { - out = vec3Create(); - } - var indices = this.indices; - out[0] = indices[idx * 3]; - out[1] = indices[idx * 3 + 1]; - out[2] = indices[idx * 3 + 2]; - return out; - } - }, - - /** - * Set indices of triangle at given index. - * @param {number} idx - * @param {Array.} arr - */ - setTriangleIndices: function (idx, arr) { - var indices = this.indices; - indices[idx * 3] = arr[0]; - indices[idx * 3 + 1] = arr[1]; - indices[idx * 3 + 2] = arr[2]; - }, - - isUseIndices: function () { - return !!this.indices; - }, - - /** - * Initialize indices from an array. - * @param {Array} array - */ - initIndicesFromArray: function (array) { - var value; - var ArrayConstructor = this.vertexCount > 0xffff - ? __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Uint32Array : __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Uint16Array; - // Convert 2d array to flat - if (array[0] && (array[0].length)) { - var n = 0; - var size = 3; - - value = new ArrayConstructor(array.length * size); - for (var i = 0; i < array.length; i++) { - for (var j = 0; j < size; j++) { - value[n++] = array[i][j]; - } - } - } - else { - value = new ArrayConstructor(array); - } - - this.indices = value; - }, - /** - * Create a new attribute - * @param {string} name - * @param {string} type - * @param {number} size - * @param {string} [semantic] - */ - createAttribute: function (name, type, size, semantic) { - var attrib = new Attribute(name, type, size, semantic); - if (this.attributes[name]) { - this.removeAttribute(name); - } - this.attributes[name] = attrib; - this._attributeList.push(name); - return attrib; - }, - /** - * Remove attribute - * @param {string} name - */ - removeAttribute: function (name) { - var attributeList = this._attributeList; - var idx = attributeList.indexOf(name); - if (idx >= 0) { - attributeList.splice(idx, 1); - delete this.attributes[name]; - return true; - } - return false; - }, - - /** - * Get attribute - * @param {string} name - * @return {clay.Geometry.Attribute} - */ - getAttribute: function (name) { - return this.attributes[name]; - }, - - /** - * Get enabled attributes name list - * Attribute which has the same vertex number with position is treated as a enabled attribute - * @return {string[]} - */ - getEnabledAttributes: function () { - var enabledAttributes = this._enabledAttributes; - var attributeList = this._attributeList; - // Cache - if (enabledAttributes) { - return enabledAttributes; - } - - var result = []; - var nVertex = this.vertexCount; - - for (var i = 0; i < attributeList.length; i++) { - var name = attributeList[i]; - var attrib = this.attributes[name]; - if (attrib.value) { - if (attrib.value.length === nVertex * attrib.size) { - result.push(name); - } - } - } - - this._enabledAttributes = result; - - return result; - }, - - getBufferChunks: function (renderer) { - var cache = this._cache; - cache.use(renderer.__uid__); - var isAttributesDirty = cache.isDirty('attributes'); - var isIndicesDirty = cache.isDirty('indices'); - if (isAttributesDirty || isIndicesDirty) { - this._updateBuffer(renderer.gl, isAttributesDirty, isIndicesDirty); - var enabledAttributes = this.getEnabledAttributes(); - for (var i = 0; i < enabledAttributes.length; i++) { - cache.fresh(makeAttrKey(enabledAttributes[i])); - } - cache.fresh('attributes'); - cache.fresh('indices'); - } - cache.fresh('any'); - return cache.get('chunks'); - }, - - _updateBuffer: function (_gl, isAttributesDirty, isIndicesDirty) { - var cache = this._cache; - var chunks = cache.get('chunks'); - var firstUpdate = false; - if (!chunks) { - chunks = []; - // Intialize - chunks[0] = { - attributeBuffers: [], - indicesBuffer: null - }; - cache.put('chunks', chunks); - firstUpdate = true; - } - - var chunk = chunks[0]; - var attributeBuffers = chunk.attributeBuffers; - var indicesBuffer = chunk.indicesBuffer; - - if (isAttributesDirty || firstUpdate) { - var attributeList = this.getEnabledAttributes(); - - var attributeBufferMap = {}; - if (!firstUpdate) { - for (var i = 0; i < attributeBuffers.length; i++) { - attributeBufferMap[attributeBuffers[i].name] = attributeBuffers[i]; - } - } - // FIXME If some attributes removed - for (var k = 0; k < attributeList.length; k++) { - var name = attributeList[k]; - var attribute = this.attributes[name]; - - var bufferInfo; - - if (!firstUpdate) { - bufferInfo = attributeBufferMap[name]; - } - var buffer; - if (bufferInfo) { - buffer = bufferInfo.buffer; - } - else { - buffer = _gl.createBuffer(); - } - if (cache.isDirty(makeAttrKey(name))) { - // Only update when they are dirty. - // TODO: Use BufferSubData? - _gl.bindBuffer(_gl.ARRAY_BUFFER, buffer); - _gl.bufferData(_gl.ARRAY_BUFFER, attribute.value, this.dynamic ? __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DYNAMIC_DRAW : __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].STATIC_DRAW); - } - - attributeBuffers[k] = new AttributeBuffer(name, attribute.type, buffer, attribute.size, attribute.semantic); - } - // Remove unused attributes buffers. - // PENDING - for (var i = k; i < attributeBuffers.length; i++) { - _gl.deleteBuffer(attributeBuffers[i].buffer); - } - attributeBuffers.length = k; - - } - - if (this.isUseIndices() && (isIndicesDirty || firstUpdate)) { - if (!indicesBuffer) { - indicesBuffer = new IndicesBuffer(_gl.createBuffer()); - chunk.indicesBuffer = indicesBuffer; - } - indicesBuffer.count = this.indices.length; - _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, indicesBuffer.buffer); - _gl.bufferData(_gl.ELEMENT_ARRAY_BUFFER, this.indices, this.dynamic ? __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DYNAMIC_DRAW : __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].STATIC_DRAW); - } - }, - - /** - * Generate normals per vertex. - */ - generateVertexNormals: function () { - if (!this.vertexCount) { - return; - } - - var indices = this.indices; - var attributes = this.attributes; - var positions = attributes.position.value; - var normals = attributes.normal.value; - - if (!normals || normals.length !== positions.length) { - normals = attributes.normal.value = new __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Float32Array(positions.length); - } - else { - // Reset - for (var i = 0; i < normals.length; i++) { - normals[i] = 0; - } - } - - var p1 = vec3Create(); - var p2 = vec3Create(); - var p3 = vec3Create(); - - var v21 = vec3Create(); - var v32 = vec3Create(); - - var n = vec3Create(); - - var len = indices ? indices.length : this.vertexCount; - var i1, i2, i3; - for (var f = 0; f < len;) { - if (indices) { - i1 = indices[f++]; - i2 = indices[f++]; - i3 = indices[f++]; - } - else { - i1 = f++; - i2 = f++; - i3 = f++; - } - - vec3Set(p1, positions[i1*3], positions[i1*3+1], positions[i1*3+2]); - vec3Set(p2, positions[i2*3], positions[i2*3+1], positions[i2*3+2]); - vec3Set(p3, positions[i3*3], positions[i3*3+1], positions[i3*3+2]); - - vec3.sub(v21, p1, p2); - vec3.sub(v32, p2, p3); - vec3.cross(n, v21, v32); - // Already be weighted by the triangle area - for (var i = 0; i < 3; i++) { - normals[i1*3+i] = normals[i1*3+i] + n[i]; - normals[i2*3+i] = normals[i2*3+i] + n[i]; - normals[i3*3+i] = normals[i3*3+i] + n[i]; - } - } - - for (var i = 0; i < normals.length;) { - vec3Set(n, normals[i], normals[i+1], normals[i+2]); - vec3.normalize(n, n); - normals[i++] = n[0]; - normals[i++] = n[1]; - normals[i++] = n[2]; - } - this.dirty(); - }, - - /** - * Generate normals per face. - */ - generateFaceNormals: function () { - if (!this.vertexCount) { - return; - } - - if (!this.isUniqueVertex()) { - this.generateUniqueVertex(); - } - - var indices = this.indices; - var attributes = this.attributes; - var positions = attributes.position.value; - var normals = attributes.normal.value; - - var p1 = vec3Create(); - var p2 = vec3Create(); - var p3 = vec3Create(); - - var v21 = vec3Create(); - var v32 = vec3Create(); - var n = vec3Create(); - - if (!normals) { - normals = attributes.normal.value = new Float32Array(positions.length); - } - var len = indices ? indices.length : this.vertexCount; - var i1, i2, i3; - for (var f = 0; f < len;) { - if (indices) { - i1 = indices[f++]; - i2 = indices[f++]; - i3 = indices[f++]; - } - else { - i1 = f++; - i2 = f++; - i3 = f++; - } - - vec3Set(p1, positions[i1*3], positions[i1*3+1], positions[i1*3+2]); - vec3Set(p2, positions[i2*3], positions[i2*3+1], positions[i2*3+2]); - vec3Set(p3, positions[i3*3], positions[i3*3+1], positions[i3*3+2]); - - vec3.sub(v21, p1, p2); - vec3.sub(v32, p2, p3); - vec3.cross(n, v21, v32); - - vec3.normalize(n, n); - - for (var i = 0; i < 3; i++) { - normals[i1*3 + i] = n[i]; - normals[i2*3 + i] = n[i]; - normals[i3*3 + i] = n[i]; - } - } - this.dirty(); - }, - - /** - * Generate tangents attributes. - */ - generateTangents: function () { - if (!this.vertexCount) { - return; - } - - var nVertex = this.vertexCount; - var attributes = this.attributes; - if (!attributes.tangent.value) { - attributes.tangent.value = new Float32Array(nVertex * 4); - } - var texcoords = attributes.texcoord0.value; - var positions = attributes.position.value; - var tangents = attributes.tangent.value; - var normals = attributes.normal.value; - - if (!texcoords) { - console.warn('Geometry without texcoords can\'t generate tangents.'); - return; - } - - var tan1 = []; - var tan2 = []; - for (var i = 0; i < nVertex; i++) { - tan1[i] = [0.0, 0.0, 0.0]; - tan2[i] = [0.0, 0.0, 0.0]; - } - - var sdir = [0.0, 0.0, 0.0]; - var tdir = [0.0, 0.0, 0.0]; - var indices = this.indices; - - var len = indices ? indices.length : this.vertexCount; - var i1, i2, i3; - for (var i = 0; i < len;) { - if (indices) { - i1 = indices[i++]; - i2 = indices[i++]; - i3 = indices[i++]; - } - else { - i1 = i++; - i2 = i++; - i3 = i++; - } - - var st1s = texcoords[i1 * 2], - st2s = texcoords[i2 * 2], - st3s = texcoords[i3 * 2], - st1t = texcoords[i1 * 2 + 1], - st2t = texcoords[i2 * 2 + 1], - st3t = texcoords[i3 * 2 + 1], - - p1x = positions[i1 * 3], - p2x = positions[i2 * 3], - p3x = positions[i3 * 3], - p1y = positions[i1 * 3 + 1], - p2y = positions[i2 * 3 + 1], - p3y = positions[i3 * 3 + 1], - p1z = positions[i1 * 3 + 2], - p2z = positions[i2 * 3 + 2], - p3z = positions[i3 * 3 + 2]; - - var x1 = p2x - p1x, - x2 = p3x - p1x, - y1 = p2y - p1y, - y2 = p3y - p1y, - z1 = p2z - p1z, - z2 = p3z - p1z; - - var s1 = st2s - st1s, - s2 = st3s - st1s, - t1 = st2t - st1t, - t2 = st3t - st1t; - - var r = 1.0 / (s1 * t2 - t1 * s2); - sdir[0] = (t2 * x1 - t1 * x2) * r; - sdir[1] = (t2 * y1 - t1 * y2) * r; - sdir[2] = (t2 * z1 - t1 * z2) * r; - - tdir[0] = (s1 * x2 - s2 * x1) * r; - tdir[1] = (s1 * y2 - s2 * y1) * r; - tdir[2] = (s1 * z2 - s2 * z1) * r; - - vec3Add(tan1[i1], tan1[i1], sdir); - vec3Add(tan1[i2], tan1[i2], sdir); - vec3Add(tan1[i3], tan1[i3], sdir); - vec3Add(tan2[i1], tan2[i1], tdir); - vec3Add(tan2[i2], tan2[i2], tdir); - vec3Add(tan2[i3], tan2[i3], tdir); - } - var tmp = vec3Create(); - var nCrossT = vec3Create(); - var n = vec3Create(); - for (var i = 0; i < nVertex; i++) { - n[0] = normals[i * 3]; - n[1] = normals[i * 3 + 1]; - n[2] = normals[i * 3 + 2]; - var t = tan1[i]; - - // Gram-Schmidt orthogonalize - vec3.scale(tmp, n, vec3.dot(n, t)); - vec3.sub(tmp, t, tmp); - vec3.normalize(tmp, tmp); - // Calculate handedness. - vec3.cross(nCrossT, n, t); - tangents[i * 4] = tmp[0]; - tangents[i * 4 + 1] = tmp[1]; - tangents[i * 4 + 2] = tmp[2]; - // PENDING can config ? - tangents[i * 4 + 3] = vec3.dot(nCrossT, tan2[i]) < 0.0 ? -1.0 : 1.0; - } - this.dirty(); - }, - - /** - * If vertices are not shared by different indices. - */ - isUniqueVertex: function () { - if (this.isUseIndices()) { - return this.vertexCount === this.indices.length; - } - else { - return true; - } - }, - /** - * Create a unique vertex for each index. - */ - generateUniqueVertex: function () { - if (!this.vertexCount || !this.indices) { - return; - } +mat4.frob = function (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) )) +}; - if (this.indices.length > 0xffff) { - this.indices = new __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Uint32Array(this.indices); - } +/* harmony default export */ __webpack_exports__["a"] = (mat4); - var attributes = this.attributes; - var indices = this.indices; +/***/ }), +/* 22 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - var attributeNameList = this.getEnabledAttributes(); +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Scene__ = __webpack_require__(36); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_prePass_ShadowMap__ = __webpack_require__(174); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_camera_Perspective__ = __webpack_require__(41); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_camera_Orthographic__ = __webpack_require__(37); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_math_Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_claygl_src_math_Vector2__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_claygl_src_core_mixin_notifier__ = __webpack_require__(53); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__effect_EffectCompositor__ = __webpack_require__(176); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__effect_TemporalSuperSampling__ = __webpack_require__(200); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__effect_halton__ = __webpack_require__(49); +/* + * @module echarts-gl/core/ViewGL + * @author Yi Shen(http://github.com/pissang) + */ - var oldAttrValues = {}; - for (var a = 0; a < attributeNameList.length; a++) { - var name = attributeNameList[a]; - oldAttrValues[name] = attributes[name].value; - attributes[name].init(this.indices.length); - } - var cursor = 0; - for (var i = 0; i < indices.length; i++) { - var ii = indices[i]; - for (var a = 0; a < attributeNameList.length; a++) { - var name = attributeNameList[a]; - var array = attributes[name].value; - var size = attributes[name].size; - for (var k = 0; k < size; k++) { - array[cursor * size + k] = oldAttrValues[name][ii * size + k]; - } - } - indices[i] = cursor; - cursor++; - } - this.dirty(); - }, - /** - * Generate barycentric coordinates for wireframe draw. - */ - generateBarycentric: function () { - if (!this.vertexCount) { - return; - } - if (!this.isUniqueVertex()) { - this.generateUniqueVertex(); - } - var attributes = this.attributes; - var array = attributes.barycentric.value; - var indices = this.indices; - // Already existed; - if (array && array.length === indices.length * 3) { - return; - } - array = attributes.barycentric.value = new Float32Array(indices.length * 3); - for (var i = 0; i < (indices ? indices.length : this.vertexCount / 3);) { - for (var j = 0; j < 3; j++) { - var ii = indices ? indices[i++] : (i * 3 + j); - array[ii * 3 + j] = 1; - } - } - this.dirty(); - }, - /** - * Apply transform to geometry attributes. - * @param {clay.Matrix4} matrix - */ - applyTransform: function (matrix) { - var attributes = this.attributes; - var positions = attributes.position.value; - var normals = attributes.normal.value; - var tangents = attributes.tangent.value; - matrix = matrix.array; - // Normal Matrix - var inverseTransposeMatrix = mat4.create(); - mat4.invert(inverseTransposeMatrix, matrix); - mat4.transpose(inverseTransposeMatrix, inverseTransposeMatrix); - var vec3TransformMat4 = vec3.transformMat4; - var vec3ForEach = vec3.forEach; - vec3ForEach(positions, 3, 0, null, vec3TransformMat4, matrix); - if (normals) { - vec3ForEach(normals, 3, 0, null, vec3TransformMat4, inverseTransposeMatrix); - } - if (tangents) { - vec3ForEach(tangents, 4, 0, null, vec3TransformMat4, inverseTransposeMatrix); - } - if (this.boundingBox) { - this.updateBoundingBox(); - } - }, - /** - * Dispose geometry data in GL context. - * @param {clay.Renderer} renderer - */ - dispose: function (renderer) { - var cache = this._cache; - cache.use(renderer.__uid__); - var chunks = cache.get('chunks'); - if (chunks) { - for (var c = 0; c < chunks.length; c++) { - var chunk = chunks[c]; - for (var k = 0; k < chunk.attributeBuffers.length; k++) { - var attribs = chunk.attributeBuffers[k]; - renderer.gl.deleteBuffer(attribs.buffer); - } - if (chunk.indicesBuffer) { - renderer.gl.deleteBuffer(chunk.indicesBuffer.buffer); - } - } - } - if (this.__vaoCache) { - var vaoExt = renderer.getGLExtension('OES_vertex_array_object'); - for (var id in this.__vaoCache) { - var vao = this.__vaoCache[id].vao; - if (vao) { - vaoExt.deleteVertexArrayOES(vao); - } - } - } - this.__vaoCache = {}; - cache.deleteContext(renderer.__uid__); - } +/** + * @constructor + * @alias module:echarts-gl/core/ViewGL + * @param {string} [projection='perspective'] + */ +function ViewGL(projection) { -}); + projection = projection || 'perspective'; -if (Object.defineProperty) { /** - * @name clay.Geometry#vertexCount - * @type {number} - * @readOnly + * @type {module:echarts-gl/core/LayerGL} */ - Object.defineProperty(Geometry.prototype, 'vertexCount', { - - enumerable: false, + this.layer = null; + /** + * @type {clay.Scene} + */ + this.scene = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Scene__["a" /* default */](); - get: function () { - var mainAttribute = this.attributes[this.mainAttribute]; - if (!mainAttribute || !mainAttribute.value) { - return 0; - } - return mainAttribute.value.length / mainAttribute.size; - } - }); /** - * @name clay.Geometry#triangleCount - * @type {number} - * @readOnly + * @type {clay.Node} */ - Object.defineProperty(Geometry.prototype, 'triangleCount', { + this.rootNode = this.scene; - enumerable: false, + this.viewport = { + x: 0, y: 0, width: 0, height: 0 + }; - get: function () { - var indices = this.indices; - if (!indices) { - return 0; - } - else { - return indices.length / 3; - } - } - }); -} + this.setProjection(projection); -Geometry.STATIC_DRAW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].STATIC_DRAW; -Geometry.DYNAMIC_DRAW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DYNAMIC_DRAW; -Geometry.STREAM_DRAW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].STREAM_DRAW; + this._compositor = new __WEBPACK_IMPORTED_MODULE_9__effect_EffectCompositor__["a" /* default */](); -Geometry.AttributeBuffer = AttributeBuffer; -Geometry.IndicesBuffer = IndicesBuffer; + this._temporalSS = new __WEBPACK_IMPORTED_MODULE_10__effect_TemporalSuperSampling__["a" /* default */](); -Geometry.Attribute = Attribute; + this._shadowMapPass = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_prePass_ShadowMap__["a" /* default */](); -/* harmony default export */ __webpack_exports__["a"] = (Geometry); + var pcfKernels = []; + var off = 0; + for (var i = 0; i < 30; i++) { + var pcfKernel = []; + for (var k = 0; k < 6; k++) { + pcfKernel.push(Object(__WEBPACK_IMPORTED_MODULE_11__effect_halton__["a" /* default */])(off, 2) * 4.0 - 2.0); + pcfKernel.push(Object(__WEBPACK_IMPORTED_MODULE_11__effect_halton__["a" /* default */])(off, 3) * 4.0 - 2.0); + off++; + } + pcfKernels.push(pcfKernel); + } + this._pcfKernels = pcfKernels; + this.scene.on('beforerender', function (renderer, scene, camera) { + if (this.needsTemporalSS()) { + this._temporalSS.jitterProjection(renderer, camera); + } + }, this); +} -/***/ }), -/* 14 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +/** + * Set camera type of group + * @param {string} cameraType 'perspective' | 'orthographic' + */ +ViewGL.prototype.setProjection = function (projection) { + var oldCamera = this.camera; + oldCamera && oldCamera.update(); + if (projection === 'perspective') { + if (!(this.camera instanceof __WEBPACK_IMPORTED_MODULE_3_claygl_src_camera_Perspective__["a" /* default */])) { + this.camera = new __WEBPACK_IMPORTED_MODULE_3_claygl_src_camera_Perspective__["a" /* default */](); + if (oldCamera) { + this.camera.setLocalTransform(oldCamera.localTransform); + } + } + } + else { + if (!(this.camera instanceof __WEBPACK_IMPORTED_MODULE_4_claygl_src_camera_Orthographic__["a" /* default */])) { + this.camera = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_camera_Orthographic__["a" /* default */](); + if (oldCamera) { + this.camera.setLocalTransform(oldCamera.localTransform); + } + } + } + // PENDING + this.camera.near = 0.1; + this.camera.far = 2000; +}; -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__camera_Orthographic__ = __webpack_require__(33); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geometry_Plane__ = __webpack_require__(37); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Shader__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Material__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Mesh__ = __webpack_require__(31); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__core_glenum__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__shader_source_compositor_vertex_glsl_js__ = __webpack_require__(118); +/** + * Set viewport of group + * @param {number} x Viewport left bottom x + * @param {number} y Viewport left bottom y + * @param {number} width Viewport height + * @param {number} height Viewport height + * @param {number} [dpr=1] + */ +ViewGL.prototype.setViewport = function (x, y, width, height, dpr) { + if (this.camera instanceof __WEBPACK_IMPORTED_MODULE_3_claygl_src_camera_Perspective__["a" /* default */]) { + this.camera.aspect = width / height; + } + dpr = dpr || 1; + + this.viewport.x = x; + this.viewport.y = y; + this.viewport.width = width; + this.viewport.height = height; + this.viewport.devicePixelRatio = dpr; + + // Source and output of compositor use high dpr texture. + // But the intermediate texture of bloom, dof effects use fixed 1.0 dpr + this._compositor.resize(width * dpr, height * dpr); + this._temporalSS.resize(width * dpr, height * dpr); +}; +/** + * If contain screen point x, y + * @param {number} x offsetX + * @param {number} y offsetY + * @return {boolean} + */ +ViewGL.prototype.containPoint = function (x, y) { + var viewport = this.viewport; + var height = this.layer.renderer.getHeight(); + // Flip y; + y = height - y; + return x >= viewport.x && y >= viewport.y + && x <= viewport.x + viewport.width && y <= viewport.y + viewport.height; +}; +/** + * Cast a ray + * @param {number} x offsetX + * @param {number} y offsetY + * @param {clay.math.Ray} out + * @return {clay.math.Ray} + */ +var ndc = new __WEBPACK_IMPORTED_MODULE_7_claygl_src_math_Vector2__["a" /* default */](); +ViewGL.prototype.castRay = function (x, y, out) { + var renderer = this.layer.renderer; + var oldViewport = renderer.viewport; + renderer.viewport = this.viewport; + renderer.screenToNDC(x, y, ndc); + this.camera.castRay(ndc, out); + renderer.viewport = oldViewport; + return out; +}; +/** + * Prepare and update scene before render + */ +ViewGL.prototype.prepareRender = function () { + this.scene.update(); + this.camera.update(); + this.scene.updateLights(); + var renderList = this.scene.updateRenderList(this.camera); + this._needsSortProgressively = false; + // If has any transparent mesh needs sort triangles progressively. + for (var i = 0; i < renderList.transparent.length; i++) { + var renderable = renderList.transparent[i]; + var geometry = renderable.geometry; + if (geometry.needsSortVerticesProgressively && geometry.needsSortVerticesProgressively()) { + this._needsSortProgressively = true; + } + if (geometry.needsSortTrianglesProgressively && geometry.needsSortTrianglesProgressively()) { + this._needsSortProgressively = true; + } + } + this._frame = 0; + this._temporalSS.resetFrame(); + // var lights = this.scene.getLights(); + // for (var i = 0; i < lights.length; i++) { + // if (lights[i].cubemap) { + // if (this._compositor && this._compositor.isSSREnabled()) { + // lights[i].invisible = true; + // } + // else { + // lights[i].invisible = false; + // } + // } + // } +}; -__WEBPACK_IMPORTED_MODULE_3__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_7__shader_source_compositor_vertex_glsl_js__["a" /* default */]); +ViewGL.prototype.render = function (renderer, accumulating) { + this._doRender(renderer, accumulating, this._frame); + this._frame++; +}; -var planeGeo = new __WEBPACK_IMPORTED_MODULE_2__geometry_Plane__["a" /* default */](); -var mesh = new __WEBPACK_IMPORTED_MODULE_5__Mesh__["a" /* default */]({ - geometry: planeGeo, - frustumCulling: false -}); -var camera = new __WEBPACK_IMPORTED_MODULE_1__camera_Orthographic__["a" /* default */](); +ViewGL.prototype.needsAccumulate = function () { + return this.needsTemporalSS() || this._needsSortProgressively; +}; -/** - * @constructor clay.compositor.Pass - * @extends clay.core.Base - */ -var Pass = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () { - return /** @lends clay.compositor.Pass# */ { - /** - * Fragment shader string - * @type {string} - */ - // PENDING shader or fragment ? - fragment : '', +ViewGL.prototype.needsTemporalSS = function () { + var enableTemporalSS = this._enableTemporalSS; + if (enableTemporalSS === 'auto') { + enableTemporalSS = this._enablePostEffect; + } + return enableTemporalSS; +}; - /** - * @type {Object} - */ - outputs : null, +ViewGL.prototype.hasDOF = function () { + return this._enableDOF; +}; - /** - * @type {clay.Material} - */ - material : null, +ViewGL.prototype.isAccumulateFinished = function () { + return this.needsTemporalSS() ? this._temporalSS.isFinished() + : (this._frame > 30); +}; - /** - * @type {Boolean} - */ - blendWithPrevious: false, +ViewGL.prototype._doRender = function (renderer, accumulating, accumFrame) { - /** - * @type {Boolean} - */ - clearColor: false, + var scene = this.scene; + var camera = this.camera; - /** - * @type {Boolean} - */ - clearDepth: true - }; -}, function() { + accumFrame = accumFrame || 0; - var shader = new __WEBPACK_IMPORTED_MODULE_3__Shader__["a" /* default */](__WEBPACK_IMPORTED_MODULE_3__Shader__["a" /* default */].source('clay.compositor.vertex'), this.fragment); - var material = new __WEBPACK_IMPORTED_MODULE_4__Material__["a" /* default */]({ - shader: shader - }); - material.enableTexturesAll(); + this._updateTransparent(renderer, scene, camera, accumFrame); - this.material = material; + if (!accumulating) { + this._shadowMapPass.kernelPCF = this._pcfKernels[0]; + // Not render shadowmap pass in accumulating frame. + this._shadowMapPass.render(renderer, scene, camera, true); + } -}, -/** @lends clay.compositor.Pass.prototype */ -{ - /** - * @param {string} name - * @param {} value - */ - setUniform : function(name, value) { - this.material.setUniform(name, value); - }, - /** - * @param {string} name - * @return {} - */ - getUniform : function(name) { - var uniform = this.material.uniforms[name]; - if (uniform) { - return uniform.value; - } - }, - /** - * @param {clay.Texture} texture - * @param {number} attachment - */ - attachOutput : function(texture, attachment) { - if (!this.outputs) { - this.outputs = {}; - } - attachment = attachment || __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].COLOR_ATTACHMENT0; - this.outputs[attachment] = texture; - }, - /** - * @param {clay.Texture} texture - */ - detachOutput : function(texture) { - for (var attachment in this.outputs) { - if (this.outputs[attachment] === texture) { - this.outputs[attachment] = null; - } - } - }, + this._updateShadowPCFKernel(accumFrame); - bind : function(renderer, frameBuffer) { + // Shadowmap will set clear color. + var bgColor = renderer.clearColor; + renderer.gl.clearColor(bgColor[0], bgColor[1], bgColor[2], bgColor[3]); - if (this.outputs) { - for (var attachment in this.outputs) { - var texture = this.outputs[attachment]; - if (texture) { - frameBuffer.attach(texture, attachment); - } - } + if (this._enablePostEffect) { + // normal render also needs to be jittered when have edge pass. + if (this.needsTemporalSS()) { + this._temporalSS.jitterProjection(renderer, camera); } + this._compositor.updateNormal(renderer, scene, camera, this._temporalSS.getFrame()); + } - if (frameBuffer) { - frameBuffer.bind(renderer); - } - }, + // Always update SSAO to make sure have correct ssaoMap status + this._updateSSAO(renderer, scene, camera, this._temporalSS.getFrame()); - unbind : function(renderer, frameBuffer) { - frameBuffer.unbind(renderer); - }, - /** - * @param {clay.Renderer} renderer - * @param {clay.FrameBuffer} [frameBuffer] - */ - render : function(renderer, frameBuffer) { + if (this._enablePostEffect) { - var _gl = renderer.gl; + var frameBuffer = this._compositor.getSourceFrameBuffer(); + frameBuffer.bind(renderer); + renderer.gl.clear(renderer.gl.DEPTH_BUFFER_BIT | renderer.gl.COLOR_BUFFER_BIT); + renderer.render(scene, camera, true, true); + frameBuffer.unbind(renderer); - if (frameBuffer) { - this.bind(renderer, frameBuffer); - // MRT Support in chrome - // https://www.khronos.org/registry/webgl/sdk/tests/conformance/extensions/ext-draw-buffers.html - var ext = renderer.getGLExtension('EXT_draw_buffers'); - if (ext && this.outputs) { - var bufs = []; - for (var attachment in this.outputs) { - attachment = +attachment; - if (attachment >= _gl.COLOR_ATTACHMENT0 && attachment <= _gl.COLOR_ATTACHMENT0 + 8) { - bufs.push(attachment); - } - } - ext.drawBuffersEXT(bufs); - } + if (this.needsTemporalSS() && accumulating) { + this._compositor.composite(renderer, scene, camera, this._temporalSS.getSourceFrameBuffer(), this._temporalSS.getFrame()); + renderer.setViewport(this.viewport); + this._temporalSS.render(renderer); } + else { + renderer.setViewport(this.viewport); + this._compositor.composite(renderer, scene, camera, null, 0); + } + } + else { + if (this.needsTemporalSS() && accumulating) { + var frameBuffer = this._temporalSS.getSourceFrameBuffer(); + frameBuffer.bind(renderer); + renderer.saveClear(); + renderer.clearBit = renderer.gl.DEPTH_BUFFER_BIT | renderer.gl.COLOR_BUFFER_BIT; + renderer.render(scene, camera, true, true); + renderer.restoreClear(); + frameBuffer.unbind(renderer); - this.trigger('beforerender', this, renderer); - - // FIXME Don't clear in each pass in default, let the color overwrite the buffer - // FIXME pixels may be discard - var clearBit = this.clearDepth ? _gl.DEPTH_BUFFER_BIT : 0; - _gl.depthMask(true); - if (this.clearColor) { - clearBit = clearBit | _gl.COLOR_BUFFER_BIT; - _gl.colorMask(true, true, true, true); - var cc = this.clearColor; - if (Array.isArray(cc)) { - _gl.clearColor(cc[0], cc[1], cc[2], cc[3]); - } + renderer.setViewport(this.viewport); + this._temporalSS.render(renderer); } - _gl.clear(clearBit); + else { + renderer.setViewport(this.viewport); + renderer.render(scene, camera, true, true); + } + } + + // this._shadowMapPass.renderDebug(renderer); + // this._compositor._normalPass.renderDebug(renderer); +}; - if (this.blendWithPrevious) { - // Blend with previous rendered scene in the final output - // FIXME Configure blend. - // FIXME It will cause screen blink? - _gl.enable(_gl.BLEND); - this.material.transparent = true; +ViewGL.prototype._updateTransparent = function (renderer, scene, camera, frame) { + + var v3 = new __WEBPACK_IMPORTED_MODULE_6_claygl_src_math_Vector3__["a" /* default */](); + var invWorldTransform = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */](); + var cameraWorldPosition = camera.getWorldPosition(); + var transparentList = scene.getRenderList(camera).transparent; + + // Sort transparent object. + for (var i = 0; i < transparentList.length; i++) { + var renderable = transparentList[i]; + var geometry = renderable.geometry; + __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */].invert(invWorldTransform, renderable.worldTransform); + __WEBPACK_IMPORTED_MODULE_6_claygl_src_math_Vector3__["a" /* default */].transformMat4(v3, cameraWorldPosition, invWorldTransform); + if (geometry.needsSortTriangles && geometry.needsSortTriangles()) { + geometry.doSortTriangles(v3, frame); } - else { - _gl.disable(_gl.BLEND); - this.material.transparent = false; + if (geometry.needsSortVertices && geometry.needsSortVertices()) { + geometry.doSortVertices(v3, frame); } + } +}; - this.renderQuad(renderer); +ViewGL.prototype._updateSSAO = function (renderer, scene, camera) { + var ifEnableSSAO = this._enableSSAO && this._enablePostEffect; + if (ifEnableSSAO) { + this._compositor.updateSSAO(renderer, scene, camera, this._temporalSS.getFrame()); + } + var renderList = scene.getRenderList(camera); - this.trigger('afterrender', this, renderer); + for (var i = 0; i < renderList.opaque.length; i++) { + var renderable = renderList.opaque[i]; + // PENDING + if (renderable.renderNormal) { + renderable.material[ifEnableSSAO ? 'enableTexture' : 'disableTexture']('ssaoMap'); + } + if (ifEnableSSAO) { + renderable.material.set('ssaoMap', this._compositor.getSSAOTexture()); + } + } +}; - if (frameBuffer) { - this.unbind(renderer, frameBuffer); +ViewGL.prototype._updateShadowPCFKernel = function (frame) { + var pcfKernel = this._pcfKernels[frame % this._pcfKernels.length]; + var renderList = this.scene.getRenderList(this.camera); + var opaqueList = renderList.opaque; + for (var i = 0; i < opaqueList.length; i++) { + if (opaqueList[i].receiveShadow) { + opaqueList[i].material.set('pcfKernel', pcfKernel); + opaqueList[i].material.define('fragment', 'PCF_KERNEL_SIZE', pcfKernel.length / 2); } - }, + } +}; - /** - * Simply do quad rendering - */ - renderQuad: function (renderer) { - mesh.material = this.material; - renderer.renderPass([mesh], camera); - }, +ViewGL.prototype.dispose = function (renderer) { + this._compositor.dispose(renderer.gl); + this._temporalSS.dispose(renderer.gl); + this._shadowMapPass.dispose(renderer); +}; +/** + * @param {module:echarts/Model} Post effect model + */ +ViewGL.prototype.setPostEffect = function (postEffectModel, api) { + var compositor = this._compositor; + this._enablePostEffect = postEffectModel.get('enable'); + var bloomModel = postEffectModel.getModel('bloom'); + var edgeModel = postEffectModel.getModel('edge'); + var dofModel = postEffectModel.getModel('DOF', postEffectModel.getModel('depthOfField')); + var ssaoModel = postEffectModel.getModel('SSAO', postEffectModel.getModel('screenSpaceAmbientOcclusion')); + var ssrModel = postEffectModel.getModel('SSR', postEffectModel.getModel('screenSpaceReflection')); + var fxaaModel = postEffectModel.getModel('FXAA'); + var colorCorrModel = postEffectModel.getModel('colorCorrection'); + bloomModel.get('enable') ? compositor.enableBloom() : compositor.disableBloom(); + dofModel.get('enable') ? compositor.enableDOF() : compositor.disableDOF(); + ssrModel.get('enable') ? compositor.enableSSR() : compositor.disableSSR(); + colorCorrModel.get('enable') ? compositor.enableColorCorrection() : compositor.disableColorCorrection(); + edgeModel.get('enable') ? compositor.enableEdge() : compositor.disableEdge(); + fxaaModel.get('enable') ? compositor.enableFXAA() : compositor.disableFXAA(); - /** - * @param {clay.Renderer} renderer - */ - dispose: function (renderer) {} -}); + this._enableDOF = dofModel.get('enable'); + this._enableSSAO = ssaoModel.get('enable'); -/* harmony default export */ __webpack_exports__["a"] = (Pass); + this._enableSSAO ? compositor.enableSSAO() : compositor.disableSSAO(); + compositor.setBloomIntensity(bloomModel.get('intensity')); + compositor.setEdgeColor(edgeModel.get('color')); + compositor.setColorLookupTexture(colorCorrModel.get('lookupTexture'), api); + compositor.setExposure(colorCorrModel.get('exposure')); -/***/ }), -/* 15 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + ['radius', 'quality', 'intensity'].forEach(function (name) { + compositor.setSSAOParameter(name, ssaoModel.get(name)); + }); + ['quality', 'maxRoughness', 'physical'].forEach(function (name) { + compositor.setSSRParameter(name, ssrModel.get(name)); + }); + ['quality', 'focalDistance', 'focalRange', 'blurRadius', 'fstop'].forEach(function (name) { + compositor.setDOFParameter(name, dofModel.get(name)); + }); + ['brightness', 'contrast', 'saturation'].forEach(function (name) { + compositor.setColorCorrection(name, colorCorrModel.get(name)); + }); -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__dep_glmatrix__); +}; +ViewGL.prototype.setDOFFocusOnPoint = function (depth) { + if (this._enablePostEffect) { -var vec3 = __WEBPACK_IMPORTED_MODULE_1__dep_glmatrix___default.a.vec3; + if (depth > this.camera.far || depth < this.camera.near) { + return; + } -var vec3Copy = vec3.copy; -var vec3Set = vec3.set; + this._compositor.setDOFParameter('focalDistance', depth); + return true; + } +}; -/** - * Axis aligned bounding box - * @constructor - * @alias clay.BoundingBox - * @param {clay.Vector3} [min] - * @param {clay.Vector3} [max] - */ -var BoundingBox = function (min, max) { +ViewGL.prototype.setTemporalSuperSampling = function (temporalSuperSamplingModel) { + this._enableTemporalSS = temporalSuperSamplingModel.get('enable'); +}; - /** - * Minimum coords of bounding box - * @type {clay.Vector3} - */ - this.min = min || new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](Infinity, Infinity, Infinity); +ViewGL.prototype.isLinearSpace = function () { + return this._enablePostEffect; +}; - /** - * Maximum coords of bounding box - * @type {clay.Vector3} - */ - this.max = max || new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](-Infinity, -Infinity, -Infinity); +ViewGL.prototype.setRootNode = function (rootNode) { + if (this.rootNode === rootNode) { + return; + } + var children = this.rootNode.children(); + for (var i = 0; i < children.length; i++) { + rootNode.add(children[i]); + } + if (rootNode !== this.scene) { + this.scene.add(rootNode); + } - this.vertices = null; + this.rootNode = rootNode; +}; +// Proxies +ViewGL.prototype.add = function (node3D) { + this.rootNode.add(node3D); +}; +ViewGL.prototype.remove = function (node3D) { + this.rootNode.remove(node3D); +}; +ViewGL.prototype.removeAll = function (node3D) { + this.rootNode.removeAll(node3D); }; -BoundingBox.prototype = { +__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.extend(ViewGL.prototype, __WEBPACK_IMPORTED_MODULE_8_claygl_src_core_mixin_notifier__["a" /* default */]); - constructor: BoundingBox, - /** - * Update min and max coords from a vertices array - * @param {array} vertices - */ - updateFromVertices: function (vertices) { - if (vertices.length > 0) { - var min = this.min; - var max = this.max; - var minArr = min.array; - var maxArr = max.array; - vec3Copy(minArr, vertices[0]); - vec3Copy(maxArr, vertices[0]); - for (var i = 1; i < vertices.length; i++) { - var vertex = vertices[i]; +/* harmony default export */ __webpack_exports__["a"] = (ViewGL); - if (vertex[0] < minArr[0]) { minArr[0] = vertex[0]; } - if (vertex[1] < minArr[1]) { minArr[1] = vertex[1]; } - if (vertex[2] < minArr[2]) { minArr[2] = vertex[2]; } +/***/ }), +/* 23 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - if (vertex[0] > maxArr[0]) { maxArr[0] = vertex[0]; } - if (vertex[1] > maxArr[1]) { maxArr[1] = vertex[1]; } - if (vertex[2] > maxArr[2]) { maxArr[2] = vertex[2]; } - } - min._dirty = true; - max._dirty = true; - } - }, +"use strict"; +var guid = 0; - /** - * Union operation with another bounding box - * @param {clay.BoundingBox} bbox - */ - union: function (bbox) { - var min = this.min; - var max = this.max; - vec3.min(min.array, min.array, bbox.min.array); - vec3.max(max.array, max.array, bbox.max.array); - min._dirty = true; - max._dirty = true; - return this; - }, +var ArrayProto = Array.prototype; +var nativeForEach = ArrayProto.forEach; - /** - * Intersection operation with another bounding box - * @param {clay.BoundingBox} bbox - */ - intersection: function (bbox) { - var min = this.min; - var max = this.max; - vec3.max(min.array, min.array, bbox.min.array); - vec3.min(max.array, max.array, bbox.max.array); - min._dirty = true; - max._dirty = true; - return this; - }, +/** + * Util functions + * @namespace clay.core.util + */ +var util = { /** - * If intersect with another bounding box - * @param {clay.BoundingBox} bbox - * @return {boolean} + * Generate GUID + * @return {number} + * @memberOf clay.core.util */ - intersectBoundingBox: function (bbox) { - var _min = this.min.array; - var _max = this.max.array; - - var _min2 = bbox.min.array; - var _max2 = bbox.max.array; - - return ! (_min[0] > _max2[0] || _min[1] > _max2[1] || _min[2] > _max2[2] - || _max[0] < _min2[0] || _max[1] < _min2[1] || _max[2] < _min2[2]); + genGUID: function () { + return ++guid; }, - /** - * If contain another bounding box entirely - * @param {clay.BoundingBox} bbox - * @return {boolean} + * Relative path to absolute path + * @param {string} path + * @param {string} basePath + * @return {string} + * @memberOf clay.core.util */ - containBoundingBox: function (bbox) { - - var _min = this.min.array; - var _max = this.max.array; - - var _min2 = bbox.min.array; - var _max2 = bbox.max.array; + relative2absolute: function (path, basePath) { + if (!basePath || path.match(/^\//)) { + return path; + } + var pathParts = path.split('/'); + var basePathParts = basePath.split('/'); - return _min[0] <= _min2[0] && _min[1] <= _min2[1] && _min[2] <= _min2[2] - && _max[0] >= _max2[0] && _max[1] >= _max2[1] && _max[2] >= _max2[2]; + var item = pathParts[0]; + while(item === '.' || item === '..') { + if (item === '..') { + basePathParts.pop(); + } + pathParts.shift(); + item = pathParts[0]; + } + return basePathParts.join('/') + '/' + pathParts.join('/'); }, /** - * If contain point entirely - * @param {clay.Vector3} point - * @return {boolean} + * Extend target with source + * @param {Object} target + * @param {Object} source + * @return {Object} + * @memberOf clay.core.util */ - containPoint: function (p) { - var _min = this.min.array; - var _max = this.max.array; - - var _p = p.array; - - return _min[0] <= _p[0] && _min[1] <= _p[1] && _min[2] <= _p[2] - && _max[0] >= _p[0] && _max[1] >= _p[1] && _max[2] >= _p[2]; + extend: function (target, source) { + if (source) { + for (var name in source) { + if (source.hasOwnProperty(name)) { + target[name] = source[name]; + } + } + } + return target; }, /** - * If bounding box is finite + * Extend properties to target if not exist. + * @param {Object} target + * @param {Object} source + * @return {Object} + * @memberOf clay.core.util */ - isFinite: function () { - var _min = this.min.array; - var _max = this.max.array; - return isFinite(_min[0]) && isFinite(_min[1]) && isFinite(_min[2]) - && isFinite(_max[0]) && isFinite(_max[1]) && isFinite(_max[2]); + defaults: function (target, source) { + if (source) { + for (var propName in source) { + if (target[propName] === undefined) { + target[propName] = source[propName]; + } + } + } + return target; }, - /** - * Apply an affine transform matrix to the bounding box - * @param {clay.Matrix4} matrix + * Extend properties with a given property list to avoid for..in.. iteration. + * @param {Object} target + * @param {Object} source + * @param {Array.} propList + * @return {Object} + * @memberOf clay.core.util */ - applyTransform: function (matrix) { - this.transformFrom(this, matrix); + extendWithPropList: function (target, source, propList) { + if (source) { + for (var i = 0; i < propList.length; i++) { + var propName = propList[i]; + target[propName] = source[propName]; + } + } + return target; }, - /** - * Get from another bounding box and an affine transform matrix. - * @param {clay.BoundingBox} source - * @param {clay.Matrix4} matrix + * Extend properties to target if not exist. With a given property list avoid for..in.. iteration. + * @param {Object} target + * @param {Object} source + * @param {Array.} propList + * @return {Object} + * @memberOf clay.core.util */ - transformFrom: (function () { - // http://dev.theomader.com/transform-bounding-boxes/ - var xa = vec3.create(); - var xb = vec3.create(); - var ya = vec3.create(); - var yb = vec3.create(); - var za = vec3.create(); - var zb = vec3.create(); - - return function (source, matrix) { - var min = source.min.array; - var max = source.max.array; - - var m = matrix.array; - - xa[0] = m[0] * min[0]; xa[1] = m[1] * min[0]; xa[2] = m[2] * min[0]; - xb[0] = m[0] * max[0]; xb[1] = m[1] * max[0]; xb[2] = m[2] * max[0]; - - ya[0] = m[4] * min[1]; ya[1] = m[5] * min[1]; ya[2] = m[6] * min[1]; - yb[0] = m[4] * max[1]; yb[1] = m[5] * max[1]; yb[2] = m[6] * max[1]; - - za[0] = m[8] * min[2]; za[1] = m[9] * min[2]; za[2] = m[10] * min[2]; - zb[0] = m[8] * max[2]; zb[1] = m[9] * max[2]; zb[2] = m[10] * max[2]; - - min = this.min.array; - max = this.max.array; - min[0] = Math.min(xa[0], xb[0]) + Math.min(ya[0], yb[0]) + Math.min(za[0], zb[0]) + m[12]; - min[1] = Math.min(xa[1], xb[1]) + Math.min(ya[1], yb[1]) + Math.min(za[1], zb[1]) + m[13]; - min[2] = Math.min(xa[2], xb[2]) + Math.min(ya[2], yb[2]) + Math.min(za[2], zb[2]) + m[14]; - - max[0] = Math.max(xa[0], xb[0]) + Math.max(ya[0], yb[0]) + Math.max(za[0], zb[0]) + m[12]; - max[1] = Math.max(xa[1], xb[1]) + Math.max(ya[1], yb[1]) + Math.max(za[1], zb[1]) + m[13]; - max[2] = Math.max(xa[2], xb[2]) + Math.max(ya[2], yb[2]) + Math.max(za[2], zb[2]) + m[14]; - - this.min._dirty = true; - this.max._dirty = true; - - return this; - }; - })(), - + defaultsWithPropList: function (target, source, propList) { + if (source) { + for (var i = 0; i < propList.length; i++) { + var propName = propList[i]; + if (target[propName] == null) { + target[propName] = source[propName]; + } + } + } + return target; + }, /** - * Apply a projection matrix to the bounding box - * @param {clay.Matrix4} matrix + * @param {Object|Array} obj + * @param {Function} iterator + * @param {Object} [context] + * @memberOf clay.core.util */ - applyProjection: function (matrix) { - var min = this.min.array; - var max = this.max.array; - - var m = matrix.array; - // min in min z - var v10 = min[0]; - var v11 = min[1]; - var v12 = min[2]; - // max in min z - var v20 = max[0]; - var v21 = max[1]; - var v22 = min[2]; - // max in max z - var v30 = max[0]; - var v31 = max[1]; - var v32 = max[2]; - - if (m[15] === 1) { // Orthographic projection - min[0] = m[0] * v10 + m[12]; - min[1] = m[5] * v11 + m[13]; - max[2] = m[10] * v12 + m[14]; - - max[0] = m[0] * v30 + m[12]; - max[1] = m[5] * v31 + m[13]; - min[2] = m[10] * v32 + m[14]; + each: function (obj, iterator, context) { + if (!(obj && iterator)) { + return; } - else { - var w = -1 / v12; - min[0] = m[0] * v10 * w; - min[1] = m[5] * v11 * w; - max[2] = (m[10] * v12 + m[14]) * w; - - w = -1 / v22; - max[0] = m[0] * v20 * w; - max[1] = m[5] * v21 * w; - - w = -1 / v32; - min[2] = (m[10] * v32 + m[14]) * w; + if (obj.forEach && obj.forEach === nativeForEach) { + obj.forEach(iterator, context); } - this.min._dirty = true; - this.max._dirty = true; - - return this; - }, - - updateVertices: function () { - var vertices = this.vertices; - if (!vertices) { - // Cube vertices - vertices = []; - for (var i = 0; i < 8; i++) { - vertices[i] = vec3.fromValues(0, 0, 0); + else if (obj.length === + obj.length) { + for (var i = 0, len = obj.length; i < len; i++) { + iterator.call(context, obj[i], i, obj); } - - /** - * Eight coords of bounding box - * @type {Float32Array[]} - */ - this.vertices = vertices; } - var min = this.min.array; - var max = this.max.array; - //--- min z - // min x - vec3Set(vertices[0], min[0], min[1], min[2]); - vec3Set(vertices[1], min[0], max[1], min[2]); - // max x - vec3Set(vertices[2], max[0], min[1], min[2]); - vec3Set(vertices[3], max[0], max[1], min[2]); + else { + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + iterator.call(context, obj[key], key, obj); + } + } + } + }, - //-- max z - vec3Set(vertices[4], min[0], min[1], max[2]); - vec3Set(vertices[5], min[0], max[1], max[2]); - vec3Set(vertices[6], max[0], min[1], max[2]); - vec3Set(vertices[7], max[0], max[1], max[2]); + /** + * Is object + * @param {} obj + * @return {boolean} + * @memberOf clay.core.util + */ + isObject: function (obj) { + return obj === Object(obj); + }, - return this; + /** + * Is array ? + * @param {} obj + * @return {boolean} + * @memberOf clay.core.util + */ + isArray: function (obj) { + return Array.isArray(obj); }, + /** - * Copy values from another bounding box - * @param {clay.BoundingBox} bbox + * Is array like, which have a length property + * @param {} obj + * @return {boolean} + * @memberOf clay.core.util */ - copy: function (bbox) { - var min = this.min; - var max = this.max; - vec3Copy(min.array, bbox.min.array); - vec3Copy(max.array, bbox.max.array); - min._dirty = true; - max._dirty = true; - return this; + isArrayLike: function (obj) { + if (!obj) { + return false; + } + else { + return obj.length === + obj.length; + } }, /** - * Clone a new bounding box - * @return {clay.BoundingBox} + * @param {} obj + * @return {} + * @memberOf clay.core.util */ - clone: function () { - var boundingBox = new BoundingBox(); - boundingBox.copy(this); - return boundingBox; + clone: function (obj) { + if (!util.isObject(obj)) { + return obj; + } + else if (util.isArray(obj)) { + return obj.slice(); + } + else if (util.isArrayLike(obj)) { // is typed array + var ret = new obj.constructor(obj.length); + for (var i = 0; i < obj.length; i++) { + ret[i] = obj[i]; + } + return ret; + } + else { + return util.extend({}, obj); + } } }; -/* harmony default export */ __webpack_exports__["a"] = (BoundingBox); - - -/***/ }), -/* 16 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = (function (seriesType, ecModel, api) { - return { - seriesType: seriesType, - reset: function (seriesModel, ecModel) { - var data = seriesModel.getData(); - var opacityAccessPath = seriesModel.visualColorAccessPath.split('.'); - opacityAccessPath[opacityAccessPath.length - 1] ='opacity'; - - var opacity = seriesModel.get(opacityAccessPath); - - data.setVisual('opacity', opacity == null ? 1 : opacity); - - function dataEach(data, idx) { - var itemModel = data.getItemModel(idx); - var opacity = itemModel.get(opacityAccessPath, true); - if (opacity != null) { - data.setItemVisual(idx, 'opacity', opacity); - } - } +/* harmony default export */ __webpack_exports__["a"] = (util); - return { - dataEach: data.hasItemOption ? dataEach : null - }; - } - }; -}); /***/ }), -/* 17 */ +/* 24 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Texture__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_util__ = __webpack_require__(20); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_color__ = __webpack_require__(105); - - +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(35); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Shader__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__shader_source_header_light__ = __webpack_require__(119); -var parseColor = __WEBPACK_IMPORTED_MODULE_3__core_color__["a" /* default */].parseToFloat; -var programKeyCache = {}; - -function getDefineCode(defines) { - var defineKeys = Object.keys(defines); - defineKeys.sort(); - var defineStr = []; - // Custom Defines - for (var i = 0; i < defineKeys.length; i++) { - var key = defineKeys[i]; - var value = defines[key]; - if (value === null) { - defineStr.push(key); - } - else{ - defineStr.push(key + ' ' + value.toString()); - } - } - return defineStr.join('\n'); -} - -function getProgramKey(vertexDefines, fragmentDefines, enabledTextures) { - enabledTextures.sort(); - var defineStr = []; - for (var i = 0; i < enabledTextures.length; i++) { - var symbol = enabledTextures[i]; - defineStr.push(symbol); - } - var key = getDefineCode(vertexDefines) + '\n' - + getDefineCode(fragmentDefines) + '\n' - + defineStr.join('\n'); - - if (programKeyCache[key]) { - return programKeyCache[key]; - } - var id = __WEBPACK_IMPORTED_MODULE_2__core_util__["a" /* default */].genGUID(); - programKeyCache[key] = id; - return id; -} +__WEBPACK_IMPORTED_MODULE_1__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_2__shader_source_header_light__["a" /* default */]); /** - * Material defines the appearance of mesh surface, like `color`, `roughness`, `metalness`, etc. - * It contains a {@link clay.Shader} and corresponding uniforms. - * - * Here is a basic example to create a standard material -```js -var material = new clay.Material({ - shader: new clay.Shader( - clay.Shader.source('clay.vertex'), - clay.Shader.source('clay.fragment') - ) -}); -``` - * @constructor clay.Material - * @extends clay.core.Base + * @constructor clay.Light + * @extends clay.Node */ -var Material = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () { - return /** @lends clay.Material# */ { - /** - * @type {string} - */ - name: '', - +var Light = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(function(){ + return /** @lends clay.Light# */ { /** - * @type {Object} + * Light RGB color + * @type {number[]} */ - // uniforms: null, + color: [1, 1, 1], /** - * @type {clay.Shader} + * Light intensity + * @type {number} */ - // shader: null, + intensity: 1.0, + // Config for shadow map /** + * If light cast shadow * @type {boolean} */ - depthTest: true, + castShadow: true, /** - * @type {boolean} + * Shadow map size + * @type {number} */ - depthMask: true, + shadowResolution: 512, /** - * @type {boolean} - */ - transparent: false, - /** - * Blend func is a callback function when the material - * have custom blending - * The gl context will be the only argument passed in tho the - * blend function - * Detail of blend function in WebGL: - * http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf + * Light group, shader with same `lightGroup` will be affected * - * Example : - * function(_gl) { - * _gl.blendEquation(_gl.FUNC_ADD); - * _gl.blendFunc(_gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA); - * } - */ - blend: null, - - /** - * If update texture status automatically. + * Only useful in forward rendering + * @type {number} */ - autoUpdateTextureStatus: true, - - uniforms: {}, - vertexDefines: {}, - fragmentDefines: {}, - _textureStatus: {}, - - // shadowTransparentMap : null - - // PENDING enable the uniform that only used in shader. - _enabledUniforms: null, + group: 0 }; -}, function () { - if (!this.name) { - this.name = 'MATERIAL_' + this.__uid__; - } - - if (this.shader) { - // Keep status, mainly preset uniforms, vertexDefines and fragmentDefines - this.attachShader(this.shader, true); - } }, -/** @lends clay.Material.prototype */ +/** @lends clay.Light.prototype. */ { - precision: 'highp', - /** - * Set material uniform - * @example - * mat.setUniform('color', [1, 1, 1, 1]); - * @param {string} symbol - * @param {number|array|clay.Texture|ArrayBufferView} value + * Light type + * @type {string} + * @memberOf clay.Light# */ - setUniform: function (symbol, value) { - if (value === undefined) { - console.warn('Uniform value "' + symbol + '" is undefined'); - } - var uniform = this.uniforms[symbol]; - if (uniform) { - - if (typeof value === 'string') { - // Try to parse as a color. Invalid color string will return null. - value = parseColor(value) || value; - } - - uniform.value = value; - - if (this.autoUpdateTextureStatus && uniform.type === 't') { - if (value) { - this.enableTexture(symbol); - } - else { - this.disableTexture(symbol); - } - } - } - }, + type: '', /** - * @param {Object} obj + * @return {clay.Light} + * @memberOf clay.Light.prototype */ - setUniforms: function(obj) { - for (var key in obj) { - var val = obj[key]; - this.setUniform(key, val); - } - }, + clone: function() { + var light = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].prototype.clone.call(this); + light.color = Array.prototype.slice.call(this.color); + light.intensity = this.intensity; + light.castShadow = this.castShadow; + light.shadowResolution = this.shadowResolution; - /** - * @param {string} symbol - * @return {boolean} - */ - isUniformEnabled: function (symbol) { - return this._enabledUniforms.indexOf(symbol) >= 0; - }, + return light; + } +}); - getEnabledUniforms: function () { - return this._enabledUniforms; - }, - getTextureUniforms: function () { - return this._textureUniforms; - }, +/* harmony default export */ __webpack_exports__["a"] = (Light); - /** - * Alias of setUniform and setUniforms - * @param {object|string} symbol - * @param {number|array|clay.Texture|ArrayBufferView} [value] - */ - set: function (symbol, value) { - if (typeof(symbol) === 'object') { - for (var key in symbol) { - var val = symbol[key]; - this.setUniform(key, val); - } - } - else { - this.setUniform(symbol, value); - } - }, - /** - * Get uniform value - * @param {string} symbol - * @return {number|array|clay.Texture|ArrayBufferView} - */ - get: function (symbol) { - var uniform = this.uniforms[symbol]; - if (uniform) { - return uniform.value; - } - }, - /** - * Attach a shader instance - * @param {clay.Shader} shader - * @param {boolean} keepStatus If try to keep uniform and texture - */ - attachShader: function(shader, keepStatus) { - var originalUniforms = this.uniforms; - // Ignore if uniform can use in shader. - this.uniforms = shader.createUniforms(); - this.shader = shader; +/***/ }), +/* 25 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - var uniforms = this.uniforms; - this._enabledUniforms = Object.keys(uniforms); - // Make sure uniforms are set in same order to avoid texture slot wrong - this._enabledUniforms.sort(); - this._textureUniforms = this._enabledUniforms.filter(function (uniformName) { - var type = this.uniforms[uniformName].type; - return type === 't' || type === 'tv'; - }, this); +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__ = __webpack_require__(38); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(6); +/** + * Lines geometry + * Use screen space projected lines lineWidth > MAX_LINE_WIDTH + * https://mattdesl.svbtle.com/drawing-lines-is-hard + * @module echarts-gl/util/geometry/LinesGeometry + * @author Yi Shen(http://github.com/pissang) + */ - var originalVertexDefines = this.vertexDefines; - var originalFragmentDefines = this.fragmentDefines; - this.vertexDefines = __WEBPACK_IMPORTED_MODULE_2__core_util__["a" /* default */].clone(shader.vertexDefines); - this.fragmentDefines = __WEBPACK_IMPORTED_MODULE_2__core_util__["a" /* default */].clone(shader.fragmentDefines); - if (keepStatus) { - for (var symbol in originalUniforms) { - if (uniforms[symbol]) { - uniforms[symbol].value = originalUniforms[symbol].value; - } - } - __WEBPACK_IMPORTED_MODULE_2__core_util__["a" /* default */].defaults(this.vertexDefines, originalVertexDefines); - __WEBPACK_IMPORTED_MODULE_2__core_util__["a" /* default */].defaults(this.fragmentDefines, originalFragmentDefines); - } - var textureStatus = {}; - for (var key in shader.textures) { - textureStatus[key] = { - shaderType: shader.textures[key].shaderType, - type: shader.textures[key].type, - enabled: (keepStatus && this._textureStatus[key]) ? this._textureStatus[key].enabled : false - }; - } +var vec3 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__["a" /* default */].vec3; - this._textureStatus = textureStatus; +// var CURVE_RECURSION_LIMIT = 8; +// var CURVE_COLLINEAR_EPSILON = 40; - this._programKey = ''; - }, +var sampleLinePoints = [[0, 0], [1, 1]]; +/** + * @constructor + * @alias module:echarts-gl/util/geometry/LinesGeometry + * @extends clay.Geometry + */ - /** - * Clone a new material and keep uniforms, shader will not be cloned - * @return {clay.Material} - */ - clone: function () { - var material = new this.constructor({ - name: this.name, - shader: this.shader - }); - for (var symbol in this.uniforms) { - material.uniforms[symbol].value = this.uniforms[symbol].value; - } - material.depthTest = this.depthTest; - material.depthMask = this.depthMask; - material.transparent = this.transparent; - material.blend = this.blend; +var LinesGeometry = __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].extend(function () { + return { - material.vertexDefines = __WEBPACK_IMPORTED_MODULE_2__core_util__["a" /* default */].clone(this.vertexDefines); - material.fragmentDefines = __WEBPACK_IMPORTED_MODULE_2__core_util__["a" /* default */].clone(this.fragmentDefines); - material.enableTexture(this.getEnabledTextures()); - material.precision = this.precision; + segmentScale: 1, - return material; - }, + dynamic: true, + /** + * Need to use mesh to expand lines if lineWidth > MAX_LINE_WIDTH + */ + useNativeLine: true, - /** - * Add a #define macro in shader code - * @param {string} shaderType Can be vertex, fragment or both - * @param {string} symbol - * @param {number} [val] - */ - define: function (shaderType, symbol, val) { - var vertexDefines = this.vertexDefines; - var fragmentDefines = this.fragmentDefines; - if (shaderType !== 'vertex' && shaderType !== 'fragment' && shaderType !== 'both' - && arguments.length < 3 - ) { - // shaderType default to be 'both' - val = symbol; - symbol = shaderType; - shaderType = 'both'; - } - val = val != null ? val : null; - if (shaderType === 'vertex' || shaderType === 'both') { - if (vertexDefines[symbol] !== val) { - vertexDefines[symbol] = val; - // Mark as dirty - this._programKey = ''; - } - } - if (shaderType === 'fragment' || shaderType === 'both') { - if (fragmentDefines[symbol] !== val) { - fragmentDefines[symbol] = val; - if (shaderType !== 'both') { - this._programKey = ''; - } - } + attributes: { + position: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('position', 'float', 3, 'POSITION'), + positionPrev: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('positionPrev', 'float', 3), + positionNext: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('positionNext', 'float', 3), + prevPositionPrev: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('prevPositionPrev', 'float', 3), + prevPosition: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('prevPosition', 'float', 3), + prevPositionNext: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('prevPositionNext', 'float', 3), + offset: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('offset', 'float', 1), + color: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('color', 'float', 4, 'COLOR') } - }, + }; +}, +/** @lends module: echarts-gl/util/geometry/LinesGeometry.prototype */ +{ /** - * Remove a #define macro in shader code - * @param {string} shaderType Can be vertex, fragment or both - * @param {string} symbol + * Reset offset */ - undefine: function (shaderType, symbol) { - if (shaderType !== 'vertex' && shaderType !== 'fragment' && shaderType !== 'both' - && arguments.length < 2 - ) { - // shaderType default to be 'both' - symbol = shaderType; - shaderType = 'both'; - } - if (shaderType === 'vertex' || shaderType === 'both') { - if (this.isDefined('vertex', symbol)) { - delete this.vertexDefines[symbol]; - // Mark as dirty - this._programKey = ''; - } - } - if (shaderType === 'fragment' || shaderType === 'both') { - if (this.isDefined('fragment', symbol)) { - delete this.fragmentDefines[symbol]; - if (shaderType !== 'both') { - this._programKey = ''; - } - } - } - }, + resetOffset: function () { + this._vertexOffset = 0; + this._triangleOffset = 0; - /** - * If macro is defined in shader. - * @param {string} shaderType Can be vertex, fragment or both - * @param {string} symbol - */ - isDefined: function (shaderType, symbol) { - // PENDING hasOwnProperty ? - switch (shaderType) { - case 'vertex': - return this.vertexDefines[symbol] !== undefined; - case 'fragment': - return this.fragmentDefines[symbol] !== undefined; - } - }, - /** - * Get macro value defined in shader. - * @param {string} shaderType Can be vertex, fragment or both - * @param {string} symbol - */ - getDefine: function (shaderType, symbol) { - switch(shaderType) { - case 'vertex': - return this.vertexDefines[symbol]; - case 'fragment': - return this.fragmentDefines[symbol]; - } + this._itemVertexOffsets = []; }, - /** - * Enable a texture, actually it will add a #define macro in the shader code - * For example, if texture symbol is diffuseMap, it will add a line `#define DIFFUSEMAP_ENABLED` in the shader code - * @param {string} symbol + + /** + * @param {number} nVertex */ - enableTexture: function (symbol) { - if (Array.isArray(symbol)) { - for (var i = 0; i < symbol.length; i++) { - this.enableTexture(symbol[i]); + setVertexCount: function (nVertex) { + var attributes = this.attributes; + if (this.vertexCount !== nVertex) { + attributes.position.init(nVertex); + attributes.color.init(nVertex); + + if (!this.useNativeLine) { + attributes.positionPrev.init(nVertex); + attributes.positionNext.init(nVertex); + attributes.offset.init(nVertex); } - return; - } - var status = this._textureStatus[symbol]; - if (status) { - var isEnabled = status.enabled; - if (!isEnabled) { - status.enabled = true; - this._programKey = ''; + if (nVertex > 0xffff) { + if (this.indices instanceof Uint16Array) { + this.indices = new Uint32Array(this.indices); + } + } + else { + if (this.indices instanceof Uint32Array) { + this.indices = new Uint16Array(this.indices); + } } } }, + /** - * Enable all textures used in the shader + * @param {number} nTriangle */ - enableTexturesAll: function () { - var textureStatus = this._textureStatus; - for (var symbol in textureStatus) { - textureStatus[symbol].enabled = true; + setTriangleCount: function (nTriangle) { + if (this.triangleCount !== nTriangle) { + if (nTriangle === 0) { + this.indices = null; + } + else { + this.indices = this.vertexCount > 0xffff ? new Uint32Array(nTriangle * 3) : new Uint16Array(nTriangle * 3); + } } + }, - this._programKey = ''; + _getCubicCurveApproxStep: function (p0, p1, p2, p3) { + var len = vec3.dist(p0, p1) + vec3.dist(p2, p1) + vec3.dist(p3, p2); + var step = 1 / (len + 1) * this.segmentScale; + return step; }, + /** - * Disable a texture, it remove a #define macro in the shader - * @param {string} symbol + * Get vertex count of cubic curve + * @param {Array.} p0 + * @param {Array.} p1 + * @param {Array.} p2 + * @param {Array.} p3 + * @return number */ - disableTexture: function (symbol) { - if (Array.isArray(symbol)) { - for (var i = 0; i < symbol.length; i++) { - this.disableTexture(symbol[i]); - } - return; + getCubicCurveVertexCount: function (p0, p1, p2, p3) { + var step = this._getCubicCurveApproxStep(p0, p1, p2, p3); + var segCount = Math.ceil(1 / step); + if (!this.useNativeLine) { + return segCount * 2 + 2; } - - var status = this._textureStatus[symbol]; - if (status) { - var isDisabled = ! status.enabled; - if (!isDisabled) { - status.enabled = false; - this._programKey = ''; - } + else { + return segCount * 2; } }, + /** - * Disable all textures used in the shader + * Get face count of cubic curve + * @param {Array.} p0 + * @param {Array.} p1 + * @param {Array.} p2 + * @param {Array.} p3 + * @return number */ - disableTexturesAll: function () { - var textureStatus = this._textureStatus; - for (var symbol in textureStatus) { - textureStatus[symbol].enabled = false; + getCubicCurveTriangleCount: function (p0, p1, p2, p3) { + var step = this._getCubicCurveApproxStep(p0, p1, p2, p3); + var segCount = Math.ceil(1 / step); + if (!this.useNativeLine) { + return segCount * 2; + } + else { + return 0; } + }, - this._programKey = ''; + /** + * Get vertex count of line + * @return {number} + */ + getLineVertexCount: function () { + return this.getPolylineVertexCount(sampleLinePoints); }, + /** - * If texture of given type is enabled. - * @param {string} symbol - * @return {boolean} + * Get face count of line + * @return {number} */ - isTextureEnabled: function (symbol) { - var textureStatus = this._textureStatus; - return !!textureStatus[symbol] - && textureStatus[symbol].enabled; + getLineTriangleCount: function () { + return this.getPolylineTriangleCount(sampleLinePoints); }, /** - * Get all enabled textures - * @return {string[]} + * Get how many vertices will polyline take. + * @type {number|Array} points Can be a 1d/2d list of points, or a number of points amount. + * @return {number} */ - getEnabledTextures: function () { - var enabledTextures = []; - var textureStatus = this._textureStatus; - for (var symbol in textureStatus) { - if (textureStatus[symbol].enabled) { - enabledTextures.push(symbol); - } + getPolylineVertexCount: function (points) { + var pointsLen; + if (typeof points === 'number') { + pointsLen = points; } - return enabledTextures; + else { + var is2DArray = typeof points[0] !== 'number'; + pointsLen = is2DArray ? points.length : (points.length / 3); + } + return !this.useNativeLine ? ((pointsLen - 1) * 2 + 2) : (pointsLen - 1) * 2; }, /** - * Mark defines are updated. + * Get how many triangles will polyline take. + * @type {number|Array} points Can be a 1d/2d list of points, or a number of points amount. + * @return {number} */ - dirtyDefines: function () { - this._programKey = ''; + getPolylineTriangleCount: function (points) { + var pointsLen; + if (typeof points === 'number') { + pointsLen = points; + } + else { + var is2DArray = typeof points[0] !== 'number'; + pointsLen = is2DArray ? points.length : (points.length / 3); + } + return !this.useNativeLine ? Math.max(pointsLen - 1, 0) * 2 : 0; }, - getProgramKey: function () { - if (!this._programKey) { - this._programKey = getProgramKey( - this.vertexDefines, this.fragmentDefines, this.getEnabledTextures() - ); + /** + * Add a cubic curve + * @param {Array.} p0 + * @param {Array.} p1 + * @param {Array.} p2 + * @param {Array.} p3 + * @param {Array.} color + * @param {number} [lineWidth=1] + */ + addCubicCurve: function (p0, p1, p2, p3, color, lineWidth) { + if (lineWidth == null) { + lineWidth = 1; } - return this._programKey; - } -}); - -/* harmony default export */ __webpack_exports__["a"] = (Material); - - -/***/ }), -/* 18 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -var supportWebGL = true; -try { - var canvas = document.createElement('canvas'); - var gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); - if (!gl) { - throw new Error(); - } -} catch (e) { - supportWebGL = false; -} - -var vendor = {}; - -/** - * If support WebGL - * @return {boolean} - */ -vendor.supportWebGL = function () { - return supportWebGL; -}; - - -vendor.Int8Array = typeof Int8Array == 'undefined' ? Array : Int8Array; - -vendor.Uint8Array = typeof Uint8Array == 'undefined' ? Array : Uint8Array; - -vendor.Uint16Array = typeof Uint16Array == 'undefined' ? Array : Uint16Array; - -vendor.Uint32Array = typeof Uint32Array == 'undefined' ? Array : Uint32Array; - -vendor.Int16Array = typeof Int16Array == 'undefined' ? Array : Int16Array; - -vendor.Float32Array = typeof Float32Array == 'undefined' ? Array : Float32Array; - -vendor.Float64Array = typeof Float64Array == 'undefined' ? Array : Float64Array; - -/* harmony default export */ __webpack_exports__["a"] = (vendor); - - -/***/ }), -/* 19 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Scene__ = __webpack_require__(32); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_prePass_ShadowMap__ = __webpack_require__(165); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_camera_Perspective__ = __webpack_require__(36); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_camera_Orthographic__ = __webpack_require__(33); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_math_Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_claygl_src_math_Vector2__ = __webpack_require__(23); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_claygl_src_core_mixin_notifier__ = __webpack_require__(47); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__effect_EffectCompositor__ = __webpack_require__(167); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__effect_TemporalSuperSampling__ = __webpack_require__(192); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__effect_halton__ = __webpack_require__(43); -/* - * @module echarts-gl/core/ViewGL - * @author Yi Shen(http://github.com/pissang) - */ - - - + // incremental interpolation + // http://antigrain.com/research/bezier_interpolation/index.html#PAGE_BEZIER_INTERPOLATION + var x0 = p0[0], y0 = p0[1], z0 = p0[2]; + var x1 = p1[0], y1 = p1[1], z1 = p1[2]; + var x2 = p2[0], y2 = p2[1], z2 = p2[2]; + var x3 = p3[0], y3 = p3[1], z3 = p3[2]; + var step = this._getCubicCurveApproxStep(p0, p1, p2, p3); + var step2 = step * step; + var step3 = step2 * step; + var pre1 = 3.0 * step; + var pre2 = 3.0 * step2; + var pre4 = 6.0 * step2; + var pre5 = 6.0 * step3; + var tmp1x = x0 - x1 * 2.0 + x2; + var tmp1y = y0 - y1 * 2.0 + y2; + var tmp1z = z0 - z1 * 2.0 + z2; + var tmp2x = (x1 - x2) * 3.0 - x0 + x3; + var tmp2y = (y1 - y2) * 3.0 - y0 + y3; + var tmp2z = (z1 - z2) * 3.0 - z0 + z3; + var fx = x0; + var fy = y0; + var fz = z0; + var dfx = (x1 - x0) * pre1 + tmp1x * pre2 + tmp2x * step3; + var dfy = (y1 - y0) * pre1 + tmp1y * pre2 + tmp2y * step3; + var dfz = (z1 - z0) * pre1 + tmp1z * pre2 + tmp2z * step3; + var ddfx = tmp1x * pre4 + tmp2x * pre5; + var ddfy = tmp1y * pre4 + tmp2y * pre5; + var ddfz = tmp1z * pre4 + tmp2z * pre5; + var dddfx = tmp2x * pre5; + var dddfy = tmp2y * pre5; + var dddfz = tmp2z * pre5; + var t = 0; + var k = 0; + var segCount = Math.ceil(1 / step); + var points = new Float32Array((segCount + 1) * 3); + var points = []; + var offset = 0; + for (var k = 0; k < segCount + 1; k++) { + points[offset++] = fx; + points[offset++] = fy; + points[offset++] = fz; + fx += dfx; fy += dfy; fz += dfz; + dfx += ddfx; dfy += ddfy; dfz += ddfz; + ddfx += dddfx; ddfy += dddfy; ddfz += dddfz; + t += step; -/** - * @constructor - * @alias module:echarts-gl/core/ViewGL - * @param {string} [projection='perspective'] - */ -function ViewGL(projection) { + if (t > 1) { + fx = dfx > 0 ? Math.min(fx, x3) : Math.max(fx, x3); + fy = dfy > 0 ? Math.min(fy, y3) : Math.max(fy, y3); + fz = dfz > 0 ? Math.min(fz, z3) : Math.max(fz, z3); + } + } - projection = projection || 'perspective'; + return this.addPolyline(points, color, lineWidth); + }, /** - * @type {module:echarts-gl/core/LayerGL} - */ - this.layer = null; - /** - * @type {clay.Scene} + * Add a straight line + * @param {Array.} p0 + * @param {Array.} p1 + * @param {Array.} color + * @param {number} [lineWidth=1] */ - this.scene = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Scene__["a" /* default */](); + addLine: function (p0, p1, color, lineWidth) { + return this.addPolyline([p0, p1], color, lineWidth); + }, /** - * @type {clay.Node} + * Add a straight line + * @param {Array. | Array.} points + * @param {Array. | Array.} color + * @param {number} [lineWidth=1] + * @param {number} [startOffset=0] + * @param {number} [pointsCount] Default to be amount of points in the first argument */ - this.rootNode = this.scene; - - this.viewport = { - x: 0, y: 0, width: 0, height: 0 - }; - - this.setProjection(projection); - - this._compositor = new __WEBPACK_IMPORTED_MODULE_9__effect_EffectCompositor__["a" /* default */](); - - this._temporalSS = new __WEBPACK_IMPORTED_MODULE_10__effect_TemporalSuperSampling__["a" /* default */](); - - this._shadowMapPass = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_prePass_ShadowMap__["a" /* default */](); - - var pcfKernels = []; - var off = 0; - for (var i = 0; i < 30; i++) { - var pcfKernel = []; - for (var k = 0; k < 6; k++) { - pcfKernel.push(Object(__WEBPACK_IMPORTED_MODULE_11__effect_halton__["a" /* default */])(off, 2) * 4.0 - 2.0); - pcfKernel.push(Object(__WEBPACK_IMPORTED_MODULE_11__effect_halton__["a" /* default */])(off, 3) * 4.0 - 2.0); - off++; + addPolyline: function (points, color, lineWidth, startOffset, pointsCount) { + if (!points.length) { + return; } - pcfKernels.push(pcfKernel); - } - this._pcfKernels = pcfKernels; - - this.scene.on('beforerender', function (renderer, scene, camera) { - if (this.needsTemporalSS()) { - this._temporalSS.jitterProjection(renderer, camera); + var is2DArray = typeof points[0] !== 'number'; + if (pointsCount == null) { + pointsCount = is2DArray ? points.length : points.length / 3; } - }, this); -} - -/** - * Set camera type of group - * @param {string} cameraType 'perspective' | 'orthographic' - */ -ViewGL.prototype.setProjection = function (projection) { - var oldCamera = this.camera; - oldCamera && oldCamera.update(); - if (projection === 'perspective') { - if (!(this.camera instanceof __WEBPACK_IMPORTED_MODULE_3_claygl_src_camera_Perspective__["a" /* default */])) { - this.camera = new __WEBPACK_IMPORTED_MODULE_3_claygl_src_camera_Perspective__["a" /* default */](); - if (oldCamera) { - this.camera.setLocalTransform(oldCamera.localTransform); - } + if (pointsCount < 2) { + return; } - } - else { - if (!(this.camera instanceof __WEBPACK_IMPORTED_MODULE_4_claygl_src_camera_Orthographic__["a" /* default */])) { - this.camera = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_camera_Orthographic__["a" /* default */](); - if (oldCamera) { - this.camera.setLocalTransform(oldCamera.localTransform); - } + if (startOffset == null) { + startOffset = 0; + } + if (lineWidth == null) { + lineWidth = 1; } - } - // PENDING - this.camera.near = 0.1; - this.camera.far = 2000; -}; - -/** - * Set viewport of group - * @param {number} x Viewport left bottom x - * @param {number} y Viewport left bottom y - * @param {number} width Viewport height - * @param {number} height Viewport height - * @param {number} [dpr=1] - */ -ViewGL.prototype.setViewport = function (x, y, width, height, dpr) { - if (this.camera instanceof __WEBPACK_IMPORTED_MODULE_3_claygl_src_camera_Perspective__["a" /* default */]) { - this.camera.aspect = width / height; - } - dpr = dpr || 1; - - this.viewport.x = x; - this.viewport.y = y; - this.viewport.width = width; - this.viewport.height = height; - this.viewport.devicePixelRatio = dpr; - // Source and output of compositor use high dpr texture. - // But the intermediate texture of bloom, dof effects use fixed 1.0 dpr - this._compositor.resize(width * dpr, height * dpr); - this._temporalSS.resize(width * dpr, height * dpr); -}; + this._itemVertexOffsets.push(this._vertexOffset); -/** - * If contain screen point x, y - * @param {number} x offsetX - * @param {number} y offsetY - * @return {boolean} - */ -ViewGL.prototype.containPoint = function (x, y) { - var viewport = this.viewport; - var height = this.layer.renderer.getHeight(); - // Flip y; - y = height - y; - return x >= viewport.x && y >= viewport.y - && x <= viewport.x + viewport.width && y <= viewport.y + viewport.height; -}; + var is2DArray = typeof points[0] !== 'number'; + var notSharingColor = is2DArray + ? typeof color[0] !== 'number' + : color.length / 4 === pointsCount; -/** - * Cast a ray - * @param {number} x offsetX - * @param {number} y offsetY - * @param {clay.math.Ray} out - * @return {clay.math.Ray} - */ -var ndc = new __WEBPACK_IMPORTED_MODULE_7_claygl_src_math_Vector2__["a" /* default */](); -ViewGL.prototype.castRay = function (x, y, out) { - var renderer = this.layer.renderer; + var positionAttr = this.attributes.position; + var positionPrevAttr = this.attributes.positionPrev; + var positionNextAttr = this.attributes.positionNext; + var colorAttr = this.attributes.color; + var offsetAttr = this.attributes.offset; + var indices = this.indices; - var oldViewport = renderer.viewport; - renderer.viewport = this.viewport; - renderer.screenToNDC(x, y, ndc); - this.camera.castRay(ndc, out); - renderer.viewport = oldViewport; + var vertexOffset = this._vertexOffset; + var point; + var pointColor; - return out; -}; + lineWidth = Math.max(lineWidth, 0.01); -/** - * Prepare and update scene before render - */ -ViewGL.prototype.prepareRender = function () { - this.scene.update(); - this.camera.update(); - this.scene.updateLights(); - var renderList = this.scene.updateRenderList(this.camera); + for (var k = startOffset; k < pointsCount; k++) { + if (is2DArray) { + point = points[k]; + if (notSharingColor) { + pointColor = color[k]; + } + else { + pointColor = color; + } + } + else { + var k3 = k * 3; + point = point || []; + point[0] = points[k3]; + point[1] = points[k3 + 1]; + point[2] = points[k3 + 2]; - this._needsSortProgressively = false; - // If has any transparent mesh needs sort triangles progressively. - for (var i = 0; i < renderList.transparent.length; i++) { - var renderable = renderList.transparent[i]; - var geometry = renderable.geometry; - if (geometry.needsSortVerticesProgressively && geometry.needsSortVerticesProgressively()) { - this._needsSortProgressively = true; - } - if (geometry.needsSortTrianglesProgressively && geometry.needsSortTrianglesProgressively()) { - this._needsSortProgressively = true; - } - } + if (notSharingColor) { + var k4 = k * 4; + pointColor = pointColor || []; + pointColor[0] = color[k4]; + pointColor[1] = color[k4 + 1]; + pointColor[2] = color[k4 + 2]; + pointColor[3] = color[k4 + 3]; + } + else { + pointColor = color; + } + } + if (!this.useNativeLine) { + if (k < pointsCount - 1) { + // Set to next two points + positionPrevAttr.set(vertexOffset + 2, point); + positionPrevAttr.set(vertexOffset + 3, point); + } + if (k > 0) { + // Set to previous two points + positionNextAttr.set(vertexOffset - 2, point); + positionNextAttr.set(vertexOffset - 1, point); + } - this._frame = 0; - this._temporalSS.resetFrame(); + positionAttr.set(vertexOffset, point); + positionAttr.set(vertexOffset + 1, point); - // var lights = this.scene.getLights(); - // for (var i = 0; i < lights.length; i++) { - // if (lights[i].cubemap) { - // if (this._compositor && this._compositor.isSSREnabled()) { - // lights[i].invisible = true; - // } - // else { - // lights[i].invisible = false; - // } - // } - // } -}; + colorAttr.set(vertexOffset, pointColor); + colorAttr.set(vertexOffset + 1, pointColor); -ViewGL.prototype.render = function (renderer, accumulating) { - this._doRender(renderer, accumulating, this._frame); - this._frame++; -}; + offsetAttr.set(vertexOffset, lineWidth / 2); + offsetAttr.set(vertexOffset + 1, -lineWidth / 2); -ViewGL.prototype.needsAccumulate = function () { - return this.needsTemporalSS() || this._needsSortProgressively; -}; + vertexOffset += 2; + } + else { + if (k > 1) { + positionAttr.copy(vertexOffset, vertexOffset - 1); + colorAttr.copy(vertexOffset, vertexOffset - 1); + vertexOffset++; + } + } -ViewGL.prototype.needsTemporalSS = function () { - var enableTemporalSS = this._enableTemporalSS; - if (enableTemporalSS === 'auto') { - enableTemporalSS = this._enablePostEffect; - } - return enableTemporalSS; -}; + if (!this.useNativeLine) { + if (k > 0) { + var idx3 = this._triangleOffset * 3; + var indices = this.indices; + // 0-----2 + // 1-----3 + // 0->1->2, 1->3->2 + indices[idx3] = vertexOffset - 4; + indices[idx3 + 1] = vertexOffset - 3; + indices[idx3 + 2] = vertexOffset - 2; -ViewGL.prototype.hasDOF = function () { - return this._enableDOF; -}; + indices[idx3 + 3] = vertexOffset - 3; + indices[idx3 + 4] = vertexOffset - 1; + indices[idx3 + 5] = vertexOffset - 2; -ViewGL.prototype.isAccumulateFinished = function () { - return this.needsTemporalSS() ? this._temporalSS.isFinished() - : (this._frame > 30); -}; + this._triangleOffset += 2; + } + } + else { + colorAttr.set(vertexOffset, pointColor); + positionAttr.set(vertexOffset, point); + vertexOffset++; + } + } + if (!this.useNativeLine) { + var start = this._vertexOffset; + var end = this._vertexOffset + pointsCount * 2; + positionPrevAttr.copy(start, start + 2); + positionPrevAttr.copy(start + 1, start + 3); + positionNextAttr.copy(end - 1, end - 3); + positionNextAttr.copy(end - 2, end - 4); + } -ViewGL.prototype._doRender = function (renderer, accumulating, accumFrame) { + this._vertexOffset = vertexOffset; - var scene = this.scene; - var camera = this.camera; + return this._vertexOffset; + }, - accumFrame = accumFrame || 0; + /** + * Set color of single line. + */ + setItemColor: function (idx, color) { + var startOffset = this._itemVertexOffsets[idx]; + var endOffset = idx < this._itemVertexOffsets.length - 1 ? this._itemVertexOffsets[idx + 1] : this._vertexOffset; - this._updateTransparent(renderer, scene, camera, accumFrame); + for (var i = startOffset; i < endOffset; i++) { + this.attributes.color.set(i, color); + } + this.dirty('color'); + }, - if (!accumulating) { - this._shadowMapPass.kernelPCF = this._pcfKernels[0]; - // Not render shadowmap pass in accumulating frame. - this._shadowMapPass.render(renderer, scene, camera, true); + /** + * @return {number} + */ + currentTriangleOffset: function () { + return this._triangleOffset; + }, + + /** + * @return {number} + */ + currentVertexOffset: function () { + return this._vertexOffset; } +}); - this._updateShadowPCFKernel(accumFrame); +__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.util.defaults(LinesGeometry.prototype, __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__["a" /* default */]); - // Shadowmap will set clear color. - var bgColor = renderer.clearColor; - renderer.gl.clearColor(bgColor[0], bgColor[1], bgColor[2], bgColor[3]); +/* harmony default export */ __webpack_exports__["a"] = (LinesGeometry); - if (this._enablePostEffect) { - // normal render also needs to be jittered when have edge pass. - if (this.needsTemporalSS()) { - this._temporalSS.jitterProjection(renderer, camera); - } - this._compositor.updateNormal(renderer, scene, camera, this._temporalSS.getFrame()); - } +/***/ }), +/* 26 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - // Always update SSAO to make sure have correct ssaoMap status - this._updateSSAO(renderer, scene, camera, this._temporalSS.getFrame()); +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__ = __webpack_require__(70); - if (this._enablePostEffect) { - var frameBuffer = this._compositor.getSourceFrameBuffer(); - frameBuffer.bind(renderer); - renderer.gl.clear(renderer.gl.DEPTH_BUFFER_BIT | renderer.gl.COLOR_BUFFER_BIT); - renderer.render(scene, camera, true, true); - frameBuffer.unbind(renderer); +/** + * @constructor + * @alias clay.Vector2 + * @param {number} x + * @param {number} y + */ +var Vector2 = function(x, y) { - if (this.needsTemporalSS() && accumulating) { - this._compositor.composite(renderer, scene, camera, this._temporalSS.getSourceFrameBuffer(), this._temporalSS.getFrame()); - renderer.setViewport(this.viewport); - this._temporalSS.render(renderer); - } - else { - renderer.setViewport(this.viewport); - this._compositor.composite(renderer, scene, camera, null, 0); - } - } - else { - if (this.needsTemporalSS() && accumulating) { - var frameBuffer = this._temporalSS.getSourceFrameBuffer(); - frameBuffer.bind(renderer); - renderer.saveClear(); - renderer.clearBit = renderer.gl.DEPTH_BUFFER_BIT | renderer.gl.COLOR_BUFFER_BIT; - renderer.render(scene, camera, true, true); - renderer.restoreClear(); - frameBuffer.unbind(renderer); + x = x || 0; + y = y || 0; - renderer.setViewport(this.viewport); - this._temporalSS.render(renderer); - } - else { - renderer.setViewport(this.viewport); - renderer.render(scene, camera, true, true); - } - } + /** + * Storage of Vector2, read and write of x, y will change the values in array + * All methods also operate on the array instead of x, y components + * @name array + * @type {Float32Array} + * @memberOf clay.Vector2# + */ + this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].fromValues(x, y); - // this._shadowMapPass.renderDebug(renderer); - // this._compositor._normalPass.renderDebug(renderer); + /** + * Dirty flag is used by the Node to determine + * if the matrix is updated to latest + * @name _dirty + * @type {boolean} + * @memberOf clay.Vector2# + */ + this._dirty = true; }; -ViewGL.prototype._updateTransparent = function (renderer, scene, camera, frame) { +Vector2.prototype = { - var v3 = new __WEBPACK_IMPORTED_MODULE_6_claygl_src_math_Vector3__["a" /* default */](); - var invWorldTransform = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */](); - var cameraWorldPosition = camera.getWorldPosition(); - var transparentList = scene.getRenderList(camera).transparent; + constructor: Vector2, - // Sort transparent object. - for (var i = 0; i < transparentList.length; i++) { - var renderable = transparentList[i]; - var geometry = renderable.geometry; - __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */].invert(invWorldTransform, renderable.worldTransform); - __WEBPACK_IMPORTED_MODULE_6_claygl_src_math_Vector3__["a" /* default */].transformMat4(v3, cameraWorldPosition, invWorldTransform); - if (geometry.needsSortTriangles && geometry.needsSortTriangles()) { - geometry.doSortTriangles(v3, frame); - } - if (geometry.needsSortVertices && geometry.needsSortVertices()) { - geometry.doSortVertices(v3, frame); - } - } -}; + /** + * Add b to self + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ + add: function(b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].add(this.array, this.array, b.array); + this._dirty = true; + return this; + }, -ViewGL.prototype._updateSSAO = function (renderer, scene, camera) { - var ifEnableSSAO = this._enableSSAO && this._enablePostEffect; - if (ifEnableSSAO) { - this._compositor.updateSSAO(renderer, scene, camera, this._temporalSS.getFrame()); - } - var renderList = scene.getRenderList(camera); + /** + * Set x and y components + * @param {number} x + * @param {number} y + * @return {clay.Vector2} + */ + set: function(x, y) { + this.array[0] = x; + this.array[1] = y; + this._dirty = true; + return this; + }, - for (var i = 0; i < renderList.opaque.length; i++) { - var renderable = renderList.opaque[i]; - // PENDING - if (renderable.renderNormal) { - renderable.material[ifEnableSSAO ? 'enableTexture' : 'disableTexture']('ssaoMap'); - } - if (ifEnableSSAO) { - renderable.material.set('ssaoMap', this._compositor.getSSAOTexture()); - } - } -}; + /** + * Set x and y components from array + * @param {Float32Array|number[]} arr + * @return {clay.Vector2} + */ + setArray: function(arr) { + this.array[0] = arr[0]; + this.array[1] = arr[1]; -ViewGL.prototype._updateShadowPCFKernel = function (frame) { - var pcfKernel = this._pcfKernels[frame % this._pcfKernels.length]; - var renderList = this.scene.getRenderList(this.camera); - var opaqueList = renderList.opaque; - for (var i = 0; i < opaqueList.length; i++) { - if (opaqueList[i].receiveShadow) { - opaqueList[i].material.set('pcfKernel', pcfKernel); - opaqueList[i].material.define('fragment', 'PCF_KERNEL_SIZE', pcfKernel.length / 2); - } - } -}; + this._dirty = true; + return this; + }, -ViewGL.prototype.dispose = function (renderer) { - this._compositor.dispose(renderer.gl); - this._temporalSS.dispose(renderer.gl); - this._shadowMapPass.dispose(renderer); -}; -/** - * @param {module:echarts/Model} Post effect model - */ -ViewGL.prototype.setPostEffect = function (postEffectModel, api) { - var compositor = this._compositor; - this._enablePostEffect = postEffectModel.get('enable'); - var bloomModel = postEffectModel.getModel('bloom'); - var edgeModel = postEffectModel.getModel('edge'); - var dofModel = postEffectModel.getModel('DOF', postEffectModel.getModel('depthOfField')); - var ssaoModel = postEffectModel.getModel('SSAO', postEffectModel.getModel('screenSpaceAmbientOcclusion')); - var ssrModel = postEffectModel.getModel('SSR', postEffectModel.getModel('screenSpaceReflection')); - var fxaaModel = postEffectModel.getModel('FXAA'); - var colorCorrModel = postEffectModel.getModel('colorCorrection'); - bloomModel.get('enable') ? compositor.enableBloom() : compositor.disableBloom(); - dofModel.get('enable') ? compositor.enableDOF() : compositor.disableDOF(); - ssrModel.get('enable') ? compositor.enableSSR() : compositor.disableSSR(); - colorCorrModel.get('enable') ? compositor.enableColorCorrection() : compositor.disableColorCorrection(); - edgeModel.get('enable') ? compositor.enableEdge() : compositor.disableEdge(); - fxaaModel.get('enable') ? compositor.enableFXAA() : compositor.disableFXAA(); + /** + * Clone a new Vector2 + * @return {clay.Vector2} + */ + clone: function() { + return new Vector2(this.x, this.y); + }, - this._enableDOF = dofModel.get('enable'); - this._enableSSAO = ssaoModel.get('enable'); + /** + * Copy x, y from b + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ + copy: function(b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].copy(this.array, b.array); + this._dirty = true; + return this; + }, - this._enableSSAO ? compositor.enableSSAO() : compositor.disableSSAO(); + /** + * Cross product of self and b, written to a Vector3 out + * @param {clay.Vector3} out + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ + cross: function(out, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].cross(out.array, this.array, b.array); + out._dirty = true; + return this; + }, - compositor.setBloomIntensity(bloomModel.get('intensity')); - compositor.setEdgeColor(edgeModel.get('color')); - compositor.setColorLookupTexture(colorCorrModel.get('lookupTexture'), api); - compositor.setExposure(colorCorrModel.get('exposure')); + /** + * Alias for distance + * @param {clay.Vector2} b + * @return {number} + */ + dist: function(b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].dist(this.array, b.array); + }, - ['radius', 'quality', 'intensity'].forEach(function (name) { - compositor.setSSAOParameter(name, ssaoModel.get(name)); - }); - ['quality', 'maxRoughness', 'physical'].forEach(function (name) { - compositor.setSSRParameter(name, ssrModel.get(name)); - }); - ['quality', 'focalDistance', 'focalRange', 'blurRadius', 'fstop'].forEach(function (name) { - compositor.setDOFParameter(name, dofModel.get(name)); - }); - ['brightness', 'contrast', 'saturation'].forEach(function (name) { - compositor.setColorCorrection(name, colorCorrModel.get(name)); - }); + /** + * Distance between self and b + * @param {clay.Vector2} b + * @return {number} + */ + distance: function(b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].distance(this.array, b.array); + }, -}; + /** + * Alias for divide + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ + div: function(b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].div(this.array, this.array, b.array); + this._dirty = true; + return this; + }, -ViewGL.prototype.setDOFFocusOnPoint = function (depth) { - if (this._enablePostEffect) { + /** + * Divide self by b + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ + divide: function(b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].divide(this.array, this.array, b.array); + this._dirty = true; + return this; + }, - if (depth > this.camera.far || depth < this.camera.near) { - return; - } + /** + * Dot product of self and b + * @param {clay.Vector2} b + * @return {number} + */ + dot: function(b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].dot(this.array, b.array); + }, - this._compositor.setDOFParameter('focalDistance', depth); - return true; - } -}; + /** + * Alias of length + * @return {number} + */ + len: function() { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].len(this.array); + }, -ViewGL.prototype.setTemporalSuperSampling = function (temporalSuperSamplingModel) { - this._enableTemporalSS = temporalSuperSamplingModel.get('enable'); -}; + /** + * Calculate the length + * @return {number} + */ + length: function() { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].length(this.array); + }, -ViewGL.prototype.isLinearSpace = function () { - return this._enablePostEffect; -}; + /** + * Linear interpolation between a and b + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @param {number} t + * @return {clay.Vector2} + */ + lerp: function(a, b, t) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].lerp(this.array, a.array, b.array, t); + this._dirty = true; + return this; + }, -ViewGL.prototype.setRootNode = function (rootNode) { - if (this.rootNode === rootNode) { - return; - } - var children = this.rootNode.children(); - for (var i = 0; i < children.length; i++) { - rootNode.add(children[i]); - } - if (rootNode !== this.scene) { - this.scene.add(rootNode); - } + /** + * Minimum of self and b + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ + min: function(b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].min(this.array, this.array, b.array); + this._dirty = true; + return this; + }, - this.rootNode = rootNode; -}; -// Proxies -ViewGL.prototype.add = function (node3D) { - this.rootNode.add(node3D); -}; -ViewGL.prototype.remove = function (node3D) { - this.rootNode.remove(node3D); -}; -ViewGL.prototype.removeAll = function (node3D) { - this.rootNode.removeAll(node3D); -}; + /** + * Maximum of self and b + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ + max: function(b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].max(this.array, this.array, b.array); + this._dirty = true; + return this; + }, -__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.extend(ViewGL.prototype, __WEBPACK_IMPORTED_MODULE_8_claygl_src_core_mixin_notifier__["a" /* default */]); + /** + * Alias for multiply + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ + mul: function(b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].mul(this.array, this.array, b.array); + this._dirty = true; + return this; + }, -/* harmony default export */ __webpack_exports__["a"] = (ViewGL); + /** + * Mutiply self and b + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ + multiply: function(b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].multiply(this.array, this.array, b.array); + this._dirty = true; + return this; + }, -/***/ }), -/* 20 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + /** + * Negate self + * @return {clay.Vector2} + */ + negate: function() { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].negate(this.array, this.array); + this._dirty = true; + return this; + }, -"use strict"; -var guid = 0; + /** + * Normalize self + * @return {clay.Vector2} + */ + normalize: function() { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].normalize(this.array, this.array); + this._dirty = true; + return this; + }, + + /** + * Generate random x, y components with a given scale + * @param {number} scale + * @return {clay.Vector2} + */ + random: function(scale) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].random(this.array, scale); + this._dirty = true; + return this; + }, -var ArrayProto = Array.prototype; -var nativeForEach = ArrayProto.forEach; + /** + * Scale self + * @param {number} scale + * @return {clay.Vector2} + */ + scale: function(s) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].scale(this.array, this.array, s); + this._dirty = true; + return this; + }, -/** - * Util functions - * @namespace clay.core.util - */ -var util = { + /** + * Scale b and add to self + * @param {clay.Vector2} b + * @param {number} scale + * @return {clay.Vector2} + */ + scaleAndAdd: function(b, s) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].scaleAndAdd(this.array, this.array, b.array, s); + this._dirty = true; + return this; + }, /** - * Generate GUID + * Alias for squaredDistance + * @param {clay.Vector2} b * @return {number} - * @memberOf clay.core.util */ - genGUID: function () { - return ++guid; + sqrDist: function(b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].sqrDist(this.array, b.array); }, + /** - * Relative path to absolute path - * @param {string} path - * @param {string} basePath - * @return {string} - * @memberOf clay.core.util + * Squared distance between self and b + * @param {clay.Vector2} b + * @return {number} */ - relative2absolute: function (path, basePath) { - if (!basePath || path.match(/^\//)) { - return path; - } - var pathParts = path.split('/'); - var basePathParts = basePath.split('/'); - - var item = pathParts[0]; - while(item === '.' || item === '..') { - if (item === '..') { - basePathParts.pop(); - } - pathParts.shift(); - item = pathParts[0]; - } - return basePathParts.join('/') + '/' + pathParts.join('/'); + squaredDistance: function(b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].squaredDistance(this.array, b.array); }, /** - * Extend target with source - * @param {Object} target - * @param {Object} source - * @return {Object} - * @memberOf clay.core.util + * Alias for squaredLength + * @return {number} */ - extend: function (target, source) { - if (source) { - for (var name in source) { - if (source.hasOwnProperty(name)) { - target[name] = source[name]; - } - } - } - return target; + sqrLen: function() { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].sqrLen(this.array); }, /** - * Extend properties to target if not exist. - * @param {Object} target - * @param {Object} source - * @return {Object} - * @memberOf clay.core.util + * Squared length of self + * @return {number} */ - defaults: function (target, source) { - if (source) { - for (var propName in source) { - if (target[propName] === undefined) { - target[propName] = source[propName]; - } - } - } - return target; + squaredLength: function() { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].squaredLength(this.array); }, + /** - * Extend properties with a given property list to avoid for..in.. iteration. - * @param {Object} target - * @param {Object} source - * @param {Array.} propList - * @return {Object} - * @memberOf clay.core.util + * Alias for subtract + * @param {clay.Vector2} b + * @return {clay.Vector2} */ - extendWithPropList: function (target, source, propList) { - if (source) { - for (var i = 0; i < propList.length; i++) { - var propName = propList[i]; - target[propName] = source[propName]; - } - } - return target; + sub: function(b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].sub(this.array, this.array, b.array); + this._dirty = true; + return this; }, + /** - * Extend properties to target if not exist. With a given property list avoid for..in.. iteration. - * @param {Object} target - * @param {Object} source - * @param {Array.} propList - * @return {Object} - * @memberOf clay.core.util + * Subtract b from self + * @param {clay.Vector2} b + * @return {clay.Vector2} */ - defaultsWithPropList: function (target, source, propList) { - if (source) { - for (var i = 0; i < propList.length; i++) { - var propName = propList[i]; - if (target[propName] == null) { - target[propName] = source[propName]; - } - } - } - return target; + subtract: function(b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].subtract(this.array, this.array, b.array); + this._dirty = true; + return this; }, + /** - * @param {Object|Array} obj - * @param {Function} iterator - * @param {Object} [context] - * @memberOf clay.core.util + * Transform self with a Matrix2 m + * @param {clay.Matrix2} m + * @return {clay.Vector2} */ - each: function (obj, iterator, context) { - if (!(obj && iterator)) { - return; - } - if (obj.forEach && obj.forEach === nativeForEach) { - obj.forEach(iterator, context); - } - else if (obj.length === + obj.length) { - for (var i = 0, len = obj.length; i < len; i++) { - iterator.call(context, obj[i], i, obj); - } - } - else { - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - iterator.call(context, obj[key], key, obj); - } - } - } + transformMat2: function(m) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat2(this.array, this.array, m.array); + this._dirty = true; + return this; }, /** - * Is object - * @param {} obj - * @return {boolean} - * @memberOf clay.core.util + * Transform self with a Matrix2d m + * @param {clay.Matrix2d} m + * @return {clay.Vector2} */ - isObject: function (obj) { - return obj === Object(obj); + transformMat2d: function(m) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat2d(this.array, this.array, m.array); + this._dirty = true; + return this; }, /** - * Is array ? - * @param {} obj - * @return {boolean} - * @memberOf clay.core.util + * Transform self with a Matrix3 m + * @param {clay.Matrix3} m + * @return {clay.Vector2} */ - isArray: function (obj) { - return Array.isArray(obj); + transformMat3: function(m) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat3(this.array, this.array, m.array); + this._dirty = true; + return this; }, /** - * Is array like, which have a length property - * @param {} obj - * @return {boolean} - * @memberOf clay.core.util + * Transform self with a Matrix4 m + * @param {clay.Matrix4} m + * @return {clay.Vector2} */ - isArrayLike: function (obj) { - if (!obj) { - return false; - } - else { - return obj.length === + obj.length; - } + transformMat4: function(m) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat4(this.array, this.array, m.array); + this._dirty = true; + return this; + }, + + toString: function() { + return '[' + Array.prototype.join.call(this.array, ',') + ']'; }, + toArray: function () { + return Array.prototype.slice.call(this.array); + } +}; + +// Getter and Setter +if (Object.defineProperty) { + + var proto = Vector2.prototype; /** - * @param {} obj - * @return {} - * @memberOf clay.core.util + * @name x + * @type {number} + * @memberOf clay.Vector2 + * @instance */ - clone: function (obj) { - if (!util.isObject(obj)) { - return obj; - } - else if (util.isArray(obj)) { - return obj.slice(); - } - else if (util.isArrayLike(obj)) { // is typed array - var ret = new obj.constructor(obj.length); - for (var i = 0; i < obj.length; i++) { - ret[i] = obj[i]; - } - return ret; + Object.defineProperty(proto, 'x', { + get: function () { + return this.array[0]; + }, + set: function (value) { + this.array[0] = value; + this._dirty = true; } - else { - return util.extend({}, obj); + }); + + /** + * @name y + * @type {number} + * @memberOf clay.Vector2 + * @instance + */ + Object.defineProperty(proto, 'y', { + get: function () { + return this.array[1]; + }, + set: function (value) { + this.array[1] = value; + this._dirty = true; } - } + }); +} + +// Supply methods that are not in place + +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ +Vector2.add = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].add(out.array, a.array, b.array); + out._dirty = true; + return out; +}; + +/** + * @param {clay.Vector2} out + * @param {number} x + * @param {number} y + * @return {clay.Vector2} + */ +Vector2.set = function(out, x, y) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].set(out.array, x, y); + out._dirty = true; + return out; +}; + +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ +Vector2.copy = function(out, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].copy(out.array, b.array); + out._dirty = true; + return out; +}; + +/** + * @param {clay.Vector3} out + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ +Vector2.cross = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].cross(out.array, a.array, b.array); + out._dirty = true; + return out; +}; +/** + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {number} + */ +Vector2.dist = function(a, b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].distance(a.array, b.array); +}; +/** + * @function + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {number} + */ +Vector2.distance = Vector2.dist; +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ +Vector2.div = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].divide(out.array, a.array, b.array); + out._dirty = true; + return out; +}; +/** + * @function + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ +Vector2.divide = Vector2.div; +/** + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {number} + */ +Vector2.dot = function(a, b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].dot(a.array, b.array); +}; + +/** + * @param {clay.Vector2} a + * @return {number} + */ +Vector2.len = function(b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].length(b.array); +}; + +// Vector2.length = Vector2.len; + +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @param {number} t + * @return {clay.Vector2} + */ +Vector2.lerp = function(out, a, b, t) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].lerp(out.array, a.array, b.array, t); + out._dirty = true; + return out; +}; +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ +Vector2.min = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].min(out.array, a.array, b.array); + out._dirty = true; + return out; +}; + +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ +Vector2.max = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].max(out.array, a.array, b.array); + out._dirty = true; + return out; +}; +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ +Vector2.mul = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].multiply(out.array, a.array, b.array); + out._dirty = true; + return out; +}; +/** + * @function + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ +Vector2.multiply = Vector2.mul; +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @return {clay.Vector2} + */ +Vector2.negate = function(out, a) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].negate(out.array, a.array); + out._dirty = true; + return out; +}; +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @return {clay.Vector2} + */ +Vector2.normalize = function(out, a) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].normalize(out.array, a.array); + out._dirty = true; + return out; +}; +/** + * @param {clay.Vector2} out + * @param {number} scale + * @return {clay.Vector2} + */ +Vector2.random = function(out, scale) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].random(out.array, scale); + out._dirty = true; + return out; +}; +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {number} scale + * @return {clay.Vector2} + */ +Vector2.scale = function(out, a, scale) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].scale(out.array, a.array, scale); + out._dirty = true; + return out; +}; +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @param {number} scale + * @return {clay.Vector2} + */ +Vector2.scaleAndAdd = function(out, a, b, scale) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].scaleAndAdd(out.array, a.array, b.array, scale); + out._dirty = true; + return out; +}; +/** + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {number} + */ +Vector2.sqrDist = function(a, b) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].sqrDist(a.array, b.array); +}; +/** + * @function + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {number} + */ +Vector2.squaredDistance = Vector2.sqrDist; + +/** + * @param {clay.Vector2} a + * @return {number} + */ +Vector2.sqrLen = function(a) { + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].sqrLen(a.array); +}; +/** + * @function + * @param {clay.Vector2} a + * @return {number} + */ +Vector2.squaredLength = Vector2.sqrLen; + +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ +Vector2.sub = function(out, a, b) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].subtract(out.array, a.array, b.array); + out._dirty = true; + return out; +}; +/** + * @function + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Vector2} b + * @return {clay.Vector2} + */ +Vector2.subtract = Vector2.sub; +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Matrix2} m + * @return {clay.Vector2} + */ +Vector2.transformMat2 = function(out, a, m) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat2(out.array, a.array, m.array); + out._dirty = true; + return out; +}; +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Matrix2d} m + * @return {clay.Vector2} + */ +Vector2.transformMat2d = function(out, a, m) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat2d(out.array, a.array, m.array); + out._dirty = true; + return out; +}; +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {Matrix3} m + * @return {clay.Vector2} + */ +Vector2.transformMat3 = function(out, a, m) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat3(out.array, a.array, m.array); + out._dirty = true; + return out; +}; +/** + * @param {clay.Vector2} out + * @param {clay.Vector2} a + * @param {clay.Matrix4} m + * @return {clay.Vector2} + */ +Vector2.transformMat4 = function(out, a, m) { + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat4(out.array, a.array, m.array); + out._dirty = true; + return out; }; -/* harmony default export */ __webpack_exports__["a"] = (util); +/* harmony default export */ __webpack_exports__["a"] = (Vector2); /***/ }), -/* 21 */ +/* 27 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(30); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_util__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_util__ = __webpack_require__(73); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_vendor__ = __webpack_require__(14); + + + +var isPowerOfTwo = __WEBPACK_IMPORTED_MODULE_3__math_util__["a" /* default */].isPowerOfTwo; + +var targetList = ['px', 'nx', 'py', 'ny', 'pz', 'nz']; + /** - * @constructor clay.Light - * @extends clay.Node + * @constructor clay.TextureCube + * @extends clay.Texture + * + * @example + * ... + * var mat = new clay.Material({ + * shader: clay.shader.library.get('clay.phong', 'environmentMap') + * }); + * var envMap = new clay.TextureCube(); + * envMap.load({ + * 'px': 'assets/textures/sky/px.jpg', + * 'nx': 'assets/textures/sky/nx.jpg' + * 'py': 'assets/textures/sky/py.jpg' + * 'ny': 'assets/textures/sky/ny.jpg' + * 'pz': 'assets/textures/sky/pz.jpg' + * 'nz': 'assets/textures/sky/nz.jpg' + * }); + * mat.set('environmentMap', envMap); + * ... + * envMap.success(function () { + * // Wait for the sky texture loaded + * animation.on('frame', function (frameTime) { + * renderer.render(scene, camera); + * }); + * }); */ -var Light = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(function(){ - return /** @lends clay.Light# */ { - /** - * Light RGB color - * @type {number[]} - */ - color: [1, 1, 1], +var TextureCube = __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].extend(function () { + return /** @lends clay.TextureCube# */{ /** - * Light intensity - * @type {number} + * @type {boolean} + * @default false */ - intensity: 1.0, + // PENDING cubemap should not flipY in default. + // flipY: false, - // Config for shadow map /** - * If light cast shadow - * @type {boolean} + * @type {Object} + * @property {?HTMLImageElement|HTMLCanvasElemnet} px + * @property {?HTMLImageElement|HTMLCanvasElemnet} nx + * @property {?HTMLImageElement|HTMLCanvasElemnet} py + * @property {?HTMLImageElement|HTMLCanvasElemnet} ny + * @property {?HTMLImageElement|HTMLCanvasElemnet} pz + * @property {?HTMLImageElement|HTMLCanvasElemnet} nz */ - castShadow: true, - + image: { + px: null, + nx: null, + py: null, + ny: null, + pz: null, + nz: null + }, /** - * Shadow map size - * @type {number} + * Pixels data of each side. Will be ignored if images are set. + * @type {Object} + * @property {?Uint8Array} px + * @property {?Uint8Array} nx + * @property {?Uint8Array} py + * @property {?Uint8Array} ny + * @property {?Uint8Array} pz + * @property {?Uint8Array} nz */ - shadowResolution: 512, + pixels: { + px: null, + nx: null, + py: null, + ny: null, + pz: null, + nz: null + }, /** - * Light group, shader with same `lightGroup` will be affected - * - * Only useful in forward rendering - * @type {number} + * @type {Array.} */ - group: 0 + mipmaps: [] }; -}, -/** @lends clay.Light.prototype. */ -{ - /** - * Light type - * @type {string} - * @memberOf clay.Light# - */ - type: '', - - /** - * @return {clay.Light} - * @memberOf clay.Light.prototype - */ - clone: function() { - var light = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].prototype.clone.call(this); - light.color = Array.prototype.slice.call(this.color); - light.intensity = this.intensity; - light.castShadow = this.castShadow; - light.shadowResolution = this.shadowResolution; - - return light; - } -}); - -/* harmony default export */ __webpack_exports__["a"] = (Light); - - -/***/ }), -/* 22 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__ = __webpack_require__(34); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__); -/** - * Lines geometry - * Use screen space projected lines lineWidth > MAX_LINE_WIDTH - * https://mattdesl.svbtle.com/drawing-lines-is-hard - * @module echarts-gl/util/geometry/LinesGeometry - * @author Yi Shen(http://github.com/pissang) - */ - - - - +}, { -var vec3 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix___default.a.vec3; + textureType: 'textureCube', -// var CURVE_RECURSION_LIMIT = 8; -// var CURVE_COLLINEAR_EPSILON = 40; + update: function (renderer) { + var _gl = renderer.gl; + _gl.bindTexture(_gl.TEXTURE_CUBE_MAP, this._cache.get('webgl_texture')); -var sampleLinePoints = [[0, 0], [1, 1]]; -/** - * @constructor - * @alias module:echarts-gl/util/geometry/LinesGeometry - * @extends clay.Geometry - */ + this.updateCommon(renderer); -var LinesGeometry = __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].extend(function () { - return { + var glFormat = this.format; + var glType = this.type; - segmentScale: 1, + _gl.texParameteri(_gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_WRAP_S, this.getAvailableWrapS()); + _gl.texParameteri(_gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_WRAP_T, this.getAvailableWrapT()); - dynamic: true, - /** - * Need to use mesh to expand lines if lineWidth > MAX_LINE_WIDTH - */ - useNativeLine: true, + _gl.texParameteri(_gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_MAG_FILTER, this.getAvailableMagFilter()); + _gl.texParameteri(_gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_MIN_FILTER, this.getAvailableMinFilter()); - attributes: { - position: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('position', 'float', 3, 'POSITION'), - positionPrev: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('positionPrev', 'float', 3), - positionNext: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('positionNext', 'float', 3), - prevPositionPrev: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('prevPositionPrev', 'float', 3), - prevPosition: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('prevPosition', 'float', 3), - prevPositionNext: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('prevPositionNext', 'float', 3), - offset: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('offset', 'float', 1), - color: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('color', 'float', 4, 'COLOR') + var anisotropicExt = renderer.getGLExtension('EXT_texture_filter_anisotropic'); + if (anisotropicExt && this.anisotropic > 1) { + _gl.texParameterf(_gl.TEXTURE_CUBE_MAP, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, this.anisotropic); } - }; -}, -/** @lends module: echarts-gl/util/geometry/LinesGeometry.prototype */ -{ - - /** - * Reset offset - */ - resetOffset: function () { - this._vertexOffset = 0; - this._triangleOffset = 0; - - this._itemVertexOffsets = []; - }, - - /** - * @param {number} nVertex - */ - setVertexCount: function (nVertex) { - var attributes = this.attributes; - if (this.vertexCount !== nVertex) { - attributes.position.init(nVertex); - attributes.color.init(nVertex); - if (!this.useNativeLine) { - attributes.positionPrev.init(nVertex); - attributes.positionNext.init(nVertex); - attributes.offset.init(nVertex); + // Fallback to float type if browser don't have half float extension + if (glType === 36193) { + var halfFloatExt = renderer.getGLExtension('OES_texture_half_float'); + if (!halfFloatExt) { + glType = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FLOAT; } + } - if (nVertex > 0xffff) { - if (this.indices instanceof Uint16Array) { - this.indices = new Uint32Array(this.indices); - } - } - else { - if (this.indices instanceof Uint32Array) { - this.indices = new Uint16Array(this.indices); - } + if (this.mipmaps.length) { + var width = this.width; + var height = this.height; + for (var i = 0; i < this.mipmaps.length; i++) { + var mipmap = this.mipmaps[i]; + this._updateTextureData(_gl, mipmap, i, width, height, glFormat, glType); + width /= 2; + height /= 2; } } - }, + else { + this._updateTextureData(_gl, this, 0, this.width, this.height, glFormat, glType); - /** - * @param {number} nTriangle - */ - setTriangleCount: function (nTriangle) { - if (this.triangleCount !== nTriangle) { - if (nTriangle === 0) { - this.indices = null; - } - else { - this.indices = this.vertexCount > 0xffff ? new Uint32Array(nTriangle * 3) : new Uint16Array(nTriangle * 3); + if (!this.NPOT && this.useMipmap) { + _gl.generateMipmap(_gl.TEXTURE_CUBE_MAP); } } - }, - _getCubicCurveApproxStep: function (p0, p1, p2, p3) { - var len = vec3.dist(p0, p1) + vec3.dist(p2, p1) + vec3.dist(p3, p2); - var step = 1 / (len + 1) * this.segmentScale; - return step; + _gl.bindTexture(_gl.TEXTURE_CUBE_MAP, null); }, - /** - * Get vertex count of cubic curve - * @param {Array.} p0 - * @param {Array.} p1 - * @param {Array.} p2 - * @param {Array.} p3 - * @return number - */ - getCubicCurveVertexCount: function (p0, p1, p2, p3) { - var step = this._getCubicCurveApproxStep(p0, p1, p2, p3); - var segCount = Math.ceil(1 / step); - if (!this.useNativeLine) { - return segCount * 2 + 2; - } - else { - return segCount * 2; + _updateTextureData: function (_gl, data, level, width, height, glFormat, glType) { + for (var i = 0; i < 6; i++) { + var target = targetList[i]; + var img = data.image && data.image[target]; + if (img) { + _gl.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level, glFormat, glFormat, glType, img); + } + else { + _gl.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level, glFormat, width, height, 0, glFormat, glType, data.pixels && data.pixels[target]); + } } }, /** - * Get face count of cubic curve - * @param {Array.} p0 - * @param {Array.} p1 - * @param {Array.} p2 - * @param {Array.} p3 - * @return number + * @param {clay.Renderer} renderer + * @memberOf clay.TextureCube.prototype */ - getCubicCurveTriangleCount: function (p0, p1, p2, p3) { - var step = this._getCubicCurveApproxStep(p0, p1, p2, p3); - var segCount = Math.ceil(1 / step); - if (!this.useNativeLine) { - return segCount * 2; - } - else { - return 0; + generateMipmap: function (renderer) { + var _gl = renderer.gl; + if (this.useMipmap && !this.NPOT) { + _gl.bindTexture(_gl.TEXTURE_CUBE_MAP, this._cache.get('webgl_texture')); + _gl.generateMipmap(_gl.TEXTURE_CUBE_MAP); } }, - /** - * Get vertex count of line - * @return {number} - */ - getLineVertexCount: function () { - return this.getPolylineVertexCount(sampleLinePoints); + bind: function (renderer) { + renderer.gl.bindTexture(renderer.gl.TEXTURE_CUBE_MAP, this.getWebGLTexture(renderer)); }, - /** - * Get face count of line - * @return {number} - */ - getLineTriangleCount: function () { - return this.getPolylineTriangleCount(sampleLinePoints); + unbind: function (renderer) { + renderer.gl.bindTexture(renderer.gl.TEXTURE_CUBE_MAP, null); }, - /** - * Get how many vertices will polyline take. - * @type {number|Array} points Can be a 1d/2d list of points, or a number of points amount. - * @return {number} - */ - getPolylineVertexCount: function (points) { - var pointsLen; - if (typeof points === 'number') { - pointsLen = points; + // Overwrite the isPowerOfTwo method + isPowerOfTwo: function () { + if (this.image.px) { + return isPowerOfTwo(this.image.px.width) + && isPowerOfTwo(this.image.px.height); } else { - var is2DArray = typeof points[0] !== 'number'; - pointsLen = is2DArray ? points.length : (points.length / 3); + return isPowerOfTwo(this.width) + && isPowerOfTwo(this.height); } - return !this.useNativeLine ? ((pointsLen - 1) * 2 + 2) : (pointsLen - 1) * 2; }, - /** - * Get how many triangles will polyline take. - * @type {number|Array} points Can be a 1d/2d list of points, or a number of points amount. - * @return {number} - */ - getPolylineTriangleCount: function (points) { - var pointsLen; - if (typeof points === 'number') { - pointsLen = points; + isRenderable: function () { + if (this.image.px) { + return isImageRenderable(this.image.px) + && isImageRenderable(this.image.nx) + && isImageRenderable(this.image.py) + && isImageRenderable(this.image.ny) + && isImageRenderable(this.image.pz) + && isImageRenderable(this.image.nz); } else { - var is2DArray = typeof points[0] !== 'number'; - pointsLen = is2DArray ? points.length : (points.length / 3); + return !!(this.width && this.height); } - return !this.useNativeLine ? Math.max(pointsLen - 1, 0) * 2 : 0; }, - /** - * Add a cubic curve - * @param {Array.} p0 - * @param {Array.} p1 - * @param {Array.} p2 - * @param {Array.} p3 - * @param {Array.} color - * @param {number} [lineWidth=1] - */ - addCubicCurve: function (p0, p1, p2, p3, color, lineWidth) { - if (lineWidth == null) { - lineWidth = 1; - } - // incremental interpolation - // http://antigrain.com/research/bezier_interpolation/index.html#PAGE_BEZIER_INTERPOLATION - var x0 = p0[0], y0 = p0[1], z0 = p0[2]; - var x1 = p1[0], y1 = p1[1], z1 = p1[2]; - var x2 = p2[0], y2 = p2[1], z2 = p2[2]; - var x3 = p3[0], y3 = p3[1], z3 = p3[2]; - - var step = this._getCubicCurveApproxStep(p0, p1, p2, p3); - - var step2 = step * step; - var step3 = step2 * step; - - var pre1 = 3.0 * step; - var pre2 = 3.0 * step2; - var pre4 = 6.0 * step2; - var pre5 = 6.0 * step3; - - var tmp1x = x0 - x1 * 2.0 + x2; - var tmp1y = y0 - y1 * 2.0 + y2; - var tmp1z = z0 - z1 * 2.0 + z2; - - var tmp2x = (x1 - x2) * 3.0 - x0 + x3; - var tmp2y = (y1 - y2) * 3.0 - y0 + y3; - var tmp2z = (z1 - z2) * 3.0 - z0 + z3; - - var fx = x0; - var fy = y0; - var fz = z0; - - var dfx = (x1 - x0) * pre1 + tmp1x * pre2 + tmp2x * step3; - var dfy = (y1 - y0) * pre1 + tmp1y * pre2 + tmp2y * step3; - var dfz = (z1 - z0) * pre1 + tmp1z * pre2 + tmp2z * step3; - - var ddfx = tmp1x * pre4 + tmp2x * pre5; - var ddfy = tmp1y * pre4 + tmp2y * pre5; - var ddfz = tmp1z * pre4 + tmp2z * pre5; - - var dddfx = tmp2x * pre5; - var dddfy = tmp2y * pre5; - var dddfz = tmp2z * pre5; - - var t = 0; - - var k = 0; - var segCount = Math.ceil(1 / step); - - var points = new Float32Array((segCount + 1) * 3); - var points = []; - var offset = 0; - for (var k = 0; k < segCount + 1; k++) { - points[offset++] = fx; - points[offset++] = fy; - points[offset++] = fz; - - fx += dfx; fy += dfy; fz += dfz; - dfx += ddfx; dfy += ddfy; dfz += ddfz; - ddfx += dddfx; ddfy += dddfy; ddfz += dddfz; - t += step; - - if (t > 1) { - fx = dfx > 0 ? Math.min(fx, x3) : Math.max(fx, x3); - fy = dfy > 0 ? Math.min(fy, y3) : Math.max(fy, y3); - fz = dfz > 0 ? Math.min(fz, z3) : Math.max(fz, z3); + load: function (imageList, crossOrigin) { + var loading = 0; + var self = this; + __WEBPACK_IMPORTED_MODULE_2__core_util__["a" /* default */].each(imageList, function (src, target){ + var image = __WEBPACK_IMPORTED_MODULE_4__core_vendor__["a" /* default */].createImage(); + if (crossOrigin) { + image.crossOrigin = crossOrigin; } - } + image.onload = function () { + loading --; + if (loading === 0){ + self.dirty(); + self.trigger('success', self); + } + image.onload = null; + }; + image.onerror = function () { + loading --; + image.onerror = null; + }; - return this.addPolyline(points, color, lineWidth); - }, + loading++; + image.src = src; + self.image[target] = image; + }); - /** - * Add a straight line - * @param {Array.} p0 - * @param {Array.} p1 - * @param {Array.} color - * @param {number} [lineWidth=1] - */ - addLine: function (p0, p1, color, lineWidth) { - return this.addPolyline([p0, p1], color, lineWidth); + return this; + } +}); + +Object.defineProperty(TextureCube.prototype, 'width', { + get: function () { + if (this.image && this.image.px) { + return this.image.px.width; + } + return this._width; }, - - /** - * Add a straight line - * @param {Array. | Array.} points - * @param {Array. | Array.} color - * @param {number} [lineWidth=1] - * @param {number} [startOffset=0] - * @param {number} [pointsCount] Default to be amount of points in the first argument - */ - addPolyline: function (points, color, lineWidth, startOffset, pointsCount) { - if (!points.length) { - return; + set: function (value) { + if (this.image && this.image.px) { + console.warn('Texture from image can\'t set width'); } - var is2DArray = typeof points[0] !== 'number'; - if (pointsCount == null) { - pointsCount = is2DArray ? points.length : points.length / 3; + else { + if (this._width !== value) { + this.dirty(); + } + this._width = value; } - if (pointsCount < 2) { - return; + } +}); +Object.defineProperty(TextureCube.prototype, 'height', { + get: function () { + if (this.image && this.image.px) { + return this.image.px.height; } - if (startOffset == null) { - startOffset = 0; + return this._height; + }, + set: function (value) { + if (this.image && this.image.px) { + console.warn('Texture from image can\'t set height'); } - if (lineWidth == null) { - lineWidth = 1; + else { + if (this._height !== value) { + this.dirty(); + } + this._height = value; } + } +}); +function isImageRenderable(image) { + return image.nodeName === 'CANVAS' || + image.nodeName === 'VIDEO' || + image.complete; +} - this._itemVertexOffsets.push(this._vertexOffset); +/* harmony default export */ __webpack_exports__["a"] = (TextureCube); - var is2DArray = typeof points[0] !== 'number'; - var notSharingColor = is2DArray - ? typeof color[0] !== 'number' - : color.length / 4 === pointsCount; - var positionAttr = this.attributes.position; - var positionPrevAttr = this.attributes.positionPrev; - var positionNextAttr = this.attributes.positionNext; - var colorAttr = this.attributes.color; - var offsetAttr = this.attributes.offset; - var indices = this.indices; +/***/ }), +/* 28 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - var vertexOffset = this._vertexOffset; - var point; - var pointColor; +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ({ + defaultOption: { + // Post effect + postEffect: { + enable: false, - lineWidth = Math.max(lineWidth, 0.01); + bloom: { + enable: true, + intensity: 0.1 + }, + depthOfField: { + enable: false, + focalRange: 20, + focalDistance: 50, + blurRadius: 10, + fstop: 2.8, + quality: 'medium' + }, - for (var k = startOffset; k < pointsCount; k++) { - if (is2DArray) { - point = points[k]; - if (notSharingColor) { - pointColor = color[k]; - } - else { - pointColor = color; - } - } - else { - var k3 = k * 3; - point = point || []; - point[0] = points[k3]; - point[1] = points[k3 + 1]; - point[2] = points[k3 + 2]; + screenSpaceAmbientOcclusion: { + enable: false, + radius: 2, + // low, medium, high, ultra + quality: 'medium', + intensity: 1 + }, - if (notSharingColor) { - var k4 = k * 4; - pointColor = pointColor || []; - pointColor[0] = color[k4]; - pointColor[1] = color[k4 + 1]; - pointColor[2] = color[k4 + 2]; - pointColor[3] = color[k4 + 3]; - } - else { - pointColor = color; - } - } - if (!this.useNativeLine) { - if (k < pointsCount - 1) { - // Set to next two points - positionPrevAttr.set(vertexOffset + 2, point); - positionPrevAttr.set(vertexOffset + 3, point); - } - if (k > 0) { - // Set to previous two points - positionNextAttr.set(vertexOffset - 2, point); - positionNextAttr.set(vertexOffset - 1, point); - } + screenSpaceReflection: { + enable: false, + quality: 'medium', + maxRoughness: 0.8 + }, - positionAttr.set(vertexOffset, point); - positionAttr.set(vertexOffset + 1, point); + colorCorrection: { + enable: true, - colorAttr.set(vertexOffset, pointColor); - colorAttr.set(vertexOffset + 1, pointColor); + exposure: 0, - offsetAttr.set(vertexOffset, lineWidth / 2); - offsetAttr.set(vertexOffset + 1, -lineWidth / 2); + brightness: 0, - vertexOffset += 2; - } - else { - if (k > 1) { - positionAttr.copy(vertexOffset, vertexOffset - 1); - colorAttr.copy(vertexOffset, vertexOffset - 1); - vertexOffset++; - } - } + contrast: 1, - if (!this.useNativeLine) { - if (k > 0) { - var idx3 = this._triangleOffset * 3; - var indices = this.indices; - // 0-----2 - // 1-----3 - // 0->1->2, 1->3->2 - indices[idx3] = vertexOffset - 4; - indices[idx3 + 1] = vertexOffset - 3; - indices[idx3 + 2] = vertexOffset - 2; + saturation: 1, - indices[idx3 + 3] = vertexOffset - 3; - indices[idx3 + 4] = vertexOffset - 1; - indices[idx3 + 5] = vertexOffset - 2; + lookupTexture: '' + }, - this._triangleOffset += 2; - } - } - else { - colorAttr.set(vertexOffset, pointColor); - positionAttr.set(vertexOffset, point); - vertexOffset++; + edge: { + enable: false + }, + + FXAA: { + enable: false } + }, + + // Temporal super sampling when the picture is still. + temporalSuperSampling: { + // Only enabled when postEffect is enabled + enable: 'auto' } - if (!this.useNativeLine) { - var start = this._vertexOffset; - var end = this._vertexOffset + pointsCount * 2; - positionPrevAttr.copy(start, start + 2); - positionPrevAttr.copy(start + 1, start + 3); - positionNextAttr.copy(end - 1, end - 3); - positionNextAttr.copy(end - 2, end - 4); - } + } +}); - this._vertexOffset = vertexOffset; +/***/ }), +/* 29 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - return this._vertexOffset; - }, +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ({ + defaultOption: { + // Light is available when material.shading is not color + light: { + // Main light + main: { + shadow: false, + // low, medium, high, ultra + shadowQuality: 'high', - /** - * Set color of single line. - */ - setItemColor: function (idx, color) { - var startOffset = this._itemVertexOffsets[idx]; - var endOffset = idx < this._itemVertexOffsets.length - 1 ? this._itemVertexOffsets[idx + 1] : this._vertexOffset; + color: '#fff', + intensity: 1, - for (var i = startOffset; i < endOffset; i++) { - this.attributes.color.set(i, color); + alpha: 0, + beta: 0 + }, + ambient: { + color: '#fff', + intensity: 0.2 + }, + ambientCubemap: { + // Panorama environment texture, + // Support .hdr and commmon web formats. + texture: null, + // Available when texture is hdr. + exposure: 1, + // Intensity for diffuse term + diffuseIntensity: 0.5, + // Intensity for specular term, only available when shading is realastic + specularIntensity: 0.5 + } } - this.dirty('color'); - }, - - /** - * @return {number} - */ - currentTriangleOffset: function () { - return this._triangleOffset; - }, - - /** - * @return {number} - */ - currentVertexOffset: function () { - return this._vertexOffset; } }); -__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.util.defaults(LinesGeometry.prototype, __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__["a" /* default */]); - -/* harmony default export */ __webpack_exports__["a"] = (LinesGeometry); - /***/ }), -/* 23 */ +/* 30 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__); - -var vec2 = __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default.a.vec2; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_plugin_Skybox__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts__); -/** - * @constructor - * @alias clay.Vector2 - * @param {number} x - * @param {number} y - */ -var Vector2 = function(x, y) { - x = x || 0; - y = y || 0; - /** - * Storage of Vector2, read and write of x, y will change the values in array - * All methods also operate on the array instead of x, y components - * @name array - * @type {Float32Array} - * @memberOf clay.Vector2# - */ - this.array = vec2.fromValues(x, y); - /** - * Dirty flag is used by the Node to determine - * if the matrix is updated to latest - * @name _dirty - * @type {boolean} - * @memberOf clay.Vector2# - */ - this._dirty = true; -}; +function SceneHelper() { +} -Vector2.prototype = { +SceneHelper.prototype = { + constructor: SceneHelper, - constructor: Vector2, + setScene: function (scene) { + this._scene = scene; - /** - * Add b to self - * @param {clay.Vector2} b - * @return {clay.Vector2} - */ - add: function(b) { - vec2.add(this.array, this.array, b.array); - this._dirty = true; - return this; + if (this._skybox) { + this._skybox.attachScene(this._scene); + } }, - /** - * Set x and y components - * @param {number} x - * @param {number} y - * @return {clay.Vector2} - */ - set: function(x, y) { - this.array[0] = x; - this.array[1] = y; - this._dirty = true; - return this; - }, + initLight: function (rootNode) { + this._lightRoot = rootNode; + /** + * @type {clay.light.Directional} + */ + this.mainLight = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].DirectionalLight({ + shadowBias: 0.005 + }); - /** - * Set x and y components from array - * @param {Float32Array|number[]} arr - * @return {clay.Vector2} - */ - setArray: function(arr) { - this.array[0] = arr[0]; - this.array[1] = arr[1]; + /** + * @type {clay.light.Ambient} + */ + this.ambientLight = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].AmbientLight(); - this._dirty = true; - return this; + rootNode.add(this.mainLight); + rootNode.add(this.ambientLight); }, - /** - * Clone a new Vector2 - * @return {clay.Vector2} - */ - clone: function() { - return new Vector2(this.x, this.y); + dispose: function () { + if (this._lightRoot) { + this._lightRoot.remove(this.mainLight); + this._lightRoot.remove(this.ambientLight); + } }, - /** - * Copy x, y from b - * @param {clay.Vector2} b - * @return {clay.Vector2} - */ - copy: function(b) { - vec2.copy(this.array, b.array); - this._dirty = true; - return this; - }, + updateLight: function (componentModel) { - /** - * Cross product of self and b, written to a Vector3 out - * @param {clay.Vector3} out - * @param {clay.Vector2} b - * @return {clay.Vector2} - */ - cross: function(out, b) { - vec2.cross(out.array, this.array, b.array); - out._dirty = true; - return this; - }, + var mainLight = this.mainLight; + var ambientLight = this.ambientLight; - /** - * Alias for distance - * @param {clay.Vector2} b - * @return {number} - */ - dist: function(b) { - return vec2.dist(this.array, b.array); - }, + var lightModel = componentModel.getModel('light'); + var mainLightModel = lightModel.getModel('main'); + var ambientLightModel = lightModel.getModel('ambient'); - /** - * Distance between self and b - * @param {clay.Vector2} b - * @return {number} - */ - distance: function(b) { - return vec2.distance(this.array, b.array); - }, + mainLight.intensity = mainLightModel.get('intensity'); + ambientLight.intensity = ambientLightModel.get('intensity'); + mainLight.color = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].parseColor(mainLightModel.get('color')).slice(0, 3); + ambientLight.color = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].parseColor(ambientLightModel.get('color')).slice(0, 3); - /** - * Alias for divide - * @param {clay.Vector2} b - * @return {clay.Vector2} - */ - div: function(b) { - vec2.div(this.array, this.array, b.array); - this._dirty = true; - return this; - }, + var alpha = mainLightModel.get('alpha') || 0; + var beta = mainLightModel.get('beta') || 0; + mainLight.position.setArray(__WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].directionFromAlphaBeta(alpha, beta)); + mainLight.lookAt(__WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Vector3.ZERO); - /** - * Divide self by b - * @param {clay.Vector2} b - * @return {clay.Vector2} - */ - divide: function(b) { - vec2.divide(this.array, this.array, b.array); - this._dirty = true; - return this; + mainLight.castShadow = mainLightModel.get('shadow'); + mainLight.shadowResolution = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].getShadowResolution(mainLightModel.get('shadowQuality')); }, - /** - * Dot product of self and b - * @param {clay.Vector2} b - * @return {number} - */ - dot: function(b) { - return vec2.dot(this.array, b.array); + updateAmbientCubemap: function (renderer, componentModel, api) { + var ambientCubemapModel = componentModel.getModel('light.ambientCubemap'); + + var textureUrl = ambientCubemapModel.get('texture'); + if (textureUrl) { + this._cubemapLightsCache = this._cubemapLightsCache || {}; + var lights = this._cubemapLightsCache[textureUrl]; + if (!lights) { + var self = this; + lights = this._cubemapLightsCache[textureUrl] + = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].createAmbientCubemap(ambientCubemapModel.option, renderer, api, function () { + // Use prefitered cubemap + if (self._isSkyboxFromAmbientCubemap) { + self._skybox.setEnvironmentMap(lights.specular.cubemap); + } + + api.getZr().refresh(); + }); + } + this._lightRoot.add(lights.diffuse); + this._lightRoot.add(lights.specular); + + this._currentCubemapLights = lights; + } + else if (this._currentCubemapLights) { + this._lightRoot.remove(this._currentCubemapLights.diffuse); + this._lightRoot.remove(this._currentCubemapLights.specular); + this._currentCubemapLights = null; + } }, - /** - * Alias of length - * @return {number} - */ - len: function() { - return vec2.len(this.array); - }, + updateSkybox: function (renderer, componentModel, api) { + var environmentUrl = componentModel.get('environment'); + + var self = this; + function getSkybox() { + self._skybox = self._skybox || new __WEBPACK_IMPORTED_MODULE_1_claygl_src_plugin_Skybox__["a" /* default */](); + return self._skybox; + } + + var skybox = getSkybox(); + if (environmentUrl && environmentUrl !== 'none') { + if (environmentUrl === 'auto') { + this._isSkyboxFromAmbientCubemap = true; + // Use environment in ambient cubemap + if (this._currentCubemapLights) { + var cubemap = this._currentCubemapLights.specular.cubemap; + skybox.setEnvironmentMap(cubemap); + if (this._scene) { + skybox.attachScene(this._scene); + } + skybox.material.set('lod', 3); + } + else if (this._skybox) { + this._skybox.detachScene(); + } + } + // Is gradient or color string + else if ((typeof environmentUrl === 'object' && environmentUrl.colorStops) + || (typeof environmentUrl === 'string' && __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default.a.color.parse(environmentUrl)) + ) { + this._isSkyboxFromAmbientCubemap = false; + var texture = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Texture2D({ + anisotropic: 8, + flipY: false + }); + skybox.setEnvironmentMap(texture); + var canvas = texture.image = document.createElement('canvas'); + canvas.width = canvas.height = 16; + var ctx = canvas.getContext('2d'); + var rect = new __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default.a.graphic.Rect({ + shape: { x: 0, y: 0, width: 16, height: 16 }, + style: { fill: environmentUrl } + }); + rect.brush(ctx); + + skybox.attachScene(this._scene); + } + else { + this._isSkyboxFromAmbientCubemap = false; + // Panorama + var texture = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].loadTexture(environmentUrl, api, { + anisotropic: 8, + flipY: false + }); + skybox.setEnvironmentMap(texture); + + skybox.attachScene(this._scene); + } + } + else { + if (this._skybox) { + this._skybox.detachScene(this._scene); + } + this._skybox = null; + } - /** - * Calculate the length - * @return {number} - */ - length: function() { - return vec2.length(this.array); - }, + var coordSys = componentModel.coordinateSystem; + if (this._skybox) { + if (coordSys && coordSys.viewGL + && environmentUrl !== 'auto' + && !(environmentUrl.match && environmentUrl.match(/.hdr$/)) + ) { + var srgbDefineMethod = coordSys.viewGL.isLinearSpace() ? 'define' : 'undefine'; + this._skybox.material[srgbDefineMethod]('fragment', 'SRGB_DECODE'); + } + else { + this._skybox.material.undefine('fragment', 'SRGB_DECODE'); + } + // var ambientCubemapUrl = environmentUrl === 'auto' + // ? componentModel.get('light.ambientCubemap.texture') + // : environmentUrl; + } + } +}; - /** - * Linear interpolation between a and b - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @param {number} t - * @return {clay.Vector2} - */ - lerp: function(a, b, t) { - vec2.lerp(this.array, a.array, b.array, t); - this._dirty = true; - return this; - }, +/* harmony default export */ __webpack_exports__["a"] = (SceneHelper); - /** - * Minimum of self and b - * @param {clay.Vector2} b - * @return {clay.Vector2} - */ - min: function(b) { - vec2.min(this.array, this.array, b.array); - this._dirty = true; - return this; - }, +/***/ }), +/* 31 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - /** - * Maximum of self and b - * @param {clay.Vector2} b - * @return {clay.Vector2} - */ - max: function(b) { - vec2.max(this.array, this.array, b.array); - this._dirty = true; - return this; - }, +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ({ + defaultOption: { + shading: null, - /** - * Alias for multiply - * @param {clay.Vector2} b - * @return {clay.Vector2} - */ - mul: function(b) { - vec2.mul(this.array, this.array, b.array); - this._dirty = true; - return this; - }, + realisticMaterial: { + textureTiling: 1, + textureOffset: 0, - /** - * Mutiply self and b - * @param {clay.Vector2} b - * @return {clay.Vector2} - */ - multiply: function(b) { - vec2.multiply(this.array, this.array, b.array); - this._dirty = true; - return this; - }, + detailTexture: null + }, - /** - * Negate self - * @return {clay.Vector2} - */ - negate: function() { - vec2.negate(this.array, this.array); - this._dirty = true; - return this; - }, + lambertMaterial: { + textureTiling: 1, + textureOffset: 0, - /** - * Normalize self - * @return {clay.Vector2} - */ - normalize: function() { - vec2.normalize(this.array, this.array); - this._dirty = true; - return this; - }, + detailTexture: null + }, - /** - * Generate random x, y components with a given scale - * @param {number} scale - * @return {clay.Vector2} - */ - random: function(scale) { - vec2.random(this.array, scale); - this._dirty = true; - return this; - }, + colorMaterial: { + textureTiling: 1, + textureOffset: 0, - /** - * Scale self - * @param {number} scale - * @return {clay.Vector2} - */ - scale: function(s) { - vec2.scale(this.array, this.array, s); - this._dirty = true; - return this; - }, + detailTexture: null + }, - /** - * Scale b and add to self - * @param {clay.Vector2} b - * @param {number} scale - * @return {clay.Vector2} - */ - scaleAndAdd: function(b, s) { - vec2.scaleAndAdd(this.array, this.array, b.array, s); - this._dirty = true; - return this; - }, + hatchingMaterial: { + textureTiling: 1, + textureOffset: 0, - /** - * Alias for squaredDistance - * @param {clay.Vector2} b - * @return {number} - */ - sqrDist: function(b) { - return vec2.sqrDist(this.array, b.array); - }, + paperColor: '#fff' + } + } +}); - /** - * Squared distance between self and b - * @param {clay.Vector2} b - * @return {number} - */ - squaredDistance: function(b) { - return vec2.squaredDistance(this.array, b.array); - }, +/***/ }), +/* 32 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - /** - * Alias for squaredLength - * @return {number} - */ - sqrLen: function() { - return vec2.sqrLen(this.array); - }, +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); - /** - * Squared length of self - * @return {number} - */ - squaredLength: function() { - return vec2.squaredLength(this.array); - }, - /** - * Alias for subtract - * @param {clay.Vector2} b - * @return {clay.Vector2} - */ - sub: function(b) { - vec2.sub(this.array, this.array, b.array); - this._dirty = true; - return this; - }, +var formatUtil = {}; +formatUtil.getFormattedLabel = function (seriesModel, dataIndex, status, dataType, dimIndex) { + status = status || 'normal'; + var data = seriesModel.getData(dataType); + var itemModel = data.getItemModel(dataIndex); - /** - * Subtract b from self - * @param {clay.Vector2} b - * @return {clay.Vector2} - */ - subtract: function(b) { - vec2.subtract(this.array, this.array, b.array); - this._dirty = true; - return this; - }, + var params = seriesModel.getDataParams(dataIndex, dataType); + if (dimIndex != null && (params.value instanceof Array)) { + params.value = params.value[dimIndex]; + } - /** - * Transform self with a Matrix2 m - * @param {clay.Matrix2} m - * @return {clay.Vector2} - */ - transformMat2: function(m) { - vec2.transformMat2(this.array, this.array, m.array); - this._dirty = true; - return this; - }, + var formatter = itemModel.get(status === 'normal' ? ['label', 'formatter'] : ['emphasis', 'label', 'formatter']); + if (formatter == null) { + formatter = itemModel.get(['label', 'formatter']); + } + var text; + if (typeof formatter === 'function') { + params.status = status; + text = formatter(params); + } + else if (typeof formatter === 'string') { + text = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.format.formatTpl(formatter, params); + } + return text; +}; - /** - * Transform self with a Matrix2d m - * @param {clay.Matrix2d} m - * @return {clay.Vector2} - */ - transformMat2d: function(m) { - vec2.transformMat2d(this.array, this.array, m.array); - this._dirty = true; - return this; - }, +/** + * If value is not array, then convert it to array. + * @param {*} value + * @return {Array} [value] or value + */ +formatUtil.normalizeToArray = function (value) { + return value instanceof Array + ? value + : value == null + ? [] + : [value]; +}; - /** - * Transform self with a Matrix3 m - * @param {clay.Matrix3} m - * @return {clay.Vector2} - */ - transformMat3: function(m) { - vec2.transformMat3(this.array, this.array, m.array); - this._dirty = true; - return this; - }, +/* harmony default export */ __webpack_exports__["a"] = (formatUtil); - /** - * Transform self with a Matrix4 m - * @param {clay.Matrix4} m - * @return {clay.Vector2} - */ - transformMat4: function(m) { - vec2.transformMat4(this.array, this.array, m.array); - this._dirty = true; - return this; - }, +/***/ }), +/* 33 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - toString: function() { - return '[' + Array.prototype.join.call(this.array, ',') + ']'; - }, +"use strict"; +/* unused harmony export vec4 */ +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20); - toArray: function () { - return Array.prototype.slice.call(this.array); - } -}; +/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. -// Getter and Setter -if (Object.defineProperty) { +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: - var proto = Vector2.prototype; - /** - * @name x - * @type {number} - * @memberOf clay.Vector2 - * @instance - */ - Object.defineProperty(proto, 'x', { - get: function () { - return this.array[0]; - }, - set: function (value) { - this.array[0] = value; - this._dirty = true; - } - }); + * 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 HOLDER 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 USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - /** - * @name y - * @type {number} - * @memberOf clay.Vector2 - * @instance - */ - Object.defineProperty(proto, 'y', { - get: function () { - return this.array[1]; - }, - set: function (value) { - this.array[1] = value; - this._dirty = true; - } - }); -} -// Supply methods that are not in place /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {clay.Vector2} + * @class 4 Dimensional Vector + * @name vec4 */ -Vector2.add = function(out, a, b) { - vec2.add(out.array, a.array, b.array); - out._dirty = true; - return out; -}; + +var vec4 = {}; /** - * @param {clay.Vector2} out - * @param {number} x - * @param {number} y - * @return {clay.Vector2} + * Creates a new, empty vec4 + * + * @returns {vec4} a new 4D vector */ -Vector2.set = function(out, x, y) { - vec2.set(out.array, x, y); - out._dirty = true; +vec4.create = function() { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](4); + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 0; return out; }; /** - * @param {clay.Vector2} out - * @param {clay.Vector2} b - * @return {clay.Vector2} + * Creates a new vec4 initialized with values from an existing vector + * + * @param {vec4} a vector to clone + * @returns {vec4} a new 4D vector */ -Vector2.copy = function(out, b) { - vec2.copy(out.array, b.array); - out._dirty = true; +vec4.clone = function(a) { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](4); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; return out; }; /** - * @param {clay.Vector3} out - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {clay.Vector2} + * 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 */ -Vector2.cross = function(out, a, b) { - vec2.cross(out.array, a.array, b.array); - out._dirty = true; +vec4.fromValues = function(x, y, z, w) { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](4); + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = w; return out; }; + /** - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {number} + * Copy the values from one vec4 to another + * + * @param {vec4} out the receiving vector + * @param {vec4} a the source vector + * @returns {vec4} out */ -Vector2.dist = function(a, b) { - return vec2.distance(a.array, b.array); +vec4.copy = function(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; }; + /** - * @function - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {number} - */ -Vector2.distance = Vector2.dist; -/** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {clay.Vector2} + * 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 */ -Vector2.div = function(out, a, b) { - vec2.divide(out.array, a.array, b.array); - out._dirty = true; +vec4.set = function(out, x, y, z, w) { + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = w; return out; }; + /** - * @function - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {clay.Vector2} - */ -Vector2.divide = Vector2.div; -/** - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {number} + * 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 */ -Vector2.dot = function(a, b) { - return vec2.dot(a.array, b.array); +vec4.add = function(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; }; /** - * @param {clay.Vector2} a - * @return {number} + * 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 */ -Vector2.len = function(b) { - return vec2.length(b.array); +vec4.subtract = function(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; }; -// Vector2.length = Vector2.len; - /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @param {number} t - * @return {clay.Vector2} + * Alias for {@link vec4.subtract} + * @function */ -Vector2.lerp = function(out, a, b, t) { - vec2.lerp(out.array, a.array, b.array, t); - out._dirty = true; - return out; -}; +vec4.sub = vec4.subtract; + /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {clay.Vector2} + * 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 */ -Vector2.min = function(out, a, b) { - vec2.min(out.array, a.array, b.array); - out._dirty = true; +vec4.multiply = function(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; }; /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {clay.Vector2} + * Alias for {@link vec4.multiply} + * @function */ -Vector2.max = function(out, a, b) { - vec2.max(out.array, a.array, b.array); - out._dirty = true; - return out; -}; +vec4.mul = vec4.multiply; + /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {clay.Vector2} + * 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 */ -Vector2.mul = function(out, a, b) { - vec2.multiply(out.array, a.array, b.array); - out._dirty = true; +vec4.divide = function(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; }; + /** + * Alias for {@link vec4.divide} * @function - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {clay.Vector2} */ -Vector2.multiply = Vector2.mul; +vec4.div = vec4.divide; + /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @return {clay.Vector2} + * 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 */ -Vector2.negate = function(out, a) { - vec2.negate(out.array, a.array); - out._dirty = true; +vec4.min = function(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; }; + /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @return {clay.Vector2} + * 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 */ -Vector2.normalize = function(out, a) { - vec2.normalize(out.array, a.array); - out._dirty = true; +vec4.max = function(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; }; + /** - * @param {clay.Vector2} out - * @param {number} scale - * @return {clay.Vector2} + * 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 */ -Vector2.random = function(out, scale) { - vec2.random(out.array, scale); - out._dirty = true; +vec4.scale = function(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; }; + /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {number} scale - * @return {clay.Vector2} + * 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 */ -Vector2.scale = function(out, a, scale) { - vec2.scale(out.array, a.array, scale); - out._dirty = true; +vec4.scaleAndAdd = function(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; }; + /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @param {number} scale - * @return {clay.Vector2} + * 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 */ -Vector2.scaleAndAdd = function(out, a, b, scale) { - vec2.scaleAndAdd(out.array, a.array, b.array, scale); - out._dirty = true; - return out; +vec4.distance = function(a, b) { + var x = b[0] - a[0], + y = b[1] - a[1], + z = b[2] - a[2], + w = b[3] - a[3]; + return Math.sqrt(x*x + y*y + z*z + w*w); }; + /** - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {number} + * Alias for {@link vec4.distance} + * @function */ -Vector2.sqrDist = function(a, b) { - return vec2.sqrDist(a.array, b.array); +vec4.dist = vec4.distance; + +/** + * 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 + */ +vec4.squaredDistance = function(a, b) { + var x = b[0] - a[0], + y = b[1] - a[1], + z = b[2] - a[2], + w = b[3] - a[3]; + return x*x + y*y + z*z + w*w; }; + /** + * Alias for {@link vec4.squaredDistance} * @function - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {number} */ -Vector2.squaredDistance = Vector2.sqrDist; +vec4.sqrDist = vec4.squaredDistance; /** - * @param {clay.Vector2} a - * @return {number} + * Calculates the length of a vec4 + * + * @param {vec4} a vector to calculate length of + * @returns {Number} length of a */ -Vector2.sqrLen = function(a) { - return vec2.sqrLen(a.array); +vec4.length = function (a) { + var x = a[0], + y = a[1], + z = a[2], + w = a[3]; + return Math.sqrt(x*x + y*y + z*z + w*w); }; + /** + * Alias for {@link vec4.length} * @function - * @param {clay.Vector2} a - * @return {number} */ -Vector2.squaredLength = Vector2.sqrLen; +vec4.len = vec4.length; /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {clay.Vector2} + * Calculates the squared length of a vec4 + * + * @param {vec4} a vector to calculate squared length of + * @returns {Number} squared length of a */ -Vector2.sub = function(out, a, b) { - vec2.subtract(out.array, a.array, b.array); - out._dirty = true; - return out; +vec4.squaredLength = function (a) { + var x = a[0], + y = a[1], + z = a[2], + w = a[3]; + return x*x + y*y + z*z + w*w; }; + /** + * Alias for {@link vec4.squaredLength} * @function - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Vector2} b - * @return {clay.Vector2} */ -Vector2.subtract = Vector2.sub; +vec4.sqrLen = vec4.squaredLength; + /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Matrix2} m - * @return {clay.Vector2} + * Negates the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {vec4} a vector to negate + * @returns {vec4} out */ -Vector2.transformMat2 = function(out, a, m) { - vec2.transformMat2(out.array, a.array, m.array); - out._dirty = true; +vec4.negate = function(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = -a[3]; return out; }; + /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Matrix2d} m - * @return {clay.Vector2} + * Returns the inverse of the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {vec4} a vector to invert + * @returns {vec4} out */ -Vector2.transformMat2d = function(out, a, m) { - vec2.transformMat2d(out.array, a.array, m.array); - out._dirty = true; - return out; +vec4.inverse = function(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; }; + /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {Matrix3} m - * @return {clay.Vector2} + * Normalize a vec4 + * + * @param {vec4} out the receiving vector + * @param {vec4} a vector to normalize + * @returns {vec4} out */ -Vector2.transformMat3 = function(out, a, m) { - vec2.transformMat3(out.array, a.array, m.array); - out._dirty = true; +vec4.normalize = function(out, a) { + var x = a[0], + y = a[1], + z = a[2], + w = a[3]; + var len = x*x + y*y + z*z + w*w; + if (len > 0) { + len = 1 / Math.sqrt(len); + out[0] = a[0] * len; + out[1] = a[1] * len; + out[2] = a[2] * len; + out[3] = a[3] * len; + } return out; }; + /** - * @param {clay.Vector2} out - * @param {clay.Vector2} a - * @param {clay.Matrix4} m - * @return {clay.Vector2} + * 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 */ -Vector2.transformMat4 = function(out, a, m) { - vec2.transformMat4(out.array, a.array, m.array); - out._dirty = true; - return out; +vec4.dot = function (a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; }; -/* harmony default export */ __webpack_exports__["a"] = (Vector2); - - -/***/ }), -/* 24 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_util__ = __webpack_require__(20); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_util__ = __webpack_require__(67); - - - - -var isPowerOfTwo = __WEBPACK_IMPORTED_MODULE_3__math_util__["a" /* default */].isPowerOfTwo; - -var targetList = ['px', 'nx', 'py', 'ny', 'pz', 'nz']; - /** - * @constructor clay.TextureCube - * @extends clay.Texture + * Performs a linear interpolation between two vec4's * - * @example - * ... - * var mat = new clay.Material({ - * shader: clay.shader.library.get('clay.phong', 'environmentMap') - * }); - * var envMap = new clay.TextureCube(); - * envMap.load({ - * 'px': 'assets/textures/sky/px.jpg', - * 'nx': 'assets/textures/sky/nx.jpg' - * 'py': 'assets/textures/sky/py.jpg' - * 'ny': 'assets/textures/sky/ny.jpg' - * 'pz': 'assets/textures/sky/pz.jpg' - * 'nz': 'assets/textures/sky/nz.jpg' - * }); - * mat.set('environmentMap', envMap); - * ... - * envMap.success(function () { - * // Wait for the sky texture loaded - * animation.on('frame', function (frameTime) { - * renderer.render(scene, camera); - * }); - * }); + * @param {vec4} out the receiving vector + * @param {vec4} a the first operand + * @param {vec4} b the second operand + * @param {Number} t interpolation amount between the two inputs + * @returns {vec4} out */ -var TextureCube = __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].extend(function () { - return /** @lends clay.TextureCube# */{ - - /** - * @type {boolean} - * @default false - */ - // PENDING cubemap should not flipY in default. - // flipY: false, - - /** - * @type {Object} - * @property {?HTMLImageElement|HTMLCanvasElemnet} px - * @property {?HTMLImageElement|HTMLCanvasElemnet} nx - * @property {?HTMLImageElement|HTMLCanvasElemnet} py - * @property {?HTMLImageElement|HTMLCanvasElemnet} ny - * @property {?HTMLImageElement|HTMLCanvasElemnet} pz - * @property {?HTMLImageElement|HTMLCanvasElemnet} nz - */ - image: { - px: null, - nx: null, - py: null, - ny: null, - pz: null, - nz: null - }, - /** - * Pixels data of each side. Will be ignored if images are set. - * @type {Object} - * @property {?Uint8Array} px - * @property {?Uint8Array} nx - * @property {?Uint8Array} py - * @property {?Uint8Array} ny - * @property {?Uint8Array} pz - * @property {?Uint8Array} nz - */ - pixels: { - px: null, - nx: null, - py: null, - ny: null, - pz: null, - nz: null - }, - - /** - * @type {Array.} - */ - mipmaps: [] - }; -}, { - - textureType: 'textureCube', - - update: function (renderer) { - var _gl = renderer.gl; - _gl.bindTexture(_gl.TEXTURE_CUBE_MAP, this._cache.get('webgl_texture')); - - this.updateCommon(renderer); - - var glFormat = this.format; - var glType = this.type; - - _gl.texParameteri(_gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_WRAP_S, this.getAvailableWrapS()); - _gl.texParameteri(_gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_WRAP_T, this.getAvailableWrapT()); - - _gl.texParameteri(_gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_MAG_FILTER, this.getAvailableMagFilter()); - _gl.texParameteri(_gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_MIN_FILTER, this.getAvailableMinFilter()); - - var anisotropicExt = renderer.getGLExtension('EXT_texture_filter_anisotropic'); - if (anisotropicExt && this.anisotropic > 1) { - _gl.texParameterf(_gl.TEXTURE_CUBE_MAP, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, this.anisotropic); - } - - // Fallback to float type if browser don't have half float extension - if (glType === 36193) { - var halfFloatExt = renderer.getGLExtension('OES_texture_half_float'); - if (!halfFloatExt) { - glType = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FLOAT; - } - } - - if (this.mipmaps.length) { - var width = this.width; - var height = this.height; - for (var i = 0; i < this.mipmaps.length; i++) { - var mipmap = this.mipmaps[i]; - this._updateTextureData(_gl, mipmap, i, width, height, glFormat, glType); - width /= 2; - height /= 2; - } - } - else { - this._updateTextureData(_gl, this, 0, this.width, this.height, glFormat, glType); - - if (!this.NPOT && this.useMipmap) { - _gl.generateMipmap(_gl.TEXTURE_CUBE_MAP); - } - } - - _gl.bindTexture(_gl.TEXTURE_CUBE_MAP, null); - }, - - _updateTextureData: function (_gl, data, level, width, height, glFormat, glType) { - for (var i = 0; i < 6; i++) { - var target = targetList[i]; - var img = data.image && data.image[target]; - if (img) { - _gl.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level, glFormat, glFormat, glType, img); - } - else { - _gl.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level, glFormat, width, height, 0, glFormat, glType, data.pixels && data.pixels[target]); - } - } - }, - - /** - * @param {clay.Renderer} renderer - * @memberOf clay.TextureCube.prototype - */ - generateMipmap: function (renderer) { - var _gl = renderer.gl; - if (this.useMipmap && !this.NPOT) { - _gl.bindTexture(_gl.TEXTURE_CUBE_MAP, this._cache.get('webgl_texture')); - _gl.generateMipmap(_gl.TEXTURE_CUBE_MAP); - } - }, +vec4.lerp = function (out, a, b, t) { + var ax = a[0], + ay = a[1], + az = a[2], + 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; +}; - bind: function (renderer) { - renderer.gl.bindTexture(renderer.gl.TEXTURE_CUBE_MAP, this.getWebGLTexture(renderer)); - }, +/** + * 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 + */ +vec4.random = function (out, scale) { + scale = scale || 1.0; - unbind: function (renderer) { - renderer.gl.bindTexture(renderer.gl.TEXTURE_CUBE_MAP, null); - }, + //TODO: This is a pretty awful way of doing this. Find something better. + out[0] = Object(__WEBPACK_IMPORTED_MODULE_0__common__["c" /* GLMAT_RANDOM */])(); + out[1] = Object(__WEBPACK_IMPORTED_MODULE_0__common__["c" /* GLMAT_RANDOM */])(); + out[2] = Object(__WEBPACK_IMPORTED_MODULE_0__common__["c" /* GLMAT_RANDOM */])(); + out[3] = Object(__WEBPACK_IMPORTED_MODULE_0__common__["c" /* GLMAT_RANDOM */])(); + vec4.normalize(out, out); + vec4.scale(out, out, scale); + return out; +}; - // Overwrite the isPowerOfTwo method - isPowerOfTwo: function () { - if (this.image.px) { - return isPowerOfTwo(this.image.px.width) - && isPowerOfTwo(this.image.px.height); - } - else { - return isPowerOfTwo(this.width) - && isPowerOfTwo(this.height); - } - }, +/** + * 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 + */ +vec4.transformMat4 = function(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; +}; - isRenderable: function () { - if (this.image.px) { - return isImageRenderable(this.image.px) - && isImageRenderable(this.image.nx) - && isImageRenderable(this.image.py) - && isImageRenderable(this.image.ny) - && isImageRenderable(this.image.pz) - && isImageRenderable(this.image.nz); - } - else { - return !!(this.width && this.height); - } - }, +/** + * 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 + */ +vec4.transformQuat = function(out, a, q) { + var x = a[0], y = a[1], z = a[2], + qx = q[0], qy = q[1], qz = q[2], qw = q[3], - load: function (imageList, crossOrigin) { - var loading = 0; - var self = this; - __WEBPACK_IMPORTED_MODULE_2__core_util__["a" /* default */].each(imageList, function (src, target){ - var image = new Image(); - if (crossOrigin) { - image.crossOrigin = crossOrigin; - } - image.onload = function () { - loading --; - if (loading === 0){ - self.dirty(); - self.trigger('success', self); - } - image.onload = null; - }; - image.onerror = function () { - loading --; - image.onerror = null; - }; + // calculate quat * vec + ix = qw * x + qy * z - qz * y, + iy = qw * y + qz * x - qx * z, + iz = qw * z + qx * y - qy * x, + iw = -qx * x - qy * y - qz * z; - loading++; - image.src = src; - self.image[target] = image; - }); + // 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; + return out; +}; - return this; - } -}); +/** + * 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 + */ +vec4.forEach = (function() { + var vec = vec4.create(); -Object.defineProperty(TextureCube.prototype, 'width', { - get: function () { - if (this.image && this.image.px) { - return this.image.px.width; - } - return this._width; - }, - set: function (value) { - if (this.image && this.image.px) { - console.warn('Texture from image can\'t set width'); - } - else { - if (this._width !== value) { - this.dirty(); - } - this._width = value; + return function(a, stride, offset, count, fn, arg) { + var i, l; + if(!stride) { + stride = 4; } - } -}); -Object.defineProperty(TextureCube.prototype, 'height', { - get: function () { - if (this.image && this.image.px) { - return this.image.px.height; + + if(!offset) { + offset = 0; } - return this._height; - }, - set: function (value) { - if (this.image && this.image.px) { - console.warn('Texture from image can\'t set height'); + + if(count) { + l = Math.min((count * stride) + offset, a.length); + } else { + l = a.length; } - else { - if (this._height !== value) { - this.dirty(); - } - this._height = value; + + 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]; } - } -}); -function isImageRenderable(image) { - return image.nodeName === 'CANVAS' || - image.nodeName === 'VIDEO' || - image.complete; -} -/* harmony default export */ __webpack_exports__["a"] = (TextureCube); + return a; + }; +})(); +/* harmony default export */ __webpack_exports__["a"] = (vec4); /***/ }), -/* 25 */ +/* 34 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony default export */ __webpack_exports__["a"] = ({ - defaultOption: { - // Post effect - postEffect: { - enable: false, - - bloom: { - enable: true, - intensity: 0.1 - }, - depthOfField: { - enable: false, - focalRange: 20, - focalDistance: 50, - blurRadius: 10, - fstop: 2.8, - quality: 'medium' - }, - - screenSpaceAmbientOcclusion: { - enable: false, - radius: 2, - // low, medium, high, ultra - quality: 'medium', - intensity: 1 - }, +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20); - screenSpaceReflection: { - enable: false, - quality: 'medium', - maxRoughness: 0.8 - }, +/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. - colorCorrection: { - enable: true, +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: - exposure: 0, + * 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. - brightness: 0, +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 HOLDER 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 USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - contrast: 1, - saturation: 1, - lookupTexture: '' - }, +/** + * @class 3x3 Matrix + * @name mat3 + */ - edge: { - enable: false - }, +var mat3 = {}; - FXAA: { - enable: false - } - }, +/** + * Creates a new identity mat3 + * + * @returns {mat3} a new 3x3 matrix + */ +mat3.create = function() { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](9); + 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; +}; - // Temporal super sampling when the picture is still. - temporalSuperSampling: { - // Only enabled when postEffect is enabled - enable: 'auto' - } - } -}); +/** + * 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 + */ +mat3.fromMat4 = function(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; +}; -/***/ }), -/* 26 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +/** + * Creates a new mat3 initialized with values from an existing matrix + * + * @param {mat3} a matrix to clone + * @returns {mat3} a new 3x3 matrix + */ +mat3.clone = function(a) { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_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; +}; -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = ({ - defaultOption: { - // Light is available when material.shading is not color - light: { - // Main light - main: { - shadow: false, - // low, medium, high, ultra - shadowQuality: 'high', +/** + * Copy the values from one mat3 to another + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the source matrix + * @returns {mat3} out + */ +mat3.copy = function(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; +}; - color: '#fff', - intensity: 1, +/** + * Set a mat3 to the identity matrix + * + * @param {mat3} out the receiving matrix + * @returns {mat3} out + */ +mat3.identity = function(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; +}; - alpha: 0, - beta: 0 - }, - ambient: { - color: '#fff', - intensity: 0.2 - }, - ambientCubemap: { - // Panorama environment texture, - // Support .hdr and commmon web formats. - texture: null, - // Available when texture is hdr. - exposure: 1, - // Intensity for diffuse term - diffuseIntensity: 0.5, - // Intensity for specular term, only available when shading is realastic - specularIntensity: 0.5 - } - } +/** + * Transpose the values of a mat3 + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the source matrix + * @returns {mat3} out + */ +mat3.transpose = function(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]; } -}); - -/***/ }), -/* 27 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_plugin_Skybox__ = __webpack_require__(57); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_plugin_Skydome__ = __webpack_require__(56); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_echarts__); + return out; +}; +/** + * Inverts a mat3 + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the source matrix + * @returns {mat3} out + */ +mat3.invert = function(out, a) { + 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], + b01 = a22 * a11 - a12 * a21, + b11 = -a22 * a10 + a12 * a20, + b21 = a21 * a10 - a11 * a20, + // Calculate the determinant + det = a00 * b01 + a01 * b11 + a02 * b21; + if (!det) { + return null; + } + det = 1.0 / det; -function SceneHelper() { -} + 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; +}; -SceneHelper.prototype = { - constructor: SceneHelper, +/** + * Calculates the adjugate of a mat3 + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the source matrix + * @returns {mat3} out + */ +mat3.adjoint = function(out, a) { + 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]; - setScene: function (scene) { - this._scene = scene; + 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; +}; - if (this._skybox) { - this._skybox.attachScene(this._scene); - } - }, +/** + * Calculates the determinant of a mat3 + * + * @param {mat3} a the source matrix + * @returns {Number} determinant of a + */ +mat3.determinant = function (a) { + 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]; - initLight: function (rootNode) { - this._lightRoot = rootNode; - /** - * @type {clay.light.Directional} - */ - this.mainLight = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].DirectionalLight({ - shadowBias: 0.005 - }); + return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); +}; - /** - * @type {clay.light.Ambient} - */ - this.ambientLight = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].AmbientLight(); +/** + * 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 + */ +mat3.multiply = function (out, a, b) { + 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], - rootNode.add(this.mainLight); - rootNode.add(this.ambientLight); - }, + b00 = b[0], b01 = b[1], b02 = b[2], + b10 = b[3], b11 = b[4], b12 = b[5], + b20 = b[6], b21 = b[7], b22 = b[8]; - dispose: function () { - if (this._lightRoot) { - this._lightRoot.remove(this.mainLight); - this._lightRoot.remove(this.ambientLight); - } - }, + out[0] = b00 * a00 + b01 * a10 + b02 * a20; + out[1] = b00 * a01 + b01 * a11 + b02 * a21; + out[2] = b00 * a02 + b01 * a12 + b02 * a22; - updateLight: function (componentModel) { + out[3] = b10 * a00 + b11 * a10 + b12 * a20; + out[4] = b10 * a01 + b11 * a11 + b12 * a21; + out[5] = b10 * a02 + b11 * a12 + b12 * a22; - var mainLight = this.mainLight; - var ambientLight = this.ambientLight; + 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; +}; - var lightModel = componentModel.getModel('light'); - var mainLightModel = lightModel.getModel('main'); - var ambientLightModel = lightModel.getModel('ambient'); +/** + * Alias for {@link mat3.multiply} + * @function + */ +mat3.mul = mat3.multiply; - mainLight.intensity = mainLightModel.get('intensity'); - ambientLight.intensity = ambientLightModel.get('intensity'); - mainLight.color = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].parseColor(mainLightModel.get('color')).slice(0, 3); - ambientLight.color = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].parseColor(ambientLightModel.get('color')).slice(0, 3); +/** + * 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 + */ +mat3.translate = function(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]; - var alpha = mainLightModel.get('alpha') || 0; - var beta = mainLightModel.get('beta') || 0; - mainLight.position.setArray(__WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].directionFromAlphaBeta(alpha, beta)); - mainLight.lookAt(__WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Vector3.ZERO); + out[0] = a00; + out[1] = a01; + out[2] = a02; - mainLight.castShadow = mainLightModel.get('shadow'); - mainLight.shadowResolution = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].getShadowResolution(mainLightModel.get('shadowQuality')); - }, + out[3] = a10; + out[4] = a11; + out[5] = a12; - updateAmbientCubemap: function (renderer, componentModel, api) { - var ambientCubemapModel = componentModel.getModel('light.ambientCubemap'); + out[6] = x * a00 + y * a10 + a20; + out[7] = x * a01 + y * a11 + a21; + out[8] = x * a02 + y * a12 + a22; + return out; +}; - var textureUrl = ambientCubemapModel.get('texture'); - if (textureUrl) { - this._cubemapLightsCache = this._cubemapLightsCache || {}; - var lights = this._cubemapLightsCache[textureUrl]; - if (!lights) { - var self = this; - lights = this._cubemapLightsCache[textureUrl] - = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].createAmbientCubemap(ambientCubemapModel.option, renderer, api, function () { - // Use prefitered cubemap - if (self._skybox instanceof __WEBPACK_IMPORTED_MODULE_1_claygl_src_plugin_Skybox__["a" /* default */]) { - self._skybox.setEnvironmentMap(lights.specular.cubemap); - } +/** + * 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 + */ +mat3.rotate = function (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], - api.getZr().refresh(); - }); - } - this._lightRoot.add(lights.diffuse); - this._lightRoot.add(lights.specular); + s = Math.sin(rad), + c = Math.cos(rad); - this._currentCubemapLights = lights; - } - else if (this._currentCubemapLights) { - this._lightRoot.remove(this._currentCubemapLights.diffuse); - this._lightRoot.remove(this._currentCubemapLights.specular); - this._currentCubemapLights = null; - } - }, + out[0] = c * a00 + s * a10; + out[1] = c * a01 + s * a11; + out[2] = c * a02 + s * a12; - updateSkybox: function (renderer, componentModel, api) { - var environmentUrl = componentModel.get('environment'); + out[3] = c * a10 - s * a00; + out[4] = c * a11 - s * a01; + out[5] = c * a12 - s * a02; - var self = this; - function getSkybox() { - if (!(self._skybox instanceof __WEBPACK_IMPORTED_MODULE_1_claygl_src_plugin_Skybox__["a" /* default */])) { - if (self._skybox) { - self._skybox.dispose(renderer); - } - self._skybox = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_plugin_Skybox__["a" /* default */](); - } - return self._skybox; - } - function getSkydome() { - if (!(self._skybox instanceof __WEBPACK_IMPORTED_MODULE_2_claygl_src_plugin_Skydome__["a" /* default */])) { - if (self._skybox) { - self._skybox.dispose(renderer); - } - self._skybox = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_plugin_Skydome__["a" /* default */](); - } - return self._skybox; - } + out[6] = a20; + out[7] = a21; + out[8] = a22; + return out; +}; - if (environmentUrl && environmentUrl !== 'none') { - if (environmentUrl === 'auto') { - // Use environment in ambient cubemap - if (this._currentCubemapLights) { - var skybox = getSkybox(); - var cubemap = this._currentCubemapLights.specular.cubemap; - skybox.setEnvironmentMap(cubemap); - if (this._scene) { - skybox.attachScene(this._scene); - } - skybox.material.set('lod', 2); - } - else if (this._skybox) { - this._skybox.detachScene(); - } - } - // Is gradient or color string - else if ((typeof environmentUrl === 'object' && environmentUrl.colorStops) - || (typeof environmentUrl === 'string' && __WEBPACK_IMPORTED_MODULE_3_echarts_lib_echarts___default.a.color.parse(environmentUrl)) - ) { - var skydome = getSkydome(); - var texture = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Texture2D({ - anisotropic: 8, - flipY: false - }); - skydome.setEnvironmentMap(texture); - var canvas = texture.image = document.createElement('canvas'); - canvas.width = canvas.height = 16; - var ctx = canvas.getContext('2d'); - var rect = new __WEBPACK_IMPORTED_MODULE_3_echarts_lib_echarts___default.a.graphic.Rect({ - shape: { x: 0, y: 0, width: 16, height: 16 }, - style: { fill: environmentUrl } - }); - rect.brush(ctx); +/** + * 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 + **/ +mat3.scale = function(out, a, v) { + var x = v[0], y = v[1]; - skydome.attachScene(this._scene); - } - else { - // Panorama - var skydome = getSkydome(); - var texture = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].loadTexture(environmentUrl, api, { - anisotropic: 8, - flipY: false - }); - skydome.setEnvironmentMap(texture); + out[0] = x * a[0]; + out[1] = x * a[1]; + out[2] = x * a[2]; - skydome.attachScene(this._scene); - } - } - else { - if (this._skybox) { - this._skybox.detachScene(this._scene); - } - this._skybox = null; - } + out[3] = y * a[3]; + out[4] = y * a[4]; + out[5] = y * a[5]; - var coordSys = componentModel.coordinateSystem; - if (this._skybox) { - if (coordSys && coordSys.viewGL - && environmentUrl !== 'auto' - && !(environmentUrl.match && environmentUrl.match(/.hdr$/)) - ) { - var srgbDefineMethod = coordSys.viewGL.isLinearSpace() ? 'define' : 'undefine'; - this._skybox.material[srgbDefineMethod]('fragment', 'SRGB_DECODE'); - } - else { - this._skybox.material.undefine('fragment', 'SRGB_DECODE'); - } - // var ambientCubemapUrl = environmentUrl === 'auto' - // ? componentModel.get('light.ambientCubemap.texture') - // : environmentUrl; - } - } + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + return out; }; -/* harmony default export */ __webpack_exports__["a"] = (SceneHelper); +/** + * 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 + **/ +mat3.fromMat2d = function(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = 0; -/***/ }), -/* 28 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + out[3] = a[2]; + out[4] = a[3]; + out[5] = 0; -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = ({ - defaultOption: { - shading: null, + out[6] = a[4]; + out[7] = a[5]; + out[8] = 1; + return out; +}; - realisticMaterial: { - textureTiling: 1, - textureOffset: 0, +/** +* 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 +*/ +mat3.fromQuat = function (out, q) { + var x = q[0], y = q[1], z = q[2], w = q[3], + x2 = x + x, + y2 = y + y, + z2 = z + z, - detailTexture: null - }, + xx = x * x2, + yx = y * x2, + yy = y * y2, + zx = z * x2, + zy = z * y2, + zz = z * z2, + wx = w * x2, + wy = w * y2, + wz = w * z2; - lambertMaterial: { - textureTiling: 1, - textureOffset: 0, + out[0] = 1 - yy - zz; + out[3] = yx - wz; + out[6] = zx + wy; - detailTexture: null - }, + out[1] = yx + wz; + out[4] = 1 - xx - zz; + out[7] = zy - wx; - colorMaterial: { - textureTiling: 1, - textureOffset: 0, + out[2] = zx - wy; + out[5] = zy + wx; + out[8] = 1 - xx - yy; - detailTexture: null - }, + return out; +}; - hatchingMaterial: { - textureTiling: 1, - textureOffset: 0, +/** +* 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 +*/ +mat3.normalFromMat4 = function (out, a) { + var 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], + a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], - paperColor: '#fff' - } - } -}); + b00 = a00 * a11 - a01 * a10, + b01 = a00 * a12 - a02 * a10, + b02 = a00 * a13 - a03 * a10, + b03 = a01 * a12 - a02 * a11, + b04 = a01 * a13 - a03 * a11, + b05 = a02 * a13 - a03 * a12, + b06 = a20 * a31 - a21 * a30, + b07 = a20 * a32 - a22 * a30, + b08 = a20 * a33 - a23 * a30, + b09 = a21 * a32 - a22 * a31, + b10 = a21 * a33 - a23 * a31, + b11 = a22 * a33 - a23 * a32, -/***/ }), -/* 29 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + // Calculate the determinant + det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); + 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; -var formatUtil = {}; -formatUtil.getFormattedLabel = function (seriesModel, dataIndex, status, dataType, dimIndex) { - status = status || 'normal'; - var data = seriesModel.getData(dataType); - var itemModel = data.getItemModel(dataIndex); + 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; - var params = seriesModel.getDataParams(dataIndex, dataType); - if (dimIndex != null && (params.value instanceof Array)) { - params.value = params.value[dimIndex]; - } + 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; - var formatter = itemModel.get(status === 'normal' ? ['label', 'formatter'] : ['emphasis', 'label', 'formatter']); - if (formatter == null) { - formatter = itemModel.get(['label', 'formatter']); - } - var text; - if (typeof formatter === 'function') { - params.status = status; - text = formatter(params); - } - else if (typeof formatter === 'string') { - text = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.format.formatTpl(formatter, params); - } - return text; + return out; }; /** - * If value is not array, then convert it to array. - * @param {*} value - * @return {Array} [value] or value + * Returns Frobenius norm of a mat3 + * + * @param {mat3} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm */ -formatUtil.normalizeToArray = function (value) { - return value instanceof Array - ? value - : value == null - ? [] - : [value]; +mat3.frob = function (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))) }; -/* harmony default export */ __webpack_exports__["a"] = (formatUtil); + +/* harmony default export */ __webpack_exports__["a"] = (mat3); /***/ }), -/* 30 */ +/* 35 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Quaternion__ = __webpack_require__(50); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4__dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__math_BoundingBox__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Quaternion__ = __webpack_require__(56); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_Matrix4__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__math_BoundingBox__ = __webpack_require__(18); -var mat4 = __WEBPACK_IMPORTED_MODULE_4__dep_glmatrix___default.a.mat4; var nameId = 0; @@ -15282,7 +13051,7 @@ var Node = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(/* * @param {clay.Matrix4} matrix */ setLocalTransform: function (matrix) { - mat4.copy(this.localTransform.array, matrix.array); + __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].copy(this.localTransform.array, matrix.array); this.decomposeLocalTransform(); }, @@ -15299,7 +13068,7 @@ var Node = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(/* * @param {clay.Matrix4} matrix */ setWorldTransform: function (matrix) { - mat4.copy(this.worldTransform.array, matrix.array); + __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].copy(this.worldTransform.array, matrix.array); this.decomposeWorldTransform(); }, @@ -15309,17 +13078,17 @@ var Node = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(/* */ decomposeWorldTransform: (function () { - var tmp = mat4.create(); + var tmp = __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].create(); return function (keepScale) { var localTransform = this.localTransform; var worldTransform = this.worldTransform; // Assume world transform is updated if (this._parent) { - mat4.invert(tmp, this._parent.worldTransform.array); - mat4.multiply(localTransform.array, tmp, worldTransform.array); + __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].invert(tmp, this._parent.worldTransform.array); + __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].multiply(localTransform.array, tmp, worldTransform.array); } else { - mat4.copy(localTransform.array, worldTransform.array); + __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].copy(localTransform.array, worldTransform.array); } var scale = !keepScale ? this.scale: null; localTransform.decomposeMatrix(scale, this.rotation, this.position); @@ -15345,9 +13114,9 @@ var Node = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(/* var m = this.localTransform.array; // Transform order, scale->rotation->position - mat4.fromRotationTranslation(m, rotation.array, position.array); + __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].fromRotationTranslation(m, rotation.array, position.array); - mat4.scale(m, m, scale.array); + __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].scale(m, m, scale.array); rotation._dirty = false; scale._dirty = false; @@ -15365,14 +13134,14 @@ var Node = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(/* var localTransform = this.localTransform.array; var worldTransform = this.worldTransform.array; if (this._parent) { - mat4.multiplyAffine( + __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].multiplyAffine( worldTransform, this._parent.worldTransform.array, localTransform ); } else { - mat4.copy(worldTransform, localTransform); + __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].copy(worldTransform, localTransform); } }, @@ -15550,103 +13319,18 @@ var Node = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(/* /***/ }), -/* 31 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Renderable__ = __webpack_require__(66); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Texture2D__ = __webpack_require__(5); - - - - -/** - * @constructor clay.Mesh - * @extends clay.Renderable - */ -var Mesh = __WEBPACK_IMPORTED_MODULE_0__Renderable__["a" /* default */].extend(/** @lends clay.Mesh# */ { - /** - * Used when it is a skinned mesh - * @type {clay.Skeleton} - */ - skeleton: null, - /** - * Joints indices Meshes can share the one skeleton instance and each mesh can use one part of joints. Joints indices indicate the index of joint in the skeleton instance - * @type {number[]} - */ - joints: null, - - /** - * If store the skin matrices in vertex texture - * @type {bool} - */ - useSkinMatricesTexture: false - -}, function () { - if (!this.joints) { - this.joints = []; - } -}, { - - isSkinnedMesh: function () { - return !!(this.skeleton && this.joints && this.joints.length > 0); - }, - - getSkinMatricesTexture: function () { - this._skinMatricesTexture = this._skinMatricesTexture || new __WEBPACK_IMPORTED_MODULE_2__Texture2D__["a" /* default */]({ - type: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FLOAT, - minFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST, - magFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST, - useMipmap: false, - flipY: false - }); - - return this._skinMatricesTexture; - }, - - clone: function () { - var mesh = __WEBPACK_IMPORTED_MODULE_0__Renderable__["a" /* default */].prototype.clone.call(this); - mesh.skeleton = this.skeleton; - if (this.joints) { - mesh.joints = this.joints.slice(); - } - return mesh; - } -}); - -// Enums -Mesh.POINTS = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].POINTS; -Mesh.LINES = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINES; -Mesh.LINE_LOOP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINE_LOOP; -Mesh.LINE_STRIP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINE_STRIP; -Mesh.TRIANGLES = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLES; -Mesh.TRIANGLE_STRIP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLE_STRIP; -Mesh.TRIANGLE_FAN = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLE_FAN; - -Mesh.BACK = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].BACK; -Mesh.FRONT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FRONT; -Mesh.FRONT_AND_BACK = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FRONT_AND_BACK; -Mesh.CW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CW; -Mesh.CCW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CCW; - -/* harmony default export */ __webpack_exports__["a"] = (Mesh); - - -/***/ }), -/* 32 */ +/* 36 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(30); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Light__ = __webpack_require__(21); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Camera__ = __webpack_require__(51); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_util__ = __webpack_require__(20); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5__dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__core_LRU__ = __webpack_require__(64); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__math_Matrix4__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(35); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Light__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Camera__ = __webpack_require__(58); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_util__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__glmatrix_mat4__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__core_LRU__ = __webpack_require__(69); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__math_Matrix4__ = __webpack_require__(9); @@ -15655,10 +13339,9 @@ Mesh.CCW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CCW; -var mat4 = __WEBPACK_IMPORTED_MODULE_5__dep_glmatrix___default.a.mat4; -var IDENTITY = mat4.create(); -var WORLDVIEW = mat4.create(); +var IDENTITY = __WEBPACK_IMPORTED_MODULE_5__glmatrix_mat4__["a" /* default */].create(); +var WORLDVIEW = __WEBPACK_IMPORTED_MODULE_5__glmatrix_mat4__["a" /* default */].create(); var programKeyCache = {}; @@ -15907,9 +13590,10 @@ var Scene = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(functi * It needs camera for the frustum culling. * * @param {clay.Camera} camera + * @param {boolean} updateSceneBoundingBox * @return {clay.Scene.RenderList} */ - updateRenderList: function (camera) { + updateRenderList: function (camera, updateSceneBoundingBox) { var id = camera.__uid__; var renderList = this._renderLists.get(id); if (!renderList) { @@ -15918,11 +13602,13 @@ var Scene = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(functi } renderList.startCount(); - this.viewBoundingBoxLastFrame.min.set(Infinity, Infinity, Infinity); - this.viewBoundingBoxLastFrame.max.set(-Infinity, -Infinity, -Infinity); + if (updateSceneBoundingBox) { + this.viewBoundingBoxLastFrame.min.set(Infinity, Infinity, Infinity); + this.viewBoundingBoxLastFrame.max.set(-Infinity, -Infinity, -Infinity); + } var sceneMaterialTransparent = this.material && this.material.transparent || false; - this._doUpdateRenderList(this, camera, sceneMaterialTransparent, renderList); + this._doUpdateRenderList(this, camera, sceneMaterialTransparent, renderList, updateSceneBoundingBox); renderList.endCount(); @@ -15938,7 +13624,7 @@ var Scene = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(functi return this._renderLists.get(camera.__uid__); }, - _doUpdateRenderList: function (parent, camera, sceneMaterialTransparent, renderList) { + _doUpdateRenderList: function (parent, camera, sceneMaterialTransparent, renderList, updateSceneBoundingBox) { if (parent.invisible) { return; } @@ -15951,13 +13637,13 @@ var Scene = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(functi var worldM = child.isSkinnedMesh() ? IDENTITY : child.worldTransform.array; var geometry = child.geometry; - mat4.multiplyAffine(WORLDVIEW, camera.viewMatrix.array, worldM); - if (!geometry.boundingBox || !this.isFrustumCulled(child, camera, WORLDVIEW)) { + __WEBPACK_IMPORTED_MODULE_5__glmatrix_mat4__["a" /* default */].multiplyAffine(WORLDVIEW, camera.viewMatrix.array, worldM); + if (updateSceneBoundingBox && !geometry.boundingBox || !this.isFrustumCulled(child, camera, WORLDVIEW)) { renderList.add(child, child.material.transparent || sceneMaterialTransparent); } } if (child._children.length > 0) { - this._doUpdateRenderList(child, camera, sceneMaterialTransparent, renderList); + this._doUpdateRenderList(child, camera, sceneMaterialTransparent, renderList, updateSceneBoundingBox); } } }, @@ -15980,7 +13666,20 @@ var Scene = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(functi return function(object, camera, worldViewMat) { // Bounding box can be a property of object(like light) or renderable.geometry // PENDING - var geoBBox = object.boundingBox || object.geometry.boundingBox; + var geoBBox = object.boundingBox; + if (!geoBBox) { + if (object.skeleton && object.skeleton.boundingBox) { + geoBBox = object.skeleton.boundingBox; + } + else { + geoBBox = object.geometry.boundingBox; + } + } + + if (!geoBBox) { + return false; + } + cullingMatrix.array = worldViewMat; cullingBoundingBox.transformFrom(geoBBox, cullingMatrix); @@ -15993,7 +13692,7 @@ var Scene = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(functi this.viewBoundingBoxLastFrame.union(cullingBoundingBox); } // Ignore frustum culling if object is skinned mesh. - if (object.frustumCulling && !object.isSkinnedMesh()) { + if (object.frustumCulling) { if (!cullingBoundingBox.intersectBoundingBox(camera.frustum.boundingBox)) { return true; } @@ -16192,11 +13891,11 @@ function lightSortFunc(a, b) { /***/ }), -/* 33 */ +/* 37 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Camera__ = __webpack_require__(51); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Camera__ = __webpack_require__(58); /** * @constructor clay.camera.Orthographic @@ -16266,7 +13965,7 @@ var Orthographic = __WEBPACK_IMPORTED_MODULE_0__Camera__["a" /* default */].exte /***/ }), -/* 34 */ +/* 38 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -16311,7 +14010,7 @@ var Orthographic = __WEBPACK_IMPORTED_MODULE_0__Camera__["a" /* default */].exte }); /***/ }), -/* 35 */ +/* 39 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -16400,20 +14099,88 @@ function otherDimToDataDim (data, otherDim) { });; /***/ }), -/* 36 */ +/* 40 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Renderable__ = __webpack_require__(72); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); + + + +/** + * @constructor clay.Mesh + * @extends clay.Renderable + */ +var Mesh = __WEBPACK_IMPORTED_MODULE_0__Renderable__["a" /* default */].extend(/** @lends clay.Mesh# */ { + /** + * Used when it is a skinned mesh + * @type {clay.Skeleton} + */ + skeleton: null, + /** + * Joints indices Meshes can share the one skeleton instance and each mesh can use one part of joints. Joints indices indicate the index of joint in the skeleton instance + * @type {number[]} + */ + joints: null, + + /** + * If store the skin matrices in vertex texture + * @type {bool} + */ + useSkinMatricesTexture: false + +}, function () { + if (!this.joints) { + this.joints = []; + } +}, { + + isSkinnedMesh: function () { + return !!(this.skeleton && this.joints && this.joints.length > 0); + }, + + clone: function () { + var mesh = __WEBPACK_IMPORTED_MODULE_0__Renderable__["a" /* default */].prototype.clone.call(this); + mesh.skeleton = this.skeleton; + if (this.joints) { + mesh.joints = this.joints.slice(); + } + return mesh; + } +}); + +// Enums +Mesh.POINTS = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].POINTS; +Mesh.LINES = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINES; +Mesh.LINE_LOOP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINE_LOOP; +Mesh.LINE_STRIP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINE_STRIP; +Mesh.TRIANGLES = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLES; +Mesh.TRIANGLE_STRIP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLE_STRIP; +Mesh.TRIANGLE_FAN = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLE_FAN; + +Mesh.BACK = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].BACK; +Mesh.FRONT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FRONT; +Mesh.FRONT_AND_BACK = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FRONT_AND_BACK; +Mesh.CW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CW; +Mesh.CCW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CCW; + +/* harmony default export */ __webpack_exports__["a"] = (Mesh); + + +/***/ }), +/* 41 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Camera__ = __webpack_require__(51); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Camera__ = __webpack_require__(58); /** * @constructor clay.camera.Perspective * @extends clay.Camera */ -var Perspective = __WEBPACK_IMPORTED_MODULE_0__Camera__["a" /* default */].extend( -/** @lends clay.camera.Perspective# */ -{ +var Perspective = __WEBPACK_IMPORTED_MODULE_0__Camera__["a" /* default */].extend(/** @lends clay.camera.Perspective# */{ /** * Vertical field of view in degrees * @type {number} @@ -16468,12 +14235,162 @@ var Perspective = __WEBPACK_IMPORTED_MODULE_0__Camera__["a" /* default */].exten /***/ }), -/* 37 */ +/* 42 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Geometry__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_BoundingBox__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Mesh__ = __webpack_require__(40); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geometry_Cube__ = __webpack_require__(76); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Shader__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Material__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Texture__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__shader_source_skybox_glsl_js__ = __webpack_require__(121); +// TODO Should not derived from mesh? + + + + + + + +__WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_5__shader_source_skybox_glsl_js__["a" /* default */]); +/** + * @constructor clay.plugin.Skybox + * + * @example + * var skyTex = new clay.TextureCube(); + * skyTex.load({ + * 'px': 'assets/textures/sky/px.jpg', + * 'nx': 'assets/textures/sky/nx.jpg' + * 'py': 'assets/textures/sky/py.jpg' + * 'ny': 'assets/textures/sky/ny.jpg' + * 'pz': 'assets/textures/sky/pz.jpg' + * 'nz': 'assets/textures/sky/nz.jpg' + * }); + * var skybox = new clay.plugin.Skybox({ + * scene: scene + * }); + * skybox.material.set('environmentMap', skyTex); + */ +var Skybox = __WEBPACK_IMPORTED_MODULE_0__Mesh__["a" /* default */].extend(function () { + + var skyboxShader = new __WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */]({ + vertex: __WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */].source('clay.skybox.vertex'), + fragment: __WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */].source('clay.skybox.fragment') + }); + var material = new __WEBPACK_IMPORTED_MODULE_3__Material__["a" /* default */]({ + shader: skyboxShader, + depthMask: false + }); + + return { + /** + * @type {clay.Scene} + * @memberOf clay.plugin.Skybox.prototype + */ + scene: null, + + geometry: new __WEBPACK_IMPORTED_MODULE_1__geometry_Cube__["a" /* default */](), + + material: material, + + environmentMap: null, + + culling: false + }; +}, function () { + var scene = this.scene; + if (scene) { + this.attachScene(scene); + } + if (this.environmentMap) { + this.setEnvironmentMap(this.environmentMap); + } +}, /** @lends clay.plugin.Skybox# */ { + /** + * Attach the skybox to the scene + * @param {clay.Scene} scene + */ + attachScene: function (scene) { + if (this.scene) { + this.detachScene(); + } + scene.skybox = this; + + this.scene = scene; + scene.on('beforerender', this._beforeRenderScene, this); + }, + /** + * Detach from scene + */ + detachScene: function () { + if (this.scene) { + this.scene.off('beforerender', this._beforeRenderScene); + this.scene.skybox = null; + } + this.scene = null; + }, + + /** + * Dispose skybox + * @param {clay.Renderer} renderer + */ + dispose: function (renderer) { + this.detachScene(); + this.geometry.dispose(renderer); + }, + /** + * Set environment map + * @param {clay.TextureCube} envMap + */ + setEnvironmentMap: function (envMap) { + if (envMap.textureType === 'texture2D') { + this.material.define('EQUIRECTANGULAR'); + // LINEAR filter can remove the artifacts in pole + envMap.minFilter = __WEBPACK_IMPORTED_MODULE_4__Texture__["a" /* default */].LINEAR; + } + else { + this.material.undefine('EQUIRECTANGULAR'); + } + this.material.set('environmentMap', envMap); + }, + /** + * Get environment map + * @return {clay.TextureCube} + */ + getEnvironmentMap: function () { + return this.material.get('environmentMap'); + }, + + _beforeRenderScene: function(renderer, scene, camera) { + this.renderSkybox(renderer, camera); + }, + + renderSkybox: function (renderer, camera) { + this.position.copy(camera.getWorldPosition()); + this.update(); + // Don't remember to disable blend + renderer.gl.disable(renderer.gl.BLEND); + if (this.material.get('lod') > 0) { + this.material.define('fragment', 'LOD'); + } + else { + this.material.undefine('fragment', 'LOD'); + } + renderer.renderPass([this], camera); + } +}); + +/* harmony default export */ __webpack_exports__["a"] = (Skybox); + + +/***/ }), +/* 43 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Geometry__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_BoundingBox__ = __webpack_require__(18); @@ -16549,7 +14466,7 @@ var Plane = __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].extend( /***/ }), -/* 38 */ +/* 44 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -16633,15 +14550,15 @@ var Plane = __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].extend( }); /***/ }), -/* 39 */ +/* 45 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_core_Base__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector2__ = __webpack_require__(23); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_math_Quaternion__ = __webpack_require__(50); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__retrieve__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_core_Base__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector2__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_math_Quaternion__ = __webpack_require__(56); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__retrieve__ = __webpack_require__(2); /** * Provide orbit control for 3D objects * @@ -17479,7 +15396,7 @@ Object.defineProperty(OrbitControl.prototype, 'autoRotate', { /* harmony default export */ __webpack_exports__["a"] = (OrbitControl); /***/ }), -/* 40 */ +/* 46 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -17487,19 +15404,37 @@ Object.defineProperty(OrbitControl.prototype, 'autoRotate', { /***/ }), -/* 41 */ +/* 47 */ /***/ (function(module, exports, __webpack_require__) { -var zrUtil = __webpack_require__(12); +var zrUtil = __webpack_require__(13); -var BoundingRect = __webpack_require__(75); +var BoundingRect = __webpack_require__(82); -var _number = __webpack_require__(78); +var _number = __webpack_require__(85); var parsePercent = _number.parsePercent; -var formatUtil = __webpack_require__(162); +var formatUtil = __webpack_require__(171); +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ // Layout helpers for each component positioning var each = zrUtil.each; /** @@ -17977,11 +15912,11 @@ exports.getLayoutParams = getLayoutParams; exports.copyLayoutParams = copyLayoutParams; /***/ }), -/* 42 */ +/* 48 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7); // PENDING @@ -18231,7 +16166,7 @@ var CompositorNode = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */] /***/ }), -/* 43 */ +/* 49 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -18255,7 +16190,7 @@ function halton(index, base) { /* harmony default export */ __webpack_exports__["a"] = (halton); /***/ }), -/* 44 */ +/* 50 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -18307,22 +16242,43 @@ function halton(index, base) { }); /***/ }), -/* 45 */ +/* 51 */ /***/ (function(module, exports) { +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ function _default(seriesType, defaultSymbolType, legendSymbol) { // Encoding visual for all series include which is filtered for legend drawing return { seriesType: seriesType, + // For legend. performRawSeries: true, reset: function (seriesModel, ecModel, api) { var data = seriesModel.getData(); var symbolType = seriesModel.get('symbol') || defaultSymbolType; var symbolSize = seriesModel.get('symbolSize'); + var keepAspect = seriesModel.get('symbolKeepAspect'); data.setVisual({ legendSymbol: legendSymbol || symbolType, symbol: symbolType, - symbolSize: symbolSize + symbolSize: symbolSize, + symbolKeepAspect: keepAspect }); // Only visible series has each data be visual encoded if (ecModel.isSeriesFiltered(seriesModel)) { @@ -18342,7 +16298,8 @@ function _default(seriesType, defaultSymbolType, legendSymbol) { if (data.hasItemOption) { var itemModel = data.getItemModel(idx); var itemSymbolType = itemModel.getShallow('symbol', true); - var itemSymbolSize = itemModel.getShallow('symbolSize', true); // If has item symbol + var itemSymbolSize = itemModel.getShallow('symbolSize', true); + var itemSymbolKeepAspect = itemModel.getShallow('symbolKeepAspect', true); // If has item symbol if (itemSymbolType != null) { data.setItemVisual(idx, 'symbol', itemSymbolType); @@ -18352,6 +16309,10 @@ function _default(seriesType, defaultSymbolType, legendSymbol) { // PENDING Transform symbolSize ? data.setItemVisual(idx, 'symbolSize', itemSymbolSize); } + + if (itemSymbolKeepAspect != null) { + data.setItemVisual(idx, 'symbolKeepAspect', itemSymbolKeepAspect); + } } } @@ -18365,24 +16326,21 @@ function _default(seriesType, defaultSymbolType, legendSymbol) { module.exports = _default; /***/ }), -/* 46 */ +/* 52 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_GLInfo__ = __webpack_require__(104); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_GLInfo__ = __webpack_require__(111); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_glenum__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_vendor__ = __webpack_require__(18); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__math_BoundingBox__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Material__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__math_Vector2__ = __webpack_require__(23); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__gpu_ProgramManager__ = __webpack_require__(107); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Shader__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__shader_source_header_light__ = __webpack_require__(109); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__shader_source_prez_glsl_js__ = __webpack_require__(65); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_12__dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_vendor__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Material__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__math_Vector2__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__gpu_ProgramManager__ = __webpack_require__(115); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Shader__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__shader_source_prez_glsl_js__ = __webpack_require__(71); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__glmatrix_vec3__ = __webpack_require__(12); // TODO Resources like shader, texture, geometry reference management // Trace and find out which shader, texture, geometry can be destroyed @@ -18394,26 +16352,31 @@ module.exports = _default; - // Light header +__WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_8__shader_source_prez_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_9__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_10__shader_source_header_light__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_9__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_11__shader_source_prez_glsl_js__["a" /* default */]); -var mat4 = __WEBPACK_IMPORTED_MODULE_12__dep_glmatrix___default.a.mat4; -var vec3 = __WEBPACK_IMPORTED_MODULE_12__dep_glmatrix___default.a.vec3; -var mat4Create = mat4.create; +var mat4Create = __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].create; var errorShader = {}; function defaultGetMaterial(renderable) { return renderable.material; } +function defaultGetUniform(renderable, material, symbol) { + return material.uniforms[symbol].value; +} +function defaultIsMaterialChanged(renderabled, prevRenderable, material, prevMaterial) { + return material !== prevMaterial; +} +function defaultIfRender(renderable) { + return true; +} function noop() {} @@ -18432,8 +16395,38 @@ function VertexArrayObject(availableAttributes, availableAttributeSymbols, indic this.vao = null; } + +function PlaceHolderTexture(renderer) { + var blankCanvas; + var webglTexture; + this.bind = function (renderer) { + if (!blankCanvas) { + // TODO Environment not support createCanvas. + blankCanvas = __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].createCanvas(); + blankCanvas.width = blankCanvas.height = 1; + blankCanvas.getContext('2d'); + } + + var gl = renderer.gl; + var firstBind = !webglTexture; + if (firstBind) { + webglTexture = gl.createTexture(); + } + gl.bindTexture(gl.TEXTURE_2D, webglTexture); + if (firstBind) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, blankCanvas); + } + }; + this.unbind = function (renderer) { + renderer.gl.bindTexture(renderer.gl.TEXTURE_2D, null); + }; + this.isRenderable = function () { + return true; + }; +} /** * @constructor clay.Renderer + * @extends clay.core.Base */ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () { return /** @lends clay.Renderer# */ { @@ -18465,7 +16458,7 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten * @type {number} * @private */ - devicePixelRatio: (window && window.devicePixelRatio) || 1.0, + devicePixelRatio: (typeof window !== 'undefined' && window.devicePixelRatio) || 1.0, /** * Clear color @@ -18540,7 +16533,7 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten }, function () { if (!this.canvas) { - this.canvas = document.createElement('canvas'); + this.canvas = __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].createCanvas(); } var canvas = this.canvas; try { @@ -18574,7 +16567,9 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten } // Init managers - this._programMgr = new __WEBPACK_IMPORTED_MODULE_8__gpu_ProgramManager__["a" /* default */](this); + this._programMgr = new __WEBPACK_IMPORTED_MODULE_6__gpu_ProgramManager__["a" /* default */](this); + + this._placeholderTexture = new PlaceHolderTexture(this); }, /** @lends clay.Renderer.prototype. **/ { @@ -18804,7 +16799,7 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten return; } camera.update(); - var renderList = scene.updateRenderList(camera); + var renderList = scene.updateRenderList(camera, true); this._sceneRendering = scene; @@ -18825,11 +16820,11 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten // Update the depth of transparent list. var worldViewMat = mat4Create(); - var posViewSpace = vec3.create(); + var posViewSpace = __WEBPACK_IMPORTED_MODULE_10__glmatrix_vec3__["a" /* default */].create(); for (var i = 0; i < transparentList.length; i++) { var renderable = transparentList[i]; - mat4.multiplyAffine(worldViewMat, camera.viewMatrix.array, renderable.worldTransform.array); - vec3.transformMat4(posViewSpace, renderable.position.array, worldViewMat); + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].multiplyAffine(worldViewMat, camera.viewMatrix.array, renderable.worldTransform.array); + __WEBPACK_IMPORTED_MODULE_10__glmatrix_vec3__["a" /* default */].transformMat4(posViewSpace, renderable.position.array, worldViewMat); renderable.__depth = posViewSpace[2]; } @@ -18908,9 +16903,11 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten /** * Render a single renderable list in camera in sequence * @param {clay.Renderable[]} list List of all renderables. - * @param {clay.Camera} camera + * @param {clay.Camera} [camera] Camera provide view matrix and porjection matrix. It can be null. * @param {Object} [passConfig] * @param {Function} [passConfig.getMaterial] Get renderable material. + * @param {Function} [passConfig.getUniform] Get material uniform value. + * @param {Function} [passConfig.isMaterialChanged] If material changed. * @param {Function} [passConfig.beforeRender] Before render each renderable. * @param {Function} [passConfig.afterRender] After render each renderable * @param {Function} [passConfig.ifRender] If render the renderable. @@ -18922,9 +16919,14 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten passConfig = passConfig || {}; passConfig.getMaterial = passConfig.getMaterial || defaultGetMaterial; + passConfig.getUniform = passConfig.getUniform || defaultGetUniform; + // PENDING Better solution? + passConfig.isMaterialChanged = passConfig.isMaterialChanged || defaultIsMaterialChanged; passConfig.beforeRender = passConfig.beforeRender || noop; passConfig.afterRender = passConfig.afterRender || noop; + var ifRenderObject = passConfig.ifRender || defaultIfRender; + this.updatePrograms(list, this._sceneRendering, passConfig); if (passConfig.sortCompare) { list.sort(passConfig.sortCompare); @@ -18948,18 +16950,26 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten var time = Date.now(); // Calculate view and projection matrix - mat4.copy(matrices.VIEW, camera.viewMatrix.array); - mat4.copy(matrices.PROJECTION, camera.projectionMatrix.array); - mat4.multiply(matrices.VIEWPROJECTION, camera.projectionMatrix.array, matrices.VIEW); - mat4.copy(matrices.VIEWINVERSE, camera.worldTransform.array); - mat4.invert(matrices.PROJECTIONINVERSE, matrices.PROJECTION); - mat4.invert(matrices.VIEWPROJECTIONINVERSE, matrices.VIEWPROJECTION); + if (camera) { + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].copy(matrices.VIEW, camera.viewMatrix.array); + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].copy(matrices.PROJECTION, camera.projectionMatrix.array); + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].copy(matrices.VIEWINVERSE, camera.worldTransform.array); + } + else { + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].identity(matrices.VIEW); + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].identity(matrices.PROJECTION); + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].identity(matrices.VIEWINVERSE); + } + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].multiply(matrices.VIEWPROJECTION, matrices.PROJECTION, matrices.VIEW); + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].invert(matrices.PROJECTIONINVERSE, matrices.PROJECTION); + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].invert(matrices.VIEWPROJECTIONINVERSE, matrices.VIEWPROJECTION); var _gl = this.gl; var scene = this._sceneRendering; var prevMaterial; var prevProgram; + var prevRenderable; // Status var depthTest, depthMask; @@ -18967,17 +16977,24 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten var transparent; var drawID; var currentVAO; + var materialTakesTextureSlot; var vaoExt = this.getGLExtension('OES_vertex_array_object'); for (var i = 0; i < list.length; i++) { var renderable = list[i]; - if (passConfig.ifRender && !passConfig.ifRender(renderable)) { + var isSceneNode = renderable.worldTransform != null; + var worldM; + + if (!ifRenderObject(renderable)) { continue; } // Skinned mesh will transformed to joint space. Ignore the mesh transform - var worldM = renderable.isSkinnedMesh() ? matrices.IDENTITY : renderable.worldTransform.array; + if (isSceneNode) { + worldM = (renderable.isSkinnedMesh && renderable.isSkinnedMesh()) + ? matrices.IDENTITY : renderable.worldTransform.array; + } var geometry = renderable.geometry; var material = passConfig.getMaterial.call(this, renderable); @@ -18991,25 +17008,26 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten // TODO Seems need to be bound to null immediately (or before bind another program?) if vao is changed vaoExt.bindVertexArrayOES(null); } - - mat4.copy(matrices.WORLD, worldM); - mat4.multiply(matrices.WORLDVIEWPROJECTION, matrices.VIEWPROJECTION, worldM); - mat4.multiplyAffine(matrices.WORLDVIEW, camera.viewMatrix.array, worldM); - if (shader.matrixSemantics.WORLDINVERSE || - shader.matrixSemantics.WORLDINVERSETRANSPOSE) { - mat4.invert(matrices.WORLDINVERSE, worldM); - } - if (shader.matrixSemantics.WORLDVIEWINVERSE || - shader.matrixSemantics.WORLDVIEWINVERSETRANSPOSE) { - mat4.invert(matrices.WORLDVIEWINVERSE, matrices.WORLDVIEW); - } - if (shader.matrixSemantics.WORLDVIEWPROJECTIONINVERSE || - shader.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE) { - mat4.invert(matrices.WORLDVIEWPROJECTIONINVERSE, matrices.WORLDVIEWPROJECTION); + if (isSceneNode) { + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].copy(matrices.WORLD, worldM); + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].multiply(matrices.WORLDVIEWPROJECTION, matrices.VIEWPROJECTION, worldM); + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].multiplyAffine(matrices.WORLDVIEW, matrices.VIEW, worldM); + if (shader.matrixSemantics.WORLDINVERSE || + shader.matrixSemantics.WORLDINVERSETRANSPOSE) { + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].invert(matrices.WORLDINVERSE, worldM); + } + if (shader.matrixSemantics.WORLDVIEWINVERSE || + shader.matrixSemantics.WORLDVIEWINVERSETRANSPOSE) { + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].invert(matrices.WORLDVIEWINVERSE, matrices.WORLDVIEW); + } + if (shader.matrixSemantics.WORLDVIEWPROJECTIONINVERSE || + shader.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE) { + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].invert(matrices.WORLDVIEWPROJECTIONINVERSE, matrices.WORLDVIEWPROJECTION); + } } // Before render hook - renderable.beforeRender(this); + renderable.beforeRender && renderable.beforeRender(this); passConfig.beforeRender.call(this, renderable, material, prevMaterial); var programChanged = program !== prevProgram; @@ -19019,8 +17037,10 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten // Set some common uniforms program.setUniformOfSemantic(_gl, 'VIEWPORT', viewportUniform); program.setUniformOfSemantic(_gl, 'WINDOW_SIZE', windowSizeUniform); - program.setUniformOfSemantic(_gl, 'NEAR', camera.near); - program.setUniformOfSemantic(_gl, 'FAR', camera.far); + if (camera) { + program.setUniformOfSemantic(_gl, 'NEAR', camera.near); + program.setUniformOfSemantic(_gl, 'FAR', camera.far); + } program.setUniformOfSemantic(_gl, 'DEVICEPIXELRATIO', vDpr); program.setUniformOfSemantic(_gl, 'TIME', time); // DEPRECATED @@ -19037,7 +17057,9 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten } // Program changes also needs reset the materials. - if (prevMaterial !== material || programChanged) { + if (programChanged || passConfig.isMaterialChanged( + renderable, prevRenderable, material, prevMaterial + )) { if (material.depthTest !== depthTest) { material.depthTest ? _gl.enable(_gl.DEPTH_TEST) : _gl.disable(_gl.DEPTH_TEST); depthTest = material.depthTest; @@ -19062,20 +17084,27 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten } } - this._bindMaterial(material, program, prevMaterial || null, prevProgram || null); + materialTakesTextureSlot = this._bindMaterial( + renderable, material, program, + prevRenderable || null, prevMaterial || null, prevProgram || null, + passConfig.getUniform + ); prevMaterial = material; } var matrixSemanticKeys = shader.matrixSemanticKeys; - for (var k = 0; k < matrixSemanticKeys.length; k++) { - var semantic = matrixSemanticKeys[k]; - var semanticInfo = shader.matrixSemantics[semantic]; - var matrix = matrices[semantic]; - if (semanticInfo.isTranspose) { - var matrixNoTranspose = matrices[semanticInfo.semanticNoTranspose]; - mat4.transpose(matrix, matrixNoTranspose); + + if (isSceneNode) { + for (var k = 0; k < matrixSemanticKeys.length; k++) { + var semantic = matrixSemanticKeys[k]; + var semanticInfo = shader.matrixSemantics[semantic]; + var matrix = matrices[semantic]; + if (semanticInfo.isTranspose) { + var matrixNoTranspose = matrices[semanticInfo.semanticNoTranspose]; + __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].transpose(matrix, matrixNoTranspose); + } + program.setUniform(_gl, semanticInfo.type, semanticInfo.symbol, matrix); } - program.setUniform(_gl, semanticInfo.type, semanticInfo.symbol, matrix); } if (renderable.cullFace !== cullFace) { @@ -19090,18 +17119,19 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten culling = renderable.culling; culling ? _gl.enable(_gl.CULL_FACE) : _gl.disable(_gl.CULL_FACE); } - - this._updateSkeleton(renderable, program); + // TODO Not update skeleton in each renderable. + this._updateSkeleton(renderable, program, materialTakesTextureSlot); if (drawIDChanged) { currentVAO = this._bindVAO(vaoExt, shader, geometry, program); } this._renderObject(renderable, currentVAO); // After render hook - passConfig.afterRender.call(this, renderable); - renderable.afterRender(this); + passConfig.afterRender(this, renderable); + renderable.afterRender && renderable.afterRender(this); prevProgram = program; + prevRenderable = renderable; } // TODO Seems need to be bound to null immediately if vao is changed? @@ -19112,13 +17142,27 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten this.trigger('afterrenderpass', this, list, camera, passConfig); }, - _updateSkeleton: function (object, program) { + getMaxJointNumber: function () { + return this._glinfo.getMaxJointNumber(); + }, + + _updateSkeleton: function (object, program, slot) { var _gl = this.gl; + var skeleton = object.skeleton; // Set pose matrices of skinned mesh - if (object.skeleton) { - object.skeleton.update(); - var skinMatricesArray = object.skeleton.getSubSkinMatrices(object.__uid__, object.joints); - program.setUniformOfSemantic(_gl, 'SKIN_MATRIX', skinMatricesArray); + if (skeleton) { + // TODO Update before culling. + skeleton.update(); + if (object.joints.length > this._glinfo.getMaxJointNumber()) { + var skinMatricesTexture = skeleton.getSubSkinMatricesTexture(object.__uid__, object.joints); + program.useTextureSlot(this, skinMatricesTexture, slot); + program.setUniform(_gl, '1i', 'skinMatricesTexture', slot); + program.setUniform(_gl, '1f', 'skinMatricesTextureSize', skinMatricesTexture.width); + } + else { + var skinMatricesArray = skeleton.getSubSkinMatrices(object.__uid__, object.joints); + program.setUniformOfSemantic(_gl, 'SKIN_MATRIX', skinMatricesArray); + } } }, @@ -19127,6 +17171,9 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten var geometry = renderable.geometry; var glDrawMode = renderable.mode; + if (glDrawMode == null) { + glDrawMode = 0x0004; + } // if (glDrawMode === glenum.LINES || glDrawMode === glenum.LINE_STRIP || glDrawMode === glenum.LINE_LOOP) { // _gl.lineWidth(this.lineWidth); @@ -19146,7 +17193,7 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten } }, - _bindMaterial: function (material, program, prevMaterial, prevProgram) { + _bindMaterial: function (renderable, material, program, prevRenderable, prevMaterial, prevProgram, getUniformValue) { var _gl = this.gl; // PENDING Same texture in different material take different slot? @@ -19156,10 +17203,11 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten var currentTextureSlot = program.currentTextureSlot(); var enabledUniforms = material.getEnabledUniforms(); var textureUniforms = material.getTextureUniforms(); + var placeholderTexture = this._placeholderTexture; for (var u = 0; u < textureUniforms.length; u++) { var symbol = textureUniforms[u]; - var uniformValue = material.uniforms[symbol].value; + var uniformValue = getUniformValue(renderable, material, symbol); var uniformType = material.uniforms[symbol].type; // Not use `instanceof` to determine if a value is texture in Material#bind. // Use type instead, in some case texture may be in different namespaces. @@ -19170,52 +17218,65 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten } else if (uniformType === 'tv') { for (var i = 0; i < uniformValue.length; i++) { - if (uniformValue[i] instanceof Texture) { + if (uniformValue[i]) { uniformValue[i].__slot = -1; } } } } + placeholderTexture.__slot = -1; + // Set uniforms for (var u = 0; u < enabledUniforms.length; u++) { var symbol = enabledUniforms[u]; var uniform = material.uniforms[symbol]; - var uniformValue = uniform.value; + var uniformValue = getUniformValue(renderable, material, symbol); + var uniformType = uniform.type; + var isTexture = uniformType === 't'; + + if (isTexture) { + if (!uniformValue || !uniformValue.isRenderable()) { + uniformValue = placeholderTexture; + } + } // PENDING // When binding two materials with the same shader // Many uniforms will be be set twice even if they have the same value // So add a evaluation to see if the uniform is really needed to be set if (prevMaterial && sameProgram) { - if (prevMaterial.uniforms[symbol].value === uniformValue) { - continue; + var prevUniformValue = getUniformValue(prevRenderable, prevMaterial, symbol); + if (isTexture) { + if (!prevUniformValue || !prevUniformValue.isRenderable()) { + prevUniformValue = placeholderTexture; + } } - } - var uniformType = uniform.type; - if (uniformValue == null) { - // FIXME Assume material with same shader have same order uniforms - // Or if different material use same textures, - // the slot will be different and still skipped because optimization - if (uniform.type === 't') { - var slot = program.currentTextureSlot(); - var res = program.setUniform(_gl, '1i', symbol, slot); - if (res) { // Texture is enabled - // Still occupy the slot to make sure same texture in different materials have same slot. + if (prevUniformValue === uniformValue) { + if (isTexture) { + // Still take the slot to make sure same texture in different materials have same slot. program.takeCurrentTextureSlot(this, null); } + else if (uniformType === 'tv' && uniformValue) { + for (var i = 0; i < uniformValue.length; i++) { + program.takeCurrentTextureSlot(this, null); + } + } + continue; } + } + + if (uniformValue == null) { continue; } - else if (uniformType === 't') { + else if (isTexture) { if (uniformValue.__slot < 0) { var slot = program.currentTextureSlot(); var res = program.setUniform(_gl, '1i', symbol, slot); - if (!res) { // Texture uniform is not enabled - continue; + if (res) { // Texture uniform is enabled + program.takeCurrentTextureSlot(this, uniformValue); + uniformValue.__slot = slot; } - program.takeCurrentTextureSlot(this, uniformValue); - uniformValue.__slot = slot; } // Multiple uniform use same texture.. else { @@ -19257,8 +17318,10 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten program.setUniform(_gl, uniform.type, symbol, uniformValue); } } + var newSlot = program.currentTextureSlot(); // Texture slot maybe used out of material. program.resetTextureSlot(currentTextureSlot); + return newSlot; }, _bindVAO: function (vaoExt, shader, geometry, program) { @@ -19353,8 +17416,8 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten renderPreZ: function (list, scene, camera) { var _gl = this.gl; - var preZPassMaterial = this._prezMaterial || new __WEBPACK_IMPORTED_MODULE_6__Material__["a" /* default */]({ - shader: new __WEBPACK_IMPORTED_MODULE_9__Shader__["a" /* default */](__WEBPACK_IMPORTED_MODULE_9__Shader__["a" /* default */].source('clay.prez.vertex'), __WEBPACK_IMPORTED_MODULE_9__Shader__["a" /* default */].source('clay.prez.fragment')) + var preZPassMaterial = this._prezMaterial || new __WEBPACK_IMPORTED_MODULE_4__Material__["a" /* default */]({ + shader: new __WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */](__WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */].source('clay.prez.vertex'), __WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */].source('clay.prez.fragment')) }); this._prezMaterial = preZPassMaterial; @@ -19366,6 +17429,29 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten ifRender: function (renderable) { return !renderable.ignorePreZ; }, + isMaterialChanged: function (renderable, prevRenderable) { + var matA = renderable.material; + var matB = prevRenderable.material; + return matA.get('diffuseMap') !== matB.get('diffuseMap') + || (matA.get('alphaCutoff') || 0) !== (matB.get('alphaCutoff') || 0); + }, + getUniform: function (renderable, depthMaterial, symbol) { + if (symbol === 'alphaMap') { + return renderable.material.get('diffuseMap'); + } + else if (symbol === 'alphaCutoff') { + if (renderable.material.isDefined('fragment', 'ALPHA_TEST') + && renderable.material.get('diffuseMap') + ) { + var alphaCutoff = renderable.material.get('alphaCutoff'); + return alphaCutoff || 0; + } + return 0; + } + else { + return depthMaterial.get(symbol); + } + }, getMaterial: function () { return preZPassMaterial; }, @@ -19472,7 +17558,7 @@ var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].exten */ screenToNDC: function(x, y, out) { if (!out) { - out = new __WEBPACK_IMPORTED_MODULE_7__math_Vector2__["a" /* default */](); + out = new __WEBPACK_IMPORTED_MODULE_5__math_Vector2__["a" /* default */](); } // Invert y; y = this._height - y; @@ -19594,7 +17680,7 @@ Renderer.STENCIL_BUFFER_BIT = __WEBPACK_IMPORTED_MODULE_2__core_glenum__["a" /* /***/ }), -/* 47 */ +/* 53 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -19724,211 +17810,93 @@ var notifier = { */ after: function(name, action, context) { if (!name || !action) { - return; - } - name = 'after' + name; - return this.on(name, action, context); - }, - - /** - * Alias of on('success') - * @param {Function} action - * @param {Object} [context] - * @chainable - */ - success: function(action, context) { - return this.once('success', action, context); - }, - - /** - * Alias of on('error') - * @param {Function} action - * @param {Object} [context] - * @chainable - */ - error: function(action, context) { - return this.once('error', action, context); - }, - - /** - * Remove event listener - * @param {Function} action - * @param {Object} [context] - * @chainable - */ - off: function(name, action) { - - var handlers = this.__handlers__ || (this.__handlers__={}); - - if (!action) { - handlers[name] = []; - return; - } - if (handlers[name]) { - var hdls = handlers[name]; - var retains = []; - for (var i = 0; i < hdls.length; i++) { - if (action && hdls[i].action !== action) { - retains.push(hdls[i]); - } - } - handlers[name] = retains; - } - - return this; - }, - - /** - * If registered the event handler - * @param {string} name - * @param {Function} action - * @return {boolean} - */ - has: function(name, action) { - var handlers = this.__handlers__; - - if (! handlers || - ! handlers[name]) { - return false; - } - var hdls = handlers[name]; - for (var i = 0; i < hdls.length; i++) { - if (hdls[i].action === action) { - return true; - } - } - } -}; - -/* harmony default export */ __webpack_exports__["a"] = (notifier); - -/***/ }), -/* 48 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -var DIRTY_PREFIX = '__dt__'; - -var Cache = function () { - - this._contextId = 0; - - this._caches = []; - - this._context = {}; -}; - -Cache.prototype = { - - use: function (contextId, documentSchema) { - var caches = this._caches; - if (!caches[contextId]) { - caches[contextId] = {}; - - if (documentSchema) { - caches[contextId] = documentSchema(); - } - } - this._contextId = contextId; - - this._context = caches[contextId]; - }, - - put: function (key, value) { - this._context[key] = value; - }, - - get: function (key) { - return this._context[key]; - }, - - dirty: function (field) { - field = field || ''; - var key = DIRTY_PREFIX + field; - this.put(key, true); - }, - - dirtyAll: function (field) { - field = field || ''; - var key = DIRTY_PREFIX + field; - var caches = this._caches; - for (var i = 0; i < caches.length; i++) { - if (caches[i]) { - caches[i][key] = true; - } - } - }, - - fresh: function (field) { - field = field || ''; - var key = DIRTY_PREFIX + field; - this.put(key, false); - }, - - freshAll: function (field) { - field = field || ''; - var key = DIRTY_PREFIX + field; - var caches = this._caches; - for (var i = 0; i < caches.length; i++) { - if (caches[i]) { - caches[i][key] = false; - } + return; } + name = 'after' + name; + return this.on(name, action, context); }, - isDirty: function (field) { - field = field || ''; - var key = DIRTY_PREFIX + field; - var context = this._context; - return !context.hasOwnProperty(key) - || context[key] === true; + /** + * Alias of on('success') + * @param {Function} action + * @param {Object} [context] + * @chainable + */ + success: function(action, context) { + return this.once('success', action, context); }, - deleteContext: function (contextId) { - delete this._caches[contextId]; - this._context = {}; + /** + * Alias of on('error') + * @param {Function} action + * @param {Object} [context] + * @chainable + */ + error: function(action, context) { + return this.once('error', action, context); }, - delete: function (key) { - delete this._context[key]; - }, + /** + * Remove event listener + * @param {Function} action + * @param {Object} [context] + * @chainable + */ + off: function(name, action) { - clearAll: function () { - this._caches = {}; - }, + var handlers = this.__handlers__ || (this.__handlers__={}); - getContext: function () { - return this._context; - }, + if (!action) { + handlers[name] = []; + return; + } + if (handlers[name]) { + var hdls = handlers[name]; + var retains = []; + for (var i = 0; i < hdls.length; i++) { + if (action && hdls[i].action !== action) { + retains.push(hdls[i]); + } + } + handlers[name] = retains; + } - eachContext : function (cb, context) { - var keys = Object.keys(this._caches); - keys.forEach(function (key) { - cb && cb.call(context, key); - }); + return this; }, - miss: function (key) { - return ! this._context.hasOwnProperty(key); + /** + * If registered the event handler + * @param {string} name + * @param {Function} action + * @return {boolean} + */ + has: function(name, action) { + var handlers = this.__handlers__; + + if (! handlers || + ! handlers[name]) { + return false; + } + var hdls = handlers[name]; + for (var i = 0; i < hdls.length; i++) { + if (hdls[i].action === action) { + return true; + } + } } }; -Cache.prototype.constructor = Cache; - -/* harmony default export */ __webpack_exports__["a"] = (Cache); - +/* harmony default export */ __webpack_exports__["a"] = (notifier); /***/ }), -/* 49 */ +/* 54 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__ = __webpack_require__(12); -var vec3 = __WEBPACK_IMPORTED_MODULE_1__dep_glmatrix___default.a.vec3; var EPSILON = 1e-5; @@ -19966,7 +17934,7 @@ Ray.prototype = { var ro = this.origin.array; var rd = this.direction.array; - var divider = vec3.dot(pn, rd); + var divider = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(pn, rd); // ray is parallel to the plane if (divider === 0) { return null; @@ -19974,8 +17942,8 @@ Ray.prototype = { if (!out) { out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](); } - var t = (vec3.dot(pn, ro) - d) / divider; - vec3.scaleAndAdd(out.array, ro, rd, -t); + var t = (__WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(pn, ro) - d) / divider; + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, ro, rd, -t); out._dirty = true; return out; }, @@ -19986,22 +17954,22 @@ Ray.prototype = { */ mirrorAgainstPlane: function (plane) { // Distance to plane - var d = vec3.dot(plane.normal.array, this.direction.array); - vec3.scaleAndAdd(this.direction.array, this.direction.array, plane.normal.array, -d * 2); + var d = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(plane.normal.array, this.direction.array); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scaleAndAdd(this.direction.array, this.direction.array, plane.normal.array, -d * 2); this.direction._dirty = true; }, distanceToPoint: (function () { - var v = vec3.create(); + var v = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); return function (point) { - vec3.sub(v, point, this.origin.array); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(v, point, this.origin.array); // Distance from projection point to origin - var b = vec3.dot(v, this.direction.array); + var b = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(v, this.direction.array); if (b < 0) { - return vec3.distance(this.origin.array, point); + return __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].distance(this.origin.array, point); } // Squared distance from center to origin - var c2 = vec3.lenSquared(v); + var c2 = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].lenSquared(v); // Squared distance from center to projection point return Math.sqrt(c2 - b * b); }; @@ -20015,248 +17983,783 @@ Ray.prototype = { * @return {clay.Vector3} */ intersectSphere: (function () { - var v = vec3.create(); + var v = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); return function (center, radius, out) { var origin = this.origin.array; var direction = this.direction.array; center = center.array; - vec3.sub(v, center, origin); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(v, center, origin); // Distance from projection point to origin - var b = vec3.dot(v, direction); + var b = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(v, direction); // Squared distance from center to origin - var c2 = vec3.squaredLength(v); + var c2 = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].squaredLength(v); // Squared distance from center to projection point var d2 = c2 - b * b; - var r2 = radius * radius; - // No intersection - if (d2 > r2) { - return; - } + var r2 = radius * radius; + // No intersection + if (d2 > r2) { + return; + } + + var a = Math.sqrt(r2 - d2); + // First intersect point + var t0 = b - a; + // Second intersect point + var t1 = b + a; + + if (!out) { + out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](); + } + if (t0 < 0) { + if (t1 < 0) { + return null; + } + else { + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, origin, direction, t1); + return out; + } + } + else { + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, origin, direction, t0); + return out; + } + }; + })(), + + // http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-box-intersection/ + /** + * Calculate intersection point between ray and bounding box + * @param {clay.BoundingBox} bbox + * @param {clay.Vector3} + * @return {clay.Vector3} + */ + intersectBoundingBox: function (bbox, out) { + var dir = this.direction.array; + var origin = this.origin.array; + var min = bbox.min.array; + var max = bbox.max.array; + + var invdirx = 1 / dir[0]; + var invdiry = 1 / dir[1]; + var invdirz = 1 / dir[2]; + + var tmin, tmax, tymin, tymax, tzmin, tzmax; + if (invdirx >= 0) { + tmin = (min[0] - origin[0]) * invdirx; + tmax = (max[0] - origin[0]) * invdirx; + } + else { + tmax = (min[0] - origin[0]) * invdirx; + tmin = (max[0] - origin[0]) * invdirx; + } + if (invdiry >= 0) { + tymin = (min[1] - origin[1]) * invdiry; + tymax = (max[1] - origin[1]) * invdiry; + } + else { + tymax = (min[1] - origin[1]) * invdiry; + tymin = (max[1] - origin[1]) * invdiry; + } + + if ((tmin > tymax) || (tymin > tmax)) { + return null; + } + + if (tymin > tmin || tmin !== tmin) { + tmin = tymin; + } + if (tymax < tmax || tmax !== tmax) { + tmax = tymax; + } + + if (invdirz >= 0) { + tzmin = (min[2] - origin[2]) * invdirz; + tzmax = (max[2] - origin[2]) * invdirz; + } + else { + tzmax = (min[2] - origin[2]) * invdirz; + tzmin = (max[2] - origin[2]) * invdirz; + } + + if ((tmin > tzmax) || (tzmin > tmax)) { + return null; + } + + if (tzmin > tmin || tmin !== tmin) { + tmin = tzmin; + } + if (tzmax < tmax || tmax !== tmax) { + tmax = tzmax; + } + if (tmax < 0) { + return null; + } + + var t = tmin >= 0 ? tmin : tmax; + + if (!out) { + out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](); + } + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, origin, dir, t); + return out; + }, + + // http://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm + /** + * Calculate intersection point between ray and three triangle vertices + * @param {clay.Vector3} a + * @param {clay.Vector3} b + * @param {clay.Vector3} c + * @param {boolean} singleSided, CW triangle will be ignored + * @param {clay.Vector3} [out] + * @param {clay.Vector3} [barycenteric] barycentric coords + * @return {clay.Vector3} + */ + intersectTriangle: (function () { + + var eBA = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); + var eCA = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); + var AO = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); + var vCross = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create(); + + return function (a, b, c, singleSided, out, barycenteric) { + var dir = this.direction.array; + var origin = this.origin.array; + a = a.array; + b = b.array; + c = c.array; + + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(eBA, b, a); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(eCA, c, a); + + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].cross(vCross, eCA, dir); + + var det = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(eBA, vCross); + + if (singleSided) { + if (det > -EPSILON) { + return null; + } + } + else { + if (det > -EPSILON && det < EPSILON) { + return null; + } + } + + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(AO, origin, a); + var u = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(vCross, AO) / det; + if (u < 0 || u > 1) { + return null; + } + + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].cross(vCross, eBA, AO); + var v = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(dir, vCross) / det; + + if (v < 0 || v > 1 || (u + v > 1)) { + return null; + } + + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].cross(vCross, eBA, eCA); + var t = -__WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(AO, vCross) / det; + + if (t < 0) { + return null; + } + + if (!out) { + out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](); + } + if (barycenteric) { + __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].set(barycenteric, (1 - u - v), u, v); + } + __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, origin, dir, t); + + return out; + }; + })(), + + /** + * Apply an affine transform matrix to the ray + * @return {clay.Matrix4} matrix + */ + applyTransform: function (matrix) { + __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].add(this.direction, this.direction, this.origin); + __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].transformMat4(this.origin, this.origin, matrix); + __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].transformMat4(this.direction, this.direction, matrix); + + __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].sub(this.direction, this.direction, this.origin); + __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].normalize(this.direction, this.direction); + }, + + /** + * Copy values from another ray + * @param {clay.Ray} ray + */ + copy: function (ray) { + __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].copy(this.origin, ray.origin); + __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].copy(this.direction, ray.direction); + }, + + /** + * Clone a new ray + * @return {clay.Ray} + */ + clone: function () { + var ray = new Ray(); + ray.copy(this); + return ray; + } +}; + +/* harmony default export */ __webpack_exports__["a"] = (Ray); + + +/***/ }), +/* 55 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__vec3__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__vec4__ = __webpack_require__(33); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__mat3__ = __webpack_require__(34); + + +/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. 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 HOLDER 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 USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + + + + + + + +/** + * @class Quaternion + * @name quat + */ + +var quat = {}; + +/** + * Creates a new identity quat + * + * @returns {quat} a new quaternion + */ +quat.create = function() { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](4); + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; +}; + +/** + * 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 + */ +quat.rotationTo = (function() { + var tmpvec3 = __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].create(); + var xUnitVec3 = __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].fromValues(1,0,0); + var yUnitVec3 = __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].fromValues(0,1,0); + + return function(out, a, b) { + var dot = __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].dot(a, b); + if (dot < -0.999999) { + __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].cross(tmpvec3, xUnitVec3, a); + if (__WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].length(tmpvec3) < 0.000001) + __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].cross(tmpvec3, yUnitVec3, a); + __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].normalize(tmpvec3, tmpvec3); + quat.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 { + __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].cross(tmpvec3, a, b); + out[0] = tmpvec3[0]; + out[1] = tmpvec3[1]; + out[2] = tmpvec3[2]; + out[3] = 1 + dot; + return quat.normalize(out, 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 + */ +quat.setAxes = (function() { + var matr = __WEBPACK_IMPORTED_MODULE_3__mat3__["a" /* default */].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 quat.normalize(out, quat.fromMat3(out, matr)); + }; +})(); + +/** + * Creates a new quat initialized with values from an existing quaternion + * + * @param {quat} a quaternion to clone + * @returns {quat} a new quaternion + * @function + */ +quat.clone = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].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 + */ +quat.fromValues = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].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 + */ +quat.copy = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].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 + */ +quat.set = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].set; + +/** + * Set a quat to the identity quaternion + * + * @param {quat} out the receiving quaternion + * @returns {quat} out + */ +quat.identity = function(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 + **/ +quat.setAxisAngle = function(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; +}; + +/** + * 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 + */ +quat.add = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].add; + +/** + * 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 + */ +quat.multiply = function(out, a, b) { + var ax = a[0], ay = a[1], az = a[2], aw = a[3], + 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; +}; + +/** + * Alias for {@link quat.multiply} + * @function + */ +quat.mul = quat.multiply; - var a = Math.sqrt(r2 - d2); - // First intersect point - var t0 = b - a; - // Second intersect point - var t1 = b + a; +/** + * 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 + */ +quat.scale = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].scale; - if (!out) { - out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](); - } - if (t0 < 0) { - if (t1 < 0) { - return null; - } - else { - vec3.scaleAndAdd(out.array, origin, direction, t1); - return out; - } - } - else { - vec3.scaleAndAdd(out.array, origin, direction, t0); - 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 + */ +quat.rotateX = function (out, a, rad) { + rad *= 0.5; - // http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-box-intersection/ - /** - * Calculate intersection point between ray and bounding box - * @param {clay.BoundingBox} bbox - * @param {clay.Vector3} - * @return {clay.Vector3} - */ - intersectBoundingBox: function (bbox, out) { - var dir = this.direction.array; - var origin = this.origin.array; - var min = bbox.min.array; - var max = bbox.max.array; + var ax = a[0], ay = a[1], az = a[2], aw = a[3], + bx = Math.sin(rad), bw = Math.cos(rad); - var invdirx = 1 / dir[0]; - var invdiry = 1 / dir[1]; - var invdirz = 1 / dir[2]; + 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; +}; - var tmin, tmax, tymin, tymax, tzmin, tzmax; - if (invdirx >= 0) { - tmin = (min[0] - origin[0]) * invdirx; - tmax = (max[0] - origin[0]) * invdirx; - } - else { - tmax = (min[0] - origin[0]) * invdirx; - tmin = (max[0] - origin[0]) * invdirx; - } - if (invdiry >= 0) { - tymin = (min[1] - origin[1]) * invdiry; - tymax = (max[1] - origin[1]) * invdiry; - } - else { - tymax = (min[1] - origin[1]) * invdiry; - tymin = (max[1] - origin[1]) * invdiry; - } +/** + * 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 + */ +quat.rotateY = function (out, a, rad) { + rad *= 0.5; - if ((tmin > tymax) || (tymin > tmax)) { - return null; - } + var ax = a[0], ay = a[1], az = a[2], aw = a[3], + by = Math.sin(rad), bw = Math.cos(rad); - if (tymin > tmin || tmin !== tmin) { - tmin = tymin; - } - if (tymax < tmax || tmax !== tmax) { - tmax = tymax; - } + 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; +}; - if (invdirz >= 0) { - tzmin = (min[2] - origin[2]) * invdirz; - tzmax = (max[2] - origin[2]) * invdirz; - } - else { - tzmax = (min[2] - origin[2]) * invdirz; - tzmin = (max[2] - origin[2]) * invdirz; - } +/** + * 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 + */ +quat.rotateZ = function (out, a, rad) { + rad *= 0.5; - if ((tmin > tzmax) || (tzmin > tmax)) { - return null; - } + var ax = a[0], ay = a[1], az = a[2], aw = a[3], + bz = Math.sin(rad), bw = Math.cos(rad); - if (tzmin > tmin || tmin !== tmin) { - tmin = tzmin; - } - if (tzmax < tmax || tmax !== tmax) { - tmax = tzmax; - } - if (tmax < 0) { - return null; - } + 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; +}; - var t = tmin >= 0 ? tmin : tmax; +/** + * 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 + */ +quat.calculateW = function (out, a) { + var x = a[0], y = a[1], z = a[2]; - if (!out) { - out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](); - } - vec3.scaleAndAdd(out.array, origin, dir, t); - return out; - }, + 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; +}; - // http://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm - /** - * Calculate intersection point between ray and three triangle vertices - * @param {clay.Vector3} a - * @param {clay.Vector3} b - * @param {clay.Vector3} c - * @param {boolean} singleSided, CW triangle will be ignored - * @param {clay.Vector3} [out] - * @param {clay.Vector3} [barycenteric] barycentric coords - * @return {clay.Vector3} - */ - intersectTriangle: (function () { +/** + * 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 + */ +quat.dot = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].dot; - var eBA = vec3.create(); - var eCA = vec3.create(); - var AO = vec3.create(); - var vCross = vec3.create(); +/** + * 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 between the two inputs + * @returns {quat} out + * @function + */ +quat.lerp = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].lerp; - return function (a, b, c, singleSided, out, barycenteric) { - var dir = this.direction.array; - var origin = this.origin.array; - a = a.array; - b = b.array; - c = c.array; +/** + * 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 between the two inputs + * @returns {quat} out + */ +quat.slerp = function (out, a, b, t) { + // benchmarks: + // http://jsperf.com/quaternion-slerp-implementations - vec3.sub(eBA, b, a); - vec3.sub(eCA, c, a); + var ax = a[0], ay = a[1], az = a[2], aw = a[3], + bx = b[0], by = b[1], bz = b[2], bw = b[3]; + + var omega, cosom, sinom, scale0, scale1; - vec3.cross(vCross, eCA, dir); + // 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) > 0.000001 ) { + // 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; - var det = vec3.dot(eBA, vCross); + return out; +}; - if (singleSided) { - if (det > -EPSILON) { - return null; - } - } - else { - if (det > -EPSILON && det < EPSILON) { - return null; - } - } +/** + * Calculates the inverse of a quat + * + * @param {quat} out the receiving quaternion + * @param {quat} a quat to calculate inverse of + * @returns {quat} out + */ +quat.invert = function(out, a) { + var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], + dot = a0*a0 + a1*a1 + a2*a2 + a3*a3, + invDot = dot ? 1.0/dot : 0; - vec3.sub(AO, origin, a); - var u = vec3.dot(vCross, AO) / det; - if (u < 0 || u > 1) { - return null; - } + // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 - vec3.cross(vCross, eBA, AO); - var v = vec3.dot(dir, vCross) / det; + out[0] = -a0*invDot; + out[1] = -a1*invDot; + out[2] = -a2*invDot; + out[3] = a3*invDot; + return out; +}; - if (v < 0 || v > 1 || (u + v > 1)) { - return null; - } +/** + * 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 + */ +quat.conjugate = function (out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = a[3]; + return out; +}; - vec3.cross(vCross, eBA, eCA); - var t = -vec3.dot(AO, vCross) / det; +/** + * Calculates the length of a quat + * + * @param {quat} a vector to calculate length of + * @returns {Number} length of a + * @function + */ +quat.length = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].length; - if (t < 0) { - return null; - } +/** + * Alias for {@link quat.length} + * @function + */ +quat.len = quat.length; - if (!out) { - out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](); - } - if (barycenteric) { - __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].set(barycenteric, (1 - u - v), u, v); - } - vec3.scaleAndAdd(out.array, origin, dir, t); +/** + * Calculates the squared length of a quat + * + * @param {quat} a vector to calculate squared length of + * @returns {Number} squared length of a + * @function + */ +quat.squaredLength = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].squaredLength; - return out; - }; - })(), +/** + * Alias for {@link quat.squaredLength} + * @function + */ +quat.sqrLen = quat.squaredLength; - /** - * Apply an affine transform matrix to the ray - * @return {clay.Matrix4} matrix - */ - applyTransform: function (matrix) { - __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].add(this.direction, this.direction, this.origin); - __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].transformMat4(this.origin, this.origin, matrix); - __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].transformMat4(this.direction, this.direction, matrix); +/** + * Normalize a quat + * + * @param {quat} out the receiving quaternion + * @param {quat} a quaternion to normalize + * @returns {quat} out + * @function + */ +quat.normalize = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].normalize; - __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].sub(this.direction, this.direction, this.origin); - __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].normalize(this.direction, this.direction); - }, +/** + * 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 + */ +quat.fromMat3 = function(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; - /** - * Copy values from another ray - * @param {clay.Ray} ray - */ - copy: function (ray) { - __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].copy(this.origin, ray.origin); - __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].copy(this.direction, ray.direction); - }, + 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; - /** - * Clone a new ray - * @return {clay.Ray} - */ - clone: function () { - var ray = new Ray(); - ray.copy(this); - return ray; + 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; } -}; -/* harmony default export */ __webpack_exports__["a"] = (Ray); + return out; +}; +/* harmony default export */ __webpack_exports__["a"] = (quat); /***/ }), -/* 50 */ +/* 56 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__ = __webpack_require__(55); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat3__ = __webpack_require__(34); + -var quat = __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default.a.quat; /** * @constructor @@ -20280,7 +18783,7 @@ var Quaternion = function (x, y, z, w) { * @type {Float32Array} * @memberOf clay.Quaternion# */ - this.array = quat.fromValues(x, y, z, w); + this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].fromValues(x, y, z, w); /** * Dirty flag is used by the Node to determine @@ -20302,7 +18805,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ add: function (b) { - quat.add(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].add(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -20312,7 +18815,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ calculateW: function () { - quat.calculateW(this.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].calculateW(this.array, this.array); this._dirty = true; return this; }, @@ -20364,7 +18867,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ conjugate: function () { - quat.conjugate(this.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].conjugate(this.array, this.array); this._dirty = true; return this; }, @@ -20375,7 +18878,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ copy: function (b) { - quat.copy(this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].copy(this.array, b.array); this._dirty = true; return this; }, @@ -20386,7 +18889,7 @@ Quaternion.prototype = { * @return {number} */ dot: function (b) { - return quat.dot(this.array, b.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].dot(this.array, b.array); }, /** @@ -20395,7 +18898,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ fromMat3: function (m) { - quat.fromMat3(this.array, m.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].fromMat3(this.array, m.array); this._dirty = true; return this; }, @@ -20407,13 +18910,12 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ fromMat4: (function () { - var mat3 = __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default.a.mat3; - var m3 = mat3.create(); + var m3 = __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat3__["a" /* default */].create(); return function (m) { - mat3.fromMat4(m3, m.array); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat3__["a" /* default */].fromMat4(m3, m.array); // TODO Not like mat4, mat3 in glmatrix seems to be row-based - mat3.transpose(m3, m3); - quat.fromMat3(this.array, m3); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat3__["a" /* default */].transpose(m3, m3); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].fromMat3(this.array, m3); this._dirty = true; return this; }; @@ -20424,7 +18926,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ identity: function () { - quat.identity(this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].identity(this.array); this._dirty = true; return this; }, @@ -20433,7 +18935,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ invert: function () { - quat.invert(this.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].invert(this.array, this.array); this._dirty = true; return this; }, @@ -20442,7 +18944,7 @@ Quaternion.prototype = { * @return {number} */ len: function () { - return quat.len(this.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].len(this.array); }, /** @@ -20450,7 +18952,7 @@ Quaternion.prototype = { * @return {number} */ length: function () { - return quat.length(this.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].length(this.array); }, /** @@ -20461,7 +18963,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ lerp: function (a, b, t) { - quat.lerp(this.array, a.array, b.array, t); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].lerp(this.array, a.array, b.array, t); this._dirty = true; return this; }, @@ -20472,7 +18974,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ mul: function (b) { - quat.mul(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].mul(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -20483,7 +18985,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ mulLeft: function (a) { - quat.multiply(this.array, a.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].multiply(this.array, a.array, this.array); this._dirty = true; return this; }, @@ -20494,7 +18996,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ multiply: function (b) { - quat.multiply(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].multiply(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -20506,7 +19008,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ multiplyLeft: function (a) { - quat.multiply(this.array, a.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].multiply(this.array, a.array, this.array); this._dirty = true; return this; }, @@ -20516,7 +19018,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ normalize: function () { - quat.normalize(this.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].normalize(this.array, this.array); this._dirty = true; return this; }, @@ -20527,7 +19029,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ rotateX: function (rad) { - quat.rotateX(this.array, this.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotateX(this.array, this.array, rad); this._dirty = true; return this; }, @@ -20538,7 +19040,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ rotateY: function (rad) { - quat.rotateY(this.array, this.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotateY(this.array, this.array, rad); this._dirty = true; return this; }, @@ -20549,7 +19051,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ rotateZ: function (rad) { - quat.rotateZ(this.array, this.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotateZ(this.array, this.array, rad); this._dirty = true; return this; }, @@ -20562,7 +19064,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ rotationTo: function (a, b) { - quat.rotationTo(this.array, a.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotationTo(this.array, a.array, b.array); this._dirty = true; return this; }, @@ -20574,7 +19076,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ setAxes: function (view, right, up) { - quat.setAxes(this.array, view.array, right.array, up.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].setAxes(this.array, view.array, right.array, up.array); this._dirty = true; return this; }, @@ -20586,7 +19088,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ setAxisAngle: function (axis, rad) { - quat.setAxisAngle(this.array, axis.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].setAxisAngle(this.array, axis.array, rad); this._dirty = true; return this; }, @@ -20598,7 +19100,7 @@ Quaternion.prototype = { * @return {clay.Quaternion} */ slerp: function (a, b, t) { - quat.slerp(this.array, a.array, b.array, t); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].slerp(this.array, a.array, b.array, t); this._dirty = true; return this; }, @@ -20608,7 +19110,7 @@ Quaternion.prototype = { * @return {number} */ sqrLen: function () { - return quat.sqrLen(this.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].sqrLen(this.array); }, /** @@ -20616,7 +19118,7 @@ Quaternion.prototype = { * @return {number} */ squaredLength: function () { - return quat.squaredLength(this.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].squaredLength(this.array); }, /** @@ -20716,7 +19218,7 @@ if (defineProperty) { * @return {clay.Quaternion} */ Quaternion.add = function (out, a, b) { - quat.add(out.array, a.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].add(out.array, a.array, b.array); out._dirty = true; return out; }; @@ -20730,7 +19232,7 @@ Quaternion.add = function (out, a, b) { * @return {clay.Quaternion} */ Quaternion.set = function (out, x, y, z, w) { - quat.set(out.array, x, y, z, w); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].set(out.array, x, y, z, w); out._dirty = true; }; @@ -20740,7 +19242,7 @@ Quaternion.set = function (out, x, y, z, w) { * @return {clay.Quaternion} */ Quaternion.copy = function (out, b) { - quat.copy(out.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].copy(out.array, b.array); out._dirty = true; return out; }; @@ -20751,7 +19253,7 @@ Quaternion.copy = function (out, b) { * @return {clay.Quaternion} */ Quaternion.calculateW = function (out, a) { - quat.calculateW(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].calculateW(out.array, a.array); out._dirty = true; return out; }; @@ -20762,7 +19264,7 @@ Quaternion.calculateW = function (out, a) { * @return {clay.Quaternion} */ Quaternion.conjugate = function (out, a) { - quat.conjugate(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].conjugate(out.array, a.array); out._dirty = true; return out; }; @@ -20772,7 +19274,7 @@ Quaternion.conjugate = function (out, a) { * @return {clay.Quaternion} */ Quaternion.identity = function (out) { - quat.identity(out.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].identity(out.array); out._dirty = true; return out; }; @@ -20783,7 +19285,7 @@ Quaternion.identity = function (out) { * @return {clay.Quaternion} */ Quaternion.invert = function (out, a) { - quat.invert(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].invert(out.array, a.array); out._dirty = true; return out; }; @@ -20794,7 +19296,7 @@ Quaternion.invert = function (out, a) { * @return {number} */ Quaternion.dot = function (a, b) { - return quat.dot(a.array, b.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].dot(a.array, b.array); }; /** @@ -20802,7 +19304,7 @@ Quaternion.dot = function (a, b) { * @return {number} */ Quaternion.len = function (a) { - return quat.length(a.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].length(a.array); }; // Quaternion.length = Quaternion.len; @@ -20815,7 +19317,7 @@ Quaternion.len = function (a) { * @return {clay.Quaternion} */ Quaternion.lerp = function (out, a, b, t) { - quat.lerp(out.array, a.array, b.array, t); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].lerp(out.array, a.array, b.array, t); out._dirty = true; return out; }; @@ -20828,7 +19330,7 @@ Quaternion.lerp = function (out, a, b, t) { * @return {clay.Quaternion} */ Quaternion.slerp = function (out, a, b, t) { - quat.slerp(out.array, a.array, b.array, t); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].slerp(out.array, a.array, b.array, t); out._dirty = true; return out; }; @@ -20840,7 +19342,7 @@ Quaternion.slerp = function (out, a, b, t) { * @return {clay.Quaternion} */ Quaternion.mul = function (out, a, b) { - quat.multiply(out.array, a.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].multiply(out.array, a.array, b.array); out._dirty = true; return out; }; @@ -20861,7 +19363,7 @@ Quaternion.multiply = Quaternion.mul; * @return {clay.Quaternion} */ Quaternion.rotateX = function (out, a, rad) { - quat.rotateX(out.array, a.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotateX(out.array, a.array, rad); out._dirty = true; return out; }; @@ -20873,7 +19375,7 @@ Quaternion.rotateX = function (out, a, rad) { * @return {clay.Quaternion} */ Quaternion.rotateY = function (out, a, rad) { - quat.rotateY(out.array, a.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotateY(out.array, a.array, rad); out._dirty = true; return out; }; @@ -20885,7 +19387,7 @@ Quaternion.rotateY = function (out, a, rad) { * @return {clay.Quaternion} */ Quaternion.rotateZ = function (out, a, rad) { - quat.rotateZ(out.array, a.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotateZ(out.array, a.array, rad); out._dirty = true; return out; }; @@ -20897,7 +19399,7 @@ Quaternion.rotateZ = function (out, a, rad) { * @return {clay.Quaternion} */ Quaternion.setAxisAngle = function (out, axis, rad) { - quat.setAxisAngle(out.array, axis.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].setAxisAngle(out.array, axis.array, rad); out._dirty = true; return out; }; @@ -20908,7 +19410,7 @@ Quaternion.setAxisAngle = function (out, axis, rad) { * @return {clay.Quaternion} */ Quaternion.normalize = function (out, a) { - quat.normalize(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].normalize(out.array, a.array); out._dirty = true; return out; }; @@ -20918,7 +19420,7 @@ Quaternion.normalize = function (out, a) { * @return {number} */ Quaternion.sqrLen = function (a) { - return quat.sqrLen(a.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].sqrLen(a.array); }; /** @@ -20934,7 +19436,7 @@ Quaternion.squaredLength = Quaternion.sqrLen; * @return {clay.Quaternion} */ Quaternion.fromMat3 = function (out, m) { - quat.fromMat3(out.array, m.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].fromMat3(out.array, m.array); out._dirty = true; return out; }; @@ -20947,7 +19449,7 @@ Quaternion.fromMat3 = function (out, m) { * @return {clay.Quaternion} */ Quaternion.setAxes = function (out, view, right, up) { - quat.setAxes(out.array, view.array, right.array, up.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].setAxes(out.array, view.array, right.array, up.array); out._dirty = true; return out; }; @@ -20959,7 +19461,7 @@ Quaternion.setAxes = function (out, view, right, up) { * @return {clay.Quaternion} */ Quaternion.rotationTo = function (out, a, b) { - quat.rotationTo(out.array, a.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotationTo(out.array, a.array, b.array); out._dirty = true; return out; }; @@ -21029,28 +19531,144 @@ Quaternion.fromEuler = function (out, v, order) { } }; -/* harmony default export */ __webpack_exports__["a"] = (Quaternion); +/* harmony default export */ __webpack_exports__["a"] = (Quaternion); + + +/***/ }), +/* 57 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +var DIRTY_PREFIX = '__dt__'; + +var Cache = function () { + + this._contextId = 0; + + this._caches = []; + + this._context = {}; +}; + +Cache.prototype = { + + use: function (contextId, documentSchema) { + var caches = this._caches; + if (!caches[contextId]) { + caches[contextId] = {}; + + if (documentSchema) { + caches[contextId] = documentSchema(); + } + } + this._contextId = contextId; + + this._context = caches[contextId]; + }, + + put: function (key, value) { + this._context[key] = value; + }, + + get: function (key) { + return this._context[key]; + }, + + dirty: function (field) { + field = field || ''; + var key = DIRTY_PREFIX + field; + this.put(key, true); + }, + + dirtyAll: function (field) { + field = field || ''; + var key = DIRTY_PREFIX + field; + var caches = this._caches; + for (var i = 0; i < caches.length; i++) { + if (caches[i]) { + caches[i][key] = true; + } + } + }, + + fresh: function (field) { + field = field || ''; + var key = DIRTY_PREFIX + field; + this.put(key, false); + }, + + freshAll: function (field) { + field = field || ''; + var key = DIRTY_PREFIX + field; + var caches = this._caches; + for (var i = 0; i < caches.length; i++) { + if (caches[i]) { + caches[i][key] = false; + } + } + }, + + isDirty: function (field) { + field = field || ''; + var key = DIRTY_PREFIX + field; + var context = this._context; + return !context.hasOwnProperty(key) + || context[key] === true; + }, + + deleteContext: function (contextId) { + delete this._caches[contextId]; + this._context = {}; + }, + + delete: function (key) { + delete this._context[key]; + }, + + clearAll: function () { + this._caches = {}; + }, + + getContext: function () { + return this._context; + }, + + eachContext : function (cb, context) { + var keys = Object.keys(this._caches); + keys.forEach(function (key) { + cb && cb.call(context, key); + }); + }, + + miss: function (key) { + return ! this._context.hasOwnProperty(key); + } +}; + +Cache.prototype.constructor = Cache; + +/* harmony default export */ __webpack_exports__["a"] = (Cache); /***/ }), -/* 51 */ +/* 58 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(30); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Frustum__ = __webpack_require__(52); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_Ray__ = __webpack_require__(49); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4__dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(35); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Matrix4__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Frustum__ = __webpack_require__(59); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_Ray__ = __webpack_require__(54); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__ = __webpack_require__(33); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__glmatrix_vec3__ = __webpack_require__(12); + + -var vec3 = __WEBPACK_IMPORTED_MODULE_4__dep_glmatrix___default.a.vec3; -var vec4 = __WEBPACK_IMPORTED_MODULE_4__dep_glmatrix___default.a.vec4; /** * @constructor clay.Camera @@ -21134,23 +19752,23 @@ var Camera = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(funct * @return {clay.Ray} */ castRay: (function () { - var v4 = vec4.create(); + var v4 = __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].create(); return function (ndc, out) { var ray = out !== undefined ? out : new __WEBPACK_IMPORTED_MODULE_3__math_Ray__["a" /* default */](); var x = ndc.array[0]; var y = ndc.array[1]; - vec4.set(v4, x, y, -1, 1); - vec4.transformMat4(v4, v4, this.invProjectionMatrix.array); - vec4.transformMat4(v4, v4, this.worldTransform.array); - vec3.scale(ray.origin.array, v4, 1 / v4[3]); - - vec4.set(v4, x, y, 1, 1); - vec4.transformMat4(v4, v4, this.invProjectionMatrix.array); - vec4.transformMat4(v4, v4, this.worldTransform.array); - vec3.scale(v4, v4, 1 / v4[3]); - vec3.sub(ray.direction.array, v4, ray.origin.array); - - vec3.normalize(ray.direction.array, ray.direction.array); + __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].set(v4, x, y, -1, 1); + __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].transformMat4(v4, v4, this.invProjectionMatrix.array); + __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].transformMat4(v4, v4, this.worldTransform.array); + __WEBPACK_IMPORTED_MODULE_5__glmatrix_vec3__["a" /* default */].scale(ray.origin.array, v4, 1 / v4[3]); + + __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].set(v4, x, y, 1, 1); + __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].transformMat4(v4, v4, this.invProjectionMatrix.array); + __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].transformMat4(v4, v4, this.worldTransform.array); + __WEBPACK_IMPORTED_MODULE_5__glmatrix_vec3__["a" /* default */].scale(v4, v4, 1 / v4[3]); + __WEBPACK_IMPORTED_MODULE_5__glmatrix_vec3__["a" /* default */].sub(ray.direction.array, v4, ray.origin.array); + + __WEBPACK_IMPORTED_MODULE_5__glmatrix_vec3__["a" /* default */].normalize(ray.direction.array, ray.direction.array); ray.direction._dirty = true; ray.origin._dirty = true; @@ -21170,25 +19788,21 @@ var Camera = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(funct /***/ }), -/* 52 */ +/* 59 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__BoundingBox__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Plane__ = __webpack_require__(68); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3__dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BoundingBox__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Plane__ = __webpack_require__(74); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__ = __webpack_require__(12); -var vec3 = __WEBPACK_IMPORTED_MODULE_3__dep_glmatrix___default.a.vec3; - -var vec3Set = vec3.set; -var vec3Copy = vec3.copy; -var vec3TranformMat4 = vec3.transformMat4; +var vec3Set = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].set; +var vec3Copy = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].copy; +var vec3TranformMat4 = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].transformMat4; var mathMin = Math.min; var mathMax = Math.max; /** @@ -21204,14 +19818,14 @@ var Frustum = function() { this.planes = []; for (var i = 0; i < 6; i++) { - this.planes.push(new __WEBPACK_IMPORTED_MODULE_2__Plane__["a" /* default */]()); + this.planes.push(new __WEBPACK_IMPORTED_MODULE_1__Plane__["a" /* default */]()); } /** * Bounding box of frustum * @type {clay.BoundingBox} */ - this.boundingBox = new __WEBPACK_IMPORTED_MODULE_1__BoundingBox__["a" /* default */](); + this.boundingBox = new __WEBPACK_IMPORTED_MODULE_0__BoundingBox__["a" /* default */](); /** * Eight vertices of frustum @@ -21219,7 +19833,7 @@ var Frustum = function() { */ this.vertices = []; for (var i = 0; i < 8; i++) { - this.vertices[i] = vec3.fromValues(0, 0, 0); + this.vertices[i] = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].fromValues(0, 0, 0); } }; @@ -21328,7 +19942,7 @@ Frustum.prototype = { */ getTransformedBoundingBox: (function() { - var tmpVec3 = vec3.create(); + var tmpVec3 = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].create(); return function(bbox, matrix) { var vertices = this.vertices; @@ -21367,7 +19981,7 @@ Frustum.prototype = { /***/ }), -/* 53 */ +/* 60 */ /***/ (function(module, exports) { // Simple LRU cache use doubly linked list @@ -21574,18 +20188,18 @@ var _default = LRU; module.exports = _default; /***/ }), -/* 54 */ +/* 61 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__TextureCube__ = __webpack_require__(24); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_request__ = __webpack_require__(112); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__prePass_EnvironmentMap__ = __webpack_require__(55); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__plugin_Skydome__ = __webpack_require__(56); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Scene__ = __webpack_require__(32); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__dds__ = __webpack_require__(114); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__hdr__ = __webpack_require__(115); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__TextureCube__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_vendor__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__prePass_EnvironmentMap__ = __webpack_require__(62); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__plugin_Skydome__ = __webpack_require__(75); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Scene__ = __webpack_require__(36); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__dds__ = __webpack_require__(122); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__hdr__ = __webpack_require__(123); @@ -21827,7 +20441,7 @@ var textureUtil = { }, _fetchTexture: function (path, onsuccess, onerror) { - __WEBPACK_IMPORTED_MODULE_2__core_request__["a" /* default */].get({ + __WEBPACK_IMPORTED_MODULE_2__core_vendor__["a" /* default */].request.get({ url: path, responseType: 'arraybuffer', onload: onsuccess, @@ -21901,13 +20515,13 @@ var textureUtil = { /***/ }), -/* 55 */ +/* 62 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__camera_Perspective__ = __webpack_require__(36); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__camera_Perspective__ = __webpack_require__(41); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__FrameBuffer__ = __webpack_require__(10); @@ -22015,1069 +20629,1612 @@ var EnvironmentMapPass = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default var n = this.texture.width; var fov = 2 * Math.atan(n / (n - 0.5)) / Math.PI * 180; - for (var i = 0; i < 6; i++) { - var target = targets[i]; - var camera = this._cameras[target]; - __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].copy(camera.position, this.position); + for (var i = 0; i < 6; i++) { + var target = targets[i]; + var camera = this._cameras[target]; + __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].copy(camera.position, this.position); + + camera.far = this.far; + camera.near = this.near; + camera.fov = fov; + + if (this.shadowMapPass) { + camera.update(); + + // update boundingBoxLastFrame + var bbox = scene.getBoundingBox(); + bbox.applyTransform(camera.viewMatrix); + scene.viewBoundingBoxLastFrame.copy(bbox); + + this.shadowMapPass.render(renderer, scene, camera, true); + } + this._frameBuffer.attach( + this.texture, _gl.COLOR_ATTACHMENT0, + _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i + ); + this._frameBuffer.bind(renderer); + renderer.render(scene, camera, true); + this._frameBuffer.unbind(renderer); + } + }, + /** + * @param {clay.Renderer} renderer + */ + dispose: function (renderer) { + this._frameBuffer.dispose(renderer); + } +}); + +/* harmony default export */ __webpack_exports__["a"] = (EnvironmentMapPass); + + +/***/ }), +/* 63 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geometry_Sprites__ = __webpack_require__(165); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__shader_labels_glsl_js__ = __webpack_require__(166); + + + + +__WEBPACK_IMPORTED_MODULE_0__graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_2__shader_labels_glsl_js__["a" /* default */]); + +/* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__graphicGL__["a" /* default */].Mesh.extend(function () { + var geometry = new __WEBPACK_IMPORTED_MODULE_1__geometry_Sprites__["a" /* default */]({ + dynamic: true + }); + var material = new __WEBPACK_IMPORTED_MODULE_0__graphicGL__["a" /* default */].Material({ + shader: __WEBPACK_IMPORTED_MODULE_0__graphicGL__["a" /* default */].createShader('ecgl.labels'), + transparent: true, + depthMask: false + }); + + return { + geometry: geometry, + material: material, + culling: false, + castShadow: false, + ignorePicking: true + }; +})); + +/***/ }), +/* 64 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_earcut__ = __webpack_require__(204); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(25); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_retrieve__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_dep_glmatrix__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__util_geometry_trianglesSortMixin__ = __webpack_require__(65); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__LabelsBuilder__ = __webpack_require__(66); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_shader_lines3D_glsl_js__ = __webpack_require__(46); + + + + + + + + + + +var vec3 = __WEBPACK_IMPORTED_MODULE_5_claygl_src_dep_glmatrix__["a" /* default */].vec3; + +__WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_8__util_shader_lines3D_glsl_js__["a" /* default */]); + +function Geo3DBuilder(api) { + + this.rootNode = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node(); + + // Cache triangulation result + this._triangulationResults = {}; + + this._shadersMap = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].COMMON_SHADERS.reduce(function (obj, shaderName) { + obj[shaderName] = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.' + shaderName); + return obj; + }, {}); + + this._linesShader = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.meshLines3D'); + + var groundMaterials = {}; + __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].COMMON_SHADERS.forEach(function (shading) { + groundMaterials[shading] = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({ + shader: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.' + shading) + }); + }); + this._groundMaterials = groundMaterials; + + this._groundMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({ + geometry: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].PlaneGeometry({ dynamic: true }), + castShadow: false, + renderNormal: true, + $ignorePicking: true + }); + this._groundMesh.rotation.rotateX(-Math.PI / 2); + + this._labelsBuilder = new __WEBPACK_IMPORTED_MODULE_7__LabelsBuilder__["a" /* default */](512, 512, api); + + // Give a large render order. + this._labelsBuilder.getMesh().renderOrder = 100; + this._labelsBuilder.getMesh().material.depthTest = false; + + this.rootNode.add(this._labelsBuilder.getMesh()); + + this._initMeshes(); + + this._api = api; +} + +Geo3DBuilder.prototype = { + + constructor: Geo3DBuilder, + + // Which dimension to extrude. Y or Z + extrudeY: true, + + update: function (componentModel, ecModel, api, start, end) { + + var data = componentModel.getData(); + + if (start == null) { + start = 0; + } + if (end == null) { + end = data.count(); + } + + this._startIndex = start; + this._endIndex = end - 1; + + this._triangulation(componentModel, start, end); + + var shader = this._getShader(componentModel.get('shading')); + + this._prepareMesh(componentModel, shader, api, start, end); + + this.rootNode.updateWorldTransform(); + + this._updateRegionMesh(componentModel, api, start, end); + + var coordSys = componentModel.coordinateSystem; + // PENDING + if (coordSys.type === 'geo3D') { + this._updateGroundPlane(componentModel, coordSys, api); + } + + var self = this; + this._labelsBuilder.updateData(data, start, end); + this._labelsBuilder.getLabelPosition = function (dataIndex, positionDesc, distance) { + var name = data.getName(dataIndex); + + var center; + var height = distance; + if (coordSys.type === 'geo3D') { + var region = coordSys.getRegion(name); + if (!region) { + return [NaN, NaN, NaN]; + } + center = region.center; + var pos = coordSys.dataToPoint([center[0], center[1], height]); + return pos; + } + else { + var tmp = self._triangulationResults[dataIndex - self._startIndex]; + var center = self.extrudeY ? [ + (tmp.max[0] + tmp.min[0]) / 2, + tmp.max[1] + height, + (tmp.max[2] + tmp.min[2]) / 2 + ] : [ + (tmp.max[0] + tmp.min[0]) / 2, + (tmp.max[1] + tmp.min[1]) / 2, + tmp.max[2] + height + ]; + } + }; + + this._data = data; + + this._labelsBuilder.updateLabels(); + + this._updateDebugWireframe(componentModel); + + // Reset some state. + this._lastHoverDataIndex = 0; + }, + + _initMeshes: function () { + var self = this; + function createPolygonMesh() { + var mesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({ + name: 'Polygon', + material: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({ + shader: self._shadersMap.lambert + }), + geometry: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Geometry({ + sortTriangles: true, + dynamic: true + }), + // TODO Disable culling + culling: false, + ignorePicking: true, + // Render normal in normal pass + renderNormal: true + }); + __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.extend(mesh.geometry, __WEBPACK_IMPORTED_MODULE_6__util_geometry_trianglesSortMixin__["a" /* default */]); + return mesh; + } + + var polygonMesh = createPolygonMesh(); + + var linesMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({ + material: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({ + shader: this._linesShader + }), + castShadow: false, + ignorePicking: true, + $ignorePicking: true, + geometry: new __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__["a" /* default */]({ + useNativeLine: false + }) + }); + + this.rootNode.add(polygonMesh); + this.rootNode.add(linesMesh); + + polygonMesh.material.define('both', 'VERTEX_COLOR'); + polygonMesh.material.define('fragment', 'DOUBLE_SIDED'); + + this._polygonMesh = polygonMesh; + this._linesMesh = linesMesh; + + this.rootNode.add(this._groundMesh); + }, + + _getShader: function (shading) { + var shader = this._shadersMap[shading]; + if (!shader) { + if (true) { + console.warn('Unkown shading ' + shading); + } + // Default use lambert shader. + shader = this._shadersMap.lambert; + } + shader.__shading = shading; + return shader; + }, + + _prepareMesh: function (componentModel, shader, api, start, end) { + var polygonVertexCount = 0; + var polygonTriangleCount = 0; + var linesVertexCount = 0; + var linesTriangleCount = 0; + // TODO Lines + for (var idx = start; idx < end; idx++) { + var polyInfo = this._getRegionPolygonInfo(idx); + var lineInfo = this._getRegionLinesInfo(idx, componentModel, this._linesMesh.geometry); + polygonVertexCount += polyInfo.vertexCount; + polygonTriangleCount += polyInfo.triangleCount; + linesVertexCount += lineInfo.vertexCount; + linesTriangleCount += lineInfo.triangleCount; + } + + var polygonMesh = this._polygonMesh; + var polygonGeo = polygonMesh.geometry; + ['position', 'normal', 'texcoord0', 'color'].forEach(function (attrName) { + polygonGeo.attributes[attrName].init(polygonVertexCount); + }); + polygonGeo.indices = polygonVertexCount > 0xffff ? new Uint32Array(polygonTriangleCount * 3) : new Uint16Array(polygonTriangleCount * 3); + + if (polygonMesh.material.shader !== shader) { + polygonMesh.material.attachShader(shader, true); + } + __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].setMaterialFromModel(shader.__shading, polygonMesh.material, componentModel, api); + + if (linesVertexCount > 0) { + this._linesMesh.geometry.resetOffset(); + this._linesMesh.geometry.setVertexCount(linesVertexCount); + this._linesMesh.geometry.setTriangleCount(linesTriangleCount); + } + + // Indexing data index from vertex index. + this._dataIndexOfVertex = new Uint32Array(polygonVertexCount); + // Indexing vertex index range from data index + this._vertexRangeOfDataIndex = new Uint32Array((end - start) * 2); + }, + + _updateRegionMesh: function (componentModel, api, start, end) { + + var data = componentModel.getData(); + + var vertexOffset = 0; + var triangleOffset = 0; + + // Materials configurations. + var hasTranparentRegion = false; + + var polygonMesh = this._polygonMesh; + var linesMesh = this._linesMesh; + + for (var dataIndex = start; dataIndex < end; dataIndex++) { + // Get bunch of visual properties. + var regionModel = componentModel.getRegionModel(dataIndex); + var itemStyleModel = regionModel.getModel('itemStyle'); + var color = itemStyleModel.get('color'); + var opacity = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(itemStyleModel.get('opacity'), 1.0); + + // Use visual color if it is encoded by visualMap component + var visualColor = data.getItemVisual(dataIndex, 'color', true); + if (visualColor != null && data.hasValue(dataIndex)) { + color = visualColor; + } + // Set color, opacity to visual for label usage. + data.setItemVisual(dataIndex, 'color', color); + data.setItemVisual(dataIndex, 'opacity', opacity); + + color = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color); + var borderColor = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(itemStyleModel.get('borderColor')); + + color[3] *= opacity; + borderColor[3] *= opacity; + + var isTransparent = color[3] < 0.99; + + polygonMesh.material.set('color', [1,1,1,1]); + hasTranparentRegion = hasTranparentRegion || isTransparent; + + var regionHeight = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(regionModel.get('height', true), componentModel.get('regionHeight')); + + var newOffsets = this._updatePolygonGeometry( + componentModel, polygonMesh.geometry, dataIndex, regionHeight, + vertexOffset, triangleOffset, color + ); + + for (var i = vertexOffset; i < newOffsets.vertexOffset; i++) { + this._dataIndexOfVertex[i] = dataIndex; + } + this._vertexRangeOfDataIndex[(dataIndex - start) * 2] = vertexOffset; + this._vertexRangeOfDataIndex[(dataIndex - start) * 2 + 1] = newOffsets.vertexOffset; + + vertexOffset = newOffsets.vertexOffset; + triangleOffset = newOffsets.triangleOffset; + + // Update lines. + var lineWidth = itemStyleModel.get('borderWidth'); + var hasLine = lineWidth > 0; + if (hasLine) { + lineWidth *= api.getDevicePixelRatio(); + this._updateLinesGeometry( + linesMesh.geometry, componentModel, dataIndex, regionHeight, lineWidth, + componentModel.coordinateSystem.transform + ); + } + linesMesh.invisible = !hasLine; + linesMesh.material.set({ + color: borderColor + }); + } + + var polygonMesh = this._polygonMesh; + polygonMesh.material.transparent = hasTranparentRegion; + polygonMesh.material.depthMask = !hasTranparentRegion; + polygonMesh.geometry.updateBoundingBox(); + + polygonMesh.frontFace = this.extrudeY ? __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh.CCW : __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh.CW; + + // Update tangents + if (polygonMesh.material.get('normalMap')) { + polygonMesh.geometry.generateTangents(); + } + + polygonMesh.seriesIndex = componentModel.seriesIndex; + + polygonMesh.on('mousemove', this._onmousemove, this); + polygonMesh.on('mouseout', this._onmouseout, this); + }, + + _updateDebugWireframe: function (componentModel) { + var debugWireframeModel = componentModel.getModel('debug.wireframe'); + + // TODO Unshow + if (debugWireframeModel.get('show')) { + var color = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor( + debugWireframeModel.get('lineStyle.color') || 'rgba(0,0,0,0.5)' + ); + var width = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull( + debugWireframeModel.get('lineStyle.width'), 1 + ); + + // TODO Will cause highlight wrong + var mesh = this._polygonMesh; + mesh.geometry.generateBarycentric(); + mesh.material.define('both', 'WIREFRAME_TRIANGLE'); + mesh.material.set('wireframeLineColor', color); + mesh.material.set('wireframeLineWidth', width); + } + }, + + _onmousemove: function (e) { + var dataIndex = this._dataIndexOfVertex[e.triangle[0]]; + if (dataIndex == null) { + dataIndex = -1; + } + if (dataIndex !== this._lastHoverDataIndex) { + this.downplay(this._lastHoverDataIndex); + this.highlight(dataIndex); + this._labelsBuilder.updateLabels([dataIndex]); + } + this._lastHoverDataIndex = dataIndex; + this._polygonMesh.dataIndex = dataIndex; + }, + + _onmouseout: function (e) { + if (e.target) { + this.downplay(this._lastHoverDataIndex); + this._lastHoverDataIndex = -1; + this._polygonMesh.dataIndex = -1; + } + + this._labelsBuilder.updateLabels([]); + }, + + _updateGroundPlane: function (componentModel, geo3D, api) { + var groundModel = componentModel.getModel('groundPlane', componentModel); + this._groundMesh.invisible = !groundModel.get('show', true); + if (this._groundMesh.invisible) { + return; + } + + var shading = componentModel.get('shading'); + var material = this._groundMaterials[shading]; + if (!material) { + if (true) { + console.warn('Unkown shading ' + shading); + } + material = this._groundMaterials.lambert; + } + + __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].setMaterialFromModel(shading, material, groundModel, api); + if (material.get('normalMap')) { + this._groundMesh.geometry.generateTangents(); + } + + this._groundMesh.material = material; + this._groundMesh.material.set('color', __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(groundModel.get('color'))); - camera.far = this.far; - camera.near = this.near; - camera.fov = fov; + this._groundMesh.scale.set(geo3D.size[0], geo3D.size[2], 1); + }, - if (this.shadowMapPass) { - camera.update(); + _triangulation: function (componentModel, start, end) { + this._triangulationResults = []; - // update boundingBoxLastFrame - var bbox = scene.getBoundingBox(); - bbox.applyTransform(camera.viewMatrix); - scene.viewBoundingBoxLastFrame.copy(bbox); + var minAll = [Infinity, Infinity, Infinity]; + var maxAll = [-Infinity, -Infinity, -Infinity]; - this.shadowMapPass.render(renderer, scene, camera, true); + var coordSys = componentModel.coordinateSystem; + + for (var idx = start; idx < end; idx++) { + var polygons = []; + var polygonCoords = componentModel.getRegionPolygonCoords(idx); + for (var i = 0; i < polygonCoords.length; i++) { + var exterior = polygonCoords[i].exterior; + var interiors = polygonCoords[i].interiors; + var points = []; + var holes = []; + if (exterior.length < 3) { + continue; + } + var offset = 0; + for (var j = 0; j < exterior.length; j++) { + var p = exterior[j]; + points[offset++] = p[0]; + points[offset++] = p[1]; + } + + for (var j = 0; j < interiors.length; j++) { + if (interiors[j].length < 3) { + continue; + } + var startIdx = points.length / 2; + for (var k = 0; k < interiors[j].length; k++) { + var p = interiors[j][k]; + points.push(p[0]); + points.push(p[1]); + } + + holes.push(startIdx); + } + var triangles = Object(__WEBPACK_IMPORTED_MODULE_2__util_earcut__["a" /* default */])(points, holes); + + var points3 = new Float64Array(points.length / 2 * 3); + var pos = []; + var min = [Infinity, Infinity, Infinity]; + var max = [-Infinity, -Infinity, -Infinity]; + var off3 = 0; + for (var j = 0; j < points.length;) { + vec3.set(pos, points[j++], 0, points[j++]); + if (coordSys && coordSys.transform) { + vec3.transformMat4(pos, pos, coordSys.transform); + } + vec3.min(min, min, pos); + vec3.max(max, max, pos); + points3[off3++] = pos[0]; + points3[off3++] = pos[1]; + points3[off3++] = pos[2]; + } + vec3.min(minAll, minAll, min); + vec3.max(maxAll, maxAll, max); + polygons.push({ + points: points3, + indices: triangles, + min: min, + max: max + }); } - this._frameBuffer.attach( - this.texture, _gl.COLOR_ATTACHMENT0, - _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i - ); - this._frameBuffer.bind(renderer); - renderer.render(scene, camera, true); - this._frameBuffer.unbind(renderer); + this._triangulationResults.push(polygons); } + + this._geoBoundingBox = [minAll, maxAll]; }, + /** - * @param {clay.Renderer} renderer + * Get region vertex and triangle count */ - dispose: function (renderer) { - this._frameBuffer.dispose(renderer); - } -}); - -/* harmony default export */ __webpack_exports__["a"] = (EnvironmentMapPass); + _getRegionPolygonInfo: function (idx) { + var polygons = this._triangulationResults[idx - this._startIndex]; -/***/ }), -/* 56 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + var sideVertexCount = 0; + var sideTriangleCount = 0; -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Mesh__ = __webpack_require__(31); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geometry_Sphere__ = __webpack_require__(69); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Shader__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Material__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__shader_source_skydome_glsl_js__ = __webpack_require__(113); + for (var i = 0; i < polygons.length; i++) { + sideVertexCount += polygons[i].points.length / 3; + sideTriangleCount += polygons[i].indices.length / 3; + } + var vertexCount = sideVertexCount * 2 + sideVertexCount * 4; + var triangleCount = sideTriangleCount * 2 + sideVertexCount * 2; + return { + vertexCount: vertexCount, + triangleCount: triangleCount + }; + }, + _updatePolygonGeometry: function ( + componentModel, geometry, dataIndex, regionHeight, + vertexOffset, triangleOffset, color + ) { + // FIXME + var projectUVOnGround = componentModel.get('projectUVOnGround'); + var positionAttr = geometry.attributes.position; + var normalAttr = geometry.attributes.normal; + var texcoordAttr = geometry.attributes.texcoord0; + var colorAttr = geometry.attributes.color; + var polygons = this._triangulationResults[dataIndex - this._startIndex]; + var hasColor = colorAttr.value && color; -__WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_4__shader_source_skydome_glsl_js__["a" /* default */]); -/** - * @constructor clay.plugin.Skydome - * - * @example - * var skyTex = new clay.Texture2D(); - * skyTex.load('assets/textures/sky.jpg'); - * var skydome = new clay.plugin.Skydome({ - * scene: scene - * }); - * skydome.material.set('diffuseMap', skyTex); -*/ -var Skydome = __WEBPACK_IMPORTED_MODULE_0__Mesh__["a" /* default */].extend(function () { + var indices = geometry.indices; - var skydomeShader = new __WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */](__WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */].source('clay.skydome.vertex'), __WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */].source('clay.skydome.fragment')); + var extrudeCoordIndex = this.extrudeY ? 1 : 2; + var sideCoordIndex = this.extrudeY ? 2 : 1; - var material = new __WEBPACK_IMPORTED_MODULE_3__Material__["a" /* default */]({ - shader: skydomeShader, - depthMask: false - }); + var scale = [ + this.rootNode.worldTransform.x.len(), + this.rootNode.worldTransform.y.len(), + this.rootNode.worldTransform.z.len() + ]; - return { - /** - * @type {clay.Scene} - * @memberOf clay.plugin.Skydome# - */ - scene: null, + var min = vec3.mul([], this._geoBoundingBox[0], scale); + var max = vec3.mul([], this._geoBoundingBox[1], scale); + var maxDimSize = Math.max(max[0] - min[0], max[2] - min[2]); - geometry: new __WEBPACK_IMPORTED_MODULE_1__geometry_Sphere__["a" /* default */]({ - widthSegments: 30, - heightSegments: 30, - // thetaLength: Math.PI / 2 - }), + function addVertices(polygon, y, insideOffset) { + var points = polygon.points; - material: material, + var pointsLen = points.length; + var currentPosition = []; + var uv = []; - environmentMap: null, + for (var k = 0; k < pointsLen; k += 3) { + currentPosition[0] = points[k]; + currentPosition[extrudeCoordIndex] = y; + currentPosition[sideCoordIndex] = points[k + 2]; - culling: false - }; -}, function () { - var scene = this.scene; - if (scene) { - this.attachScene(scene); - } + uv[0] = (points[k] * scale[0] - min[0]) / maxDimSize; + uv[1] = (points[k + 2] * scale[sideCoordIndex] - min[2]) / maxDimSize; - if (this.environmentMap) { - this.setEnvironmentMap(this.environmentMap); - } -}, { - /** - * Attach the skybox to the scene - * @param {clay.Scene} scene - * @memberOf clay.plugin.Skydome.prototype - */ - attachScene: function (scene) { - if (this.scene) { - this.detachScene(); + positionAttr.set(vertexOffset, currentPosition); + if (hasColor) { + colorAttr.set(vertexOffset, color); + } + texcoordAttr.set(vertexOffset++, uv); + } } - scene.skydome = this; - this.scene = scene; - scene.on('beforerender', this._beforeRenderScene, this); - }, - /** - * Detach from scene - * @memberOf clay.plugin.Skydome.prototype - */ - detachScene: function () { - if (this.scene) { - this.scene.off('beforerender', this._beforeRenderScene); - this.scene.skydome = null; - } - this.scene = null; - }, + function buildTopBottom(polygon, y, insideOffset) { - _beforeRenderScene: function (renderer, scene, camera) { - this.position.copy(camera.getWorldPosition()); - this.update(); - renderer.renderPass([this], camera); - }, + var startVertexOffset = vertexOffset; - setEnvironmentMap: function (envMap) { - this.material.set('environmentMap', envMap); - }, + addVertices(polygon, y, insideOffset); - getEnvironmentMap: function () { - return this.material.get('environmentMap'); - }, + var len = polygon.indices.length; + for (var k = 0; k < len; k++) { + indices[triangleOffset * 3 + k] = polygon.indices[k] + startVertexOffset; + } + triangleOffset += polygon.indices.length / 3; + } - dispose: function (renderer) { - this.detachScene(); - this.geometry.dispose(renderer); - } -}); + var normalTop = this.extrudeY ? [0, 1, 0] : [0, 0, 1]; + var normalBottom = vec3.negate([], normalTop); + for (var p = 0; p < polygons.length; p++) { + var startVertexOffset = vertexOffset; + var polygon = polygons[p]; + // BOTTOM + buildTopBottom(polygon, 0, 0); + // TOP + buildTopBottom(polygon, regionHeight, 0); -/* harmony default export */ __webpack_exports__["a"] = (Skydome); + var ringVertexCount = polygon.points.length / 3; + for (var v = 0; v < ringVertexCount; v++) { + normalAttr.set(startVertexOffset + v, normalBottom); + normalAttr.set(startVertexOffset + v + ringVertexCount, normalTop); + } + var quadToTriangle = [0, 3, 1, 1, 3, 2]; -/***/ }), -/* 57 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + var quadPos = [[], [], [], []]; + var a = []; + var b = []; + var normal = []; + var uv = []; + var len = 0; + for (var v = 0; v < ringVertexCount; v++) { + var next = (v + 1) % ringVertexCount; -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Mesh__ = __webpack_require__(31); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geometry_Cube__ = __webpack_require__(71); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Shader__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Material__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__shader_source_skybox_glsl_js__ = __webpack_require__(119); -// TODO Should not derived from mesh? + var dx = (polygon.points[next * 3] - polygon.points[v * 3]) * scale[0]; + var dy = (polygon.points[next * 3 + 2] - polygon.points[v * 3 + 2]) * scale[sideCoordIndex]; + var sideLen = Math.sqrt(dx * dx + dy * dy); + // 0----1 + // 3----2 + for (var k = 0; k < 4; k++) { + var isCurrent = (k === 0 || k === 3); + var idx3 = (isCurrent ? v : next) * 3; + quadPos[k][0] = polygon.points[idx3]; + quadPos[k][extrudeCoordIndex] = k > 1 ? regionHeight : 0; + quadPos[k][sideCoordIndex] = polygon.points[idx3 + 2]; + positionAttr.set(vertexOffset + k, quadPos[k]); + if (projectUVOnGround) { + uv[0] = (polygon.points[idx3] * scale[0] - min[0]) / maxDimSize; + uv[1] = (polygon.points[idx3 + 2] * scale[sideCoordIndex] - min[sideCoordIndex]) / maxDimSize; + } + else { + uv[0] = (isCurrent ? len : (len + sideLen)) / maxDimSize; + uv[1] = (quadPos[k][extrudeCoordIndex] * scale[extrudeCoordIndex] - min[extrudeCoordIndex]) / maxDimSize; + } + texcoordAttr.set(vertexOffset + k, uv); + } + vec3.sub(a, quadPos[1], quadPos[0]); + vec3.sub(b, quadPos[3], quadPos[0]); + vec3.cross(normal, a, b); + vec3.normalize(normal, normal); + for (var k = 0; k < 4; k++) { + normalAttr.set(vertexOffset + k, normal); + if (hasColor) { + colorAttr.set(vertexOffset + k, color); + } + } + for (var k = 0; k < 6; k++) { + indices[triangleOffset * 3 + k] = quadToTriangle[k] + vertexOffset; + } -__WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_4__shader_source_skybox_glsl_js__["a" /* default */]); -/** - * @constructor clay.plugin.Skybox - * - * @example - * var skyTex = new clay.TextureCube(); - * skyTex.load({ - * 'px': 'assets/textures/sky/px.jpg', - * 'nx': 'assets/textures/sky/nx.jpg' - * 'py': 'assets/textures/sky/py.jpg' - * 'ny': 'assets/textures/sky/ny.jpg' - * 'pz': 'assets/textures/sky/pz.jpg' - * 'nz': 'assets/textures/sky/nz.jpg' - * }); - * var skybox = new clay.plugin.Skybox({ - * scene: scene - * }); - * skybox.material.set('environmentMap', skyTex); - */ -var Skybox = __WEBPACK_IMPORTED_MODULE_0__Mesh__["a" /* default */].extend(function () { + vertexOffset += 4; + triangleOffset += 2; - var skyboxShader = new __WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */]({ - vertex: __WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */].source('clay.skybox.vertex'), - fragment: __WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */].source('clay.skybox.fragment') - }); - var material = new __WEBPACK_IMPORTED_MODULE_3__Material__["a" /* default */]({ - shader: skyboxShader, - depthMask: false - }); + len += sideLen; + } + } - return { - /** - * @type {clay.Scene} - * @memberOf clay.plugin.Skybox.prototype - */ - scene: null, + geometry.dirty(); - geometry: new __WEBPACK_IMPORTED_MODULE_1__geometry_Cube__["a" /* default */](), + return { + vertexOffset: vertexOffset, + triangleOffset: triangleOffset + }; + }, - material: material, + _getRegionLinesInfo: function (idx, componentModel, geometry) { + var vertexCount = 0; + var triangleCount = 0; - environmentMap: null, + var regionModel = componentModel.getRegionModel(idx); + var itemStyleModel = regionModel.getModel('itemStyle'); - culling: false - }; -}, function () { - var scene = this.scene; - if (scene) { - this.attachScene(scene); - } - if (this.environmentMap) { - this.setEnvironmentMap(this.environmentMap); - } -}, /** @lends clay.plugin.Skybox# */ { - /** - * Attach the skybox to the scene - * @param {clay.Scene} scene - */ - attachScene: function (scene) { - if (this.scene) { - this.detachScene(); + var lineWidth = itemStyleModel.get('borderWidth'); + if (lineWidth > 0) { + var polygonCoords = componentModel.getRegionPolygonCoords(idx); + polygonCoords.forEach(function (coords) { + var exterior = coords.exterior; + var interiors = coords.interiors; + vertexCount += geometry.getPolylineVertexCount(exterior); + triangleCount += geometry.getPolylineTriangleCount(exterior); + for (var i = 0; i < interiors.length; i++) { + vertexCount += geometry.getPolylineVertexCount(interiors[i]); + triangleCount += geometry.getPolylineTriangleCount(interiors[i]); + } + }, this); } - scene.skybox = this; - this.scene = scene; - scene.on('beforerender', this._beforeRenderScene, this); + return { + vertexCount: vertexCount, + triangleCount: triangleCount + }; + }, - /** - * Detach from scene - */ - detachScene: function () { - if (this.scene) { - this.scene.off('beforerender', this._beforeRenderScene); - this.scene.skybox = null; + + _updateLinesGeometry: function (geometry, componentModel, dataIndex, regionHeight, lineWidth, transform) { + function convertToPoints3(polygon) { + var points = new Float64Array(polygon.length * 3); + var offset = 0; + var pos = []; + for (var i = 0; i < polygon.length; i++) { + pos[0] = polygon[i][0]; + // Add a offset to avoid z-fighting + pos[1] = regionHeight + 0.1; + pos[2] = polygon[i][1]; + + if (transform) { + vec3.transformMat4(pos, pos, transform); + } + + points[offset++] = pos[0]; + points[offset++] = pos[1]; + points[offset++] = pos[2]; + } + return points; } - this.scene = null; - }, - /** - * Dispose skybox - * @param {clay.Renderer} renderer - */ - dispose: function (renderer) { - this.detachScene(); - this.geometry.dispose(renderer); - }, - /** - * Set environment map - * @param {clay.TextureCube} envMap - */ - setEnvironmentMap: function (envMap) { - this.material.set('environmentMap', envMap); + var whiteColor = [1, 1, 1, 1]; + var coords = componentModel.getRegionPolygonCoords(dataIndex); + coords.forEach(function (geo) { + var exterior = geo.exterior; + var interiors = geo.interiors; + + geometry.addPolyline(convertToPoints3(exterior), whiteColor, lineWidth); + + for (var i = 0; i < interiors.length; i++) { + geometry.addPolyline(convertToPoints3(interiors[i]), whiteColor, lineWidth); + } + }); }, - /** - * Get environment map - * @return {clay.TextureCube} - */ - getEnvironmentMap: function () { - return this.material.get('environmentMap'); + + highlight: function (dataIndex) { + var data = this._data; + if (!data) { + return; + } + + var itemModel = data.getItemModel(dataIndex); + var emphasisItemStyleModel = itemModel.getModel('emphasis.itemStyle'); + var emphasisColor = emphasisItemStyleModel.get('color'); + var emphasisOpacity = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull( + emphasisItemStyleModel.get('opacity'), + data.getItemVisual(dataIndex, 'opacity'), + 1 + ); + if (emphasisColor == null) { + var color = data.getItemVisual(dataIndex, 'color'); + emphasisColor = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.color.lift(color, -0.4); + } + if (emphasisOpacity == null) { + emphasisOpacity = data.getItemVisual(dataIndex, 'opacity'); + } + var colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(emphasisColor); + colorArr[3] *= emphasisOpacity; + + this._setColorOfDataIndex(data, dataIndex, colorArr); }, - _beforeRenderScene: function(renderer, scene, camera) { - this.renderSkybox(renderer, camera); + downplay: function (dataIndex) { + + var data = this._data; + if (!data) { + return; + } + + var color = data.getItemVisual(dataIndex, 'color'); + var opacity = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(data.getItemVisual(dataIndex, 'opacity'), 1); + + var colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color); + colorArr[3] *= opacity; + + this._setColorOfDataIndex(data, dataIndex, colorArr); }, - renderSkybox: function (renderer, camera) { - this.position.copy(camera.getWorldPosition()); - this.update(); - // Don't remember to disable blend - renderer.gl.disable(renderer.gl.BLEND); - if (this.material.get('lod') > 0) { - this.material.define('fragment', 'LOD'); + _setColorOfDataIndex: function (data, dataIndex, colorArr) { + if (dataIndex < this._startIndex && dataIndex > this._endIndex) { + return; } - else { - this.material.undefine('fragment', 'LOD'); + dataIndex -= this._startIndex; + for (var i = this._vertexRangeOfDataIndex[dataIndex * 2]; i < this._vertexRangeOfDataIndex[dataIndex * 2 + 1]; i++) { + this._polygonMesh.geometry.attributes.color.set(i, colorArr); } - renderer.renderPass([this], camera); + this._polygonMesh.geometry.dirty(); + this._api.getZr().refresh(); } -}); - -/* harmony default export */ __webpack_exports__["a"] = (Skybox); +}; +/* harmony default export */ __webpack_exports__["a"] = (Geo3DBuilder); /***/ }), -/* 58 */ +/* 65 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geometry_Sprites__ = __webpack_require__(156); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__shader_labels_glsl_js__ = __webpack_require__(157); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__ = __webpack_require__(97); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(6); +var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].vec3; +var p0 = vec3.create(); +var p1 = vec3.create(); +var p2 = vec3.create(); +// var cp = vec3.create(); -__WEBPACK_IMPORTED_MODULE_0__graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_2__shader_labels_glsl_js__["a" /* default */]); +/* harmony default export */ __webpack_exports__["a"] = ({ -/* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__graphicGL__["a" /* default */].Mesh.extend(function () { - var geometry = new __WEBPACK_IMPORTED_MODULE_1__geometry_Sprites__["a" /* default */]({ - dynamic: true - }); - var material = new __WEBPACK_IMPORTED_MODULE_0__graphicGL__["a" /* default */].Material({ - shader: __WEBPACK_IMPORTED_MODULE_0__graphicGL__["a" /* default */].createShader('ecgl.labels'), - transparent: true, - depthMask: false - }); + needsSortTriangles: function () { + return this.indices && this.sortTriangles; + }, - return { - geometry: geometry, - material: material, - culling: false, - castShadow: false, - ignorePicking: true - }; -})); + needsSortTrianglesProgressively: function () { + return this.needsSortTriangles() && this.triangleCount >= 2e4; + }, -/***/ }), -/* 59 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + doSortTriangles: function (cameraPos, frame) { + var indices = this.indices; + // Do progressive quick sort. + if (frame === 0) { + var posAttr = this.attributes.position; + var cameraPos = cameraPos.array; -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_earcut__ = __webpack_require__(196); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(22); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_retrieve__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_claygl_src_dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__util_geometry_trianglesSortMixin__ = __webpack_require__(60); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__LabelsBuilder__ = __webpack_require__(61); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_shader_lines3D_glsl_js__ = __webpack_require__(40); + if (!this._triangleZList || this._triangleZList.length !== this.triangleCount) { + this._triangleZList = new Float32Array(this.triangleCount); + this._sortedTriangleIndices = new Uint32Array(this.triangleCount); + this._indicesTmp = new indices.constructor(indices.length); + this._triangleZListTmp = new Float32Array(this.triangleCount); + } + var cursor = 0; + var firstZ; + for (var i = 0; i < indices.length;) { + posAttr.get(indices[i++], p0); + posAttr.get(indices[i++], p1); + posAttr.get(indices[i++], p2); + // FIXME If use center ? + // cp[0] = (p0[0] + p1[0] + p2[0]) / 3; + // cp[1] = (p0[1] + p1[1] + p2[1]) / 3; + // cp[2] = (p0[2] + p1[2] + p2[2]) / 3; + // Camera position is in object space + // Use max of three points, PENDING + var z0 = vec3.sqrDist(p0, cameraPos); + var z1 = vec3.sqrDist(p1, cameraPos); + var z2 = vec3.sqrDist(p2, cameraPos); + var zMax = Math.min(z0, z1); + zMax = Math.min(zMax, z2); + if (i === 3) { + firstZ = zMax; + zMax = 0; + } + else { + // Only store the difference to avoid the precision issue. + zMax = zMax - firstZ; + } + this._triangleZList[cursor++] = zMax; + } + } + var sortedTriangleIndices = this._sortedTriangleIndices; + for (var i = 0; i < sortedTriangleIndices.length; i++) { + sortedTriangleIndices[i] = i; + } + if (this.triangleCount < 2e4) { + // Use simple timsort for simple geometries. + if (frame === 0) { + // Use native sort temporary. + this._simpleSort(true); + } + } + else { + for (var i = 0; i < 3; i++) { + this._progressiveQuickSort(frame * 3 + i); + } + } + var targetIndices = this._indicesTmp; + var targetTriangleZList = this._triangleZListTmp; + var faceZList = this._triangleZList; + for (var i = 0; i < this.triangleCount; i++) { + var fromIdx3 = sortedTriangleIndices[i] * 3; + var toIdx3 = i * 3; + targetIndices[toIdx3++] = indices[fromIdx3++]; + targetIndices[toIdx3++] = indices[fromIdx3++]; + targetIndices[toIdx3] = indices[fromIdx3]; + targetTriangleZList[i] = faceZList[sortedTriangleIndices[i]]; + } -var vec3 = __WEBPACK_IMPORTED_MODULE_5_claygl_src_dep_glmatrix___default.a.vec3; + // Swap indices. + var tmp = this._indicesTmp; + this._indicesTmp = this.indices; + this.indices = tmp; + var tmp = this._triangleZListTmp; + this._triangleZListTmp = this._triangleZList; + this._triangleZList = tmp; -__WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_8__util_shader_lines3D_glsl_js__["a" /* default */]); + this.dirtyIndices(); + }, -function Geo3DBuilder(api) { + _simpleSort: function (useNativeQuickSort) { + var faceZList = this._triangleZList; + var sortedTriangleIndices = this._sortedTriangleIndices; - this.rootNode = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node(); + function compare(a, b) { + // Sort from far to near. which is descending order + return faceZList[b] - faceZList[a]; + } + if (useNativeQuickSort) { + Array.prototype.sort.call(sortedTriangleIndices, compare); + } + else { + __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__["a" /* default */].sort(sortedTriangleIndices, compare, 0, sortedTriangleIndices.length - 1); + } + }, - // Cache triangulation result - this._triangulationResults = {}; + _progressiveQuickSort: function (frame) { + var faceZList = this._triangleZList; + var sortedTriangleIndices = this._sortedTriangleIndices; - this._shadersMap = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].COMMON_SHADERS.reduce(function (obj, shaderName) { - obj[shaderName] = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.' + shaderName); - return obj; - }, {}); + this._quickSort = this._quickSort || new __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__["a" /* default */](); - this._linesShader = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.meshLines3D'); + this._quickSort.step(sortedTriangleIndices, function (a, b) { + return faceZList[b] - faceZList[a]; + }, frame); + } +}); - var groundMaterials = {}; - __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].COMMON_SHADERS.forEach(function (shading) { - groundMaterials[shading] = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({ - shader: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.' + shading) - }); - }); - this._groundMaterials = groundMaterials; +/***/ }), +/* 66 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - this._groundMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({ - geometry: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].PlaneGeometry({ dynamic: true }), - castShadow: false, - renderNormal: true, - $ignorePicking: true - }); - this._groundMesh.rotation.rotateX(-Math.PI / 2); +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_ZRTextureAtlasSurface__ = __webpack_require__(81); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_mesh_LabelsMesh__ = __webpack_require__(63); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_retrieve__ = __webpack_require__(2); - this._labelsBuilder = new __WEBPACK_IMPORTED_MODULE_7__LabelsBuilder__["a" /* default */](512, 512, api); - // Give a large render order. - this._labelsBuilder.getMesh().renderOrder = 100; - this._labelsBuilder.getMesh().material.depthTest = false; - this.rootNode.add(this._labelsBuilder.getMesh()); - this._initMeshes(); +var LABEL_NORMAL_SHOW_BIT = 1; +var LABEL_EMPHASIS_SHOW_BIT = 2; + +function LabelsBuilder(width, height, api) { + + this._labelsMesh = new __WEBPACK_IMPORTED_MODULE_2__util_mesh_LabelsMesh__["a" /* default */](); + + this._labelTextureSurface = new __WEBPACK_IMPORTED_MODULE_1__util_ZRTextureAtlasSurface__["a" /* default */]({ + width: 512, + height: 512, + devicePixelRatio: api.getDevicePixelRatio(), + onupdate: function () { + api.getZr().refresh(); + } + }); this._api = api; + + this._labelsMesh.material.set('textureAtlas', this._labelTextureSurface.getTexture()); } -Geo3DBuilder.prototype = { +LabelsBuilder.prototype.getLabelPosition = function (dataIndex, positionDesc, distance) { + return [0, 0, 0]; +}; - constructor: Geo3DBuilder, +LabelsBuilder.prototype.getLabelDistance = function (dataIndex, positionDesc, distance) { + return 0; +}; - // Which dimension to extrude. Y or Z - extrudeY: true, +LabelsBuilder.prototype.getMesh = function () { + return this._labelsMesh; +}; - update: function (componentModel, ecModel, api, start, end) { +LabelsBuilder.prototype.updateData = function (data, start, end) { + if (start == null) { + start = 0; + } + if (end == null) { + end = data.count(); + } - var data = componentModel.getData(); + if (!this._labelsVisibilitiesBits || this._labelsVisibilitiesBits.length !== (end - start)) { + this._labelsVisibilitiesBits = new Uint8Array(end - start); + } + var normalLabelVisibilityQuery = ['label', 'show']; + var emphasisLabelVisibilityQuery = ['emphasis', 'label', 'show']; - if (start == null) { - start = 0; - } - if (end == null) { - end = data.count(); + for (var idx = start; idx < end; idx++) { + var itemModel = data.getItemModel(idx); + var normalVisibility = itemModel.get(normalLabelVisibilityQuery); + var emphasisVisibility = itemModel.get(emphasisLabelVisibilityQuery); + if (emphasisVisibility == null) { + emphasisVisibility = normalVisibility; } + var bit = (normalVisibility ? LABEL_NORMAL_SHOW_BIT : 0) + | (emphasisVisibility ? LABEL_EMPHASIS_SHOW_BIT : 0); + this._labelsVisibilitiesBits[idx - start] = bit; + } - this._startIndex = start; - this._endIndex = end - 1; - - this._triangulation(componentModel, start, end); + this._start = start; + this._end = end; - var shader = this._getShader(componentModel.get('shading')); + this._data = data; +}; - this._prepareMesh(componentModel, shader, api, start, end); +LabelsBuilder.prototype.updateLabels = function (highlightDataIndices) { - this.rootNode.updateWorldTransform(); + if (!this._data) { + return; + } - this._updateRegionMesh(componentModel, api, start, end); + highlightDataIndices = highlightDataIndices || []; - var coordSys = componentModel.coordinateSystem; - // PENDING - if (coordSys.type === 'geo3D') { - this._updateGroundPlane(componentModel, coordSys, api); - } + var hasHighlightData = highlightDataIndices.length > 0; + var highlightDataIndicesMap = {}; + for (var i = 0; i < highlightDataIndices.length; i++) { + highlightDataIndicesMap[highlightDataIndices[i]] = true; + } - var self = this; - this._labelsBuilder.updateData(data, start, end); - this._labelsBuilder.getLabelPosition = function (dataIndex, positionDesc, distance) { - var name = data.getName(dataIndex); + this._labelsMesh.geometry.convertToDynamicArray(true); + this._labelTextureSurface.clear(); - var center; - var height = distance; - if (coordSys.type === 'geo3D') { - var region = coordSys.getRegion(name); - if (!region) { - return [NaN, NaN, NaN]; - } - center = region.center; - var pos = coordSys.dataToPoint([center[0], center[1], height]); - return pos; - } - else { - var tmp = self._triangulationResults[dataIndex - self._startIndex]; - var center = self.extrudeY ? [ - (tmp.max[0] + tmp.min[0]) / 2, - tmp.max[1] + height, - (tmp.max[2] + tmp.min[2]) / 2 - ] : [ - (tmp.max[0] + tmp.min[0]) / 2, - (tmp.max[1] + tmp.min[1]) / 2, - tmp.max[2] + height - ]; - } - }; + var normalLabelQuery = ['label']; + var emphasisLabelQuery = ['emphasis', 'label']; + var seriesModel = this._data.hostModel; + var data = this._data; - this._data = data; + var seriesLabelModel = seriesModel.getModel(normalLabelQuery); + var seriesLabelEmphasisModel = seriesModel.getModel(emphasisLabelQuery, seriesLabelModel); - this._labelsBuilder.updateLabels(); + var textAlignMap = { + left: 'right', + right: 'left', + top: 'center', + bottom: 'center' + }; + var textVerticalAlignMap = { + left: 'middle', + right: 'middle', + top: 'bottom', + bottom: 'top' + }; - this._updateDebugWireframe(componentModel); + for (var dataIndex = this._start; dataIndex < this._end; dataIndex++) { + var isEmphasis = false; + if (hasHighlightData && highlightDataIndicesMap[dataIndex]) { + isEmphasis = true; + } + var ifShow = this._labelsVisibilitiesBits[dataIndex - this._start] + & (isEmphasis ? LABEL_EMPHASIS_SHOW_BIT : LABEL_NORMAL_SHOW_BIT); + if (!ifShow) { + continue; + } - // Reset some state. - this._lastHoverDataIndex = 0; - }, + var itemModel = data.getItemModel(dataIndex); + var labelModel = itemModel.getModel( + isEmphasis ? emphasisLabelQuery : normalLabelQuery, + isEmphasis ? seriesLabelEmphasisModel : seriesLabelModel + ); + var distance = labelModel.get('distance') || 0; + var position = labelModel.get('position'); + var textStyleModel = labelModel.getModel('textStyle'); - _initMeshes: function () { - var self = this; - function createPolygonMesh() { - var mesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({ - name: 'Polygon', - material: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({ - shader: self._shadersMap.lambert - }), - geometry: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Geometry({ - sortTriangles: true, - dynamic: true - }), - // TODO Disable culling - culling: false, - ignorePicking: true, - // Render normal in normal pass - renderNormal: true - }); - __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.extend(mesh.geometry, __WEBPACK_IMPORTED_MODULE_6__util_geometry_trianglesSortMixin__["a" /* default */]); - return mesh; + var dpr = this._api.getDevicePixelRatio(); + var text = seriesModel.getFormattedLabel(dataIndex, isEmphasis ? 'emphasis' : 'normal'); + if (text == null || text === '') { + return; } - var polygonMesh = createPolygonMesh(); - - var linesMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({ - material: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({ - shader: this._linesShader - }), - castShadow: false, - ignorePicking: true, - $ignorePicking: true, - geometry: new __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__["a" /* default */]({ - useNativeLine: false - }) + // TODO Background. + var textEl = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.Text(); + __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.setTextStyle(textEl.style, textStyleModel, { + text: text, + textFill: textStyleModel.get('color') || data.getItemVisual(dataIndex, 'color') || '#000', + textAlign: 'left', + textVerticalAlign: 'top', + opacity: __WEBPACK_IMPORTED_MODULE_3__util_retrieve__["a" /* default */].firstNotNull(textStyleModel.get('opacity'), data.getItemVisual(dataIndex, 'opacity'), 1) }); + var rect = textEl.getBoundingRect(); + var lineHeight = 1.2; + rect.height *= lineHeight; - this.rootNode.add(polygonMesh); - this.rootNode.add(linesMesh); - - polygonMesh.material.define('both', 'VERTEX_COLOR'); - polygonMesh.material.define('fragment', 'DOUBLE_SIDED'); - - this._polygonMesh = polygonMesh; - this._linesMesh = linesMesh; - - this.rootNode.add(this._groundMesh); - }, + var coords = this._labelTextureSurface.add(textEl); - _getShader: function (shading) { - var shader = this._shadersMap[shading]; - if (!shader) { - if (true) { - console.warn('Unkown shading ' + shading); - } - // Default use lambert shader. - shader = this._shadersMap.lambert; - } - shader.__shading = shading; - return shader; - }, + var textAlign = textAlignMap[position] || 'center'; + var textVerticalAlign = textVerticalAlignMap[position] || 'bottom'; - _prepareMesh: function (componentModel, shader, api, start, end) { - var polygonVertexCount = 0; - var polygonTriangleCount = 0; - var linesVertexCount = 0; - var linesTriangleCount = 0; - // TODO Lines - for (var idx = start; idx < end; idx++) { - var polyInfo = this._getRegionPolygonInfo(idx); - var lineInfo = this._getRegionLinesInfo(idx, componentModel, this._linesMesh.geometry); - polygonVertexCount += polyInfo.vertexCount; - polygonTriangleCount += polyInfo.triangleCount; - linesVertexCount += lineInfo.vertexCount; - linesTriangleCount += lineInfo.triangleCount; - } + this._labelsMesh.geometry.addSprite( + this.getLabelPosition(dataIndex, position, distance), + [rect.width * dpr, rect.height * dpr], coords, + textAlign, textVerticalAlign, + this.getLabelDistance(dataIndex, position, distance) * dpr + ); + } - var polygonMesh = this._polygonMesh; - var polygonGeo = polygonMesh.geometry; - ['position', 'normal', 'texcoord0', 'color'].forEach(function (attrName) { - polygonGeo.attributes[attrName].init(polygonVertexCount); - }); - polygonGeo.indices = polygonVertexCount > 0xffff ? new Uint32Array(polygonTriangleCount * 3) : new Uint16Array(polygonTriangleCount * 3); + this._labelsMesh.material.set('uvScale', this._labelTextureSurface.getCoordsScale()); - if (polygonMesh.material.shader !== shader) { - polygonMesh.material.attachShader(shader, true); - } - __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].setMaterialFromModel(shader.__shading, polygonMesh.material, componentModel, api); + // var canvas = this._labelTextureSurface.getTexture().image; + // document.body.appendChild(canvas); + // canvas.style.cssText = 'position:absolute;z-index: 1000'; - if (linesVertexCount > 0) { - this._linesMesh.geometry.resetOffset(); - this._linesMesh.geometry.setVertexCount(linesVertexCount); - this._linesMesh.geometry.setTriangleCount(linesTriangleCount); - } + // Update image. + this._labelTextureSurface.getZr().refreshImmediately(); + this._labelsMesh.geometry.convertToTypedArray(); + this._labelsMesh.geometry.dirty(); +}; - // Indexing data index from vertex index. - this._dataIndexOfVertex = new Uint32Array(polygonVertexCount); - // Indexing vertex index range from data index - this._vertexRangeOfDataIndex = new Uint32Array((end - start) * 2); - }, +/* harmony default export */ __webpack_exports__["a"] = (LabelsBuilder); - _updateRegionMesh: function (componentModel, api, start, end) { +/***/ }), +/* 67 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - var data = componentModel.getData(); +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_sprite__ = __webpack_require__(239); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__PointsMesh__ = __webpack_require__(240); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__component_common_LabelsBuilder__ = __webpack_require__(66); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__util_retrieve__ = __webpack_require__(2); - var vertexOffset = 0; - var triangleOffset = 0; - // Materials configurations. - var hasTranparentRegion = false; - var polygonMesh = this._polygonMesh; - var linesMesh = this._linesMesh; - for (var dataIndex = start; dataIndex < end; dataIndex++) { - // Get bunch of visual properties. - var regionModel = componentModel.getRegionModel(dataIndex); - var itemStyleModel = regionModel.getModel('itemStyle'); - var color = itemStyleModel.get('color'); - var opacity = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(itemStyleModel.get('opacity'), 1.0); - // Use visual color if it is encoded by visualMap component - var visualColor = data.getItemVisual(dataIndex, 'color', true); - if (visualColor != null && data.hasValue(dataIndex)) { - color = visualColor; - } - // Set color, opacity to visual for label usage. - data.setItemVisual(dataIndex, 'color', color); - data.setItemVisual(dataIndex, 'opacity', opacity); - color = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color); - var borderColor = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(itemStyleModel.get('borderColor')); - color[3] *= opacity; - borderColor[3] *= opacity; - var isTransparent = color[3] < 0.99; +var SDF_RANGE = 20; - polygonMesh.material.set('color', [1,1,1,1]); - hasTranparentRegion = hasTranparentRegion || isTransparent; +var Z_2D = -10; - var regionHeight = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(regionModel.get('height', true), componentModel.get('regionHeight')); +function isSymbolSizeSame(a, b) { + return a && b && a[0] === b[0] && a[1] === b[1]; +} +// TODO gl_PointSize has max value. +function PointsBuilder(is2D, api) { + this.rootNode = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node(); - var newOffsets = this._updatePolygonGeometry( - componentModel, polygonMesh.geometry, dataIndex, regionHeight, - vertexOffset, triangleOffset, color - ); + /** + * @type {boolean} + */ + this.is2D = is2D; - for (var i = vertexOffset; i < newOffsets.vertexOffset; i++) { - this._dataIndexOfVertex[i] = dataIndex; - } - this._vertexRangeOfDataIndex[(dataIndex - start) * 2] = vertexOffset; - this._vertexRangeOfDataIndex[(dataIndex - start) * 2 + 1] = newOffsets.vertexOffset; + this._labelsBuilder = new __WEBPACK_IMPORTED_MODULE_4__component_common_LabelsBuilder__["a" /* default */](256, 256, api); - vertexOffset = newOffsets.vertexOffset; - triangleOffset = newOffsets.triangleOffset; + // Give a large render order. + this._labelsBuilder.getMesh().renderOrder = 100; + this.rootNode.add(this._labelsBuilder.getMesh()); - // Update lines. - var lineWidth = itemStyleModel.get('borderWidth'); - var hasLine = lineWidth > 0; - if (hasLine) { - lineWidth *= api.getDevicePixelRatio(); - this._updateLinesGeometry( - linesMesh.geometry, componentModel, dataIndex, regionHeight, lineWidth, - componentModel.coordinateSystem.transform - ); - } - linesMesh.invisible = !hasLine; - linesMesh.material.set({ - color: borderColor - }); - } + this._api = api; - var polygonMesh = this._polygonMesh; - polygonMesh.material.transparent = hasTranparentRegion; - polygonMesh.material.depthMask = !hasTranparentRegion; - polygonMesh.geometry.updateBoundingBox(); + this._spriteImageCanvas = document.createElement('canvas'); - polygonMesh.frontFace = this.extrudeY ? __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh.CCW : __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh.CW; + this._startDataIndex = 0; + this._endDataIndex = 0; - // Update tangents - if (polygonMesh.material.get('normalMap')) { - polygonMesh.geometry.generateTangents(); - } + this._sizeScale = 1; +} - polygonMesh.seriesIndex = componentModel.seriesIndex; +PointsBuilder.prototype = { - polygonMesh.on('mousemove', this._onmousemove, this); - polygonMesh.on('mouseout', this._onmouseout, this); - }, + constructor: PointsBuilder, - _updateDebugWireframe: function (componentModel) { - var debugWireframeModel = componentModel.getModel('debug.wireframe'); + /** + * If highlight on over + */ + highlightOnMouseover: true, - // TODO Unshow - if (debugWireframeModel.get('show')) { - var color = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor( - debugWireframeModel.get('lineStyle.color') || 'rgba(0,0,0,0.5)' - ); - var width = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull( - debugWireframeModel.get('lineStyle.width'), 1 - ); + update: function (seriesModel, ecModel, api, start, end) { + // Swap barMesh + var tmp = this._prevMesh; + this._prevMesh = this._mesh; + this._mesh = tmp; - // TODO Will cause highlight wrong - var mesh = this._polygonMesh; - mesh.geometry.generateBarycentric(); - mesh.material.define('both', 'WIREFRAME_TRIANGLE'); - mesh.material.set('wireframeLineColor', color); - mesh.material.set('wireframeLineWidth', width); - } - }, + var data = seriesModel.getData(); - _onmousemove: function (e) { - var dataIndex = this._dataIndexOfVertex[e.triangle[0]]; - if (dataIndex == null) { - dataIndex = -1; + if (start == null) { + start = 0; } - if (dataIndex !== this._lastHoverDataIndex) { - this.downplay(this._lastHoverDataIndex); - this.highlight(dataIndex); - this._labelsBuilder.updateLabels([dataIndex]); + if (end == null) { + end = data.count(); } - this._lastHoverDataIndex = dataIndex; - this._polygonMesh.dataIndex = dataIndex; - }, + this._startDataIndex = start; + this._endDataIndex = end - 1; - _onmouseout: function (e) { - if (e.target) { - this.downplay(this._lastHoverDataIndex); - this._lastHoverDataIndex = -1; - this._polygonMesh.dataIndex = -1; + if (!this._mesh) { + var material = this._prevMesh && this._prevMesh.material; + this._mesh = new __WEBPACK_IMPORTED_MODULE_3__PointsMesh__["a" /* default */]({ + // Render after axes + renderOrder: 10, + // FIXME + frustumCulling: false + }); + if (material) { + this._mesh.material = material; + } } + var material = this._mesh.material; + var geometry = this._mesh.geometry; + var attributes = geometry.attributes; - this._labelsBuilder.updateLabels([]); - }, + this.rootNode.remove(this._prevMesh); + this.rootNode.add(this._mesh); - _updateGroundPlane: function (componentModel, geo3D, api) { - var groundModel = componentModel.getModel('groundPlane', componentModel); - this._groundMesh.invisible = !groundModel.get('show', true); - if (this._groundMesh.invisible) { - return; - } + this._setPositionTextureToMesh(this._mesh, this._positionTexture); - var shading = componentModel.get('shading'); - var material = this._groundMaterials[shading]; - if (!material) { - if (true) { - console.warn('Unkown shading ' + shading); - } - material = this._groundMaterials.lambert; - } + var symbolInfo = this._getSymbolInfo(seriesModel, start, end); + var dpr = api.getDevicePixelRatio(); - __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].setMaterialFromModel(shading, material, groundModel, api); - if (material.get('normalMap')) { - this._groundMesh.geometry.generateTangents(); + // TODO image symbol + var itemStyle = seriesModel.getModel('itemStyle').getItemStyle(); + var largeMode = seriesModel.get('large'); + + var pointSizeScale = 1; + if (symbolInfo.maxSize > 2) { + pointSizeScale = this._updateSymbolSprite(seriesModel, itemStyle, symbolInfo, dpr); + material.enableTexture('sprite'); + } + else { + material.disableTexture('sprite'); } - this._groundMesh.material = material; - this._groundMesh.material.set('color', __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(groundModel.get('color'))); + attributes.position.init(end - start); + var rgbaArr = []; + if (largeMode) { + material.undefine('VERTEX_SIZE'); + material.undefine('VERTEX_COLOR'); - this._groundMesh.scale.set(geo3D.size[0], geo3D.size[2], 1); - }, + var color = data.getVisual('color'); + var opacity = data.getVisual('opacity'); + __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color, rgbaArr); + rgbaArr[3] *= opacity; - _triangulation: function (componentModel, start, end) { - this._triangulationResults = []; + material.set({ + color: rgbaArr, + 'u_Size': symbolInfo.maxSize * this._sizeScale + }); + } + else { + material.set({ + color: [1, 1, 1, 1] + }); + material.define('VERTEX_SIZE'); + material.define('VERTEX_COLOR'); + attributes.size.init(end - start); + attributes.color.init(end - start); + this._originalOpacity = new Float32Array(end - start); + } - var minAll = [Infinity, Infinity, Infinity]; - var maxAll = [-Infinity, -Infinity, -Infinity]; + var points = data.getLayout('points'); - var coordSys = componentModel.coordinateSystem; + var positionArr = attributes.position.value; - for (var idx = start; idx < end; idx++) { - var polygons = []; - var polygonCoords = componentModel.getRegionPolygonCoords(idx); - for (var i = 0; i < polygonCoords.length; i++) { - var exterior = polygonCoords[i].exterior; - var interiors = polygonCoords[i].interiors; - var points = []; - var holes = []; - if (exterior.length < 3) { - continue; - } - var offset = 0; - for (var j = 0; j < exterior.length; j++) { - var p = exterior[j]; - points[offset++] = p[0]; - points[offset++] = p[1]; - } + var hasTransparentPoint = false; - for (var j = 0; j < interiors.length; j++) { - if (interiors[j].length < 3) { - continue; - } - var startIdx = points.length / 2; - for (var k = 0; k < interiors[j].length; k++) { - var p = interiors[j][k]; - points.push(p[0]); - points.push(p[1]); - } + for (var i = 0; i < end - start; i++) { + var i3 = i * 3; + var i2 = i * 2; + if (this.is2D) { + positionArr[i3] = points[i2]; + positionArr[i3 + 1] = points[i2 + 1]; + positionArr[i3 + 2] = Z_2D; + } + else { + positionArr[i3] = points[i3]; + positionArr[i3 + 1] = points[i3 + 1]; + positionArr[i3 + 2] = points[i3 + 2]; + } - holes.push(startIdx); + if (!largeMode) { + var color = data.getItemVisual(i, 'color'); + var opacity = data.getItemVisual(i, 'opacity'); + __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color, rgbaArr); + rgbaArr[3] *= opacity; + attributes.color.set(i, rgbaArr); + if (rgbaArr[3] < 0.99) { + hasTransparentPoint = true; } - var triangles = Object(__WEBPACK_IMPORTED_MODULE_2__util_earcut__["a" /* default */])(points, holes); + var symbolSize = data.getItemVisual(i, 'symbolSize'); + symbolSize = (symbolSize instanceof Array + ? Math.max(symbolSize[0], symbolSize[1]) : symbolSize); - var points3 = new Float64Array(points.length / 2 * 3); - var pos = []; - var min = [Infinity, Infinity, Infinity]; - var max = [-Infinity, -Infinity, -Infinity]; - var off3 = 0; - for (var j = 0; j < points.length;) { - vec3.set(pos, points[j++], 0, points[j++]); - if (coordSys && coordSys.transform) { - vec3.transformMat4(pos, pos, coordSys.transform); - } - vec3.min(min, min, pos); - vec3.max(max, max, pos); - points3[off3++] = pos[0]; - points3[off3++] = pos[1]; - points3[off3++] = pos[2]; + // NaN pointSize may have strange result. + if (isNaN(symbolSize)) { + symbolSize = 0; } - vec3.min(minAll, minAll, min); - vec3.max(maxAll, maxAll, max); - polygons.push({ - points: points3, - indices: triangles, - min: min, - max: max - }); + // Scale point size because canvas has margin. + attributes.size.value[i] = symbolSize * pointSizeScale * this._sizeScale; + + // Save the original opacity for recover from fadeIn. + this._originalOpacity[i] = rgbaArr[3]; } - this._triangulationResults.push(polygons); + } - this._geoBoundingBox = [minAll, maxAll]; - }, + this._mesh.sizeScale = pointSizeScale; - /** - * Get region vertex and triangle count - */ - _getRegionPolygonInfo: function (idx) { + geometry.updateBoundingBox(); + geometry.dirty(); - var polygons = this._triangulationResults[idx - this._startIndex]; + // Update material. + this._updateMaterial(seriesModel, itemStyle); - var sideVertexCount = 0; - var sideTriangleCount = 0; + var coordSys = seriesModel.coordinateSystem; + if (coordSys && coordSys.viewGL) { + var methodName = coordSys.viewGL.isLinearSpace() ? 'define' : 'undefine'; + material[methodName]('fragment', 'SRGB_DECODE'); + } - for (var i = 0; i < polygons.length; i++) { - sideVertexCount += polygons[i].points.length / 3; - sideTriangleCount += polygons[i].indices.length / 3; + if (!largeMode) { + this._updateLabelBuilder(seriesModel, start, end); } - var vertexCount = sideVertexCount * 2 + sideVertexCount * 4; - var triangleCount = sideTriangleCount * 2 + sideVertexCount * 2; + this._updateHandler(seriesModel, ecModel, api); - return { - vertexCount: vertexCount, - triangleCount: triangleCount - }; - }, + this._updateAnimation(seriesModel); - _updatePolygonGeometry: function ( - componentModel, geometry, dataIndex, regionHeight, - vertexOffset, triangleOffset, color - ) { - // FIXME - var projectUVOnGround = componentModel.get('projectUVOnGround'); + this._api = api; + }, - var positionAttr = geometry.attributes.position; - var normalAttr = geometry.attributes.normal; - var texcoordAttr = geometry.attributes.texcoord0; - var colorAttr = geometry.attributes.color; - var polygons = this._triangulationResults[dataIndex - this._startIndex]; + getPointsMesh: function () { + return this._mesh; + }, - var hasColor = colorAttr.value && color; + updateLabels: function (highlightDataIndices) { + this._labelsBuilder.updateLabels(highlightDataIndices); + }, - var indices = geometry.indices; + hideLabels: function () { + this.rootNode.remove(this._labelsBuilder.getMesh()); + }, - var extrudeCoordIndex = this.extrudeY ? 1 : 2; - var sideCoordIndex = this.extrudeY ? 2 : 1; + showLabels: function () { + this.rootNode.add(this._labelsBuilder.getMesh()); + }, - var scale = [ - this.rootNode.worldTransform.x.len(), - this.rootNode.worldTransform.y.len(), - this.rootNode.worldTransform.z.len() - ]; + _updateSymbolSprite: function (seriesModel, itemStyle, symbolInfo, dpr) { + symbolInfo.maxSize = Math.min(symbolInfo.maxSize * 2, 200); + var symbolSize = []; + if (symbolInfo.aspect > 1) { + symbolSize[0] = symbolInfo.maxSize; + symbolSize[1] = symbolInfo.maxSize / symbolInfo.aspect; + } + else { + symbolSize[1] = symbolInfo.maxSize; + symbolSize[0] = symbolInfo.maxSize * symbolInfo.aspect; + } - var min = vec3.mul([], this._geoBoundingBox[0], scale); - var max = vec3.mul([], this._geoBoundingBox[1], scale); - var maxDimSize = Math.max(max[0] - min[0], max[2] - min[2]); + // In case invalid data. + symbolSize[0] = symbolSize[0] || 1; + symbolSize[1] = symbolSize[1] || 1; - function addVertices(polygon, y, insideOffset) { - var points = polygon.points; + if (this._symbolType !== symbolInfo.type + || !isSymbolSizeSame(this._symbolSize, symbolSize) + || this._lineWidth !== itemStyle.lineWidth + ) { + __WEBPACK_IMPORTED_MODULE_2__util_sprite__["a" /* default */].createSymbolSprite(symbolInfo.type, symbolSize, { + fill: '#fff', + lineWidth: itemStyle.lineWidth, + stroke: 'transparent', + shadowColor: 'transparent', + minMargin: Math.min(symbolSize[0] / 2, 10) + }, this._spriteImageCanvas); - var pointsLen = points.length; - var currentPosition = []; - var uv = []; + __WEBPACK_IMPORTED_MODULE_2__util_sprite__["a" /* default */].createSDFFromCanvas( + this._spriteImageCanvas, Math.min(this._spriteImageCanvas.width, 32), SDF_RANGE, + this._mesh.material.get('sprite').image + ); - for (var k = 0; k < pointsLen; k += 3) { - currentPosition[0] = points[k]; - currentPosition[extrudeCoordIndex] = y; - currentPosition[sideCoordIndex] = points[k + 2]; + this._symbolType = symbolInfo.type; + this._symbolSize = symbolSize; + this._lineWidth = itemStyle.lineWidth; + } + return this._spriteImageCanvas.width / symbolInfo.maxSize * dpr; - uv[0] = (points[k] * scale[0] - min[0]) / maxDimSize; - uv[1] = (points[k + 2] * scale[sideCoordIndex] - min[2]) / maxDimSize; + }, - positionAttr.set(vertexOffset, currentPosition); - if (hasColor) { - colorAttr.set(vertexOffset, color); - } - texcoordAttr.set(vertexOffset++, uv); - } - } + _updateMaterial: function (seriesModel, itemStyle) { + var blendFunc = seriesModel.get('blendMode') === 'lighter' + ? __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].additiveBlend : null; + var material = this._mesh.material; + material.blend = blendFunc; - function buildTopBottom(polygon, y, insideOffset) { + material.set('lineWidth', itemStyle.lineWidth / SDF_RANGE); - var startVertexOffset = vertexOffset; + var strokeColor = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(itemStyle.stroke); + material.set('strokeColor', strokeColor); - addVertices(polygon, y, insideOffset); + // Because of symbol texture, we always needs it be transparent. + material.transparent = true; + material.depthMask = false; + material.depthTest = !this.is2D; + material.sortVertices = !this.is2D; + }, - var len = polygon.indices.length; - for (var k = 0; k < len; k++) { - indices[triangleOffset * 3 + k] = polygon.indices[k] + startVertexOffset; - } - triangleOffset += polygon.indices.length / 3; - } + _updateLabelBuilder: function (seriesModel, start, end) { + var data =seriesModel.getData(); + var geometry = this._mesh.geometry; + var positionArr = geometry.attributes.position.value; + var start = this._startDataIndex; + var pointSizeScale = this._mesh.sizeScale; + this._labelsBuilder.updateData(data, start, end); - var normalTop = this.extrudeY ? [0, 1, 0] : [0, 0, 1]; - var normalBottom = vec3.negate([], normalTop); - for (var p = 0; p < polygons.length; p++) { - var startVertexOffset = vertexOffset; - var polygon = polygons[p]; - // BOTTOM - buildTopBottom(polygon, 0, 0); - // TOP - buildTopBottom(polygon, regionHeight, 0); + this._labelsBuilder.getLabelPosition = function (dataIndex, positionDesc, distance) { + var idx3 = (dataIndex - start) * 3; + return [positionArr[idx3], positionArr[idx3 + 1], positionArr[idx3 + 2]]; + }; - var ringVertexCount = polygon.points.length / 3; - for (var v = 0; v < ringVertexCount; v++) { - normalAttr.set(startVertexOffset + v, normalBottom); - normalAttr.set(startVertexOffset + v + ringVertexCount, normalTop); - } + this._labelsBuilder.getLabelDistance = function (dataIndex, positionDesc, distance) { + var size = geometry.attributes.size.get(dataIndex - start) / pointSizeScale; + return size / 2 + distance; + }; + this._labelsBuilder.updateLabels(); - var quadToTriangle = [0, 3, 1, 1, 3, 2]; + }, - var quadPos = [[], [], [], []]; - var a = []; - var b = []; - var normal = []; - var uv = []; - var len = 0; - for (var v = 0; v < ringVertexCount; v++) { - var next = (v + 1) % ringVertexCount; + _updateAnimation: function (seriesModel) { + __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].updateVertexAnimation( + [['prevPosition', 'position'], + ['prevSize', 'size']], + this._prevMesh, + this._mesh, + seriesModel + ); + }, - var dx = (polygon.points[next * 3] - polygon.points[v * 3]) * scale[0]; - var dy = (polygon.points[next * 3 + 2] - polygon.points[v * 3 + 2]) * scale[sideCoordIndex]; - var sideLen = Math.sqrt(dx * dx + dy * dy); + _updateHandler: function (seriesModel, ecModel, api) { + var data = seriesModel.getData(); + var pointsMesh = this._mesh; + var self = this; - // 0----1 - // 3----2 - for (var k = 0; k < 4; k++) { - var isCurrent = (k === 0 || k === 3); - var idx3 = (isCurrent ? v : next) * 3; - quadPos[k][0] = polygon.points[idx3]; - quadPos[k][extrudeCoordIndex] = k > 1 ? regionHeight : 0; - quadPos[k][sideCoordIndex] = polygon.points[idx3 + 2]; + var lastDataIndex = -1; + var isCartesian3D = seriesModel.coordinateSystem + && seriesModel.coordinateSystem.type === 'cartesian3D'; - positionAttr.set(vertexOffset + k, quadPos[k]); + var grid3DModel; + if (isCartesian3D) { + grid3DModel = seriesModel.coordinateSystem.model; + } - if (projectUVOnGround) { - uv[0] = (polygon.points[idx3] * scale[0] - min[0]) / maxDimSize; - uv[1] = (polygon.points[idx3 + 2] * scale[sideCoordIndex] - min[sideCoordIndex]) / maxDimSize; - } - else { - uv[0] = (isCurrent ? len : (len + sideLen)) / maxDimSize; - uv[1] = (quadPos[k][extrudeCoordIndex] * scale[extrudeCoordIndex] - min[extrudeCoordIndex]) / maxDimSize; - } - texcoordAttr.set(vertexOffset + k, uv); - } - vec3.sub(a, quadPos[1], quadPos[0]); - vec3.sub(b, quadPos[3], quadPos[0]); - vec3.cross(normal, a, b); - vec3.normalize(normal, normal); + pointsMesh.seriesIndex = seriesModel.seriesIndex; - for (var k = 0; k < 4; k++) { - normalAttr.set(vertexOffset + k, normal); - if (hasColor) { - colorAttr.set(vertexOffset + k, color); - } - } + pointsMesh.off('mousemove'); + pointsMesh.off('mouseout'); - for (var k = 0; k < 6; k++) { - indices[triangleOffset * 3 + k] = quadToTriangle[k] + vertexOffset; + pointsMesh.on('mousemove', function (e) { + var dataIndex = e.vertexIndex + self._startDataIndex; + if (dataIndex !== lastDataIndex) { + if (this.highlightOnMouseover) { + this.downplay(data, lastDataIndex); + this.highlight(data, dataIndex); + this._labelsBuilder.updateLabels([dataIndex]); } - vertexOffset += 4; - triangleOffset += 2; - - len += sideLen; + if (isCartesian3D) { + api.dispatchAction({ + type: 'grid3DShowAxisPointer', + value: [ + data.get(seriesModel.coordDimToDataDim('x')[0], dataIndex), + data.get(seriesModel.coordDimToDataDim('y')[0], dataIndex), + data.get(seriesModel.coordDimToDataDim('z')[0], dataIndex) + ], + grid3DIndex: grid3DModel.componentIndex + }); + } } - } - geometry.dirty(); + pointsMesh.dataIndex = dataIndex; + lastDataIndex = dataIndex; + }, this); + pointsMesh.on('mouseout', function (e) { + var dataIndex = e.vertexIndex + self._startDataIndex; + if (this.highlightOnMouseover) { + this.downplay(data, dataIndex); + this._labelsBuilder.updateLabels(); + } + lastDataIndex = -1; + pointsMesh.dataIndex = -1; - return { - vertexOffset: vertexOffset, - triangleOffset: triangleOffset - }; + if (isCartesian3D) { + api.dispatchAction({ + type: 'grid3DHideAxisPointer', + grid3DIndex: grid3DModel.componentIndex + }); + } + }, this); }, - _getRegionLinesInfo: function (idx, componentModel, geometry) { - var vertexCount = 0; - var triangleCount = 0; - - var regionModel = componentModel.getRegionModel(idx); - var itemStyleModel = regionModel.getModel('itemStyle'); - - var lineWidth = itemStyleModel.get('borderWidth'); - if (lineWidth > 0) { - var polygonCoords = componentModel.getRegionPolygonCoords(idx); - polygonCoords.forEach(function (coords) { - var exterior = coords.exterior; - var interiors = coords.interiors; - vertexCount += geometry.getPolylineVertexCount(exterior); - triangleCount += geometry.getPolylineTriangleCount(exterior); - for (var i = 0; i < interiors.length; i++) { - vertexCount += geometry.getPolylineVertexCount(interiors[i]); - triangleCount += geometry.getPolylineTriangleCount(interiors[i]); - } - }, this); + updateLayout: function (seriesModel, ecModel, api) { + var data = seriesModel.getData(); + if (!this._mesh) { + return; } - return { - vertexCount: vertexCount, - triangleCount: triangleCount - }; + var positionArr = this._mesh.geometry.attributes.position.value; + var points = data.getLayout('points'); + if (this.is2D) { + for (var i = 0; i < points.length / 2; i++) { + var i3 = i * 3; + var i2 = i * 2; + positionArr[i3] = points[i2]; + positionArr[i3 + 1] = points[i2 + 1]; + positionArr[i3 + 2] = Z_2D; + } + } + else { + for (var i = 0; i < points.length; i++) { + positionArr[i] = points[i]; + } + } + this._mesh.geometry.dirty(); + api.getZr().refresh(); }, - _updateLinesGeometry: function (geometry, componentModel, dataIndex, regionHeight, lineWidth, transform) { - function convertToPoints3(polygon) { - var points = new Float64Array(polygon.length * 3); - var offset = 0; - var pos = []; - for (var i = 0; i < polygon.length; i++) { - pos[0] = polygon[i][0]; - // Add a offset to avoid z-fighting - pos[1] = regionHeight + 0.1; - pos[2] = polygon[i][1]; - - if (transform) { - vec3.transformMat4(pos, pos, transform); - } - - points[offset++] = pos[0]; - points[offset++] = pos[1]; - points[offset++] = pos[2]; - } - return points; + updateView: function (camera) { + if (!this._mesh) { + return; } - var whiteColor = [1, 1, 1, 1]; - var coords = componentModel.getRegionPolygonCoords(dataIndex); - coords.forEach(function (geo) { - var exterior = geo.exterior; - var interiors = geo.interiors; - - geometry.addPolyline(convertToPoints3(exterior), whiteColor, lineWidth); + var worldViewProjection = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */](); + __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */].mul(worldViewProjection, camera.viewMatrix, this._mesh.worldTransform); + __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */].mul(worldViewProjection, camera.projectionMatrix, worldViewProjection); - for (var i = 0; i < interiors.length; i++) { - geometry.addPolyline(convertToPoints3(interiors[i]), whiteColor, lineWidth); - } - }); + this._mesh.updateNDCPosition(worldViewProjection, this.is2D, this._api); }, - highlight: function (dataIndex) { - var data = this._data; - if (!data) { + highlight: function (data, dataIndex) { + if (dataIndex > this._endDataIndex || dataIndex < this._startDataIndex) { return; } - var itemModel = data.getItemModel(dataIndex); var emphasisItemStyleModel = itemModel.getModel('emphasis.itemStyle'); var emphasisColor = emphasisItemStyleModel.get('color'); - var emphasisOpacity = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull( - emphasisItemStyleModel.get('opacity'), - data.getItemVisual(dataIndex, 'opacity'), - 1 - ); + var emphasisOpacity = emphasisItemStyleModel.get('opacity'); if (emphasisColor == null) { var color = data.getItemVisual(dataIndex, 'color'); emphasisColor = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.color.lift(color, -0.4); @@ -23088,8057 +22245,9196 @@ Geo3DBuilder.prototype = { var colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(emphasisColor); colorArr[3] *= emphasisOpacity; - this._setColorOfDataIndex(data, dataIndex, colorArr); - }, + this._mesh.geometry.attributes.color.set(dataIndex - this._startDataIndex, colorArr); + this._mesh.geometry.dirtyAttribute('color'); - downplay: function (dataIndex) { + this._api.getZr().refresh(); + }, - var data = this._data; - if (!data) { + downplay: function (data, dataIndex) { + if (dataIndex > this._endDataIndex || dataIndex < this._startDataIndex) { return; } - var color = data.getItemVisual(dataIndex, 'color'); - var opacity = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(data.getItemVisual(dataIndex, 'opacity'), 1); + var opacity = data.getItemVisual(dataIndex, 'opacity'); var colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color); colorArr[3] *= opacity; - this._setColorOfDataIndex(data, dataIndex, colorArr); - }, + this._mesh.geometry.attributes.color.set(dataIndex - this._startDataIndex, colorArr); + this._mesh.geometry.dirtyAttribute('color'); - _setColorOfDataIndex: function (data, dataIndex, colorArr) { - if (dataIndex < this._startIndex && dataIndex > this._endIndex) { - return; - } - dataIndex -= this._startIndex; - for (var i = this._vertexRangeOfDataIndex[dataIndex * 2]; i < this._vertexRangeOfDataIndex[dataIndex * 2 + 1]; i++) { - this._polygonMesh.geometry.attributes.color.set(i, colorArr); - } - this._polygonMesh.geometry.dirty(); this._api.getZr().refresh(); - } -}; + }, -/* harmony default export */ __webpack_exports__["a"] = (Geo3DBuilder); + fadeOutAll: function (fadeOutPercent) { + if (this._originalOpacity) { + var geo = this._mesh.geometry; + for (var i = 0; i < geo.vertexCount; i++) { + var fadeOutOpacity = this._originalOpacity[i] * fadeOutPercent; + geo.attributes.color.value[i * 4 + 3] = fadeOutOpacity; + } + geo.dirtyAttribute('color'); -/***/ }), -/* 60 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + this._api.getZr().refresh(); + } + }, -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__ = __webpack_require__(90); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__); + fadeInAll: function () { + this.fadeOutAll(1); + }, + setPositionTexture: function (texture) { + if (this._mesh) { + this._setPositionTextureToMesh(this._mesh, texture); + } -var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default.a.vec3; + this._positionTexture = texture; + }, -var p0 = vec3.create(); -var p1 = vec3.create(); -var p2 = vec3.create(); -// var cp = vec3.create(); + removePositionTexture: function () { + this._positionTexture = null; + if (this._mesh) { + this._setPositionTextureToMesh(this._mesh, null); + } + }, -/* harmony default export */ __webpack_exports__["a"] = ({ + setSizeScale: function (sizeScale) { + if (sizeScale !== this._sizeScale) { + if (this._mesh) { + var originalSize = this._mesh.material.get('u_Size'); + this._mesh.material.set('u_Size', originalSize / this._sizeScale * sizeScale); - needsSortTriangles: function () { - return this.indices && this.sortTriangles; + var attributes = this._mesh.geometry.attributes; + if (attributes.size.value) { + for (var i = 0; i < attributes.size.value.length; i++) { + attributes.size.value[i] = attributes.size.value[i] / this._sizeScale * sizeScale; + } + } + } + this._sizeScale = sizeScale; + } }, - needsSortTrianglesProgressively: function () { - return this.needsSortTriangles() && this.triangleCount >= 2e4; + _setPositionTextureToMesh: function (mesh, texture) { + if (texture) { + mesh.material.set('positionTexture', texture); + } + mesh.material[ + texture ? 'enableTexture' : 'disableTexture' + ]('positionTexture'); }, - doSortTriangles: function (cameraPos, frame) { - var indices = this.indices; - // Do progressive quick sort. - if (frame === 0) { - var posAttr = this.attributes.position; - var cameraPos = cameraPos.array; - - if (!this._triangleZList || this._triangleZList.length !== this.triangleCount) { - this._triangleZList = new Float32Array(this.triangleCount); - this._sortedTriangleIndices = new Uint32Array(this.triangleCount); - - this._indicesTmp = new indices.constructor(indices.length); - this._triangleZListTmp = new Float32Array(this.triangleCount); + _getSymbolInfo: function (seriesModel, start, end) { + if (seriesModel.get('large')) { + var symbolSize = __WEBPACK_IMPORTED_MODULE_6__util_retrieve__["a" /* default */].firstNotNull(seriesModel.get('symbolSize'), 1); + var maxSymbolSize; + var symbolAspect; + if (symbolSize instanceof Array) { + maxSymbolSize = Math.max(symbolSize[0], symbolSize[1]); + symbolAspect = symbolSize[0] / symbolSize[1]; } + else { + maxSymbolSize = symbolSize; + symbolAspect = 1; + } + return { + maxSize: symbolSize, + type: seriesModel.get('symbol'), + aspect: symbolAspect + } + } + var data = seriesModel.getData(); + var symbolAspect; + var differentSymbolAspect = false; + var symbolType = data.getItemVisual(0, 'symbol') || 'circle'; + var differentSymbolType = false; + var maxSymbolSize = 0; - var cursor = 0; - var firstZ; - for (var i = 0; i < indices.length;) { - posAttr.get(indices[i++], p0); - posAttr.get(indices[i++], p1); - posAttr.get(indices[i++], p2); - - // FIXME If use center ? - // cp[0] = (p0[0] + p1[0] + p2[0]) / 3; - // cp[1] = (p0[1] + p1[1] + p2[1]) / 3; - // cp[2] = (p0[2] + p1[2] + p2[2]) / 3; - // Camera position is in object space + for (var idx = start; idx < end; idx++) { + var symbolSize = data.getItemVisual(idx, 'symbolSize'); + var currentSymbolType = data.getItemVisual(idx, 'symbol'); + var currentSymbolAspect; + if (!(symbolSize instanceof Array)) { + // Ignore NaN value. + if (isNaN(symbolSize)) { + return; + } - // Use max of three points, PENDING - var z0 = vec3.sqrDist(p0, cameraPos); - var z1 = vec3.sqrDist(p1, cameraPos); - var z2 = vec3.sqrDist(p2, cameraPos); - var zMax = Math.min(z0, z1); - zMax = Math.min(zMax, z2); - if (i === 3) { - firstZ = zMax; - zMax = 0; + currentSymbolAspect = 1; + maxSymbolSize = Math.max(symbolSize, maxSymbolSize); + } + else { + currentSymbolAspect = symbolSize[0] / symbolSize[1]; + maxSymbolSize = Math.max(Math.max(symbolSize[0], symbolSize[1]), maxSymbolSize); + } + if (true) { + if (symbolAspect != null && Math.abs(currentSymbolAspect - symbolAspect) > 0.05) { + differentSymbolAspect = true; } - else { - // Only store the difference to avoid the precision issue. - zMax = zMax - firstZ; + if (currentSymbolType !== symbolType) { + differentSymbolType = true; } - this._triangleZList[cursor++] = zMax; } + symbolType = currentSymbolType; + symbolAspect = currentSymbolAspect; } - - var sortedTriangleIndices = this._sortedTriangleIndices; - for (var i = 0; i < sortedTriangleIndices.length; i++) { - sortedTriangleIndices[i] = i; - } - - if (this.triangleCount < 2e4) { - // Use simple timsort for simple geometries. - if (frame === 0) { - // Use native sort temporary. - this._simpleSort(true); + if (true) { + if (differentSymbolAspect) { + console.warn('Different symbol width / height ratio will be ignored.'); } - } - else { - for (var i = 0; i < 3; i++) { - this._progressiveQuickSort(frame * 3 + i); + if (differentSymbolType) { + console.warn('Different symbol type will be ignored.'); } } - var targetIndices = this._indicesTmp; - var targetTriangleZList = this._triangleZListTmp; - var faceZList = this._triangleZList; - for (var i = 0; i < this.triangleCount; i++) { - var fromIdx3 = sortedTriangleIndices[i] * 3; - var toIdx3 = i * 3; - targetIndices[toIdx3++] = indices[fromIdx3++]; - targetIndices[toIdx3++] = indices[fromIdx3++]; - targetIndices[toIdx3] = indices[fromIdx3]; + return { + maxSize: maxSymbolSize, + type: symbolType, + aspect: symbolAspect + }; + } +}; - targetTriangleZList[i] = faceZList[sortedTriangleIndices[i]]; - } +/* harmony default export */ __webpack_exports__["a"] = (PointsBuilder); - // Swap indices. - var tmp = this._indicesTmp; - this._indicesTmp = this.indices; - this.indices = tmp; - var tmp = this._triangleZListTmp; - this._triangleZListTmp = this._triangleZList; - this._triangleZList = tmp; - this.dirtyIndices(); - }, +/***/ }), +/* 68 */ +/***/ (function(module, exports) { - _simpleSort: function (useNativeQuickSort) { - var faceZList = this._triangleZList; - var sortedTriangleIndices = this._sortedTriangleIndices; +var g; - function compare(a, b) { - // Sort from far to near. which is descending order - return faceZList[b] - faceZList[a]; - } - if (useNativeQuickSort) { - Array.prototype.sort.call(sortedTriangleIndices, compare); +// 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; + + +/***/ }), +/* 69 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__LinkedList__ = __webpack_require__(114); + + +/** + * LRU Cache + * @constructor + * @alias clay.core.LRU + */ +var LRU = function (maxSize) { + + this._list = new __WEBPACK_IMPORTED_MODULE_0__LinkedList__["a" /* default */](); + + this._map = {}; + + this._maxSize = maxSize || 10; +}; + +/** + * Set cache max size + * @param {number} size + */ +LRU.prototype.setMaxSize = function (size) { + this._maxSize = size; +}; + +/** + * @param {string} key + * @param {} value + */ +LRU.prototype.put = function (key, value) { + if (!this._map.hasOwnProperty(key)) { + var len = this._list.length(); + if (len >= this._maxSize && len > 0) { + // Remove the least recently used + var leastUsedEntry = this._list.head; + this._list.remove(leastUsedEntry); + delete this._map[leastUsedEntry.key]; } - else { - __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__["a" /* default */].sort(sortedTriangleIndices, compare, 0, sortedTriangleIndices.length - 1); + + var entry = this._list.insert(value); + entry.key = key; + this._map[key] = entry; + } +}; + +/** + * @param {string} key + * @return {} + */ +LRU.prototype.get = function (key) { + var entry = this._map[key]; + if (this._map.hasOwnProperty(key)) { + // Put the latest used entry in the tail + if (entry !== this._list.tail) { + this._list.remove(entry); + this._list.insertEntry(entry); } - }, - _progressiveQuickSort: function (frame) { - var faceZList = this._triangleZList; - var sortedTriangleIndices = this._sortedTriangleIndices; + return entry.value; + } +}; + +/** + * @param {string} key + */ +LRU.prototype.remove = function (key) { + var entry = this._map[key]; + if (typeof(entry) !== 'undefined') { + delete this._map[key]; + this._list.remove(entry); + } +}; + +/** + * Clear the cache + */ +LRU.prototype.clear = function () { + this._list.clear(); + this._map = {}; +}; + +/* harmony default export */ __webpack_exports__["a"] = (LRU); + + +/***/ }), +/* 70 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20); + +/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. 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 HOLDER 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 USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + + + +/** + * @class 2 Dimensional Vector + * @name vec2 + */ + +var vec2 = {}; + +/** + * Creates a new, empty vec2 + * + * @returns {vec2} a new 2D vector + */ +vec2.create = function() { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](2); + 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 + */ +vec2.clone = function(a) { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](2); + out[0] = a[0]; + out[1] = a[1]; + return out; +}; - this._quickSort = this._quickSort || new __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__["a" /* default */](); +/** + * 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 + */ +vec2.fromValues = function(x, y) { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](2); + out[0] = x; + out[1] = y; + return out; +}; - this._quickSort.step(sortedTriangleIndices, function (a, b) { - return faceZList[b] - faceZList[a]; - }, frame); - } -}); +/** + * Copy the values from one vec2 to another + * + * @param {vec2} out the receiving vector + * @param {vec2} a the source vector + * @returns {vec2} out + */ +vec2.copy = function(out, a) { + out[0] = a[0]; + out[1] = a[1]; + return out; +}; -/***/ }), -/* 61 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +/** + * 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 + */ +vec2.set = function(out, x, y) { + out[0] = x; + out[1] = y; + return out; +}; -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_ZRTextureAtlasSurface__ = __webpack_require__(73); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_mesh_LabelsMesh__ = __webpack_require__(58); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_retrieve__ = __webpack_require__(3); +/** + * 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 + */ +vec2.add = function(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 + */ +vec2.subtract = function(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + return out; +}; +/** + * Alias for {@link vec2.subtract} + * @function + */ +vec2.sub = vec2.subtract; +/** + * 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 + */ +vec2.multiply = function(out, a, b) { + out[0] = a[0] * b[0]; + out[1] = a[1] * b[1]; + return out; +}; +/** + * Alias for {@link vec2.multiply} + * @function + */ +vec2.mul = vec2.multiply; -var LABEL_NORMAL_SHOW_BIT = 1; -var LABEL_EMPHASIS_SHOW_BIT = 2; +/** + * 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 + */ +vec2.divide = function(out, a, b) { + out[0] = a[0] / b[0]; + out[1] = a[1] / b[1]; + return out; +}; -function LabelsBuilder(width, height, api) { +/** + * Alias for {@link vec2.divide} + * @function + */ +vec2.div = vec2.divide; - this._labelsMesh = new __WEBPACK_IMPORTED_MODULE_2__util_mesh_LabelsMesh__["a" /* default */](); +/** + * 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 + */ +vec2.min = function(out, a, b) { + out[0] = Math.min(a[0], b[0]); + out[1] = Math.min(a[1], b[1]); + return out; +}; - this._labelTextureSurface = new __WEBPACK_IMPORTED_MODULE_1__util_ZRTextureAtlasSurface__["a" /* default */]({ - width: 512, - height: 512, - devicePixelRatio: api.getDevicePixelRatio(), - onupdate: function () { - api.getZr().refresh(); - } - }); - this._api = api; +/** + * 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 + */ +vec2.max = function(out, a, b) { + out[0] = Math.max(a[0], b[0]); + out[1] = Math.max(a[1], b[1]); + return out; +}; - this._labelsMesh.material.set('textureAtlas', this._labelTextureSurface.getTexture()); -} +/** + * 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 + */ +vec2.scale = function(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + return out; +}; -LabelsBuilder.prototype.getLabelPosition = function (dataIndex, positionDesc, distance) { - return [0, 0, 0]; +/** + * 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 + */ +vec2.scaleAndAdd = function(out, a, b, scale) { + out[0] = a[0] + (b[0] * scale); + out[1] = a[1] + (b[1] * scale); + return out; }; -LabelsBuilder.prototype.getLabelDistance = function (dataIndex, positionDesc, distance) { - return 0; +/** + * 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 + */ +vec2.distance = function(a, b) { + var x = b[0] - a[0], + y = b[1] - a[1]; + return Math.sqrt(x*x + y*y); }; -LabelsBuilder.prototype.getMesh = function () { - return this._labelsMesh; +/** + * Alias for {@link vec2.distance} + * @function + */ +vec2.dist = vec2.distance; + +/** + * 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 + */ +vec2.squaredDistance = function(a, b) { + var x = b[0] - a[0], + y = b[1] - a[1]; + return x*x + y*y; }; -LabelsBuilder.prototype.updateData = function (data, start, end) { - if (start == null) { - start = 0; - } - if (end == null) { - end = data.count(); - } +/** + * Alias for {@link vec2.squaredDistance} + * @function + */ +vec2.sqrDist = vec2.squaredDistance; - if (!this._labelsVisibilitiesBits || this._labelsVisibilitiesBits.length !== (end - start)) { - this._labelsVisibilitiesBits = new Uint8Array(end - start); - } - var normalLabelVisibilityQuery = ['label', 'show']; - var emphasisLabelVisibilityQuery = ['emphasis', 'label', 'show']; +/** + * Calculates the length of a vec2 + * + * @param {vec2} a vector to calculate length of + * @returns {Number} length of a + */ +vec2.length = function (a) { + var x = a[0], + y = a[1]; + return Math.sqrt(x*x + y*y); +}; - for (var idx = start; idx < end; idx++) { - var itemModel = data.getItemModel(idx); - var normalVisibility = itemModel.get(normalLabelVisibilityQuery); - var emphasisVisibility = itemModel.get(emphasisLabelVisibilityQuery); - if (emphasisVisibility == null) { - emphasisVisibility = normalVisibility; - } - var bit = (normalVisibility ? LABEL_NORMAL_SHOW_BIT : 0) - | (emphasisVisibility ? LABEL_EMPHASIS_SHOW_BIT : 0); - this._labelsVisibilitiesBits[idx - start] = bit; - } +/** + * Alias for {@link vec2.length} + * @function + */ +vec2.len = vec2.length; - this._start = start; - this._end = end; +/** + * Calculates the squared length of a vec2 + * + * @param {vec2} a vector to calculate squared length of + * @returns {Number} squared length of a + */ +vec2.squaredLength = function (a) { + var x = a[0], + y = a[1]; + return x*x + y*y; +}; - this._data = data; +/** + * Alias for {@link vec2.squaredLength} + * @function + */ +vec2.sqrLen = vec2.squaredLength; + +/** + * Negates the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to negate + * @returns {vec2} out + */ +vec2.negate = function(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + return out; }; -LabelsBuilder.prototype.updateLabels = function (highlightDataIndices) { +/** + * Returns the inverse of the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to invert + * @returns {vec2} out + */ +vec2.inverse = function(out, a) { + out[0] = 1.0 / a[0]; + out[1] = 1.0 / a[1]; + return out; +}; - if (!this._data) { - return; +/** + * Normalize a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to normalize + * @returns {vec2} out + */ +vec2.normalize = function(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; +}; - highlightDataIndices = highlightDataIndices || []; +/** + * 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 + */ +vec2.dot = function (a, b) { + return a[0] * b[0] + a[1] * b[1]; +}; - var hasHighlightData = highlightDataIndices.length > 0; - var highlightDataIndicesMap = {}; - for (var i = 0; i < highlightDataIndices.length; i++) { - highlightDataIndicesMap[highlightDataIndices[i]] = true; - } +/** + * 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 + */ +vec2.cross = function(out, a, b) { + var z = a[0] * b[1] - a[1] * b[0]; + out[0] = out[1] = 0; + out[2] = z; + return out; +}; - this._labelsMesh.geometry.convertToDynamicArray(true); - this._labelTextureSurface.clear(); +/** + * 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 between the two inputs + * @returns {vec2} out + */ +vec2.lerp = function (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; +}; - var normalLabelQuery = ['label']; - var emphasisLabelQuery = ['emphasis', 'label']; - var seriesModel = this._data.hostModel; - var data = this._data; +/** + * 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 + */ +vec2.random = function (out, scale) { + scale = scale || 1.0; + var r = GLMAT_RANDOM() * 2.0 * Math.PI; + out[0] = Math.cos(r) * scale; + out[1] = Math.sin(r) * scale; + return out; +}; - var seriesLabelModel = seriesModel.getModel(normalLabelQuery); - var seriesLabelEmphasisModel = seriesModel.getModel(emphasisLabelQuery, seriesLabelModel); +/** + * 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 + */ +vec2.transformMat2 = function(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; +}; - var textAlignMap = { - left: 'right', - right: 'left', - top: 'center', - bottom: 'center' - }; - var textVerticalAlignMap = { - left: 'middle', - right: 'middle', - top: 'bottom', - bottom: 'top' - }; +/** + * 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 + */ +vec2.transformMat2d = function(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; +}; - for (var dataIndex = this._start; dataIndex < this._end; dataIndex++) { - var isEmphasis = false; - if (hasHighlightData && highlightDataIndicesMap[dataIndex]) { - isEmphasis = true; - } - var ifShow = this._labelsVisibilitiesBits[dataIndex - this._start] - & (isEmphasis ? LABEL_EMPHASIS_SHOW_BIT : LABEL_NORMAL_SHOW_BIT); - if (!ifShow) { - continue; - } +/** + * 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 + */ +vec2.transformMat3 = function(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; +}; - var itemModel = data.getItemModel(dataIndex); - var labelModel = itemModel.getModel( - isEmphasis ? emphasisLabelQuery : normalLabelQuery, - isEmphasis ? seriesLabelEmphasisModel : seriesLabelModel - ); - var distance = labelModel.get('distance') || 0; - var position = labelModel.get('position'); - var textStyleModel = labelModel.getModel('textStyle'); +/** + * 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 + */ +vec2.transformMat4 = function(out, a, m) { + var x = a[0], + 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; +}; + +/** + * 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 + */ +vec2.forEach = (function() { + var vec = vec2.create(); - var dpr = this._api.getDevicePixelRatio(); - var text = seriesModel.getFormattedLabel(dataIndex, isEmphasis ? 'emphasis' : 'normal'); - if (text == null || text === '') { - return; + return function(a, stride, offset, count, fn, arg) { + var i, l; + if(!stride) { + stride = 2; } - // TODO Background. - var textEl = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.Text(); - __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.setTextStyle(textEl.style, textStyleModel, { - text: text, - textFill: textStyleModel.get('color') || data.getItemVisual(dataIndex, 'color') || '#000', - textAlign: 'left', - textVerticalAlign: 'top', - opacity: __WEBPACK_IMPORTED_MODULE_3__util_retrieve__["a" /* default */].firstNotNull(textStyleModel.get('opacity'), data.getItemVisual(dataIndex, 'opacity'), 1) - }); - var rect = textEl.getBoundingRect(); - var lineHeight = 1.2; - rect.height *= lineHeight; + if(!offset) { + offset = 0; + } - var coords = this._labelTextureSurface.add(textEl); + if(count) { + l = Math.min((count * stride) + offset, a.length); + } else { + l = a.length; + } - var textAlign = textAlignMap[position] || 'center'; - var textVerticalAlign = textVerticalAlignMap[position] || 'bottom'; + 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]; + } - this._labelsMesh.geometry.addSprite( - this.getLabelPosition(dataIndex, position, distance), - [rect.width * dpr, rect.height * dpr], coords, - textAlign, textVerticalAlign, - this.getLabelDistance(dataIndex, position, distance) * dpr - ); - } + return a; + }; +})(); - this._labelsMesh.material.set('uvScale', this._labelTextureSurface.getCoordsScale()); +/* harmony default export */ __webpack_exports__["a"] = (vec2); - // var canvas = this._labelTextureSurface.getTexture().image; - // document.body.appendChild(canvas); - // canvas.style.cssText = 'position:absolute;z-index: 1000'; +/***/ }), +/* 71 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - // Update image. - this._labelTextureSurface.getZr().refreshImmediately(); - this._labelsMesh.geometry.convertToTypedArray(); - this._labelsMesh.geometry.dirty(); -}; +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ("@export clay.prez.vertex\nuniform mat4 WVP : WORLDVIEWPROJECTION;\nattribute vec3 pos : POSITION;\nattribute vec2 uv : TEXCOORD_0;\n@import clay.chunk.skinning_header\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec3 P = pos;\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = (skinMatrixWS * vec4(pos, 1.0)).xyz;\n#endif\n gl_Position = WVP * vec4(P, 1.0);\n v_Texcoord = uv;\n}\n@end\n@export clay.prez.fragment\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\n}\n@end"); -/* harmony default export */ __webpack_exports__["a"] = (LabelsBuilder); /***/ }), -/* 62 */ +/* 72 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_sprite__ = __webpack_require__(231); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__PointsMesh__ = __webpack_require__(232); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__component_common_LabelsBuilder__ = __webpack_require__(61); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__util_retrieve__ = __webpack_require__(3); - +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(35); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); +/** + * @constructor + * @alias clay.Renderable + * @extends clay.Node + */ +var Renderable = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(/** @lends clay.Renderable# */ { + /** + * @type {clay.Material} + */ + material: null, + /** + * @type {clay.Geometry} + */ + geometry: null, + /** + * @type {number} + */ + mode: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLES, + _renderInfo: null +}, +/** @lends clay.Renderable.prototype */ +{ -var SDF_RANGE = 20; + __program: null, -var Z_2D = -10; + /** + * Group of received light. + */ + lightGroup: 0, + /** + * Render order, Nodes with smaller value renders before nodes with larger values. + * @type {Number} + */ + renderOrder: 0, -function isSymbolSizeSame(a, b) { - return a && b && a[0] === b[0] && a[1] === b[1]; -} -// TODO gl_PointSize has max value. -function PointsBuilder(is2D, api) { - this.rootNode = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node(); + /** + * Used when mode is LINES, LINE_STRIP or LINE_LOOP + * @type {number} + */ + // lineWidth: 1, /** + * If enable culling * @type {boolean} */ - this.is2D = is2D; - - this._labelsBuilder = new __WEBPACK_IMPORTED_MODULE_4__component_common_LabelsBuilder__["a" /* default */](256, 256, api); - - // Give a large render order. - this._labelsBuilder.getMesh().renderOrder = 100; - this.rootNode.add(this._labelsBuilder.getMesh()); - - this._api = api; - - this._spriteImageCanvas = document.createElement('canvas'); - - this._startDataIndex = 0; - this._endDataIndex = 0; - - this._sizeScale = 1; -} - -PointsBuilder.prototype = { + culling: true, + /** + * Specify which side of polygon will be culled. + * Possible values: + * + {@link clay.Renderable.BACK} + * + {@link clay.Renderable.FRONT} + * + {@link clay.Renderable.FRONT_AND_BACK} + * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/cullFace + * @type {number} + */ + cullFace: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].BACK, + /** + * Specify which side is front face. + * Possible values: + * + {@link clay.Renderable.CW} + * + {@link clay.Renderable.CCW} + * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/frontFace + * @type {number} + */ + frontFace: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CCW, - constructor: PointsBuilder, + /** + * If enable software frustum culling + * @type {boolean} + */ + frustumCulling: true, + /** + * @type {boolean} + */ + receiveShadow: true, + /** + * @type {boolean} + */ + castShadow: true, + /** + * @type {boolean} + */ + ignorePicking: false, + /** + * @type {boolean} + */ + ignorePreZ: false, /** - * If highlight on over + * @type {boolean} */ - highlightOnMouseover: true, + ignoreGBuffer: false, - update: function (seriesModel, ecModel, api, start, end) { - // Swap barMesh - var tmp = this._prevMesh; - this._prevMesh = this._mesh; - this._mesh = tmp; + /** + * @return {boolean} + */ + isRenderable: function() { + // TODO Shader ? + return this.geometry && this.material && this.material.shader && !this.invisible + && this.geometry.vertexCount > 0; + }, - var data = seriesModel.getData(); + /** + * Before render hook + * @type {Function} + */ + beforeRender: function (_gl) {}, - if (start == null) { - start = 0; - } - if (end == null) { - end = data.count(); - } - this._startDataIndex = start; - this._endDataIndex = end - 1; + /** + * Before render hook + * @type {Function} + */ + afterRender: function (_gl, renderStat) {}, - if (!this._mesh) { - var material = this._prevMesh && this._prevMesh.material; - this._mesh = new __WEBPACK_IMPORTED_MODULE_3__PointsMesh__["a" /* default */]({ - // Render after axes - renderOrder: 10, - // FIXME - frustumCulling: false - }); - if (material) { - this._mesh.material = material; - } + getBoundingBox: function (filter, out) { + out = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].prototype.getBoundingBox.call(this, filter, out); + if (this.geometry && this.geometry.boundingBox) { + out.union(this.geometry.boundingBox); } - var material = this._mesh.material; - var geometry = this._mesh.geometry; - var attributes = geometry.attributes; - - this.rootNode.remove(this._prevMesh); - this.rootNode.add(this._mesh); - this._setPositionTextureToMesh(this._mesh, this._positionTexture); + return out; + }, - var symbolInfo = this._getSymbolInfo(seriesModel, start, end); - var dpr = api.getDevicePixelRatio(); + /** + * Clone a new renderable + * @function + * @return {clay.Renderable} + */ + clone: (function() { + var properties = [ + 'castShadow', 'receiveShadow', + 'mode', 'culling', 'cullFace', 'frontFace', + 'frustumCulling', + 'renderOrder', 'lineWidth', + 'ignorePicking', 'ignorePreZ', 'ignoreGBuffer' + ]; + return function() { + var renderable = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].prototype.clone.call(this); - // TODO image symbol - var itemStyle = seriesModel.getModel('itemStyle').getItemStyle(); - var largeMode = seriesModel.get('large'); + renderable.geometry = this.geometry; + renderable.material = this.material; - var pointSizeScale = 1; - if (symbolInfo.maxSize > 2) { - pointSizeScale = this._updateSymbolSprite(seriesModel, itemStyle, symbolInfo, dpr); - material.enableTexture('sprite'); - } - else { - material.disableTexture('sprite'); - } + for (var i = 0; i < properties.length; i++) { + var name = properties[i]; + // Try not to overwrite the prototype property + if (renderable[name] !== this[name]) { + renderable[name] = this[name]; + } + } - attributes.position.init(end - start); - var rgbaArr = []; - if (largeMode) { - material.undefine('VERTEX_SIZE'); - material.undefine('VERTEX_COLOR'); + return renderable; + }; + })() +}); - var color = data.getVisual('color'); - var opacity = data.getVisual('opacity'); - __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color, rgbaArr); - rgbaArr[3] *= opacity; +/** + * @type {number} + */ +Renderable.POINTS = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].POINTS; +/** + * @type {number} + */ +Renderable.LINES = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINES; +/** + * @type {number} + */ +Renderable.LINE_LOOP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINE_LOOP; +/** + * @type {number} + */ +Renderable.LINE_STRIP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINE_STRIP; +/** + * @type {number} + */ +Renderable.TRIANGLES = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLES; +/** + * @type {number} + */ +Renderable.TRIANGLE_STRIP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLE_STRIP; +/** + * @type {number} + */ +Renderable.TRIANGLE_FAN = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLE_FAN; +/** + * @type {number} + */ +Renderable.BACK = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].BACK; +/** + * @type {number} + */ +Renderable.FRONT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FRONT; +/** + * @type {number} + */ +Renderable.FRONT_AND_BACK = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FRONT_AND_BACK; +/** + * @type {number} + */ +Renderable.CW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CW; +/** + * @type {number} + */ +Renderable.CCW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CCW; - material.set({ - color: rgbaArr, - 'u_Size': symbolInfo.maxSize * this._sizeScale - }); - } - else { - material.set({ - color: [1, 1, 1, 1] - }); - material.define('VERTEX_SIZE'); - material.define('VERTEX_COLOR'); - attributes.size.init(end - start); - attributes.color.init(end - start); - this._originalOpacity = new Float32Array(end - start); - } +/* harmony default export */ __webpack_exports__["a"] = (Renderable); - var points = data.getLayout('points'); - var positionArr = attributes.position.value; +/***/ }), +/* 73 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - var hasTransparentPoint = false; +"use strict"; +var mathUtil = {}; - for (var i = 0; i < end - start; i++) { - var i3 = i * 3; - var i2 = i * 2; - if (this.is2D) { - positionArr[i3] = points[i2]; - positionArr[i3 + 1] = points[i2 + 1]; - positionArr[i3 + 2] = Z_2D; - } - else { - positionArr[i3] = points[i3]; - positionArr[i3 + 1] = points[i3 + 1]; - positionArr[i3 + 2] = points[i3 + 2]; - } +mathUtil.isPowerOfTwo = function (value) { + return (value & (value - 1)) === 0; +}; - if (!largeMode) { - var color = data.getItemVisual(i, 'color'); - var opacity = data.getItemVisual(i, 'opacity'); - __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color, rgbaArr); - rgbaArr[3] *= opacity; - attributes.color.set(i, rgbaArr); - if (rgbaArr[3] < 0.99) { - hasTransparentPoint = true; - } - var symbolSize = data.getItemVisual(i, 'symbolSize'); - symbolSize = (symbolSize instanceof Array - ? Math.max(symbolSize[0], symbolSize[1]) : symbolSize); +mathUtil.nextPowerOfTwo = function (value) { + value --; + value |= value >> 1; + value |= value >> 2; + value |= value >> 4; + value |= value >> 8; + value |= value >> 16; + value ++; - // NaN pointSize may have strange result. - if (isNaN(symbolSize)) { - symbolSize = 0; - } - // Scale point size because canvas has margin. - attributes.size.value[i] = symbolSize * pointSizeScale * this._sizeScale; + return value; +}; - // Save the original opacity for recover from fadeIn. - this._originalOpacity[i] = rgbaArr[3]; - } +mathUtil.nearestPowerOfTwo = function (value) { + return Math.pow( 2, Math.round( Math.log( value ) / Math.LN2 ) ); +}; - } +/* harmony default export */ __webpack_exports__["a"] = (mathUtil); - this._mesh.sizeScale = pointSizeScale; - geometry.updateBoundingBox(); - geometry.dirty(); +/***/ }), +/* 74 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - // Update material. - this._updateMaterial(seriesModel, itemStyle); +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat4__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__glmatrix_vec4__ = __webpack_require__(33); - var coordSys = seriesModel.coordinateSystem; - if (coordSys && coordSys.viewGL) { - var methodName = coordSys.viewGL.isLinearSpace() ? 'define' : 'undefine'; - material[methodName]('fragment', 'SRGB_DECODE'); - } - if (!largeMode) { - this._updateLabelBuilder(seriesModel, start, end); - } - this._updateHandler(seriesModel, ecModel, api); - this._updateAnimation(seriesModel); - this._api = api; - }, +/** + * @constructor + * @alias clay.Plane + * @param {clay.Vector3} [normal] + * @param {number} [distance] + */ +var Plane = function(normal, distance) { + /** + * Normal of the plane + * @type {clay.Vector3} + */ + this.normal = normal || new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](0, 1, 0); - getPointsMesh: function () { - return this._mesh; - }, + /** + * Constant of the plane equation, used as distance to the origin + * @type {number} + */ + this.distance = distance || 0; +}; - updateLabels: function (highlightDataIndices) { - this._labelsBuilder.updateLabels(highlightDataIndices); - }, +Plane.prototype = { - hideLabels: function () { - this.rootNode.remove(this._labelsBuilder.getMesh()); - }, + constructor: Plane, - showLabels: function () { - this.rootNode.add(this._labelsBuilder.getMesh()); + /** + * Distance from a given point to the plane + * @param {clay.Vector3} point + * @return {number} + */ + distanceToPoint: function(point) { + return __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].dot(point.array, this.normal.array) - this.distance; }, - _updateSymbolSprite: function (seriesModel, itemStyle, symbolInfo, dpr) { - symbolInfo.maxSize = Math.min(symbolInfo.maxSize * 2, 200); - var symbolSize = []; - if (symbolInfo.aspect > 1) { - symbolSize[0] = symbolInfo.maxSize; - symbolSize[1] = symbolInfo.maxSize / symbolInfo.aspect; - } - else { - symbolSize[1] = symbolInfo.maxSize; - symbolSize[0] = symbolInfo.maxSize * symbolInfo.aspect; - } - - // In case invalid data. - symbolSize[0] = symbolSize[0] || 1; - symbolSize[1] = symbolSize[1] || 1; - - if (this._symbolType !== symbolInfo.type - || !isSymbolSizeSame(this._symbolSize, symbolSize) - || this._lineWidth !== itemStyle.lineWidth - ) { - __WEBPACK_IMPORTED_MODULE_2__util_sprite__["a" /* default */].createSymbolSprite(symbolInfo.type, symbolSize, { - fill: '#fff', - lineWidth: itemStyle.lineWidth, - stroke: 'transparent', - shadowColor: 'transparent', - minMargin: Math.min(symbolSize[0] / 2, 10) - }, this._spriteImageCanvas); - - __WEBPACK_IMPORTED_MODULE_2__util_sprite__["a" /* default */].createSDFFromCanvas( - this._spriteImageCanvas, Math.min(this._spriteImageCanvas.width, 32), SDF_RANGE, - this._mesh.material.get('sprite').image - ); - - this._symbolType = symbolInfo.type; - this._symbolSize = symbolSize; - this._lineWidth = itemStyle.lineWidth; + /** + * Calculate the projection point on the plane + * @param {clay.Vector3} point + * @param {clay.Vector3} out + * @return {clay.Vector3} + */ + projectPoint: function(point, out) { + if (!out) { + out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](); } - return this._spriteImageCanvas.width / symbolInfo.maxSize * dpr; - + var d = this.distanceToPoint(point); + __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, point.array, this.normal.array, -d); + out._dirty = true; + return out; }, - _updateMaterial: function (seriesModel, itemStyle) { - var blendFunc = seriesModel.get('blendMode') === 'lighter' - ? __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].additiveBlend : null; - var material = this._mesh.material; - material.blend = blendFunc; - - material.set('lineWidth', itemStyle.lineWidth / SDF_RANGE); - - var strokeColor = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(itemStyle.stroke); - material.set('strokeColor', strokeColor); + /** + * Normalize the plane's normal and calculate the distance + */ + normalize: function() { + var invLen = 1 / __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].len(this.normal.array); + __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].scale(this.normal.array, invLen); + this.distance *= invLen; + }, - // Because of symbol texture, we always needs it be transparent. - material.transparent = true; - material.depthMask = false; - material.depthTest = !this.is2D; - material.sortVertices = !this.is2D; + /** + * If the plane intersect a frustum + * @param {clay.Frustum} Frustum + * @return {boolean} + */ + intersectFrustum: function(frustum) { + // Check if all coords of frustum is on plane all under plane + var coords = frustum.vertices; + var normal = this.normal.array; + var onPlane = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].dot(coords[0].array, normal) > this.distance; + for (var i = 1; i < 8; i++) { + if ((__WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].dot(coords[i].array, normal) > this.distance) != onPlane) { + return true; + } + } }, - _updateLabelBuilder: function (seriesModel, start, end) { - var data =seriesModel.getData(); - var geometry = this._mesh.geometry; - var positionArr = geometry.attributes.position.value; - var start = this._startDataIndex; - var pointSizeScale = this._mesh.sizeScale; - this._labelsBuilder.updateData(data, start, end); + /** + * Calculate the intersection point between plane and a given line + * @function + * @param {clay.Vector3} start start point of line + * @param {clay.Vector3} end end point of line + * @param {clay.Vector3} [out] + * @return {clay.Vector3} + */ + intersectLine: (function() { + var rd = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].create(); + return function(start, end, out) { + var d0 = this.distanceToPoint(start); + var d1 = this.distanceToPoint(end); + if ((d0 > 0 && d1 > 0) || (d0 < 0 && d1 < 0)) { + return null; + } + // Ray intersection + var pn = this.normal.array; + var d = this.distance; + var ro = start.array; + // direction + __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].sub(rd, end.array, start.array); + __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].normalize(rd, rd); - this._labelsBuilder.getLabelPosition = function (dataIndex, positionDesc, distance) { - var idx3 = (dataIndex - start) * 3; - return [positionArr[idx3], positionArr[idx3 + 1], positionArr[idx3 + 2]]; + var divider = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].dot(pn, rd); + // ray is parallel to the plane + if (divider === 0) { + return null; + } + if (!out) { + out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](); + } + var t = (__WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].dot(pn, ro) - d) / divider; + __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, ro, rd, -t); + out._dirty = true; + return out; }; + })(), - this._labelsBuilder.getLabelDistance = function (dataIndex, positionDesc, distance) { - var size = geometry.attributes.size.get(dataIndex - start) / pointSizeScale; - return size / 2 + distance; + /** + * Apply an affine transform matrix to plane + * @function + * @return {clay.Matrix4} + */ + applyTransform: (function() { + var inverseTranspose = __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat4__["a" /* default */].create(); + var normalv4 = __WEBPACK_IMPORTED_MODULE_3__glmatrix_vec4__["a" /* default */].create(); + var pointv4 = __WEBPACK_IMPORTED_MODULE_3__glmatrix_vec4__["a" /* default */].create(); + pointv4[3] = 1; + return function(m4) { + m4 = m4.array; + // Transform point on plane + __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].scale(pointv4, this.normal.array, this.distance); + __WEBPACK_IMPORTED_MODULE_3__glmatrix_vec4__["a" /* default */].transformMat4(pointv4, pointv4, m4); + this.distance = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].dot(pointv4, this.normal.array); + // Transform plane normal + __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat4__["a" /* default */].invert(inverseTranspose, m4); + __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat4__["a" /* default */].transpose(inverseTranspose, inverseTranspose); + normalv4[3] = 0; + __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].copy(normalv4, this.normal.array); + __WEBPACK_IMPORTED_MODULE_3__glmatrix_vec4__["a" /* default */].transformMat4(normalv4, normalv4, inverseTranspose); + __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].copy(this.normal.array, normalv4); }; - this._labelsBuilder.updateLabels(); + })(), + /** + * Copy from another plane + * @param {clay.Vector3} plane + */ + copy: function(plane) { + __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].copy(this.normal.array, plane.normal.array); + this.normal._dirty = true; + this.distance = plane.distance; }, - _updateAnimation: function (seriesModel) { - __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].updateVertexAnimation( - [['prevPosition', 'position'], - ['prevSize', 'size']], - this._prevMesh, - this._mesh, - seriesModel - ); - }, + /** + * Clone a new plane + * @return {clay.Plane} + */ + clone: function() { + var plane = new Plane(); + plane.copy(this); + return plane; + } +}; - _updateHandler: function (seriesModel, ecModel, api) { - var data = seriesModel.getData(); - var pointsMesh = this._mesh; - var self = this; +/* harmony default export */ __webpack_exports__["a"] = (Plane); - var lastDataIndex = -1; - var isCartesian3D = seriesModel.coordinateSystem - && seriesModel.coordinateSystem.type === 'cartesian3D'; - var grid3DModel; - if (isCartesian3D) { - grid3DModel = seriesModel.coordinateSystem.model; - } +/***/ }), +/* 75 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - pointsMesh.seriesIndex = seriesModel.seriesIndex; +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Skybox__ = __webpack_require__(42); - pointsMesh.off('mousemove'); - pointsMesh.off('mouseout'); - pointsMesh.on('mousemove', function (e) { - var dataIndex = e.vertexIndex + self._startDataIndex; - if (dataIndex !== lastDataIndex) { - if (this.highlightOnMouseover) { - this.downplay(data, lastDataIndex); - this.highlight(data, dataIndex); - this._labelsBuilder.updateLabels([dataIndex]); - } +/* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__Skybox__["a" /* default */]); - if (isCartesian3D) { - api.dispatchAction({ - type: 'grid3DShowAxisPointer', - value: [ - data.get(seriesModel.coordDimToDataDim('x')[0], dataIndex), - data.get(seriesModel.coordDimToDataDim('y')[0], dataIndex), - data.get(seriesModel.coordDimToDataDim('z')[0], dataIndex) - ], - grid3DIndex: grid3DModel.componentIndex - }); - } - } +/***/ }), +/* 76 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - pointsMesh.dataIndex = dataIndex; - lastDataIndex = dataIndex; - }, this); - pointsMesh.on('mouseout', function (e) { - var dataIndex = e.vertexIndex + self._startDataIndex; - if (this.highlightOnMouseover) { - this.downplay(data, dataIndex); - this._labelsBuilder.updateLabels(); - } - lastDataIndex = -1; - pointsMesh.dataIndex = -1; +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Geometry__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Plane__ = __webpack_require__(43); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__math_BoundingBox__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__core_vendor__ = __webpack_require__(14); - if (isCartesian3D) { - api.dispatchAction({ - type: 'grid3DHideAxisPointer', - grid3DIndex: grid3DModel.componentIndex - }); - } - }, this); - }, - updateLayout: function (seriesModel, ecModel, api) { - var data = seriesModel.getData(); - if (!this._mesh) { - return; - } - var positionArr = this._mesh.geometry.attributes.position.value; - var points = data.getLayout('points'); - if (this.is2D) { - for (var i = 0; i < points.length / 2; i++) { - var i3 = i * 3; - var i2 = i * 2; - positionArr[i3] = points[i2]; - positionArr[i3 + 1] = points[i2 + 1]; - positionArr[i3 + 2] = Z_2D; - } - } - else { - for (var i = 0; i < points.length; i++) { - positionArr[i] = points[i]; - } - } - this._mesh.geometry.dirty(); - api.getZr().refresh(); - }, - updateView: function (camera) { - if (!this._mesh) { - return; - } - var worldViewProjection = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */](); - __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */].mul(worldViewProjection, camera.viewMatrix, this._mesh.worldTransform); - __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */].mul(worldViewProjection, camera.projectionMatrix, worldViewProjection); - this._mesh.updateNDCPosition(worldViewProjection, this.is2D, this._api); - }, +var planeMatrix = new __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */](); - highlight: function (data, dataIndex) { - if (dataIndex > this._endDataIndex || dataIndex < this._startDataIndex) { - return; +/** + * @constructor clay.geometry.Cube + * @extends clay.Geometry + * @param {Object} [opt] + * @param {number} [opt.widthSegments] + * @param {number} [opt.heightSegments] + * @param {number} [opt.depthSegments] + * @param {boolean} [opt.inside] + */ +var Cube = __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].extend( +/**@lends clay.geometry.Cube# */ +{ + dynamic: false, + /** + * @type {number} + */ + widthSegments: 1, + /** + * @type {number} + */ + heightSegments: 1, + /** + * @type {number} + */ + depthSegments: 1, + /** + * @type {boolean} + */ + inside: false +}, function() { + this.build(); +}, +/** @lends clay.geometry.Cube.prototype */ +{ + /** + * Build cube geometry + */ + build: function() { + + var planes = { + 'px': createPlane('px', this.depthSegments, this.heightSegments), + 'nx': createPlane('nx', this.depthSegments, this.heightSegments), + 'py': createPlane('py', this.widthSegments, this.depthSegments), + 'ny': createPlane('ny', this.widthSegments, this.depthSegments), + 'pz': createPlane('pz', this.widthSegments, this.heightSegments), + 'nz': createPlane('nz', this.widthSegments, this.heightSegments), + }; + + var attrList = ['position', 'texcoord0', 'normal']; + var vertexNumber = 0; + var faceNumber = 0; + for (var pos in planes) { + vertexNumber += planes[pos].vertexCount; + faceNumber += planes[pos].indices.length; } - var itemModel = data.getItemModel(dataIndex); - var emphasisItemStyleModel = itemModel.getModel('emphasis.itemStyle'); - var emphasisColor = emphasisItemStyleModel.get('color'); - var emphasisOpacity = emphasisItemStyleModel.get('opacity'); - if (emphasisColor == null) { - var color = data.getItemVisual(dataIndex, 'color'); - emphasisColor = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.color.lift(color, -0.4); + for (var k = 0; k < attrList.length; k++) { + this.attributes[attrList[k]].init(vertexNumber); } - if (emphasisOpacity == null) { - emphasisOpacity = data.getItemVisual(dataIndex, 'opacity'); + this.indices = new __WEBPACK_IMPORTED_MODULE_5__core_vendor__["a" /* default */].Uint16Array(faceNumber); + var faceOffset = 0; + var vertexOffset = 0; + for (var pos in planes) { + var plane = planes[pos]; + for (var k = 0; k < attrList.length; k++) { + var attrName = attrList[k]; + var attrArray = plane.attributes[attrName].value; + var attrSize = plane.attributes[attrName].size; + var isNormal = attrName === 'normal'; + for (var i = 0; i < attrArray.length; i++) { + var value = attrArray[i]; + if (this.inside && isNormal) { + value = -value; + } + this.attributes[attrName].value[i + attrSize * vertexOffset] = value; + } + } + var len = plane.indices.length; + for (var i = 0; i < plane.indices.length; i++) { + this.indices[i + faceOffset] = vertexOffset + plane.indices[this.inside ? (len - i - 1) : i]; + } + faceOffset += plane.indices.length; + vertexOffset += plane.vertexCount; } - var colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(emphasisColor); - colorArr[3] *= emphasisOpacity; - this._mesh.geometry.attributes.color.set(dataIndex - this._startDataIndex, colorArr); - this._mesh.geometry.dirtyAttribute('color'); + this.boundingBox = new __WEBPACK_IMPORTED_MODULE_4__math_BoundingBox__["a" /* default */](); + this.boundingBox.max.set(1, 1, 1); + this.boundingBox.min.set(-1, -1, -1); + } +}); - this._api.getZr().refresh(); - }, +function createPlane(pos, widthSegments, heightSegments) { - downplay: function (data, dataIndex) { - if (dataIndex > this._endDataIndex || dataIndex < this._startDataIndex) { - return; - } - var color = data.getItemVisual(dataIndex, 'color'); - var opacity = data.getItemVisual(dataIndex, 'opacity'); + planeMatrix.identity(); - var colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color); - colorArr[3] *= opacity; + var plane = new __WEBPACK_IMPORTED_MODULE_1__Plane__["a" /* default */]({ + widthSegments: widthSegments, + heightSegments: heightSegments + }); - this._mesh.geometry.attributes.color.set(dataIndex - this._startDataIndex, colorArr); - this._mesh.geometry.dirtyAttribute('color'); + switch(pos) { + case 'px': + __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].POSITIVE_X); + __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateY(planeMatrix, planeMatrix, Math.PI / 2); + break; + case 'nx': + __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].NEGATIVE_X); + __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateY(planeMatrix, planeMatrix, -Math.PI / 2); + break; + case 'py': + __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].POSITIVE_Y); + __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateX(planeMatrix, planeMatrix, -Math.PI / 2); + break; + case 'ny': + __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].NEGATIVE_Y); + __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateX(planeMatrix, planeMatrix, Math.PI / 2); + break; + case 'pz': + __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].POSITIVE_Z); + break; + case 'nz': + __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].NEGATIVE_Z); + __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateY(planeMatrix, planeMatrix, Math.PI); + break; + } + plane.applyTransform(planeMatrix); + return plane; +} - this._api.getZr().refresh(); - }, +/* harmony default export */ __webpack_exports__["a"] = (Cube); - fadeOutAll: function (fadeOutPercent) { - if (this._originalOpacity) { - var geo = this._mesh.geometry; - for (var i = 0; i < geo.vertexCount; i++) { - var fadeOutOpacity = this._originalOpacity[i] * fadeOutPercent; - geo.attributes.color.value[i * 4 + 3] = fadeOutOpacity; - } - geo.dirtyAttribute('color'); - this._api.getZr().refresh(); - } - }, +/***/ }), +/* 77 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - fadeInAll: function () { - this.fadeOutAll(1); - }, +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture2D__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__TextureCube__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Texture__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__FrameBuffer__ = __webpack_require__(10); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__compositor_Pass__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Material__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Shader__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__plugin_Skybox__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Scene__ = __webpack_require__(36); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__prePass_EnvironmentMap__ = __webpack_require__(62); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__core_vendor__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__texture__ = __webpack_require__(61); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__shader_integrateBRDF_glsl_js__ = __webpack_require__(127); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__shader_prefilter_glsl_js__ = __webpack_require__(128); +// Cubemap prefilter utility +// http://www.unrealengine.com/files/downloads/2013SiggraphPresentationsNotes.pdf +// http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html - setPositionTexture: function (texture) { - if (this._mesh) { - this._setPositionTextureToMesh(this._mesh, texture); - } - this._positionTexture = texture; - }, - removePositionTexture: function () { - this._positionTexture = null; - if (this._mesh) { - this._setPositionTextureToMesh(this._mesh, null); - } - }, - setSizeScale: function (sizeScale) { - if (sizeScale !== this._sizeScale) { - if (this._mesh) { - var originalSize = this._mesh.material.get('u_Size'); - this._mesh.material.set('u_Size', originalSize / this._sizeScale * sizeScale); - var attributes = this._mesh.geometry.attributes; - if (attributes.size.value) { - for (var i = 0; i < attributes.size.value.length; i++) { - attributes.size.value[i] = attributes.size.value[i] / this._sizeScale * sizeScale; - } - } - } - this._sizeScale = sizeScale; - } - }, - _setPositionTextureToMesh: function (mesh, texture) { - if (texture) { - mesh.material.set('positionTexture', texture); - } - mesh.material[ - texture ? 'enableTexture' : 'disableTexture' - ]('positionTexture'); - }, - _getSymbolInfo: function (seriesModel, start, end) { - if (seriesModel.get('large')) { - var symbolSize = __WEBPACK_IMPORTED_MODULE_6__util_retrieve__["a" /* default */].firstNotNull(seriesModel.get('symbolSize'), 1); - var maxSymbolSize; - var symbolAspect; - if (symbolSize instanceof Array) { - maxSymbolSize = Math.max(symbolSize[0], symbolSize[1]); - symbolAspect = symbolSize[0] / symbolSize[1]; - } - else { - maxSymbolSize = symbolSize; - symbolAspect = 1; - } - return { - maxSize: symbolSize, - type: seriesModel.get('symbol'), - aspect: symbolAspect - } - } - var data = seriesModel.getData(); - var symbolAspect; - var differentSymbolAspect = false; - var symbolType = data.getItemVisual(0, 'symbol') || 'circle'; - var differentSymbolType = false; - var maxSymbolSize = 0; - for (var idx = start; idx < end; idx++) { - var symbolSize = data.getItemVisual(idx, 'symbolSize'); - var currentSymbolType = data.getItemVisual(idx, 'symbol'); - var currentSymbolAspect; - if (!(symbolSize instanceof Array)) { - // Ignore NaN value. - if (isNaN(symbolSize)) { - return; - } - currentSymbolAspect = 1; - maxSymbolSize = Math.max(symbolSize, maxSymbolSize); - } - else { - currentSymbolAspect = symbolSize[0] / symbolSize[1]; - maxSymbolSize = Math.max(Math.max(symbolSize[0], symbolSize[1]), maxSymbolSize); - } - if (true) { - if (symbolAspect != null && Math.abs(currentSymbolAspect - symbolAspect) > 0.05) { - differentSymbolAspect = true; - } - if (currentSymbolType !== symbolType) { - differentSymbolType = true; - } - } - symbolType = currentSymbolType; - symbolAspect = currentSymbolAspect; - } - if (true) { - if (differentSymbolAspect) { - console.warn('Different symbol width / height ratio will be ignored.'); - } - if (differentSymbolType) { - console.warn('Different symbol type will be ignored.'); - } - } - return { - maxSize: maxSymbolSize, - type: symbolType, - aspect: symbolAspect - }; - } -}; -/* harmony default export */ __webpack_exports__["a"] = (PointsBuilder); -/***/ }), -/* 63 */ -/***/ (function(module, exports) { -var g; -// This works in non-strict mode -g = (function() { - return this; -})(); +var cubemapUtil = {}; + +var targets = ['px', 'nx', 'py', 'ny', 'pz', 'nz']; + +// TODO Downsample +/** + * @name clay.util.cubemap.prefilterEnvironmentMap + * @param {clay.Renderer} renderer + * @param {clay.Texture} envMap + * @param {Object} [textureOpts] + * @param {number} [textureOpts.width=64] + * @param {number} [textureOpts.height=64] + * @param {number} [textureOpts.type] + * @param {boolean} [textureOpts.encodeRGBM=false] + * @param {boolean} [textureOpts.decodeRGBM=false] + * @param {clay.Texture2D} [normalDistribution] + * @param {clay.Texture2D} [brdfLookup] + */ +cubemapUtil.prefilterEnvironmentMap = function ( + renderer, envMap, textureOpts, normalDistribution, brdfLookup +) { + // Not create other renderer, it is easy having issue of cross reference of resources like framebuffer + // PENDING preserveDrawingBuffer? + if (!brdfLookup || !normalDistribution) { + normalDistribution = cubemapUtil.generateNormalDistribution(); + brdfLookup = cubemapUtil.integrateBRDF(renderer, normalDistribution); + } + textureOpts = textureOpts || {}; + + var width = textureOpts.width || 64; + var height = textureOpts.height || 64; + + var textureType = textureOpts.type || envMap.type; -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; -} + // Use same type with given envMap + var prefilteredCubeMap = new __WEBPACK_IMPORTED_MODULE_1__TextureCube__["a" /* default */]({ + width: width, + height: height, + type: textureType, + flipY: false, + mipmaps: [] + }); -// 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) { ...} + if (!prefilteredCubeMap.isPowerOfTwo()) { + console.warn('Width and height must be power of two to enable mipmap.'); + } -module.exports = g; + var size = Math.min(width, height); + var mipmapNum = Math.log(size) / Math.log(2) + 1; + var prefilterMaterial = new __WEBPACK_IMPORTED_MODULE_5__Material__["a" /* default */]({ + shader: new __WEBPACK_IMPORTED_MODULE_6__Shader__["a" /* default */]({ + vertex: __WEBPACK_IMPORTED_MODULE_6__Shader__["a" /* default */].source('clay.skybox.vertex'), + fragment: __WEBPACK_IMPORTED_MODULE_13__shader_prefilter_glsl_js__["a" /* default */] + }) + }); + prefilterMaterial.set('normalDistribution', normalDistribution); -/***/ }), -/* 64 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + textureOpts.encodeRGBM && prefilterMaterial.define('fragment', 'RGBM_ENCODE'); + textureOpts.decodeRGBM && prefilterMaterial.define('fragment', 'RGBM_DECODE'); -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__LinkedList__ = __webpack_require__(106); + var dummyScene = new __WEBPACK_IMPORTED_MODULE_8__Scene__["a" /* default */](); + var skyEnv; + if (envMap.textureType === 'texture2D') { + // Convert panorama to cubemap + var envCubemap = new __WEBPACK_IMPORTED_MODULE_1__TextureCube__["a" /* default */]({ + width: width, + height: height, + // FIXME FLOAT type will cause GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT error on iOS + type: textureType === __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].FLOAT ? + __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].HALF_FLOAT : textureType + }); + __WEBPACK_IMPORTED_MODULE_11__texture__["a" /* default */].panoramaToCubeMap(renderer, envMap, envCubemap, { + // PENDING encodeRGBM so it can be decoded as RGBM + encodeRGBM: textureOpts.decodeRGBM + }); + envMap = envCubemap; + } + skyEnv = new __WEBPACK_IMPORTED_MODULE_7__plugin_Skybox__["a" /* default */]({ + scene: dummyScene, + material: prefilterMaterial + }); + skyEnv.material.set('environmentMap', envMap); -/** - * LRU Cache - * @constructor - * @alias clay.core.LRU - */ -var LRU = function(maxSize) { + var envMapPass = new __WEBPACK_IMPORTED_MODULE_9__prePass_EnvironmentMap__["a" /* default */]({ + texture: prefilteredCubeMap + }); - this._list = new __WEBPACK_IMPORTED_MODULE_0__LinkedList__["a" /* default */](); + // Force to be UNSIGNED_BYTE + if (textureOpts.encodeRGBM) { + textureType = prefilteredCubeMap.type = __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].UNSIGNED_BYTE; + } - this._map = {}; + var renderTargetTmp = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]({ + width: width, + height: height, + type: textureType + }); + var frameBuffer = new __WEBPACK_IMPORTED_MODULE_3__FrameBuffer__["a" /* default */]({ + depthBuffer: false + }); + var ArrayCtor = __WEBPACK_IMPORTED_MODULE_10__core_vendor__["a" /* default */][textureType === __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].UNSIGNED_BYTE ? 'Uint8Array' : 'Float32Array']; + for (var i = 0; i < mipmapNum; i++) { + // console.time('prefilter'); + prefilteredCubeMap.mipmaps[i] = { + pixels: {} + }; + skyEnv.material.set('roughness', i / (mipmapNum - 1)); - this._maxSize = maxSize || 10; -}; + // Tweak fov + // http://the-witness.net/news/2012/02/seamless-cube-map-filtering/ + var n = renderTargetTmp.width; + var fov = 2 * Math.atan(n / (n - 0.5)) / Math.PI * 180; -/** - * Set cache max size - * @param {number} size - */ -LRU.prototype.setMaxSize = function(size) { - this._maxSize = size; -}; + for (var j = 0; j < targets.length; j++) { + var pixels = new ArrayCtor(renderTargetTmp.width * renderTargetTmp.height * 4); + frameBuffer.attach(renderTargetTmp); + frameBuffer.bind(renderer); -/** - * @param {string} key - * @param {} value - */ -LRU.prototype.put = function(key, value) { - if (typeof(this._map[key]) == 'undefined') { - var len = this._list.length(); - if (len >= this._maxSize && len > 0) { - // Remove the least recently used - var leastUsedEntry = this._list.head; - this._list.remove(leastUsedEntry); - delete this._map[leastUsedEntry.key]; - } + var camera = envMapPass.getCamera(targets[j]); + camera.fov = fov; + renderer.render(dummyScene, camera); + renderer.gl.readPixels( + 0, 0, renderTargetTmp.width, renderTargetTmp.height, + __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].RGBA, textureType, pixels + ); - var entry = this._list.insert(value); - entry.key = key; - this._map[key] = entry; - } -}; + // var canvas = document.createElement('canvas'); + // var ctx = canvas.getContext('2d'); + // canvas.width = renderTargetTmp.width; + // canvas.height = renderTargetTmp.height; + // var imageData = ctx.createImageData(renderTargetTmp.width, renderTargetTmp.height); + // for (var k = 0; k < pixels.length; k++) { + // imageData.data[k] = pixels[k]; + // } + // ctx.putImageData(imageData, 0, 0); + // document.body.appendChild(canvas); -/** - * @param {string} key - * @return {} - */ -LRU.prototype.get = function(key) { - var entry = this._map[key]; - if (typeof(entry) != 'undefined') { - // Put the latest used entry in the tail - if (entry !== this._list.tail) { - this._list.remove(entry); - this._list.insertEntry(entry); + frameBuffer.unbind(renderer); + prefilteredCubeMap.mipmaps[i].pixels[targets[j]] = pixels; } - return entry.value; + renderTargetTmp.width /= 2; + renderTargetTmp.height /= 2; + renderTargetTmp.dirty(); + // console.timeEnd('prefilter'); } -}; -/** - * @param {string} key - */ -LRU.prototype.remove = function(key) { - var entry = this._map[key]; - if (typeof(entry) != 'undefined') { - delete this._map[key]; - this._list.remove(entry); - } -}; + frameBuffer.dispose(renderer); + renderTargetTmp.dispose(renderer); + skyEnv.dispose(renderer); + // Remove gpu resource allucated in renderer + normalDistribution.dispose(renderer); -/** - * Clear the cache - */ -LRU.prototype.clear = function() { - this._list.clear(); - this._map = {}; + // renderer.dispose(); + + return { + environmentMap: prefilteredCubeMap, + brdfLookup: brdfLookup, + normalDistribution: normalDistribution, + maxMipmapLevel: mipmapNum + }; }; -/* harmony default export */ __webpack_exports__["a"] = (LRU); +cubemapUtil.integrateBRDF = function (renderer, normalDistribution) { + normalDistribution = normalDistribution || cubemapUtil.generateNormalDistribution(); + var framebuffer = new __WEBPACK_IMPORTED_MODULE_3__FrameBuffer__["a" /* default */]({ + depthBuffer: false + }); + var pass = new __WEBPACK_IMPORTED_MODULE_4__compositor_Pass__["a" /* default */]({ + fragment: __WEBPACK_IMPORTED_MODULE_12__shader_integrateBRDF_glsl_js__["a" /* default */] + }); + var texture = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]({ + width: 512, + height: 256, + type: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].HALF_FLOAT, + wrapS: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].CLAMP_TO_EDGE, + wrapT: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].CLAMP_TO_EDGE, + minFilter: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].NEAREST, + magFilter: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].NEAREST, + useMipmap: false + }); + pass.setUniform('normalDistribution', normalDistribution); + pass.setUniform('viewportSize', [512, 256]); + pass.attachOutput(texture); + pass.render(renderer, framebuffer); -/***/ }), -/* 65 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + // FIXME Only chrome and firefox can readPixels with float type. + // framebuffer.bind(renderer); + // var pixels = new Float32Array(512 * 256 * 4); + // renderer.gl.readPixels( + // 0, 0, texture.width, texture.height, + // Texture.RGBA, Texture.FLOAT, pixels + // ); + // texture.pixels = pixels; + // texture.flipY = false; + // texture.dirty(); + // framebuffer.unbind(renderer); -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("@export clay.prez.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\n@import clay.chunk.skinning_header\nvoid main()\n{\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n}\n@end\n@export clay.prez.fragment\nvoid main()\n{\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n@end"); + framebuffer.dispose(renderer); + return texture; +}; -/***/ }), -/* 66 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +cubemapUtil.generateNormalDistribution = function (roughnessLevels, sampleSize) { -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(30); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); + // http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html + // GLSL not support bit operation, use lookup instead + // V -> i / N, U -> roughness + var roughnessLevels = roughnessLevels || 256; + var sampleSize = sampleSize || 1024; + var normalDistribution = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]({ + width: roughnessLevels, + height: sampleSize, + type: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].FLOAT, + minFilter: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].NEAREST, + magFilter: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].NEAREST, + wrapS: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].CLAMP_TO_EDGE, + wrapT: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].CLAMP_TO_EDGE, + useMipmap: false + }); + var pixels = new Float32Array(sampleSize * roughnessLevels * 4); + var tmp = []; + // function sortFunc(a, b) { + // return Math.abs(b) - Math.abs(a); + // } + for (var j = 0; j < roughnessLevels; j++) { + var roughness = j / roughnessLevels; + var a = roughness * roughness; -/** - * @constructor - * @alias clay.Renderable - * @extends clay.Node - */ -var Renderable = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(/** @lends clay.Renderable# */ { - /** - * @type {clay.Material} - */ - material: null, + for (var i = 0; i < sampleSize; i++) { + // http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators + // http://stackoverflow.com/questions/1908492/unsigned-integer-in-javascript + // http://stackoverflow.com/questions/1822350/what-is-the-javascript-operator-and-how-do-you-use-it + var y = (i << 16 | i >>> 16) >>> 0; + y = ((y & 1431655765) << 1 | (y & 2863311530) >>> 1) >>> 0; + y = ((y & 858993459) << 2 | (y & 3435973836) >>> 2) >>> 0; + y = ((y & 252645135) << 4 | (y & 4042322160) >>> 4) >>> 0; + y = (((y & 16711935) << 8 | (y & 4278255360) >>> 8) >>> 0) / 4294967296; - /** - * @type {clay.Geometry} - */ - geometry: null, + // CDF + var cosTheta = Math.sqrt((1 - y) / (1 + (a * a - 1.0) * y)); + tmp[i] = cosTheta; + } - /** - * @type {number} - */ - mode: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLES, + for (var i = 0; i < sampleSize; i++) { + var offset = (i * roughnessLevels + j) * 4; + var cosTheta = tmp[i]; + var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta); + var x = i / sampleSize; + var phi = 2.0 * Math.PI * x; + pixels[offset] = sinTheta * Math.cos(phi); + pixels[offset + 1] = cosTheta; + pixels[offset + 2] = sinTheta * Math.sin(phi); + pixels[offset + 3] = 1.0; + } + } + normalDistribution.pixels = pixels; - _renderInfo: null -}, -/** @lends clay.Renderable.prototype */ -{ + return normalDistribution; +}; - __program: null, +/* harmony default export */ __webpack_exports__["a"] = (cubemapUtil); - /** - * Group of received light. - */ - lightGroup: 0, - /** - * Render order, Nodes with smaller value renders before nodes with larger values. - * @type {Number} - */ - renderOrder: 0, - /** - * Used when mode is LINES, LINE_STRIP or LINE_LOOP - * @type {number} - */ - // lineWidth: 1, +/***/ }), +/* 78 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - /** - * If enable culling - * @type {boolean} - */ - culling: true, - /** - * Specify which side of polygon will be culled. - * Possible values: - * + {@link clay.Renderable.BACK} - * + {@link clay.Renderable.FRONT} - * + {@link clay.Renderable.FRONT_AND_BACK} - * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/cullFace - * @type {number} - */ - cullFace: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].BACK, - /** - * Specify which side is front face. - * Possible values: - * + {@link clay.Renderable.CW} - * + {@link clay.Renderable.CCW} - * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/frontFace - * @type {number} - */ - frontFace: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CCW, +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20); - /** - * If enable software frustum culling - * @type {boolean} - */ - frustumCulling: true, - /** - * @type {boolean} - */ - receiveShadow: true, - /** - * @type {boolean} - */ - castShadow: true, - /** - * @type {boolean} - */ - ignorePicking: false, - /** - * @type {boolean} - */ - ignorePreZ: false, - /** - * @type {boolean} - */ - ignoreGBuffer: false, +/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. - /** - * @return {boolean} - */ - isRenderable: function() { - // TODO Shader ? - return this.geometry && this.material && this.material.shader && !this.invisible - && this.geometry.vertexCount > 0; - }, +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: - /** - * Before render hook - * @type {Function} - */ - beforeRender: function (_gl) {}, + * 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. - /** - * Before render hook - * @type {Function} - */ - afterRender: function (_gl, renderStat) {}, +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 HOLDER 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 USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - getBoundingBox: function (filter, out) { - out = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].prototype.getBoundingBox.call(this, filter, out); - if (this.geometry && this.geometry.boundingBox) { - out.union(this.geometry.boundingBox); - } - return out; - }, - /** - * Clone a new renderable - * @function - * @return {clay.Renderable} - */ - clone: (function() { - var properties = [ - 'castShadow', 'receiveShadow', - 'mode', 'culling', 'cullFace', 'frontFace', - 'frustumCulling', - 'renderOrder', 'lineWidth', - 'ignorePicking', 'ignorePreZ', 'ignoreGBuffer' - ]; - return function() { - var renderable = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].prototype.clone.call(this); +/** + * @class 2x2 Matrix + * @name mat2 + */ - renderable.geometry = this.geometry; - renderable.material = this.material; +var mat2 = {}; - for (var i = 0; i < properties.length; i++) { - var name = properties[i]; - // Try not to overwrite the prototype property - if (renderable[name] !== this[name]) { - renderable[name] = this[name]; - } - } +/** + * Creates a new identity mat2 + * + * @returns {mat2} a new 2x2 matrix + */ +mat2.create = function() { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](4); + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; +}; - return renderable; - }; - })() -}); +/** + * Creates a new mat2 initialized with values from an existing matrix + * + * @param {mat2} a matrix to clone + * @returns {mat2} a new 2x2 matrix + */ +mat2.clone = function(a) { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](4); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +}; /** - * @type {number} + * Copy the values from one mat2 to another + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the source matrix + * @returns {mat2} out */ -Renderable.POINTS = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].POINTS; +mat2.copy = function(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; +}; + /** - * @type {number} + * Set a mat2 to the identity matrix + * + * @param {mat2} out the receiving matrix + * @returns {mat2} out */ -Renderable.LINES = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINES; +mat2.identity = function(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; +}; + /** - * @type {number} + * Transpose the values of a mat2 + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the source matrix + * @returns {mat2} out */ -Renderable.LINE_LOOP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINE_LOOP; +mat2.transpose = function(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; +}; + /** - * @type {number} + * Inverts a mat2 + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the source matrix + * @returns {mat2} out */ -Renderable.LINE_STRIP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINE_STRIP; +mat2.invert = function(out, a) { + var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], + + // Calculate the determinant + 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; +}; + /** - * @type {number} + * Calculates the adjugate of a mat2 + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the source matrix + * @returns {mat2} out */ -Renderable.TRIANGLES = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLES; +mat2.adjoint = function(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; +}; + /** - * @type {number} + * Calculates the determinant of a mat2 + * + * @param {mat2} a the source matrix + * @returns {Number} determinant of a */ -Renderable.TRIANGLE_STRIP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLE_STRIP; +mat2.determinant = function (a) { + return a[0] * a[3] - a[2] * a[1]; +}; + /** - * @type {number} + * 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 */ -Renderable.TRIANGLE_FAN = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLE_FAN; +mat2.multiply = function (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; +}; + /** - * @type {number} + * Alias for {@link mat2.multiply} + * @function */ -Renderable.BACK = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].BACK; +mat2.mul = mat2.multiply; + /** - * @type {number} + * 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 */ -Renderable.FRONT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FRONT; +mat2.rotate = function (out, a, rad) { + var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], + s = Math.sin(rad), + 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; +}; + /** - * @type {number} - */ -Renderable.FRONT_AND_BACK = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FRONT_AND_BACK; + * 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 + **/ +mat2.scale = function(out, a, v) { + var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], + v0 = v[0], v1 = v[1]; + out[0] = a0 * v0; + out[1] = a1 * v0; + out[2] = a2 * v1; + out[3] = a3 * v1; + return out; +}; + /** - * @type {number} + * Returns Frobenius norm of a mat2 + * + * @param {mat2} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm */ -Renderable.CW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CW; +mat2.frob = function (a) { + return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2))) +}; + /** - * @type {number} + * 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 */ -Renderable.CCW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CCW; -/* harmony default export */ __webpack_exports__["a"] = (Renderable); +mat2.LDU = function (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]; +}; +/* harmony default export */ __webpack_exports__["a"] = (mat2); + /***/ }), -/* 67 */ +/* 79 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -var mathUtil = {}; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20); -mathUtil.isPowerOfTwo = function (value) { - return (value & (value - 1)) === 0; -}; +/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. -mathUtil.nextPowerOfTwo = function (value) { - value --; - value |= value >> 1; - value |= value >> 2; - value |= value >> 4; - value |= value >> 8; - value |= value >> 16; - value ++; +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: - return value; -}; + * 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. -mathUtil.nearestPowerOfTwo = function (value) { - return Math.pow( 2, Math.round( Math.log( value ) / Math.LN2 ) ); -}; +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 HOLDER 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 USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* harmony default export */ __webpack_exports__["a"] = (mathUtil); -/***/ }), -/* 68 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +/** + * @class 2x3 Matrix + * @name mat2d + * + * @description + * A mat2d contains six elements defined as: + *
+ * [a, c, tx,
+ *  b, d, ty]
+ * 
+ * This is a short form for the 3x3 matrix: + *
+ * [a, c, tx,
+ *  b, d, ty,
+ *  0, 0, 1]
+ * 
+ * The last row is ignored so the array is shorter and operations are faster. + */ -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__dep_glmatrix__); +var mat2d = {}; + +/** + * Creates a new identity mat2d + * + * @returns {mat2d} a new 2x3 matrix + */ +mat2d.create = function() { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](6); + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = 0; + out[5] = 0; + 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 + */ +mat2d.clone = function(a) { + var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_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; +}; -var vec3 = __WEBPACK_IMPORTED_MODULE_1__dep_glmatrix___default.a.vec3; -var mat4 = __WEBPACK_IMPORTED_MODULE_1__dep_glmatrix___default.a.mat4; -var vec4 = __WEBPACK_IMPORTED_MODULE_1__dep_glmatrix___default.a.vec4; +/** + * Copy the values from one mat2d to another + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the source matrix + * @returns {mat2d} out + */ +mat2d.copy = function(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; +}; /** - * @constructor - * @alias clay.Plane - * @param {clay.Vector3} [normal] - * @param {number} [distance] + * Set a mat2d to the identity matrix + * + * @param {mat2d} out the receiving matrix + * @returns {mat2d} out */ -var Plane = function(normal, distance) { - /** - * Normal of the plane - * @type {clay.Vector3} - */ - this.normal = normal || new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](0, 1, 0); +mat2d.identity = function(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = 0; + out[5] = 0; + return out; +}; - /** - * Constant of the plane equation, used as distance to the origin - * @type {number} - */ - this.distance = distance || 0; +/** + * Inverts a mat2d + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the source matrix + * @returns {mat2d} out + */ +mat2d.invert = function(out, a) { + var aa = a[0], ab = a[1], ac = a[2], ad = a[3], + 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; }; -Plane.prototype = { +/** + * Calculates the determinant of a mat2d + * + * @param {mat2d} a the source matrix + * @returns {Number} determinant of a + */ +mat2d.determinant = function (a) { + return a[0] * a[3] - a[1] * a[2]; +}; - constructor: Plane, +/** + * 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 + */ +mat2d.multiply = function (out, a, b) { + var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], + 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; +}; - /** - * Distance from a given point to the plane - * @param {clay.Vector3} point - * @return {number} - */ - distanceToPoint: function(point) { - return vec3.dot(point.array, this.normal.array) - this.distance; - }, +/** + * Alias for {@link mat2d.multiply} + * @function + */ +mat2d.mul = mat2d.multiply; - /** - * Calculate the projection point on the plane - * @param {clay.Vector3} point - * @param {clay.Vector3} out - * @return {clay.Vector3} - */ - projectPoint: function(point, out) { - if (!out) { - out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](); - } - var d = this.distanceToPoint(point); - vec3.scaleAndAdd(out.array, point.array, this.normal.array, -d); - out._dirty = true; - return out; - }, - /** - * Normalize the plane's normal and calculate the distance - */ - normalize: function() { - var invLen = 1 / vec3.len(this.normal.array); - vec3.scale(this.normal.array, invLen); - this.distance *= invLen; - }, +/** + * 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 + */ +mat2d.rotate = function (out, a, rad) { + var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], + s = Math.sin(rad), + 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; +}; - /** - * If the plane intersect a frustum - * @param {clay.Frustum} Frustum - * @return {boolean} - */ - intersectFrustum: function(frustum) { - // Check if all coords of frustum is on plane all under plane - var coords = frustum.vertices; - var normal = this.normal.array; - var onPlane = vec3.dot(coords[0].array, normal) > this.distance; - for (var i = 1; i < 8; i++) { - if ((vec3.dot(coords[i].array, normal) > this.distance) != onPlane) { - return true; - } - } - }, +/** + * 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 + **/ +mat2d.scale = function(out, a, v) { + var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], + 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; +}; - /** - * Calculate the intersection point between plane and a given line - * @function - * @param {clay.Vector3} start start point of line - * @param {clay.Vector3} end end point of line - * @param {clay.Vector3} [out] - * @return {clay.Vector3} - */ - intersectLine: (function() { - var rd = vec3.create(); - return function(start, end, out) { - var d0 = this.distanceToPoint(start); - var d1 = this.distanceToPoint(end); - if ((d0 > 0 && d1 > 0) || (d0 < 0 && d1 < 0)) { - return null; - } - // Ray intersection - var pn = this.normal.array; - var d = this.distance; - var ro = start.array; - // direction - vec3.sub(rd, end.array, start.array); - vec3.normalize(rd, rd); +/** + * 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 + **/ +mat2d.translate = function(out, a, v) { + var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], + 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; +}; + +/** + * Returns Frobenius norm of a mat2d + * + * @param {mat2d} a the matrix to calculate Frobenius norm of + * @returns {Number} Frobenius norm + */ +mat2d.frob = function (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)) +}; - var divider = vec3.dot(pn, rd); - // ray is parallel to the plane - if (divider === 0) { - return null; - } - if (!out) { - out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](); - } - var t = (vec3.dot(pn, ro) - d) / divider; - vec3.scaleAndAdd(out.array, ro, rd, -t); - out._dirty = true; - return out; - }; - })(), - /** - * Apply an affine transform matrix to plane - * @function - * @return {clay.Matrix4} - */ - applyTransform: (function() { - var inverseTranspose = mat4.create(); - var normalv4 = vec4.create(); - var pointv4 = vec4.create(); - pointv4[3] = 1; - return function(m4) { - m4 = m4.array; - // Transform point on plane - vec3.scale(pointv4, this.normal.array, this.distance); - vec4.transformMat4(pointv4, pointv4, m4); - this.distance = vec3.dot(pointv4, this.normal.array); - // Transform plane normal - mat4.invert(inverseTranspose, m4); - mat4.transpose(inverseTranspose, inverseTranspose); - normalv4[3] = 0; - vec3.copy(normalv4, this.normal.array); - vec4.transformMat4(normalv4, normalv4, inverseTranspose); - vec3.copy(this.normal.array, normalv4); - }; - })(), +/* harmony default export */ __webpack_exports__["a"] = (mat2d); - /** - * Copy from another plane - * @param {clay.Vector3} plane - */ - copy: function(plane) { - vec3.copy(this.normal.array, plane.normal.array); - this.normal._dirty = true; - this.distance = plane.distance; - }, +/***/ }), +/* 80 */ +/***/ (function(module, exports) { - /** - * Clone a new plane - * @return {clay.Plane} - */ - clone: function() { - var plane = new Plane(); - plane.copy(this); - return plane; - } +var _default = typeof window !== 'undefined' && (window.requestAnimationFrame && window.requestAnimationFrame.bind(window) || // https://github.com/ecomfe/zrender/issues/189#issuecomment-224919809 +window.msRequestAnimationFrame && window.msRequestAnimationFrame.bind(window) || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame) || function (func) { + setTimeout(func, 16); }; -/* harmony default export */ __webpack_exports__["a"] = (Plane); - +module.exports = _default; /***/ }), -/* 69 */ +/* 81 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Geometry__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_BoundingBox__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture2D__ = __webpack_require__(5); +/** + * Texture Atlas for the sprites. + * It uses zrender for 2d element management and rendering + * @module echarts-gl/util/ZRTextureAtlasSurface + */ +// TODO Expand. -/** - * @constructor clay.geometry.Sphere - * @extends clay.Geometry - * @param {Object} [opt] - * @param {number} [widthSegments] - * @param {number} [heightSegments] - * @param {number} [phiStart] - * @param {number} [phiLength] - * @param {number} [thetaStart] - * @param {number} [thetaLength] - * @param {number} [radius] - */ -var Sphere = __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].extend(/** @lends clay.geometry.Sphere# */ { - dynamic: false, - /** - * @type {number} - */ - widthSegments: 40, - /** - * @type {number} - */ - heightSegments: 20, + +function ZRTextureAtlasSurfaceNode(zr, offsetX, offsetY, width, height, gap, dpr) { + this._zr = zr; /** + * Current cursor x * @type {number} + * @private */ - phiStart: 0, + this._x = 0; + /** + * Current cursor y * @type {number} */ - phiLength: Math.PI * 2, + this._y = 0; + this._rowHeight = 0; /** + * width without dpr. * @type {number} + * @private */ - thetaStart: 0, + this.width = width; + /** + * height without dpr. * @type {number} + * @private */ - thetaLength: Math.PI, + this.height = height; /** + * offsetX without dpr * @type {number} */ - radius: 1 - -}, function() { - this.build(); -}, -/** @lends clay.geometry.Sphere.prototype */ -{ + this.offsetX = offsetX; /** - * Build sphere geometry + * offsetY without dpr + * @type {number} */ - build: function() { - var heightSegments = this.heightSegments; - var widthSegments = this.widthSegments; + this.offsetY = offsetY; - var positionAttr = this.attributes.position; - var texcoordAttr = this.attributes.texcoord0; - var normalAttr = this.attributes.normal; + this.dpr = dpr; - var vertexCount = (widthSegments + 1) * (heightSegments + 1); - positionAttr.init(vertexCount); - texcoordAttr.init(vertexCount); - normalAttr.init(vertexCount); + this.gap = gap; +} - var IndicesCtor = vertexCount > 0xffff ? Uint32Array : Uint16Array; - var indices = this.indices = new IndicesCtor(widthSegments * heightSegments * 6); +ZRTextureAtlasSurfaceNode.prototype = { - var x, y, z, - u, v, - i, j; + constructor: ZRTextureAtlasSurfaceNode, - var radius = this.radius; - var phiStart = this.phiStart; - var phiLength = this.phiLength; - var thetaStart = this.thetaStart; - var thetaLength = this.thetaLength; - var radius = this.radius; + clear: function () { + this._x = 0; + this._y = 0; + this._rowHeight = 0; + }, - var pos = []; - var uv = []; - var offset = 0; - var divider = 1 / radius; - for (j = 0; j <= heightSegments; j ++) { - for (i = 0; i <= widthSegments; i ++) { - u = i / widthSegments; - v = j / heightSegments; + /** + * Add shape to atlas + * @param {module:zrender/graphic/Displayable} shape + * @param {number} width + * @param {number} height + * @return {Array} + */ + add: function (el, width, height) { + // FIXME Text element not consider textAlign and textVerticalAlign. - // X axis is inverted so texture can be mapped from left to right - x = -radius * Math.cos(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength); - y = radius * Math.cos(thetaStart + v * thetaLength); - z = radius * Math.sin(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength); + // TODO, inner text, shadow + var rect = el.getBoundingRect(); - pos[0] = x; pos[1] = y; pos[2] = z; - uv[0] = u; uv[1] = v; - positionAttr.set(offset, pos); - texcoordAttr.set(offset, uv); - pos[0] *= divider; - pos[1] *= divider; - pos[2] *= divider; - normalAttr.set(offset, pos); - offset++; - } + // FIXME aspect ratio + if (width == null) { + width = rect.width; + } + if (height == null) { + height = rect.height; } + width *= this.dpr; + height *= this.dpr; - var i1, i2, i3, i4; + this._fitElement(el, width, height); - var len = widthSegments + 1; + // var aspect = el.scale[1] / el.scale[0]; + // Adjust aspect ratio to make the text more clearly + // FIXME If height > width, width is useless ? + // width = height * aspect; + // el.position[0] *= aspect; + // el.scale[0] = el.scale[1]; - var n = 0; - for (j = 0; j < heightSegments; j ++) { - for (i = 0; i < widthSegments; i ++) { - i2 = j * len + i; - i1 = (j * len + i + 1); - i4 = (j + 1) * len + i + 1; - i3 = (j + 1) * len + i; + var x = this._x; + var y = this._y; - indices[n++] = i1; - indices[n++] = i2; - indices[n++] = i4; + var canvasWidth = this.width * this.dpr; + var canvasHeight = this.height * this.dpr; + var gap = this.gap; - indices[n++] = i2; - indices[n++] = i3; - indices[n++] = i4; - } + if (x + width + gap > canvasWidth) { + // Change a new row + x = this._x = 0; + y += this._rowHeight + gap; + this._y = y; + // Reset row height + this._rowHeight = 0; } - this.boundingBox = new __WEBPACK_IMPORTED_MODULE_1__math_BoundingBox__["a" /* default */](); - this.boundingBox.max.set(radius, radius, radius); - this.boundingBox.min.set(-radius, -radius, -radius); - } -}); - -/* harmony default export */ __webpack_exports__["a"] = (Sphere); - + this._x += width + gap; -/***/ }), -/* 70 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + this._rowHeight = Math.max(this._rowHeight, height); -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__TextureCube__ = __webpack_require__(24); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Texture__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__FrameBuffer__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__compositor_Pass__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Material__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Shader__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__plugin_Skybox__ = __webpack_require__(57); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Scene__ = __webpack_require__(32); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__prePass_EnvironmentMap__ = __webpack_require__(55); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__core_vendor__ = __webpack_require__(18); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__texture__ = __webpack_require__(54); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__shader_integrateBRDF_glsl_js__ = __webpack_require__(120); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__shader_prefilter_glsl_js__ = __webpack_require__(121); -// Cubemap prefilter utility -// http://www.unrealengine.com/files/downloads/2013SiggraphPresentationsNotes.pdf -// http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html + if (y + height + gap > canvasHeight) { + // There is no space anymore + return null; + } + // Shift the el + el.position[0] += this.offsetX * this.dpr + x; + el.position[1] += this.offsetY * this.dpr + y; + this._zr.add(el); + var coordsOffset = [ + this.offsetX / this.width, + this.offsetY / this.height + ]; + var coords = [ + [x / canvasWidth + coordsOffset[0], y / canvasHeight + coordsOffset[1]], + [(x + width) / canvasWidth + coordsOffset[0], (y + height) / canvasHeight + coordsOffset[1]] + ]; + return coords; + }, + /** + * Fit element size by correct its position and scaling + * @param {module:zrender/graphic/Displayable} el + * @param {number} spriteWidth + * @param {number} spriteHeight + */ + _fitElement: function (el, spriteWidth, spriteHeight) { + // TODO, inner text, shadow + var rect = el.getBoundingRect(); + var scaleX = spriteWidth / rect.width; + var scaleY = spriteHeight / rect.height; + el.position = [-rect.x * scaleX, -rect.y * scaleY]; + el.scale = [scaleX, scaleY]; + el.update(); + } +} +/** + * constructor + * @alias module:echarts-gl/util/ZRTextureAtlasSurface + * @param {number} opt.width + * @param {number} opt.height + * @param {number} opt.devicePixelRatio + * @param {number} opt.gap Gap for safe. + * @param {Function} opt.onupdate + */ +function ZRTextureAtlasSurface (opt) { + opt = opt || {}; + opt.width = opt.width || 512; + opt.height = opt.height || 512; + opt.devicePixelRatio = opt.devicePixelRatio || 1; + opt.gap = opt.gap == null ? 2 : opt.gap; + var canvas = document.createElement('canvas'); + canvas.width = opt.width * opt.devicePixelRatio; + canvas.height = opt.height * opt.devicePixelRatio; + this._canvas = canvas; + this._texture = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture2D__["a" /* default */]({ + image: canvas, + flipY: false + }); + var self = this; + /** + * zrender instance in the Chart + * @type {zrender~ZRender} + */ + this._zr = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.zrender.init(canvas); + var oldRefreshImmediately = this._zr.refreshImmediately; + this._zr.refreshImmediately = function () { + oldRefreshImmediately.call(this); + self._texture.dirty(); + self.onupdate && self.onupdate(); + }; + this._dpr = opt.devicePixelRatio; + /** + * Texture coords map for each sprite image + * @type {Object} + */ + this._coords = {}; + this.onupdate = opt.onupdate; + this._gap = opt.gap; -var cubemapUtil = {}; + // Left sub atlas. + this._textureAtlasNodes = [new ZRTextureAtlasSurfaceNode( + this._zr, 0, 0, opt.width, opt.height, this._gap, this._dpr + )]; -var targets = ['px', 'nx', 'py', 'ny', 'pz', 'nz']; + this._nodeWidth = opt.width; + this._nodeHeight = opt.height; -/** - * @name clay.util.cubemap.prefilterEnvironmentMap - * @param {clay.Renderer} renderer - * @param {clay.Texture} envMap - * @param {Object} [textureOpts] - * @param {number} [textureOpts.width=64] - * @param {number} [textureOpts.height=64] - * @param {number} [textureOpts.type] - * @param {boolean} [textureOpts.encodeRGBM=false] - * @param {boolean} [textureOpts.decodeRGBM=false] - * @param {clay.Texture2D} [normalDistribution] - * @param {clay.Texture2D} [brdfLookup] - */ -cubemapUtil.prefilterEnvironmentMap = function ( - renderer, envMap, textureOpts, normalDistribution, brdfLookup -) { - // Not create other renderer, it is easy having issue of cross reference of resources like framebuffer - // PENDING preserveDrawingBuffer? - if (!brdfLookup || !normalDistribution) { - normalDistribution = cubemapUtil.generateNormalDistribution(); - brdfLookup = cubemapUtil.integrateBRDF(renderer, normalDistribution); - } - textureOpts = textureOpts || {}; + this._currentNodeIdx = 0; +} - var width = textureOpts.width || 64; - var height = textureOpts.height || 64; +ZRTextureAtlasSurface.prototype = { - var textureType = textureOpts.type || envMap.type; + /** + * Clear the texture atlas + */ + clear: function () { - // Use same type with given envMap - var prefilteredCubeMap = new __WEBPACK_IMPORTED_MODULE_1__TextureCube__["a" /* default */]({ - width: width, - height: height, - type: textureType, - flipY: false, - mipmaps: [] - }); + for (var i = 0; i < this._textureAtlasNodes.length; i++) { + this._textureAtlasNodes[i].clear(); + } - if (!prefilteredCubeMap.isPowerOfTwo()) { - console.warn('Width and height must be power of two to enable mipmap.'); - } + this._currentNodeIdx = 0; - var size = Math.min(width, height); - var mipmapNum = Math.log(size) / Math.log(2) + 1; + this._zr.clear(); + this._coords = {}; + }, - var prefilterMaterial = new __WEBPACK_IMPORTED_MODULE_5__Material__["a" /* default */]({ - shader: new __WEBPACK_IMPORTED_MODULE_6__Shader__["a" /* default */]({ - vertex: __WEBPACK_IMPORTED_MODULE_6__Shader__["a" /* default */].source('clay.skybox.vertex'), - fragment: __WEBPACK_IMPORTED_MODULE_13__shader_prefilter_glsl_js__["a" /* default */] - }) - }); - prefilterMaterial.set('normalDistribution', normalDistribution); + /** + * @return {number} + */ + getWidth: function () { + return this._width; + }, - textureOpts.encodeRGBM && prefilterMaterial.define('fragment', 'RGBM_ENCODE'); - textureOpts.decodeRGBM && prefilterMaterial.define('fragment', 'RGBM_DECODE'); + /** + * @return {number} + */ + getHeight: function () { + return this._height; + }, - var dummyScene = new __WEBPACK_IMPORTED_MODULE_8__Scene__["a" /* default */](); - var skyEnv; + /** + * @return {number} + */ + getTexture: function () { + return this._texture; + }, - if (envMap.textureType === 'texture2D') { - // Convert panorama to cubemap - var envCubemap = new __WEBPACK_IMPORTED_MODULE_1__TextureCube__["a" /* default */]({ - width: width, - height: height, - // FIXME FLOAT type will cause GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT error on iOS - type: textureType === __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].FLOAT ? - __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].HALF_FLOAT : textureType - }); - __WEBPACK_IMPORTED_MODULE_11__texture__["a" /* default */].panoramaToCubeMap(renderer, envMap, envCubemap, { - // PENDING encodeRGBM so it can be decoded as RGBM - encodeRGBM: textureOpts.decodeRGBM - }); - envMap = envCubemap; - } - skyEnv = new __WEBPACK_IMPORTED_MODULE_7__plugin_Skybox__["a" /* default */]({ - scene: dummyScene, - material: prefilterMaterial - }); - skyEnv.material.set('environmentMap', envMap); + /** + * @return {number} + */ + getDevicePixelRatio: function () { + return this._dpr; + }, - var envMapPass = new __WEBPACK_IMPORTED_MODULE_9__prePass_EnvironmentMap__["a" /* default */]({ - texture: prefilteredCubeMap - }); + getZr: function () { + return this._zr; + }, - // Force to be UNSIGNED_BYTE - if (textureOpts.encodeRGBM) { - textureType = prefilteredCubeMap.type = __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].UNSIGNED_BYTE; - } + _getCurrentNode: function () { + return this._textureAtlasNodes[this._currentNodeIdx]; + }, - var renderTargetTmp = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]({ - width: width, - height: height, - type: textureType - }); - var frameBuffer = new __WEBPACK_IMPORTED_MODULE_3__FrameBuffer__["a" /* default */]({ - depthBuffer: false - }); - var ArrayCtor = __WEBPACK_IMPORTED_MODULE_10__core_vendor__["a" /* default */][textureType === __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].UNSIGNED_BYTE ? 'Uint8Array' : 'Float32Array']; - for (var i = 0; i < mipmapNum; i++) { - // console.time('prefilter'); - prefilteredCubeMap.mipmaps[i] = { - pixels: {} - }; - skyEnv.material.set('roughness', i / (targets.length - 1)); - var maxSampleNumber = renderTargetTmp.width * renderTargetTmp.height; - if (renderTargetTmp.width >= 32) { - maxSampleNumber /= 4; + _expand: function () { + this._currentNodeIdx++; + if (this._textureAtlasNodes[this._currentNodeIdx]) { + // Use the node created previously. + return this._textureAtlasNodes[this._currentNodeIdx]; } - skyEnv.material.set('maxSampleNumber', Math.min(maxSampleNumber, 1024)); - // Tweak fov - // http://the-witness.net/news/2012/02/seamless-cube-map-filtering/ - var n = renderTargetTmp.width; - var fov = 2 * Math.atan(n / (n - 0.5)) / Math.PI * 180; + var maxSize = 4096 / this._dpr; + var textureAtlasNodes = this._textureAtlasNodes; + var nodeLen = textureAtlasNodes.length; + var offsetX = (nodeLen * this._nodeWidth) % maxSize; + var offsetY = Math.floor(nodeLen * this._nodeWidth / maxSize) * this._nodeHeight; + if (offsetY >= maxSize) { + // Failed if image is too large. + if (true) { + console.error('Too much labels. Some will be ignored.'); + } + return; + } - for (var j = 0; j < targets.length; j++) { - var pixels = new ArrayCtor(renderTargetTmp.width * renderTargetTmp.height * 4); - frameBuffer.attach(renderTargetTmp); - frameBuffer.bind(renderer); + var width = (offsetX + this._nodeWidth) * this._dpr; + var height = (offsetY + this._nodeHeight) * this._dpr; + try { + // Resize will error in node. + this._zr.resize({ + width: width, + height: height + }); + } + catch (e) { + this._canvas.width = width; + this._canvas.height = height; + } - var camera = envMapPass.getCamera(targets[j]); - camera.fov = fov; - renderer.render(dummyScene, camera); - renderer.gl.readPixels( - 0, 0, renderTargetTmp.width, renderTargetTmp.height, - __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].RGBA, textureType, pixels - ); + var newNode = new ZRTextureAtlasSurfaceNode( + this._zr, offsetX, offsetY, this._nodeWidth, this._nodeHeight, this._gap, this._dpr + ); + this._textureAtlasNodes.push(newNode); - // var canvas = document.createElement('canvas'); - // var ctx = canvas.getContext('2d'); - // canvas.width = renderTargetTmp.width; - // canvas.height = renderTargetTmp.height; - // var imageData = ctx.createImageData(renderTargetTmp.width, renderTargetTmp.height); - // for (var k = 0; k < pixels.length; k++) { - // imageData.data[k] = pixels[k]; - // } - // ctx.putImageData(imageData, 0, 0); - // document.body.appendChild(canvas); + return newNode; + }, - frameBuffer.unbind(renderer); - prefilteredCubeMap.mipmaps[i].pixels[targets[j]] = pixels; + add: function (el, width, height) { + if (this._coords[el.id]) { + if (true) { + console.warn('Element already been add'); + } + return this._coords[el.id]; + } + var coords = this._getCurrentNode().add(el, width, height); + if (!coords) { + var newNode = this._expand(); + if (!newNode) { + // To maximum + return; + } + coords = newNode.add(el, width, height); } - renderTargetTmp.width /= 2; - renderTargetTmp.height /= 2; - renderTargetTmp.dirty(); - // console.timeEnd('prefilter'); - } + this._coords[el.id] = coords; - frameBuffer.dispose(renderer); - renderTargetTmp.dispose(renderer); - skyEnv.dispose(renderer); - // Remove gpu resource allucated in renderer - normalDistribution.dispose(renderer); + return coords; + }, - // renderer.dispose(); + /** + * Get coord scale after texture atlas is expanded. + * @return {Array.} + */ + getCoordsScale: function () { + var dpr = this._dpr; + return [this._nodeWidth / this._canvas.width * dpr, this._nodeHeight / this._canvas.height * dpr]; + }, - return { - environmentMap: prefilteredCubeMap, - brdfLookup: brdfLookup, - normalDistribution: normalDistribution, - maxMipmapLevel: mipmapNum - }; + /** + * Get texture coords of sprite image + * @param {string} id Image id + * @return {Array} + */ + getCoords: function (id) { + return this._coords[id]; + } }; -cubemapUtil.integrateBRDF = function (renderer, normalDistribution) { - normalDistribution = normalDistribution || cubemapUtil.generateNormalDistribution(); - var framebuffer = new __WEBPACK_IMPORTED_MODULE_3__FrameBuffer__["a" /* default */]({ - depthBuffer: false - }); - var pass = new __WEBPACK_IMPORTED_MODULE_4__compositor_Pass__["a" /* default */]({ - fragment: __WEBPACK_IMPORTED_MODULE_12__shader_integrateBRDF_glsl_js__["a" /* default */] - }); +/* harmony default export */ __webpack_exports__["a"] = (ZRTextureAtlasSurface); - var texture = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]({ - width: 512, - height: 256, - type: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].HALF_FLOAT, - minFilter: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].NEAREST, - magFilter: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].NEAREST, - useMipmap: false - }); - pass.setUniform('normalDistribution', normalDistribution); - pass.setUniform('viewportSize', [512, 256]); - pass.attachOutput(texture); - pass.render(renderer, framebuffer); +/***/ }), +/* 82 */ +/***/ (function(module, exports, __webpack_require__) { - // FIXME Only chrome and firefox can readPixels with float type. - // framebuffer.bind(renderer); - // var pixels = new Float32Array(512 * 256 * 4); - // renderer.gl.readPixels( - // 0, 0, texture.width, texture.height, - // Texture.RGBA, Texture.FLOAT, pixels - // ); - // texture.pixels = pixels; - // texture.flipY = false; - // texture.dirty(); - // framebuffer.unbind(renderer); +var vec2 = __webpack_require__(83); - framebuffer.dispose(renderer); +var matrix = __webpack_require__(84); - return texture; -}; +/** + * @module echarts/core/BoundingRect + */ +var v2ApplyTransform = vec2.applyTransform; +var mathMin = Math.min; +var mathMax = Math.max; +/** + * @alias module:echarts/core/BoundingRect + */ -cubemapUtil.generateNormalDistribution = function (roughnessLevels, sampleSize) { +function BoundingRect(x, y, width, height) { + if (width < 0) { + x = x + width; + width = -width; + } - // http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html - // GLSL not support bit operation, use lookup instead - // V -> i / N, U -> roughness - var roughnessLevels = roughnessLevels || 256; - var sampleSize = sampleSize || 1024; + if (height < 0) { + y = y + height; + height = -height; + } + /** + * @type {number} + */ - var normalDistribution = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]({ - width: roughnessLevels, - height: sampleSize, - type: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].FLOAT, - minFilter: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].NEAREST, - magFilter: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].NEAREST, - wrapS: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].CLAMP_TO_EDGE, - wrapT: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].CLAMP_TO_EDGE, - useMipmap: false - }); - var pixels = new Float32Array(sampleSize * roughnessLevels * 4); - var tmp = []; - // function sortFunc(a, b) { - // return Math.abs(b) - Math.abs(a); - // } - for (var j = 0; j < roughnessLevels; j++) { - var roughness = j / roughnessLevels; - var a = roughness * roughness; + this.x = x; + /** + * @type {number} + */ - for (var i = 0; i < sampleSize; i++) { - // http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators - // http://stackoverflow.com/questions/1908492/unsigned-integer-in-javascript - // http://stackoverflow.com/questions/1822350/what-is-the-javascript-operator-and-how-do-you-use-it - var y = (i << 16 | i >>> 16) >>> 0; - y = ((y & 1431655765) << 1 | (y & 2863311530) >>> 1) >>> 0; - y = ((y & 858993459) << 2 | (y & 3435973836) >>> 2) >>> 0; - y = ((y & 252645135) << 4 | (y & 4042322160) >>> 4) >>> 0; - y = (((y & 16711935) << 8 | (y & 4278255360) >>> 8) >>> 0) / 4294967296; + this.y = y; + /** + * @type {number} + */ - // CDF - var cosTheta = Math.sqrt((1 - y) / (1 + (a * a - 1.0) * y)); - tmp[i] = cosTheta; - } + this.width = width; + /** + * @type {number} + */ - for (var i = 0; i < sampleSize; i++) { - var offset = (i * roughnessLevels + j) * 4; - var cosTheta = tmp[i]; - var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta); - var x = i / sampleSize; - var phi = 2.0 * Math.PI * x; - pixels[offset] = sinTheta * Math.cos(phi); - pixels[offset + 1] = cosTheta; - pixels[offset + 2] = sinTheta * Math.sin(phi); - pixels[offset + 3] = 1.0; - } - } - normalDistribution.pixels = pixels; + this.height = height; +} - return normalDistribution; -}; +BoundingRect.prototype = { + constructor: BoundingRect, -/* harmony default export */ __webpack_exports__["a"] = (cubemapUtil); + /** + * @param {module:echarts/core/BoundingRect} other + */ + union: function (other) { + var x = mathMin(other.x, this.x); + var y = mathMin(other.y, this.y); + this.width = mathMax(other.x + other.width, this.x + this.width) - x; + this.height = mathMax(other.y + other.height, this.y + this.height) - y; + this.x = x; + this.y = y; + }, + /** + * @param {Array.} m + * @methods + */ + applyTransform: function () { + var lt = []; + var rb = []; + var lb = []; + var rt = []; + return function (m) { + // In case usage like this + // el.getBoundingRect().applyTransform(el.transform) + // And element has no transform + if (!m) { + return; + } -/***/ }), -/* 71 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + lt[0] = lb[0] = this.x; + lt[1] = rt[1] = this.y; + rb[0] = rt[0] = this.x + this.width; + rb[1] = lb[1] = this.y + this.height; + v2ApplyTransform(lt, lt, m); + v2ApplyTransform(rb, rb, m); + v2ApplyTransform(lb, lb, m); + v2ApplyTransform(rt, rt, m); + this.x = mathMin(lt[0], rb[0], lb[0], rt[0]); + this.y = mathMin(lt[1], rb[1], lb[1], rt[1]); + var maxX = mathMax(lt[0], rb[0], lb[0], rt[0]); + var maxY = mathMax(lt[1], rb[1], lb[1], rt[1]); + this.width = maxX - this.x; + this.height = maxY - this.y; + }; + }(), -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Geometry__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Plane__ = __webpack_require__(37); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__math_BoundingBox__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__core_vendor__ = __webpack_require__(18); + /** + * Calculate matrix of transforming from self to target rect + * @param {module:zrender/core/BoundingRect} b + * @return {Array.} + */ + calculateTransform: function (b) { + var a = this; + var sx = b.width / a.width; + var sy = b.height / a.height; + var m = matrix.create(); // 矩阵右乘 + + matrix.translate(m, m, [-a.x, -a.y]); + matrix.scale(m, m, [sx, sy]); + matrix.translate(m, m, [b.x, b.y]); + return m; + }, + + /** + * @param {(module:echarts/core/BoundingRect|Object)} b + * @return {boolean} + */ + intersect: function (b) { + if (!b) { + return false; + } + if (!(b instanceof BoundingRect)) { + // Normalize negative width/height. + b = BoundingRect.create(b); + } + var a = this; + var ax0 = a.x; + var ax1 = a.x + a.width; + var ay0 = a.y; + var ay1 = a.y + a.height; + var bx0 = b.x; + var bx1 = b.x + b.width; + var by0 = b.y; + var by1 = b.y + b.height; + return !(ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0); + }, + contain: function (x, y) { + var rect = this; + return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height; + }, + /** + * @return {module:echarts/core/BoundingRect} + */ + clone: function () { + return new BoundingRect(this.x, this.y, this.width, this.height); + }, + /** + * Copy from another rect + */ + copy: function (other) { + this.x = other.x; + this.y = other.y; + this.width = other.width; + this.height = other.height; + }, + plain: function () { + return { + x: this.x, + y: this.y, + width: this.width, + height: this.height + }; + } +}; +/** + * @param {Object|module:zrender/core/BoundingRect} rect + * @param {number} rect.x + * @param {number} rect.y + * @param {number} rect.width + * @param {number} rect.height + * @return {module:zrender/core/BoundingRect} + */ +BoundingRect.create = function (rect) { + return new BoundingRect(rect.x, rect.y, rect.width, rect.height); +}; +var _default = BoundingRect; +module.exports = _default; -var planeMatrix = new __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */](); +/***/ }), +/* 83 */ +/***/ (function(module, exports) { +var ArrayCtor = typeof Float32Array === 'undefined' ? Array : Float32Array; /** - * @constructor clay.geometry.Cube - * @extends clay.Geometry - * @param {Object} [opt] - * @param {number} [opt.widthSegments] - * @param {number} [opt.heightSegments] - * @param {number} [opt.depthSegments] - * @param {boolean} [opt.inside] + * 创建一个向量 + * @param {number} [x=0] + * @param {number} [y=0] + * @return {Vector2} */ -var Cube = __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].extend( -/**@lends clay.geometry.Cube# */ -{ - dynamic: false, - /** - * @type {number} - */ - widthSegments: 1, - /** - * @type {number} - */ - heightSegments: 1, - /** - * @type {number} - */ - depthSegments: 1, - /** - * @type {boolean} - */ - inside: false -}, function() { - this.build(); -}, -/** @lends clay.geometry.Cube.prototype */ -{ - /** - * Build cube geometry - */ - build: function() { - - var planes = { - 'px': createPlane('px', this.depthSegments, this.heightSegments), - 'nx': createPlane('nx', this.depthSegments, this.heightSegments), - 'py': createPlane('py', this.widthSegments, this.depthSegments), - 'ny': createPlane('ny', this.widthSegments, this.depthSegments), - 'pz': createPlane('pz', this.widthSegments, this.heightSegments), - 'nz': createPlane('nz', this.widthSegments, this.heightSegments), - }; - var attrList = ['position', 'texcoord0', 'normal']; - var vertexNumber = 0; - var faceNumber = 0; - for (var pos in planes) { - vertexNumber += planes[pos].vertexCount; - faceNumber += planes[pos].indices.length; - } - for (var k = 0; k < attrList.length; k++) { - this.attributes[attrList[k]].init(vertexNumber); - } - this.indices = new __WEBPACK_IMPORTED_MODULE_5__core_vendor__["a" /* default */].Uint16Array(faceNumber); - var faceOffset = 0; - var vertexOffset = 0; - for (var pos in planes) { - var plane = planes[pos]; - for (var k = 0; k < attrList.length; k++) { - var attrName = attrList[k]; - var attrArray = plane.attributes[attrName].value; - var attrSize = plane.attributes[attrName].size; - var isNormal = attrName === 'normal'; - for (var i = 0; i < attrArray.length; i++) { - var value = attrArray[i]; - if (this.inside && isNormal) { - value = -value; - } - this.attributes[attrName].value[i + attrSize * vertexOffset] = value; - } - } - var len = plane.indices.length; - for (var i = 0; i < plane.indices.length; i++) { - this.indices[i + faceOffset] = vertexOffset + plane.indices[this.inside ? (len - i - 1) : i]; - } - faceOffset += plane.indices.length; - vertexOffset += plane.vertexCount; - } +function create(x, y) { + var out = new ArrayCtor(2); - this.boundingBox = new __WEBPACK_IMPORTED_MODULE_4__math_BoundingBox__["a" /* default */](); - this.boundingBox.max.set(1, 1, 1); - this.boundingBox.min.set(-1, -1, -1); - } -}); + if (x == null) { + x = 0; + } -function createPlane(pos, widthSegments, heightSegments) { + if (y == null) { + y = 0; + } - planeMatrix.identity(); + out[0] = x; + out[1] = y; + return out; +} +/** + * 复制向量数据 + * @param {Vector2} out + * @param {Vector2} v + * @return {Vector2} + */ - var plane = new __WEBPACK_IMPORTED_MODULE_1__Plane__["a" /* default */]({ - widthSegments: widthSegments, - heightSegments: heightSegments - }); - switch(pos) { - case 'px': - __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].POSITIVE_X); - __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateY(planeMatrix, planeMatrix, Math.PI / 2); - break; - case 'nx': - __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].NEGATIVE_X); - __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateY(planeMatrix, planeMatrix, -Math.PI / 2); - break; - case 'py': - __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].POSITIVE_Y); - __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateX(planeMatrix, planeMatrix, -Math.PI / 2); - break; - case 'ny': - __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].NEGATIVE_Y); - __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateX(planeMatrix, planeMatrix, Math.PI / 2); - break; - case 'pz': - __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].POSITIVE_Z); - break; - case 'nz': - __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].NEGATIVE_Z); - __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateY(planeMatrix, planeMatrix, Math.PI); - break; - } - plane.applyTransform(planeMatrix); - return plane; +function copy(out, v) { + out[0] = v[0]; + out[1] = v[1]; + return out; } +/** + * 克隆一个向量 + * @param {Vector2} v + * @return {Vector2} + */ -/* harmony default export */ __webpack_exports__["a"] = (Cube); + +function clone(v) { + var out = new ArrayCtor(2); + out[0] = v[0]; + out[1] = v[1]; + return out; +} +/** + * 设置向量的两个项 + * @param {Vector2} out + * @param {number} a + * @param {number} b + * @return {Vector2} 结果 + */ -/***/ }), -/* 72 */ -/***/ (function(module, exports) { +function set(out, a, b) { + out[0] = a; + out[1] = b; + return out; +} +/** + * 向量相加 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ -var _default = typeof window !== 'undefined' && (window.requestAnimationFrame && window.requestAnimationFrame.bind(window) || // https://github.com/ecomfe/zrender/issues/189#issuecomment-224919809 -window.msRequestAnimationFrame && window.msRequestAnimationFrame.bind(window) || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame) || function (func) { - setTimeout(func, 16); -}; -module.exports = _default; +function add(out, v1, v2) { + out[0] = v1[0] + v2[0]; + out[1] = v1[1] + v2[1]; + return out; +} +/** + * 向量缩放后相加 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + * @param {number} a + */ -/***/ }), -/* 73 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture2D__ = __webpack_require__(5); +function scaleAndAdd(out, v1, v2, a) { + out[0] = v1[0] + v2[0] * a; + out[1] = v1[1] + v2[1] * a; + return out; +} /** - * Texture Atlas for the sprites. - * It uses zrender for 2d element management and rendering - * @module echarts-gl/util/ZRTextureAtlasSurface + * 向量相减 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 */ -// TODO Expand. +function sub(out, v1, v2) { + out[0] = v1[0] - v2[0]; + out[1] = v1[1] - v2[1]; + return out; +} +/** + * 向量长度 + * @param {Vector2} v + * @return {number} + */ -function ZRTextureAtlasSurfaceNode(zr, offsetX, offsetY, width, height, gap, dpr) { - this._zr = zr; +function len(v) { + return Math.sqrt(lenSquare(v)); +} - /** - * Current cursor x - * @type {number} - * @private - */ - this._x = 0; +var length = len; // jshint ignore:line - /** - * Current cursor y - * @type {number} - */ - this._y = 0; +/** + * 向量长度平方 + * @param {Vector2} v + * @return {number} + */ - this._rowHeight = 0; - /** - * width without dpr. - * @type {number} - * @private - */ - this.width = width; +function lenSquare(v) { + return v[0] * v[0] + v[1] * v[1]; +} - /** - * height without dpr. - * @type {number} - * @private - */ - this.height = height; +var lengthSquare = lenSquare; +/** + * 向量乘法 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ - /** - * offsetX without dpr - * @type {number} - */ - this.offsetX = offsetX; - /** - * offsetY without dpr - * @type {number} - */ - this.offsetY = offsetY; +function mul(out, v1, v2) { + out[0] = v1[0] * v2[0]; + out[1] = v1[1] * v2[1]; + return out; +} +/** + * 向量除法 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ - this.dpr = dpr; - this.gap = gap; +function div(out, v1, v2) { + out[0] = v1[0] / v2[0]; + out[1] = v1[1] / v2[1]; + return out; } +/** + * 向量点乘 + * @param {Vector2} v1 + * @param {Vector2} v2 + * @return {number} + */ -ZRTextureAtlasSurfaceNode.prototype = { - constructor: ZRTextureAtlasSurfaceNode, +function dot(v1, v2) { + return v1[0] * v2[0] + v1[1] * v2[1]; +} +/** + * 向量缩放 + * @param {Vector2} out + * @param {Vector2} v + * @param {number} s + */ - clear: function () { - this._x = 0; - this._y = 0; - this._rowHeight = 0; - }, - /** - * Add shape to atlas - * @param {module:zrender/graphic/Displayable} shape - * @param {number} width - * @param {number} height - * @return {Array} - */ - add: function (el, width, height) { - // FIXME Text element not consider textAlign and textVerticalAlign. +function scale(out, v, s) { + out[0] = v[0] * s; + out[1] = v[1] * s; + return out; +} +/** + * 向量归一化 + * @param {Vector2} out + * @param {Vector2} v + */ - // TODO, inner text, shadow - var rect = el.getBoundingRect(); - // FIXME aspect ratio - if (width == null) { - width = rect.width; - } - if (height == null) { - height = rect.height; - } - width *= this.dpr; - height *= this.dpr; +function normalize(out, v) { + var d = len(v); - this._fitElement(el, width, height); + if (d === 0) { + out[0] = 0; + out[1] = 0; + } else { + out[0] = v[0] / d; + out[1] = v[1] / d; + } - // var aspect = el.scale[1] / el.scale[0]; - // Adjust aspect ratio to make the text more clearly - // FIXME If height > width, width is useless ? - // width = height * aspect; - // el.position[0] *= aspect; - // el.scale[0] = el.scale[1]; + return out; +} +/** + * 计算向量间距离 + * @param {Vector2} v1 + * @param {Vector2} v2 + * @return {number} + */ - var x = this._x; - var y = this._y; - var canvasWidth = this.width * this.dpr; - var canvasHeight = this.height * this.dpr; - var gap = this.gap; +function distance(v1, v2) { + return Math.sqrt((v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1])); +} - if (x + width + gap > canvasWidth) { - // Change a new row - x = this._x = 0; - y += this._rowHeight + gap; - this._y = y; - // Reset row height - this._rowHeight = 0; - } +var dist = distance; +/** + * 向量距离平方 + * @param {Vector2} v1 + * @param {Vector2} v2 + * @return {number} + */ - this._x += width + gap; +function distanceSquare(v1, v2) { + return (v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1]); +} - this._rowHeight = Math.max(this._rowHeight, height); +var distSquare = distanceSquare; +/** + * 求负向量 + * @param {Vector2} out + * @param {Vector2} v + */ - if (y + height + gap > canvasHeight) { - // There is no space anymore - return null; - } +function negate(out, v) { + out[0] = -v[0]; + out[1] = -v[1]; + return out; +} +/** + * 插值两个点 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + * @param {number} t + */ - // Shift the el - el.position[0] += this.offsetX * this.dpr + x; - el.position[1] += this.offsetY * this.dpr + y; - this._zr.add(el); +function lerp(out, v1, v2, t) { + out[0] = v1[0] + t * (v2[0] - v1[0]); + out[1] = v1[1] + t * (v2[1] - v1[1]); + return out; +} +/** + * 矩阵左乘向量 + * @param {Vector2} out + * @param {Vector2} v + * @param {Vector2} m + */ - var coordsOffset = [ - this.offsetX / this.width, - this.offsetY / this.height - ]; - var coords = [ - [x / canvasWidth + coordsOffset[0], y / canvasHeight + coordsOffset[1]], - [(x + width) / canvasWidth + coordsOffset[0], (y + height) / canvasHeight + coordsOffset[1]] - ]; - return coords; - }, +function applyTransform(out, v, m) { + var x = v[0]; + var y = v[1]; + out[0] = m[0] * x + m[2] * y + m[4]; + out[1] = m[1] * x + m[3] * y + m[5]; + return out; +} +/** + * 求两个向量最小值 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 + */ - /** - * Fit element size by correct its position and scaling - * @param {module:zrender/graphic/Displayable} el - * @param {number} spriteWidth - * @param {number} spriteHeight - */ - _fitElement: function (el, spriteWidth, spriteHeight) { - // TODO, inner text, shadow - var rect = el.getBoundingRect(); - var scaleX = spriteWidth / rect.width; - var scaleY = spriteHeight / rect.height; - el.position = [-rect.x * scaleX, -rect.y * scaleY]; - el.scale = [scaleX, scaleY]; - el.update(); - } +function min(out, v1, v2) { + out[0] = Math.min(v1[0], v2[0]); + out[1] = Math.min(v1[1], v2[1]); + return out; } /** - * constructor - * @alias module:echarts-gl/util/ZRTextureAtlasSurface - * @param {number} opt.width - * @param {number} opt.height - * @param {number} opt.devicePixelRatio - * @param {number} opt.gap Gap for safe. - * @param {Function} opt.onupdate + * 求两个向量最大值 + * @param {Vector2} out + * @param {Vector2} v1 + * @param {Vector2} v2 */ -function ZRTextureAtlasSurface (opt) { - opt = opt || {}; - opt.width = opt.width || 512; - opt.height = opt.height || 512; - opt.devicePixelRatio = opt.devicePixelRatio || 1; - opt.gap = opt.gap == null ? 2 : opt.gap; - var canvas = document.createElement('canvas'); - canvas.width = opt.width * opt.devicePixelRatio; - canvas.height = opt.height * opt.devicePixelRatio; +function max(out, v1, v2) { + out[0] = Math.max(v1[0], v2[0]); + out[1] = Math.max(v1[1], v2[1]); + return out; +} - this._canvas = canvas; +exports.create = create; +exports.copy = copy; +exports.clone = clone; +exports.set = set; +exports.add = add; +exports.scaleAndAdd = scaleAndAdd; +exports.sub = sub; +exports.len = len; +exports.length = length; +exports.lenSquare = lenSquare; +exports.lengthSquare = lengthSquare; +exports.mul = mul; +exports.div = div; +exports.dot = dot; +exports.scale = scale; +exports.normalize = normalize; +exports.distance = distance; +exports.dist = dist; +exports.distanceSquare = distanceSquare; +exports.distSquare = distSquare; +exports.negate = negate; +exports.lerp = lerp; +exports.applyTransform = applyTransform; +exports.min = min; +exports.max = max; - this._texture = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture2D__["a" /* default */]({ - image: canvas, - flipY: false - }); +/***/ }), +/* 84 */ +/***/ (function(module, exports) { - var self = this; - /** - * zrender instance in the Chart - * @type {zrender~ZRender} - */ - this._zr = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.zrender.init(canvas); - var oldRefreshImmediately = this._zr.refreshImmediately; - this._zr.refreshImmediately = function () { - oldRefreshImmediately.call(this); - self._texture.dirty(); - self.onupdate && self.onupdate(); - }; +/** + * 3x2矩阵操作类 + * @exports zrender/tool/matrix + */ +var ArrayCtor = typeof Float32Array === 'undefined' ? Array : Float32Array; +/** + * Create a identity matrix. + * @return {Float32Array|Array.} + */ - this._dpr = opt.devicePixelRatio; +function create() { + var out = new ArrayCtor(6); + identity(out); + return out; +} +/** + * 设置矩阵为单位矩阵 + * @param {Float32Array|Array.} out + */ - /** - * Texture coords map for each sprite image - * @type {Object} - */ - this._coords = {}; - this.onupdate = opt.onupdate; +function identity(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 1; + out[4] = 0; + out[5] = 0; + return out; +} +/** + * 复制矩阵 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} m + */ - this._gap = opt.gap; - // Left sub atlas. - this._textureAtlasNodes = [new ZRTextureAtlasSurfaceNode( - this._zr, 0, 0, opt.width, opt.height, this._gap, this._dpr - )]; +function copy(out, m) { + out[0] = m[0]; + out[1] = m[1]; + out[2] = m[2]; + out[3] = m[3]; + out[4] = m[4]; + out[5] = m[5]; + return out; +} +/** + * 矩阵相乘 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} m1 + * @param {Float32Array|Array.} m2 + */ - this._nodeWidth = opt.width; - this._nodeHeight = opt.height; - this._currentNodeIdx = 0; +function mul(out, m1, m2) { + // Consider matrix.mul(m, m2, m); + // where out is the same as m2. + // So use temp variable to escape error. + var out0 = m1[0] * m2[0] + m1[2] * m2[1]; + var out1 = m1[1] * m2[0] + m1[3] * m2[1]; + var out2 = m1[0] * m2[2] + m1[2] * m2[3]; + var out3 = m1[1] * m2[2] + m1[3] * m2[3]; + var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4]; + var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5]; + out[0] = out0; + out[1] = out1; + out[2] = out2; + out[3] = out3; + out[4] = out4; + out[5] = out5; + return out; } +/** + * 平移变换 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + * @param {Float32Array|Array.} v + */ -ZRTextureAtlasSurface.prototype = { - /** - * Clear the texture atlas - */ - clear: function () { +function translate(out, a, v) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4] + v[0]; + out[5] = a[5] + v[1]; + return out; +} +/** + * 旋转变换 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + * @param {number} rad + */ - for (var i = 0; i < this._textureAtlasNodes.length; i++) { - this._textureAtlasNodes[i].clear(); - } - this._currentNodeIdx = 0; +function rotate(out, a, rad) { + var aa = a[0]; + var ac = a[2]; + var atx = a[4]; + var ab = a[1]; + var ad = a[3]; + var aty = a[5]; + var st = Math.sin(rad); + var ct = Math.cos(rad); + out[0] = aa * ct + ab * st; + out[1] = -aa * st + ab * ct; + out[2] = ac * ct + ad * st; + out[3] = -ac * st + ct * ad; + out[4] = ct * atx + st * aty; + out[5] = ct * aty - st * atx; + return out; +} +/** + * 缩放变换 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + * @param {Float32Array|Array.} v + */ - this._zr.clear(); - this._coords = {}; - }, - /** - * @return {number} - */ - getWidth: function () { - return this._width; - }, +function scale(out, a, v) { + var vx = v[0]; + var vy = v[1]; + out[0] = a[0] * vx; + out[1] = a[1] * vy; + out[2] = a[2] * vx; + out[3] = a[3] * vy; + out[4] = a[4] * vx; + out[5] = a[5] * vy; + return out; +} +/** + * 求逆矩阵 + * @param {Float32Array|Array.} out + * @param {Float32Array|Array.} a + */ + - /** - * @return {number} - */ - getHeight: function () { - return this._height; - }, +function invert(out, a) { + var aa = a[0]; + var ac = a[2]; + var atx = a[4]; + var ab = a[1]; + var ad = a[3]; + var aty = a[5]; + var det = aa * ad - ab * ac; - /** - * @return {number} - */ - getTexture: function () { - return this._texture; - }, + if (!det) { + return null; + } - /** - * @return {number} - */ - getDevicePixelRatio: function () { - return this._dpr; - }, + 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; +} +/** + * Clone a new matrix. + * @param {Float32Array|Array.} a + */ - getZr: function () { - return this._zr; - }, - _getCurrentNode: function () { - return this._textureAtlasNodes[this._currentNodeIdx]; - }, +function clone(a) { + var b = create(); + copy(b, a); + return b; +} - _expand: function () { - this._currentNodeIdx++; - if (this._textureAtlasNodes[this._currentNodeIdx]) { - // Use the node created previously. - return this._textureAtlasNodes[this._currentNodeIdx]; - } +exports.create = create; +exports.identity = identity; +exports.copy = copy; +exports.mul = mul; +exports.translate = translate; +exports.rotate = rotate; +exports.scale = scale; +exports.invert = invert; +exports.clone = clone; - var maxSize = 4096 / this._dpr; - var textureAtlasNodes = this._textureAtlasNodes; - var nodeLen = textureAtlasNodes.length; - var offsetX = (nodeLen * this._nodeWidth) % maxSize; - var offsetY = Math.floor(nodeLen * this._nodeWidth / maxSize) * this._nodeHeight; - if (offsetY >= maxSize) { - // Failed if image is too large. - if (true) { - console.error('Too much labels. Some will be ignored.'); - } - return; - } +/***/ }), +/* 85 */ +/***/ (function(module, exports, __webpack_require__) { - var width = (offsetX + this._nodeWidth) * this._dpr; - var height = (offsetY + this._nodeHeight) * this._dpr; - try { - // Resize will error in node. - this._zr.resize({ - width: width, - height: height - }); - } - catch (e) { - this._canvas.width = width; - this._canvas.height = height; - } +var zrUtil = __webpack_require__(13); - var newNode = new ZRTextureAtlasSurfaceNode( - this._zr, offsetX, offsetY, this._nodeWidth, this._nodeHeight, this._gap, this._dpr - ); - this._textureAtlasNodes.push(newNode); +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +var RADIAN_EPSILON = 1e-4; - return newNode; - }, +function _trim(str) { + return str.replace(/^\s+/, '').replace(/\s+$/, ''); +} +/** + * Linear mapping a value from domain to range + * @memberOf module:echarts/util/number + * @param {(number|Array.)} val + * @param {Array.} domain Domain extent domain[0] can be bigger than domain[1] + * @param {Array.} range Range extent range[0] can be bigger than range[1] + * @param {boolean} clamp + * @return {(number|Array.} + */ - add: function (el, width, height) { - if (this._coords[el.id]) { - if (true) { - console.warn('Element already been add'); - } - return this._coords[el.id]; - } - var coords = this._getCurrentNode().add(el, width, height); - if (!coords) { - var newNode = this._expand(); - if (!newNode) { - // To maximum - return; - } - coords = newNode.add(el, width, height); - } - this._coords[el.id] = coords; +function linearMap(val, domain, range, clamp) { + var subDomain = domain[1] - domain[0]; + var subRange = range[1] - range[0]; - return coords; - }, + if (subDomain === 0) { + return subRange === 0 ? range[0] : (range[0] + range[1]) / 2; + } // Avoid accuracy problem in edge, such as + // 146.39 - 62.83 === 83.55999999999999. + // See echarts/test/ut/spec/util/number.js#linearMap#accuracyError + // It is a little verbose for efficiency considering this method + // is a hotspot. - /** - * Get coord scale after texture atlas is expanded. - * @return {Array.} - */ - getCoordsScale: function () { - var dpr = this._dpr; - return [this._nodeWidth / this._canvas.width * dpr, this._nodeHeight / this._canvas.height * dpr]; - }, - /** - * Get texture coords of sprite image - * @param {string} id Image id - * @return {Array} - */ - getCoords: function (id) { - return this._coords[id]; + if (clamp) { + if (subDomain > 0) { + if (val <= domain[0]) { + return range[0]; + } else if (val >= domain[1]) { + return range[1]; + } + } else { + if (val >= domain[0]) { + return range[0]; + } else if (val <= domain[1]) { + return range[1]; + } + } + } else { + if (val === domain[0]) { + return range[0]; } -}; -/* harmony default export */ __webpack_exports__["a"] = (ZRTextureAtlasSurface); + if (val === domain[1]) { + return range[1]; + } + } -/***/ }), -/* 74 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + return (val - domain[0]) / subDomain * subRange + range[0]; +} +/** + * Convert a percent string to absolute number. + * Returns NaN if percent is not a valid string or number + * @memberOf module:echarts/util/number + * @param {string|number} percent + * @param {number} all + * @return {number} + */ -"use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = ifIgnoreOnTick; -function ifIgnoreOnTick(axis, i, interval) { - var rawTick; - var scale = axis.scale; - return scale.type === 'ordinal' - && ( - typeof interval === 'function' - ? ( - rawTick = scale.getTicks()[i], - !interval(rawTick, scale.getLabel(rawTick)) - ) - : i % (interval + 1) - ); -}; -/***/ }), -/* 75 */ -/***/ (function(module, exports, __webpack_require__) { +function parsePercent(percent, all) { + switch (percent) { + case 'center': + case 'middle': + percent = '50%'; + break; -var vec2 = __webpack_require__(76); + case 'left': + case 'top': + percent = '0%'; + break; -var matrix = __webpack_require__(77); + case 'right': + case 'bottom': + percent = '100%'; + break; + } -/** - * @module echarts/core/BoundingRect - */ -var v2ApplyTransform = vec2.applyTransform; -var mathMin = Math.min; -var mathMax = Math.max; -/** - * @alias module:echarts/core/BoundingRect - */ + if (typeof percent === 'string') { + if (_trim(percent).match(/%$/)) { + return parseFloat(percent) / 100 * all; + } -function BoundingRect(x, y, width, height) { - if (width < 0) { - x = x + width; - width = -width; + return parseFloat(percent); } - if (height < 0) { - y = y + height; - height = -height; - } - /** - * @type {number} - */ + return percent == null ? NaN : +percent; +} +/** + * (1) Fix rounding error of float numbers. + * (2) Support return string to avoid scientific notation like '3.5e-7'. + * + * @param {number} x + * @param {number} [precision] + * @param {boolean} [returnStr] + * @return {number|string} + */ - this.x = x; - /** - * @type {number} - */ +function round(x, precision, returnStr) { + if (precision == null) { + precision = 10; + } // Avoid range error - this.y = y; - /** - * @type {number} - */ - this.width = width; - /** - * @type {number} - */ + precision = Math.min(Math.max(0, precision), 20); + x = (+x).toFixed(precision); + return returnStr ? x : +x; +} - this.height = height; +function asc(arr) { + arr.sort(function (a, b) { + return a - b; + }); + return arr; } +/** + * Get precision + * @param {number} val + */ -BoundingRect.prototype = { - constructor: BoundingRect, - /** - * @param {module:echarts/core/BoundingRect} other - */ - union: function (other) { - var x = mathMin(other.x, this.x); - var y = mathMin(other.y, this.y); - this.width = mathMax(other.x + other.width, this.x + this.width) - x; - this.height = mathMax(other.y + other.height, this.y + this.height) - y; - this.x = x; - this.y = y; - }, +function getPrecision(val) { + val = +val; - /** - * @param {Array.} m - * @methods - */ - applyTransform: function () { - var lt = []; - var rb = []; - var lb = []; - var rt = []; - return function (m) { - // In case usage like this - // el.getBoundingRect().applyTransform(el.transform) - // And element has no transform - if (!m) { - return; - } + if (isNaN(val)) { + return 0; + } // It is much faster than methods converting number to string as follows + // var tmp = val.toString(); + // return tmp.length - 1 - tmp.indexOf('.'); + // especially when precision is low - lt[0] = lb[0] = this.x; - lt[1] = rt[1] = this.y; - rb[0] = rt[0] = this.x + this.width; - rb[1] = lb[1] = this.y + this.height; - v2ApplyTransform(lt, lt, m); - v2ApplyTransform(rb, rb, m); - v2ApplyTransform(lb, lb, m); - v2ApplyTransform(rt, rt, m); - this.x = mathMin(lt[0], rb[0], lb[0], rt[0]); - this.y = mathMin(lt[1], rb[1], lb[1], rt[1]); - var maxX = mathMax(lt[0], rb[0], lb[0], rt[0]); - var maxY = mathMax(lt[1], rb[1], lb[1], rt[1]); - this.width = maxX - this.x; - this.height = maxY - this.y; - }; - }(), - /** - * Calculate matrix of transforming from self to target rect - * @param {module:zrender/core/BoundingRect} b - * @return {Array.} - */ - calculateTransform: function (b) { - var a = this; - var sx = b.width / a.width; - var sy = b.height / a.height; - var m = matrix.create(); // 矩阵右乘 + var e = 1; + var count = 0; - matrix.translate(m, m, [-a.x, -a.y]); - matrix.scale(m, m, [sx, sy]); - matrix.translate(m, m, [b.x, b.y]); - return m; - }, + while (Math.round(val * e) / e !== val) { + e *= 10; + count++; + } - /** - * @param {(module:echarts/core/BoundingRect|Object)} b - * @return {boolean} - */ - intersect: function (b) { - if (!b) { - return false; - } + return count; +} +/** + * @param {string|number} val + * @return {number} + */ - if (!(b instanceof BoundingRect)) { - // Normalize negative width/height. - b = BoundingRect.create(b); - } - var a = this; - var ax0 = a.x; - var ax1 = a.x + a.width; - var ay0 = a.y; - var ay1 = a.y + a.height; - var bx0 = b.x; - var bx1 = b.x + b.width; - var by0 = b.y; - var by1 = b.y + b.height; - return !(ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0); - }, - contain: function (x, y) { - var rect = this; - return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height; - }, +function getPrecisionSafe(val) { + var str = val.toString(); // Consider scientific notation: '3.4e-12' '3.4e+12' - /** - * @return {module:echarts/core/BoundingRect} - */ - clone: function () { - return new BoundingRect(this.x, this.y, this.width, this.height); - }, + var eIndex = str.indexOf('e'); - /** - * Copy from another rect - */ - copy: function (other) { - this.x = other.x; - this.y = other.y; - this.width = other.width; - this.height = other.height; - }, - plain: function () { - return { - x: this.x, - y: this.y, - width: this.width, - height: this.height - }; + if (eIndex > 0) { + var precision = +str.slice(eIndex + 1); + return precision < 0 ? -precision : 0; + } else { + var dotIndex = str.indexOf('.'); + return dotIndex < 0 ? 0 : str.length - 1 - dotIndex; } -}; +} /** - * @param {Object|module:zrender/core/BoundingRect} rect - * @param {number} rect.x - * @param {number} rect.y - * @param {number} rect.width - * @param {number} rect.height - * @return {module:zrender/core/BoundingRect} + * Minimal dicernible data precisioin according to a single pixel. + * + * @param {Array.} dataExtent + * @param {Array.} pixelExtent + * @return {number} precision */ -BoundingRect.create = function (rect) { - return new BoundingRect(rect.x, rect.y, rect.width, rect.height); -}; - -var _default = BoundingRect; -module.exports = _default; -/***/ }), -/* 76 */ -/***/ (function(module, exports) { +function getPixelPrecision(dataExtent, pixelExtent) { + var log = Math.log; + var LN10 = Math.LN10; + var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10); + var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10); // toFixed() digits argument must be between 0 and 20. -var ArrayCtor = typeof Float32Array === 'undefined' ? Array : Float32Array; + var precision = Math.min(Math.max(-dataQuantity + sizeQuantity, 0), 20); + return !isFinite(precision) ? 20 : precision; +} /** - * 创建一个向量 - * @param {number} [x=0] - * @param {number} [y=0] - * @return {Vector2} + * Get a data of given precision, assuring the sum of percentages + * in valueList is 1. + * The largest remainer method is used. + * https://en.wikipedia.org/wiki/Largest_remainder_method + * + * @param {Array.} valueList a list of all data + * @param {number} idx index of the data to be processed in valueList + * @param {number} precision integer number showing digits of precision + * @return {number} percent ranging from 0 to 100 */ -function create(x, y) { - var out = new ArrayCtor(2); - if (x == null) { - x = 0; - } +function getPercentWithPrecision(valueList, idx, precision) { + if (!valueList[idx]) { + return 0; + } + + var sum = zrUtil.reduce(valueList, function (acc, val) { + return acc + (isNaN(val) ? 0 : val); + }, 0); + + if (sum === 0) { + return 0; + } + + var digits = Math.pow(10, precision); + var votesPerQuota = zrUtil.map(valueList, function (val) { + return (isNaN(val) ? 0 : val) / sum * digits * 100; + }); + var targetSeats = digits * 100; + var seats = zrUtil.map(votesPerQuota, function (votes) { + // Assign automatic seats. + return Math.floor(votes); + }); + var currentSum = zrUtil.reduce(seats, function (acc, val) { + return acc + val; + }, 0); + var remainder = zrUtil.map(votesPerQuota, function (votes, idx) { + return votes - seats[idx]; + }); // Has remainding votes. + + while (currentSum < targetSeats) { + // Find next largest remainder. + var max = Number.NEGATIVE_INFINITY; + var maxId = null; + + for (var i = 0, len = remainder.length; i < len; ++i) { + if (remainder[i] > max) { + max = remainder[i]; + maxId = i; + } + } // Add a vote to max remainder. - if (y == null) { - y = 0; + + ++seats[maxId]; + remainder[maxId] = 0; + ++currentSum; } - out[0] = x; - out[1] = y; - return out; -} -/** - * 复制向量数据 - * @param {Vector2} out - * @param {Vector2} v - * @return {Vector2} - */ + return seats[idx] / digits; +} // Number.MAX_SAFE_INTEGER, ie do not support. -function copy(out, v) { - out[0] = v[0]; - out[1] = v[1]; - return out; -} +var MAX_SAFE_INTEGER = 9007199254740991; /** - * 克隆一个向量 - * @param {Vector2} v - * @return {Vector2} + * To 0 - 2 * PI, considering negative radian. + * @param {number} radian + * @return {number} */ - -function clone(v) { - var out = new ArrayCtor(2); - out[0] = v[0]; - out[1] = v[1]; - return out; +function remRadian(radian) { + var pi2 = Math.PI * 2; + return (radian % pi2 + pi2) % pi2; } /** - * 设置向量的两个项 - * @param {Vector2} out - * @param {number} a - * @param {number} b - * @return {Vector2} 结果 + * @param {type} radian + * @return {boolean} */ -function set(out, a, b) { - out[0] = a; - out[1] = b; - return out; +function isRadianAroundZero(val) { + return val > -RADIAN_EPSILON && val < RADIAN_EPSILON; } -/** - * 向量相加 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ +var TIME_REG = /^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d\d)(?::(\d\d)(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/; // jshint ignore:line -function add(out, v1, v2) { - out[0] = v1[0] + v2[0]; - out[1] = v1[1] + v2[1]; - return out; -} /** - * 向量缩放后相加 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - * @param {number} a + * @param {string|Date|number} value These values can be accepted: + * + An instance of Date, represent a time in its own time zone. + * + Or string in a subset of ISO 8601, only including: + * + only year, month, date: '2012-03', '2012-03-01', '2012-03-01 05', '2012-03-01 05:06', + * + separated with T or space: '2012-03-01T12:22:33.123', '2012-03-01 12:22:33.123', + * + time zone: '2012-03-01T12:22:33Z', '2012-03-01T12:22:33+8000', '2012-03-01T12:22:33-05:00', + * all of which will be treated as local time if time zone is not specified + * (see ). + * + Or other string format, including (all of which will be treated as loacal time): + * '2012', '2012-3-1', '2012/3/1', '2012/03/01', + * '2009/6/12 2:00', '2009/6/12 2:05:08', '2009/6/12 2:05:08.123' + * + a timestamp, which represent a time in UTC. + * @return {Date} date */ +function parseDate(value) { + if (value instanceof Date) { + return value; + } else if (typeof value === 'string') { + // Different browsers parse date in different way, so we parse it manually. + // Some other issues: + // new Date('1970-01-01') is UTC, + // new Date('1970/01/01') and new Date('1970-1-01') is local. + // See issue #3623 + var match = TIME_REG.exec(value); -function scaleAndAdd(out, v1, v2, a) { - out[0] = v1[0] + v2[0] * a; - out[1] = v1[1] + v2[1] * a; - return out; -} -/** - * 向量相减 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ + if (!match) { + // return Invalid Date. + return new Date(NaN); + } // Use local time when no timezone offset specifed. -function sub(out, v1, v2) { - out[0] = v1[0] - v2[0]; - out[1] = v1[1] - v2[1]; - return out; + if (!match[8]) { + // match[n] can only be string or undefined. + // But take care of '12' + 1 => '121'. + return new Date(+match[1], +(match[2] || 1) - 1, +match[3] || 1, +match[4] || 0, +(match[5] || 0), +match[6] || 0, +match[7] || 0); + } // Timezoneoffset of Javascript Date has considered DST (Daylight Saving Time, + // https://tc39.github.io/ecma262/#sec-daylight-saving-time-adjustment). + // For example, system timezone is set as "Time Zone: America/Toronto", + // then these code will get different result: + // `new Date(1478411999999).getTimezoneOffset(); // get 240` + // `new Date(1478412000000).getTimezoneOffset(); // get 300` + // So we should not use `new Date`, but use `Date.UTC`. + else { + var hour = +match[4] || 0; + + if (match[8].toUpperCase() !== 'Z') { + hour -= match[8].slice(0, 3); + } + + return new Date(Date.UTC(+match[1], +(match[2] || 1) - 1, +match[3] || 1, hour, +(match[5] || 0), +match[6] || 0, +match[7] || 0)); + } + } else if (value == null) { + return new Date(NaN); + } + + return new Date(Math.round(value)); } /** - * 向量长度 - * @param {Vector2} v + * Quantity of a number. e.g. 0.1, 1, 10, 100 + * + * @param {number} val * @return {number} */ -function len(v) { - return Math.sqrt(lenSquare(v)); +function quantity(val) { + return Math.pow(10, quantityExponent(val)); } -var length = len; // jshint ignore:line - +function quantityExponent(val) { + return Math.floor(Math.log(val) / Math.LN10); +} /** - * 向量长度平方 - * @param {Vector2} v + * find a “nice” number approximately equal to x. Round the number if round = true, + * take ceiling if round = false. The primary observation is that the “nicest” + * numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers. + * + * See "Nice Numbers for Graph Labels" of Graphic Gems. + * + * @param {number} val Non-negative value. + * @param {boolean} round * @return {number} */ -function lenSquare(v) { - return v[0] * v[0] + v[1] * v[1]; -} - -var lengthSquare = lenSquare; -/** - * 向量乘法 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ -function mul(out, v1, v2) { - out[0] = v1[0] * v2[0]; - out[1] = v1[1] * v2[1]; - return out; -} -/** - * 向量除法 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ +function nice(val, round) { + var exponent = quantityExponent(val); + var exp10 = Math.pow(10, exponent); + var f = val / exp10; // 1 <= f < 10 + var nf; -function div(out, v1, v2) { - out[0] = v1[0] / v2[0]; - out[1] = v1[1] / v2[1]; - return out; -} -/** - * 向量点乘 - * @param {Vector2} v1 - * @param {Vector2} v2 - * @return {number} - */ + if (round) { + if (f < 1.5) { + nf = 1; + } else if (f < 2.5) { + nf = 2; + } else if (f < 4) { + nf = 3; + } else if (f < 7) { + nf = 5; + } else { + nf = 10; + } + } else { + if (f < 1) { + nf = 1; + } else if (f < 2) { + nf = 2; + } else if (f < 3) { + nf = 3; + } else if (f < 5) { + nf = 5; + } else { + nf = 10; + } + } + val = nf * exp10; // Fix 3 * 0.1 === 0.30000000000000004 issue (see IEEE 754). + // 20 is the uppper bound of toFixed. -function dot(v1, v2) { - return v1[0] * v2[0] + v1[1] * v2[1]; + return exponent >= -20 ? +val.toFixed(exponent < 0 ? -exponent : 0) : val; } /** - * 向量缩放 - * @param {Vector2} out - * @param {Vector2} v - * @param {number} s + * Order intervals asc, and split them when overlap. + * expect(numberUtil.reformIntervals([ + * {interval: [18, 62], close: [1, 1]}, + * {interval: [-Infinity, -70], close: [0, 0]}, + * {interval: [-70, -26], close: [1, 1]}, + * {interval: [-26, 18], close: [1, 1]}, + * {interval: [62, 150], close: [1, 1]}, + * {interval: [106, 150], close: [1, 1]}, + * {interval: [150, Infinity], close: [0, 0]} + * ])).toEqual([ + * {interval: [-Infinity, -70], close: [0, 0]}, + * {interval: [-70, -26], close: [1, 1]}, + * {interval: [-26, 18], close: [0, 1]}, + * {interval: [18, 62], close: [0, 1]}, + * {interval: [62, 150], close: [0, 1]}, + * {interval: [150, Infinity], close: [0, 0]} + * ]); + * @param {Array.} list, where `close` mean open or close + * of the interval, and Infinity can be used. + * @return {Array.} The origin list, which has been reformed. */ -function scale(out, v, s) { - out[0] = v[0] * s; - out[1] = v[1] * s; - return out; -} -/** - * 向量归一化 - * @param {Vector2} out - * @param {Vector2} v - */ +function reformIntervals(list) { + list.sort(function (a, b) { + return littleThan(a, b, 0) ? -1 : 1; + }); + var curr = -Infinity; + var currClose = 1; + for (var i = 0; i < list.length;) { + var interval = list[i].interval; + var close = list[i].close; -function normalize(out, v) { - var d = len(v); + for (var lg = 0; lg < 2; lg++) { + if (interval[lg] <= curr) { + interval[lg] = curr; + close[lg] = !lg ? 1 - currClose : 1; + } - if (d === 0) { - out[0] = 0; - out[1] = 0; - } else { - out[0] = v[0] / d; - out[1] = v[1] / d; + curr = interval[lg]; + currClose = close[lg]; + } + + if (interval[0] === interval[1] && close[0] * close[1] !== 1) { + list.splice(i, 1); + } else { + i++; + } } - return out; + return list; + + function littleThan(a, b, lg) { + return a.interval[lg] < b.interval[lg] || a.interval[lg] === b.interval[lg] && (a.close[lg] - b.close[lg] === (!lg ? 1 : -1) || !lg && littleThan(a, b, 1)); + } } /** - * 计算向量间距离 - * @param {Vector2} v1 - * @param {Vector2} v2 - * @return {number} + * parseFloat NaNs numeric-cast false positives (null|true|false|"") + * ...but misinterprets leading-number strings, particularly hex literals ("0x...") + * subtraction forces infinities to NaN + * + * @param {*} v + * @return {boolean} */ -function distance(v1, v2) { - return Math.sqrt((v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1])); +function isNumeric(v) { + return v - parseFloat(v) >= 0; } -var dist = distance; -/** - * 向量距离平方 - * @param {Vector2} v1 - * @param {Vector2} v2 - * @return {number} - */ +exports.linearMap = linearMap; +exports.parsePercent = parsePercent; +exports.round = round; +exports.asc = asc; +exports.getPrecision = getPrecision; +exports.getPrecisionSafe = getPrecisionSafe; +exports.getPixelPrecision = getPixelPrecision; +exports.getPercentWithPrecision = getPercentWithPrecision; +exports.MAX_SAFE_INTEGER = MAX_SAFE_INTEGER; +exports.remRadian = remRadian; +exports.isRadianAroundZero = isRadianAroundZero; +exports.parseDate = parseDate; +exports.quantity = quantity; +exports.nice = nice; +exports.reformIntervals = reformIntervals; +exports.isNumeric = isNumeric; -function distanceSquare(v1, v2) { - return (v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1]); -} +/***/ }), +/* 86 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -var distSquare = distanceSquare; -/** - * 求负向量 - * @param {Vector2} out - * @param {Vector2} v - */ +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture2D__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_util__ = __webpack_require__(23); -function negate(out, v) { - out[0] = -v[0]; - out[1] = -v[1]; - return out; + + + +var TexturePool = function () { + + this._pool = {}; + + this._allocatedTextures = []; +}; + +TexturePool.prototype = { + + constructor: TexturePool, + + get: function (parameters) { + var key = generateKey(parameters); + if (!this._pool.hasOwnProperty(key)) { + this._pool[key] = []; + } + var list = this._pool[key]; + if (!list.length) { + var texture = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */](parameters); + this._allocatedTextures.push(texture); + return texture; + } + return list.pop(); + }, + + put: function (texture) { + var key = generateKey(texture); + if (!this._pool.hasOwnProperty(key)) { + this._pool[key] = []; + } + var list = this._pool[key]; + list.push(texture); + }, + + clear: function (renderer) { + for (var i = 0; i < this._allocatedTextures.length; i++) { + this._allocatedTextures[i].dispose(renderer); + } + this._pool = {}; + this._allocatedTextures = []; + } +}; + +var defaultParams = { + width: 512, + height: 512, + type: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_BYTE, + format: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].RGBA, + wrapS: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE, + wrapT: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE, + minFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR, + magFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR, + useMipmap: true, + anisotropic: 1, + flipY: true, + unpackAlignment: 4, + premultiplyAlpha: false +}; + +var defaultParamPropList = Object.keys(defaultParams); + +function generateKey(parameters) { + __WEBPACK_IMPORTED_MODULE_2__core_util__["a" /* default */].defaultsWithPropList(parameters, defaultParams, defaultParamPropList); + fallBack(parameters); + + var key = ''; + for (var i = 0; i < defaultParamPropList.length; i++) { + var name = defaultParamPropList[i]; + var chunk = parameters[name].toString(); + key += chunk; + } + return key; } -/** - * 插值两个点 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - * @param {number} t - */ +function fallBack(target) { -function lerp(out, v1, v2, t) { - out[0] = v1[0] + t * (v2[0] - v1[0]); - out[1] = v1[1] + t * (v2[1] - v1[1]); - return out; + var IPOT = isPowerOfTwo(target.width, target.height); + + if (target.format === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DEPTH_COMPONENT) { + target.useMipmap = false; + } + + if (!IPOT || !target.useMipmap) { + if (target.minFilter == __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_NEAREST || + target.minFilter == __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_LINEAR) { + target.minFilter = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST; + } else if ( + target.minFilter == __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR || + target.minFilter == __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_NEAREST + ) { + target.minFilter = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR; + } + } + if (!IPOT) { + target.wrapS = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE; + target.wrapT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE; + } } -/** - * 矩阵左乘向量 - * @param {Vector2} out - * @param {Vector2} v - * @param {Vector2} m - */ +function isPowerOfTwo(width, height) { + return (width & (width-1)) === 0 && + (height & (height-1)) === 0; +} + +/* harmony default export */ __webpack_exports__["a"] = (TexturePool); + + +/***/ }), +/* 87 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.kernel.gaussian_9\nfloat gaussianKernel[9];\ngaussianKernel[0] = 0.07;\ngaussianKernel[1] = 0.09;\ngaussianKernel[2] = 0.12;\ngaussianKernel[3] = 0.14;\ngaussianKernel[4] = 0.16;\ngaussianKernel[5] = 0.14;\ngaussianKernel[6] = 0.12;\ngaussianKernel[7] = 0.09;\ngaussianKernel[8] = 0.07;\n@end\n@export clay.compositor.kernel.gaussian_13\nfloat gaussianKernel[13];\ngaussianKernel[0] = 0.02;\ngaussianKernel[1] = 0.03;\ngaussianKernel[2] = 0.06;\ngaussianKernel[3] = 0.08;\ngaussianKernel[4] = 0.11;\ngaussianKernel[5] = 0.13;\ngaussianKernel[6] = 0.14;\ngaussianKernel[7] = 0.13;\ngaussianKernel[8] = 0.11;\ngaussianKernel[9] = 0.08;\ngaussianKernel[10] = 0.06;\ngaussianKernel[11] = 0.03;\ngaussianKernel[12] = 0.02;\n@end\n@export clay.compositor.gaussian_blur\n#define SHADER_NAME gaussian_blur\nuniform sampler2D texture;varying vec2 v_Texcoord;\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main (void)\n{\n @import clay.compositor.kernel.gaussian_9\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n for (int i = 0; i < 9; i++) {\n float w = gaussianKernel[i];\n vec4 texel = decodeHDR(clampSample(texture, v_Texcoord + float(i - 4) * off));\n sum += texel * w;\n weightAll += w;\n }\n gl_FragColor = encodeHDR(sum / max(weightAll, 0.01));\n}\n@end\n"); + + +/***/ }), +/* 88 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ("\n@export clay.compositor.lut\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform sampler2D lookup;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n float blueColor = tex.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec4 newColor1 = texture2D(lookup, texPos1);\n vec4 newColor2 = texture2D(lookup, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n gl_FragColor = vec4(newColor.rgb, tex.w);\n}\n@end"); + + +/***/ }), +/* 89 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = tex.rgb;\n#ifdef OUTPUT_ALPHA\n gl_FragColor.a = tex.a;\n#else\n gl_FragColor.a = 1.0;\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end"); -function applyTransform(out, v, m) { - var x = v[0]; - var y = v[1]; - out[0] = m[0] * x + m[2] * y + m[4]; - out[1] = m[1] * x + m[3] * y + m[5]; - return out; -} -/** - * 求两个向量最小值 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ +/***/ }), +/* 90 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -function min(out, v1, v2) { - out[0] = Math.min(v1[0], v2[0]); - out[1] = Math.min(v1[1], v2[1]); - return out; -} -/** - * 求两个向量最大值 - * @param {Vector2} out - * @param {Vector2} v1 - * @param {Vector2} v2 - */ +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.bright\nuniform sampler2D texture;\nuniform float threshold : 1;\nuniform float scale : 1.0;\nuniform vec2 textureSize: [512, 512];\nvarying vec2 v_Texcoord;\nconst vec3 lumWeight = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvec4 median(vec4 a, vec4 b, vec4 c)\n{\n return a + b + c - min(min(a, b), c) - max(max(a, b), c);\n}\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n#ifdef ANTI_FLICKER\n vec3 d = 1.0 / textureSize.xyx * vec3(1.0, 1.0, 0.0);\n vec4 s1 = decodeHDR(texture2D(texture, v_Texcoord - d.xz));\n vec4 s2 = decodeHDR(texture2D(texture, v_Texcoord + d.xz));\n vec4 s3 = decodeHDR(texture2D(texture, v_Texcoord - d.zy));\n vec4 s4 = decodeHDR(texture2D(texture, v_Texcoord + d.zy));\n texel = median(median(texel, s1, s2), s3, s4);\n#endif\n float lum = dot(texel.rgb , lumWeight);\n vec4 color;\n if (lum > threshold && texel.a > 0.0)\n {\n color = vec4(texel.rgb * scale, texel.a * scale);\n }\n else\n {\n color = vec4(0.0);\n }\n gl_FragColor = encodeHDR(color);\n}\n@end\n"); -function max(out, v1, v2) { - out[0] = Math.max(v1[0], v2[0]); - out[1] = Math.max(v1[1], v2[1]); - return out; -} +/***/ }), +/* 91 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import clay.util.clamp_sample\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n#ifdef ANTI_FLICKER\n vec3 s1 = decodeHDR(clampSample(texture, v_Texcoord + d.xy)).rgb;\n vec3 s2 = decodeHDR(clampSample(texture, v_Texcoord + d.zy)).rgb;\n vec3 s3 = decodeHDR(clampSample(texture, v_Texcoord + d.xw)).rgb;\n vec3 s4 = decodeHDR(clampSample(texture, v_Texcoord + d.zw)).rgb;\n float s1w = 1.0 / (brightness(s1) + 1.0);\n float s2w = 1.0 / (brightness(s2) + 1.0);\n float s3w = 1.0 / (brightness(s3) + 1.0);\n float s4w = 1.0 / (brightness(s4) + 1.0);\n float oneDivideSum = 1.0 / (s1w + s2w + s3w + s4w);\n vec4 color = vec4(\n (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * oneDivideSum,\n 1.0\n );\n#else\n vec4 color = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n color *= 0.25;\n#endif\n gl_FragColor = encodeHDR(color);\n}\n@end"); -exports.create = create; -exports.copy = copy; -exports.clone = clone; -exports.set = set; -exports.add = add; -exports.scaleAndAdd = scaleAndAdd; -exports.sub = sub; -exports.len = len; -exports.length = length; -exports.lenSquare = lenSquare; -exports.lengthSquare = lengthSquare; -exports.mul = mul; -exports.div = div; -exports.dot = dot; -exports.scale = scale; -exports.normalize = normalize; -exports.distance = distance; -exports.dist = dist; -exports.distanceSquare = distanceSquare; -exports.distSquare = distSquare; -exports.negate = negate; -exports.lerp = lerp; -exports.applyTransform = applyTransform; -exports.min = min; -exports.max = max; /***/ }), -/* 77 */ -/***/ (function(module, exports) { +/* 92 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -/** - * 3x2矩阵操作类 - * @exports zrender/tool/matrix - */ -var ArrayCtor = typeof Float32Array === 'undefined' ? Array : Float32Array; -/** - * Create a identity matrix. - * @return {Float32Array|Array.} - */ +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ("\n@export clay.compositor.upsample\n#define HIGH_QUALITY\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord - d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord - d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord - d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord )) * 4.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n gl_FragColor = encodeHDR(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n gl_FragColor = encodeHDR(s / 4.0);\n#endif\n}\n@end"); -function create() { - var out = new ArrayCtor(6); - identity(out); - return out; -} -/** - * 设置矩阵为单位矩阵 - * @param {Float32Array|Array.} out - */ +/***/ }), +/* 93 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -function identity(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = 0; - out[5] = 0; - return out; -} -/** - * 复制矩阵 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} m - */ +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.hdr.composite\n#define TONEMAPPING\nuniform sampler2D texture;\n#ifdef BLOOM_ENABLED\nuniform sampler2D bloom;\n#endif\n#ifdef LENSFLARE_ENABLED\nuniform sampler2D lensflare;\nuniform sampler2D lensdirt;\n#endif\n#ifdef LUM_ENABLED\nuniform sampler2D lum;\n#endif\n#ifdef LUT_ENABLED\nuniform sampler2D lut;\n#endif\n#ifdef COLOR_CORRECTION\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float saturation : 1.0;\n#endif\n#ifdef VIGNETTE\nuniform float vignetteDarkness: 1.0;\nuniform float vignetteOffset: 1.0;\n#endif\nuniform float exposure : 1.0;\nuniform float bloomIntensity : 0.25;\nuniform float lensflareIntensity : 1;\nvarying vec2 v_Texcoord;\n@import clay.util.srgb\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nfloat eyeAdaption(float fLum)\n{\n return mix(0.2, fLum, 0.5);\n}\n#ifdef LUT_ENABLED\nvec3 lutTransform(vec3 color) {\n float blueColor = color.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec4 newColor1 = texture2D(lut, texPos1);\n vec4 newColor2 = texture2D(lut, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n return newColor.rgb;\n}\n#endif\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = vec4(0.0);\n vec4 originalTexel = vec4(0.0);\n#ifdef TEXTURE_ENABLED\n texel = decodeHDR(texture2D(texture, v_Texcoord));\n originalTexel = texel;\n#endif\n#ifdef BLOOM_ENABLED\n vec4 bloomTexel = decodeHDR(texture2D(bloom, v_Texcoord));\n texel.rgb += bloomTexel.rgb * bloomIntensity;\n texel.a += bloomTexel.a * bloomIntensity;\n#endif\n#ifdef LENSFLARE_ENABLED\n texel += decodeHDR(texture2D(lensflare, v_Texcoord)) * texture2D(lensdirt, v_Texcoord) * lensflareIntensity;\n#endif\n texel.a = min(texel.a, 1.0);\n#ifdef LUM_ENABLED\n float fLum = texture2D(lum, vec2(0.5, 0.5)).r;\n float adaptedLumDest = 3.0 / (max(0.1, 1.0 + 10.0*eyeAdaption(fLum)));\n float exposureBias = adaptedLumDest * exposure;\n#else\n float exposureBias = exposure;\n#endif\n#ifdef TONEMAPPING\n texel.rgb *= exposureBias;\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n texel = linearTosRGB(texel);\n#ifdef LUT_ENABLED\n texel.rgb = lutTransform(clamp(texel.rgb,vec3(0.0),vec3(1.0)));\n#endif\n#ifdef COLOR_CORRECTION\n texel.rgb = clamp(texel.rgb + vec3(brightness), 0.0, 1.0);\n texel.rgb = clamp((texel.rgb - vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n float lum = dot(texel.rgb, vec3(0.2125, 0.7154, 0.0721));\n texel.rgb = mix(vec3(lum), texel.rgb, saturation);\n#endif\n#ifdef VIGNETTE\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(vignetteOffset);\n texel.rgb = mix(texel.rgb, vec3(1.0 - vignetteDarkness), dot(uv, uv));\n#endif\n gl_FragColor = encodeHDR(texel);\n#ifdef DEBUG\n #if DEBUG == 1\n gl_FragColor = encodeHDR(decodeHDR(texture2D(texture, v_Texcoord)));\n #elif DEBUG == 2\n gl_FragColor = encodeHDR(decodeHDR(texture2D(bloom, v_Texcoord)) * bloomIntensity);\n #elif DEBUG == 3\n gl_FragColor = encodeHDR(decodeHDR(texture2D(lensflare, v_Texcoord) * lensflareIntensity));\n #endif\n#endif\n if (originalTexel.a <= 0.01 && gl_FragColor.a > 1e-5) {\n gl_FragColor.a = dot(gl_FragColor.rgb, vec3(0.2125, 0.7154, 0.0721));\n }\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end"); -function copy(out, m) { - out[0] = m[0]; - out[1] = m[1]; - out[2] = m[2]; - out[3] = m[3]; - out[4] = m[4]; - out[5] = m[5]; - return out; -} -/** - * 矩阵相乘 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} m1 - * @param {Float32Array|Array.} m2 - */ +/***/ }), +/* 94 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.blend\n#define SHADER_NAME blend\n#ifdef TEXTURE1_ENABLED\nuniform sampler2D texture1;\nuniform float weight1 : 1.0;\n#endif\n#ifdef TEXTURE2_ENABLED\nuniform sampler2D texture2;\nuniform float weight2 : 1.0;\n#endif\n#ifdef TEXTURE3_ENABLED\nuniform sampler2D texture3;\nuniform float weight3 : 1.0;\n#endif\n#ifdef TEXTURE4_ENABLED\nuniform sampler2D texture4;\nuniform float weight4 : 1.0;\n#endif\n#ifdef TEXTURE5_ENABLED\nuniform sampler2D texture5;\nuniform float weight5 : 1.0;\n#endif\n#ifdef TEXTURE6_ENABLED\nuniform sampler2D texture6;\nuniform float weight6 : 1.0;\n#endif\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = vec4(0.0);\n#ifdef TEXTURE1_ENABLED\n tex += decodeHDR(texture2D(texture1, v_Texcoord)) * weight1;\n#endif\n#ifdef TEXTURE2_ENABLED\n tex += decodeHDR(texture2D(texture2, v_Texcoord)) * weight2;\n#endif\n#ifdef TEXTURE3_ENABLED\n tex += decodeHDR(texture2D(texture3, v_Texcoord)) * weight3;\n#endif\n#ifdef TEXTURE4_ENABLED\n tex += decodeHDR(texture2D(texture4, v_Texcoord)) * weight4;\n#endif\n#ifdef TEXTURE5_ENABLED\n tex += decodeHDR(texture2D(texture5, v_Texcoord)) * weight5;\n#endif\n#ifdef TEXTURE6_ENABLED\n tex += decodeHDR(texture2D(texture6, v_Texcoord)) * weight6;\n#endif\n gl_FragColor = encodeHDR(tex);\n}\n@end"); -function mul(out, m1, m2) { - // Consider matrix.mul(m, m2, m); - // where out is the same as m2. - // So use temp variable to escape error. - var out0 = m1[0] * m2[0] + m1[2] * m2[1]; - var out1 = m1[1] * m2[0] + m1[3] * m2[1]; - var out2 = m1[0] * m2[2] + m1[2] * m2[3]; - var out3 = m1[1] * m2[2] + m1[3] * m2[3]; - var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4]; - var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5]; - out[0] = out0; - out[1] = out1; - out[2] = out2; - out[3] = out3; - out[4] = out4; - out[5] = out5; - return out; -} -/** - * 平移变换 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - * @param {Float32Array|Array.} v - */ +/***/ }), +/* 95 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -function translate(out, a, v) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4] + v[0]; - out[5] = a[5] + v[1]; - return out; -} -/** - * 旋转变换 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - * @param {number} rad - */ +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.fxaa\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nvarying vec2 v_Texcoord;\n#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\n@import clay.util.rgbm\nvoid main()\n{\n vec2 resolution = 1.0 / viewport.zw;\n vec3 rgbNW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbNE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ) ).xyz;\n vec4 rgbaM = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution ) );\n vec3 rgbM = rgbaM.xyz;\n float opacity = rgbaM.w;\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float lumaNW = dot( rgbNW, luma );\n float lumaNE = dot( rgbNE, luma );\n float lumaSW = dot( rgbSW, luma );\n float lumaSE = dot( rgbSE, luma );\n float lumaM = dot( rgbM, luma );\n float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );\n float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * resolution;\n vec3 rgbA = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA *= 0.5;\n vec3 rgbB = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * -0.5 ) ).xyz;\n rgbB += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * 0.5 ) ).xyz;\n rgbB *= 0.25;\n rgbB += rgbA * 0.5;\n float lumaB = dot( rgbB, luma );\n if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )\n {\n gl_FragColor = vec4( rgbA, opacity );\n }\n else {\n gl_FragColor = vec4( rgbB, opacity );\n }\n}\n@end"); -function rotate(out, a, rad) { - var aa = a[0]; - var ac = a[2]; - var atx = a[4]; - var ab = a[1]; - var ad = a[3]; - var aty = a[5]; - var st = Math.sin(rad); - var ct = Math.cos(rad); - out[0] = aa * ct + ab * st; - out[1] = -aa * st + ab * ct; - out[2] = ac * ct + ad * st; - out[3] = -ac * st + ct * ad; - out[4] = ct * atx + st * aty; - out[5] = ct * aty - st * atx; - return out; -} -/** - * 缩放变换 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - * @param {Float32Array|Array.} v - */ +/***/ }), +/* 96 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -function scale(out, a, v) { - var vx = v[0]; - var vy = v[1]; - out[0] = a[0] * vx; - out[1] = a[1] * vy; - out[2] = a[2] * vx; - out[3] = a[3] * vy; - out[4] = a[4] * vx; - out[5] = a[5] * vy; - return out; -} -/** - * 求逆矩阵 - * @param {Float32Array|Array.} out - * @param {Float32Array|Array.} a - */ +/* harmony default export */ __webpack_exports__["a"] = ({ -function invert(out, a) { - var aa = a[0]; - var ac = a[2]; - var atx = a[4]; - var ab = a[1]; - var ad = a[3]; - var aty = a[5]; - var det = aa * ad - ab * ac; + getFilledRegions: function (regions, mapData) { + var regionsArr = (regions || []).slice(); - if (!det) { - return null; - } + var geoJson; + if (typeof mapData === 'string') { + mapData = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.getMap(mapData); + geoJson = mapData && mapData.geoJson; + } + else { + if (mapData && mapData.features) { + geoJson = mapData; + } + } + if (!geoJson) { + if (true) { + console.error('Map ' + mapData + ' not exists. You can download map file on http://echarts.baidu.com/download-map.html'); + if (!geoJson.features) { + console.error('Invalid GeoJSON for map3D'); + } + } + return []; + } - 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; -} -/** - * Clone a new matrix. - * @param {Float32Array|Array.} a - */ + var dataNameMap = {}; + var features = geoJson.features; + for (var i = 0; i < regionsArr.length; i++) { + dataNameMap[regionsArr[i].name] = regionsArr[i]; + } + for (var i = 0; i < features.length; i++) { + var name = features[i].properties.name; + if (!dataNameMap[name]) { + regionsArr.push({ + name: name + }); + } + } -function clone(a) { - var b = create(); - copy(b, a); - return b; -} + return regionsArr; + }, -exports.create = create; -exports.identity = identity; -exports.copy = copy; -exports.mul = mul; -exports.translate = translate; -exports.rotate = rotate; -exports.scale = scale; -exports.invert = invert; -exports.clone = clone; + defaultOption: { + show: true, -/***/ }), -/* 78 */ -/***/ (function(module, exports, __webpack_require__) { + zlevel: -10, -var zrUtil = __webpack_require__(12); + // geoJson used by geo3D + map: '', -var RADIAN_EPSILON = 1e-4; + // Layout used for viewport + left: 0, + top: 0, + width: '100%', + height: '100%', -function _trim(str) { - return str.replace(/^\s+/, '').replace(/\s+$/, ''); -} -/** - * Linear mapping a value from domain to range - * @memberOf module:echarts/util/number - * @param {(number|Array.)} val - * @param {Array.} domain Domain extent domain[0] can be bigger than domain[1] - * @param {Array.} range Range extent range[0] can be bigger than range[1] - * @param {boolean} clamp - * @return {(number|Array.} - */ + boxWidth: 100, + boxHeight: 10, + boxDepth: 'auto', + regionHeight: 3, -function linearMap(val, domain, range, clamp) { - var subDomain = domain[1] - domain[0]; - var subRange = range[1] - range[0]; + environment: 'auto', - if (subDomain === 0) { - return subRange === 0 ? range[0] : (range[0] + range[1]) / 2; - } // Avoid accuracy problem in edge, such as - // 146.39 - 62.83 === 83.55999999999999. - // See echarts/test/ut/spec/util/number.js#linearMap#accuracyError - // It is a little verbose for efficiency considering this method - // is a hotspot. + groundPlane: { + show: false, + color: '#aaa' + }, + shading: 'lambert', - if (clamp) { - if (subDomain > 0) { - if (val <= domain[0]) { - return range[0]; - } else if (val >= domain[1]) { - return range[1]; - } - } else { - if (val >= domain[0]) { - return range[0]; - } else if (val <= domain[1]) { - return range[1]; - } - } - } else { - if (val === domain[0]) { - return range[0]; - } + light: { + main: { + alpha: 40, + beta: 30 + } + }, - if (val === domain[1]) { - return range[1]; - } - } + viewControl: { + alpha: 40, + beta: 0, + distance: 100, + orthographicSize: 60, - return (val - domain[0]) / subDomain * subRange + range[0]; -} -/** - * Convert a percent string to absolute number. - * Returns NaN if percent is not a valid string or number - * @memberOf module:echarts/util/number - * @param {string|number} percent - * @param {number} all - * @return {number} - */ + minAlpha: 5, + minBeta: -80, + maxBeta: 80 + }, + label: { + show: false, + // Distance in 3d space. + distance: 2, -function parsePercent(percent, all) { - switch (percent) { - case 'center': - case 'middle': - percent = '50%'; - break; + textStyle: { + fontSize: 20, + color: '#000', + backgroundColor: 'rgba(255,255,255,0.7)', + padding: 3, + borderRadius: 4 + } + }, - case 'left': - case 'top': - percent = '0%'; - break; + // TODO + // altitude: { + // min: 'auto', + // max: 'auto', - case 'right': - case 'bottom': - percent = '100%'; - break; - } + // height: [] + // }, - if (typeof percent === 'string') { - if (_trim(percent).match(/%$/)) { - return parseFloat(percent) / 100 * all; + + // labelLine + + // light + // postEffect + // temporalSuperSampling + + itemStyle: { + color: '#fff', + borderWidth: 0, + borderColor: '#333' + }, + + emphasis: { + itemStyle: { + // color: '#f94b59' + color: '#639fc0' + }, + label: { + show: true + } + } } +}); - return parseFloat(percent); - } +/***/ }), +/* 97 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - return percent == null ? NaN : +percent; +"use strict"; + +function swap(arr, a, b) { + var tmp = arr[a]; + arr[a] = arr[b]; + arr[b] = tmp; } -/** - * (1) Fix rounding error of float numbers. - * (2) Support return string to avoid scientific notation like '3.5e-7'. - * - * @param {number} x - * @param {number} [precision] - * @param {boolean} [returnStr] - * @return {number|string} - */ +function partition(arr, pivot, left, right, compare) { + var storeIndex = left; + var pivotValue = arr[pivot]; + // put the pivot on the right + swap(arr, pivot, right); -function round(x, precision, returnStr) { - if (precision == null) { - precision = 10; - } // Avoid range error + // go through the rest + for(var v = left; v < right; v++) { + if(compare(arr[v], pivotValue) < 0) { + swap(arr, v, storeIndex); + storeIndex++; + } + } + // finally put the pivot in the correct place + swap(arr, right, storeIndex); - precision = Math.min(Math.max(0, precision), 20); - x = (+x).toFixed(precision); - return returnStr ? x : +x; + return storeIndex; } -function asc(arr) { - arr.sort(function (a, b) { - return a - b; - }); - return arr; +function quickSort(array, compare, left, right) { + if(left < right) { + var pivot = Math.floor((left + right) / 2); + var newPivot = partition(array, pivot, left, right, compare); + quickSort(array, compare, left, newPivot - 1); + quickSort(array, compare, newPivot + 1, right); + } +} + + +// TODO Test. +function ProgressiveQuickSort() { + + // this._pivotList = new LinkedList(); + this._parts = []; } -/** - * Get precision - * @param {number} val - */ +ProgressiveQuickSort.prototype.step = function (arr, compare, frame) { -function getPrecision(val) { - val = +val; + var len = arr.length; + if (frame === 0) { + this._parts = []; + this._sorted = false; - if (isNaN(val)) { - return 0; - } // It is much faster than methods converting number to string as follows - // var tmp = val.toString(); - // return tmp.length - 1 - tmp.indexOf('.'); - // especially when precision is low + // Pick a start pivot; + var pivot = Math.floor(len / 2); + this._parts.push({ + pivot: pivot, + left: 0, + right: len - 1 + }); + this._currentSortPartIdx = 0; + } - var e = 1; - var count = 0; + if (this._sorted) { + return; + } - while (Math.round(val * e) / e !== val) { - e *= 10; - count++; - } + var parts = this._parts; + if (parts.length === 0) { + this._sorted = true; + // Already finished. + return true; + } + else if (parts.length < 512) { + // Sort large parts in about 10 frames. + for (var i = 0; i < parts.length; i++) { + // Partition and Modify the pivot index. + parts[i].pivot = partition( + arr, parts[i].pivot, parts[i].left, parts[i].right, compare + ); + } - return count; -} -/** - * @param {string|number} val - * @return {number} - */ + var subdividedParts = []; + for (var i = 0; i < parts.length; i++) { + // Subdivide left + var left = parts[i].left; + var right = parts[i].pivot - 1; + if (right > left) { + subdividedParts.push({ + pivot: Math.floor((right + left) / 2), + left: left, right: right + }); + } + // Subdivide right + var left = parts[i].pivot + 1; + var right = parts[i].right; + if (right > left) { + subdividedParts.push({ + pivot: Math.floor((right + left) / 2), + left: left, right: right + }); + } + } + parts = this._parts = subdividedParts; + } + else { + // console.time('sort'); + // Finally quick sort each parts in 10 frames. + for (var i = 0; i < Math.floor(parts.length / 10); i++) { + // Sort near parts first. + var idx = parts.length - 1 - this._currentSortPartIdx; + quickSort(arr, compare, parts[idx].left, parts[idx].right); + this._currentSortPartIdx++; + // Finish sort + if (this._currentSortPartIdx === parts.length) { + this._sorted = true; + return true; + } + } + // console.timeEnd('sort'); -function getPrecisionSafe(val) { - var str = val.toString(); // Consider scientific notation: '3.4e-12' '3.4e+12' + } - var eIndex = str.indexOf('e'); + return false; +}; - if (eIndex > 0) { - var precision = +str.slice(eIndex + 1); - return precision < 0 ? -precision : 0; - } else { - var dotIndex = str.indexOf('.'); - return dotIndex < 0 ? 0 : str.length - 1 - dotIndex; - } -} -/** - * Minimal dicernible data precisioin according to a single pixel. - * - * @param {Array.} dataExtent - * @param {Array.} pixelExtent - * @return {number} precision - */ +ProgressiveQuickSort.sort = quickSort; +/* harmony default export */ __webpack_exports__["a"] = (ProgressiveQuickSort); -function getPixelPrecision(dataExtent, pixelExtent) { - var log = Math.log; - var LN10 = Math.LN10; - var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10); - var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10); // toFixed() digits argument must be between 0 and 20. +/***/ }), +/* 98 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - var precision = Math.min(Math.max(-dataQuantity + sizeQuantity, 0), 20); - return !isFinite(precision) ? 20 : precision; -} -/** - * Get a data of given precision, assuring the sum of percentages - * in valueList is 1. - * The largest remainer method is used. - * https://en.wikipedia.org/wiki/Largest_remainder_method - * - * @param {Array.} valueList a list of all data - * @param {number} idx index of the data to be processed in valueList - * @param {number} precision integer number showing digits of precision - * @return {number} percent ranging from 0 to 100 - */ +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geo3D_Geo3D__ = __webpack_require__(99); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout__ = __webpack_require__(47); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__ = __webpack_require__(22); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_retrieve__ = __webpack_require__(2); -function getPercentWithPrecision(valueList, idx, precision) { - if (!valueList[idx]) { - return 0; - } - var sum = zrUtil.reduce(valueList, function (acc, val) { - return acc + (isNaN(val) ? 0 : val); - }, 0); - if (sum === 0) { - return 0; - } - var digits = Math.pow(10, precision); - var votesPerQuota = zrUtil.map(valueList, function (val) { - return (isNaN(val) ? 0 : val) / sum * digits * 100; - }); - var targetSeats = digits * 100; - var seats = zrUtil.map(votesPerQuota, function (votes) { - // Assign automatic seats. - return Math.floor(votes); - }); - var currentSum = zrUtil.reduce(seats, function (acc, val) { - return acc + val; - }, 0); - var remainder = zrUtil.map(votesPerQuota, function (votes, idx) { - return votes - seats[idx]; - }); // Has remainding votes. - while (currentSum < targetSeats) { - // Find next largest remainder. - var max = Number.NEGATIVE_INFINITY; - var maxId = null; +function resizeGeo3D(geo3DModel, api) { + // Use left/top/width/height + var boxLayoutOption = geo3DModel.getBoxLayoutParams(); - for (var i = 0, len = remainder.length; i < len; ++i) { - if (remainder[i] > max) { - max = remainder[i]; - maxId = i; - } - } // Add a vote to max remainder. + var viewport = __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout___default.a.getLayoutRect(boxLayoutOption, { + width: api.getWidth(), + height: api.getHeight() + }); + // Flip Y + viewport.y = api.getHeight() - viewport.y - viewport.height; - ++seats[maxId]; - remainder[maxId] = 0; - ++currentSum; - } + this.viewGL.setViewport(viewport.x, viewport.y, viewport.width, viewport.height, api.getDevicePixelRatio()); - return seats[idx] / digits; -} // Number.MAX_SAFE_INTEGER, ie do not support. + var geoRect = this.getGeoBoundingRect(); + var aspect = geoRect.width / geoRect.height * (geo3DModel.get('aspectScale') || 0.75); + + var width = geo3DModel.get('boxWidth'); + var depth = geo3DModel.get('boxDepth'); + var height = geo3DModel.get('boxHeight'); + if (height == null) { + height = 5; + } + if (isNaN(width) && isNaN(depth)) { + // Default to have 100 width + width = 100; + } + if (isNaN(depth)) { + depth = width / aspect; + } + else if (isNaN(width)) { + width = depth / aspect; + } + this.setSize(width, height, depth); -var MAX_SAFE_INTEGER = 9007199254740991; -/** - * To 0 - 2 * PI, considering negative radian. - * @param {number} radian - * @return {number} - */ + this.regionHeight = geo3DModel.get('regionHeight'); -function remRadian(radian) { - var pi2 = Math.PI * 2; - return (radian % pi2 + pi2) % pi2; + if (this.altitudeAxis) { + this.altitudeAxis.setExtent(0, Math.max(height - this.regionHeight, 0)); + } } -/** - * @param {type} radian - * @return {boolean} - */ +function updateGeo3D(ecModel, api) { -function isRadianAroundZero(val) { - return val > -RADIAN_EPSILON && val < RADIAN_EPSILON; -} + var altitudeDataExtent = [Infinity, -Infinity]; -var TIME_REG = /^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d\d)(?::(\d\d)(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/; // jshint ignore:line + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.coordinateSystem !== this) { + return; + } + if (seriesModel.type === 'series.map3D') { + return; + } + // Get altitude data extent. + var data = seriesModel.getData(); + var altDims = seriesModel.coordDimToDataDim('alt'); + var altDim = altDims && altDims[0]; + if (altDim) { + // TODO altitiude is in coords of lines. + var dataExtent = data.getDataExtent(altDim, true); + altitudeDataExtent[0] = Math.min( + altitudeDataExtent[0], dataExtent[0] + ); + altitudeDataExtent[1] = Math.max( + altitudeDataExtent[1], dataExtent[1] + ); + } + }, this); + // Create altitude axis + if (altitudeDataExtent && isFinite(altitudeDataExtent[1] - altitudeDataExtent[0])) { + var scale = __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.helper.createScale( + altitudeDataExtent, { + type: 'value', + // PENDING + min: 'dataMin', + max: 'dataMax' + } + ); + this.altitudeAxis = new __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.Axis('altitude', scale); + // Resize again + this.resize(this.model, api); + } +} -/** - * @param {string|Date|number} value These values can be accepted: - * + An instance of Date, represent a time in its own time zone. - * + Or string in a subset of ISO 8601, only including: - * + only year, month, date: '2012-03', '2012-03-01', '2012-03-01 05', '2012-03-01 05:06', - * + separated with T or space: '2012-03-01T12:22:33.123', '2012-03-01 12:22:33.123', - * + time zone: '2012-03-01T12:22:33Z', '2012-03-01T12:22:33+8000', '2012-03-01T12:22:33-05:00', - * all of which will be treated as local time if time zone is not specified - * (see ). - * + Or other string format, including (all of which will be treated as loacal time): - * '2012', '2012-3-1', '2012/3/1', '2012/03/01', - * '2009/6/12 2:00', '2009/6/12 2:05:08', '2009/6/12 2:05:08.123' - * + a timestamp, which represent a time in UTC. - * @return {Date} date - */ -function parseDate(value) { - if (value instanceof Date) { - return value; - } else if (typeof value === 'string') { - // Different browsers parse date in different way, so we parse it manually. - // Some other issues: - // new Date('1970-01-01') is UTC, - // new Date('1970/01/01') and new Date('1970-1-01') is local. - // See issue #3623 - var match = TIME_REG.exec(value); +if (true) { + var mapNotExistsError = function (name) { + console.error('Map ' + name + ' not exists. You can download map file on http://echarts.baidu.com/download-map.html'); + }; +} - if (!match) { - // return Invalid Date. - return new Date(NaN); - } // Use local time when no timezone offset specifed. +var idStart = 0; - if (!match[8]) { - // match[n] can only be string or undefined. - // But take care of '12' + 1 => '121'. - return new Date(+match[1], +(match[2] || 1) - 1, +match[3] || 1, +match[4] || 0, +(match[5] || 0), +match[6] || 0, +match[7] || 0); - } // Timezoneoffset of Javascript Date has considered DST (Daylight Saving Time, - // https://tc39.github.io/ecma262/#sec-daylight-saving-time-adjustment). - // For example, system timezone is set as "Time Zone: America/Toronto", - // then these code will get different result: - // `new Date(1478411999999).getTimezoneOffset(); // get 240` - // `new Date(1478412000000).getTimezoneOffset(); // get 300` - // So we should not use `new Date`, but use `Date.UTC`. - else { - var hour = +match[4] || 0; +var geo3DCreator = { - if (match[8].toUpperCase() !== 'Z') { - hour -= match[8].slice(0, 3); - } + dimensions: __WEBPACK_IMPORTED_MODULE_0__geo3D_Geo3D__["a" /* default */].prototype.dimensions, - return new Date(Date.UTC(+match[1], +(match[2] || 1) - 1, +match[3] || 1, hour, +(match[5] || 0), +match[6] || 0, +match[7] || 0)); - } - } else if (value == null) { - return new Date(NaN); - } + create: function (ecModel, api) { - return new Date(Math.round(value)); -} -/** - * Quantity of a number. e.g. 0.1, 1, 10, 100 - * - * @param {number} val - * @return {number} - */ + var geo3DList = []; + if (!__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.getMap) { + throw new Error('geo3D component depends on geo component'); + } -function quantity(val) { - return Math.pow(10, quantityExponent(val)); -} + function createGeo3D(componentModel, idx) { -function quantityExponent(val) { - return Math.floor(Math.log(val) / Math.LN10); -} -/** - * find a “nice” number approximately equal to x. Round the number if round = true, - * take ceiling if round = false. The primary observation is that the “nicest” - * numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers. - * - * See "Nice Numbers for Graph Labels" of Graphic Gems. - * - * @param {number} val Non-negative value. - * @param {boolean} round - * @return {number} - */ + var geo3D = geo3DCreator.createGeo3D(componentModel); + // FIXME + componentModel.__viewGL = componentModel.__viewGL || new __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__["a" /* default */](); -function nice(val, round) { - var exponent = quantityExponent(val); - var exp10 = Math.pow(10, exponent); - var f = val / exp10; // 1 <= f < 10 + geo3D.viewGL = componentModel.__viewGL; - var nf; + componentModel.coordinateSystem = geo3D; + geo3D.model = componentModel; - if (round) { - if (f < 1.5) { - nf = 1; - } else if (f < 2.5) { - nf = 2; - } else if (f < 4) { - nf = 3; - } else if (f < 7) { - nf = 5; - } else { - nf = 10; - } - } else { - if (f < 1) { - nf = 1; - } else if (f < 2) { - nf = 2; - } else if (f < 3) { - nf = 3; - } else if (f < 5) { - nf = 5; - } else { - nf = 10; - } - } + geo3DList.push(geo3D); - val = nf * exp10; // Fix 3 * 0.1 === 0.30000000000000004 issue (see IEEE 754). - // 20 is the uppper bound of toFixed. + // Inject resize + geo3D.resize = resizeGeo3D; + geo3D.resize(componentModel, api); - return exponent >= -20 ? +val.toFixed(exponent < 0 ? -exponent : 0) : val; -} -/** - * Order intervals asc, and split them when overlap. - * expect(numberUtil.reformIntervals([ - * {interval: [18, 62], close: [1, 1]}, - * {interval: [-Infinity, -70], close: [0, 0]}, - * {interval: [-70, -26], close: [1, 1]}, - * {interval: [-26, 18], close: [1, 1]}, - * {interval: [62, 150], close: [1, 1]}, - * {interval: [106, 150], close: [1, 1]}, - * {interval: [150, Infinity], close: [0, 0]} - * ])).toEqual([ - * {interval: [-Infinity, -70], close: [0, 0]}, - * {interval: [-70, -26], close: [1, 1]}, - * {interval: [-26, 18], close: [0, 1]}, - * {interval: [18, 62], close: [0, 1]}, - * {interval: [62, 150], close: [0, 1]}, - * {interval: [150, Infinity], close: [0, 0]} - * ]); - * @param {Array.} list, where `close` mean open or close - * of the interval, and Infinity can be used. - * @return {Array.} The origin list, which has been reformed. - */ + geo3D.update = updateGeo3D; + } + ecModel.eachComponent('geo3D', function (geo3DModel, idx) { + createGeo3D(geo3DModel, idx); + }); -function reformIntervals(list) { - list.sort(function (a, b) { - return littleThan(a, b, 0) ? -1 : 1; - }); - var curr = -Infinity; - var currClose = 1; + ecModel.eachSeriesByType('map3D', function (map3DModel, idx) { + var coordSys = map3DModel.get('coordinateSystem'); + if (coordSys == null) { + coordSys = 'geo3D'; + } + if (coordSys === 'geo3D') { + createGeo3D(map3DModel, idx); + } + }); - for (var i = 0; i < list.length;) { - var interval = list[i].interval; - var close = list[i].close; + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.get('coordinateSystem') === 'geo3D') { + if (seriesModel.type === 'series.map3D') { + return; + } + var geo3DModel = seriesModel.getReferringComponents('geo3D')[0]; + if (!geo3DModel) { + geo3DModel = ecModel.getComponent('geo3D'); + } - for (var lg = 0; lg < 2; lg++) { - if (interval[lg] <= curr) { - interval[lg] = curr; - close[lg] = !lg ? 1 - currClose : 1; - } + if (!geo3DModel) { + throw new Error('geo "' + __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull( + seriesModel.get('geo3DIndex'), + seriesModel.get('geo3DId'), + 0 + ) + '" not found'); + } - curr = interval[lg]; - currClose = close[lg]; - } + seriesModel.coordinateSystem = geo3DModel.coordinateSystem; + } + }); - if (interval[0] === interval[1] && close[0] * close[1] !== 1) { - list.splice(i, 1); - } else { - i++; - } - } + return geo3DList; + }, - return list; + createGeo3D: function (componentModel) { - function littleThan(a, b, lg) { - return a.interval[lg] < b.interval[lg] || a.interval[lg] === b.interval[lg] && (a.close[lg] - b.close[lg] === (!lg ? 1 : -1) || !lg && littleThan(a, b, 1)); - } -} -/** - * parseFloat NaNs numeric-cast false positives (null|true|false|"") - * ...but misinterprets leading-number strings, particularly hex literals ("0x...") - * subtraction forces infinities to NaN - * - * @param {*} v - * @return {boolean} - */ + var mapData = componentModel.get('map'); + var name; + if (typeof mapData === 'string') { + name = mapData; + mapData = __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.getMap(mapData); + } + else { + if (mapData && mapData.features) { + mapData = { + geoJson: mapData + }; + } + } + if (true) { + if (!mapData) { + mapNotExistsError(mapData); + } + if (!mapData.geoJson.features) { + throw new Error('Invalid GeoJSON for map3D'); + } + } + if (name == null) { + name = 'GEO_ANONYMOUS_' + idStart++; + } + return new __WEBPACK_IMPORTED_MODULE_0__geo3D_Geo3D__["a" /* default */]( + name + idStart++, name, + mapData && mapData.geoJson, mapData && mapData.specialAreas, + componentModel.get('nameMap') + ); + } +}; -function isNumeric(v) { - return v - parseFloat(v) >= 0; -} +__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.registerCoordinateSystem('geo3D', geo3DCreator); -exports.linearMap = linearMap; -exports.parsePercent = parsePercent; -exports.round = round; -exports.asc = asc; -exports.getPrecision = getPrecision; -exports.getPrecisionSafe = getPrecisionSafe; -exports.getPixelPrecision = getPixelPrecision; -exports.getPercentWithPrecision = getPercentWithPrecision; -exports.MAX_SAFE_INTEGER = MAX_SAFE_INTEGER; -exports.remRadian = remRadian; -exports.isRadianAroundZero = isRadianAroundZero; -exports.parseDate = parseDate; -exports.quantity = quantity; -exports.nice = nice; -exports.reformIntervals = reformIntervals; -exports.isNumeric = isNumeric; +/* harmony default export */ __webpack_exports__["a"] = (geo3DCreator); /***/ }), -/* 79 */ +/* 99 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_util__ = __webpack_require__(20); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_coord_geo_fix_textCoord__ = __webpack_require__(205); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_coord_geo_fix_textCoord___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_coord_geo_fix_textCoord__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_coord_geo_fix_geoCoord__ = __webpack_require__(206); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_coord_geo_fix_geoCoord___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_coord_geo_fix_geoCoord__); +var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].vec3; +var mat4 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].mat4; -var TexturePool = function () { - this._pool = {}; +// Geo fix functions +var geoFixFuncs = [__WEBPACK_IMPORTED_MODULE_2_echarts_lib_coord_geo_fix_textCoord___default.a, __WEBPACK_IMPORTED_MODULE_3_echarts_lib_coord_geo_fix_geoCoord___default.a]; - this._allocatedTextures = []; -}; +function Geo3D(name, map, geoJson, specialAreas, nameMap) { -TexturePool.prototype = { + this.name = name; - constructor: TexturePool, + this.map = map; - get: function (parameters) { - var key = generateKey(parameters); - if (!this._pool.hasOwnProperty(key)) { - this._pool[key] = []; - } - var list = this._pool[key]; - if (!list.length) { - var texture = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */](parameters); - this._allocatedTextures.push(texture); - return texture; - } - return list.pop(); - }, + this.regionHeight = 0; - put: function (texture) { - var key = generateKey(texture); - if (!this._pool.hasOwnProperty(key)) { - this._pool[key] = []; - } - var list = this._pool[key]; - list.push(texture); - }, + this.regions = []; - clear: function (renderer) { - for (var i = 0; i < this._allocatedTextures.length; i++) { - this._allocatedTextures[i].dispose(renderer); - } - this._pool = {}; - this._allocatedTextures = []; - } -}; + this._nameCoordMap = {}; -var defaultParams = { - width: 512, - height: 512, - type: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_BYTE, - format: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].RGBA, - wrapS: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE, - wrapT: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE, - minFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR, - magFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR, - useMipmap: true, - anisotropic: 1, - flipY: true, - unpackAlignment: 4, - premultiplyAlpha: false -}; + this.loadGeoJson(geoJson, specialAreas, nameMap); -var defaultParamPropList = Object.keys(defaultParams); + this.transform = mat4.identity(new Float64Array(16)); -function generateKey(parameters) { - __WEBPACK_IMPORTED_MODULE_2__core_util__["a" /* default */].defaultsWithPropList(parameters, defaultParams, defaultParamPropList); - fallBack(parameters); + this.invTransform = mat4.identity(new Float64Array(16)); - var key = ''; - for (var i = 0; i < defaultParamPropList.length; i++) { - var name = defaultParamPropList[i]; - var chunk = parameters[name].toString(); - key += chunk; - } - return key; + // Which dimension to extrude. Y or Z + this.extrudeY = true; + + this.altitudeAxis; } -function fallBack(target) { +Geo3D.prototype = { - var IPOT = isPowerOfTwo(target.width, target.height); + constructor: Geo3D, - if (target.format === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DEPTH_COMPONENT) { - target.useMipmap = false; - } + type: 'geo3D', - if (!IPOT || !target.useMipmap) { - if (target.minFilter == __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_NEAREST || - target.minFilter == __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_LINEAR) { - target.minFilter = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST; - } else if ( - target.minFilter == __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR || - target.minFilter == __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_NEAREST - ) { - target.minFilter = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR; + dimensions: ['lng', 'lat', 'alt'], + + containPoint: function () {}, + + loadGeoJson: function (geoJson, specialAreas, nameMap) { + var parseGeoJSON = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.parseGeoJSON || __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.parseGeoJson; + try { + this.regions = geoJson ? parseGeoJSON(geoJson) : []; } - } - if (!IPOT) { - target.wrapS = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE; - target.wrapT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE; - } -} + catch (e) { + throw 'Invalid geoJson format\n' + e; + } + specialAreas = specialAreas || {}; + nameMap = nameMap || {}; + var regions = this.regions; + var regionsMap = {}; + for (var i = 0; i < regions.length; i++) { + var regionName = regions[i].name; + // Try use the alias in nameMap + regionName = nameMap[regionName] || regionName; + regions[i].name = regionName; -function isPowerOfTwo(width, height) { - return (width & (width-1)) === 0 && - (height & (height-1)) === 0; -} + regionsMap[regionName] = regions[i]; + // Add geoJson + this.addGeoCoord(regionName, regions[i].center); -/* harmony default export */ __webpack_exports__["a"] = (TexturePool); + // Some area like Alaska in USA map needs to be tansformed + // to look better + var specialArea = specialAreas[regionName]; + if (specialArea) { + regions[i].transformTo( + specialArea.left, specialArea.top, specialArea.width, specialArea.height + ); + } + } + this._regionsMap = regionsMap; -/***/ }), -/* 80 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + this._geoRect = null; -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.kernel.gaussian_9\nfloat gaussianKernel[9];\ngaussianKernel[0] = 0.07;\ngaussianKernel[1] = 0.09;\ngaussianKernel[2] = 0.12;\ngaussianKernel[3] = 0.14;\ngaussianKernel[4] = 0.16;\ngaussianKernel[5] = 0.14;\ngaussianKernel[6] = 0.12;\ngaussianKernel[7] = 0.09;\ngaussianKernel[8] = 0.07;\n@end\n@export clay.compositor.kernel.gaussian_13\nfloat gaussianKernel[13];\ngaussianKernel[0] = 0.02;\ngaussianKernel[1] = 0.03;\ngaussianKernel[2] = 0.06;\ngaussianKernel[3] = 0.08;\ngaussianKernel[4] = 0.11;\ngaussianKernel[5] = 0.13;\ngaussianKernel[6] = 0.14;\ngaussianKernel[7] = 0.13;\ngaussianKernel[8] = 0.11;\ngaussianKernel[9] = 0.08;\ngaussianKernel[10] = 0.06;\ngaussianKernel[11] = 0.03;\ngaussianKernel[12] = 0.02;\n@end\n@export clay.compositor.gaussian_blur\n#define SHADER_NAME gaussian_blur\nuniform sampler2D texture;varying vec2 v_Texcoord;\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main (void)\n{\n @import clay.compositor.kernel.gaussian_9\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n for (int i = 0; i < 9; i++) {\n float w = gaussianKernel[i];\n vec4 texel = decodeHDR(clampSample(texture, v_Texcoord + float(i - 4) * off));\n sum += texel * w;\n weightAll += w;\n }\n gl_FragColor = encodeHDR(sum / max(weightAll, 0.01));\n}\n@end\n"); + geoFixFuncs.forEach(function (fixFunc) { + fixFunc(this); + }, this); + }, + getGeoBoundingRect: function () { + if (this._geoRect) { + return this._geoRect; + } + var rect; -/***/ }), -/* 81 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + var regions = this.regions; + for (var i = 0; i < regions.length; i++) { + var regionRect = regions[i].getBoundingRect(); + rect = rect || regionRect.clone(); + rect.union(regionRect); + } + // FIXME Always return new ? + return (this._geoRect = rect || new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.BoundingRect(0, 0, 0, 0)); + }, -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("\n@export clay.compositor.lut\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform sampler2D lookup;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n float blueColor = tex.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec4 newColor1 = texture2D(lookup, texPos1);\n vec4 newColor2 = texture2D(lookup, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n gl_FragColor = vec4(newColor.rgb, tex.w);\n}\n@end"); + /** + * Add geoCoord for indexing by name + * @param {string} name + * @param {Array.} geoCoord + */ + addGeoCoord: function (name, geoCoord) { + this._nameCoordMap[name] = geoCoord; + }, + /** + * @param {string} name + * @return {module:echarts/coord/geo/Region} + */ + getRegion: function (name) { + return this._regionsMap[name]; + }, -/***/ }), -/* 82 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + getRegionByCoord: function (coord) { + var regions = this.regions; + for (var i = 0; i < regions.length; i++) { + if (regions[i].contain(coord)) { + return regions[i]; + } + } + }, -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = tex.rgb;\n#ifdef OUTPUT_ALPHA\n gl_FragColor.a = tex.a;\n#else\n gl_FragColor.a = 1.0;\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end"); + setSize: function (width, height, depth) { + this.size = [width, height, depth]; + var rect = this.getGeoBoundingRect(); -/***/ }), -/* 83 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + var scaleX = width / rect.width; + var scaleZ = -depth / rect.height; + var translateX = -width / 2 - rect.x * scaleX; + var translateZ = depth / 2 - rect.y * scaleZ; -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.bright\nuniform sampler2D texture;\nuniform float threshold : 1;\nuniform float scale : 1.0;\nuniform vec2 textureSize: [512, 512];\nvarying vec2 v_Texcoord;\nconst vec3 lumWeight = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvec4 median(vec4 a, vec4 b, vec4 c)\n{\n return a + b + c - min(min(a, b), c) - max(max(a, b), c);\n}\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n#ifdef ANTI_FLICKER\n vec3 d = 1.0 / textureSize.xyx * vec3(1.0, 1.0, 0.0);\n vec4 s1 = decodeHDR(texture2D(texture, v_Texcoord - d.xz));\n vec4 s2 = decodeHDR(texture2D(texture, v_Texcoord + d.xz));\n vec4 s3 = decodeHDR(texture2D(texture, v_Texcoord - d.zy));\n vec4 s4 = decodeHDR(texture2D(texture, v_Texcoord + d.zy));\n texel = median(median(texel, s1, s2), s3, s4);\n#endif\n float lum = dot(texel.rgb , lumWeight);\n vec4 color;\n if (lum > threshold && texel.a > 0.0)\n {\n color = vec4(texel.rgb * scale, texel.a * scale);\n }\n else\n {\n color = vec4(0.0);\n }\n gl_FragColor = encodeHDR(color);\n}\n@end\n"); + var position = this.extrudeY ? [translateX, 0, translateZ] : [translateX, translateZ, 0]; + var scale = this.extrudeY ? [scaleX, 1, scaleZ] : [scaleX, scaleZ, 1]; + var m = this.transform; + mat4.identity(m); + mat4.translate(m, m, position); + mat4.scale(m, m, scale); -/***/ }), -/* 84 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + mat4.invert(this.invTransform, m); + }, -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import clay.util.clamp_sample\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n#ifdef ANTI_FLICKER\n vec3 s1 = decodeHDR(clampSample(texture, v_Texcoord + d.xy)).rgb;\n vec3 s2 = decodeHDR(clampSample(texture, v_Texcoord + d.zy)).rgb;\n vec3 s3 = decodeHDR(clampSample(texture, v_Texcoord + d.xw)).rgb;\n vec3 s4 = decodeHDR(clampSample(texture, v_Texcoord + d.zw)).rgb;\n float s1w = 1.0 / (brightness(s1) + 1.0);\n float s2w = 1.0 / (brightness(s2) + 1.0);\n float s3w = 1.0 / (brightness(s3) + 1.0);\n float s4w = 1.0 / (brightness(s4) + 1.0);\n float oneDivideSum = 1.0 / (s1w + s2w + s3w + s4w);\n vec4 color = vec4(\n (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * oneDivideSum,\n 1.0\n );\n#else\n vec4 color = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n color *= 0.25;\n#endif\n gl_FragColor = encodeHDR(color);\n}\n@end"); + dataToPoint: function (data, out) { + out = out || []; + var extrudeCoordIndex = this.extrudeY ? 1 : 2; + var sideCoordIndex = this.extrudeY ? 2 : 1; -/***/ }), -/* 85 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + var altitudeVal = data[2]; + // PENDING. + if (isNaN(altitudeVal)) { + altitudeVal = 0; + } + // lng + out[0] = data[0]; + // lat + out[sideCoordIndex] = data[1]; -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("\n@export clay.compositor.upsample\n#define HIGH_QUALITY\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord - d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord - d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord - d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord )) * 4.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n gl_FragColor = encodeHDR(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n gl_FragColor = encodeHDR(s / 4.0);\n#endif\n}\n@end"); + if (this.altitudeAxis) { + out[extrudeCoordIndex] = this.altitudeAxis.dataToCoord(altitudeVal); + } + else { + out[extrudeCoordIndex] = 0; + } + // PENDING different region height. + out[extrudeCoordIndex] += this.regionHeight; + vec3.transformMat4(out, out, this.transform); -/***/ }), -/* 86 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + return out; + }, -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.hdr.composite\nuniform sampler2D texture;\n#ifdef BLOOM_ENABLED\nuniform sampler2D bloom;\n#endif\n#ifdef LENSFLARE_ENABLED\nuniform sampler2D lensflare;\nuniform sampler2D lensdirt;\n#endif\n#ifdef LUM_ENABLED\nuniform sampler2D lum;\n#endif\n#ifdef LUT_ENABLED\nuniform sampler2D lut;\n#endif\n#ifdef COLOR_CORRECTION\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float saturation : 1.0;\n#endif\n#ifdef VIGNETTE\nuniform float vignetteDarkness: 1.0;\nuniform float vignetteOffset: 1.0;\n#endif\nuniform float exposure : 1.0;\nuniform float bloomIntensity : 0.25;\nuniform float lensflareIntensity : 1;\nvarying vec2 v_Texcoord;\n@import clay.util.srgb\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nfloat eyeAdaption(float fLum)\n{\n return mix(0.2, fLum, 0.5);\n}\n#ifdef LUT_ENABLED\nvec3 lutTransform(vec3 color) {\n float blueColor = color.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec4 newColor1 = texture2D(lut, texPos1);\n vec4 newColor2 = texture2D(lut, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n return newColor.rgb;\n}\n#endif\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = vec4(0.0);\n vec4 originalTexel = vec4(0.0);\n#ifdef TEXTURE_ENABLED\n texel = decodeHDR(texture2D(texture, v_Texcoord));\n originalTexel = texel;\n#endif\n#ifdef BLOOM_ENABLED\n vec4 bloomTexel = decodeHDR(texture2D(bloom, v_Texcoord));\n texel.rgb += bloomTexel.rgb * bloomIntensity;\n texel.a += bloomTexel.a * bloomIntensity;\n#endif\n#ifdef LENSFLARE_ENABLED\n texel += decodeHDR(texture2D(lensflare, v_Texcoord)) * texture2D(lensdirt, v_Texcoord) * lensflareIntensity;\n#endif\n texel.a = min(texel.a, 1.0);\n#ifdef LUM_ENABLED\n float fLum = texture2D(lum, vec2(0.5, 0.5)).r;\n float adaptedLumDest = 3.0 / (max(0.1, 1.0 + 10.0*eyeAdaption(fLum)));\n float exposureBias = adaptedLumDest * exposure;\n#else\n float exposureBias = exposure;\n#endif\n texel.rgb *= exposureBias;\n texel.rgb = ACESToneMapping(texel.rgb);\n texel = linearTosRGB(texel);\n#ifdef LUT_ENABLED\n texel.rgb = lutTransform(clamp(texel.rgb,vec3(0.0),vec3(1.0)));\n#endif\n#ifdef COLOR_CORRECTION\n texel.rgb = clamp(texel.rgb + vec3(brightness), 0.0, 1.0);\n texel.rgb = clamp((texel.rgb - vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n float lum = dot(texel.rgb, vec3(0.2125, 0.7154, 0.0721));\n texel.rgb = mix(vec3(lum), texel.rgb, saturation);\n#endif\n#ifdef VIGNETTE\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(vignetteOffset);\n texel.rgb = mix(texel.rgb, vec3(1.0 - vignetteDarkness), dot(uv, uv));\n#endif\n gl_FragColor = encodeHDR(texel);\n#ifdef DEBUG\n #if DEBUG == 1\n gl_FragColor = encodeHDR(decodeHDR(texture2D(texture, v_Texcoord)));\n #elif DEBUG == 2\n gl_FragColor = encodeHDR(decodeHDR(texture2D(bloom, v_Texcoord)) * bloomIntensity);\n #elif DEBUG == 3\n gl_FragColor = encodeHDR(decodeHDR(texture2D(lensflare, v_Texcoord) * lensflareIntensity));\n #endif\n#endif\n if (originalTexel.a <= 0.01 && gl_FragColor.a > 1e-5) {\n gl_FragColor.a = dot(gl_FragColor.rgb, vec3(0.2125, 0.7154, 0.0721));\n }\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end"); + pointToData: function (point, out) { + // TODO + } +}; +/* harmony default export */ __webpack_exports__["a"] = (Geo3D); /***/ }), -/* 87 */ +/* 100 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.blend\n#define SHADER_NAME blend\n#ifdef TEXTURE1_ENABLED\nuniform sampler2D texture1;\nuniform float weight1 : 1.0;\n#endif\n#ifdef TEXTURE2_ENABLED\nuniform sampler2D texture2;\nuniform float weight2 : 1.0;\n#endif\n#ifdef TEXTURE3_ENABLED\nuniform sampler2D texture3;\nuniform float weight3 : 1.0;\n#endif\n#ifdef TEXTURE4_ENABLED\nuniform sampler2D texture4;\nuniform float weight4 : 1.0;\n#endif\n#ifdef TEXTURE5_ENABLED\nuniform sampler2D texture5;\nuniform float weight5 : 1.0;\n#endif\n#ifdef TEXTURE6_ENABLED\nuniform sampler2D texture6;\nuniform float weight6 : 1.0;\n#endif\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = vec4(0.0);\n#ifdef TEXTURE1_ENABLED\n tex += decodeHDR(texture2D(texture1, v_Texcoord)) * weight1;\n#endif\n#ifdef TEXTURE2_ENABLED\n tex += decodeHDR(texture2D(texture2, v_Texcoord)) * weight2;\n#endif\n#ifdef TEXTURE3_ENABLED\n tex += decodeHDR(texture2D(texture3, v_Texcoord)) * weight3;\n#endif\n#ifdef TEXTURE4_ENABLED\n tex += decodeHDR(texture2D(texture4, v_Texcoord)) * weight4;\n#endif\n#ifdef TEXTURE5_ENABLED\n tex += decodeHDR(texture2D(texture5, v_Texcoord)) * weight5;\n#endif\n#ifdef TEXTURE6_ENABLED\n tex += decodeHDR(texture2D(texture6, v_Texcoord)) * weight6;\n#endif\n gl_FragColor = encodeHDR(tex);\n}\n@end"); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix__ = __webpack_require__(6); +var mat4 = __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix__["a" /* default */].mat4; -/***/ }), -/* 88 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +var TILE_SIZE = 512; +var FOV = 0.6435011087932844; +var PI = Math.PI; -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.fxaa\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nvarying vec2 v_Texcoord;\n#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\n@import clay.util.rgbm\nvoid main()\n{\n vec2 resolution = 1.0 / viewport.zw;\n vec3 rgbNW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbNE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ) ).xyz;\n vec4 rgbaM = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution ) );\n vec3 rgbM = rgbaM.xyz;\n float opacity = rgbaM.w;\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float lumaNW = dot( rgbNW, luma );\n float lumaNE = dot( rgbNE, luma );\n float lumaSW = dot( rgbSW, luma );\n float lumaSE = dot( rgbSE, luma );\n float lumaM = dot( rgbM, luma );\n float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );\n float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * resolution;\n vec3 rgbA = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA *= 0.5;\n vec3 rgbB = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * -0.5 ) ).xyz;\n rgbB += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * 0.5 ) ).xyz;\n rgbB *= 0.25;\n rgbB += rgbA * 0.5;\n float lumaB = dot( rgbB, luma );\n if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )\n {\n gl_FragColor = vec4( rgbA, opacity );\n }\n else {\n gl_FragColor = vec4( rgbB, opacity );\n }\n}\n@end"); +var WORLD_SCALE = 1 / 10; +function MapServiceCoordSys3D() { + /** + * Width of mapbox viewport + */ + this.width = 0; + /** + * Height of mapbox viewport + */ + this.height = 0; -/***/ }), -/* 89 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + this.altitudeScale = 1; -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); + // TODO Change boxHeight won't have animation. + this.boxHeight = 'auto'; + // Set by mapbox creator + this.altitudeExtent; -/* harmony default export */ __webpack_exports__["a"] = ({ + this.bearing = 0; + this.pitch = 0; + this.center = [0, 0]; - getFilledRegions: function (regions, mapData) { - var regionsArr = (regions || []).slice(); + this._origin; - var geoJson; - if (typeof mapData === 'string') { - mapData = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.getMap(mapData); - geoJson = mapData && mapData.geoJson; - } - else { - if (mapData && mapData.features) { - geoJson = mapData; - } - } - if (!geoJson) { - if (true) { - console.error('Map ' + mapData + ' not exists. You can download map file on http://echarts.baidu.com/download-map.html'); - if (!geoJson.features) { - console.error('Invalid GeoJSON for map3D'); - } - } - return []; - } + this.zoom = 0; + this._initialZoom; - var dataNameMap = {}; - var features = geoJson.features; - for (var i = 0; i < regionsArr.length; i++) { - dataNameMap[regionsArr[i].name] = regionsArr[i]; - } + // Some parameters for different map services. + this.maxPitch = 60; + this.zoomOffset = 0; +} - for (var i = 0; i < features.length; i++) { - var name = features[i].properties.name; - if (!dataNameMap[name]) { - regionsArr.push({ - name: name - }); - } - } +MapServiceCoordSys3D.prototype = { - return regionsArr; - }, + constructor: MapServiceCoordSys3D, - defaultOption: { - show: true, + dimensions: ['lng', 'lat', 'alt'], - zlevel: -10, + containPoint: function () {}, - // geoJson used by geo3D - map: '', + setCameraOption: function (option) { + this.bearing = option.bearing; + this.pitch = option.pitch; - // Layout used for viewport - left: 0, - top: 0, - width: '100%', - height: '100%', + this.center = option.center; + this.zoom = option.zoom; - boxWidth: 100, - boxHeight: 10, - boxDepth: 'auto', + if (!this._origin) { + this._origin = this.projectOnTileWithScale(this.center, TILE_SIZE); + } + if (this._initialZoom == null) { + this._initialZoom = this.zoom; + } - regionHeight: 3, + this.updateTransform(); + }, - environment: 'auto', + // https://github.com/mapbox/mapbox-gl-js/blob/master/src/geo/transform.js#L479 + updateTransform: function () { + if (!this.height) { return; } - groundPlane: { - show: false, - color: '#aaa' - }, + var cameraToCenterDistance = 0.5 / Math.tan(FOV / 2) * this.height * WORLD_SCALE; + // Convert to radian. + var pitch = Math.max(Math.min(this.pitch, this.maxPitch), 0) / 180 * Math.PI; - shading: 'lambert', + // Find the distance from the center point [width/2, height/2] to the + // center top point [width/2, 0] in Z units, using the law of sines. + // 1 Z unit is equivalent to 1 horizontal px at the center of the map + // (the distance between[width/2, height/2] and [width/2 + 1, height/2]) + var halfFov = FOV / 2; + var groundAngle = Math.PI / 2 + pitch; + var topHalfSurfaceDistance = Math.sin(halfFov) * cameraToCenterDistance / Math.sin(Math.PI - groundAngle - halfFov); - light: { - main: { - alpha: 40, - beta: 30 - } - }, + // Calculate z distance of the farthest fragment that should be rendered. + var furthestDistance = Math.cos(Math.PI / 2 - pitch) * topHalfSurfaceDistance + cameraToCenterDistance; + // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance` + var farZ = furthestDistance * 1.1; + // Forced to be 1000 + if (this.pitch > 50) { + farZ = 1000; + } - viewControl: { - alpha: 40, - beta: 0, - distance: 100, - orthographicSize: 60, + // matrix for conversion from location to GL coordinates (-1 .. 1) + var m = []; + mat4.perspective(m, FOV, this.width / this.height, 1, farZ); + this.viewGL.camera.projectionMatrix.setArray(m); + this.viewGL.camera.decomposeProjectionMatrix(); - minAlpha: 5, - minBeta: -80, - maxBeta: 80 - }, + var m = mat4.identity([]); + var pt = this.dataToPoint(this.center); + // Inverse + mat4.scale(m, m, [1, -1, 1]); + // Translate to altitude + mat4.translate(m, m, [0, 0, -cameraToCenterDistance]); + mat4.rotateX(m, m, pitch); + mat4.rotateZ(m, m, -this.bearing / 180 * Math.PI); + // Translate to center. + mat4.translate(m, m, [-pt[0] * this.getScale() * WORLD_SCALE, -pt[1] * this.getScale() * WORLD_SCALE, 0]); - label: { - show: false, - // Distance in 3d space. - distance: 2, + this.viewGL.camera.viewMatrix.array = m; + var invertM = []; + mat4.invert(invertM, m); + this.viewGL.camera.worldTransform.array = invertM; + this.viewGL.camera.decomposeWorldTransform(); - textStyle: { - fontSize: 20, - color: '#000', - backgroundColor: 'rgba(255,255,255,0.7)', - padding: 3, - borderRadius: 4 - } - }, + // scale vertically to meters per pixel (inverse of ground resolution): + // worldSize / (circumferenceOfEarth * cos(lat * π / 180)) + var worldSize = TILE_SIZE * this.getScale(); + var verticalScale; - // TODO - // altitude: { - // min: 'auto', - // max: 'auto', + if (this.altitudeExtent && !isNaN(this.boxHeight)) { + var range = this.altitudeExtent[1] - this.altitudeExtent[0]; + verticalScale = this.boxHeight / range * this.getScale() / Math.pow(2, this._initialZoom - this.zoomOffset); + } + else { + verticalScale = worldSize / (2 * Math.PI * 6378000 * Math.abs(Math.cos(this.center[1] * (Math.PI / 180)))) + * this.altitudeScale * WORLD_SCALE; + } + // Include scale to avoid relayout when zooming + // FIXME Camera scale may have problem in shadow + this.viewGL.rootNode.scale.set( + this.getScale() * WORLD_SCALE, this.getScale() * WORLD_SCALE, verticalScale + ); + }, - // height: [] - // }, + getScale: function () { + return Math.pow(2, this.zoom - this.zoomOffset); + }, + projectOnTile: function (data, out) { + return this.projectOnTileWithScale(data, this.getScale() * TILE_SIZE, out); + }, - // labelLine + projectOnTileWithScale: function (data, scale, out) { + var lng = data[0]; + var lat = data[1]; + var lambda2 = lng * PI / 180; + var phi2 = lat * PI / 180; + var x = scale * (lambda2 + PI) / (2 * PI); + var y = scale * (PI - Math.log(Math.tan(PI / 4 + phi2 * 0.5))) / (2 * PI); + out = out || []; + out[0] = x; + out[1] = y; + return out; + }, - // light - // postEffect - // temporalSuperSampling + unprojectFromTile: function (point, out) { + return this.unprojectOnTileWithScale(point, this.getScale() * TILE_SIZE, out); + }, - itemStyle: { - color: '#fff', - borderWidth: 0, - borderColor: '#333' - }, + unprojectOnTileWithScale: function (point, scale, out) { + var x = point[0]; + var y = point[1]; + var lambda2 = (x / scale) * (2 * PI) - PI; + var phi2 = 2 * (Math.atan(Math.exp(PI - (y / scale) * (2 * PI))) - PI / 4); + out = out || []; + out[0] = lambda2 * 180 / PI; + out[1] = phi2 * 180 / PI; + return out; + }, - emphasis: { - itemStyle: { - // color: '#f94b59' - color: '#639fc0' - }, - label: { - show: true + dataToPoint: function (data, out) { + out = this.projectOnTileWithScale(data, TILE_SIZE, out); + // Add a origin to avoid precision issue in WebGL. + out[0] -= this._origin[0]; + out[1] -= this._origin[1]; + // PENDING + out[2] = !isNaN(data[2]) ? data[2] : 0; + if (!isNaN(data[2])) { + out[2] = data[2]; + if (this.altitudeExtent) { + out[2] -= this.altitudeExtent[0]; } } + return out; } -}); +}; + +/* harmony default export */ __webpack_exports__["a"] = (MapServiceCoordSys3D); /***/ }), -/* 90 */ +/* 101 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_retrieve__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__ = __webpack_require__(22); -function swap(arr, a, b) { - var tmp = arr[a]; - arr[a] = arr[b]; - arr[b] = tmp; -} -function partition(arr, pivot, left, right, compare) { - var storeIndex = left; - var pivotValue = arr[pivot]; - - // put the pivot on the right - swap(arr, pivot, right); - - // go through the rest - for(var v = left; v < right; v++) { - if(compare(arr[v], pivotValue) < 0) { - swap(arr, v, storeIndex); - storeIndex++; - } - } - - // finally put the pivot in the correct place - swap(arr, right, storeIndex); - - return storeIndex; -} - -function quickSort(array, compare, left, right) { - if(left < right) { - var pivot = Math.floor((left + right) / 2); - var newPivot = partition(array, pivot, left, right, compare); - quickSort(array, compare, left, newPivot - 1); - quickSort(array, compare, newPivot + 1, right); - } -} -// TODO Test. -function ProgressiveQuickSort() { - // this._pivotList = new LinkedList(); - this._parts = []; -} +/* harmony default export */ __webpack_exports__["a"] = (function (serviceComponentType, ServiceCtor, afterCreate) { -ProgressiveQuickSort.prototype.step = function (arr, compare, frame) { + function resizeMapService3D(mapService3DModel, api) { + var width = api.getWidth(); + var height = api.getHeight(); + var dpr = api.getDevicePixelRatio(); + this.viewGL.setViewport(0, 0, width, height, dpr); - var len = arr.length; - if (frame === 0) { - this._parts = []; - this._sorted = false; + this.width = width; + this.height = height; - // Pick a start pivot; - var pivot = Math.floor(len / 2); - this._parts.push({ - pivot: pivot, - left: 0, - right: len - 1 - }); + this.altitudeScale = mapService3DModel.get('altitudeScale'); - this._currentSortPartIdx = 0; + this.boxHeight = mapService3DModel.get('boxHeight'); + // this.updateTransform(); } - if (this._sorted) { - return; - } - var parts = this._parts; - if (parts.length === 0) { - this._sorted = true; - // Already finished. - return true; - } - else if (parts.length < 512) { - // Sort large parts in about 10 frames. - for (var i = 0; i < parts.length; i++) { - // Partition and Modify the pivot index. - parts[i].pivot = partition( - arr, parts[i].pivot, parts[i].left, parts[i].right, compare - ); + function updateService3D(ecModel, api) { + + if (this.model.get('boxHeight') === 'auto') { + return; } - var subdividedParts = []; - for (var i = 0; i < parts.length; i++) { - // Subdivide left - var left = parts[i].left; - var right = parts[i].pivot - 1; - if (right > left) { - subdividedParts.push({ - pivot: Math.floor((right + left) / 2), - left: left, right: right - }); - } - // Subdivide right - var left = parts[i].pivot + 1; - var right = parts[i].right; - if (right > left) { - subdividedParts.push({ - pivot: Math.floor((right + left) / 2), - left: left, right: right - }); + var altitudeDataExtent = [Infinity, -Infinity] + + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.coordinateSystem !== this) { + return; } - } - parts = this._parts = subdividedParts; - } - else { - // console.time('sort'); - // Finally quick sort each parts in 10 frames. - for (var i = 0; i < Math.floor(parts.length / 10); i++) { - // Sort near parts first. - var idx = parts.length - 1 - this._currentSortPartIdx; - quickSort(arr, compare, parts[idx].left, parts[idx].right); - this._currentSortPartIdx++; - // Finish sort - if (this._currentSortPartIdx === parts.length) { - this._sorted = true; - return true; + // Get altitude data extent. + var data = seriesModel.getData(); + var altDim = seriesModel.coordDimToDataDim('alt')[0]; + if (altDim) { + // TODO altitiude is in coords of lines. + var dataExtent = data.getDataExtent(altDim, true); + altitudeDataExtent[0] = Math.min( + altitudeDataExtent[0], dataExtent[0] + ); + altitudeDataExtent[1] = Math.max( + altitudeDataExtent[1], dataExtent[1] + ); } + }, this); + if (altitudeDataExtent && isFinite(altitudeDataExtent[1] - altitudeDataExtent[0])) { + this.altitudeExtent = altitudeDataExtent; } - // console.timeEnd('sort'); - } - return false; -}; - -ProgressiveQuickSort.sort = quickSort; - -/* harmony default export */ __webpack_exports__["a"] = (ProgressiveQuickSort); - -/***/ }), -/* 91 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geo3D_Geo3D__ = __webpack_require__(92); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout__ = __webpack_require__(41); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_retrieve__ = __webpack_require__(3); - - - - + return { -function resizeGeo3D(geo3DModel, api) { - // Use left/top/width/height - var boxLayoutOption = geo3DModel.getBoxLayoutParams(); + dimensions: ServiceCtor.prototype.dimensions, - var viewport = __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout___default.a.getLayoutRect(boxLayoutOption, { - width: api.getWidth(), - height: api.getHeight() - }); + create: function (ecModel, api) { + var mapService3DList = []; - // Flip Y - viewport.y = api.getHeight() - viewport.y - viewport.height; + ecModel.eachComponent(serviceComponentType, function (mapService3DModel) { + var viewGL = mapService3DModel.__viewGL; + if (!viewGL) { + viewGL = mapService3DModel.__viewGL = new __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__["a" /* default */](); + viewGL.setRootNode(new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node()); + } - this.viewGL.setViewport(viewport.x, viewport.y, viewport.width, viewport.height, api.getDevicePixelRatio()); + var mapService3DCoordSys = new ServiceCtor(); + mapService3DCoordSys.viewGL = mapService3DModel.__viewGL; + // Inject resize + mapService3DCoordSys.resize = resizeMapService3D; + mapService3DCoordSys.resize(mapService3DModel, api); - var geoRect = this.getGeoBoundingRect(); - var aspect = geoRect.width / geoRect.height * (geo3DModel.get('aspectScale') || 0.75); + mapService3DList.push(mapService3DCoordSys); - var width = geo3DModel.get('boxWidth'); - var depth = geo3DModel.get('boxDepth'); - var height = geo3DModel.get('boxHeight'); - if (height == null) { - height = 5; - } - if (isNaN(width) && isNaN(depth)) { - // Default to have 100 width - width = 100; - } - if (isNaN(depth)) { - depth = width / aspect; - } - else if (isNaN(width)) { - width = depth / aspect; - } + mapService3DModel.coordinateSystem = mapService3DCoordSys; + mapService3DCoordSys.model = mapService3DModel; - this.setSize(width, height, depth); + mapService3DCoordSys.update = updateService3D; + }); - this.regionHeight = geo3DModel.get('regionHeight'); + ecModel.eachSeries(function (seriesModel) { + if (seriesModel.get('coordinateSystem') === serviceComponentType) { + var mapService3DModel = seriesModel.getReferringComponents(serviceComponentType)[0]; + if (!mapService3DModel) { + mapService3DModel = ecModel.getComponent(serviceComponentType); + } - if (this.altitudeAxis) { - this.altitudeAxis.setExtent(0, Math.max(height - this.regionHeight, 0)); - } -} + if (!mapService3DModel) { + throw new Error(serviceComponentType + ' "' + __WEBPACK_IMPORTED_MODULE_0__util_retrieve__["a" /* default */].firstNotNull( + seriesModel.get(serviceComponentType + 'Index'), + seriesModel.get(serviceComponentType + 'Id'), + 0 + ) + '" not found'); + } -function updateGeo3D(ecModel, api) { + seriesModel.coordinateSystem = mapService3DModel.coordinateSystem; + } + }); - var altitudeDataExtent = [Infinity, -Infinity]; + afterCreate && afterCreate(mapService3DList, ecModel, api); - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.coordinateSystem !== this) { - return; - } - if (seriesModel.type === 'series.map3D') { - return; - } - // Get altitude data extent. - var data = seriesModel.getData(); - var altDims = seriesModel.coordDimToDataDim('alt'); - var altDim = altDims && altDims[0]; - if (altDim) { - // TODO altitiude is in coords of lines. - var dataExtent = data.getDataExtent(altDim, true); - altitudeDataExtent[0] = Math.min( - altitudeDataExtent[0], dataExtent[0] - ); - altitudeDataExtent[1] = Math.max( - altitudeDataExtent[1], dataExtent[1] - ); + return mapService3DList; } - }, this); - // Create altitude axis - if (altitudeDataExtent && isFinite(altitudeDataExtent[1] - altitudeDataExtent[0])) { - var scale = __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.helper.createScale( - altitudeDataExtent, { - type: 'value', - // PENDING - min: 'dataMin', - max: 'dataMax' - } - ); - this.altitudeAxis = new __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.Axis('altitude', scale); - // Resize again - this.resize(this.model, api); - } -} - - -if (true) { - var mapNotExistsError = function (name) { - console.error('Map ' + name + ' not exists. You can download map file on http://echarts.baidu.com/download-map.html'); }; -} +}); -var idStart = 0; +/***/ }), +/* 102 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -var geo3DCreator = { +"use strict"; +/* harmony default export */ __webpack_exports__["a"] = ("\n@export ecgl.displayShadow.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_WorldPosition;\n\nvarying vec3 v_Normal;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n\n@export ecgl.displayShadow.fragment\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform float roughness: 0.2;\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.ssaoMap.header\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n float shadow = 1.0;\n\n @import ecgl.common.ssaoMap.main\n\n#if defined(DIRECTIONAL_LIGHT_COUNT) && defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n for (int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++) {\n shadow = min(shadow, shadowContribsDir[i] * 0.5 + 0.5);\n }\n#endif\n\n shadow *= 0.5 + ao * 0.5;\n shadow = clamp(shadow, 0.0, 1.0);\n\n gl_FragColor = vec4(vec3(0.0), 1.0 - shadow);\n}\n\n@end"); - dimensions: __WEBPACK_IMPORTED_MODULE_0__geo3D_Geo3D__["a" /* default */].prototype.dimensions, - create: function (ecModel, api) { +/***/ }), +/* 103 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - var geo3DList = []; +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix__ = __webpack_require__(84); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector__ = __webpack_require__(83); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector__); - if (!__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.getMap) { - throw new Error('geo3D component depends on geo component'); - } - function createGeo3D(componentModel, idx) { - var geo3D = geo3DCreator.createGeo3D(componentModel); - // FIXME - componentModel.__viewGL = componentModel.__viewGL || new __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__["a" /* default */](); +function GLViewHelper(viewGL) { + this.viewGL = viewGL; +} - geo3D.viewGL = componentModel.__viewGL; +GLViewHelper.prototype.reset = function (seriesModel, api) { + this._updateCamera(api.getWidth(), api.getHeight(), api.getDevicePixelRatio()); + this._viewTransform = __WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix___default.a.create(); + this.updateTransform(seriesModel, api); +}; - componentModel.coordinateSystem = geo3D; - geo3D.model = componentModel; +GLViewHelper.prototype.updateTransform = function (seriesModel, api) { + var coordinateSystem = seriesModel.coordinateSystem; - geo3DList.push(geo3D); + if (coordinateSystem.getRoamTransform) { - // Inject resize - geo3D.resize = resizeGeo3D; - geo3D.resize(componentModel, api); + __WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix___default.a.invert(this._viewTransform, coordinateSystem.getRoamTransform()); - geo3D.update = updateGeo3D; - } + this._setCameraTransform(this._viewTransform); - ecModel.eachComponent('geo3D', function (geo3DModel, idx) { - createGeo3D(geo3DModel, idx); - }); + api.getZr().refresh(); + } +}; - ecModel.eachSeriesByType('map3D', function (map3DModel, idx) { - var coordSys = map3DModel.get('coordinateSystem'); - if (coordSys == null) { - coordSys = 'geo3D'; - } - if (coordSys === 'geo3D') { - createGeo3D(map3DModel, idx); - } - }); +// Reimplement the dataToPoint of coordinate system. +// Remove the effect of pan/zoom transform +GLViewHelper.prototype.dataToPoint = function (coordSys, data, pt) { + pt = coordSys.dataToPoint(data, null, pt); + var viewTransform = this._viewTransform; + if (viewTransform) { + __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector___default.a.applyTransform(pt, pt, viewTransform); + } +}; - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.get('coordinateSystem') === 'geo3D') { - if (seriesModel.type === 'series.map3D') { - return; - } - var geo3DModel = seriesModel.getReferringComponents('geo3D')[0]; - if (!geo3DModel) { - geo3DModel = ecModel.getComponent('geo3D'); - } +/** + * Remove transform info in point. + */ +GLViewHelper.prototype.removeTransformInPoint = function (pt) { + if (this._viewTransform) { + __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector___default.a.applyTransform(pt, pt, this._viewTransform); + } + return pt; +}; - if (!geo3DModel) { - throw new Error('geo "' + __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull( - seriesModel.get('geo3DIndex'), - seriesModel.get('geo3DId'), - 0 - ) + '" not found'); - } +/** + * Return number + */ +GLViewHelper.prototype.getZoom = function () { + if (this._viewTransform) { + var m = this._viewTransform; + return 1 / Math.max( + Math.sqrt(m[0] * m[0] + m[1] * m[1]), + Math.sqrt(m[2] * m[2] + m[3] * m[3]) + ); + } + return 1; +}; - seriesModel.coordinateSystem = geo3DModel.coordinateSystem; - } - }); +GLViewHelper.prototype._setCameraTransform = function (m) { + var camera = this.viewGL.camera; + camera.position.set(m[4], m[5], 0); + camera.scale.set( + Math.sqrt(m[0] * m[0] + m[1] * m[1]), + Math.sqrt(m[2] * m[2] + m[3] * m[3]), + 1 + ); +}; - return geo3DList; - }, +GLViewHelper.prototype._updateCamera = function (width, height, dpr) { + // TODO, left, top, right, bottom + this.viewGL.setViewport(0, 0, width, height, dpr); + var camera = this.viewGL.camera; + camera.left = camera.top = 0; + camera.bottom = height; + camera.right = width; + camera.near = 0; + camera.far = 100; +}; - createGeo3D: function (componentModel) { +/* harmony default export */ __webpack_exports__["a"] = (GLViewHelper); - var mapData = componentModel.get('map'); - var name; - if (typeof mapData === 'string') { - name = mapData; - mapData = __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.getMap(mapData); - } - else { - if (mapData && mapData.features) { - mapData = { - geoJson: mapData - }; - } - } - if (true) { - if (!mapData) { - mapNotExistsError(mapData); - } - if (!mapData.geoJson.features) { - throw new Error('Invalid GeoJSON for map3D'); - } - } - if (name == null) { - name = 'GEO_ANONYMOUS_' + idStart++; - } +/***/ }), +/* 104 */ +/***/ (function(module, exports, __webpack_require__) { - return new __WEBPACK_IMPORTED_MODULE_0__geo3D_Geo3D__["a" /* default */]( - name + idStart++, name, - mapData && mapData.geoJson, mapData && mapData.specialAreas, - componentModel.get('nameMap') - ); - } -}; +/* WEBPACK VAR INJECTION */(function(global) {/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +// (1) The code `if (__DEV__) ...` can be removed by build tool. +// (2) If intend to use `__DEV__`, this module should be imported. Use a global +// variable `__DEV__` may cause that miss the declaration (see #6535), or the +// declaration is behind of the using position (for example in `Model.extent`, +// And tools like rollup can not analysis the dependency if not import). +var dev; // In browser -__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.registerCoordinateSystem('geo3D', geo3DCreator); +if (typeof window !== 'undefined') { + dev = window.__DEV__; +} // In node +else if (typeof global !== 'undefined') { + dev = global.__DEV__; + } -/* harmony default export */ __webpack_exports__["a"] = (geo3DCreator); +if (typeof dev === 'undefined') { + dev = true; +} + +var __DEV__ = dev; +exports.__DEV__ = __DEV__; +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(68))) /***/ }), -/* 92 */ +/* 105 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_coord_geo_fix_textCoord__ = __webpack_require__(197); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_coord_geo_fix_textCoord___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_coord_geo_fix_textCoord__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_coord_geo_fix_geoCoord__ = __webpack_require__(198); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_coord_geo_fix_geoCoord___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_coord_geo_fix_geoCoord__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__ = __webpack_require__(38); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(6); +/** + * Lines geometry + * Use screen space projected lines lineWidth > MAX_LINE_WIDTH + * https://mattdesl.svbtle.com/drawing-lines-is-hard + * @module echarts-gl/util/geometry/LinesGeometry + * @author Yi Shen(http://github.com/pissang) + */ -var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default.a.vec3; -var mat4 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default.a.mat4; -// Geo fix functions -var geoFixFuncs = [__WEBPACK_IMPORTED_MODULE_2_echarts_lib_coord_geo_fix_textCoord___default.a, __WEBPACK_IMPORTED_MODULE_3_echarts_lib_coord_geo_fix_geoCoord___default.a]; +var vec2 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__["a" /* default */].vec2; -function Geo3D(name, map, geoJson, specialAreas, nameMap) { +// var CURVE_RECURSION_LIMIT = 8; +// var CURVE_COLLINEAR_EPSILON = 40; - this.name = name; +var sampleLinePoints = [[0, 0], [1, 1]]; +/** + * @constructor + * @alias module:echarts-gl/util/geometry/LinesGeometry + * @extends clay.Geometry + */ - this.map = map; +var LinesGeometry = __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].extend(function () { + return { - this.regionHeight = 0; + segmentScale: 4, - this.regions = []; + dynamic: true, + /** + * Need to use mesh to expand lines if lineWidth > MAX_LINE_WIDTH + */ + useNativeLine: true, - this._nameCoordMap = {}; + attributes: { + position: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('position', 'float', 2, 'POSITION'), + normal: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('normal', 'float', 2), + offset: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('offset', 'float', 1), + color: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('color', 'float', 4, 'COLOR') + } + }; +}, +/** @lends module: echarts-gl/util/geometry/LinesGeometry.prototype */ +{ - this.loadGeoJson(geoJson, specialAreas, nameMap); + /** + * Reset offset + */ + resetOffset: function () { + this._vertexOffset = 0; + this._faceOffset = 0; - this.transform = mat4.identity(new Float64Array(16)); + this._itemVertexOffsets = []; + }, - this.invTransform = mat4.identity(new Float64Array(16)); + /** + * @param {number} nVertex + */ + setVertexCount: function (nVertex) { + var attributes = this.attributes; + if (this.vertexCount !== nVertex) { + attributes.position.init(nVertex); + attributes.color.init(nVertex); - // Which dimension to extrude. Y or Z - this.extrudeY = true; + if (!this.useNativeLine) { + attributes.offset.init(nVertex); + attributes.normal.init(nVertex); + } - this.altitudeAxis; -} + if (nVertex > 0xffff) { + if (this.indices instanceof Uint16Array) { + this.indices = new Uint32Array(this.indices); + } + } + else { + if (this.indices instanceof Uint32Array) { + this.indices = new Uint16Array(this.indices); + } + } + } + }, -Geo3D.prototype = { + /** + * @param {number} nTriangle + */ + setTriangleCount: function (nTriangle) { + if (this.triangleCount !== nTriangle) { + if (nTriangle === 0) { + this.indices = null; + } + else { + this.indices = this.vertexCount > 0xffff ? new Uint32Array(nTriangle * 3) : new Uint16Array(nTriangle * 3); + } + } + }, - constructor: Geo3D, + _getCubicCurveApproxStep: function (p0, p1, p2, p3) { + var len = vec2.dist(p0, p1) + vec2.dist(p2, p1) + vec2.dist(p3, p2); + var step = 1 / (len + 1) * this.segmentScale; + return step; + }, - type: 'geo3D', + /** + * Get vertex count of cubic curve + * @param {Array.} p0 + * @param {Array.} p1 + * @param {Array.} p2 + * @param {Array.} p3 + * @return number + */ + getCubicCurveVertexCount: function (p0, p1, p2, p3) { + var step = this._getCubicCurveApproxStep(p0, p1, p2, p3); + var segCount = Math.ceil(1 / step); + if (!this.useNativeLine) { + return segCount * 2 + 2; + } + else { + return segCount * 2; + } + }, - dimensions: ['lng', 'lat', 'alt'], + /** + * Get face count of cubic curve + * @param {Array.} p0 + * @param {Array.} p1 + * @param {Array.} p2 + * @param {Array.} p3 + * @return number + */ + getCubicCurveTriangleCount: function (p0, p1, p2, p3) { + var step = this._getCubicCurveApproxStep(p0, p1, p2, p3); + var segCount = Math.ceil(1 / step); + if (!this.useNativeLine) { + return segCount * 2; + } + else { + return 0; + } + }, - containPoint: function () {}, + /** + * Get vertex count of line + * @return {number} + */ + getLineVertexCount: function () { + return this.getPolylineVertexCount(sampleLinePoints); + }, - loadGeoJson: function (geoJson, specialAreas, nameMap) { - var parseGeoJSON = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.parseGeoJSON || __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.parseGeoJson; - try { - this.regions = geoJson ? parseGeoJSON(geoJson) : []; + /** + * Get face count of line + * @return {number} + */ + getLineTriangleCount: function () { + return this.getPolylineTriangleCount(sampleLinePoints); + }, + + /** + * Get how many vertices will polyline take. + * @type {number|Array} points Can be a 1d/2d list of points, or a number of points amount. + * @return {number} + */ + getPolylineVertexCount: function (points) { + var pointsLen; + if (typeof points === 'number') { + pointsLen = points; } - catch (e) { - throw 'Invalid geoJson format\n' + e; + else { + var is2DArray = typeof points[0] !== 'number'; + pointsLen = is2DArray ? points.length : (points.length / 2); } - specialAreas = specialAreas || {}; - nameMap = nameMap || {}; - var regions = this.regions; - var regionsMap = {}; - for (var i = 0; i < regions.length; i++) { - var regionName = regions[i].name; - // Try use the alias in nameMap - regionName = nameMap[regionName] || regionName; - regions[i].name = regionName; + return !this.useNativeLine ? ((pointsLen - 1) * 2 + 2) : (pointsLen - 1) * 2; + }, - regionsMap[regionName] = regions[i]; - // Add geoJson - this.addGeoCoord(regionName, regions[i].center); + /** + * Get how many triangles will polyline take. + * @type {number|Array} points Can be a 1d/2d list of points, or a number of points amount. + * @return {number} + */ + getPolylineTriangleCount: function (points) { + var pointsLen; + if (typeof points === 'number') { + pointsLen = points; + } + else { + var is2DArray = typeof points[0] !== 'number'; + pointsLen = is2DArray ? points.length : (points.length / 2); + } + return !this.useNativeLine ? (pointsLen - 1) * 2 : 0; + }, - // Some area like Alaska in USA map needs to be tansformed - // to look better - var specialArea = specialAreas[regionName]; - if (specialArea) { - regions[i].transformTo( - specialArea.left, specialArea.top, specialArea.width, specialArea.height - ); - } + /** + * Add a cubic curve + * @param {Array.} p0 + * @param {Array.} p1 + * @param {Array.} p2 + * @param {Array.} p3 + * @param {Array.} color + * @param {number} [lineWidth=1] + */ + addCubicCurve: function (p0, p1, p2, p3, color, lineWidth) { + if (lineWidth == null) { + lineWidth = 1; } + // incremental interpolation + // http://antigrain.com/research/bezier_interpolation/index.html#PAGE_BEZIER_INTERPOLATION + var x0 = p0[0], y0 = p0[1]; + var x1 = p1[0], y1 = p1[1]; + var x2 = p2[0], y2 = p2[1]; + var x3 = p3[0], y3 = p3[1]; - this._regionsMap = regionsMap; + var step = this._getCubicCurveApproxStep(p0, p1, p2, p3); - this._geoRect = null; + var step2 = step * step; + var step3 = step2 * step; - geoFixFuncs.forEach(function (fixFunc) { - fixFunc(this); - }, this); - }, + var pre1 = 3.0 * step; + var pre2 = 3.0 * step2; + var pre4 = 6.0 * step2; + var pre5 = 6.0 * step3; - getGeoBoundingRect: function () { - if (this._geoRect) { - return this._geoRect; - } - var rect; + var tmp1x = x0 - x1 * 2.0 + x2; + var tmp1y = y0 - y1 * 2.0 + y2; - var regions = this.regions; - for (var i = 0; i < regions.length; i++) { - var regionRect = regions[i].getBoundingRect(); - rect = rect || regionRect.clone(); - rect.union(regionRect); + var tmp2x = (x1 - x2) * 3.0 - x0 + x3; + var tmp2y = (y1 - y2) * 3.0 - y0 + y3; + + var fx = x0; + var fy = y0; + + var dfx = (x1 - x0) * pre1 + tmp1x * pre2 + tmp2x * step3; + var dfy = (y1 - y0) * pre1 + tmp1y * pre2 + tmp2y * step3; + + var ddfx = tmp1x * pre4 + tmp2x * pre5; + var ddfy = tmp1y * pre4 + tmp2y * pre5; + + var dddfx = tmp2x * pre5; + var dddfy = tmp2y * pre5; + + var t = 0; + + var k = 0; + var segCount = Math.ceil(1 / step); + + var points = new Float32Array((segCount + 1) * 3); + var points = []; + var offset = 0; + for (var k = 0; k < segCount + 1; k++) { + points[offset++] = fx; + points[offset++] = fy; + + fx += dfx; fy += dfy; + dfx += ddfx; dfy += ddfy; + ddfx += dddfx; ddfy += dddfy; + t += step; + + if (t > 1) { + fx = dfx > 0 ? Math.min(fx, x3) : Math.max(fx, x3); + fy = dfy > 0 ? Math.min(fy, y3) : Math.max(fy, y3); + } } - // FIXME Always return new ? - return (this._geoRect = rect || new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.BoundingRect(0, 0, 0, 0)); + + this.addPolyline(points, color, lineWidth); }, /** - * Add geoCoord for indexing by name - * @param {string} name - * @param {Array.} geoCoord + * Add a straight line + * @param {Array.} p0 + * @param {Array.} p1 + * @param {Array.} color + * @param {number} [lineWidth=1] */ - addGeoCoord: function (name, geoCoord) { - this._nameCoordMap[name] = geoCoord; + addLine: function (p0, p1, color, lineWidth) { + this.addPolyline([p0, p1], color, lineWidth); }, /** - * @param {string} name - * @return {module:echarts/coord/geo/Region} + * Add a straight line + * @param {Array. | Array.} points + * @param {Array. | Array.} color + * @param {number} [lineWidth=1] + * @param {number} [arrayOffset=0] + * @param {number} [pointsCount] Default to be amount of points in the first argument */ - getRegion: function (name) { - return this._regionsMap[name]; - }, - - getRegionByCoord: function (coord) { - var regions = this.regions; - for (var i = 0; i < regions.length; i++) { - if (regions[i].contain(coord)) { - return regions[i]; + addPolyline: (function () { + var dirA = vec2.create(); + var dirB = vec2.create(); + var normal = vec2.create(); + var tangent = vec2.create(); + var point = [], nextPoint = [], prevPoint = []; + return function (points, color, lineWidth, arrayOffset, pointsCount) { + if (!points.length) { + return; + } + var is2DArray = typeof points[0] !== 'number'; + if (pointsCount == null) { + pointsCount = is2DArray ? points.length : points.length / 2; + } + if (pointsCount < 2) { + return; + } + if (arrayOffset == null) { + arrayOffset = 0; + } + if (lineWidth == null) { + lineWidth = 1; } - } - }, - setSize: function (width, height, depth) { - this.size = [width, height, depth]; + this._itemVertexOffsets.push(this._vertexOffset); - var rect = this.getGeoBoundingRect(); + var notSharingColor = is2DArray + ? typeof color[0] !== 'number' + : color.length / 4 === pointsCount; - var scaleX = width / rect.width; - var scaleZ = -depth / rect.height; - var translateX = -width / 2 - rect.x * scaleX; - var translateZ = depth / 2 - rect.y * scaleZ; + var positionAttr = this.attributes.position; + var colorAttr = this.attributes.color; + var offsetAttr = this.attributes.offset; + var normalAttr = this.attributes.normal; + var indices = this.indices; - var position = this.extrudeY ? [translateX, 0, translateZ] : [translateX, translateZ, 0]; - var scale = this.extrudeY ? [scaleX, 1, scaleZ] : [scaleX, scaleZ, 1]; + var vertexOffset = this._vertexOffset; + var pointColor; + for (var k = 0; k < pointsCount; k++) { + if (is2DArray) { + point = points[k + arrayOffset]; + if (notSharingColor) { + pointColor = color[k + arrayOffset]; + } + else { + pointColor = color; + } + } + else { + var k2 = k * 2 + arrayOffset; + point = point || []; + point[0] = points[k2]; + point[1] = points[k2 + 1]; - var m = this.transform; - mat4.identity(m); - mat4.translate(m, m, position); - mat4.scale(m, m, scale); + if (notSharingColor) { + var k4 = k * 4 + arrayOffset; + pointColor = pointColor || []; + pointColor[0] = color[k4]; + pointColor[1] = color[k4 + 1]; + pointColor[2] = color[k4 + 2]; + pointColor[3] = color[k4 + 3]; + } + else { + pointColor = color; + } + } + if (!this.useNativeLine) { + var offset; + if (k < pointsCount - 1) { + if (is2DArray) { + vec2.copy(nextPoint, points[k + 1]); + } + else { + var k2 = (k + 1) * 2 + arrayOffset; + nextPoint = nextPoint || []; + nextPoint[0] = points[k2]; + nextPoint[1] = points[k2 + 1]; + } + // TODO In case dir is (0, 0) + // TODO miterLimit + if (k > 0) { + vec2.sub(dirA, point, prevPoint); + vec2.sub(dirB, nextPoint, point); + vec2.normalize(dirA, dirA); + vec2.normalize(dirB, dirB); + vec2.add(tangent, dirA, dirB); + vec2.normalize(tangent, tangent); + var miter = lineWidth / 2 * Math.min(1 / vec2.dot(dirA, tangent), 2); + normal[0] = -tangent[1]; + normal[1] = tangent[0]; - mat4.invert(this.invTransform, m); - }, + offset = miter; + } + else { + vec2.sub(dirA, nextPoint, point); + vec2.normalize(dirA, dirA); - dataToPoint: function (data, out) { - out = out || []; + normal[0] = -dirA[1]; + normal[1] = dirA[0]; - var extrudeCoordIndex = this.extrudeY ? 1 : 2; - var sideCoordIndex = this.extrudeY ? 2 : 1; + offset = lineWidth / 2; + } - var altitudeVal = data[2]; - // PENDING. - if (isNaN(altitudeVal)) { - altitudeVal = 0; - } - // lng - out[0] = data[0]; - // lat - out[sideCoordIndex] = data[1]; + } + else { + vec2.sub(dirA, point, prevPoint); + vec2.normalize(dirA, dirA); + + normal[0] = -dirA[1]; + normal[1] = dirA[0]; + + offset = lineWidth / 2; + } + normalAttr.set(vertexOffset, normal); + normalAttr.set(vertexOffset + 1, normal); + offsetAttr.set(vertexOffset, offset); + offsetAttr.set(vertexOffset + 1, -offset); + + vec2.copy(prevPoint, point); + + positionAttr.set(vertexOffset, point); + positionAttr.set(vertexOffset + 1, point); + + colorAttr.set(vertexOffset, pointColor); + colorAttr.set(vertexOffset + 1, pointColor); + + vertexOffset += 2; + } + else { + if (k > 1) { + positionAttr.copy(vertexOffset, vertexOffset - 1); + colorAttr.copy(vertexOffset, vertexOffset - 1); + vertexOffset++; + } + } + + if (!this.useNativeLine) { + if (k > 0) { + var idx3 = this._faceOffset * 3; + var indices = this.indices; + // 0-----2 + // 1-----3 + // 0->1->2, 1->3->2 + indices[idx3] = vertexOffset - 4; + indices[idx3 + 1] = vertexOffset - 3; + indices[idx3 + 2] = vertexOffset - 2; + + indices[idx3 + 3] = vertexOffset - 3; + indices[idx3 + 4] = vertexOffset - 1; + indices[idx3 + 5] = vertexOffset - 2; - if (this.altitudeAxis) { - out[extrudeCoordIndex] = this.altitudeAxis.dataToCoord(altitudeVal); - } - else { - out[extrudeCoordIndex] = 0; - } - // PENDING different region height. - out[extrudeCoordIndex] += this.regionHeight; + this._faceOffset += 2; + } + } + else { + colorAttr.set(vertexOffset, pointColor); + positionAttr.set(vertexOffset, point); + vertexOffset++; + } + } - vec3.transformMat4(out, out, this.transform); + this._vertexOffset = vertexOffset; + }; + })(), - return out; - }, + /** + * Set color of single line. + */ + setItemColor: function (idx, color) { + var startOffset = this._itemVertexOffsets[idx]; + var endOffset = idx < this._itemVertexOffsets.length - 1 ? this._itemVertexOffsets[idx + 1] : this._vertexOffset; - pointToData: function (point, out) { - // TODO + for (var i = startOffset; i < endOffset; i++) { + this.attributes.color.set(i, color); + } + this.dirty('color'); } -}; +}); -/* harmony default export */ __webpack_exports__["a"] = (Geo3D); +__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.util.defaults(LinesGeometry.prototype, __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__["a" /* default */]); + +/* harmony default export */ __webpack_exports__["a"] = (LinesGeometry); /***/ }), -/* 93 */ +/* 106 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix__); +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_echarts_gl__ = __webpack_require__(107); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_component_grid3D__ = __webpack_require__(154); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_component_geo3D__ = __webpack_require__(201); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_component_globe__ = __webpack_require__(207); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_component_mapbox3D__ = __webpack_require__(213); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_component_maptalks3D__ = __webpack_require__(219); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_chart_bar3D__ = __webpack_require__(225); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_chart_line3D__ = __webpack_require__(232); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_chart_scatter3D__ = __webpack_require__(236); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_chart_lines3D__ = __webpack_require__(243); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__src_chart_polygons3D__ = __webpack_require__(249); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__src_chart_surface__ = __webpack_require__(252); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__src_chart_map3D__ = __webpack_require__(256); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__src_chart_scatterGL__ = __webpack_require__(259); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__src_chart_graphGL__ = __webpack_require__(262); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__src_chart_flowGL__ = __webpack_require__(275); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__src_chart_linesGL__ = __webpack_require__(281); -var mat4 = __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix___default.a.mat4; -var TILE_SIZE = 512; -var FOV = 0.6435011087932844; -var PI = Math.PI; -var WORLD_SCALE = 1 / 10; -function MapServiceCoordSys3D() { - /** - * Width of mapbox viewport - */ - this.width = 0; - /** - * Height of mapbox viewport - */ - this.height = 0; - this.altitudeScale = 1; - // TODO Change boxHeight won't have animation. - this.boxHeight = 'auto'; - // Set by mapbox creator - this.altitudeExtent; - this.bearing = 0; - this.pitch = 0; - this.center = [0, 0]; - this._origin; - this.zoom = 0; - this._initialZoom; - // Some parameters for different map services. - this.maxPitch = 60; - this.zoomOffset = 0; -} -MapServiceCoordSys3D.prototype = { - constructor: MapServiceCoordSys3D, - dimensions: ['lng', 'lat', 'alt'], - containPoint: function () {}, - setCameraOption: function (option) { - this.bearing = option.bearing; - this.pitch = option.pitch; - this.center = option.center; - this.zoom = option.zoom; - if (!this._origin) { - this._origin = this.projectOnTileWithScale(this.center, TILE_SIZE); - } - if (this._initialZoom == null) { - this._initialZoom = this.zoom; - } - this.updateTransform(); - }, - // https://github.com/mapbox/mapbox-gl-js/blob/master/src/geo/transform.js#L479 - updateTransform: function () { - if (!this.height) { return; } - var cameraToCenterDistance = 0.5 / Math.tan(FOV / 2) * this.height * WORLD_SCALE; - // Convert to radian. - var pitch = Math.max(Math.min(this.pitch, this.maxPitch), 0) / 180 * Math.PI; +/***/ }), +/* 107 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - // Find the distance from the center point [width/2, height/2] to the - // center top point [width/2, 0] in Z units, using the law of sines. - // 1 Z unit is equivalent to 1 horizontal px at the center of the map - // (the distance between[width/2, height/2] and [width/2 + 1, height/2]) - var halfFov = FOV / 2; - var groundAngle = Math.PI / 2 + pitch; - var topHalfSurfaceDistance = Math.sin(halfFov) * cameraToCenterDistance / Math.sin(Math.PI - groundAngle - halfFov); +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_version__ = __webpack_require__(108); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_LayerGL__ = __webpack_require__(109); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__preprocessor_backwardCompat__ = __webpack_require__(153); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_graphicGL__ = __webpack_require__(1); +/** + * echarts-gl + * Extension pack of ECharts providing 3d plots and globe visualization + * + * Copyright (c) 2014, echarts-gl + * 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 HOLDER 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 USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ - // Calculate z distance of the farthest fragment that should be rendered. - var furthestDistance = Math.cos(Math.PI / 2 - pitch) * topHalfSurfaceDistance + cameraToCenterDistance; - // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance` - var farZ = furthestDistance * 1.1; - // Forced to be 1000 - if (this.pitch > 50) { - farZ = 1000; - } +/** + * @module echarts-gl + * @author Yi Shen(http://github.com/pissang) + */ - // matrix for conversion from location to GL coordinates (-1 .. 1) - var m = []; - mat4.perspective(m, FOV, this.width / this.height, 1, farZ); - this.viewGL.camera.projectionMatrix.setArray(m); - this.viewGL.camera.decomposeProjectionMatrix(); +// PENDING Use a single canvas as layer or use image element? +var echartsGl = { + version: '1.1.1', + dependencies: { + echarts: '4.1.0', + claygl: '1.2.1' + } +}; - var m = mat4.identity([]); - var pt = this.dataToPoint(this.center); - // Inverse - mat4.scale(m, m, [1, -1, 1]); - // Translate to altitude - mat4.translate(m, m, [0, 0, -cameraToCenterDistance]); - mat4.rotateX(m, m, pitch); - mat4.rotateZ(m, m, -this.bearing / 180 * Math.PI); - // Translate to center. - mat4.translate(m, m, [-pt[0] * this.getScale() * WORLD_SCALE, -pt[1] * this.getScale() * WORLD_SCALE, 0]); - this.viewGL.camera.viewMatrix.array = m; - var invertM = []; - mat4.invert(invertM, m); - this.viewGL.camera.worldTransform.array = invertM; - this.viewGL.camera.decomposeWorldTransform(); - // scale vertically to meters per pixel (inverse of ground resolution): - // worldSize / (circumferenceOfEarth * cos(lat * π / 180)) - var worldSize = TILE_SIZE * this.getScale(); - var verticalScale; - if (this.altitudeExtent && !isNaN(this.boxHeight)) { - var range = this.altitudeExtent[1] - this.altitudeExtent[0]; - verticalScale = this.boxHeight / range * this.getScale() / Math.pow(2, this._initialZoom - this.zoomOffset); - } - else { - verticalScale = worldSize / (2 * Math.PI * 6378000 * Math.abs(Math.cos(this.center[1] * (Math.PI / 180)))) - * this.altitudeScale * WORLD_SCALE; - } - // Include scale to avoid relayout when zooming - // FIXME Camera scale may have problem in shadow - this.viewGL.rootNode.scale.set( - this.getScale() * WORLD_SCALE, this.getScale() * WORLD_SCALE, verticalScale - ); - }, - getScale: function () { - return Math.pow(2, this.zoom - this.zoomOffset); - }, - projectOnTile: function (data, out) { - return this.projectOnTileWithScale(data, this.getScale() * TILE_SIZE, out); - }, +// Version checking +var deps = echartsGl.dependencies; +function versionTooOldMsg(name) { + throw new Error( + name + ' version is too old, needs ' + deps[name] + ' or higher' + ); +} +function checkVersion(version, name) { + if ((version.replace('.', '') - 0) < (deps[name].replace('.', '') - 0)) { + versionTooOldMsg(name); + } + console.log('Loaded ' + name + ', version ' + version); +} +checkVersion(__WEBPACK_IMPORTED_MODULE_1_claygl_src_version__["a" /* default */], 'claygl'); +checkVersion(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.version, 'echarts'); - projectOnTileWithScale: function (data, scale, out) { - var lng = data[0]; - var lat = data[1]; - var lambda2 = lng * PI / 180; - var phi2 = lat * PI / 180; - var x = scale * (lambda2 + PI) / (2 * PI); - var y = scale * (PI - Math.log(Math.tan(PI / 4 + phi2 * 0.5))) / (2 * PI); - out = out || []; - out[0] = x; - out[1] = y; - return out; - }, +function EChartsGL (zr) { + this._layers = {}; - unprojectFromTile: function (point, out) { - return this.unprojectOnTileWithScale(point, this.getScale() * TILE_SIZE, out); - }, + this._zr = zr; +} - unprojectOnTileWithScale: function (point, scale, out) { - var x = point[0]; - var y = point[1]; - var lambda2 = (x / scale) * (2 * PI) - PI; - var phi2 = 2 * (Math.atan(Math.exp(PI - (y / scale) * (2 * PI))) - PI / 4); - out = out || []; - out[0] = lambda2 * 180 / PI; - out[1] = phi2 * 180 / PI; - return out; - }, +EChartsGL.prototype.update = function (ecModel, api) { + var self = this; + var zr = api.getZr(); - dataToPoint: function (data, out) { - out = this.projectOnTileWithScale(data, TILE_SIZE, out); - // Add a origin to avoid precision issue in WebGL. - out[0] -= this._origin[0]; - out[1] -= this._origin[1]; - // PENDING - out[2] = !isNaN(data[2]) ? data[2] : 0; - if (!isNaN(data[2])) { - out[2] = data[2]; - if (this.altitudeExtent) { - out[2] -= this.altitudeExtent[0]; - } - } - return out; + if (!zr.getWidth() || !zr.getHeight()) { + console.warn('Dom has no width or height'); + return; } -}; -/* harmony default export */ __webpack_exports__["a"] = (MapServiceCoordSys3D); - -/***/ }), -/* 94 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + function getLayerGL(model) { + var zlevel; + // Host on coordinate system. + if (model.coordinateSystem && model.coordinateSystem.model) { + zlevel = model.get('zlevel'); + } + else { + zlevel = model.get('zlevel'); + } -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_retrieve__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__ = __webpack_require__(19); + var layers = self._layers; + var layerGL = layers[zlevel]; + if (!layerGL) { + layerGL = layers[zlevel] = new __WEBPACK_IMPORTED_MODULE_2__core_LayerGL__["a" /* default */]('gl-' + zlevel, zr); + if (zr.painter.isSingleCanvas()) { + layerGL.virtual = true; + // If container is canvas, use image to represent LayerGL + // FIXME Performance + var img = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.Image({ + z: 1e4, + style: { + image: layerGL.renderer.canvas + }, + silent: true + }); + layerGL.__hostImage = img; + zr.add(img); + } + zr.painter.insertLayer(zlevel, layerGL); + } + if (layerGL.__hostImage) { + layerGL.__hostImage.setStyle({ + width: layerGL.renderer.getWidth(), + height: layerGL.renderer.getHeight() + }); + } -/* harmony default export */ __webpack_exports__["a"] = (function (serviceComponentType, ServiceCtor, afterCreate) { + return layerGL; + } - function resizeMapService3D(mapService3DModel, api) { - var width = api.getWidth(); - var height = api.getHeight(); - var dpr = api.getDevicePixelRatio(); - this.viewGL.setViewport(0, 0, width, height, dpr); + function setSilent(groupGL, silent) { + if (groupGL) { + groupGL.traverse(function (mesh) { + if (mesh.isRenderable && mesh.isRenderable()) { + mesh.ignorePicking = mesh.$ignorePicking != null + ? mesh.$ignorePicking : silent; + } + }); + } + } - this.width = width; - this.height = height; + for (var zlevel in this._layers) { + this._layers[zlevel].removeViewsAll(); + } - this.altitudeScale = mapService3DModel.get('altitudeScale'); + ecModel.eachComponent(function (componentType, componentModel) { + if (componentType !== 'series') { + var view = api.getViewOfComponentModel(componentModel); + var coordSys = componentModel.coordinateSystem; + // View with __ecgl__ flag is a echarts-gl component. + if (view.__ecgl__) { + var viewGL; + if (coordSys) { + if (!coordSys.viewGL) { + console.error('Can\'t find viewGL in coordinateSystem of component ' + componentModel.id); + return; + } + viewGL = coordSys.viewGL; + } + else { + if (!componentModel.viewGL) { + console.error('Can\'t find viewGL of component ' + componentModel.id); + return; + } + viewGL = coordSys.viewGL; + } - this.boxHeight = mapService3DModel.get('boxHeight'); - // this.updateTransform(); - } + var viewGL = coordSys.viewGL; + var layerGL = getLayerGL(componentModel); + layerGL.addView(viewGL); - function updateService3D(ecModel, api) { + view.afterRender && view.afterRender( + componentModel, ecModel, api, layerGL + ); - if (this.model.get('boxHeight') === 'auto') { - return; + setSilent(view.groupGL, componentModel.get('silent')); + } } + }); - var altitudeDataExtent = [Infinity, -Infinity] - - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.coordinateSystem !== this) { + ecModel.eachSeries(function (seriesModel) { + var chartView = api.getViewOfSeriesModel(seriesModel); + var coordSys = seriesModel.coordinateSystem; + if (chartView.__ecgl__) { + if ((coordSys && !coordSys.viewGL) && !chartView.viewGL) { + console.error('Can\'t find viewGL of series ' + chartView.id); return; } + var viewGL = (coordSys && coordSys.viewGL) || chartView.viewGL; + // TODO Check zlevel not same with component of coordinate system ? + var layerGL = getLayerGL(seriesModel); + layerGL.addView(viewGL); - // Get altitude data extent. - var data = seriesModel.getData(); - var altDim = seriesModel.coordDimToDataDim('alt')[0]; - if (altDim) { - // TODO altitiude is in coords of lines. - var dataExtent = data.getDataExtent(altDim, true); - altitudeDataExtent[0] = Math.min( - altitudeDataExtent[0], dataExtent[0] - ); - altitudeDataExtent[1] = Math.max( - altitudeDataExtent[1], dataExtent[1] - ); - } - }, this); - if (altitudeDataExtent && isFinite(altitudeDataExtent[1] - altitudeDataExtent[0])) { - this.altitudeExtent = altitudeDataExtent; + chartView.afterRender && chartView.afterRender( + seriesModel, ecModel, api, layerGL + ); + + setSilent(chartView.groupGL, seriesModel.get('silent')); } - } + }); +}; - return { +// Hack original getRenderedCanvas. Will removed after new echarts released +// TODO +var oldInit = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.init; +__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.init = function () { + var chart = oldInit.apply(this, arguments); + chart.getZr().painter.getRenderedCanvas = function (opts) { + opts = opts || {}; + if (this._singleCanvas) { + return this._layers[0].dom; + } + + var canvas = document.createElement('canvas'); + var dpr = opts.pixelRatio || this.dpr; + canvas.width = this.getWidth() * dpr; + canvas.height = this.getHeight() * dpr; + var ctx = canvas.getContext('2d'); + ctx.dpr = dpr; + ctx.clearRect(0, 0, canvas.width, canvas.height); + if (opts.backgroundColor) { + ctx.fillStyle = opts.backgroundColor; + ctx.fillRect(0, 0, canvas.width, canvas.height); + } - dimensions: ServiceCtor.prototype.dimensions, + var displayList = this.storage.getDisplayList(true); - create: function (ecModel, api) { - var mapService3DList = []; + var scope = {}; + var zlevel; - ecModel.eachComponent(serviceComponentType, function (mapService3DModel) { - var viewGL = mapService3DModel.__viewGL; - if (!viewGL) { - viewGL = mapService3DModel.__viewGL = new __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__["a" /* default */](); - viewGL.setRootNode(new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node()); + var self = this; + function findAndDrawOtherLayer(smaller, larger) { + var zlevelList = self._zlevelList; + if (smaller == null) { + smaller = -Infinity; + } + var intermediateLayer; + for (var i = 0; i < zlevelList.length; i++) { + var z = zlevelList[i]; + var layer = self._layers[z]; + if (!layer.__builtin__ && z > smaller && z < larger) { + intermediateLayer = layer; + break; } + } + if (intermediateLayer && intermediateLayer.renderToCanvas) { + ctx.save(); + intermediateLayer.renderToCanvas(ctx); + ctx.restore(); + } + } + var layer = { + ctx: ctx + }; + for (var i = 0; i < displayList.length; i++) { + var el = displayList[i]; - var mapService3DCoordSys = new ServiceCtor(); - mapService3DCoordSys.viewGL = mapService3DModel.__viewGL; - // Inject resize - mapService3DCoordSys.resize = resizeMapService3D; - mapService3DCoordSys.resize(mapService3DModel, api); + if (el.zlevel !== zlevel) { + findAndDrawOtherLayer(zlevel, el.zlevel); + zlevel = el.zlevel; + } + this._doPaintEl(el, layer, true, scope); + } - mapService3DList.push(mapService3DCoordSys); + findAndDrawOtherLayer(zlevel, Infinity); - mapService3DModel.coordinateSystem = mapService3DCoordSys; - mapService3DCoordSys.model = mapService3DModel; + return canvas; + }; + return chart; +}; - mapService3DCoordSys.update = updateService3D; - }); - ecModel.eachSeries(function (seriesModel) { - if (seriesModel.get('coordinateSystem') === serviceComponentType) { - var mapService3DModel = seriesModel.getReferringComponents(serviceComponentType)[0]; - if (!mapService3DModel) { - mapService3DModel = ecModel.getComponent(serviceComponentType); - } +__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerPostUpdate(function (ecModel, api) { + var zr = api.getZr(); - if (!mapService3DModel) { - throw new Error(serviceComponentType + ' "' + __WEBPACK_IMPORTED_MODULE_0__util_retrieve__["a" /* default */].firstNotNull( - seriesModel.get(serviceComponentType + 'Index'), - seriesModel.get(serviceComponentType + 'Id'), - 0 - ) + '" not found'); - } + var egl = zr.__egl = zr.__egl || new EChartsGL(zr); - seriesModel.coordinateSystem = mapService3DModel.coordinateSystem; - } - }); + egl.update(ecModel, api); +}); - afterCreate && afterCreate(mapService3DList, ecModel, api); +__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerPreprocessor(__WEBPACK_IMPORTED_MODULE_3__preprocessor_backwardCompat__["a" /* default */]); - return mapService3DList; - } - }; -}); +__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphicGL = __WEBPACK_IMPORTED_MODULE_4__util_graphicGL__["a" /* default */]; +/* unused harmony default export */ var _unused_webpack_default_export = (EChartsGL); /***/ }), -/* 95 */ +/* 108 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("\n@export ecgl.displayShadow.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_WorldPosition;\n\nvarying vec3 v_Normal;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n\n@export ecgl.displayShadow.fragment\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform float roughness: 0.2;\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.ssaoMap.header\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n float shadow = 1.0;\n\n @import ecgl.common.ssaoMap.main\n\n#if defined(DIRECTIONAL_LIGHT_COUNT) && defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n for (int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++) {\n shadow = min(shadow, shadowContribsDir[i] * 0.5 + 0.5);\n }\n#endif\n\n shadow *= 0.5 + ao * 0.5;\n shadow = clamp(shadow, 0.0, 1.0);\n\n gl_FragColor = vec4(vec3(0.0), 1.0 - shadow);\n}\n\n@end"); +/** + * @name clay.version + */ +/* harmony default export */ __webpack_exports__["a"] = ('1.2.1'); /***/ }), -/* 96 */ +/* 109 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix__ = __webpack_require__(77); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector__ = __webpack_require__(76); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Renderer__ = __webpack_require__(52); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_picking_RayPicking__ = __webpack_require__(117); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_core_mixin_notifier__ = __webpack_require__(53); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_zrender_lib_animation_requestAnimationFrame__ = __webpack_require__(80); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_zrender_lib_animation_requestAnimationFrame___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_zrender_lib_animation_requestAnimationFrame__); +/** + * Provide WebGL layer to zrender. Which is rendered on top of clay. + * + * + * Relationship between zrender, LayerGL(renderer) and ViewGL(Scene, Camera, Viewport) + * zrender + * / \ + * LayerGL LayerGL + * (renderer) (renderer) + * / \ + * ViewGL ViewGL + * + * @module echarts-gl/core/LayerGL + * @author Yi Shen(http://github.com/pissang) + */ -function GLViewHelper(viewGL) { - this.viewGL = viewGL; -} -GLViewHelper.prototype.reset = function (seriesModel, api) { - this._updateCamera(api.getWidth(), api.getHeight(), api.getDevicePixelRatio()); - this._viewTransform = __WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix___default.a.create(); - this.updateTransform(seriesModel, api); -}; -GLViewHelper.prototype.updateTransform = function (seriesModel, api) { - var coordinateSystem = seriesModel.coordinateSystem; - if (coordinateSystem.getRoamTransform) { +// PENDING, clay. notifier is same with zrender Eventful - __WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix___default.a.invert(this._viewTransform, coordinateSystem.getRoamTransform()); - this._setCameraTransform(this._viewTransform); - api.getZr().refresh(); +/** + * @constructor + * @alias module:echarts-gl/core/LayerGL + * @param {string} id Layer ID + * @param {module:zrender/ZRender} zr + */ +var LayerGL = function (id, zr) { + + /** + * Layer ID + * @type {string} + */ + this.id = id; + + /** + * @type {module:zrender/ZRender} + */ + this.zr = zr; + + /** + * @type {clay.Renderer} + */ + try { + this.renderer = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Renderer__["a" /* default */]({ + clearBit: 0, + devicePixelRatio: zr.painter.dpr, + preserveDrawingBuffer: true, + // PENDING + premultipliedAlpha: true + }); + this.renderer.resize(zr.painter.getWidth(), zr.painter.getHeight()); } -}; + catch (e) { + this.renderer = null; + this.dom = document.createElement('div'); + this.dom.style.cssText = 'position:absolute; left: 0; top: 0; right: 0; bottom: 0;'; + this.dom.className = 'ecgl-nowebgl'; + this.dom.innerHTML = 'Sorry, your browser does not support WebGL'; -// Reimplement the dataToPoint of coordinate system. -// Remove the effect of pan/zoom transform -GLViewHelper.prototype.dataToPoint = function (coordSys, data, pt) { - pt = coordSys.dataToPoint(data, null, pt); - var viewTransform = this._viewTransform; - if (viewTransform) { - __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector___default.a.applyTransform(pt, pt, viewTransform); + console.error(e); + return; } + + this.onglobalout = this.onglobalout.bind(this); + zr.on('globalout', this.onglobalout); + + /** + * Canvas dom for webgl rendering + * @type {HTMLCanvasElement} + */ + this.dom = this.renderer.canvas; + var style = this.dom.style; + style.position = 'absolute'; + style.left = '0'; + style.top = '0'; + + /** + * @type {Array.} + */ + this.views = []; + + this._picking = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_picking_RayPicking__["a" /* default */]({ + renderer: this.renderer + }); + + this._viewsToDispose = []; + + /** + * Current accumulating id. + */ + this._accumulatingId = 0; + + this._zrEventProxy = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.Rect({ + shape: {x: -1, y: -1, width: 2, height: 2}, + // FIXME Better solution. + __isGLToZRProxy: true + }); + + this._backgroundColor = null; }; /** - * Remove transform info in point. + * @param {module:echarts-gl/core/ViewGL} view */ -GLViewHelper.prototype.removeTransformInPoint = function (pt) { - if (this._viewTransform) { - __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector___default.a.applyTransform(pt, pt, this._viewTransform); +LayerGL.prototype.addView = function (view) { + if (view.layer === this) { + return; } - return pt; + // If needs to dispose in this layer. unmark it. + var idx = this._viewsToDispose.indexOf(view); + if (idx >= 0) { + this._viewsToDispose.splice(idx, 1); + } + + this.views.push(view); + + view.layer = this; + + var zr = this.zr; + view.scene.traverse(function (node) { + node.__zr = zr; + if (node.addAnimatorsToZr) { + node.addAnimatorsToZr(zr); + } + }); }; +function removeFromZr(node) { + var zr = node.__zr; + node.__zr = null; + if (zr && node.removeAnimatorsFromZr) { + node.removeAnimatorsFromZr(zr); + } +} /** - * Return number + * @param {module:echarts-gl/core/ViewGL} view */ -GLViewHelper.prototype.getZoom = function () { - if (this._viewTransform) { - var m = this._viewTransform; - return 1 / Math.max( - Math.sqrt(m[0] * m[0] + m[1] * m[1]), - Math.sqrt(m[2] * m[2] + m[3] * m[3]) - ); +LayerGL.prototype.removeView = function (view) { + if (view.layer !== this) { + return; } - return 1; -}; -GLViewHelper.prototype._setCameraTransform = function (m) { - var camera = this.viewGL.camera; - camera.position.set(m[4], m[5], 0); - camera.scale.set( - Math.sqrt(m[0] * m[0] + m[1] * m[1]), - Math.sqrt(m[2] * m[2] + m[3] * m[3]), - 1 - ); -}; + var idx = this.views.indexOf(view); + if (idx >= 0) { + this.views.splice(idx, 1); + view.scene.traverse(removeFromZr, this); + view.layer = null; -GLViewHelper.prototype._updateCamera = function (width, height, dpr) { - // TODO, left, top, right, bottom - this.viewGL.setViewport(0, 0, width, height, dpr); - var camera = this.viewGL.camera; - camera.left = camera.top = 0; - camera.bottom = height; - camera.right = width; - camera.near = 0; - camera.far = 100; + // Mark to dispose in this layer. + this._viewsToDispose.push(view); + } }; -/* harmony default export */ __webpack_exports__["a"] = (GLViewHelper); +/** + * Remove all views + */ +LayerGL.prototype.removeViewsAll = function () { + this.views.forEach(function (view) { + view.scene.traverse(removeFromZr, this); + view.layer = null; -/***/ }), -/* 97 */ -/***/ (function(module, exports, __webpack_require__) { + // Mark to dispose in this layer. + this._viewsToDispose.push(view); + }, this); -/* WEBPACK VAR INJECTION */(function(global) {// (1) The code `if (__DEV__) ...` can be removed by build tool. -// (2) If intend to use `__DEV__`, this module should be imported. Use a global -// variable `__DEV__` may cause that miss the declaration (see #6535), or the -// declaration is behind of the using position (for example in `Model.extent`, -// And tools like rollup can not analysis the dependency if not import). -var dev; // In browser + this.views.length = 0; -if (typeof window !== 'undefined') { - dev = window.__DEV__; -} // In node -else if (typeof global !== 'undefined') { - dev = global.__DEV__; - } +}; -if (typeof dev === 'undefined') { - dev = true; -} +/** + * Resize the canvas and viewport, will be invoked by zrender + * @param {number} width + * @param {number} height + */ +LayerGL.prototype.resize = function (width, height) { + var renderer = this.renderer; + renderer.resize(width, height); +}; -var __DEV__ = dev; -exports.__DEV__ = __DEV__; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(63))) +/** + * Clear color and depth + * @return {[type]} [description] + */ +LayerGL.prototype.clear = function () { + var gl = this.renderer.gl; + var clearColor = this._backgroundColor || [0, 0, 0, 0]; + gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); + gl.depthMask(true); + gl.colorMask(true, true, true, true); + gl.clear(gl.DEPTH_BUFFER_BIT | gl.COLOR_BUFFER_BIT); +}; -/***/ }), -/* 98 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +/** + * Clear depth + */ +LayerGL.prototype.clearDepth = function () { + var gl = this.renderer.gl; + gl.clear(gl.DEPTH_BUFFER_BIT); +}; -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__ = __webpack_require__(34); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__); /** - * Lines geometry - * Use screen space projected lines lineWidth > MAX_LINE_WIDTH - * https://mattdesl.svbtle.com/drawing-lines-is-hard - * @module echarts-gl/util/geometry/LinesGeometry - * @author Yi Shen(http://github.com/pissang) + * Clear color */ +LayerGL.prototype.clearColor = function () { + var gl = this.renderer.gl; + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; +/** + * Mark layer to refresh next tick + */ +LayerGL.prototype.needsRefresh = function () { + this.zr.refresh(); +}; +/** + * Refresh the layer, will be invoked by zrender + */ +LayerGL.prototype.refresh = function (bgColor) { + this._backgroundColor = bgColor ? __WEBPACK_IMPORTED_MODULE_4__util_graphicGL__["a" /* default */].parseColor(bgColor) : [0, 0, 0, 0]; + this.renderer.clearColor = this._backgroundColor; + for (var i = 0; i < this.views.length; i++) { + this.views[i].prepareRender(this.renderer); + } -var vec2 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix___default.a.vec2; + this._doRender(false); -// var CURVE_RECURSION_LIMIT = 8; -// var CURVE_COLLINEAR_EPSILON = 40; + // Auto dispose unused resources on GPU, like program(shader), texture, geometry(buffers) + this._trackAndClean(); -var sampleLinePoints = [[0, 0], [1, 1]]; -/** - * @constructor - * @alias module:echarts-gl/util/geometry/LinesGeometry - * @extends clay.Geometry - */ + // Dispose trashed views + for (var i = 0; i < this._viewsToDispose.length; i++) { + this._viewsToDispose[i].dispose(this.renderer); + } + this._viewsToDispose.length = 0; -var LinesGeometry = __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].extend(function () { - return { + this._startAccumulating(); +}; - segmentScale: 4, - dynamic: true, - /** - * Need to use mesh to expand lines if lineWidth > MAX_LINE_WIDTH - */ - useNativeLine: true, +LayerGL.prototype.renderToCanvas = function (ctx) { + // PENDING will block the page + this._startAccumulating(true); + ctx.drawImage(this.dom, 0, 0, ctx.canvas.width, ctx.canvas.height); +}; - attributes: { - position: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('position', 'float', 2, 'POSITION'), - normal: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('normal', 'float', 2), - offset: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('offset', 'float', 1), - color: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('color', 'float', 4, 'COLOR') - } - }; -}, -/** @lends module: echarts-gl/util/geometry/LinesGeometry.prototype */ -{ +LayerGL.prototype._doRender = function (accumulating) { + this.clear(); + this.renderer.saveViewport(); + for (var i = 0; i < this.views.length; i++) { + this.views[i].render(this.renderer, accumulating); + } + this.renderer.restoreViewport(); +}; - /** - * Reset offset - */ - resetOffset: function () { - this._vertexOffset = 0; - this._faceOffset = 0; +/** + * Stop accumulating + */ +LayerGL.prototype._stopAccumulating = function () { + this._accumulatingId = 0; + clearTimeout(this._accumulatingTimeout); +}; - this._itemVertexOffsets = []; - }, +var accumulatingId = 1; +/** + * Start accumulating all the views. + * Accumulating is for antialising and have more sampling in SSAO + * @private + */ +LayerGL.prototype._startAccumulating = function (immediate) { + var self = this; + this._stopAccumulating(); - /** - * @param {number} nVertex - */ - setVertexCount: function (nVertex) { - var attributes = this.attributes; - if (this.vertexCount !== nVertex) { - attributes.position.init(nVertex); - attributes.color.init(nVertex); + var needsAccumulate = false; + for (var i = 0; i < this.views.length; i++) { + needsAccumulate = this.views[i].needsAccumulate() || needsAccumulate; + } + if (!needsAccumulate) { + return; + } - if (!this.useNativeLine) { - attributes.offset.init(nVertex); - attributes.normal.init(nVertex); - } + function accumulate(id) { + if (!self._accumulatingId || id !== self._accumulatingId) { + return; + } - if (nVertex > 0xffff) { - if (this.indices instanceof Uint16Array) { - this.indices = new Uint32Array(this.indices); - } - } - else { - if (this.indices instanceof Uint32Array) { - this.indices = new Uint16Array(this.indices); - } - } + var isFinished = true; + for (var i = 0; i < self.views.length; i++) { + isFinished = self.views[i].isAccumulateFinished() && needsAccumulate; } - }, - /** - * @param {number} nTriangle - */ - setTriangleCount: function (nTriangle) { - if (this.triangleCount !== nTriangle) { - if (nTriangle === 0) { - this.indices = null; + if (!isFinished) { + self._doRender(true); + + if (immediate) { + accumulate(id); } else { - this.indices = this.vertexCount > 0xffff ? new Uint32Array(nTriangle * 3) : new Uint16Array(nTriangle * 3); + __WEBPACK_IMPORTED_MODULE_6_zrender_lib_animation_requestAnimationFrame___default()(function () { + accumulate(id); + }); } } - }, - - _getCubicCurveApproxStep: function (p0, p1, p2, p3) { - var len = vec2.dist(p0, p1) + vec2.dist(p2, p1) + vec2.dist(p3, p2); - var step = 1 / (len + 1) * this.segmentScale; - return step; - }, + } - /** - * Get vertex count of cubic curve - * @param {Array.} p0 - * @param {Array.} p1 - * @param {Array.} p2 - * @param {Array.} p3 - * @return number - */ - getCubicCurveVertexCount: function (p0, p1, p2, p3) { - var step = this._getCubicCurveApproxStep(p0, p1, p2, p3); - var segCount = Math.ceil(1 / step); - if (!this.useNativeLine) { - return segCount * 2 + 2; - } - else { - return segCount * 2; - } - }, + this._accumulatingId = accumulatingId++; - /** - * Get face count of cubic curve - * @param {Array.} p0 - * @param {Array.} p1 - * @param {Array.} p2 - * @param {Array.} p3 - * @return number - */ - getCubicCurveTriangleCount: function (p0, p1, p2, p3) { - var step = this._getCubicCurveApproxStep(p0, p1, p2, p3); - var segCount = Math.ceil(1 / step); - if (!this.useNativeLine) { - return segCount * 2; - } - else { - return 0; - } - }, + if (immediate) { + accumulate(self._accumulatingId); + } + else { + this._accumulatingTimeout = setTimeout(function () { + accumulate(self._accumulatingId); + }, 50); + } +}; - /** - * Get vertex count of line - * @return {number} - */ - getLineVertexCount: function () { - return this.getPolylineVertexCount(sampleLinePoints); - }, +LayerGL.prototype._trackAndClean = function () { + var textureList = []; + var geometriesList = []; - /** - * Get face count of line - * @return {number} - */ - getLineTriangleCount: function () { - return this.getPolylineTriangleCount(sampleLinePoints); - }, + // Mark all resources unused; + if (this._textureList) { + markUnused(this._textureList); + markUnused(this._geometriesList); + } - /** - * Get how many vertices will polyline take. - * @type {number|Array} points Can be a 1d/2d list of points, or a number of points amount. - * @return {number} - */ - getPolylineVertexCount: function (points) { - var pointsLen; - if (typeof points === 'number') { - pointsLen = points; - } - else { - var is2DArray = typeof points[0] !== 'number'; - pointsLen = is2DArray ? points.length : (points.length / 2); - } - return !this.useNativeLine ? ((pointsLen - 1) * 2 + 2) : (pointsLen - 1) * 2; - }, + for (var i = 0; i < this.views.length; i++) { + collectResources(this.views[i].scene, textureList, geometriesList); + } - /** - * Get how many triangles will polyline take. - * @type {number|Array} points Can be a 1d/2d list of points, or a number of points amount. - * @return {number} - */ - getPolylineTriangleCount: function (points) { - var pointsLen; - if (typeof points === 'number') { - pointsLen = points; + // Dispose those unsed resources. + if (this._textureList) { + checkAndDispose(this.renderer, this._textureList); + checkAndDispose(this.renderer, this._geometriesList); + } + + this._textureList = textureList; + this._geometriesList = geometriesList; +}; + +function markUnused(resourceList) { + for (var i = 0; i < resourceList.length; i++) { + resourceList[i].__used__ = 0; + } +} +function checkAndDispose(renderer, resourceList) { + for (var i = 0; i < resourceList.length; i++) { + if (!resourceList[i].__used__) { + resourceList[i].dispose(renderer); } - else { - var is2DArray = typeof points[0] !== 'number'; - pointsLen = is2DArray ? points.length : (points.length / 2); + } +} +function updateUsed(resource, list) { + resource.__used__ = resource.__used__ || 0; + resource.__used__++; + if (resource.__used__ === 1) { + // Don't push to the list twice. + list.push(resource); + } +} +function collectResources(scene, textureResourceList, geometryResourceList) { + var prevMaterial; + var prevGeometry; + scene.traverse(function (renderable) { + if (renderable.isRenderable()) { + var geometry = renderable.geometry; + var material = renderable.material; + + // TODO optimize!! + if (material !== prevMaterial) { + var textureUniforms = material.getTextureUniforms(); + for (var u = 0; u < textureUniforms.length; u++) { + var uniformName = textureUniforms[u]; + var val = material.uniforms[uniformName].value; + if (!val) { + continue; + } + if (val instanceof __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */]) { + updateUsed(val, textureResourceList); + } + else if (val instanceof Array) { + for (var k = 0; k < val.length; k++) { + if (val[k] instanceof __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */]) { + updateUsed(val[k], textureResourceList); + } + } + } + } + } + if (geometry !== prevGeometry) { + updateUsed(geometry, geometryResourceList); + } + + prevMaterial = material; + prevGeometry = geometry; } - return !this.useNativeLine ? (pointsLen - 1) * 2 : 0; - }, + }); - /** - * Add a cubic curve - * @param {Array.} p0 - * @param {Array.} p1 - * @param {Array.} p2 - * @param {Array.} p3 - * @param {Array.} color - * @param {number} [lineWidth=1] - */ - addCubicCurve: function (p0, p1, p2, p3, color, lineWidth) { - if (lineWidth == null) { - lineWidth = 1; + for (var k = 0; k < scene.lights.length; k++) { + // Track AmbientCubemap + if (scene.lights[k].cubemap) { + updateUsed(scene.lights[k].cubemap, textureResourceList); } - // incremental interpolation - // http://antigrain.com/research/bezier_interpolation/index.html#PAGE_BEZIER_INTERPOLATION - var x0 = p0[0], y0 = p0[1]; - var x1 = p1[0], y1 = p1[1]; - var x2 = p2[0], y2 = p2[1]; - var x3 = p3[0], y3 = p3[1]; + } +} +/** + * Dispose the layer + */ +LayerGL.prototype.dispose = function () { + this._stopAccumulating(); + this.renderer.disposeScene(this.scene); - var step = this._getCubicCurveApproxStep(p0, p1, p2, p3); + this.zr.off('globalout', this.onglobalout); +}; - var step2 = step * step; - var step3 = step2 * step; +// Event handlers +LayerGL.prototype.onmousedown = function (e) { + if (e.target && e.target.__isGLToZRProxy) { + return; + } - var pre1 = 3.0 * step; - var pre2 = 3.0 * step2; - var pre4 = 6.0 * step2; - var pre5 = 6.0 * step3; + e = e.event; + var obj = this.pickObject(e.offsetX, e.offsetY); + if (obj) { + this._dispatchEvent('mousedown', e, obj); + this._dispatchDataEvent('mousedown', e, obj); + } - var tmp1x = x0 - x1 * 2.0 + x2; - var tmp1y = y0 - y1 * 2.0 + y2; + this._downX = e.offsetX; + this._downY = e.offsetY; +}; - var tmp2x = (x1 - x2) * 3.0 - x0 + x3; - var tmp2y = (y1 - y2) * 3.0 - y0 + y3; +LayerGL.prototype.onmousemove = function (e) { + if (e.target && e.target.__isGLToZRProxy) { + return; + } - var fx = x0; - var fy = y0; + e = e.event; + var obj = this.pickObject(e.offsetX, e.offsetY); - var dfx = (x1 - x0) * pre1 + tmp1x * pre2 + tmp2x * step3; - var dfy = (y1 - y0) * pre1 + tmp1y * pre2 + tmp2y * step3; + var target = obj && obj.target; + var lastHovered = this._hovered; + this._hovered = obj; - var ddfx = tmp1x * pre4 + tmp2x * pre5; - var ddfy = tmp1y * pre4 + tmp2y * pre5; + if (lastHovered && target !== lastHovered.target) { + lastHovered.relatedTarget = target; + this._dispatchEvent('mouseout', e, lastHovered); + // this._dispatchDataEvent('mouseout', e, lastHovered); - var dddfx = tmp2x * pre5; - var dddfy = tmp2y * pre5; + this.zr.setCursorStyle('default'); + } - var t = 0; + this._dispatchEvent('mousemove', e, obj); - var k = 0; - var segCount = Math.ceil(1 / step); + if (obj) { + this.zr.setCursorStyle('pointer'); - var points = new Float32Array((segCount + 1) * 3); - var points = []; - var offset = 0; - for (var k = 0; k < segCount + 1; k++) { - points[offset++] = fx; - points[offset++] = fy; + if (!lastHovered || (target !== lastHovered.target)) { + this._dispatchEvent('mouseover', e, obj); + // this._dispatchDataEvent('mouseover', e, obj); + } + } - fx += dfx; fy += dfy; - dfx += ddfx; dfy += ddfy; - ddfx += dddfx; ddfy += dddfy; - t += step; + this._dispatchDataEvent('mousemove', e, obj); +}; - if (t > 1) { - fx = dfx > 0 ? Math.min(fx, x3) : Math.max(fx, x3); - fy = dfy > 0 ? Math.min(fy, y3) : Math.max(fy, y3); - } - } +LayerGL.prototype.onmouseup = function (e) { + if (e.target && e.target.__isGLToZRProxy) { + return; + } - this.addPolyline(points, color, lineWidth); - }, + e = e.event; + var obj = this.pickObject(e.offsetX, e.offsetY); - /** - * Add a straight line - * @param {Array.} p0 - * @param {Array.} p1 - * @param {Array.} color - * @param {number} [lineWidth=1] - */ - addLine: function (p0, p1, color, lineWidth) { - this.addPolyline([p0, p1], color, lineWidth); - }, + if (obj) { + this._dispatchEvent('mouseup', e, obj); + this._dispatchDataEvent('mouseup', e, obj); + } - /** - * Add a straight line - * @param {Array. | Array.} points - * @param {Array. | Array.} color - * @param {number} [lineWidth=1] - * @param {number} [arrayOffset=0] - * @param {number} [pointsCount] Default to be amount of points in the first argument - */ - addPolyline: (function () { - var dirA = vec2.create(); - var dirB = vec2.create(); - var normal = vec2.create(); - var tangent = vec2.create(); - var point = [], nextPoint = [], prevPoint = []; - return function (points, color, lineWidth, arrayOffset, pointsCount) { - if (!points.length) { - return; - } - var is2DArray = typeof points[0] !== 'number'; - if (pointsCount == null) { - pointsCount = is2DArray ? points.length : points.length / 2; - } - if (pointsCount < 2) { - return; - } - if (arrayOffset == null) { - arrayOffset = 0; - } - if (lineWidth == null) { - lineWidth = 1; - } + this._upX = e.offsetX; + this._upY = e.offsetY; +}; - this._itemVertexOffsets.push(this._vertexOffset); +LayerGL.prototype.onclick = LayerGL.prototype.dblclick = function (e) { + if (e.target && e.target.__isGLToZRProxy) { + return; + } - var notSharingColor = is2DArray - ? typeof color[0] !== 'number' - : color.length / 4 === pointsCount; + // Ignore click event if mouse moved + var dx = this._upX - this._downX; + var dy = this._upY - this._downY; + if (Math.sqrt(dx * dx + dy * dy) > 20) { + return; + } - var positionAttr = this.attributes.position; - var colorAttr = this.attributes.color; - var offsetAttr = this.attributes.offset; - var normalAttr = this.attributes.normal; - var indices = this.indices; + e = e.event; + var obj = this.pickObject(e.offsetX, e.offsetY); - var vertexOffset = this._vertexOffset; - var pointColor; - for (var k = 0; k < pointsCount; k++) { - if (is2DArray) { - point = points[k + arrayOffset]; - if (notSharingColor) { - pointColor = color[k + arrayOffset]; - } - else { - pointColor = color; - } - } - else { - var k2 = k * 2 + arrayOffset; - point = point || []; - point[0] = points[k2]; - point[1] = points[k2 + 1]; + if (obj) { + this._dispatchEvent(e.type, e, obj); + this._dispatchDataEvent(e.type, e, obj); + } - if (notSharingColor) { - var k4 = k * 4 + arrayOffset; - pointColor = pointColor || []; - pointColor[0] = color[k4]; - pointColor[1] = color[k4 + 1]; - pointColor[2] = color[k4 + 2]; - pointColor[3] = color[k4 + 3]; - } - else { - pointColor = color; - } - } - if (!this.useNativeLine) { - var offset; - if (k < pointsCount - 1) { - if (is2DArray) { - vec2.copy(nextPoint, points[k + 1]); - } - else { - var k2 = (k + 1) * 2 + arrayOffset; - nextPoint = nextPoint || []; - nextPoint[0] = points[k2]; - nextPoint[1] = points[k2 + 1]; - } - // TODO In case dir is (0, 0) - // TODO miterLimit - if (k > 0) { - vec2.sub(dirA, point, prevPoint); - vec2.sub(dirB, nextPoint, point); - vec2.normalize(dirA, dirA); - vec2.normalize(dirB, dirB); - vec2.add(tangent, dirA, dirB); - vec2.normalize(tangent, tangent); - var miter = lineWidth / 2 * Math.min(1 / vec2.dot(dirA, tangent), 2); - normal[0] = -tangent[1]; - normal[1] = tangent[0]; + // Try set depth of field onclick + var result = this._clickToSetFocusPoint(e); + if (result) { + var success = result.view.setDOFFocusOnPoint(result.distance); + if (success) { + this.zr.refresh(); + } + } +}; - offset = miter; - } - else { - vec2.sub(dirA, nextPoint, point); - vec2.normalize(dirA, dirA); +LayerGL.prototype._clickToSetFocusPoint = function (e) { + var renderer = this.renderer; + var oldViewport = renderer.viewport; + for (var i = this.views.length - 1; i >= 0; i--) { + var viewGL = this.views[i]; + if (viewGL.hasDOF() && viewGL.containPoint(e.offsetX, e.offsetY)) { + this._picking.scene = viewGL.scene; + this._picking.camera = viewGL.camera; + // Only used for picking, renderer.setViewport will also invoke gl.viewport. + // Set directly, PENDING. + renderer.viewport = viewGL.viewport; + var result = this._picking.pick(e.offsetX, e.offsetY, true); + if (result) { + result.view = viewGL; + return result; + } + } + } + renderer.viewport = oldViewport; +}; - normal[0] = -dirA[1]; - normal[1] = dirA[0]; +LayerGL.prototype.onglobalout = function (e) { + var lastHovered = this._hovered; + if (lastHovered) { + this._dispatchEvent('mouseout', e, { + target: lastHovered.target + }); + } +}; - offset = lineWidth / 2; - } +LayerGL.prototype.pickObject = function (x, y) { - } - else { - vec2.sub(dirA, point, prevPoint); - vec2.normalize(dirA, dirA); + var output = []; + var renderer = this.renderer; + var oldViewport = renderer.viewport; + for (var i = 0; i < this.views.length; i++) { + var viewGL = this.views[i]; + if (viewGL.containPoint(x, y)) { + this._picking.scene = viewGL.scene; + this._picking.camera = viewGL.camera; + // Only used for picking, renderer.setViewport will also invoke gl.viewport. + // Set directly, PENDING. + renderer.viewport = viewGL.viewport; + this._picking.pickAll(x, y, output); + } + } + renderer.viewport = oldViewport; + output.sort(function (a, b) { + return a.distance - b.distance; + }); + return output[0]; +}; - normal[0] = -dirA[1]; - normal[1] = dirA[0]; +LayerGL.prototype._dispatchEvent = function (eveName, originalEvent, newEvent) { + if (!newEvent) { + newEvent = {}; + } + var current = newEvent.target; - offset = lineWidth / 2; - } - normalAttr.set(vertexOffset, normal); - normalAttr.set(vertexOffset + 1, normal); - offsetAttr.set(vertexOffset, offset); - offsetAttr.set(vertexOffset + 1, -offset); + newEvent.cancelBubble = false; + newEvent.event = originalEvent; + newEvent.type = eveName; + newEvent.offsetX = originalEvent.offsetX; + newEvent.offsetY = originalEvent.offsetY; - vec2.copy(prevPoint, point); + while (current) { + current.trigger(eveName, newEvent); + current = current.getParent(); - positionAttr.set(vertexOffset, point); - positionAttr.set(vertexOffset + 1, point); + if (newEvent.cancelBubble) { + break; + } + } - colorAttr.set(vertexOffset, pointColor); - colorAttr.set(vertexOffset + 1, pointColor); + this._dispatchToView(eveName, newEvent); +}; - vertexOffset += 2; - } - else { - if (k > 1) { - positionAttr.copy(vertexOffset, vertexOffset - 1); - colorAttr.copy(vertexOffset, vertexOffset - 1); - vertexOffset++; - } - } +LayerGL.prototype._dispatchDataEvent = function (eveName, originalEvent, newEvent) { + var mesh = newEvent && newEvent.target; - if (!this.useNativeLine) { - if (k > 0) { - var idx3 = this._faceOffset * 3; - var indices = this.indices; - // 0-----2 - // 1-----3 - // 0->1->2, 1->3->2 - indices[idx3] = vertexOffset - 4; - indices[idx3 + 1] = vertexOffset - 3; - indices[idx3 + 2] = vertexOffset - 2; + var dataIndex = mesh && mesh.dataIndex; + var seriesIndex = mesh && mesh.seriesIndex; + // Custom event data + var eventData = mesh && mesh.eventData; + var elChangedInMouseMove = false; - indices[idx3 + 3] = vertexOffset - 3; - indices[idx3 + 4] = vertexOffset - 1; - indices[idx3 + 5] = vertexOffset - 2; + var eventProxy = this._zrEventProxy; + eventProxy.position = [originalEvent.offsetX, originalEvent.offsetY]; + eventProxy.update(); - this._faceOffset += 2; - } + var targetInfo = { + target: eventProxy + }; + if (eveName === 'mousemove') { + if (dataIndex != null) { + if (dataIndex !== this._lastDataIndex) { + if (parseInt(this._lastDataIndex, 10) >= 0) { + eventProxy.dataIndex = this._lastDataIndex; + eventProxy.seriesIndex = this._lastSeriesIndex; + // FIXME May cause double events. + this.zr.handler.dispatchToElement(targetInfo, 'mouseout', originalEvent); } - else { - colorAttr.set(vertexOffset, pointColor); - positionAttr.set(vertexOffset, point); - vertexOffset++; + elChangedInMouseMove = true; + } + } + else if (eventData != null) { + if (eventData !== this._lastEventData) { + if (this._lastEventData != null) { + eventProxy.eventData = this._lastEventData; + // FIXME May cause double events. + this.zr.handler.dispatchToElement(targetInfo, 'mouseout', originalEvent); } + elChangedInMouseMove = true; } + } + this._lastEventData = eventData; + this._lastDataIndex = dataIndex; + this._lastSeriesIndex = seriesIndex; + } - this._vertexOffset = vertexOffset; - }; - })(), + eventProxy.eventData = eventData; + eventProxy.dataIndex = dataIndex; + eventProxy.seriesIndex = seriesIndex; - /** - * Set color of single line. - */ - setItemColor: function (idx, color) { - var startOffset = this._itemVertexOffsets[idx]; - var endOffset = idx < this._itemVertexOffsets.length - 1 ? this._itemVertexOffsets[idx + 1] : this._vertexOffset; + if (eventData != null || (parseInt(dataIndex, 10) >= 0 && parseInt(seriesIndex, 10) >= 0)) { + this.zr.handler.dispatchToElement(targetInfo, eveName, originalEvent); - for (var i = startOffset; i < endOffset; i++) { - this.attributes.color.set(i, color); + if (elChangedInMouseMove) { + this.zr.handler.dispatchToElement(targetInfo, 'mouseover', originalEvent); + } + } +}; + +LayerGL.prototype._dispatchToView = function (eventName, e) { + for (var i = 0; i < this.views.length; i++) { + if (this.views[i].containPoint(e.offsetX, e.offsetY)) { + this.views[i].trigger(eventName, e); } - this.dirty('color'); } -}); +}; -__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.util.defaults(LinesGeometry.prototype, __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__["a" /* default */]); +__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.extend(LayerGL.prototype, __WEBPACK_IMPORTED_MODULE_5_claygl_src_core_mixin_notifier__["a" /* default */]); -/* harmony default export */ __webpack_exports__["a"] = (LinesGeometry); +/* harmony default export */ __webpack_exports__["a"] = (LayerGL); /***/ }), -/* 99 */ +/* 110 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_echarts_gl__ = __webpack_require__(100); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_component_grid3D__ = __webpack_require__(146); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_component_geo3D__ = __webpack_require__(193); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_component_globe__ = __webpack_require__(199); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_component_mapbox3D__ = __webpack_require__(205); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_component_maptalks3D__ = __webpack_require__(211); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_chart_bar3D__ = __webpack_require__(217); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_chart_line3D__ = __webpack_require__(224); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_chart_scatter3D__ = __webpack_require__(228); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_chart_lines3D__ = __webpack_require__(235); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__src_chart_polygons3D__ = __webpack_require__(241); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__src_chart_surface__ = __webpack_require__(244); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__src_chart_map3D__ = __webpack_require__(248); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__src_chart_scatterGL__ = __webpack_require__(251); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__src_chart_graphGL__ = __webpack_require__(254); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__src_chart_flowGL__ = __webpack_require__(267); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__src_chart_linesGL__ = __webpack_require__(273); - - - +/** + * Extend a sub class from base class + * @param {object|Function} makeDefaultOpt default option of this sub class, method of the sub can use this.xxx to access this option + * @param {Function} [initialize] Initialize after the sub class is instantiated + * @param {Object} [proto] Prototype methods/properties of the sub class + * @memberOf clay.core.mixin.extend + * @return {Function} + */ +function derive(makeDefaultOpt, initialize/*optional*/, proto/*optional*/) { + if (typeof initialize == 'object') { + proto = initialize; + initialize = null; + } + var _super = this; + var propList; + if (!(makeDefaultOpt instanceof Function)) { + // Optimize the property iterate if it have been fixed + propList = []; + for (var propName in makeDefaultOpt) { + if (makeDefaultOpt.hasOwnProperty(propName)) { + propList.push(propName); + } + } + } + var sub = function(options) { + // call super constructor + _super.apply(this, arguments); + if (makeDefaultOpt instanceof Function) { + // Invoke makeDefaultOpt each time if it is a function, So we can make sure each + // property in the object will not be shared by mutiple instances + extend(this, makeDefaultOpt.call(this, options)); + } + else { + extendWithPropList(this, makeDefaultOpt, propList); + } + if (this.constructor === sub) { + // Initialize function will be called in the order of inherit + var initializers = sub.__initializers__; + for (var i = 0; i < initializers.length; i++) { + initializers[i].apply(this, arguments); + } + } + }; + // save super constructor + sub.__super__ = _super; + // Initialize function will be called after all the super constructor is called + if (!_super.__initializers__) { + sub.__initializers__ = []; + } else { + sub.__initializers__ = _super.__initializers__.slice(); + } + if (initialize) { + sub.__initializers__.push(initialize); + } + var Ctor = function() {}; + Ctor.prototype = _super.prototype; + sub.prototype = new Ctor(); + sub.prototype.constructor = sub; + extend(sub.prototype, proto); + // extend the derive method as a static method; + sub.extend = _super.extend; + // DEPCRATED + sub.derive = _super.extend; + return sub; +} +function extend(target, source) { + if (!source) { + return; + } + for (var name in source) { + if (source.hasOwnProperty(name)) { + target[name] = source[name]; + } + } +} +function extendWithPropList(target, source, propList) { + for (var i = 0; i < propList.length; i++) { + var propName = propList[i]; + target[propName] = source[propName]; + } +} +/** + * @alias clay.core.mixin.extend + * @mixin + */ +/* harmony default export */ __webpack_exports__["a"] = ({ + extend: derive, + // DEPCRATED + derive: derive +}); /***/ }), -/* 100 */ +/* 111 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_version__ = __webpack_require__(101); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_LayerGL__ = __webpack_require__(102); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__preprocessor_backwardCompat__ = __webpack_require__(145); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_graphicGL__ = __webpack_require__(2); -/** - * echarts-gl - * Extension pack of ECharts providing 3d plots and globe visualization - * - * Copyright (c) 2014, echarts-gl - * 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 HOLDER 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 USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @module echarts-gl - * @author Yi Shen(http://github.com/pissang) - */ - -// PENDING Use a single canvas as layer or use image element? -var echartsGl = { - version: '1.1.0', - dependencies: { - echarts: '4.0.3', - claygl: '1.1.0' - } -}; - - - +var EXTENSION_LIST = [ + 'OES_texture_float', + 'OES_texture_half_float', + 'OES_texture_float_linear', + 'OES_texture_half_float_linear', + 'OES_standard_derivatives', + 'OES_vertex_array_object', + 'OES_element_index_uint', + 'WEBGL_compressed_texture_s3tc', + 'WEBGL_depth_texture', + 'EXT_texture_filter_anisotropic', + 'EXT_shader_texture_lod', + 'WEBGL_draw_buffers', + 'EXT_frag_depth', + 'EXT_sRGB' +]; +var PARAMETER_NAMES = [ + 'MAX_TEXTURE_SIZE', + 'MAX_CUBE_MAP_TEXTURE_SIZE' +]; +function GLInfo(_gl) { + var extensions = {}; + var parameters = {}; -// Version checking -var deps = echartsGl.dependencies; -function versionTooOldMsg(name) { - throw new Error( - name + ' version is too old, needs ' + deps[name] + ' or higher' - ); -} -function checkVersion(version, name) { - if ((version.replace('.', '') - 0) < (deps[name].replace('.', '') - 0)) { - versionTooOldMsg(name); + // Get webgl extension + for (var i = 0; i < EXTENSION_LIST.length; i++) { + var extName = EXTENSION_LIST[i]; + createExtension(extName); } - console.log('Loaded ' + name + ', version ' + version); -} -checkVersion(__WEBPACK_IMPORTED_MODULE_1_claygl_src_version__["a" /* default */], 'claygl'); -checkVersion(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.version, 'echarts'); - -function EChartsGL (zr) { - this._layers = {}; - - this._zr = zr; -} - -EChartsGL.prototype.update = function (ecModel, api) { - var self = this; - var zr = api.getZr(); - - if (!zr.getWidth() || !zr.getHeight()) { - console.warn('Dom has no width or height'); - return; + // Get parameters + for (var i = 0; i < PARAMETER_NAMES.length; i++) { + var name = PARAMETER_NAMES[i]; + parameters[name] = _gl.getParameter(_gl[name]); } - function getLayerGL(model) { - var zlevel; - // Host on coordinate system. - if (model.coordinateSystem && model.coordinateSystem.model) { - zlevel = model.get('zlevel'); - } - else { - zlevel = model.get('zlevel'); + this.getExtension = function (name) { + if (!(name in extensions)) { + createExtension(name); } + return extensions[name]; + }; - var layers = self._layers; - var layerGL = layers[zlevel]; - if (!layerGL) { - layerGL = layers[zlevel] = new __WEBPACK_IMPORTED_MODULE_2__core_LayerGL__["a" /* default */]('gl-' + zlevel, zr); - - if (zr.painter.isSingleCanvas()) { - layerGL.virtual = true; - // If container is canvas, use image to represent LayerGL - // FIXME Performance - var img = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.Image({ - z: 1e4, - style: { - image: layerGL.renderer.canvas - }, - silent: true - }); - layerGL.__hostImage = img; + this.getParameter = function (name) { + return parameters[name]; + }; - zr.add(img); - } + this.getMaxJointNumber = function () { + return 15; + }; - zr.painter.insertLayer(zlevel, layerGL); + function createExtension(name) { + var ext = _gl.getExtension(name); + if (!ext) { + ext = _gl.getExtension('MOZ_' + name); } - if (layerGL.__hostImage) { - layerGL.__hostImage.setStyle({ - width: layerGL.renderer.getWidth(), - height: layerGL.renderer.getHeight() - }); + if (!ext) { + ext = _gl.getExtension('WEBKIT_' + name); } - - return layerGL; + extensions[name] = ext; } +} - function setSilent(groupGL, silent) { - if (groupGL) { - groupGL.traverse(function (mesh) { - if (mesh.isRenderable && mesh.isRenderable()) { - mesh.ignorePicking = mesh.$ignorePicking != null - ? mesh.$ignorePicking : silent; - } - }); - } - } +/* harmony default export */ __webpack_exports__["a"] = (GLInfo); - for (var zlevel in this._layers) { - this._layers[zlevel].removeViewsAll(); - } - ecModel.eachComponent(function (componentType, componentModel) { - if (componentType !== 'series') { - var view = api.getViewOfComponentModel(componentModel); - var coordSys = componentModel.coordinateSystem; - // View with __ecgl__ flag is a echarts-gl component. - if (view.__ecgl__) { - var viewGL; - if (coordSys) { - if (!coordSys.viewGL) { - console.error('Can\'t find viewGL in coordinateSystem of component ' + componentModel.id); - return; - } - viewGL = coordSys.viewGL; - } - else { - if (!componentModel.viewGL) { - console.error('Can\'t find viewGL of component ' + componentModel.id); - return; - } - viewGL = coordSys.viewGL; - } +/***/ }), +/* 112 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - var viewGL = coordSys.viewGL; - var layerGL = getLayerGL(componentModel); +"use strict"; +function get(options) { - layerGL.addView(viewGL); + var xhr = new XMLHttpRequest(); - view.afterRender && view.afterRender( - componentModel, ecModel, api, layerGL - ); + xhr.open('get', options.url); + // With response type set browser can get and put binary data + // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Sending_and_Receiving_Binary_Data + // Default is text, and it can be set + // arraybuffer, blob, document, json, text + xhr.responseType = options.responseType || 'text'; - setSilent(view.groupGL, componentModel.get('silent')); + if (options.onprogress) { + //https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest + xhr.onprogress = function(e) { + if (e.lengthComputable) { + var percent = e.loaded / e.total; + options.onprogress(percent, e.loaded, e.total); } - } - }); - - ecModel.eachSeries(function (seriesModel) { - var chartView = api.getViewOfSeriesModel(seriesModel); - var coordSys = seriesModel.coordinateSystem; - if (chartView.__ecgl__) { - if ((coordSys && !coordSys.viewGL) && !chartView.viewGL) { - console.error('Can\'t find viewGL of series ' + chartView.id); - return; + else { + options.onprogress(null); } - var viewGL = (coordSys && coordSys.viewGL) || chartView.viewGL; - // TODO Check zlevel not same with component of coordinate system ? - var layerGL = getLayerGL(seriesModel); - layerGL.addView(viewGL); - - chartView.afterRender && chartView.afterRender( - seriesModel, ecModel, api, layerGL - ); - - setSilent(chartView.groupGL, seriesModel.get('silent')); + }; + } + xhr.onload = function(e) { + if (xhr.status >= 400) { + options.onerror && options.onerror(); } - }); -}; - -// Hack original getRenderedCanvas. Will removed after new echarts released -// TODO -var oldInit = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.init; -__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.init = function () { - var chart = oldInit.apply(this, arguments); - chart.getZr().painter.getRenderedCanvas = function (opts) { - opts = opts || {}; - if (this._singleCanvas) { - return this._layers[0].dom; + else { + options.onload && options.onload(xhr.response); } + }; + if (options.onerror) { + xhr.onerror = options.onerror; + } + xhr.send(null); +} - var canvas = document.createElement('canvas'); - var dpr = opts.pixelRatio || this.dpr; - canvas.width = this.getWidth() * dpr; - canvas.height = this.getHeight() * dpr; - var ctx = canvas.getContext('2d'); - ctx.dpr = dpr; - - ctx.clearRect(0, 0, canvas.width, canvas.height); - if (opts.backgroundColor) { - ctx.fillStyle = opts.backgroundColor; - ctx.fillRect(0, 0, canvas.width, canvas.height); - } +/* harmony default export */ __webpack_exports__["a"] = ({ + get: get +}); - var displayList = this.storage.getDisplayList(true); - var scope = {}; - var zlevel; +/***/ }), +/* 113 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - var self = this; - function findAndDrawOtherLayer(smaller, larger) { - var zlevelList = self._zlevelList; - if (smaller == null) { - smaller = -Infinity; - } - var intermediateLayer; - for (var i = 0; i < zlevelList.length; i++) { - var z = zlevelList[i]; - var layer = self._layers[z]; - if (!layer.__builtin__ && z > smaller && z < larger) { - intermediateLayer = layer; - break; - } - } - if (intermediateLayer && intermediateLayer.renderToCanvas) { - ctx.save(); - intermediateLayer.renderToCanvas(ctx); - ctx.restore(); - } - } - var layer = { - ctx: ctx - }; - for (var i = 0; i < displayList.length; i++) { - var el = displayList[i]; +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_LRU__ = __webpack_require__(69); +/** + * @namespace clay.core.color + */ - if (el.zlevel !== zlevel) { - findAndDrawOtherLayer(zlevel, el.zlevel); - zlevel = el.zlevel; - } - this._doPaintEl(el, layer, true, scope); - } - findAndDrawOtherLayer(zlevel, Infinity); +var colorUtil = {}; - return canvas; - }; - return chart; +var kCSSColorTable = { + 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1], + 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1], + 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1], + 'beige': [245,245,220,1], 'bisque': [255,228,196,1], + 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1], + 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1], + 'brown': [165,42,42,1], 'burlywood': [222,184,135,1], + 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1], + 'chocolate': [210,105,30,1], 'coral': [255,127,80,1], + 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1], + 'crimson': [220,20,60,1], 'cyan': [0,255,255,1], + 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1], + 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1], + 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1], + 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1], + 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1], + 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1], + 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1], + 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1], + 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1], + 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1], + 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1], + 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1], + 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1], + 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1], + 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1], + 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1], + 'gray': [128,128,128,1], 'green': [0,128,0,1], + 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1], + 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1], + 'indianred': [205,92,92,1], 'indigo': [75,0,130,1], + 'ivory': [255,255,240,1], 'khaki': [240,230,140,1], + 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1], + 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1], + 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1], + 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1], + 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1], + 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1], + 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1], + 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1], + 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1], + 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1], + 'limegreen': [50,205,50,1], 'linen': [250,240,230,1], + 'magenta': [255,0,255,1], 'maroon': [128,0,0,1], + 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1], + 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1], + 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1], + 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1], + 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1], + 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1], + 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1], + 'navy': [0,0,128,1], 'oldlace': [253,245,230,1], + 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1], + 'orange': [255,165,0,1], 'orangered': [255,69,0,1], + 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1], + 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1], + 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1], + 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1], + 'pink': [255,192,203,1], 'plum': [221,160,221,1], + 'powderblue': [176,224,230,1], 'purple': [128,0,128,1], + 'red': [255,0,0,1], 'rosybrown': [188,143,143,1], + 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1], + 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1], + 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1], + 'sienna': [160,82,45,1], 'silver': [192,192,192,1], + 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1], + 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1], + 'snow': [255,250,250,1], 'springgreen': [0,255,127,1], + 'steelblue': [70,130,180,1], 'tan': [210,180,140,1], + 'teal': [0,128,128,1], 'thistle': [216,191,216,1], + 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1], + 'violet': [238,130,238,1], 'wheat': [245,222,179,1], + 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1], + 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1] }; +function clampCssByte(i) { // Clamp to integer 0 .. 255. + i = Math.round(i); // Seems to be what Chrome does (vs truncation). + return i < 0 ? 0 : i > 255 ? 255 : i; +} -__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerPostUpdate(function (ecModel, api) { - var zr = api.getZr(); - - var egl = zr.__egl = zr.__egl || new EChartsGL(zr); +function clampCssAngle(i) { // Clamp to integer 0 .. 360. + i = Math.round(i); // Seems to be what Chrome does (vs truncation). + return i < 0 ? 0 : i > 360 ? 360 : i; +} - egl.update(ecModel, api); -}); +function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0. + return f < 0 ? 0 : f > 1 ? 1 : f; +} -__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerPreprocessor(__WEBPACK_IMPORTED_MODULE_3__preprocessor_backwardCompat__["a" /* default */]); +function parseCssInt(str) { // int or percentage. + if (str.length && str.charAt(str.length - 1) === '%') { + return clampCssByte(parseFloat(str) / 100 * 255); + } + return clampCssByte(parseInt(str, 10)); +} -__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphicGL = __WEBPACK_IMPORTED_MODULE_4__util_graphicGL__["a" /* default */]; +function parseCssFloat(str) { // float or percentage. + if (str.length && str.charAt(str.length - 1) === '%') { + return clampCssFloat(parseFloat(str) / 100); + } + return clampCssFloat(parseFloat(str)); +} -/* unused harmony default export */ var _unused_webpack_default_export = (EChartsGL); +function cssHueToRgb(m1, m2, h) { + if (h < 0) { + h += 1; + } + else if (h > 1) { + h -= 1; + } -/***/ }), -/* 101 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + if (h * 6 < 1) { + return m1 + (m2 - m1) * h * 6; + } + if (h * 2 < 1) { + return m2; + } + if (h * 3 < 2) { + return m1 + (m2 - m1) * (2/3 - h) * 6; + } + return m1; +} -"use strict"; -/** - * @name clay.version - */ -/* harmony default export */ __webpack_exports__["a"] = ('1.1.0'); +function lerpNumber(a, b, p) { + return a + (b - a) * p; +} +function setRgba(out, r, g, b, a) { + out[0] = r; out[1] = g; out[2] = b; out[3] = a; + return out; +} +function copyRgba(out, a) { + out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3]; + return out; +} -/***/ }), -/* 102 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +var colorCache = new __WEBPACK_IMPORTED_MODULE_0__core_LRU__["a" /* default */](20); +var lastRemovedArr = null; + +function putToCache(colorStr, rgbaArr) { + // Reuse removed array + if (lastRemovedArr) { + copyRgba(lastRemovedArr, rgbaArr); + } + lastRemovedArr = colorCache.put(colorStr, lastRemovedArr || (rgbaArr.slice())); +} -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Renderer__ = __webpack_require__(46); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_picking_RayPicking__ = __webpack_require__(111); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_core_mixin_notifier__ = __webpack_require__(47); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_zrender_lib_animation_requestAnimationFrame__ = __webpack_require__(72); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_zrender_lib_animation_requestAnimationFrame___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_zrender_lib_animation_requestAnimationFrame__); /** - * Provide WebGL layer to zrender. Which is rendered on top of clay. - * - * - * Relationship between zrender, LayerGL(renderer) and ViewGL(Scene, Camera, Viewport) - * zrender - * / \ - * LayerGL LayerGL - * (renderer) (renderer) - * / \ - * ViewGL ViewGL - * - * @module echarts-gl/core/LayerGL - * @author Yi Shen(http://github.com/pissang) + * @name clay.core.color.parse + * @param {string} colorStr + * @param {Array.} out + * @return {Array.} */ +colorUtil.parse = function (colorStr, rgbaArr) { + if (!colorStr) { + return; + } + rgbaArr = rgbaArr || []; + var cached = colorCache.get(colorStr); + if (cached) { + return copyRgba(rgbaArr, cached); + } + // colorStr may be not string + colorStr = colorStr + ''; + // Remove all whitespace, not compliant, but should just be more accepting. + var str = colorStr.replace(/ /g, '').toLowerCase(); + // Color keywords (and transparent) lookup. + if (str in kCSSColorTable) { + copyRgba(rgbaArr, kCSSColorTable[str]); + putToCache(colorStr, rgbaArr); + return rgbaArr; + } + // #abc and #abc123 syntax. + if (str.charAt(0) === '#') { + if (str.length === 4) { + var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. + if (!(iv >= 0 && iv <= 0xfff)) { + setRgba(rgbaArr, 0, 0, 0, 1); + return; // Covers NaN. + } + setRgba(rgbaArr, + ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8), + (iv & 0xf0) | ((iv & 0xf0) >> 4), + (iv & 0xf) | ((iv & 0xf) << 4), + 1 + ); + putToCache(colorStr, rgbaArr); + return rgbaArr; + } + else if (str.length === 7) { + var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. + if (!(iv >= 0 && iv <= 0xffffff)) { + setRgba(rgbaArr, 0, 0, 0, 1); + return; // Covers NaN. + } + setRgba(rgbaArr, + (iv & 0xff0000) >> 16, + (iv & 0xff00) >> 8, + iv & 0xff, + 1 + ); + putToCache(colorStr, rgbaArr); + return rgbaArr; + } + return; + } + var op = str.indexOf('('), ep = str.indexOf(')'); + if (op !== -1 && ep + 1 === str.length) { + var fname = str.substr(0, op); + var params = str.substr(op + 1, ep - (op + 1)).split(','); + var alpha = 1; // To allow case fallthrough. + switch (fname) { + case 'rgba': + if (params.length !== 4) { + setRgba(rgbaArr, 0, 0, 0, 1); + return; + } + alpha = parseCssFloat(params.pop()); // jshint ignore:line + // Fall through. + case 'rgb': + if (params.length !== 3) { + setRgba(rgbaArr, 0, 0, 0, 1); + return; + } + setRgba(rgbaArr, + parseCssInt(params[0]), + parseCssInt(params[1]), + parseCssInt(params[2]), + alpha + ); + putToCache(colorStr, rgbaArr); + return rgbaArr; + case 'hsla': + if (params.length !== 4) { + setRgba(rgbaArr, 0, 0, 0, 1); + return; + } + params[3] = parseCssFloat(params[3]); + hsla2rgba(params, rgbaArr); + putToCache(colorStr, rgbaArr); + return rgbaArr; + case 'hsl': + if (params.length !== 3) { + setRgba(rgbaArr, 0, 0, 0, 1); + return; + } + hsla2rgba(params, rgbaArr); + putToCache(colorStr, rgbaArr); + return rgbaArr; + default: + return; + } + } + setRgba(rgbaArr, 0, 0, 0, 1); + return; +}; -// PENDING, clay. notifier is same with zrender Eventful - - +colorUtil.parseToFloat = function (colorStr, rgbaArr) { + rgbaArr = colorUtil.parse(colorStr, rgbaArr); + if (!rgbaArr) { + return; + } + rgbaArr[0] /= 255; + rgbaArr[1] /= 255; + rgbaArr[2] /= 255; + return rgbaArr; +} /** - * @constructor - * @alias module:echarts-gl/core/LayerGL - * @param {string} id Layer ID - * @param {module:zrender/ZRender} zr + * @name clay.core.color.hsla2rgba + * @param {Array.} hsla + * @param {Array.} rgba + * @return {Array.} rgba */ -var LayerGL = function (id, zr) { - - /** - * Layer ID - * @type {string} - */ - this.id = id; +function hsla2rgba(hsla, rgba) { + var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1 + // NOTE(deanm): According to the CSS spec s/l should only be + // percentages, but we don't bother and let float or percentage. + var s = parseCssFloat(hsla[1]); + var l = parseCssFloat(hsla[2]); + var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; + var m1 = l * 2 - m2; - /** - * @type {module:zrender/ZRender} - */ - this.zr = zr; + rgba = rgba || []; + setRgba(rgba, + clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255), + clampCssByte(cssHueToRgb(m1, m2, h) * 255), + clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255), + 1 + ); - /** - * @type {clay.Renderer} - */ - try { - this.renderer = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Renderer__["a" /* default */]({ - clearBit: 0, - devicePixelRatio: zr.painter.dpr, - preserveDrawingBuffer: true, - // PENDING - premultipliedAlpha: true - }); - this.renderer.resize(zr.painter.getWidth(), zr.painter.getHeight()); + if (hsla.length === 4) { + rgba[3] = hsla[3]; } - catch (e) { - this.renderer = null; - this.dom = document.createElement('div'); - this.dom.style.cssText = 'position:absolute; left: 0; top: 0; right: 0; bottom: 0;'; - this.dom.className = 'ecgl-nowebgl'; - this.dom.innerHTML = 'Sorry, your browser does support WebGL'; - console.error(e); + return rgba; +} + +/** + * @name clay.core.color.rgba2hsla + * @param {Array.} rgba + * @return {Array.} hsla + */ +function rgba2hsla(rgba) { + if (!rgba) { return; } - this.onglobalout = this.onglobalout.bind(this); - zr.on('globalout', this.onglobalout); + // RGB from 0 to 255 + var R = rgba[0] / 255; + var G = rgba[1] / 255; + var B = rgba[2] / 255; - /** - * Canvas dom for webgl rendering - * @type {HTMLCanvasElement} - */ - this.dom = this.renderer.canvas; - var style = this.dom.style; - style.position = 'absolute'; - style.left = '0'; - style.top = '0'; + var vMin = Math.min(R, G, B); // Min. value of RGB + var vMax = Math.max(R, G, B); // Max. value of RGB + var delta = vMax - vMin; // Delta RGB value - /** - * @type {Array.} - */ - this.views = []; + var L = (vMax + vMin) / 2; + var H; + var S; + // HSL results from 0 to 1 + if (delta === 0) { + H = 0; + S = 0; + } + else { + if (L < 0.5) { + S = delta / (vMax + vMin); + } + else { + S = delta / (2 - vMax - vMin); + } - this._picking = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_picking_RayPicking__["a" /* default */]({ - renderer: this.renderer - }); + var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta; + var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta; + var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta; - this._viewsToDispose = []; + if (R === vMax) { + H = deltaB - deltaG; + } + else if (G === vMax) { + H = (1 / 3) + deltaR - deltaB; + } + else if (B === vMax) { + H = (2 / 3) + deltaG - deltaR; + } - /** - * Current accumulating id. - */ - this._accumulatingId = 0; + if (H < 0) { + H += 1; + } - this._zrEventProxy = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.Rect({ - shape: {x: -1, y: -1, width: 2, height: 2}, - // FIXME Better solution. - __isGLToZRProxy: true - }); + if (H > 1) { + H -= 1; + } + } - this._backgroundColor = null; -}; + var hsla = [H * 360, S, L]; -/** - * @param {module:echarts-gl/core/ViewGL} view - */ -LayerGL.prototype.addView = function (view) { - if (view.layer === this) { - return; - } - // If needs to dispose in this layer. unmark it. - var idx = this._viewsToDispose.indexOf(view); - if (idx >= 0) { - this._viewsToDispose.splice(idx, 1); + if (rgba[3] != null) { + hsla.push(rgba[3]); } - this.views.push(view); - - view.layer = this; + return hsla; +} - var zr = this.zr; - view.scene.traverse(function (node) { - node.__zr = zr; - if (node.addAnimatorsToZr) { - node.addAnimatorsToZr(zr); +/** + * @name clay.core.color.lift + * @param {string} color + * @param {number} level + * @return {string} + */ +colorUtil.lift = function (color, level) { + var colorArr = colorUtil.parse(color); + if (colorArr) { + for (var i = 0; i < 3; i++) { + if (level < 0) { + colorArr[i] = colorArr[i] * (1 - level) | 0; + } + else { + colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0; + } } - }); -}; - -function removeFromZr(node) { - var zr = node.__zr; - node.__zr = null; - if (zr && node.removeAnimatorsFromZr) { - node.removeAnimatorsFromZr(zr); + return colorUtil.stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb'); } } + /** - * @param {module:echarts-gl/core/ViewGL} view + * @name clay.core.color.toHex + * @param {string} color + * @return {string} */ -LayerGL.prototype.removeView = function (view) { - if (view.layer !== this) { - return; - } - - var idx = this.views.indexOf(view); - if (idx >= 0) { - this.views.splice(idx, 1); - view.scene.traverse(removeFromZr, this); - view.layer = null; - - // Mark to dispose in this layer. - this._viewsToDispose.push(view); +colorUtil.toHex = function (color) { + var colorArr = colorUtil.parse(color); + if (colorArr) { + return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1); } }; /** - * Remove all views + * Map value to color. Faster than lerp methods because color is represented by rgba array. + * @name clay.core.color + * @param {number} normalizedValue A float between 0 and 1. + * @param {Array.>} colors List of rgba color array + * @param {Array.} [out] Mapped gba color array + * @return {Array.} will be null/undefined if input illegal. */ -LayerGL.prototype.removeViewsAll = function () { - this.views.forEach(function (view) { - view.scene.traverse(removeFromZr, this); - view.layer = null; +colorUtil.fastLerp = function (normalizedValue, colors, out) { + if (!(colors && colors.length) + || !(normalizedValue >= 0 && normalizedValue <= 1) + ) { + return; + } - // Mark to dispose in this layer. - this._viewsToDispose.push(view); - }, this); + out = out || []; - this.views.length = 0; + var value = normalizedValue * (colors.length - 1); + var leftIndex = Math.floor(value); + var rightIndex = Math.ceil(value); + var leftColor = colors[leftIndex]; + var rightColor = colors[rightIndex]; + var dv = value - leftIndex; + out[0] = clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv)); + out[1] = clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv)); + out[2] = clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv)); + out[3] = clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv)); -}; + return out; +} -/** - * Resize the canvas and viewport, will be invoked by zrender - * @param {number} width - * @param {number} height - */ -LayerGL.prototype.resize = function (width, height) { - var renderer = this.renderer; - renderer.resize(width, height); -}; +colorUtil.fastMapToColor = colorUtil.fastLerp; /** - * Clear color and depth - * @return {[type]} [description] + * @param {number} normalizedValue A float between 0 and 1. + * @param {Array.} colors Color list. + * @param {boolean=} fullOutput Default false. + * @return {(string|Object)} Result color. If fullOutput, + * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...}, */ -LayerGL.prototype.clear = function () { - var gl = this.renderer.gl; - var clearColor = this._backgroundColor || [0, 0, 0, 0]; - gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); - gl.depthMask(true); - gl.colorMask(true, true, true, true); - gl.clear(gl.DEPTH_BUFFER_BIT | gl.COLOR_BUFFER_BIT); -}; +colorUtil.lerp = function (normalizedValue, colors, fullOutput) { + if (!(colors && colors.length) + || !(normalizedValue >= 0 && normalizedValue <= 1) + ) { + return; + } -/** - * Clear depth - */ -LayerGL.prototype.clearDepth = function () { - var gl = this.renderer.gl; - gl.clear(gl.DEPTH_BUFFER_BIT); -}; + var value = normalizedValue * (colors.length - 1); + var leftIndex = Math.floor(value); + var rightIndex = Math.ceil(value); + var leftColor = colorUtil.parse(colors[leftIndex]); + var rightColor = colorUtil.parse(colors[rightIndex]); + var dv = value - leftIndex; + + var color = colorUtil.stringify( + [ + clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv)), + clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv)), + clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv)), + clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv)) + ], + 'rgba' + ); + + return fullOutput + ? { + color: color, + leftIndex: leftIndex, + rightIndex: rightIndex, + value: value + } + : color; +} /** - * Clear color + * @deprecated */ -LayerGL.prototype.clearColor = function () { - var gl = this.renderer.gl; - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); -}; +colorUtil.mapToColor = colorUtil.lerp; /** - * Mark layer to refresh next tick + * @name clay.core.color + * @param {string} color + * @param {number=} h 0 ~ 360, ignore when null. + * @param {number=} s 0 ~ 1, ignore when null. + * @param {number=} l 0 ~ 1, ignore when null. + * @return {string} Color string in rgba format. */ -LayerGL.prototype.needsRefresh = function () { - this.zr.refresh(); -}; +colorUtil.modifyHSL = function (color, h, s, l) { + color = colorUtil.parse(color); + + if (color) { + color = rgba2hsla(color); + h != null && (color[0] = clampCssAngle(h)); + s != null && (color[1] = parseCssFloat(s)); + l != null && (color[2] = parseCssFloat(l)); + + return colorUtil.stringify(hsla2rgba(color), 'rgba'); + } +} /** - * Refresh the layer, will be invoked by zrender + * @param {string} color + * @param {number=} alpha 0 ~ 1 + * @return {string} Color string in rgba format. */ -LayerGL.prototype.refresh = function (bgColor) { +colorUtil.modifyAlpha = function (color, alpha) { + color = colorUtil.parse(color); - this._backgroundColor = bgColor ? __WEBPACK_IMPORTED_MODULE_4__util_graphicGL__["a" /* default */].parseColor(bgColor) : [0, 0, 0, 0]; - this.renderer.clearColor = this._backgroundColor; + if (color && alpha != null) { + color[3] = clampCssFloat(alpha); + return colorUtil.stringify(color, 'rgba'); + } +} - for (var i = 0; i < this.views.length; i++) { - this.views[i].prepareRender(this.renderer); +/** + * @param {Array.} arrColor like [12,33,44,0.4] + * @param {string} type 'rgba', 'hsva', ... + * @return {string} Result color. (If input illegal, return undefined). + */ +colorUtil.stringify = function (arrColor, type) { + if (!arrColor || !arrColor.length) { + return; + } + var colorStr = arrColor[0] + ',' + arrColor[1] + ',' + arrColor[2]; + if (type === 'rgba' || type === 'hsva' || type === 'hsla') { + colorStr += ',' + arrColor[3]; } + return type + '(' + colorStr + ')'; +}; - this._doRender(false); - // Auto dispose unused resources on GPU, like program(shader), texture, geometry(buffers) - this._trackAndClean(); - // Dispose trashed views - for (var i = 0; i < this._viewsToDispose.length; i++) { - this._viewsToDispose[i].dispose(this.renderer); - } - this._viewsToDispose.length = 0; +/* harmony default export */ __webpack_exports__["a"] = (colorUtil); - this._startAccumulating(); -}; +/***/ }), +/* 114 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +/** + * Simple double linked list. Compared with array, it has O(1) remove operation. + * @constructor + * @alias clay.core.LinkedList + */ +var LinkedList = function () { -LayerGL.prototype.renderToCanvas = function (ctx) { - // PENDING will block the page - this._startAccumulating(true); - ctx.drawImage(this.dom, 0, 0, ctx.canvas.width, ctx.canvas.height); -}; + /** + * @type {clay.core.LinkedList.Entry} + */ + this.head = null; -LayerGL.prototype._doRender = function (accumulating) { - this.clear(); - this.renderer.saveViewport(); - for (var i = 0; i < this.views.length; i++) { - this.views[i].render(this.renderer, accumulating); - } - this.renderer.restoreViewport(); + /** + * @type {clay.core.LinkedList.Entry} + */ + this.tail = null; + + this._length = 0; }; /** - * Stop accumulating + * Insert a new value at the tail + * @param {} val + * @return {clay.core.LinkedList.Entry} */ -LayerGL.prototype._stopAccumulating = function () { - this._accumulatingId = 0; - clearTimeout(this._accumulatingTimeout); +LinkedList.prototype.insert = function (val) { + var entry = new LinkedList.Entry(val); + this.insertEntry(entry); + return entry; }; -var accumulatingId = 1; /** - * Start accumulating all the views. - * Accumulating is for antialising and have more sampling in SSAO - * @private + * Insert a new value at idx + * @param {number} idx + * @param {} val + * @return {clay.core.LinkedList.Entry} */ -LayerGL.prototype._startAccumulating = function (immediate) { - var self = this; - this._stopAccumulating(); - - var needsAccumulate = false; - for (var i = 0; i < this.views.length; i++) { - needsAccumulate = this.views[i].needsAccumulate() || needsAccumulate; - } - if (!needsAccumulate) { +LinkedList.prototype.insertAt = function (idx, val) { + if (idx < 0) { return; } - - function accumulate(id) { - if (!self._accumulatingId || id !== self._accumulatingId) { - return; - } - - var isFinished = true; - for (var i = 0; i < self.views.length; i++) { - isFinished = self.views[i].isAccumulateFinished() && needsAccumulate; + var next = this.head; + var cursor = 0; + while (next && cursor != idx) { + next = next.next; + cursor++; + } + if (next) { + var entry = new LinkedList.Entry(val); + var prev = next.prev; + if (!prev) { //next is head + this.head = entry; } - - if (!isFinished) { - self._doRender(true); - - if (immediate) { - accumulate(id); - } - else { - __WEBPACK_IMPORTED_MODULE_6_zrender_lib_animation_requestAnimationFrame___default()(function () { - accumulate(id); - }); - } + else { + prev.next = entry; + entry.prev = prev; } - } - - this._accumulatingId = accumulatingId++; - - if (immediate) { - accumulate(self._accumulatingId); + entry.next = next; + next.prev = entry; } else { - this._accumulatingTimeout = setTimeout(function () { - accumulate(self._accumulatingId); - }, 50); + this.insert(val); } }; -LayerGL.prototype._trackAndClean = function () { - var textureList = []; - var geometriesList = []; - - // Mark all resources unused; - if (this._textureList) { - markUnused(this._textureList); - markUnused(this._geometriesList); - } - - for (var i = 0; i < this.views.length; i++) { - collectResources(this.views[i].scene, textureList, geometriesList); +LinkedList.prototype.insertBeforeEntry = function (val, next) { + var entry = new LinkedList.Entry(val); + var prev = next.prev; + if (!prev) { //next is head + this.head = entry; } - - // Dispose those unsed resources. - if (this._textureList) { - checkAndDispose(this.renderer, this._textureList); - checkAndDispose(this.renderer, this._geometriesList); + else { + prev.next = entry; + entry.prev = prev; } + entry.next = next; + next.prev = entry; - this._textureList = textureList; - this._geometriesList = geometriesList; + this._length++; }; -function markUnused(resourceList) { - for (var i = 0; i < resourceList.length; i++) { - resourceList[i].__used__ = 0; - } -} -function checkAndDispose(renderer, resourceList) { - for (var i = 0; i < resourceList.length; i++) { - if (!resourceList[i].__used__) { - resourceList[i].dispose(renderer); - } - } -} -function updateUsed(resource, list) { - resource.__used__ = resource.__used__ || 0; - resource.__used__++; - if (resource.__used__ === 1) { - // Don't push to the list twice. - list.push(resource); - } -} -function collectResources(scene, textureResourceList, geometryResourceList) { - var prevMaterial; - var prevGeometry; - scene.traverse(function (renderable) { - if (renderable.isRenderable()) { - var geometry = renderable.geometry; - var material = renderable.material; - - // TODO optimize!! - if (material !== prevMaterial) { - var textureUniforms = material.getTextureUniforms(); - for (var u = 0; u < textureUniforms.length; u++) { - var uniformName = textureUniforms[u]; - var val = material.uniforms[uniformName].value; - if (!val) { - continue; - } - if (val instanceof __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */]) { - updateUsed(val, textureResourceList); - } - else if (val instanceof Array) { - for (var k = 0; k < val.length; k++) { - if (val[k] instanceof __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */]) { - updateUsed(val[k], textureResourceList); - } - } - } - } - } - if (geometry !== prevGeometry) { - updateUsed(geometry, geometryResourceList); - } - - prevMaterial = material; - prevGeometry = geometry; - } - }); - - for (var k = 0; k < scene.lights.length; k++) { - // Track AmbientCubemap - if (scene.lights[k].cubemap) { - updateUsed(scene.lights[k].cubemap, textureResourceList); - } - } -} /** - * Dispose the layer + * Insert an entry at the tail + * @param {clay.core.LinkedList.Entry} entry */ -LayerGL.prototype.dispose = function () { - this._stopAccumulating(); - this.renderer.disposeScene(this.scene); - - this.zr.off('globalout', this.onglobalout); -}; - -// Event handlers -LayerGL.prototype.onmousedown = function (e) { - if (e.target && e.target.__isGLToZRProxy) { - return; +LinkedList.prototype.insertEntry = function (entry) { + if (!this.head) { + this.head = this.tail = entry; } - - e = e.event; - var obj = this.pickObject(e.offsetX, e.offsetY); - if (obj) { - this._dispatchEvent('mousedown', e, obj); - this._dispatchDataEvent('mousedown', e, obj); + else { + this.tail.next = entry; + entry.prev = this.tail; + this.tail = entry; } - - this._downX = e.offsetX; - this._downY = e.offsetY; + this._length++; }; -LayerGL.prototype.onmousemove = function (e) { - if (e.target && e.target.__isGLToZRProxy) { - return; - } - - e = e.event; - var obj = this.pickObject(e.offsetX, e.offsetY); - - var target = obj && obj.target; - var lastHovered = this._hovered; - this._hovered = obj; - - if (lastHovered && target !== lastHovered.target) { - lastHovered.relatedTarget = target; - this._dispatchEvent('mouseout', e, lastHovered); - // this._dispatchDataEvent('mouseout', e, lastHovered); - - this.zr.setCursorStyle('default'); +/** + * Remove entry. + * @param {clay.core.LinkedList.Entry} entry + */ +LinkedList.prototype.remove = function (entry) { + var prev = entry.prev; + var next = entry.next; + if (prev) { + prev.next = next; } - - this._dispatchEvent('mousemove', e, obj); - - if (obj) { - this.zr.setCursorStyle('pointer'); - - if (!lastHovered || (target !== lastHovered.target)) { - this._dispatchEvent('mouseover', e, obj); - // this._dispatchDataEvent('mouseover', e, obj); - } + else { + // Is head + this.head = next; } - - this._dispatchDataEvent('mousemove', e, obj); -}; - -LayerGL.prototype.onmouseup = function (e) { - if (e.target && e.target.__isGLToZRProxy) { - return; + if (next) { + next.prev = prev; } - - e = e.event; - var obj = this.pickObject(e.offsetX, e.offsetY); - - if (obj) { - this._dispatchEvent('mouseup', e, obj); - this._dispatchDataEvent('mouseup', e, obj); + else { + // Is tail + this.tail = prev; } - - this._upX = e.offsetX; - this._upY = e.offsetY; + entry.next = entry.prev = null; + this._length--; }; -LayerGL.prototype.onclick = LayerGL.prototype.dblclick = function (e) { - if (e.target && e.target.__isGLToZRProxy) { - return; - } - - // Ignore click event if mouse moved - var dx = this._upX - this._downX; - var dy = this._upY - this._downY; - if (Math.sqrt(dx * dx + dy * dy) > 20) { +/** + * Remove entry at index. + * @param {number} idx + * @return {} + */ +LinkedList.prototype.removeAt = function (idx) { + if (idx < 0) { return; } - - e = e.event; - var obj = this.pickObject(e.offsetX, e.offsetY); - - if (obj) { - this._dispatchEvent(e.type, e, obj); - this._dispatchDataEvent(e.type, e, obj); + var curr = this.head; + var cursor = 0; + while (curr && cursor != idx) { + curr = curr.next; + cursor++; } - - // Try set depth of field onclick - var result = this._clickToSetFocusPoint(e); - if (result) { - var success = result.view.setDOFFocusOnPoint(result.distance); - if (success) { - this.zr.refresh(); - } + if (curr) { + this.remove(curr); + return curr.value; } }; - -LayerGL.prototype._clickToSetFocusPoint = function (e) { - var renderer = this.renderer; - var oldViewport = renderer.viewport; - for (var i = this.views.length - 1; i >= 0; i--) { - var viewGL = this.views[i]; - if (viewGL.hasDOF() && viewGL.containPoint(e.offsetX, e.offsetY)) { - this._picking.scene = viewGL.scene; - this._picking.camera = viewGL.camera; - // Only used for picking, renderer.setViewport will also invoke gl.viewport. - // Set directly, PENDING. - renderer.viewport = viewGL.viewport; - var result = this._picking.pick(e.offsetX, e.offsetY, true); - if (result) { - result.view = viewGL; - return result; - } - } +/** + * Get head value + * @return {} + */ +LinkedList.prototype.getHead = function () { + if (this.head) { + return this.head.value; } - renderer.viewport = oldViewport; }; - -LayerGL.prototype.onglobalout = function (e) { - var lastHovered = this._hovered; - if (lastHovered) { - this._dispatchEvent('mouseout', e, { - target: lastHovered.target - }); +/** + * Get tail value + * @return {} + */ +LinkedList.prototype.getTail = function () { + if (this.tail) { + return this.tail.value; } }; - -LayerGL.prototype.pickObject = function (x, y) { - - var output = []; - var renderer = this.renderer; - var oldViewport = renderer.viewport; - for (var i = 0; i < this.views.length; i++) { - var viewGL = this.views[i]; - if (viewGL.containPoint(x, y)) { - this._picking.scene = viewGL.scene; - this._picking.camera = viewGL.camera; - // Only used for picking, renderer.setViewport will also invoke gl.viewport. - // Set directly, PENDING. - renderer.viewport = viewGL.viewport; - this._picking.pickAll(x, y, output); - } +/** + * Get value at idx + * @param {number} idx + * @return {} + */ +LinkedList.prototype.getAt = function (idx) { + if (idx < 0) { + return; } - renderer.viewport = oldViewport; - output.sort(function (a, b) { - return a.distance - b.distance; - }); - return output[0]; -}; - -LayerGL.prototype._dispatchEvent = function (eveName, originalEvent, newEvent) { - if (!newEvent) { - newEvent = {}; + var curr = this.head; + var cursor = 0; + while (curr && cursor != idx) { + curr = curr.next; + cursor++; } - var current = newEvent.target; - - newEvent.cancelBubble = false; - newEvent.event = originalEvent; - newEvent.type = eveName; - newEvent.offsetX = originalEvent.offsetX; - newEvent.offsetY = originalEvent.offsetY; - - while (current) { - current.trigger(eveName, newEvent); - current = current.getParent(); + return curr.value; +}; - if (newEvent.cancelBubble) { - break; +/** + * @param {} value + * @return {number} + */ +LinkedList.prototype.indexOf = function (value) { + var curr = this.head; + var cursor = 0; + while (curr) { + if (curr.value === value) { + return cursor; } + curr = curr.next; + cursor++; } - - this._dispatchToView(eveName, newEvent); }; -LayerGL.prototype._dispatchDataEvent = function (eveName, originalEvent, newEvent) { - var mesh = newEvent && newEvent.target; - - var dataIndex = mesh && mesh.dataIndex; - var seriesIndex = mesh && mesh.seriesIndex; - // Custom event data - var eventData = mesh && mesh.eventData; - var elChangedInMouseMove = false; +/** + * @return {number} + */ +LinkedList.prototype.length = function () { + return this._length; +}; - var eventProxy = this._zrEventProxy; - eventProxy.position = [originalEvent.offsetX, originalEvent.offsetY]; - eventProxy.update(); +/** + * If list is empty + */ +LinkedList.prototype.isEmpty = function () { + return this._length === 0; +}; - var targetInfo = { - target: eventProxy - }; - if (eveName === 'mousemove') { - if (dataIndex != null) { - if (dataIndex !== this._lastDataIndex) { - if (parseInt(this._lastDataIndex, 10) >= 0) { - eventProxy.dataIndex = this._lastDataIndex; - eventProxy.seriesIndex = this._lastSeriesIndex; - // FIXME May cause double events. - this.zr.handler.dispatchToElement(targetInfo, 'mouseout', originalEvent); - } - elChangedInMouseMove = true; - } +/** + * @param {Function} cb + * @param {} context + */ +LinkedList.prototype.forEach = function (cb, context) { + var curr = this.head; + var idx = 0; + var haveContext = typeof(context) != 'undefined'; + while (curr) { + if (haveContext) { + cb.call(context, curr.value, idx); } - else if (eventData != null) { - if (eventData !== this._lastEventData) { - if (this._lastEventData != null) { - eventProxy.eventData = this._lastEventData; - // FIXME May cause double events. - this.zr.handler.dispatchToElement(targetInfo, 'mouseout', originalEvent); - } - elChangedInMouseMove = true; - } + else { + cb(curr.value, idx); } - this._lastEventData = eventData; - this._lastDataIndex = dataIndex; - this._lastSeriesIndex = seriesIndex; + curr = curr.next; + idx++; } +}; - eventProxy.eventData = eventData; - eventProxy.dataIndex = dataIndex; - eventProxy.seriesIndex = seriesIndex; +/** + * Clear the list + */ +LinkedList.prototype.clear = function () { + this.tail = this.head = null; + this._length = 0; +}; - if (eventData != null || (parseInt(dataIndex, 10) >= 0 && parseInt(seriesIndex, 10) >= 0)) { - this.zr.handler.dispatchToElement(targetInfo, eveName, originalEvent); +/** + * @constructor + * @param {} val + */ +LinkedList.Entry = function (val) { + /** + * @type {} + */ + this.value = val; - if (elChangedInMouseMove) { - this.zr.handler.dispatchToElement(targetInfo, 'mouseover', originalEvent); - } - } -}; + /** + * @type {clay.core.LinkedList.Entry} + */ + this.next = null; -LayerGL.prototype._dispatchToView = function (eventName, e) { - for (var i = 0; i < this.views.length; i++) { - if (this.views[i].containPoint(e.offsetX, e.offsetY)) { - this.views[i].trigger(eventName, e); - } - } + /** + * @type {clay.core.LinkedList.Entry} + */ + this.prev = null; }; -__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.extend(LayerGL.prototype, __WEBPACK_IMPORTED_MODULE_5_claygl_src_core_mixin_notifier__["a" /* default */]); +/* harmony default export */ __webpack_exports__["a"] = (LinkedList); -/* harmony default export */ __webpack_exports__["a"] = (LayerGL); /***/ }), -/* 103 */ +/* 115 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/** - * Extend a sub class from base class - * @param {object|Function} makeDefaultOpt default option of this sub class, method of the sub can use this.xxx to access this option - * @param {Function} [initialize] Initialize after the sub class is instantiated - * @param {Object} [proto] Prototype methods/properties of the sub class - * @memberOf clay.core.mixin.extend - * @return {Function} - */ -function derive(makeDefaultOpt, initialize/*optional*/, proto/*optional*/) { +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__GLProgram__ = __webpack_require__(116); - if (typeof initialize == 'object') { - proto = initialize; - initialize = null; - } - - var _super = this; - - var propList; - if (!(makeDefaultOpt instanceof Function)) { - // Optimize the property iterate if it have been fixed - propList = []; - for (var propName in makeDefaultOpt) { - if (makeDefaultOpt.hasOwnProperty(propName)) { - propList.push(propName); - } - } - } - var sub = function(options) { +var loopRegex = /for\s*?\(int\s*?_idx_\s*\=\s*([\w-]+)\;\s*_idx_\s*<\s*([\w-]+);\s*_idx_\s*\+\+\s*\)\s*\{\{([\s\S]+?)(?=\}\})\}\}/g; - // call super constructor - _super.apply(this, arguments); +function unrollLoop(shaderStr, defines, lightsNumbers) { + // Loop unroll from three.js, https://github.com/mrdoob/three.js/blob/master/src/renderers/webgl/WebGLProgram.js#L175 + // In some case like shadowMap in loop use 'i' to index value much slower. - if (makeDefaultOpt instanceof Function) { - // Invoke makeDefaultOpt each time if it is a function, So we can make sure each - // property in the object will not be shared by mutiple instances - extend(this, makeDefaultOpt.call(this, options)); - } - else { - extendWithPropList(this, makeDefaultOpt, propList); + // Loop use _idx_ and increased with _idx_++ will be unrolled + // Use {{ }} to match the pair so the if statement will not be affected + // Write like following + // for (int _idx_ = 0; _idx_ < 4; _idx_++) {{ + // vec3 color = texture2D(textures[_idx_], uv).rgb; + // }} + function replace(match, start, end, snippet) { + var unroll = ''; + // Try to treat as define + if (isNaN(start)) { + if (start in defines) { + start = defines[start]; + } + else { + start = lightNumberDefines[start]; + } } - - if (this.constructor === sub) { - // Initialize function will be called in the order of inherit - var initializers = sub.__initializers__; - for (var i = 0; i < initializers.length; i++) { - initializers[i].apply(this, arguments); + if (isNaN(end)) { + if (end in defines) { + end = defines[end]; + } + else { + end = lightNumberDefines[end]; } } - }; - // save super constructor - sub.__super__ = _super; - // Initialize function will be called after all the super constructor is called - if (!_super.__initializers__) { - sub.__initializers__ = []; - } else { - sub.__initializers__ = _super.__initializers__.slice(); - } - if (initialize) { - sub.__initializers__.push(initialize); - } - - var Ctor = function() {}; - Ctor.prototype = _super.prototype; - sub.prototype = new Ctor(); - sub.prototype.constructor = sub; - extend(sub.prototype, proto); + // TODO Error checking - // extend the derive method as a static method; - sub.extend = _super.extend; + for (var idx = parseInt(start); idx < parseInt(end); idx++) { + // PENDING Add scope? + unroll += '{' + + snippet + .replace(/float\s*\(\s*_idx_\s*\)/g, idx.toFixed(1)) + .replace(/_idx_/g, idx) + + '}'; + } - // DEPCRATED - sub.derive = _super.extend; + return unroll; + } - return sub; + var lightNumberDefines = {}; + for (var lightType in lightsNumbers) { + lightNumberDefines[lightType + '_COUNT'] = lightsNumbers[lightType]; + } + return shaderStr.replace(loopRegex, replace); } -function extend(target, source) { - if (!source) { - return; +function getDefineCode(defines, lightsNumbers, enabledTextures) { + var defineStr = []; + if (lightsNumbers) { + for (var lightType in lightsNumbers) { + var count = lightsNumbers[lightType]; + if (count > 0) { + defineStr.push('#define ' + lightType.toUpperCase() + '_COUNT ' + count); + } + } } - for (var name in source) { - if (source.hasOwnProperty(name)) { - target[name] = source[name]; + if (enabledTextures) { + for (var i = 0; i < enabledTextures.length; i++) { + var symbol = enabledTextures[i]; + defineStr.push('#define ' + symbol.toUpperCase() + '_ENABLED'); + } + } + // Custom Defines + for (var symbol in defines) { + var value = defines[symbol]; + if (value === null) { + defineStr.push('#define ' + symbol); + } + else{ + defineStr.push('#define ' + symbol + ' ' + value.toString()); } } + return defineStr.join('\n'); } -function extendWithPropList(target, source, propList) { - for (var i = 0; i < propList.length; i++) { - var propName = propList[i]; - target[propName] = source[propName]; +function getExtensionCode(exts) { + // Extension declaration must before all non-preprocessor codes + // TODO vertex ? extension enum ? + var extensionStr = []; + for (var i = 0; i < exts.length; i++) { + extensionStr.push('#extension GL_' + exts[i] + ' : enable'); } + return extensionStr.join('\n'); } -/** - * @alias clay.core.mixin.extend - * @mixin - */ -/* harmony default export */ __webpack_exports__["a"] = ({ - - extend: derive, - - // DEPCRATED - derive: derive -}); - - -/***/ }), -/* 104 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -var EXTENSION_LIST = [ - 'OES_texture_float', - 'OES_texture_half_float', - 'OES_texture_float_linear', - 'OES_texture_half_float_linear', - 'OES_standard_derivatives', - 'OES_vertex_array_object', - 'OES_element_index_uint', - 'WEBGL_compressed_texture_s3tc', - 'WEBGL_depth_texture', - 'EXT_texture_filter_anisotropic', - 'EXT_shader_texture_lod', - 'WEBGL_draw_buffers', - 'EXT_frag_depth', - 'EXT_sRGB' -]; +function getPrecisionCode(precision) { + return ['precision', precision, 'float'].join(' ') + ';\n' + + ['precision', precision, 'int'].join(' ') + ';\n' + // depth texture may have precision problem on iOS device. + + ['precision', precision, 'sampler2D'].join(' ') + ';\n'; +} -var PARAMETER_NAMES = [ - 'MAX_TEXTURE_SIZE', - 'MAX_CUBE_MAP_TEXTURE_SIZE' -]; +function ProgramManager(renderer) { + this._renderer = renderer; + this._cache = {}; +} -function GLInfo(_gl) { - var extensions = {}; - var parameters = {}; +ProgramManager.prototype.getProgram = function (renderable, material, scene) { + var cache = this._cache; - // Get webgl extension - for (var i = 0; i < EXTENSION_LIST.length; i++) { - var extName = EXTENSION_LIST[i]; - createExtension(extName); + var isSkinnedMesh = renderable.isSkinnedMesh && renderable.isSkinnedMesh(); + var key = 's' + material.shader.shaderID + 'm' + material.getProgramKey(); + if (scene) { + key += 'se' + scene.getProgramKey(renderable.lightGroup); } - // Get parameters - for (var i = 0; i < PARAMETER_NAMES.length; i++) { - var name = PARAMETER_NAMES[i]; - parameters[name] = _gl.getParameter(_gl[name]); + if (isSkinnedMesh) { + key += ',' + renderable.joints.length; } + var program = cache[key]; - this.getExtension = function (name) { - if (!(name in extensions)) { - createExtension(name); - } - return extensions[name]; - }; - - this.getParameter = function (name) { - return parameters[name]; - }; + if (program) { + return program; + } - function createExtension(name) { - var ext = _gl.getExtension(name); - if (!ext) { - ext = _gl.getExtension('MOZ_' + name); - } - if (!ext) { - ext = _gl.getExtension('WEBKIT_' + name); + var lightsNumbers = scene ? scene.getLightsNumbers(renderable.lightGroup) : {}; + var renderer = this._renderer; + var _gl = renderer.gl; + var enabledTextures = material.getEnabledTextures(); + var skinDefineCode = ''; + if (isSkinnedMesh) { + var skinDefines = { + SKINNING: null, + JOINT_COUNT: renderable.joints.length + }; + if (renderable.joints.length > renderer.getMaxJointNumber()) { + skinDefines.USE_SKIN_MATRICES_TEXTURE = null; } - extensions[name] = ext; + // TODO Add skinning code? + skinDefineCode = '\n' + getDefineCode(skinDefines) + '\n'; } -} - -/* harmony default export */ __webpack_exports__["a"] = (GLInfo); - - -/***/ }), -/* 105 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_LRU__ = __webpack_require__(64); -/** - * @namespace clay.core.color - */ - - -var colorUtil = {}; - -var kCSSColorTable = { - 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1], - 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1], - 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1], - 'beige': [245,245,220,1], 'bisque': [255,228,196,1], - 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1], - 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1], - 'brown': [165,42,42,1], 'burlywood': [222,184,135,1], - 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1], - 'chocolate': [210,105,30,1], 'coral': [255,127,80,1], - 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1], - 'crimson': [220,20,60,1], 'cyan': [0,255,255,1], - 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1], - 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1], - 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1], - 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1], - 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1], - 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1], - 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1], - 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1], - 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1], - 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1], - 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1], - 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1], - 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1], - 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1], - 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1], - 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1], - 'gray': [128,128,128,1], 'green': [0,128,0,1], - 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1], - 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1], - 'indianred': [205,92,92,1], 'indigo': [75,0,130,1], - 'ivory': [255,255,240,1], 'khaki': [240,230,140,1], - 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1], - 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1], - 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1], - 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1], - 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1], - 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1], - 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1], - 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1], - 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1], - 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1], - 'limegreen': [50,205,50,1], 'linen': [250,240,230,1], - 'magenta': [255,0,255,1], 'maroon': [128,0,0,1], - 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1], - 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1], - 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1], - 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1], - 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1], - 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1], - 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1], - 'navy': [0,0,128,1], 'oldlace': [253,245,230,1], - 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1], - 'orange': [255,165,0,1], 'orangered': [255,69,0,1], - 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1], - 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1], - 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1], - 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1], - 'pink': [255,192,203,1], 'plum': [221,160,221,1], - 'powderblue': [176,224,230,1], 'purple': [128,0,128,1], - 'red': [255,0,0,1], 'rosybrown': [188,143,143,1], - 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1], - 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1], - 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1], - 'sienna': [160,82,45,1], 'silver': [192,192,192,1], - 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1], - 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1], - 'snow': [255,250,250,1], 'springgreen': [0,255,127,1], - 'steelblue': [70,130,180,1], 'tan': [210,180,140,1], - 'teal': [0,128,128,1], 'thistle': [216,191,216,1], - 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1], - 'violet': [238,130,238,1], 'wheat': [245,222,179,1], - 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1], - 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1] -}; - -function clampCssByte(i) { // Clamp to integer 0 .. 255. - i = Math.round(i); // Seems to be what Chrome does (vs truncation). - return i < 0 ? 0 : i > 255 ? 255 : i; -} + // TODO Optimize key generation + // VERTEX + var vertexDefineStr = skinDefineCode + getDefineCode(material.vertexDefines, lightsNumbers, enabledTextures); + // FRAGMENT + var fragmentDefineStr = skinDefineCode + getDefineCode(material.fragmentDefines, lightsNumbers, enabledTextures); -function clampCssAngle(i) { // Clamp to integer 0 .. 360. - i = Math.round(i); // Seems to be what Chrome does (vs truncation). - return i < 0 ? 0 : i > 360 ? 360 : i; -} + var vertexCode = vertexDefineStr + '\n' + material.shader.vertex; -function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0. - return f < 0 ? 0 : f > 1 ? 1 : f; -} + var extensions = [ + 'OES_standard_derivatives', + 'EXT_shader_texture_lod' + ].filter(function (ext) { + return renderer.getGLExtension(ext) != null; + }); -function parseCssInt(str) { // int or percentage. - if (str.length && str.charAt(str.length - 1) === '%') { - return clampCssByte(parseFloat(str) / 100 * 255); + if (extensions.indexOf('EXT_shader_texture_lod') >= 0) { + fragmentDefineStr += '\n#define SUPPORT_TEXTURE_LOD'; } - return clampCssByte(parseInt(str, 10)); -} - -function parseCssFloat(str) { // float or percentage. - if (str.length && str.charAt(str.length - 1) === '%') { - return clampCssFloat(parseFloat(str) / 100); + if (extensions.indexOf('OES_standard_derivatives') >= 0) { + fragmentDefineStr += '\n#define SUPPORT_STANDARD_DERIVATIVES'; } - return clampCssFloat(parseFloat(str)); -} -function cssHueToRgb(m1, m2, h) { - if (h < 0) { - h += 1; - } - else if (h > 1) { - h -= 1; - } + var fragmentCode = getExtensionCode(extensions) + '\n' + + getPrecisionCode(material.precision) + '\n' + + fragmentDefineStr + '\n' + + material.shader.fragment; - if (h * 6 < 1) { - return m1 + (m2 - m1) * h * 6; - } - if (h * 2 < 1) { - return m2; - } - if (h * 3 < 2) { - return m1 + (m2 - m1) * (2/3 - h) * 6; - } - return m1; -} + var finalVertexCode = unrollLoop(vertexCode, material.vertexDefines, lightsNumbers); + var finalFragmentCode = unrollLoop(fragmentCode, material.fragmentDefines, lightsNumbers); + + var program = new __WEBPACK_IMPORTED_MODULE_0__GLProgram__["a" /* default */](); + program.uniformSemantics = material.shader.uniformSemantics; + program.attributes = material.shader.attributes; + var errorMsg = program.buildProgram(_gl, material.shader, finalVertexCode, finalFragmentCode); + program.__error = errorMsg; -function lerpNumber(a, b, p) { - return a + (b - a) * p; -} + cache[key] = program; -function setRgba(out, r, g, b, a) { - out[0] = r; out[1] = g; out[2] = b; out[3] = a; - return out; -} -function copyRgba(out, a) { - out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3]; - return out; -} + return program; +}; -var colorCache = new __WEBPACK_IMPORTED_MODULE_0__core_LRU__["a" /* default */](20); -var lastRemovedArr = null; +/* harmony default export */ __webpack_exports__["a"] = (ProgramManager); -function putToCache(colorStr, rgbaArr) { - // Reuse removed array - if (lastRemovedArr) { - copyRgba(lastRemovedArr, rgbaArr); - } - lastRemovedArr = colorCache.put(colorStr, lastRemovedArr || (rgbaArr.slice())); -} +/***/ }), +/* 116 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -/** - * @name clay.core.color.parse - * @param {string} colorStr - * @param {Array.} out - * @return {Array.} - */ -colorUtil.parse = function (colorStr, rgbaArr) { - if (!colorStr) { - return; - } - rgbaArr = rgbaArr || []; +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_vendor__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Base__ = __webpack_require__(7); - var cached = colorCache.get(colorStr); - if (cached) { - return copyRgba(rgbaArr, cached); - } - // colorStr may be not string - colorStr = colorStr + ''; - // Remove all whitespace, not compliant, but should just be more accepting. - var str = colorStr.replace(/ /g, '').toLowerCase(); - // Color keywords (and transparent) lookup. - if (str in kCSSColorTable) { - copyRgba(rgbaArr, kCSSColorTable[str]); - putToCache(colorStr, rgbaArr); - return rgbaArr; - } +var SHADER_STATE_TO_ENABLE = 1; +var SHADER_STATE_KEEP_ENABLE = 2; +var SHADER_STATE_PENDING = 3; - // #abc and #abc123 syntax. - if (str.charAt(0) === '#') { - if (str.length === 4) { - var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. - if (!(iv >= 0 && iv <= 0xfff)) { - setRgba(rgbaArr, 0, 0, 0, 1); - return; // Covers NaN. - } - setRgba(rgbaArr, - ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8), - (iv & 0xf0) | ((iv & 0xf0) >> 4), - (iv & 0xf) | ((iv & 0xf) << 4), - 1 - ); - putToCache(colorStr, rgbaArr); - return rgbaArr; - } - else if (str.length === 7) { - var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing. - if (!(iv >= 0 && iv <= 0xffffff)) { - setRgba(rgbaArr, 0, 0, 0, 1); - return; // Covers NaN. - } - setRgba(rgbaArr, - (iv & 0xff0000) >> 16, - (iv & 0xff00) >> 8, - iv & 0xff, - 1 - ); - putToCache(colorStr, rgbaArr); - return rgbaArr; - } +// Enable attribute operation is global to all programs +// Here saved the list of all enabled attribute index +// http://www.mjbshaw.com/2013/03/webgl-fixing-invalidoperation.html +var enabledAttributeList = {}; - return; - } - var op = str.indexOf('('), ep = str.indexOf(')'); - if (op !== -1 && ep + 1 === str.length) { - var fname = str.substr(0, op); - var params = str.substr(op + 1, ep - (op + 1)).split(','); - var alpha = 1; // To allow case fallthrough. - switch (fname) { - case 'rgba': - if (params.length !== 4) { - setRgba(rgbaArr, 0, 0, 0, 1); - return; - } - alpha = parseCssFloat(params.pop()); // jshint ignore:line - // Fall through. - case 'rgb': - if (params.length !== 3) { - setRgba(rgbaArr, 0, 0, 0, 1); - return; - } - setRgba(rgbaArr, - parseCssInt(params[0]), - parseCssInt(params[1]), - parseCssInt(params[2]), - alpha - ); - putToCache(colorStr, rgbaArr); - return rgbaArr; - case 'hsla': - if (params.length !== 4) { - setRgba(rgbaArr, 0, 0, 0, 1); - return; - } - params[3] = parseCssFloat(params[3]); - hsla2rgba(params, rgbaArr); - putToCache(colorStr, rgbaArr); - return rgbaArr; - case 'hsl': - if (params.length !== 3) { - setRgba(rgbaArr, 0, 0, 0, 1); - return; - } - hsla2rgba(params, rgbaArr); - putToCache(colorStr, rgbaArr); - return rgbaArr; - default: - return; - } +// some util functions +function addLineNumbers(string) { + var chunks = string.split('\n'); + for (var i = 0, il = chunks.length; i < il; i ++) { + // Chrome reports shader errors on lines + // starting counting from 1 + chunks[i] = (i + 1) + ': ' + chunks[i]; } + return chunks.join('\n'); +} - setRgba(rgbaArr, 0, 0, 0, 1); - return; -}; - -colorUtil.parseToFloat = function (colorStr, rgbaArr) { - rgbaArr = colorUtil.parse(colorStr, rgbaArr); - if (!rgbaArr) { - return; +// Return true or error msg if error happened +function checkShaderErrorMsg(_gl, shader, shaderString) { + if (!_gl.getShaderParameter(shader, _gl.COMPILE_STATUS)) { + return [_gl.getShaderInfoLog(shader), addLineNumbers(shaderString)].join('\n'); } - rgbaArr[0] /= 255; - rgbaArr[1] /= 255; - rgbaArr[2] /= 255; - return rgbaArr; } -/** - * @name clay.core.color.hsla2rgba - * @param {Array.} hsla - * @param {Array.} rgba - * @return {Array.} rgba - */ -function hsla2rgba(hsla, rgba) { - var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1 - // NOTE(deanm): According to the CSS spec s/l should only be - // percentages, but we don't bother and let float or percentage. - var s = parseCssFloat(hsla[1]); - var l = parseCssFloat(hsla[2]); - var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; - var m1 = l * 2 - m2; +var tmpFloat32Array16 = new __WEBPACK_IMPORTED_MODULE_0__core_vendor__["a" /* default */].Float32Array(16); - rgba = rgba || []; - setRgba(rgba, - clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255), - clampCssByte(cssHueToRgb(m1, m2, h) * 255), - clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255), - 1 - ); +var GLProgram = __WEBPACK_IMPORTED_MODULE_1__core_Base__["a" /* default */].extend({ - if (hsla.length === 4) { - rgba[3] = hsla[3]; - } + uniformSemantics: {}, + attributes: {} - return rgba; -} +}, function () { + this._locations = {}; -/** - * @name clay.core.color.rgba2hsla - * @param {Array.} rgba - * @return {Array.} hsla - */ -function rgba2hsla(rgba) { - if (!rgba) { - return; - } + this._textureSlot = 0; - // RGB from 0 to 255 - var R = rgba[0] / 255; - var G = rgba[1] / 255; - var B = rgba[2] / 255; + this._program = null; +}, { - var vMin = Math.min(R, G, B); // Min. value of RGB - var vMax = Math.max(R, G, B); // Max. value of RGB - var delta = vMax - vMin; // Delta RGB value + bind: function (renderer) { + this._textureSlot = 0; + renderer.gl.useProgram(this._program); + }, - var L = (vMax + vMin) / 2; - var H; - var S; - // HSL results from 0 to 1 - if (delta === 0) { - H = 0; - S = 0; - } - else { - if (L < 0.5) { - S = delta / (vMax + vMin); - } - else { - S = delta / (2 - vMax - vMin); + hasUniform: function (symbol) { + var location = this._locations[symbol]; + return location !== null && location !== undefined; + }, + + useTextureSlot: function (renderer, texture, slot) { + if (texture) { + renderer.gl.activeTexture(renderer.gl.TEXTURE0 + slot); + // Maybe texture is not loaded yet; + if (texture.isRenderable()) { + texture.bind(renderer); + } + else { + // Bind texture to null + texture.unbind(renderer); + } } + }, - var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta; - var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta; - var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta; + currentTextureSlot: function () { + return this._textureSlot; + }, - if (R === vMax) { - H = deltaB - deltaG; - } - else if (G === vMax) { - H = (1 / 3) + deltaR - deltaB; - } - else if (B === vMax) { - H = (2 / 3) + deltaG - deltaR; - } + resetTextureSlot: function (slot) { + this._textureSlot = slot || 0; + }, - if (H < 0) { - H += 1; + takeCurrentTextureSlot: function (renderer, texture) { + var textureSlot = this._textureSlot; + + this.useTextureSlot(renderer, texture, textureSlot); + + this._textureSlot++; + + return textureSlot; + }, + + setUniform: function (_gl, type, symbol, value) { + var locationMap = this._locations; + var location = locationMap[symbol]; + // Uniform is not existed in the shader + if (location === null || location === undefined) { + return false; } - if (H > 1) { - H -= 1; + switch (type) { + case 'm4': + if (!(value instanceof Float32Array)) { + // Use Float32Array is much faster than array when uniformMatrix4fv. + for (var i = 0; i < value.length; i++) { + tmpFloat32Array16[i] = value[i]; + } + value = tmpFloat32Array16; + } + _gl.uniformMatrix4fv(location, false, value); + break; + case '2i': + _gl.uniform2i(location, value[0], value[1]); + break; + case '2f': + _gl.uniform2f(location, value[0], value[1]); + break; + case '3i': + _gl.uniform3i(location, value[0], value[1], value[2]); + break; + case '3f': + _gl.uniform3f(location, value[0], value[1], value[2]); + break; + case '4i': + _gl.uniform4i(location, value[0], value[1], value[2], value[3]); + break; + case '4f': + _gl.uniform4f(location, value[0], value[1], value[2], value[3]); + break; + case '1i': + _gl.uniform1i(location, value); + break; + case '1f': + _gl.uniform1f(location, value); + break; + case '1fv': + _gl.uniform1fv(location, value); + break; + case '1iv': + _gl.uniform1iv(location, value); + break; + case '2iv': + _gl.uniform2iv(location, value); + break; + case '2fv': + _gl.uniform2fv(location, value); + break; + case '3iv': + _gl.uniform3iv(location, value); + break; + case '3fv': + _gl.uniform3fv(location, value); + break; + case '4iv': + _gl.uniform4iv(location, value); + break; + case '4fv': + _gl.uniform4fv(location, value); + break; + case 'm2': + case 'm2v': + _gl.uniformMatrix2fv(location, false, value); + break; + case 'm3': + case 'm3v': + _gl.uniformMatrix3fv(location, false, value); + break; + case 'm4v': + // Raw value + if (Array.isArray(value) && Array.isArray(value[0])) { + var array = new __WEBPACK_IMPORTED_MODULE_0__core_vendor__["a" /* default */].Float32Array(value.length * 16); + var cursor = 0; + for (var i = 0; i < value.length; i++) { + var item = value[i]; + for (var j = 0; j < 16; j++) { + array[cursor++] = item[j]; + } + } + _gl.uniformMatrix4fv(location, false, array); + } + else { // ArrayBufferView + _gl.uniformMatrix4fv(location, false, value); + } + break; } - } + return true; + }, - var hsla = [H * 360, S, L]; + setUniformOfSemantic: function (_gl, semantic, val) { + var semanticInfo = this.uniformSemantics[semantic]; + if (semanticInfo) { + return this.setUniform(_gl, semanticInfo.type, semanticInfo.symbol, val); + } + return false; + }, - if (rgba[3] != null) { - hsla.push(rgba[3]); - } + // Used for creating VAO + // Enable the attributes passed in and disable the rest + // Example Usage: + // enableAttributes(renderer, ["position", "texcoords"]) + enableAttributes: function (renderer, attribList, vao) { + var _gl = renderer.gl; + var program = this._program; - return hsla; -} + var locationMap = this._locations; -/** - * @name clay.core.color.lift - * @param {string} color - * @param {number} level - * @return {string} - */ -colorUtil.lift = function (color, level) { - var colorArr = colorUtil.parse(color); - if (colorArr) { - for (var i = 0; i < 3; i++) { - if (level < 0) { - colorArr[i] = colorArr[i] * (1 - level) | 0; + var enabledAttributeListInContext; + if (vao) { + enabledAttributeListInContext = vao.__enabledAttributeList; + } + else { + enabledAttributeListInContext = enabledAttributeList[renderer.__uid__]; + } + if (!enabledAttributeListInContext) { + // In vertex array object context + // PENDING Each vao object needs to enable attributes again? + if (vao) { + enabledAttributeListInContext + = vao.__enabledAttributeList + = []; } else { - colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0; + enabledAttributeListInContext + = enabledAttributeList[renderer.__uid__] + = []; } } - return colorUtil.stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb'); - } -} - -/** - * @name clay.core.color.toHex - * @param {string} color - * @return {string} - */ -colorUtil.toHex = function (color) { - var colorArr = colorUtil.parse(color); - if (colorArr) { - return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1); - } -}; - -/** - * Map value to color. Faster than lerp methods because color is represented by rgba array. - * @name clay.core.color - * @param {number} normalizedValue A float between 0 and 1. - * @param {Array.>} colors List of rgba color array - * @param {Array.} [out] Mapped gba color array - * @return {Array.} will be null/undefined if input illegal. - */ -colorUtil.fastLerp = function (normalizedValue, colors, out) { - if (!(colors && colors.length) - || !(normalizedValue >= 0 && normalizedValue <= 1) - ) { - return; - } - - out = out || []; + var locationList = []; + for (var i = 0; i < attribList.length; i++) { + var symbol = attribList[i]; + if (!this.attributes[symbol]) { + locationList[i] = -1; + continue; + } + var location = locationMap[symbol]; + if (location == null) { + location = _gl.getAttribLocation(program, symbol); + // Attrib location is a number from 0 to ... + if (location === -1) { + locationList[i] = -1; + continue; + } + locationMap[symbol] = location; + } + locationList[i] = location; - var value = normalizedValue * (colors.length - 1); - var leftIndex = Math.floor(value); - var rightIndex = Math.ceil(value); - var leftColor = colors[leftIndex]; - var rightColor = colors[rightIndex]; - var dv = value - leftIndex; - out[0] = clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv)); - out[1] = clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv)); - out[2] = clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv)); - out[3] = clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv)); + if (!enabledAttributeListInContext[location]) { + enabledAttributeListInContext[location] = SHADER_STATE_TO_ENABLE; + } + else { + enabledAttributeListInContext[location] = SHADER_STATE_KEEP_ENABLE; + } + } - return out; -} + for (var i = 0; i < enabledAttributeListInContext.length; i++) { + switch(enabledAttributeListInContext[i]){ + case SHADER_STATE_TO_ENABLE: + _gl.enableVertexAttribArray(i); + enabledAttributeListInContext[i] = SHADER_STATE_PENDING; + break; + case SHADER_STATE_KEEP_ENABLE: + enabledAttributeListInContext[i] = SHADER_STATE_PENDING; + break; + // Expired + case SHADER_STATE_PENDING: + _gl.disableVertexAttribArray(i); + enabledAttributeListInContext[i] = 0; + break; + } + } -colorUtil.fastMapToColor = colorUtil.fastLerp; + return locationList; + }, -/** - * @param {number} normalizedValue A float between 0 and 1. - * @param {Array.} colors Color list. - * @param {boolean=} fullOutput Default false. - * @return {(string|Object)} Result color. If fullOutput, - * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...}, - */ -colorUtil.lerp = function (normalizedValue, colors, fullOutput) { - if (!(colors && colors.length) - || !(normalizedValue >= 0 && normalizedValue <= 1) - ) { - return; - } + buildProgram: function (_gl, shader, vertexShaderCode, fragmentShaderCode) { + var vertexShader = _gl.createShader(_gl.VERTEX_SHADER); + var program = _gl.createProgram(); - var value = normalizedValue * (colors.length - 1); - var leftIndex = Math.floor(value); - var rightIndex = Math.ceil(value); - var leftColor = colorUtil.parse(colors[leftIndex]); - var rightColor = colorUtil.parse(colors[rightIndex]); - var dv = value - leftIndex; + _gl.shaderSource(vertexShader, vertexShaderCode); + _gl.compileShader(vertexShader); - var color = colorUtil.stringify( - [ - clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv)), - clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv)), - clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv)), - clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv)) - ], - 'rgba' - ); + var fragmentShader = _gl.createShader(_gl.FRAGMENT_SHADER); + _gl.shaderSource(fragmentShader, fragmentShaderCode); + _gl.compileShader(fragmentShader); - return fullOutput - ? { - color: color, - leftIndex: leftIndex, - rightIndex: rightIndex, - value: value + var msg = checkShaderErrorMsg(_gl, vertexShader, vertexShaderCode); + if (msg) { + return msg; + } + msg = checkShaderErrorMsg(_gl, fragmentShader, fragmentShaderCode); + if (msg) { + return msg; } - : color; -} -/** - * @deprecated - */ -colorUtil.mapToColor = colorUtil.lerp; + _gl.attachShader(program, vertexShader); + _gl.attachShader(program, fragmentShader); + // Force the position bind to location 0; + if (shader.attributeSemantics['POSITION']) { + _gl.bindAttribLocation(program, 0, shader.attributeSemantics['POSITION'].symbol); + } + else { + // Else choose an attribute and bind to location 0; + var keys = Object.keys(this.attributes); + _gl.bindAttribLocation(program, 0, keys[0]); + } -/** - * @name clay.core.color - * @param {string} color - * @param {number=} h 0 ~ 360, ignore when null. - * @param {number=} s 0 ~ 1, ignore when null. - * @param {number=} l 0 ~ 1, ignore when null. - * @return {string} Color string in rgba format. - */ -colorUtil.modifyHSL = function (color, h, s, l) { - color = colorUtil.parse(color); + _gl.linkProgram(program); - if (color) { - color = rgba2hsla(color); - h != null && (color[0] = clampCssAngle(h)); - s != null && (color[1] = parseCssFloat(s)); - l != null && (color[2] = parseCssFloat(l)); + if (!_gl.getProgramParameter(program, _gl.LINK_STATUS)) { + return 'Could not link program\n' + _gl.getProgramInfoLog(program); + } - return colorUtil.stringify(hsla2rgba(color), 'rgba'); - } -} + // Cache uniform locations + for (var i = 0; i < shader.uniforms.length; i++) { + var uniformSymbol = shader.uniforms[i]; + this._locations[uniformSymbol] = _gl.getUniformLocation(program, uniformSymbol); + } -/** - * @param {string} color - * @param {number=} alpha 0 ~ 1 - * @return {string} Color string in rgba format. - */ -colorUtil.modifyAlpha = function (color, alpha) { - color = colorUtil.parse(color); + _gl.deleteShader(vertexShader); + _gl.deleteShader(fragmentShader); - if (color && alpha != null) { - color[3] = clampCssFloat(alpha); - return colorUtil.stringify(color, 'rgba'); - } -} + this._program = program; -/** - * @param {Array.} arrColor like [12,33,44,0.4] - * @param {string} type 'rgba', 'hsva', ... - * @return {string} Result color. (If input illegal, return undefined). - */ -colorUtil.stringify = function (arrColor, type) { - if (!arrColor || !arrColor.length) { - return; - } - var colorStr = arrColor[0] + ',' + arrColor[1] + ',' + arrColor[2]; - if (type === 'rgba' || type === 'hsva' || type === 'hsla') { - colorStr += ',' + arrColor[3]; + // Save code. + this.vertexCode = vertexShaderCode; + this.fragmentCode = fragmentShaderCode; } - return type + '(' + colorStr + ')'; -}; - - +}); -/* harmony default export */ __webpack_exports__["a"] = (colorUtil); +/* harmony default export */ __webpack_exports__["a"] = (GLProgram); /***/ }), -/* 106 */ +/* 117 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Ray__ = __webpack_require__(54); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Vector2__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__math_Matrix4__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Renderable__ = __webpack_require__(72); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__core_glenum__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__glmatrix_vec3__ = __webpack_require__(12); + + + + + + + + + /** - * Simple double linked list. Compared with array, it has O(1) remove operation. - * @constructor - * @alias clay.core.LinkedList + * @constructor clay.picking.RayPicking + * @extends clay.core.Base */ -var LinkedList = function () { +var RayPicking = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(/** @lends clay.picking.RayPicking# */{ + /** + * Target scene + * @type {clay.Scene} + */ + scene: null, + /** + * Target camera + * @type {clay.Camera} + */ + camera: null, + /** + * Target renderer + * @type {clay.Renderer} + */ + renderer: null +}, function () { + this._ray = new __WEBPACK_IMPORTED_MODULE_1__math_Ray__["a" /* default */](); + this._ndc = new __WEBPACK_IMPORTED_MODULE_2__math_Vector2__["a" /* default */](); +}, +/** @lends clay.picking.RayPicking.prototype */ +{ /** - * @type {clay.core.LinkedList.Entry} + * Pick the nearest intersection object in the scene + * @param {number} x Mouse position x + * @param {number} y Mouse position y + * @param {boolean} [forcePickAll=false] ignore ignorePicking + * @return {clay.picking.RayPicking~Intersection} */ - this.head = null; + pick: function (x, y, forcePickAll) { + var out = this.pickAll(x, y, [], forcePickAll); + return out[0] || null; + }, /** - * @type {clay.core.LinkedList.Entry} + * Pick all intersection objects, wich will be sorted from near to far + * @param {number} x Mouse position x + * @param {number} y Mouse position y + * @param {Array} [output] + * @param {boolean} [forcePickAll=false] ignore ignorePicking + * @return {Array.} */ - this.tail = null; + pickAll: function (x, y, output, forcePickAll) { + this.renderer.screenToNDC(x, y, this._ndc); + this.camera.castRay(this._ndc, this._ray); - this._length = 0; -}; + output = output || []; -/** - * Insert a new value at the tail - * @param {} val - * @return {clay.core.LinkedList.Entry} - */ -LinkedList.prototype.insert = function (val) { - var entry = new LinkedList.Entry(val); - this.insertEntry(entry); - return entry; -}; + this._intersectNode(this.scene, output, forcePickAll || false); -/** - * Insert a new value at idx - * @param {number} idx - * @param {} val - * @return {clay.core.LinkedList.Entry} - */ -LinkedList.prototype.insertAt = function (idx, val) { - if (idx < 0) { - return; - } - var next = this.head; - var cursor = 0; - while (next && cursor != idx) { - next = next.next; - cursor++; - } - if (next) { - var entry = new LinkedList.Entry(val); - var prev = next.prev; - if (!prev) { //next is head - this.head = entry; + output.sort(this._intersectionCompareFunc); + + return output; + }, + + _intersectNode: function (node, out, forcePickAll) { + if ((node instanceof __WEBPACK_IMPORTED_MODULE_5__Renderable__["a" /* default */]) && node.isRenderable()) { + if ((!node.ignorePicking || forcePickAll) + && ( + // Only triangle mesh support ray picking + (node.mode === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].TRIANGLES && node.geometry.isUseIndices()) + // Or if geometry has it's own pickByRay, pick, implementation + || node.geometry.pickByRay + || node.geometry.pick + ) + ) { + this._intersectRenderable(node, out); + } } - else { - prev.next = entry; - entry.prev = prev; + for (var i = 0; i < node._children.length; i++) { + this._intersectNode(node._children[i], out, forcePickAll); } - entry.next = next; - next.prev = entry; - } - else { - this.insert(val); - } -}; + }, -LinkedList.prototype.insertBeforeEntry = function (val, next) { - var entry = new LinkedList.Entry(val); - var prev = next.prev; - if (!prev) { //next is head - this.head = entry; - } - else { - prev.next = entry; - entry.prev = prev; - } - entry.next = next; - next.prev = entry; + _intersectRenderable: (function () { - this._length++; -}; + var v1 = new __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */](); + var v2 = new __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */](); + var v3 = new __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */](); + var ray = new __WEBPACK_IMPORTED_MODULE_1__math_Ray__["a" /* default */](); + var worldInverse = new __WEBPACK_IMPORTED_MODULE_4__math_Matrix4__["a" /* default */](); -/** - * Insert an entry at the tail - * @param {clay.core.LinkedList.Entry} entry - */ -LinkedList.prototype.insertEntry = function (entry) { - if (!this.head) { - this.head = this.tail = entry; - } - else { - this.tail.next = entry; - entry.prev = this.tail; - this.tail = entry; - } - this._length++; -}; + return function (renderable, out) { -/** - * Remove entry. - * @param {clay.core.LinkedList.Entry} entry - */ -LinkedList.prototype.remove = function (entry) { - var prev = entry.prev; - var next = entry.next; - if (prev) { - prev.next = next; - } - else { - // Is head - this.head = next; - } - if (next) { - next.prev = prev; - } - else { - // Is tail - this.tail = prev; - } - entry.next = entry.prev = null; - this._length--; -}; + var isSkinnedMesh = renderable.isSkinnedMesh(); + ray.copy(this._ray); + __WEBPACK_IMPORTED_MODULE_4__math_Matrix4__["a" /* default */].invert(worldInverse, renderable.worldTransform); -/** - * Remove entry at index. - * @param {number} idx - * @return {} - */ -LinkedList.prototype.removeAt = function (idx) { - if (idx < 0) { - return; - } - var curr = this.head; - var cursor = 0; - while (curr && cursor != idx) { - curr = curr.next; - cursor++; - } - if (curr) { - this.remove(curr); - return curr.value; - } -}; -/** - * Get head value - * @return {} - */ -LinkedList.prototype.getHead = function () { - if (this.head) { - return this.head.value; - } -}; -/** - * Get tail value - * @return {} - */ -LinkedList.prototype.getTail = function () { - if (this.tail) { - return this.tail.value; - } -}; -/** - * Get value at idx - * @param {number} idx - * @return {} - */ -LinkedList.prototype.getAt = function (idx) { - if (idx < 0) { - return; - } - var curr = this.head; - var cursor = 0; - while (curr && cursor != idx) { - curr = curr.next; - cursor++; - } - return curr.value; -}; + // Skinned mesh will ignore the world transform. + if (!isSkinnedMesh) { + ray.applyTransform(worldInverse); + } -/** - * @param {} value - * @return {number} - */ -LinkedList.prototype.indexOf = function (value) { - var curr = this.head; - var cursor = 0; - while (curr) { - if (curr.value === value) { - return cursor; - } - curr = curr.next; - cursor++; - } -}; + var geometry = renderable.geometry; -/** - * @return {number} - */ -LinkedList.prototype.length = function () { - return this._length; -}; + var bbox = isSkinnedMesh ? renderable.skeleton.boundingBox : geometry.boundingBox; -/** - * If list is empty - */ -LinkedList.prototype.isEmpty = function () { - return this._length === 0; -}; + if (bbox && !ray.intersectBoundingBox(bbox)) { + return; + } + // Use user defined picking algorithm + if (geometry.pick) { + geometry.pick( + this._ndc.x, this._ndc.y, + this.renderer, + this.camera, + renderable, out + ); + return; + } + // Use user defined ray picking algorithm + else if (geometry.pickByRay) { + geometry.pickByRay(ray, renderable, out); + return; + } -/** - * @param {Function} cb - * @param {} context - */ -LinkedList.prototype.forEach = function (cb, context) { - var curr = this.head; - var idx = 0; - var haveContext = typeof(context) != 'undefined'; - while (curr) { - if (haveContext) { - cb.call(context, curr.value, idx); - } - else { - cb(curr.value, idx); - } - curr = curr.next; - idx++; - } -}; + var cullBack = (renderable.cullFace === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].BACK && renderable.frontFace === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].CCW) + || (renderable.cullFace === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].FRONT && renderable.frontFace === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].CW); + + var point; + var indices = geometry.indices; + var positionAttr = geometry.attributes.position; + var weightAttr = geometry.attributes.weight; + var jointAttr = geometry.attributes.joint; + var skinMatricesArray; + var skinMatrices = []; + // Check if valid. + if (!positionAttr || !positionAttr.value || !indices) { + return; + } + if (isSkinnedMesh) { + skinMatricesArray = renderable.skeleton.getSubSkinMatrices(renderable.__uid__, renderable.joints); + for (var i = 0; i < renderable.joints.length; i++) { + skinMatrices[i] = skinMatrices[i] || []; + for (var k = 0; k < 16; k++) { + skinMatrices[i][k] = skinMatricesArray[i * 16 + k]; + } + } + var pos = []; + var weight = []; + var joint = []; + var skinnedPos = []; + var tmp = []; + var skinnedPositionAttr = geometry.attributes.skinnedPosition; + if (!skinnedPositionAttr || !skinnedPositionAttr.value) { + geometry.createAttribute('skinnedPosition', 'f', 3); + skinnedPositionAttr = geometry.attributes.skinnedPosition; + skinnedPositionAttr.init(geometry.vertexCount); + } + for (var i = 0; i < geometry.vertexCount; i++) { + positionAttr.get(i, pos); + weightAttr.get(i, weight); + jointAttr.get(i, joint); + weight[3] = 1 - weight[0] - weight[1] - weight[2]; + __WEBPACK_IMPORTED_MODULE_7__glmatrix_vec3__["a" /* default */].set(skinnedPos, 0, 0, 0); + for (var k = 0; k < 4; k++) { + if (joint[k] >= 0 && weight[k] > 1e-4) { + __WEBPACK_IMPORTED_MODULE_7__glmatrix_vec3__["a" /* default */].transformMat4(tmp, pos, skinMatrices[joint[k]]); + __WEBPACK_IMPORTED_MODULE_7__glmatrix_vec3__["a" /* default */].scaleAndAdd(skinnedPos, skinnedPos, tmp, weight[k]); + } + } + skinnedPositionAttr.set(i, skinnedPos); + } + } + + for (var i = 0; i < indices.length; i += 3) { + var i1 = indices[i]; + var i2 = indices[i + 1]; + var i3 = indices[i + 2]; + var finalPosAttr = isSkinnedMesh + ? geometry.attributes.skinnedPosition + : positionAttr; + finalPosAttr.get(i1, v1.array); + finalPosAttr.get(i2, v2.array); + finalPosAttr.get(i3, v3.array); + + if (cullBack) { + point = ray.intersectTriangle(v1, v2, v3, renderable.culling); + } + else { + point = ray.intersectTriangle(v1, v3, v2, renderable.culling); + } + if (point) { + var pointW = new __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */](); + if (!isSkinnedMesh) { + __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].transformMat4(pointW, point, renderable.worldTransform); + } + else { + // TODO point maybe not right. + __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].copy(pointW, point); + } + out.push(new RayPicking.Intersection( + point, pointW, renderable, [i1, i2, i3], i / 3, + __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].dist(pointW, this._ray.origin) + )); + } + } + }; + })(), -/** - * Clear the list - */ -LinkedList.prototype.clear = function () { - this.tail = this.head = null; - this._length = 0; -}; + _intersectionCompareFunc: function (a, b) { + return a.distance - b.distance; + } +}); /** - * @constructor - * @param {} val + * @constructor clay.picking.RayPicking~Intersection + * @param {clay.Vector3} point + * @param {clay.Vector3} pointWorld + * @param {clay.Node} target + * @param {Array.} triangle + * @param {number} triangleIndex + * @param {number} distance */ -LinkedList.Entry = function (val) { +RayPicking.Intersection = function (point, pointWorld, target, triangle, triangleIndex, distance) { /** - * @type {} + * Intersection point in local transform coordinates + * @type {clay.Vector3} */ - this.value = val; - + this.point = point; /** - * @type {clay.core.LinkedList.Entry} + * Intersection point in world transform coordinates + * @type {clay.Vector3} */ - this.next = null; - + this.pointWorld = pointWorld; /** - * @type {clay.core.LinkedList.Entry} + * Intersection scene node + * @type {clay.Node} */ - this.prev = null; + this.target = target; + /** + * Intersection triangle, which is an array of vertex index + * @type {Array.} + */ + this.triangle = triangle; + /** + * Index of intersection triangle. + */ + this.triangleIndex = triangleIndex; + /** + * Distance from intersection point to ray origin + * @type {number} + */ + this.distance = distance; }; -/* harmony default export */ __webpack_exports__["a"] = (LinkedList); +/* harmony default export */ __webpack_exports__["a"] = (RayPicking); /***/ }), -/* 107 */ +/* 118 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__GLProgram__ = __webpack_require__(108); - - -var loopRegex = /for\s*?\(int\s*?_idx_\s*\=\s*([\w-]+)\;\s*_idx_\s*<\s*([\w-]+);\s*_idx_\s*\+\+\s*\)\s*\{\{([\s\S]+?)(?=\}\})\}\}/g; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_Cache__ = __webpack_require__(57); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_vendor__ = __webpack_require__(14); -function unrollLoop(shaderStr, defines, lightsNumbers) { - // Loop unroll from three.js, https://github.com/mrdoob/three.js/blob/master/src/renderers/webgl/WebGLProgram.js#L175 - // In some case like shadowMap in loop use 'i' to index value much slower. - // Loop use _idx_ and increased with _idx_++ will be unrolled - // Use {{ }} to match the pair so the if statement will not be affected - // Write like following - // for (int _idx_ = 0; _idx_ < 4; _idx_++) {{ - // vec3 color = texture2D(textures[_idx_], uv).rgb; - // }} - function replace(match, start, end, snippet) { - var unroll = ''; - // Try to treat as define - if (isNaN(start)) { - if (start in defines) { - start = defines[start]; - } - else { - start = lightNumberDefines[start]; - } - } - if (isNaN(end)) { - if (end in defines) { - end = defines[end]; - } - else { - end = lightNumberDefines[end]; - } - } - // TODO Error checking - for (var idx = parseInt(start); idx < parseInt(end); idx++) { - // PENDING Add scope? - unroll += '{' - + snippet - .replace(/float\s*\(\s*_idx_\s*\)/g, idx.toFixed(1)) - .replace(/_idx_/g, idx) - + '}'; - } - return unroll; - } - var lightNumberDefines = {}; - for (var lightType in lightsNumbers) { - lightNumberDefines[lightType + '_COUNT'] = lightsNumbers[lightType]; - } - return shaderStr.replace(loopRegex, replace); +function getArrayCtorByType (type) { + return ({ + 'byte': __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Int8Array, + 'ubyte': __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Uint8Array, + 'short': __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Int16Array, + 'ushort': __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Uint16Array + })[type] || __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Float32Array; } -function getDefineCode(defines, lightsNumbers, enabledTextures) { - var defineStr = []; - if (lightsNumbers) { - for (var lightType in lightsNumbers) { - var count = lightsNumbers[lightType]; - if (count > 0) { - defineStr.push('#define ' + lightType.toUpperCase() + '_COUNT ' + count); - } - } - } - if (enabledTextures) { - for (var i = 0; i < enabledTextures.length; i++) { - var symbol = enabledTextures[i]; - defineStr.push('#define ' + symbol.toUpperCase() + '_ENABLED'); - } - } - // Custom Defines - for (var symbol in defines) { - var value = defines[symbol]; - if (value === null) { - defineStr.push('#define ' + symbol); - } - else{ - defineStr.push('#define ' + symbol + ' ' + value.toString()); - } - } - return defineStr.join('\n'); +function makeAttrKey(attrName) { + return 'attr_' + attrName; } +/** + * GeometryBase attribute + * @alias clay.GeometryBase.Attribute + * @constructor + */ +function Attribute(name, type, size, semantic) { + /** + * Attribute name + * @type {string} + */ + this.name = name; + /** + * Attribute type + * Possible values: + * + `'byte'` + * + `'ubyte'` + * + `'short'` + * + `'ushort'` + * + `'float'` Most commonly used. + * @type {string} + */ + this.type = type; + /** + * Size of attribute component. 1 - 4. + * @type {number} + */ + this.size = size; + /** + * Semantic of this attribute. + * Possible values: + * + `'POSITION'` + * + `'NORMAL'` + * + `'BINORMAL'` + * + `'TANGENT'` + * + `'TEXCOORD'` + * + `'TEXCOORD_0'` + * + `'TEXCOORD_1'` + * + `'COLOR'` + * + `'JOINT'` + * + `'WEIGHT'` + * + * In shader, attribute with same semantic will be automatically mapped. For example: + * ```glsl + * attribute vec3 pos: POSITION + * ``` + * will use the attribute value with semantic POSITION in geometry, no matter what name it used. + * @type {string} + */ + this.semantic = semantic || ''; -function getExtensionCode(exts) { - // Extension declaration must before all non-preprocessor codes - // TODO vertex ? extension enum ? - var extensionStr = []; - for (var i = 0; i < exts.length; i++) { - extensionStr.push('#extension GL_' + exts[i] + ' : enable'); - } - return extensionStr.join('\n'); -} + /** + * Value of the attribute. + * @type {TypedArray} + */ + this.value = null; -function getPrecisionCode(precision) { - return ['precision', precision, 'float'].join(' ') + ';\n' - + ['precision', precision, 'int'].join(' ') + ';\n' - // depth texture may have precision problem on iOS device. - + ['precision', precision, 'sampler2D'].join(' ') + ';\n'; + // Init getter setter + switch (size) { + case 1: + this.get = function (idx) { + return this.value[idx]; + }; + this.set = function (idx, value) { + this.value[idx] = value; + }; + // Copy from source to target + this.copy = function (target, source) { + this.value[target] = this.value[target]; + }; + break; + case 2: + this.get = function (idx, out) { + var arr = this.value; + out[0] = arr[idx * 2]; + out[1] = arr[idx * 2 + 1]; + return out; + }; + this.set = function (idx, val) { + var arr = this.value; + arr[idx * 2] = val[0]; + arr[idx * 2 + 1] = val[1]; + }; + this.copy = function (target, source) { + var arr = this.value; + source *= 2; + target *= 2; + arr[target] = arr[source]; + arr[target + 1] = arr[source + 1]; + }; + break; + case 3: + this.get = function (idx, out) { + var idx3 = idx * 3; + var arr = this.value; + out[0] = arr[idx3]; + out[1] = arr[idx3 + 1]; + out[2] = arr[idx3 + 2]; + return out; + }; + this.set = function (idx, val) { + var idx3 = idx * 3; + var arr = this.value; + arr[idx3] = val[0]; + arr[idx3 + 1] = val[1]; + arr[idx3 + 2] = val[2]; + }; + this.copy = function (target, source) { + var arr = this.value; + source *= 3; + target *= 3; + arr[target] = arr[source]; + arr[target + 1] = arr[source + 1]; + arr[target + 2] = arr[source + 2]; + }; + break; + case 4: + this.get = function (idx, out) { + var arr = this.value; + var idx4 = idx * 4; + out[0] = arr[idx4]; + out[1] = arr[idx4 + 1]; + out[2] = arr[idx4 + 2]; + out[3] = arr[idx4 + 3]; + return out; + }; + this.set = function (idx, val) { + var arr = this.value; + var idx4 = idx * 4; + arr[idx4] = val[0]; + arr[idx4 + 1] = val[1]; + arr[idx4 + 2] = val[2]; + arr[idx4 + 3] = val[3]; + }; + this.copy = function (target, source) { + var arr = this.value; + source *= 4; + target *= 4; + // copyWithin is extremely slow + arr[target] = arr[source]; + arr[target + 1] = arr[source + 1]; + arr[target + 2] = arr[source + 2]; + arr[target + 3] = arr[source + 3]; + }; + } } -function ProgramManager(renderer) { - this._renderer = renderer; - this._cache = {}; -} +/** + * Set item value at give index. Second parameter val is number if size is 1 + * @function + * @name clay.GeometryBase.Attribute#set + * @param {number} idx + * @param {number[]|number} val + * @example + * geometry.getAttribute('position').set(0, [1, 1, 1]); + */ -ProgramManager.prototype.getProgram = function (renderable, material, scene) { - var cache = this._cache; +/** + * Get item value at give index. Second parameter out is no need if size is 1 + * @function + * @name clay.GeometryBase.Attribute#set + * @param {number} idx + * @param {number[]} [out] + * @example + * geometry.getAttribute('position').get(0, out); + */ - var key = 's' + material.shader.shaderID + 'm' + material.getProgramKey(); - if (scene) { - key += 'se' + scene.getProgramKey(renderable.lightGroup); - } - if (renderable.isSkinnedMesh()) { - key += ',' + renderable.joints.length; +/** + * Initialize attribute with given vertex count + * @param {number} nVertex + */ +Attribute.prototype.init = function (nVertex) { + if (!this.value || this.value.length != nVertex * this.size) { + var ArrayConstructor = getArrayCtorByType(this.type); + this.value = new ArrayConstructor(nVertex * this.size); } - var program = cache[key]; +}; - if (program) { - return program; +/** + * Initialize attribute with given array. Which can be 1 dimensional or 2 dimensional + * @param {Array} array + * @example + * geometry.getAttribute('position').fromArray( + * [-1, 0, 0, 1, 0, 0, 0, 1, 0] + * ); + * geometry.getAttribute('position').fromArray( + * [ [-1, 0, 0], [1, 0, 0], [0, 1, 0] ] + * ); + */ +Attribute.prototype.fromArray = function (array) { + var ArrayConstructor = getArrayCtorByType(this.type); + var value; + // Convert 2d array to flat + if (array[0] && (array[0].length)) { + var n = 0; + var size = this.size; + value = new ArrayConstructor(array.length * size); + for (var i = 0; i < array.length; i++) { + for (var j = 0; j < size; j++) { + value[n++] = array[i][j]; + } + } } - - var lightsNumbers = scene ? scene.getLightsNumbers(renderable.lightGroup) : {}; - var renderer = this._renderer; - var _gl = renderer.gl; - var enabledTextures = material.getEnabledTextures(); - var skinDefineCode = ''; - if (renderable.isSkinnedMesh()) { - // TODO Add skinning code? - skinDefineCode = '\n' + getDefineCode({ - SKINNING: null, - JOINT_COUNT: renderable.joints.length - }) + '\n'; + else { + value = new ArrayConstructor(array); } - // TODO Optimize key generation - // VERTEX - var vertexDefineStr = skinDefineCode + getDefineCode(material.vertexDefines, lightsNumbers, enabledTextures); - // FRAGMENT - var fragmentDefineStr = skinDefineCode + getDefineCode(material.fragmentDefines, lightsNumbers, enabledTextures); - - var vertexCode = vertexDefineStr + '\n' + material.shader.vertex; - var fragmentCode = getExtensionCode([ - // TODO Not hard coded - 'OES_standard_derivatives', - 'EXT_shader_texture_lod' - ]) + '\n' - + getPrecisionCode(material.precision) + '\n' - + fragmentDefineStr + '\n' + material.shader.fragment; - - var finalVertexCode = unrollLoop(vertexCode, material.vertexDefines, lightsNumbers); - var finalFragmentCode = unrollLoop(fragmentCode, material.fragmentDefines, lightsNumbers); - - var program = new __WEBPACK_IMPORTED_MODULE_0__GLProgram__["a" /* default */](); - program.uniformSemantics = material.shader.uniformSemantics; - program.attributes = material.shader.attributes; - var errorMsg = program.buildProgram(_gl, material.shader, finalVertexCode, finalFragmentCode); - program.__error = errorMsg; - - cache[key] = program; - - return program; + this.value = value; }; -/* harmony default export */ __webpack_exports__["a"] = (ProgramManager); - -/***/ }), -/* 108 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +Attribute.prototype.clone = function(copyValue) { + var ret = new Attribute(this.name, this.type, this.size, this.semantic); + // FIXME + if (copyValue) { + console.warn('todo'); + } + return ret; +}; -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_vendor__ = __webpack_require__(18); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Base__ = __webpack_require__(9); +function AttributeBuffer(name, type, buffer, size, semantic) { + this.name = name; + this.type = type; + this.buffer = buffer; + this.size = size; + this.semantic = semantic; + // To be set in mesh + // symbol in the shader + this.symbol = ''; + // Needs remove flag + this.needsRemove = false; +} -var SHADER_STATE_TO_ENABLE = 1; -var SHADER_STATE_KEEP_ENABLE = 2; -var SHADER_STATE_PENDING = 3; +function IndicesBuffer(buffer) { + this.buffer = buffer; + this.count = 0; +} -// Enable attribute operation is global to all programs -// Here saved the list of all enabled attribute index -// http://www.mjbshaw.com/2013/03/webgl-fixing-invalidoperation.html -var enabledAttributeList = {}; +/** + * Base of all geometry. Use {@link clay.Geometry} for common 3D usage. + * @constructor clay.GeometryBase + * @extends clay.core.Base + */ +var GeometryBase = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () { + return /** @lends clay.GeometryBase# */ { + /** + * Attributes of geometry. + * @type {Object.} + */ + attributes: {}, -// some util functions -function addLineNumbers(string) { - var chunks = string.split('\n'); - for (var i = 0, il = chunks.length; i < il; i ++) { - // Chrome reports shader errors on lines - // starting counting from 1 - chunks[i] = (i + 1) + ': ' + chunks[i]; - } - return chunks.join('\n'); -} + /** + * Indices of geometry. + * @type {Uint16Array|Uint32Array} + */ + indices: null, -// Return true or error msg if error happened -function checkShaderErrorMsg(_gl, shader, shaderString) { - if (!_gl.getShaderParameter(shader, _gl.COMPILE_STATUS)) { - return [_gl.getShaderInfoLog(shader), addLineNumbers(shaderString)].join('\n'); - } -} + /** + * Is vertices data dynamically updated. + * Attributes value can't be changed after first render if dyanmic is false. + * @type {boolean} + */ + dynamic: true, -var tmpFloat32Array16 = new __WEBPACK_IMPORTED_MODULE_0__core_vendor__["a" /* default */].Float32Array(16); + _enabledAttributes: null, -var GLProgram = __WEBPACK_IMPORTED_MODULE_1__core_Base__["a" /* default */].extend({ + // PENDING + // Init it here to avoid deoptimization when it's assigned in application dynamically + __used: 0 + }; +}, function() { + // Use cache + this._cache = new __WEBPACK_IMPORTED_MODULE_2__core_Cache__["a" /* default */](); - uniformSemantics: {}, - attributes: {} + this._attributeList = Object.keys(this.attributes); -}, function () { - this._locations = {}; + this.__vaoCache = {}; +}, +/** @lends clay.GeometryBase.prototype */ +{ + /** + * Main attribute will be used to count vertex number + * @type {string} + */ + mainAttribute: '', + /** + * User defined picking algorithm instead of default + * triangle ray intersection + * x, y are NDC. + * ```typescript + * (x, y, renderer, camera, renderable, out) => boolean + * ``` + * @type {?Function} + */ + pick: null, - this._textureSlot = 0; + /** + * User defined ray picking algorithm instead of default + * triangle ray intersection + * ```typescript + * (ray: clay.Ray, renderable: clay.Renderable, out: Array) => boolean + * ``` + * @type {?Function} + */ + pickByRay: null, - this._program = null; -}, { + /** + * Mark attributes and indices in geometry needs to update. + * Usually called after you change the data in attributes. + */ + dirty: function () { + var enabledAttributes = this.getEnabledAttributes(); + for (var i = 0; i < enabledAttributes.length; i++) { + this.dirtyAttribute(enabledAttributes[i]); + } + this.dirtyIndices(); + this._enabledAttributes = null; - bind: function (renderer) { - this._textureSlot = 0; - renderer.gl.useProgram(this._program); + this._cache.dirty('any'); }, - - hasUniform: function (symbol) { - var location = this._locations[symbol]; - return location !== null && location !== undefined; + /** + * Mark the indices needs to update. + */ + dirtyIndices: function () { + this._cache.dirtyAll('indices'); }, - - useTextureSlot: function (renderer, texture, slot) { - if (texture) { - renderer.gl.activeTexture(renderer.gl.TEXTURE0 + slot); - // Maybe texture is not loaded yet; - if (texture.isRenderable()) { - texture.bind(renderer); - } - else { - // Bind texture to null - texture.unbind(renderer); + /** + * Mark the attributes needs to update. + * @param {string} [attrName] + */ + dirtyAttribute: function (attrName) { + this._cache.dirtyAll(makeAttrKey(attrName)); + this._cache.dirtyAll('attributes'); + }, + /** + * Get indices of triangle at given index. + * @param {number} idx + * @param {Array.} out + * @return {Array.} + */ + getTriangleIndices: function (idx, out) { + if (idx < this.triangleCount && idx >= 0) { + if (!out) { + out = []; } + var indices = this.indices; + out[0] = indices[idx * 3]; + out[1] = indices[idx * 3 + 1]; + out[2] = indices[idx * 3 + 2]; + return out; } }, - currentTextureSlot: function () { - return this._textureSlot; + /** + * Set indices of triangle at given index. + * @param {number} idx + * @param {Array.} arr + */ + setTriangleIndices: function (idx, arr) { + var indices = this.indices; + indices[idx * 3] = arr[0]; + indices[idx * 3 + 1] = arr[1]; + indices[idx * 3 + 2] = arr[2]; }, - resetTextureSlot: function (slot) { - this._textureSlot = slot || 0; + isUseIndices: function () { + return !!this.indices; }, - takeCurrentTextureSlot: function (renderer, texture) { - var textureSlot = this._textureSlot; + /** + * Initialize indices from an array. + * @param {Array} array + */ + initIndicesFromArray: function (array) { + var value; + var ArrayConstructor = this.vertexCount > 0xffff + ? __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Uint32Array : __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Uint16Array; + // Convert 2d array to flat + if (array[0] && (array[0].length)) { + var n = 0; + var size = 3; - this.useTextureSlot(renderer, texture, textureSlot); + value = new ArrayConstructor(array.length * size); + for (var i = 0; i < array.length; i++) { + for (var j = 0; j < size; j++) { + value[n++] = array[i][j]; + } + } + } + else { + value = new ArrayConstructor(array); + } - this._textureSlot++; + this.indices = value; + }, + /** + * Create a new attribute + * @param {string} name + * @param {string} type + * @param {number} size + * @param {string} [semantic] + */ + createAttribute: function (name, type, size, semantic) { + var attrib = new Attribute(name, type, size, semantic); + if (this.attributes[name]) { + this.removeAttribute(name); + } + this.attributes[name] = attrib; + this._attributeList.push(name); + return attrib; + }, + /** + * Remove attribute + * @param {string} name + */ + removeAttribute: function (name) { + var attributeList = this._attributeList; + var idx = attributeList.indexOf(name); + if (idx >= 0) { + attributeList.splice(idx, 1); + delete this.attributes[name]; + return true; + } + return false; + }, - return textureSlot; + /** + * Get attribute + * @param {string} name + * @return {clay.GeometryBase.Attribute} + */ + getAttribute: function (name) { + return this.attributes[name]; }, - setUniform: function (_gl, type, symbol, value) { - var locationMap = this._locations; - var location = locationMap[symbol]; - // Uniform is not existed in the shader - if (location === null || location === undefined) { - return false; + /** + * Get enabled attributes name list + * Attribute which has the same vertex number with position is treated as a enabled attribute + * @return {string[]} + */ + getEnabledAttributes: function () { + var enabledAttributes = this._enabledAttributes; + var attributeList = this._attributeList; + // Cache + if (enabledAttributes) { + return enabledAttributes; } - switch (type) { - case 'm4': - if (!(value instanceof Float32Array)) { - // Use Float32Array is much faster than array when uniformMatrix4fv. - for (var i = 0; i < value.length; i++) { - tmpFloat32Array16[i] = value[i]; - } - value = tmpFloat32Array16; - } - _gl.uniformMatrix4fv(location, false, value); - break; - case '2i': - _gl.uniform2i(location, value[0], value[1]); - break; - case '2f': - _gl.uniform2f(location, value[0], value[1]); - break; - case '3i': - _gl.uniform3i(location, value[0], value[1], value[2]); - break; - case '3f': - _gl.uniform3f(location, value[0], value[1], value[2]); - break; - case '4i': - _gl.uniform4i(location, value[0], value[1], value[2], value[3]); - break; - case '4f': - _gl.uniform4f(location, value[0], value[1], value[2], value[3]); - break; - case '1i': - _gl.uniform1i(location, value); - break; - case '1f': - _gl.uniform1f(location, value); - break; - case '1fv': - _gl.uniform1fv(location, value); - break; - case '1iv': - _gl.uniform1iv(location, value); - break; - case '2iv': - _gl.uniform2iv(location, value); - break; - case '2fv': - _gl.uniform2fv(location, value); - break; - case '3iv': - _gl.uniform3iv(location, value); - break; - case '3fv': - _gl.uniform3fv(location, value); - break; - case '4iv': - _gl.uniform4iv(location, value); - break; - case '4fv': - _gl.uniform4fv(location, value); - break; - case 'm2': - case 'm2v': - _gl.uniformMatrix2fv(location, false, value); - break; - case 'm3': - case 'm3v': - _gl.uniformMatrix3fv(location, false, value); - break; - case 'm4v': - // Raw value - if (Array.isArray(value) && Array.isArray(value[0])) { - var array = new __WEBPACK_IMPORTED_MODULE_0__core_vendor__["a" /* default */].Float32Array(value.length * 16); - var cursor = 0; - for (var i = 0; i < value.length; i++) { - var item = value[i]; - for (var j = 0; j < 16; j++) { - array[cursor++] = item[j]; - } - } - _gl.uniformMatrix4fv(location, false, array); - } - else { // ArrayBufferView - _gl.uniformMatrix4fv(location, false, value); + var result = []; + var nVertex = this.vertexCount; + + for (var i = 0; i < attributeList.length; i++) { + var name = attributeList[i]; + var attrib = this.attributes[name]; + if (attrib.value) { + if (attrib.value.length === nVertex * attrib.size) { + result.push(name); } - break; + } } - return true; + + this._enabledAttributes = result; + + return result; }, - setUniformOfSemantic: function (_gl, semantic, val) { - var semanticInfo = this.uniformSemantics[semantic]; - if (semanticInfo) { - return this.setUniform(_gl, semanticInfo.type, semanticInfo.symbol, val); + getBufferChunks: function (renderer) { + var cache = this._cache; + cache.use(renderer.__uid__); + var isAttributesDirty = cache.isDirty('attributes'); + var isIndicesDirty = cache.isDirty('indices'); + if (isAttributesDirty || isIndicesDirty) { + this._updateBuffer(renderer.gl, isAttributesDirty, isIndicesDirty); + var enabledAttributes = this.getEnabledAttributes(); + for (var i = 0; i < enabledAttributes.length; i++) { + cache.fresh(makeAttrKey(enabledAttributes[i])); + } + cache.fresh('attributes'); + cache.fresh('indices'); } - return false; + cache.fresh('any'); + return cache.get('chunks'); }, - // Used for creating VAO - // Enable the attributes passed in and disable the rest - // Example Usage: - // enableAttributes(renderer, ["position", "texcoords"]) - enableAttributes: function (renderer, attribList, vao) { - var _gl = renderer.gl; - var program = this._program; + _updateBuffer: function (_gl, isAttributesDirty, isIndicesDirty) { + var cache = this._cache; + var chunks = cache.get('chunks'); + var firstUpdate = false; + if (!chunks) { + chunks = []; + // Intialize + chunks[0] = { + attributeBuffers: [], + indicesBuffer: null + }; + cache.put('chunks', chunks); + firstUpdate = true; + } - var locationMap = this._locations; + var chunk = chunks[0]; + var attributeBuffers = chunk.attributeBuffers; + var indicesBuffer = chunk.indicesBuffer; - var enabledAttributeListInContext; - if (vao) { - enabledAttributeListInContext = vao.__enabledAttributeList; - } - else { - enabledAttributeListInContext = enabledAttributeList[renderer.__uid__]; - } - if (!enabledAttributeListInContext) { - // In vertex array object context - // PENDING Each vao object needs to enable attributes again? - if (vao) { - enabledAttributeListInContext - = vao.__enabledAttributeList - = []; - } - else { - enabledAttributeListInContext - = enabledAttributeList[renderer.__uid__] - = []; - } - } - var locationList = []; - for (var i = 0; i < attribList.length; i++) { - var symbol = attribList[i]; - if (!this.attributes[symbol]) { - locationList[i] = -1; - continue; - } - var location = locationMap[symbol]; - if (location == null) { - location = _gl.getAttribLocation(program, symbol); - // Attrib location is a number from 0 to ... - if (location === -1) { - locationList[i] = -1; - continue; + if (isAttributesDirty || firstUpdate) { + var attributeList = this.getEnabledAttributes(); + + var attributeBufferMap = {}; + if (!firstUpdate) { + for (var i = 0; i < attributeBuffers.length; i++) { + attributeBufferMap[attributeBuffers[i].name] = attributeBuffers[i]; } - locationMap[symbol] = location; } - locationList[i] = location; + // FIXME If some attributes removed + for (var k = 0; k < attributeList.length; k++) { + var name = attributeList[k]; + var attribute = this.attributes[name]; - if (!enabledAttributeListInContext[location]) { - enabledAttributeListInContext[location] = SHADER_STATE_TO_ENABLE; + var bufferInfo; + + if (!firstUpdate) { + bufferInfo = attributeBufferMap[name]; + } + var buffer; + if (bufferInfo) { + buffer = bufferInfo.buffer; + } + else { + buffer = _gl.createBuffer(); + } + if (cache.isDirty(makeAttrKey(name))) { + // Only update when they are dirty. + // TODO: Use BufferSubData? + _gl.bindBuffer(_gl.ARRAY_BUFFER, buffer); + _gl.bufferData(_gl.ARRAY_BUFFER, attribute.value, this.dynamic ? __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DYNAMIC_DRAW : __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].STATIC_DRAW); + } + + attributeBuffers[k] = new AttributeBuffer(name, attribute.type, buffer, attribute.size, attribute.semantic); } - else { - enabledAttributeListInContext[location] = SHADER_STATE_KEEP_ENABLE; + // Remove unused attributes buffers. + // PENDING + for (var i = k; i < attributeBuffers.length; i++) { + _gl.deleteBuffer(attributeBuffers[i].buffer); } + attributeBuffers.length = k; + } - for (var i = 0; i < enabledAttributeListInContext.length; i++) { - switch(enabledAttributeListInContext[i]){ - case SHADER_STATE_TO_ENABLE: - _gl.enableVertexAttribArray(i); - enabledAttributeListInContext[i] = SHADER_STATE_PENDING; - break; - case SHADER_STATE_KEEP_ENABLE: - enabledAttributeListInContext[i] = SHADER_STATE_PENDING; - break; - // Expired - case SHADER_STATE_PENDING: - _gl.disableVertexAttribArray(i); - enabledAttributeListInContext[i] = 0; - break; + if (this.isUseIndices() && (isIndicesDirty || firstUpdate)) { + if (!indicesBuffer) { + indicesBuffer = new IndicesBuffer(_gl.createBuffer()); + chunk.indicesBuffer = indicesBuffer; } + indicesBuffer.count = this.indices.length; + _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, indicesBuffer.buffer); + _gl.bufferData(_gl.ELEMENT_ARRAY_BUFFER, this.indices, this.dynamic ? __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DYNAMIC_DRAW : __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].STATIC_DRAW); } - - return locationList; }, - buildProgram: function (_gl, shader, vertexShaderCode, fragmentShaderCode) { - var vertexShader = _gl.createShader(_gl.VERTEX_SHADER); - var program = _gl.createProgram(); + /** + * Dispose geometry data in GL context. + * @param {clay.Renderer} renderer + */ + dispose: function (renderer) { - _gl.shaderSource(vertexShader, vertexShaderCode); - _gl.compileShader(vertexShader); + var cache = this._cache; - var fragmentShader = _gl.createShader(_gl.FRAGMENT_SHADER); - _gl.shaderSource(fragmentShader, fragmentShaderCode); - _gl.compileShader(fragmentShader); + cache.use(renderer.__uid__); + var chunks = cache.get('chunks'); + if (chunks) { + for (var c = 0; c < chunks.length; c++) { + var chunk = chunks[c]; - var msg = checkShaderErrorMsg(_gl, vertexShader, vertexShaderCode); - if (msg) { - return msg; - } - msg = checkShaderErrorMsg(_gl, fragmentShader, fragmentShaderCode); - if (msg) { - return msg; - } + for (var k = 0; k < chunk.attributeBuffers.length; k++) { + var attribs = chunk.attributeBuffers[k]; + renderer.gl.deleteBuffer(attribs.buffer); + } - _gl.attachShader(program, vertexShader); - _gl.attachShader(program, fragmentShader); - // Force the position bind to location 0; - if (shader.attributeSemantics['POSITION']) { - _gl.bindAttribLocation(program, 0, shader.attributeSemantics['POSITION'].symbol); + if (chunk.indicesBuffer) { + renderer.gl.deleteBuffer(chunk.indicesBuffer.buffer); + } + } } - else { - // Else choose an attribute and bind to location 0; - var keys = Object.keys(this.attributes); - _gl.bindAttribLocation(program, 0, keys[0]); + if (this.__vaoCache) { + var vaoExt = renderer.getGLExtension('OES_vertex_array_object'); + for (var id in this.__vaoCache) { + var vao = this.__vaoCache[id].vao; + if (vao) { + vaoExt.deleteVertexArrayOES(vao); + } + } } + this.__vaoCache = {}; + cache.deleteContext(renderer.__uid__); + } - _gl.linkProgram(program); +}); - if (!_gl.getProgramParameter(program, _gl.LINK_STATUS)) { - return 'Could not link program\n' + 'VALIDATE_STATUS: ' + _gl.getProgramParameter(program, _gl.VALIDATE_STATUS) + ', gl error [' + _gl.getError() + ']'; +if (Object.defineProperty) { + /** + * @name clay.GeometryBase#vertexCount + * @type {number} + * @readOnly + */ + Object.defineProperty(GeometryBase.prototype, 'vertexCount', { + + enumerable: false, + + get: function () { + + var mainAttribute = this.attributes[this.mainAttribute]; + + if (!mainAttribute) { + mainAttribute = this.attributes[this._attributeList[0]]; + } + + if (!mainAttribute || !mainAttribute.value) { + return 0; + } + return mainAttribute.value.length / mainAttribute.size; } + }); + /** + * @name clay.GeometryBase#triangleCount + * @type {number} + * @readOnly + */ + Object.defineProperty(GeometryBase.prototype, 'triangleCount', { - // Cache uniform locations - for (var i = 0; i < shader.uniforms.length; i++) { - var uniformSymbol = shader.uniforms[i]; - this._locations[uniformSymbol] = _gl.getUniformLocation(program, uniformSymbol); + enumerable: false, + + get: function () { + var indices = this.indices; + if (!indices) { + return 0; + } + else { + return indices.length / 3; + } } + }); +} - _gl.deleteShader(vertexShader); - _gl.deleteShader(fragmentShader); +GeometryBase.STATIC_DRAW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].STATIC_DRAW; +GeometryBase.DYNAMIC_DRAW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DYNAMIC_DRAW; +GeometryBase.STREAM_DRAW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].STREAM_DRAW; - this._program = program; +GeometryBase.AttributeBuffer = AttributeBuffer; +GeometryBase.IndicesBuffer = IndicesBuffer; - // Save code. - this.vertexCode = vertexShaderCode; - this.fragmentCode = fragmentShaderCode; - } -}); +GeometryBase.Attribute = Attribute; + +/* harmony default export */ __webpack_exports__["a"] = (GeometryBase); -/* harmony default export */ __webpack_exports__["a"] = (GLProgram); /***/ }), -/* 109 */ +/* 119 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__calcAmbientSHLight_glsl_js__ = __webpack_require__(110); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__calcAmbientSHLight_glsl_js__ = __webpack_require__(120); var uniformVec3Prefix = 'uniform vec3 '; @@ -31187,7 +31483,7 @@ var unconfigurable = ':unconfigurable;'; /***/ }), -/* 110 */ +/* 120 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -31195,351 +31491,21 @@ var unconfigurable = ':unconfigurable;'; /***/ }), -/* 111 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Ray__ = __webpack_require__(49); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Vector2__ = __webpack_require__(23); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Renderable__ = __webpack_require__(66); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__core_glenum__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7__dep_glmatrix__); - - - - - - - - - -var vec3 = __WEBPACK_IMPORTED_MODULE_7__dep_glmatrix___default.a.vec3; - -/** - * @constructor clay.picking.RayPicking - * @extends clay.core.Base - */ -var RayPicking = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend( -/** @lends clay.picking.RayPicking# */ -{ - /** - * Target scene - * @type {clay.Scene} - */ - scene: null, - /** - * Target camera - * @type {clay.Camera} - */ - camera: null, - /** - * Target renderer - * @type {clay.Renderer} - */ - renderer: null -}, function () { - this._ray = new __WEBPACK_IMPORTED_MODULE_1__math_Ray__["a" /* default */](); - this._ndc = new __WEBPACK_IMPORTED_MODULE_2__math_Vector2__["a" /* default */](); -}, -/** @lends clay.picking.RayPicking.prototype */ -{ - - /** - * Pick the nearest intersection object in the scene - * @param {number} x Mouse position x - * @param {number} y Mouse position y - * @param {boolean} [forcePickAll=false] ignore ignorePicking - * @return {clay.picking.RayPicking~Intersection} - */ - pick: function (x, y, forcePickAll) { - var out = this.pickAll(x, y, [], forcePickAll); - return out[0] || null; - }, - - /** - * Pick all intersection objects, wich will be sorted from near to far - * @param {number} x Mouse position x - * @param {number} y Mouse position y - * @param {Array} [output] - * @param {boolean} [forcePickAll=false] ignore ignorePicking - * @return {Array.} - */ - pickAll: function (x, y, output, forcePickAll) { - this.renderer.screenToNDC(x, y, this._ndc); - this.camera.castRay(this._ndc, this._ray); - - output = output || []; - - this._intersectNode(this.scene, output, forcePickAll || false); - - output.sort(this._intersectionCompareFunc); - - return output; - }, - - _intersectNode: function (node, out, forcePickAll) { - if ((node instanceof __WEBPACK_IMPORTED_MODULE_5__Renderable__["a" /* default */]) && node.isRenderable()) { - if ((!node.ignorePicking || forcePickAll) - && ( - // Only triangle mesh support ray picking - (node.mode === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].TRIANGLES && node.geometry.isUseIndices()) - // Or if geometry has it's own pickByRay, pick, implementation - || node.geometry.pickByRay - || node.geometry.pick - ) - ) { - this._intersectRenderable(node, out); - } - } - for (var i = 0; i < node._children.length; i++) { - this._intersectNode(node._children[i], out, forcePickAll); - } - }, - - _intersectRenderable: (function () { - - var v1 = new __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */](); - var v2 = new __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */](); - var v3 = new __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */](); - var ray = new __WEBPACK_IMPORTED_MODULE_1__math_Ray__["a" /* default */](); - var worldInverse = new __WEBPACK_IMPORTED_MODULE_4__math_Matrix4__["a" /* default */](); - - return function (renderable, out) { - - var isSkinnedMesh = renderable.isSkinnedMesh(); - ray.copy(this._ray); - __WEBPACK_IMPORTED_MODULE_4__math_Matrix4__["a" /* default */].invert(worldInverse, renderable.worldTransform); - - // Skinned mesh will ignore the world transform. - if (!isSkinnedMesh) { - ray.applyTransform(worldInverse); - } - - var geometry = renderable.geometry; - // Ignore bounding box of skinned mesh? - if (!isSkinnedMesh) { - if (geometry.boundingBox) { - if (!ray.intersectBoundingBox(geometry.boundingBox)) { - return; - } - } - } - // Use user defined picking algorithm - if (geometry.pick) { - geometry.pick( - this._ndc.x, this._ndc.y, - this.renderer, - this.camera, - renderable, out - ); - return; - } - // Use user defined ray picking algorithm - else if (geometry.pickByRay) { - geometry.pickByRay(ray, renderable, out); - return; - } - - var cullBack = (renderable.cullFace === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].BACK && renderable.frontFace === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].CCW) - || (renderable.cullFace === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].FRONT && renderable.frontFace === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].CW); - - var point; - var indices = geometry.indices; - var positionAttr = geometry.attributes.position; - var weightAttr = geometry.attributes.weight; - var jointAttr = geometry.attributes.joint; - var skinMatricesArray; - var skinMatrices = []; - // Check if valid. - if (!positionAttr || !positionAttr.value || !indices) { - return; - } - if (isSkinnedMesh) { - skinMatricesArray = renderable.skeleton.getSubSkinMatrices(renderable.__uid__, renderable.joints); - for (var i = 0; i < renderable.joints.length; i++) { - skinMatrices[i] = skinMatrices[i] || []; - for (var k = 0; k < 16; k++) { - skinMatrices[i][k] = skinMatricesArray[i * 16 + k]; - } - } - var pos = []; - var weight = []; - var joint = []; - var skinnedPos = []; - var tmp = []; - var skinnedPositionAttr = geometry.attributes.skinnedPosition; - if (!skinnedPositionAttr || !skinnedPositionAttr.value) { - geometry.createAttribute('skinnedPosition', 'f', 3); - skinnedPositionAttr = geometry.attributes.skinnedPosition; - skinnedPositionAttr.init(geometry.vertexCount); - } - for (var i = 0; i < geometry.vertexCount; i++) { - positionAttr.get(i, pos); - weightAttr.get(i, weight); - jointAttr.get(i, joint); - weight[3] = 1 - weight[0] - weight[1] - weight[2]; - vec3.set(skinnedPos, 0, 0, 0); - for (var k = 0; k < 4; k++) { - if (joint[k] >= 0 && weight[k] > 1e-4) { - vec3.transformMat4(tmp, pos, skinMatrices[joint[k]]); - vec3.scaleAndAdd(skinnedPos, skinnedPos, tmp, weight[k]); - } - } - skinnedPositionAttr.set(i, skinnedPos); - } - } - - for (var i = 0; i < indices.length; i += 3) { - var i1 = indices[i]; - var i2 = indices[i + 1]; - var i3 = indices[i + 2]; - var finalPosAttr = isSkinnedMesh - ? geometry.attributes.skinnedPosition - : positionAttr; - finalPosAttr.get(i1, v1.array); - finalPosAttr.get(i2, v2.array); - finalPosAttr.get(i3, v3.array); - - if (cullBack) { - point = ray.intersectTriangle(v1, v2, v3, renderable.culling); - } - else { - point = ray.intersectTriangle(v1, v3, v2, renderable.culling); - } - if (point) { - var pointW = new __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */](); - if (!isSkinnedMesh) { - __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].transformMat4(pointW, point, renderable.worldTransform); - } - else { - // TODO point maybe not right. - __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].copy(pointW, point); - } - out.push(new RayPicking.Intersection( - point, pointW, renderable, [i1, i2, i3], i / 3, - __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].dist(pointW, this._ray.origin) - )); - } - } - }; - })(), - - _intersectionCompareFunc: function (a, b) { - return a.distance - b.distance; - } -}); - -/** - * @constructor clay.picking.RayPicking~Intersection - * @param {clay.Vector3} point - * @param {clay.Vector3} pointWorld - * @param {clay.Node} target - * @param {Array.} triangle - * @param {number} triangleIndex - * @param {number} distance - */ -RayPicking.Intersection = function (point, pointWorld, target, triangle, triangleIndex, distance) { - /** - * Intersection point in local transform coordinates - * @type {clay.Vector3} - */ - this.point = point; - /** - * Intersection point in world transform coordinates - * @type {clay.Vector3} - */ - this.pointWorld = pointWorld; - /** - * Intersection scene node - * @type {clay.Node} - */ - this.target = target; - /** - * Intersection triangle, which is an array of vertex index - * @type {Array.} - */ - this.triangle = triangle; - /** - * Index of intersection triangle. - */ - this.triangleIndex = triangleIndex; - /** - * Distance from intersection point to ray origin - * @type {number} - */ - this.distance = distance; -}; - -/* harmony default export */ __webpack_exports__["a"] = (RayPicking); - - -/***/ }), -/* 112 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -function get(options) { - - var xhr = new XMLHttpRequest(); - - xhr.open('get', options.url); - // With response type set browser can get and put binary data - // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Sending_and_Receiving_Binary_Data - // Default is text, and it can be set - // arraybuffer, blob, document, json, text - xhr.responseType = options.responseType || 'text'; - - if (options.onprogress) { - //https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest - xhr.onprogress = function(e) { - if (e.lengthComputable) { - var percent = e.loaded / e.total; - options.onprogress(percent, e.loaded, e.total); - } - else { - options.onprogress(null); - } - }; - } - xhr.onload = function(e) { - if (xhr.status >= 400) { - options.onerror && options.onerror(); - } - else { - options.onload && options.onload(xhr.response); - } - }; - if (options.onerror) { - xhr.onerror = options.onerror; - } - xhr.send(null); -} - -/* harmony default export */ __webpack_exports__["a"] = ({ - get : get -}); - - -/***/ }), -/* 113 */ +/* 121 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("@export clay.skydome.vertex\n#define SHADER_NAME skydome\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position : POSITION;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n v_Texcoord = texcoord;\n}\n@end\n@export clay.skydome.fragment\nuniform sampler2D environmentMap;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(environmentMap, v_Texcoord));\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end"); +/* harmony default export */ __webpack_exports__["a"] = ("@export clay.skybox.vertex\n#define SHADER_NAME skybox\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export clay.skybox.fragment\n#define PI 3.1415926\nuniform mat4 viewInverse : VIEWINVERSE;\n#ifdef EQUIRECTANGULAR\nuniform sampler2D environmentMap;\n#else\nuniform samplerCube environmentMap;\n#endif\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n#ifdef EQUIRECTANGULAR\n float phi = acos(V.y);\n float theta = atan(-V.x, V.z) + PI * 0.5;\n vec2 uv = vec2(theta / 2.0 / PI, phi / PI);\n vec4 texel = decodeHDR(texture2D(environmentMap, fract(uv)));\n#else\n #if defined(LOD) || defined(SUPPORT_TEXTURE_LOD)\n vec4 texel = decodeHDR(textureCubeLodEXT(environmentMap, V, lod));\n #else\n vec4 texel = decodeHDR(textureCube(environmentMap, V));\n #endif\n#endif\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end"); /***/ }), -/* 114 */ +/* 122 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(4); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__TextureCube__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__TextureCube__ = __webpack_require__(27); @@ -31699,11 +31665,11 @@ var ret = { /***/ }), -/* 115 */ +/* 123 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(4); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Texture2D__ = __webpack_require__(5); @@ -31885,13 +31851,13 @@ var ret = { /***/ }), -/* 116 */ +/* 124 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector2__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector2__ = __webpack_require__(26); /** * Surface texture in the 3D scene. * Provide management and rendering of zrender shapes and groups @@ -32071,12 +32037,12 @@ EChartsSurface.prototype = { /* harmony default export */ __webpack_exports__["a"] = (EChartsSurface); /***/ }), -/* 117 */ +/* 125 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(21); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_cubemap__ = __webpack_require__(70); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_cubemap__ = __webpack_require__(77); // https://docs.unrealengine.com/latest/INT/Engine/Rendering/LightingAndShadows/AmbientCubemap/ @@ -32113,6 +32079,10 @@ var AmbientCubemapLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */ * @param {number} [size=32] */ prefilter: function (renderer, size) { + if (!renderer.getGLExtension('EXT_shader_texture_lod')) { + console.warn('Device not support textureCubeLodEXT'); + return; + } if (!this._brdfLookup) { this._normalDistribution = __WEBPACK_IMPORTED_MODULE_1__util_cubemap__["a" /* default */].generateNormalDistribution(); this._brdfLookup = __WEBPACK_IMPORTED_MODULE_1__util_cubemap__["a" /* default */].integrateBRDF(renderer, this._normalDistribution); @@ -32135,6 +32105,10 @@ var AmbientCubemapLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */ cubemap.dispose(renderer); }, + getBRDFLookup: function () { + return this._brdfLookup; + }, + uniformTemplates: { ambientCubemapLightColor: { type: '3f', @@ -32171,7 +32145,7 @@ var AmbientCubemapLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */ /***/ }), -/* 118 */ +/* 126 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -32179,15 +32153,7 @@ var AmbientCubemapLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */ /***/ }), -/* 119 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("@export clay.skybox.vertex\n#define SHADER_NAME skybox\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export clay.skybox.fragment\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 viewDirection = normalize(v_WorldPosition - eyePos);\n#ifdef LOD\n vec4 texel = decodeHDR(textureCubeLodEXT(environmentMap, viewDirection, lod));\n#else\n vec4 texel = decodeHDR(textureCube(environmentMap, viewDirection));\n#endif\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end"); - - -/***/ }), -/* 120 */ +/* 127 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -32195,20 +32161,20 @@ var AmbientCubemapLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */ /***/ }), -/* 121 */ +/* 128 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nuniform int maxSampleNumber: 1024\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(maxSampleNumber);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n if (i > maxSampleNumber) {\n break;\n }\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"); +/* harmony default export */ __webpack_exports__["a"] = ("#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(SAMPLE_NUMBER);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"); /***/ }), -/* 122 */ +/* 129 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(21); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_vendor__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_vendor__ = __webpack_require__(14); @@ -32267,22 +32233,21 @@ var AmbientSHLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].ext /***/ }), -/* 123 */ +/* 130 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(4); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__FrameBuffer__ = __webpack_require__(10); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__compositor_Pass__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_vendor__ = __webpack_require__(18); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__plugin_Skybox__ = __webpack_require__(57); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__plugin_Skydome__ = __webpack_require__(56); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__prePass_EnvironmentMap__ = __webpack_require__(55); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Scene__ = __webpack_require__(32); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_9__dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__shader_projectEnvMap_glsl_js__ = __webpack_require__(124); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__compositor_Pass__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_vendor__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__plugin_Skybox__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__plugin_Skydome__ = __webpack_require__(75); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__prePass_EnvironmentMap__ = __webpack_require__(62); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Scene__ = __webpack_require__(36); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__shader_projectEnvMap_glsl_js__ = __webpack_require__(131); // Spherical Harmonic Helpers @@ -32294,7 +32259,6 @@ var AmbientSHLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].ext -var vec3 = __WEBPACK_IMPORTED_MODULE_9__dep_glmatrix___default.a.vec3; var sh = {}; @@ -32382,15 +32346,15 @@ var normalTransform = { // Project on cpu. function projectEnvironmentMapCPU(renderer, cubePixels, width, height) { var coeff = new __WEBPACK_IMPORTED_MODULE_4__core_vendor__["a" /* default */].Float32Array(9 * 3); - var normal = vec3.create(); - var texel = vec3.create(); - var fetchNormal = vec3.create(); + var normal = __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].create(); + var texel = __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].create(); + var fetchNormal = __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].create(); for (var m = 0; m < 9; m++) { - var result = vec3.create(); + var result = __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].create(); for (var k = 0; k < targets.length; k++) { var pixels = cubePixels[targets[k]]; - var sideResult = vec3.create(); + var sideResult = __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].create(); var divider = 0; var i = 0; var transform = normalTransform[targets[k]]; @@ -32401,7 +32365,7 @@ function projectEnvironmentMapCPU(renderer, cubePixels, width, height) { // TODO Flip y? normal[1] = y / (height - 1.0) * 2.0 - 1.0; normal[2] = -1.0; - vec3.normalize(normal, normal); + __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].normalize(normal, normal); fetchNormal[0] = normal[transform[0]] * transform[3]; fetchNormal[1] = normal[transform[1]] * transform[4]; @@ -32416,12 +32380,12 @@ function projectEnvironmentMapCPU(renderer, cubePixels, width, height) { texel[1] *= scale; texel[2] *= scale; - vec3.scaleAndAdd(sideResult, sideResult, texel, harmonics(fetchNormal, m) * -normal[2]); + __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].scaleAndAdd(sideResult, sideResult, texel, harmonics(fetchNormal, m) * -normal[2]); // -normal.z equals cos(theta) of Lambertian divider += -normal[2]; } } - vec3.scaleAndAdd(result, result, sideResult, 1 / divider); + __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].scaleAndAdd(result, result, sideResult, 1 / divider); } coeff[m * 3] = result[0] / 6.0; @@ -32503,7 +32467,7 @@ sh.projectEnvironmentMap = function (renderer, envMap, opts) { /***/ }), -/* 124 */ +/* 131 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -32511,11 +32475,159 @@ sh.projectEnvironmentMap = function (renderer, envMap, opts) { /***/ }), -/* 125 */ +/* 132 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Geometry__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_BoundingBox__ = __webpack_require__(18); + + + +/** + * @constructor clay.geometry.Sphere + * @extends clay.Geometry + * @param {Object} [opt] + * @param {number} [widthSegments] + * @param {number} [heightSegments] + * @param {number} [phiStart] + * @param {number} [phiLength] + * @param {number} [thetaStart] + * @param {number} [thetaLength] + * @param {number} [radius] + */ +var Sphere = __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].extend(/** @lends clay.geometry.Sphere# */ { + dynamic: false, + /** + * @type {number} + */ + widthSegments: 40, + /** + * @type {number} + */ + heightSegments: 20, + + /** + * @type {number} + */ + phiStart: 0, + /** + * @type {number} + */ + phiLength: Math.PI * 2, + + /** + * @type {number} + */ + thetaStart: 0, + /** + * @type {number} + */ + thetaLength: Math.PI, + + /** + * @type {number} + */ + radius: 1 + +}, function() { + this.build(); +}, +/** @lends clay.geometry.Sphere.prototype */ +{ + /** + * Build sphere geometry + */ + build: function() { + var heightSegments = this.heightSegments; + var widthSegments = this.widthSegments; + + var positionAttr = this.attributes.position; + var texcoordAttr = this.attributes.texcoord0; + var normalAttr = this.attributes.normal; + + var vertexCount = (widthSegments + 1) * (heightSegments + 1); + positionAttr.init(vertexCount); + texcoordAttr.init(vertexCount); + normalAttr.init(vertexCount); + + var IndicesCtor = vertexCount > 0xffff ? Uint32Array : Uint16Array; + var indices = this.indices = new IndicesCtor(widthSegments * heightSegments * 6); + + var x, y, z, + u, v, + i, j; + + var radius = this.radius; + var phiStart = this.phiStart; + var phiLength = this.phiLength; + var thetaStart = this.thetaStart; + var thetaLength = this.thetaLength; + var radius = this.radius; + + var pos = []; + var uv = []; + var offset = 0; + var divider = 1 / radius; + for (j = 0; j <= heightSegments; j ++) { + for (i = 0; i <= widthSegments; i ++) { + u = i / widthSegments; + v = j / heightSegments; + + // X axis is inverted so texture can be mapped from left to right + x = -radius * Math.cos(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength); + y = radius * Math.cos(thetaStart + v * thetaLength); + z = radius * Math.sin(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength); + + pos[0] = x; pos[1] = y; pos[2] = z; + uv[0] = u; uv[1] = v; + positionAttr.set(offset, pos); + texcoordAttr.set(offset, uv); + pos[0] *= divider; + pos[1] *= divider; + pos[2] *= divider; + normalAttr.set(offset, pos); + offset++; + } + } + + var i1, i2, i3, i4; + + var len = widthSegments + 1; + + var n = 0; + for (j = 0; j < heightSegments; j ++) { + for (i = 0; i < widthSegments; i ++) { + i2 = j * len + i; + i1 = (j * len + i + 1); + i4 = (j + 1) * len + i + 1; + i3 = (j + 1) * len + i; + + indices[n++] = i1; + indices[n++] = i2; + indices[n++] = i4; + + indices[n++] = i2; + indices[n++] = i3; + indices[n++] = i4; + } + } + + this.boundingBox = new __WEBPACK_IMPORTED_MODULE_1__math_BoundingBox__["a" /* default */](); + this.boundingBox.max.set(radius, radius, radius); + this.boundingBox.min.set(-radius, -radius, -radius); + } +}); + +/* harmony default export */ __webpack_exports__["a"] = (Sphere); + + +/***/ }), +/* 133 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(24); /** @@ -32552,12 +32664,12 @@ var AmbientLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].exten /***/ }), -/* 126 */ +/* 134 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(21); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Vector3__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Vector3__ = __webpack_require__(3); @@ -32633,11 +32745,11 @@ var DirectionalLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].e /***/ }), -/* 127 */ +/* 135 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(24); /** @@ -32695,12 +32807,12 @@ var PointLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].extend( /***/ }), -/* 128 */ +/* 136 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(21); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Vector3__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Vector3__ = __webpack_require__(3); @@ -32708,9 +32820,7 @@ var PointLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].extend( * @constructor clay.light.Spot * @extends clay.Light */ -var SpotLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].extend( -/**@lends clay.light.Spot */ -{ +var SpotLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].extend(/**@lends clay.light.Spot */ { /** * @type {number} */ @@ -32730,12 +32840,12 @@ var SpotLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].extend( /** * @type {number} */ - shadowBias: 0.0002, + shadowBias: 0.001, /** * @type {number} */ shadowSlopeScale: 2.0 -},{ +}, { type: 'SPOT_LIGHT', @@ -32807,14 +32917,12 @@ var SpotLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].extend( /***/ }), -/* 129 */ +/* 137 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__ = __webpack_require__(33); -var vec4 = __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default.a.vec4; /** * @constructor @@ -32838,7 +32946,7 @@ var Vector4 = function(x, y, z, w) { * @type {Float32Array} * @memberOf clay.Vector4# */ - this.array = vec4.fromValues(x, y, z, w); + this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].fromValues(x, y, z, w); /** * Dirty flag is used by the Node to determine @@ -32860,7 +32968,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ add: function(b) { - vec4.add(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].add(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -32911,7 +33019,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ copy: function(b) { - vec4.copy(this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].copy(this.array, b.array); this._dirty = true; return this; }, @@ -32922,7 +33030,7 @@ Vector4.prototype = { * @return {number} */ dist: function(b) { - return vec4.dist(this.array, b.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].dist(this.array, b.array); }, /** @@ -32931,7 +33039,7 @@ Vector4.prototype = { * @return {number} */ distance: function(b) { - return vec4.distance(this.array, b.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].distance(this.array, b.array); }, /** @@ -32940,7 +33048,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ div: function(b) { - vec4.div(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].div(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -32951,7 +33059,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ divide: function(b) { - vec4.divide(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].divide(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -32962,7 +33070,7 @@ Vector4.prototype = { * @return {number} */ dot: function(b) { - return vec4.dot(this.array, b.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].dot(this.array, b.array); }, /** @@ -32970,7 +33078,7 @@ Vector4.prototype = { * @return {number} */ len: function() { - return vec4.len(this.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].len(this.array); }, /** @@ -32978,7 +33086,7 @@ Vector4.prototype = { * @return {number} */ length: function() { - return vec4.length(this.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].length(this.array); }, /** * Linear interpolation between a and b @@ -32988,7 +33096,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ lerp: function(a, b, t) { - vec4.lerp(this.array, a.array, b.array, t); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].lerp(this.array, a.array, b.array, t); this._dirty = true; return this; }, @@ -32999,7 +33107,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ min: function(b) { - vec4.min(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].min(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -33010,7 +33118,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ max: function(b) { - vec4.max(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].max(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -33021,7 +33129,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ mul: function(b) { - vec4.mul(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].mul(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -33032,7 +33140,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ multiply: function(b) { - vec4.multiply(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].multiply(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -33042,7 +33150,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ negate: function() { - vec4.negate(this.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].negate(this.array, this.array); this._dirty = true; return this; }, @@ -33052,7 +33160,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ normalize: function() { - vec4.normalize(this.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].normalize(this.array, this.array); this._dirty = true; return this; }, @@ -33063,7 +33171,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ random: function(scale) { - vec4.random(this.array, scale); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].random(this.array, scale); this._dirty = true; return this; }, @@ -33074,7 +33182,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ scale: function(s) { - vec4.scale(this.array, this.array, s); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].scale(this.array, this.array, s); this._dirty = true; return this; }, @@ -33085,7 +33193,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ scaleAndAdd: function(b, s) { - vec4.scaleAndAdd(this.array, this.array, b.array, s); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].scaleAndAdd(this.array, this.array, b.array, s); this._dirty = true; return this; }, @@ -33096,7 +33204,7 @@ Vector4.prototype = { * @return {number} */ sqrDist: function(b) { - return vec4.sqrDist(this.array, b.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].sqrDist(this.array, b.array); }, /** @@ -33105,7 +33213,7 @@ Vector4.prototype = { * @return {number} */ squaredDistance: function(b) { - return vec4.squaredDistance(this.array, b.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].squaredDistance(this.array, b.array); }, /** @@ -33113,7 +33221,7 @@ Vector4.prototype = { * @return {number} */ sqrLen: function() { - return vec4.sqrLen(this.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].sqrLen(this.array); }, /** @@ -33121,7 +33229,7 @@ Vector4.prototype = { * @return {number} */ squaredLength: function() { - return vec4.squaredLength(this.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].squaredLength(this.array); }, /** @@ -33130,7 +33238,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ sub: function(b) { - vec4.sub(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].sub(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -33141,7 +33249,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ subtract: function(b) { - vec4.subtract(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].subtract(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -33152,7 +33260,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ transformMat4: function(m) { - vec4.transformMat4(this.array, this.array, m.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].transformMat4(this.array, this.array, m.array); this._dirty = true; return this; }, @@ -33163,7 +33271,7 @@ Vector4.prototype = { * @return {clay.Vector4} */ transformQuat: function(q) { - vec4.transformQuat(this.array, this.array, q.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].transformQuat(this.array, this.array, q.array); this._dirty = true; return this; }, @@ -33256,7 +33364,7 @@ if (defineProperty) { * @return {clay.Vector4} */ Vector4.add = function(out, a, b) { - vec4.add(out.array, a.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].add(out.array, a.array, b.array); out._dirty = true; return out; }; @@ -33269,7 +33377,7 @@ Vector4.add = function(out, a, b) { * @return {clay.Vector4} */ Vector4.set = function(out, x, y, z, w) { - vec4.set(out.array, x, y, z, w); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].set(out.array, x, y, z, w); out._dirty = true; }; @@ -33279,7 +33387,7 @@ Vector4.set = function(out, x, y, z, w) { * @return {clay.Vector4} */ Vector4.copy = function(out, b) { - vec4.copy(out.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].copy(out.array, b.array); out._dirty = true; return out; }; @@ -33290,7 +33398,7 @@ Vector4.copy = function(out, b) { * @return {number} */ Vector4.dist = function(a, b) { - return vec4.distance(a.array, b.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].distance(a.array, b.array); }; /** @@ -33308,7 +33416,7 @@ Vector4.distance = Vector4.dist; * @return {clay.Vector4} */ Vector4.div = function(out, a, b) { - vec4.divide(out.array, a.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].divide(out.array, a.array, b.array); out._dirty = true; return out; }; @@ -33328,7 +33436,7 @@ Vector4.divide = Vector4.div; * @return {number} */ Vector4.dot = function(a, b) { - return vec4.dot(a.array, b.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].dot(a.array, b.array); }; /** @@ -33336,7 +33444,7 @@ Vector4.dot = function(a, b) { * @return {number} */ Vector4.len = function(b) { - return vec4.length(b.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].length(b.array); }; // Vector4.length = Vector4.len; @@ -33349,7 +33457,7 @@ Vector4.len = function(b) { * @return {clay.Vector4} */ Vector4.lerp = function(out, a, b, t) { - vec4.lerp(out.array, a.array, b.array, t); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].lerp(out.array, a.array, b.array, t); out._dirty = true; return out; }; @@ -33361,7 +33469,7 @@ Vector4.lerp = function(out, a, b, t) { * @return {clay.Vector4} */ Vector4.min = function(out, a, b) { - vec4.min(out.array, a.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].min(out.array, a.array, b.array); out._dirty = true; return out; }; @@ -33373,7 +33481,7 @@ Vector4.min = function(out, a, b) { * @return {clay.Vector4} */ Vector4.max = function(out, a, b) { - vec4.max(out.array, a.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].max(out.array, a.array, b.array); out._dirty = true; return out; }; @@ -33385,7 +33493,7 @@ Vector4.max = function(out, a, b) { * @return {clay.Vector4} */ Vector4.mul = function(out, a, b) { - vec4.multiply(out.array, a.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].multiply(out.array, a.array, b.array); out._dirty = true; return out; }; @@ -33405,7 +33513,7 @@ Vector4.multiply = Vector4.mul; * @return {clay.Vector4} */ Vector4.negate = function(out, a) { - vec4.negate(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].negate(out.array, a.array); out._dirty = true; return out; }; @@ -33416,7 +33524,7 @@ Vector4.negate = function(out, a) { * @return {clay.Vector4} */ Vector4.normalize = function(out, a) { - vec4.normalize(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].normalize(out.array, a.array); out._dirty = true; return out; }; @@ -33427,7 +33535,7 @@ Vector4.normalize = function(out, a) { * @return {clay.Vector4} */ Vector4.random = function(out, scale) { - vec4.random(out.array, scale); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].random(out.array, scale); out._dirty = true; return out; }; @@ -33439,7 +33547,7 @@ Vector4.random = function(out, scale) { * @return {clay.Vector4} */ Vector4.scale = function(out, a, scale) { - vec4.scale(out.array, a.array, scale); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].scale(out.array, a.array, scale); out._dirty = true; return out; }; @@ -33452,7 +33560,7 @@ Vector4.scale = function(out, a, scale) { * @return {clay.Vector4} */ Vector4.scaleAndAdd = function(out, a, b, scale) { - vec4.scaleAndAdd(out.array, a.array, b.array, scale); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].scaleAndAdd(out.array, a.array, b.array, scale); out._dirty = true; return out; }; @@ -33463,7 +33571,7 @@ Vector4.scaleAndAdd = function(out, a, b, scale) { * @return {number} */ Vector4.sqrDist = function(a, b) { - return vec4.sqrDist(a.array, b.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].sqrDist(a.array, b.array); }; /** @@ -33479,7 +33587,7 @@ Vector4.squaredDistance = Vector4.sqrDist; * @return {number} */ Vector4.sqrLen = function(a) { - return vec4.sqrLen(a.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].sqrLen(a.array); }; /** * @function @@ -33495,7 +33603,7 @@ Vector4.squaredLength = Vector4.sqrLen; * @return {clay.Vector4} */ Vector4.sub = function(out, a, b) { - vec4.subtract(out.array, a.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].subtract(out.array, a.array, b.array); out._dirty = true; return out; }; @@ -33515,7 +33623,7 @@ Vector4.subtract = Vector4.sub; * @return {clay.Vector4} */ Vector4.transformMat4 = function(out, a, m) { - vec4.transformMat4(out.array, a.array, m.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].transformMat4(out.array, a.array, m.array); out._dirty = true; return out; }; @@ -33527,7 +33635,7 @@ Vector4.transformMat4 = function(out, a, m) { * @return {clay.Vector4} */ Vector4.transformQuat = function(out, a, q) { - vec4.transformQuat(out.array, a.array, q.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].transformQuat(out.array, a.array, q.array); out._dirty = true; return out; }; @@ -33536,14 +33644,12 @@ Vector4.transformQuat = function(out, a, q) { /***/ }), -/* 130 */ +/* 138 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__ = __webpack_require__(78); -var mat2 = __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default.a.mat2; /** * @constructor @@ -33557,7 +33663,7 @@ var Matrix2 = function() { * @type {Float32Array} * @memberOf clay.Matrix2# */ - this.array = mat2.create(); + this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].create(); /** * @name _dirty @@ -33596,7 +33702,7 @@ Matrix2.prototype = { * @return {clay.Matrix2} */ copy: function(b) { - mat2.copy(this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].copy(this.array, b.array); this._dirty = true; return this; }, @@ -33606,7 +33712,7 @@ Matrix2.prototype = { * @return {clay.Matrix2} */ adjoint: function() { - mat2.adjoint(this.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].adjoint(this.array, this.array); this._dirty = true; return this; }, @@ -33616,7 +33722,7 @@ Matrix2.prototype = { * @return {number} */ determinant: function() { - return mat2.determinant(this.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].determinant(this.array); }, /** @@ -33624,7 +33730,7 @@ Matrix2.prototype = { * @return {clay.Matrix2} */ identity: function() { - mat2.identity(this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].identity(this.array); this._dirty = true; return this; }, @@ -33634,7 +33740,7 @@ Matrix2.prototype = { * @return {clay.Matrix2} */ invert: function() { - mat2.invert(this.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].invert(this.array, this.array); this._dirty = true; return this; }, @@ -33645,7 +33751,7 @@ Matrix2.prototype = { * @return {clay.Matrix2} */ mul: function(b) { - mat2.mul(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].mul(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -33656,7 +33762,7 @@ Matrix2.prototype = { * @return {clay.Matrix2} */ mulLeft: function(a) { - mat2.mul(this.array, a.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].mul(this.array, a.array, this.array); this._dirty = true; return this; }, @@ -33667,7 +33773,7 @@ Matrix2.prototype = { * @return {clay.Matrix2} */ multiply: function(b) { - mat2.multiply(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].multiply(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -33678,7 +33784,7 @@ Matrix2.prototype = { * @return {clay.Matrix2} */ multiplyLeft: function(a) { - mat2.multiply(this.array, a.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].multiply(this.array, a.array, this.array); this._dirty = true; return this; }, @@ -33689,7 +33795,7 @@ Matrix2.prototype = { * @return {clay.Matrix2} */ rotate: function(rad) { - mat2.rotate(this.array, this.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].rotate(this.array, this.array, rad); this._dirty = true; return this; }, @@ -33700,7 +33806,7 @@ Matrix2.prototype = { * @return {clay.Matrix2} */ scale: function(v) { - mat2.scale(this.array, this.array, v.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].scale(this.array, this.array, v.array); this._dirty = true; return this; }, @@ -33709,7 +33815,7 @@ Matrix2.prototype = { * @return {clay.Matrix2} */ transpose: function() { - mat2.transpose(this.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].transpose(this.array, this.array); this._dirty = true; return this; }, @@ -33729,7 +33835,7 @@ Matrix2.prototype = { * @return {Matrix2} */ Matrix2.adjoint = function(out, a) { - mat2.adjoint(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].adjoint(out.array, a.array); out._dirty = true; return out; }; @@ -33740,7 +33846,7 @@ Matrix2.adjoint = function(out, a) { * @return {clay.Matrix2} */ Matrix2.copy = function(out, a) { - mat2.copy(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].copy(out.array, a.array); out._dirty = true; return out; }; @@ -33750,7 +33856,7 @@ Matrix2.copy = function(out, a) { * @return {number} */ Matrix2.determinant = function(a) { - return mat2.determinant(a.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].determinant(a.array); }; /** @@ -33758,7 +33864,7 @@ Matrix2.determinant = function(a) { * @return {clay.Matrix2} */ Matrix2.identity = function(out) { - mat2.identity(out.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].identity(out.array); out._dirty = true; return out; }; @@ -33769,7 +33875,7 @@ Matrix2.identity = function(out) { * @return {clay.Matrix2} */ Matrix2.invert = function(out, a) { - mat2.invert(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].invert(out.array, a.array); out._dirty = true; return out; }; @@ -33781,7 +33887,7 @@ Matrix2.invert = function(out, a) { * @return {clay.Matrix2} */ Matrix2.mul = function(out, a, b) { - mat2.mul(out.array, a.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].mul(out.array, a.array, b.array); out._dirty = true; return out; }; @@ -33802,7 +33908,7 @@ Matrix2.multiply = Matrix2.mul; * @return {clay.Matrix2} */ Matrix2.rotate = function(out, a, rad) { - mat2.rotate(out.array, a.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].rotate(out.array, a.array, rad); out._dirty = true; return out; }; @@ -33814,7 +33920,7 @@ Matrix2.rotate = function(out, a, rad) { * @return {clay.Matrix2} */ Matrix2.scale = function(out, a, v) { - mat2.scale(out.array, a.array, v.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].scale(out.array, a.array, v.array); out._dirty = true; return out; }; @@ -33824,7 +33930,7 @@ Matrix2.scale = function(out, a, v) { * @return {Matrix2} */ Matrix2.transpose = function(out, a) { - mat2.transpose(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].transpose(out.array, a.array); out._dirty = true; return out; }; @@ -33833,14 +33939,12 @@ Matrix2.transpose = function(out, a) { /***/ }), -/* 131 */ +/* 139 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__ = __webpack_require__(79); -var mat2d = __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default.a.mat2d; /** * @constructor @@ -33853,7 +33957,7 @@ var Matrix2d = function() { * @type {Float32Array} * @memberOf clay.Matrix2d# */ - this.array = mat2d.create(); + this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].create(); /** * @name _dirty @@ -33892,7 +33996,7 @@ Matrix2d.prototype = { * @return {clay.Matrix2d} */ copy: function(b) { - mat2d.copy(this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].copy(this.array, b.array); this._dirty = true; return this; }, @@ -33902,7 +34006,7 @@ Matrix2d.prototype = { * @return {number} */ determinant: function() { - return mat2d.determinant(this.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].determinant(this.array); }, /** @@ -33910,7 +34014,7 @@ Matrix2d.prototype = { * @return {clay.Matrix2d} */ identity: function() { - mat2d.identity(this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].identity(this.array); this._dirty = true; return this; }, @@ -33920,7 +34024,7 @@ Matrix2d.prototype = { * @return {clay.Matrix2d} */ invert: function() { - mat2d.invert(this.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].invert(this.array, this.array); this._dirty = true; return this; }, @@ -33931,7 +34035,7 @@ Matrix2d.prototype = { * @return {clay.Matrix2d} */ mul: function(b) { - mat2d.mul(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].mul(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -33942,7 +34046,7 @@ Matrix2d.prototype = { * @return {clay.Matrix2d} */ mulLeft: function(b) { - mat2d.mul(this.array, b.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].mul(this.array, b.array, this.array); this._dirty = true; return this; }, @@ -33953,7 +34057,7 @@ Matrix2d.prototype = { * @return {clay.Matrix2d} */ multiply: function(b) { - mat2d.multiply(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].multiply(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -33964,7 +34068,7 @@ Matrix2d.prototype = { * @return {clay.Matrix2d} */ multiplyLeft: function(b) { - mat2d.multiply(this.array, b.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].multiply(this.array, b.array, this.array); this._dirty = true; return this; }, @@ -33975,7 +34079,7 @@ Matrix2d.prototype = { * @return {clay.Matrix2d} */ rotate: function(rad) { - mat2d.rotate(this.array, this.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].rotate(this.array, this.array, rad); this._dirty = true; return this; }, @@ -33986,7 +34090,7 @@ Matrix2d.prototype = { * @return {clay.Matrix2d} */ scale: function(s) { - mat2d.scale(this.array, this.array, s.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].scale(this.array, this.array, s.array); this._dirty = true; return this; }, @@ -33997,7 +34101,7 @@ Matrix2d.prototype = { * @return {clay.Matrix2d} */ translate: function(v) { - mat2d.translate(this.array, this.array, v.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].translate(this.array, this.array, v.array); this._dirty = true; return this; }, @@ -34017,7 +34121,7 @@ Matrix2d.prototype = { * @return {clay.Matrix2d} */ Matrix2d.copy = function(out, a) { - mat2d.copy(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].copy(out.array, a.array); out._dirty = true; return out; }; @@ -34027,7 +34131,7 @@ Matrix2d.copy = function(out, a) { * @return {number} */ Matrix2d.determinant = function(a) { - return mat2d.determinant(a.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].determinant(a.array); }; /** @@ -34035,7 +34139,7 @@ Matrix2d.determinant = function(a) { * @return {clay.Matrix2d} */ Matrix2d.identity = function(out) { - mat2d.identity(out.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].identity(out.array); out._dirty = true; return out; }; @@ -34046,7 +34150,7 @@ Matrix2d.identity = function(out) { * @return {clay.Matrix2d} */ Matrix2d.invert = function(out, a) { - mat2d.invert(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].invert(out.array, a.array); out._dirty = true; return out; }; @@ -34058,7 +34162,7 @@ Matrix2d.invert = function(out, a) { * @return {clay.Matrix2d} */ Matrix2d.mul = function(out, a, b) { - mat2d.mul(out.array, a.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].mul(out.array, a.array, b.array); out._dirty = true; return out; }; @@ -34079,7 +34183,7 @@ Matrix2d.multiply = Matrix2d.mul; * @return {clay.Matrix2d} */ Matrix2d.rotate = function(out, a, rad) { - mat2d.rotate(out.array, a.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].rotate(out.array, a.array, rad); out._dirty = true; return out; }; @@ -34091,7 +34195,7 @@ Matrix2d.rotate = function(out, a, rad) { * @return {clay.Matrix2d} */ Matrix2d.scale = function(out, a, v) { - mat2d.scale(out.array, a.array, v.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].scale(out.array, a.array, v.array); out._dirty = true; return out; }; @@ -34103,7 +34207,7 @@ Matrix2d.scale = function(out, a, v) { * @return {clay.Matrix2d} */ Matrix2d.translate = function(out, a, v) { - mat2d.translate(out.array, a.array, v.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].translate(out.array, a.array, v.array); out._dirty = true; return out; }; @@ -34112,14 +34216,12 @@ Matrix2d.translate = function(out, a, v) { /***/ }), -/* 132 */ +/* 140 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__ = __webpack_require__(34); -var mat3 = __WEBPACK_IMPORTED_MODULE_0__dep_glmatrix___default.a.mat3; /** * @constructor @@ -34133,7 +34235,7 @@ var Matrix3 = function () { * @type {Float32Array} * @memberOf clay.Matrix3# */ - this.array = mat3.create(); + this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].create(); /** * @name _dirty @@ -34163,7 +34265,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ adjoint: function () { - mat3.adjoint(this.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].adjoint(this.array, this.array); this._dirty = true; return this; }, @@ -34182,7 +34284,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ copy: function (b) { - mat3.copy(this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].copy(this.array, b.array); this._dirty = true; return this; }, @@ -34192,7 +34294,7 @@ Matrix3.prototype = { * @return {number} */ determinant: function () { - return mat3.determinant(this.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].determinant(this.array); }, /** @@ -34201,7 +34303,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ fromMat2d: function (a) { - mat3.fromMat2d(this.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].fromMat2d(this.array, a.array); this._dirty = true; return this; }, @@ -34212,7 +34314,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ fromMat4: function (a) { - mat3.fromMat4(this.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].fromMat4(this.array, a.array); this._dirty = true; return this; }, @@ -34223,7 +34325,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ fromQuat: function (q) { - mat3.fromQuat(this.array, q.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].fromQuat(this.array, q.array); this._dirty = true; return this; }, @@ -34233,7 +34335,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ identity: function () { - mat3.identity(this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].identity(this.array); this._dirty = true; return this; }, @@ -34243,7 +34345,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ invert: function () { - mat3.invert(this.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].invert(this.array, this.array); this._dirty = true; return this; }, @@ -34254,7 +34356,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ mul: function (b) { - mat3.mul(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].mul(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -34265,7 +34367,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ mulLeft: function (a) { - mat3.mul(this.array, a.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].mul(this.array, a.array, this.array); this._dirty = true; return this; }, @@ -34276,7 +34378,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ multiply: function (b) { - mat3.multiply(this.array, this.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].multiply(this.array, this.array, b.array); this._dirty = true; return this; }, @@ -34287,7 +34389,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ multiplyLeft: function (a) { - mat3.multiply(this.array, a.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].multiply(this.array, a.array, this.array); this._dirty = true; return this; }, @@ -34298,7 +34400,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ rotate: function (rad) { - mat3.rotate(this.array, this.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].rotate(this.array, this.array, rad); this._dirty = true; return this; }, @@ -34309,7 +34411,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ scale: function (v) { - mat3.scale(this.array, this.array, v.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].scale(this.array, this.array, v.array); this._dirty = true; return this; }, @@ -34320,7 +34422,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ translate: function (v) { - mat3.translate(this.array, this.array, v.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].translate(this.array, this.array, v.array); this._dirty = true; return this; }, @@ -34329,7 +34431,7 @@ Matrix3.prototype = { * @param {clay.Matrix4} a */ normalFromMat4: function (a) { - mat3.normalFromMat4(this.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].normalFromMat4(this.array, a.array); this._dirty = true; return this; }, @@ -34339,7 +34441,7 @@ Matrix3.prototype = { * @return {clay.Matrix2} */ transpose: function () { - mat3.transpose(this.array, this.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].transpose(this.array, this.array); this._dirty = true; return this; }, @@ -34358,7 +34460,7 @@ Matrix3.prototype = { * @return {clay.Matrix3} */ Matrix3.adjoint = function (out, a) { - mat3.adjoint(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].adjoint(out.array, a.array); out._dirty = true; return out; }; @@ -34369,7 +34471,7 @@ Matrix3.adjoint = function (out, a) { * @return {clay.Matrix3} */ Matrix3.copy = function (out, a) { - mat3.copy(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].copy(out.array, a.array); out._dirty = true; return out; }; @@ -34379,7 +34481,7 @@ Matrix3.copy = function (out, a) { * @return {number} */ Matrix3.determinant = function (a) { - return mat3.determinant(a.array); + return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].determinant(a.array); }; /** @@ -34387,7 +34489,7 @@ Matrix3.determinant = function (a) { * @return {clay.Matrix3} */ Matrix3.identity = function (out) { - mat3.identity(out.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].identity(out.array); out._dirty = true; return out; }; @@ -34398,7 +34500,7 @@ Matrix3.identity = function (out) { * @return {clay.Matrix3} */ Matrix3.invert = function (out, a) { - mat3.invert(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].invert(out.array, a.array); return out; }; @@ -34409,7 +34511,7 @@ Matrix3.invert = function (out, a) { * @return {clay.Matrix3} */ Matrix3.mul = function (out, a, b) { - mat3.mul(out.array, a.array, b.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].mul(out.array, a.array, b.array); out._dirty = true; return out; }; @@ -34429,7 +34531,7 @@ Matrix3.multiply = Matrix3.mul; * @return {clay.Matrix3} */ Matrix3.fromMat2d = function (out, a) { - mat3.fromMat2d(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].fromMat2d(out.array, a.array); out._dirty = true; return out; }; @@ -34440,7 +34542,7 @@ Matrix3.fromMat2d = function (out, a) { * @return {clay.Matrix3} */ Matrix3.fromMat4 = function (out, a) { - mat3.fromMat4(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].fromMat4(out.array, a.array); out._dirty = true; return out; }; @@ -34451,7 +34553,7 @@ Matrix3.fromMat4 = function (out, a) { * @return {clay.Matrix3} */ Matrix3.fromQuat = function (out, q) { - mat3.fromQuat(out.array, q.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].fromQuat(out.array, q.array); out._dirty = true; return out; }; @@ -34462,7 +34564,7 @@ Matrix3.fromQuat = function (out, q) { * @return {clay.Matrix3} */ Matrix3.normalFromMat4 = function (out, a) { - mat3.normalFromMat4(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].normalFromMat4(out.array, a.array); out._dirty = true; return out; }; @@ -34474,7 +34576,7 @@ Matrix3.normalFromMat4 = function (out, a) { * @return {clay.Matrix3} */ Matrix3.rotate = function (out, a, rad) { - mat3.rotate(out.array, a.array, rad); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].rotate(out.array, a.array, rad); out._dirty = true; return out; }; @@ -34486,7 +34588,7 @@ Matrix3.rotate = function (out, a, rad) { * @return {clay.Matrix3} */ Matrix3.scale = function (out, a, v) { - mat3.scale(out.array, a.array, v.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].scale(out.array, a.array, v.array); out._dirty = true; return out; }; @@ -34497,7 +34599,7 @@ Matrix3.scale = function (out, a, v) { * @return {clay.Matrix3} */ Matrix3.transpose = function (out, a) { - mat3.transpose(out.array, a.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].transpose(out.array, a.array); out._dirty = true; return out; }; @@ -34509,7 +34611,7 @@ Matrix3.transpose = function (out, a) { * @return {clay.Matrix3} */ Matrix3.translate = function (out, a, v) { - mat3.translate(out.array, a.array, v.array); + __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].translate(out.array, a.array, v.array); out._dirty = true; return out; }; @@ -34518,11 +34620,11 @@ Matrix3.translate = function (out, a, v) { /***/ }), -/* 133 */ +/* 141 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_zrender_lib_animation_Animator__ = __webpack_require__(134); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_zrender_lib_animation_Animator__ = __webpack_require__(142); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_zrender_lib_animation_Animator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_zrender_lib_animation_Animator__); @@ -34619,14 +34721,14 @@ var animatableMixin = { /* harmony default export */ __webpack_exports__["a"] = (animatableMixin); /***/ }), -/* 134 */ +/* 142 */ /***/ (function(module, exports, __webpack_require__) { -var Clip = __webpack_require__(135); +var Clip = __webpack_require__(143); -var color = __webpack_require__(137); +var color = __webpack_require__(145); -var _util = __webpack_require__(12); +var _util = __webpack_require__(13); var isArrayLike = _util.isArrayLike; @@ -35268,10 +35370,10 @@ var _default = Animator; module.exports = _default; /***/ }), -/* 135 */ +/* 143 */ /***/ (function(module, exports, __webpack_require__) { -var easingFuncs = __webpack_require__(136); +var easingFuncs = __webpack_require__(144); /** * 动画主控制器 @@ -35374,7 +35476,7 @@ var _default = Clip; module.exports = _default; /***/ }), -/* 136 */ +/* 144 */ /***/ (function(module, exports) { /** @@ -35757,10 +35859,10 @@ var _default = easing; module.exports = _default; /***/ }), -/* 137 */ +/* 145 */ /***/ (function(module, exports, __webpack_require__) { -var LRU = __webpack_require__(53); +var LRU = __webpack_require__(60); var kCSSColorTable = { 'transparent': [0, 0, 0, 0], @@ -36228,6 +36330,12 @@ function lift(color, level) { } else { colorArr[i] = (255 - colorArr[i]) * level + colorArr[i] | 0; } + + if (colorArr[i] > 255) { + colorArr[i] = 255; + } else if (color[i] < 0) { + colorArr[i] = 0; + } } return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb'); @@ -36383,15 +36491,15 @@ exports.modifyAlpha = modifyAlpha; exports.stringify = stringify; /***/ }), -/* 138 */ +/* 146 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("\n@export clay.util.rand\nhighp float rand(vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\nvec4 sRGBToLinear(in vec4 value) {\n return vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.w);\n}\nvec4 linearTosRGB(in vec4 value) {\n return vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92, vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.w);\n}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end"); +/* harmony default export */ __webpack_exports__["a"] = ("\n@export clay.util.rand\nhighp float rand(vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\n#ifdef SUPPORT_STANDARD_DERIVATIVES\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#else\nfloat edgeFactor(float width)\n{\n return 1.0;\n}\n#endif\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\nvec4 sRGBToLinear(in vec4 value) {\n return vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.w);\n}\nvec4 linearTosRGB(in vec4 value) {\n return vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92, vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.w);\n}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n#ifdef USE_SKIN_MATRICES_TEXTURE\nuniform sampler2D skinMatricesTexture : ignore;\nuniform float skinMatricesTextureSize: ignore;\nmat4 getSkinMatrix(sampler2D tex, float idx) {\n float j = idx * 4.0;\n float x = mod(j, skinMatricesTextureSize);\n float y = floor(j / skinMatricesTextureSize) + 0.5;\n vec2 scale = vec2(skinMatricesTextureSize);\n return mat4(\n texture2D(tex, vec2(x + 0.5, y) / scale),\n texture2D(tex, vec2(x + 1.5, y) / scale),\n texture2D(tex, vec2(x + 2.5, y) / scale),\n texture2D(tex, vec2(x + 3.5, y) / scale)\n );\n}\nmat4 getSkinMatrix(float idx) {\n return getSkinMatrix(skinMatricesTexture, idx);\n}\n#else\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end"); /***/ }), -/* 139 */ +/* 147 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -36399,7 +36507,7 @@ exports.stringify = stringify; /***/ }), -/* 140 */ +/* 148 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -36407,7 +36515,7 @@ exports.stringify = stringify; /***/ }), -/* 141 */ +/* 149 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -36415,7 +36523,7 @@ exports.stringify = stringify; /***/ }), -/* 142 */ +/* 150 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -36423,7 +36531,7 @@ exports.stringify = stringify; /***/ }), -/* 143 */ +/* 151 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -36431,15 +36539,15 @@ exports.stringify = stringify; /***/ }), -/* 144 */ +/* 152 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end"); +/* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n v_Texcoord = texcoord;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end"); /***/ }), -/* 145 */ +/* 153 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -36509,14 +36617,14 @@ function removeTextStyleInAxis(axesOpt) { });; /***/ }), -/* 146 */ +/* 154 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__grid3D_Axis3DModel__ = __webpack_require__(147); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__grid3D_Grid3DModel__ = __webpack_require__(151); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__grid3D_Grid3DView__ = __webpack_require__(152); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__coord_grid3DCreator__ = __webpack_require__(158); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__grid3D_Axis3DModel__ = __webpack_require__(155); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__grid3D_Grid3DModel__ = __webpack_require__(159); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__grid3D_Grid3DView__ = __webpack_require__(160); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__coord_grid3DCreator__ = __webpack_require__(167); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_echarts_lib_echarts__); @@ -36553,13 +36661,13 @@ __WEBPACK_IMPORTED_MODULE_4_echarts_lib_echarts___default.a.registerAction({ }); /***/ }), -/* 147 */ +/* 155 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__createAxis3DModel__ = __webpack_require__(148); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__createAxis3DModel__ = __webpack_require__(156); @@ -36599,14 +36707,14 @@ Object(__WEBPACK_IMPORTED_MODULE_1__createAxis3DModel__["a" /* default */])('z', }); /***/ }), -/* 148 */ +/* 156 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__axis3DDefault__ = __webpack_require__(149); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_OrdinalMeta__ = __webpack_require__(150); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__axis3DDefault__ = __webpack_require__(157); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_OrdinalMeta__ = __webpack_require__(158); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_OrdinalMeta___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_OrdinalMeta__); @@ -36680,7 +36788,7 @@ var AXIS_TYPES = ['value', 'category', 'time', 'log']; });; /***/ }), -/* 149 */ +/* 157 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -36779,15 +36887,34 @@ logAxis.scale = true; }); /***/ }), -/* 150 */ +/* 158 */ /***/ (function(module, exports, __webpack_require__) { -var _util = __webpack_require__(12); +var _util = __webpack_require__(13); var createHashMap = _util.createHashMap; var isObject = _util.isObject; var map = _util.map; +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + /** * @constructor * @param {Object} [opt] @@ -36912,15 +37039,15 @@ var _default = OrdinalMeta; module.exports = _default; /***/ }), -/* 151 */ +/* 159 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentViewControlMixin__ = __webpack_require__(38); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentPostEffectMixin__ = __webpack_require__(25); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_componentLightMixin__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentViewControlMixin__ = __webpack_require__(44); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentPostEffectMixin__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_componentLightMixin__ = __webpack_require__(29); @@ -37069,22 +37196,22 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Grid3DMod /***/ }), -/* 152 */ +/* 160 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_OrbitControl__ = __webpack_require__(39); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(22); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_retrieve__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_ZRTextureAtlasSurface__ = __webpack_require__(73); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__common_SceneHelper__ = __webpack_require__(27); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Grid3DFace__ = __webpack_require__(153); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Grid3DAxis__ = __webpack_require__(155); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__util_mesh_LabelsMesh__ = __webpack_require__(58); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__util_shader_lines3D_glsl_js__ = __webpack_require__(40); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_OrbitControl__ = __webpack_require__(45); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(25); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_retrieve__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_ZRTextureAtlasSurface__ = __webpack_require__(81); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__common_SceneHelper__ = __webpack_require__(30); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Grid3DFace__ = __webpack_require__(162); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Grid3DAxis__ = __webpack_require__(164); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__util_mesh_LabelsMesh__ = __webpack_require__(63); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__util_shader_lines3D_glsl_js__ = __webpack_require__(46); // TODO orthographic camera @@ -37236,29 +37363,13 @@ var dimIndicesMap = { this._axisLabelSurface.clear(); - var labelIntervalFuncs = ['x', 'y', 'z'].reduce(function (obj, axisDim) { - var axis = cartesian.getAxis(axisDim); - var axisModel = axis.model; - obj[axisDim] = firstNotNull( - axisModel.get('axisLabel.interval'), - grid3DModel.get('axisLabel.interval') - ); - if (axis.scale.type === 'ordinal') { - // TODO consider label length - if (obj[axisDim] == null || obj[axisDim] == 'auto') { - obj[axisDim] = Math.floor(axis.scale.getTicks().length / 8); - } - } - return obj; - }, {}); - control.off('update'); if (grid3DModel.get('show')) { this._faces.forEach(function (face) { - face.update(labelIntervalFuncs, grid3DModel, ecModel, api); + face.update(grid3DModel, ecModel, api); }, this); this._axes.forEach(function (axis) { - axis.update(grid3DModel, labelIntervalFuncs, this._axisLabelSurface, api); + axis.update(grid3DModel, this._axisLabelSurface, api); }, this); } @@ -37692,17 +37803,79 @@ var dimIndicesMap = { })); /***/ }), -/* 153 */ +/* 161 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__vec2__ = __webpack_require__(70); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__vec3__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__vec4__ = __webpack_require__(33); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__mat2__ = __webpack_require__(78); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__mat2d__ = __webpack_require__(79); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__mat3__ = __webpack_require__(34); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__mat4__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__quat__ = __webpack_require__(55); +/** + * @fileoverview gl-matrix - High performance matrix and vector operations + * @author Brandon Jones + * @author Colin MacKenzie IV + * @version 2.2.2 + */ + +/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. 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 HOLDER 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 USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + + + + + + + + + + +/* harmony default export */ __webpack_exports__["a"] = ({ + vec2: __WEBPACK_IMPORTED_MODULE_0__vec2__["a" /* default */], + vec3: __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */], + vec4: __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */], + mat2: __WEBPACK_IMPORTED_MODULE_3__mat2__["a" /* default */], + mat2d: __WEBPACK_IMPORTED_MODULE_4__mat2d__["a" /* default */], + mat3: __WEBPACK_IMPORTED_MODULE_5__mat3__["a" /* default */], + mat4: __WEBPACK_IMPORTED_MODULE_6__mat4__["a" /* default */], + quat: __WEBPACK_IMPORTED_MODULE_7__quat__["a" /* default */] +}); + + +/***/ }), +/* 162 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(22); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_geometry_Quads__ = __webpack_require__(154); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__ifIgnoreOnTick__ = __webpack_require__(74); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(25); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_geometry_Quads__ = __webpack_require__(163); @@ -37710,7 +37883,6 @@ var dimIndicesMap = { var firstNotNull = __WEBPACK_IMPORTED_MODULE_2__util_retrieve__["a" /* default */].firstNotNull; - var dimIndicesMap = { // Left to right x: 0, @@ -37777,7 +37949,7 @@ function Grid3DFace(faceInfo, linesMaterial, quadsMaterial) { this.quadsMesh =quadsMesh; } -Grid3DFace.prototype.update = function (labelIntervalFuncs, grid3DModel, ecModel, api) { +Grid3DFace.prototype.update = function (grid3DModel, ecModel, api) { var cartesian = grid3DModel.coordinateSystem; var axes = [ cartesian.getAxis(this.faceInfo[0]), @@ -37788,8 +37960,8 @@ Grid3DFace.prototype.update = function (labelIntervalFuncs, grid3DModel, ecModel lineGeometry.convertToDynamicArray(true); quadsGeometry.convertToDynamicArray(true); - this._updateSplitLines(lineGeometry, axes, grid3DModel, labelIntervalFuncs, api); - this._udpateSplitAreas(quadsGeometry, axes, grid3DModel, labelIntervalFuncs, api); + this._updateSplitLines(lineGeometry, axes, grid3DModel, api); + this._udpateSplitAreas(quadsGeometry, axes, grid3DModel, api); lineGeometry.convertToTypedArray(); quadsGeometry.convertToTypedArray(); @@ -37798,7 +37970,7 @@ Grid3DFace.prototype.update = function (labelIntervalFuncs, grid3DModel, ecModel updateFacePlane(this.rootNode, this.plane, otherAxis, this.faceInfo[3]); }; -Grid3DFace.prototype._updateSplitLines = function (geometry, axes, grid3DModel, labelIntervalFuncs, api) { +Grid3DFace.prototype._updateSplitLines = function (geometry, axes, grid3DModel, api) { var dpr = api.getDevicePixelRatio(); axes.forEach(function (axis, idx) { var axisModel = axis.model; @@ -37815,21 +37987,16 @@ Grid3DFace.prototype._updateSplitLines = function (geometry, axes, grid3DModel, var lineColors = lineStyleModel.get('color'); var opacity = firstNotNull(lineStyleModel.get('opacity'), 1.0); var lineWidth = firstNotNull(lineStyleModel.get('width'), 1.0); - // TODO Automatic interval - var intervalFunc = splitLineModel.get('interval'); - if (intervalFunc == null || intervalFunc === 'auto') { - intervalFunc = labelIntervalFuncs[axis.dim]; - } + lineColors = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(lineColors) ? lineColors : [lineColors]; - var ticksCoords = axis.getTicksCoords(); + var ticksCoords = axis.getTicksCoords({ + tickModel: splitLineModel + }); var count = 0; for (var i = 0; i < ticksCoords.length; i++) { - if (Object(__WEBPACK_IMPORTED_MODULE_5__ifIgnoreOnTick__["a" /* default */])(axis, i, intervalFunc)) { - continue; - } - var tickCoord = ticksCoords[i]; + var tickCoord = ticksCoords[i].coord; var lineColor = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(lineColors[count % lineColors.length]); lineColor[3] *= opacity; @@ -37847,7 +38014,7 @@ Grid3DFace.prototype._updateSplitLines = function (geometry, axes, grid3DModel, }); }; -Grid3DFace.prototype._udpateSplitAreas = function (geometry, axes, grid3DModel, labelIntervalFuncs, api) { +Grid3DFace.prototype._udpateSplitAreas = function (geometry, axes, grid3DModel, api) { axes.forEach(function (axis, idx) { var axisModel = axis.model; var otherExtent = axes[1 - idx].getExtent(); @@ -37862,22 +38029,20 @@ Grid3DFace.prototype._udpateSplitAreas = function (geometry, axes, grid3DModel, var areaStyleModel = splitAreaModel.getModel('areaStyle'); var colors = areaStyleModel.get('color'); var opacity = firstNotNull(areaStyleModel.get('opacity'), 1.0); - // TODO Automatic interval - var intervalFunc = splitAreaModel.get('interval'); - if (intervalFunc == null || intervalFunc === 'auto') { - intervalFunc = labelIntervalFuncs[axis.dim]; - } colors = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(colors) ? colors : [colors]; - var ticksCoords = axis.getTicksCoords(); + var ticksCoords = axis.getTicksCoords({ + tickModel: splitAreaModel, + clamp: true + }); var count = 0; var prevP0 = [0, 0, 0]; var prevP1 = [0, 0, 0]; // 0 - x, 1 - y for (var i = 0; i < ticksCoords.length; i++) { - var tickCoord = ticksCoords[i]; + var tickCoord = ticksCoords[i].coord; var p0 = [0, 0, 0]; var p1 = [0, 0, 0]; // 0 - x, 1 - y @@ -37891,10 +38056,6 @@ Grid3DFace.prototype._udpateSplitAreas = function (geometry, axes, grid3DModel, continue; } - if (Object(__WEBPACK_IMPORTED_MODULE_5__ifIgnoreOnTick__["a" /* default */])(axis, i, intervalFunc)) { - continue; - } - var color = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(colors[count % colors.length]); color[3] *= opacity; geometry.addQuad([prevP0, p0, p1, prevP1], color); @@ -37911,16 +38072,15 @@ Grid3DFace.prototype._udpateSplitAreas = function (geometry, axes, grid3DModel, /* harmony default export */ __webpack_exports__["a"] = (Grid3DFace); /***/ }), -/* 154 */ +/* 163 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__ = __webpack_require__(15); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__ = __webpack_require__(34); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__ = __webpack_require__(38); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(6); /** * @module echarts-gl/util/geometry/QuadsGeometry * @author Yi Shen(http://github.com/pissang) @@ -37930,7 +38090,7 @@ Grid3DFace.prototype._udpateSplitAreas = function (geometry, axes, grid3DModel, -var vec3 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix___default.a.vec3; +var vec3 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__["a" /* default */].vec3; /** * @constructor @@ -38031,17 +38191,16 @@ __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.util.defaults(QuadsG /* harmony default export */ __webpack_exports__["a"] = (QuadsGeometry); /***/ }), -/* 155 */ +/* 164 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_geometry_Lines3D__ = __webpack_require__(22); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_retrieve__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_mesh_LabelsMesh__ = __webpack_require__(58); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__ifIgnoreOnTick__ = __webpack_require__(74); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_geometry_Lines3D__ = __webpack_require__(25); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_retrieve__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_mesh_LabelsMesh__ = __webpack_require__(63); @@ -38049,7 +38208,6 @@ __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.util.defaults(QuadsG var firstNotNull = __WEBPACK_IMPORTED_MODULE_3__util_retrieve__["a" /* default */].firstNotNull; - var dimIndicesMap = { // Left to right x: 0, @@ -38086,11 +38244,10 @@ var otherDim = { x: 'y', y: 'x', z: 'y' }; Grid3DAxis.prototype.update = function ( - grid3DModel, labelIntervalFuncs, axisLabelSurface, api + grid3DModel, axisLabelSurface, api ) { var cartesian = grid3DModel.coordinateSystem; var axis = cartesian.getAxis(this.dim); - var labelIntervalFunc = labelIntervalFuncs[this.dim]; var linesGeo = this.linesMesh.geometry; var labelsGeo = this.labelsMesh.geometry; @@ -38130,18 +38287,10 @@ Grid3DAxis.prototype.update = function ( var lineWidth = firstNotNull(lineStyleModel.get('width'), 1.0); lineColor[3] *= firstNotNull(lineStyleModel.get('opacity'), 1.0); var ticksCoords = axis.getTicksCoords(); - // TODO Automatic interval - var intervalFunc = axisTickModel.get('interval'); - if (intervalFunc == null || intervalFunc === 'auto') { - intervalFunc = labelIntervalFunc; - } var tickLength = axisTickModel.get('length'); for (var i = 0; i < ticksCoords.length; i++) { - if (Object(__WEBPACK_IMPORTED_MODULE_5__ifIgnoreOnTick__["a" /* default */])(axis, i, intervalFunc)) { - continue; - } - var tickCoord = ticksCoords[i]; + var tickCoord = ticksCoords[i].coord; var p0 = [0, 0, 0]; var p1 = [0, 0, 0]; var idx = dimIndicesMap[axis.dim]; @@ -38157,20 +38306,18 @@ Grid3DAxis.prototype.update = function ( this.labelElements = []; var dpr = api.getDevicePixelRatio(); if (axisLabelModel.get('show')) { - var labelsCoords = axis.getLabelsCoords(); + var ticksCoords = axis.getTicksCoords(); var categoryData = axisModel.get('data'); - // TODO Automatic interval - var intervalFunc = labelIntervalFunc; var labelMargin = axisLabelModel.get('margin'); + var labels = axis.getViewLabels(); - var labels = axisModel.getFormattedLabels(); - var ticks = axis.scale.getTicks(); - for (var i = 0; i < labelsCoords.length; i++) { - if (Object(__WEBPACK_IMPORTED_MODULE_5__ifIgnoreOnTick__["a" /* default */])(axis, i, intervalFunc)) { - continue; - } - var tickCoord = labelsCoords[i]; + for (var i = 0; i < labels.length; i++) { + var tickValue = labels[i].tickValue; + var formattedLabel = labels[i].formattedLabel; + var rawLabel = labels[i].rawLabel; + + var tickCoord = axis.dataToCoord(tickValue); var p = [0, 0, 0]; var idx = dimIndicesMap[axis.dim]; @@ -38180,16 +38327,16 @@ Grid3DAxis.prototype.update = function ( p[otherIdx] = labelMargin; var itemTextStyleModel = axisLabelModel; - if (categoryData && categoryData[ticks[i]] && categoryData[ticks[i]].textStyle) { + if (categoryData && categoryData[tickValue] && categoryData[tickValue].textStyle) { itemTextStyleModel = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.Model( - categoryData[ticks[i]].textStyle, axisLabelModel, axisModel.ecModel + categoryData[tickValue].textStyle, axisLabelModel, axisModel.ecModel ); } var textColor = firstNotNull(itemTextStyleModel.get('color'), axisLineColor); var textEl = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.Text(); __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.setTextStyle(textEl.style, itemTextStyleModel, { - text: labels[i], + text: formattedLabel, textFill: typeof textColor === 'function' ? textColor( // (1) In category axis with data zoom, tick is not the original @@ -38199,7 +38346,7 @@ Grid3DAxis.prototype.update = function ( // But in interval scale labelStr is like '223,445', which maked // user repalce ','. So we modify it to return original val but remain // it as 'string' to avoid error in replacing. - axis.type === 'category' ? labels[i] : axis.type === 'value' ? ticks[i] + '' : ticks[i], + axis.type === 'category' ? rawLabel : axis.type === 'value' ? tickValue + '' : tickValue, i ) : textColor, @@ -38272,14 +38419,14 @@ Grid3DAxis.prototype.setSpriteAlign = function (textAlign, textVerticalAlign, ap /* harmony default export */ __webpack_exports__["a"] = (Grid3DAxis); /***/ }), -/* 156 */ +/* 165 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Geometry__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__ = __webpack_require__(34); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Geometry__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__ = __webpack_require__(38); /** * Geometry collecting sprites * @@ -38420,7 +38567,7 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.defaults(Sprite /* harmony default export */ __webpack_exports__["a"] = (SpritesGeometry); /***/ }), -/* 157 */ +/* 166 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -38428,18 +38575,18 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.defaults(Sprite /***/ }), -/* 158 */ +/* 167 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__grid3D_Cartesian3D__ = __webpack_require__(159); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__grid3D_Axis3D__ = __webpack_require__(161); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__grid3D_Cartesian3D__ = __webpack_require__(168); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__grid3D_Axis3D__ = __webpack_require__(170); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_util_layout__ = __webpack_require__(41); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_util_layout__ = __webpack_require__(47); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_util_layout___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_util_layout__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_ViewGL__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_ViewGL__ = __webpack_require__(22); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(2); @@ -38531,6 +38678,15 @@ function updateCartesian3D(ecModel, api) { axisModel.axis = axis; axis.model = axisModel; + // override `echarts/coord/Axis#getLabelModel` + axis.getLabelModel = function () { + return axisModel.getModel('axisLabel', grid3DModel.getModel('axisLabel')); + }; + // override `echarts/coord/Axis#getTickModel` + axis.getTickModel = function () { + return axisModel.getModel('axisTick', grid3DModel.getModel('axisTick')); + }; + cartesian3D.addAxis(axis); }, this); }, this); @@ -38624,13 +38780,13 @@ __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default.a.registerCoordinateSy /* unused harmony default export */ var _unused_webpack_default_export = (grid3DCreator); /***/ }), -/* 159 */ +/* 168 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_coord_cartesian_Cartesian__ = __webpack_require__(160); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_coord_cartesian_Cartesian__ = __webpack_require__(169); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_coord_cartesian_Cartesian___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_coord_cartesian_Cartesian__); @@ -38686,10 +38842,29 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.inherits(Cartes /* harmony default export */ __webpack_exports__["a"] = (Cartesian3D); /***/ }), -/* 160 */ +/* 169 */ /***/ (function(module, exports, __webpack_require__) { -var zrUtil = __webpack_require__(12); +var zrUtil = __webpack_require__(13); + +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ /** * Cartesian coordinate system @@ -38791,7 +38966,7 @@ var _default = Cartesian; module.exports = _default; /***/ }), -/* 161 */ +/* 170 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -38815,6 +38990,11 @@ Axis3D.prototype = { getExtentMax: function () { var extent = this._extent; return Math.max(extent[0], extent[1]); + }, + + calculateCategoryInterval: function () { + // TODO consider label length + return Math.floor(this.scale.count() / 8); } }; @@ -38823,14 +39003,33 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.inherits(Axis3D /* harmony default export */ __webpack_exports__["a"] = (Axis3D); /***/ }), -/* 162 */ +/* 171 */ /***/ (function(module, exports, __webpack_require__) { -var zrUtil = __webpack_require__(12); +var zrUtil = __webpack_require__(13); + +var textContain = __webpack_require__(172); -var textContain = __webpack_require__(163); +var numberUtil = __webpack_require__(85); -var numberUtil = __webpack_require__(78); +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ /** * 每三位默认加,格式化 @@ -38865,9 +39064,19 @@ function toCamelCase(str, upperCaseFirst) { } var normalizeCssArray = zrUtil.normalizeCssArray; +var replaceReg = /([&<>"'])/g; +var replaceMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + '\'': ''' +}; function encodeHTML(source) { - return String(source).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); + return source == null ? '' : (source + '').replace(replaceReg, function (str, c) { + return replaceMap[c]; + }); } var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g']; @@ -39010,14 +39219,14 @@ exports.truncateText = truncateText; exports.getTextRect = getTextRect; /***/ }), -/* 163 */ +/* 172 */ /***/ (function(module, exports, __webpack_require__) { -var BoundingRect = __webpack_require__(75); +var BoundingRect = __webpack_require__(82); -var imageHelper = __webpack_require__(164); +var imageHelper = __webpack_require__(173); -var _util = __webpack_require__(12); +var _util = __webpack_require__(13); var getContext = _util.getContext; var extend = _util.extend; @@ -39704,10 +39913,10 @@ exports.parseRichText = parseRichText; exports.makeFont = makeFont; /***/ }), -/* 164 */ +/* 173 */ /***/ (function(module, exports, __webpack_require__) { -var LRU = __webpack_require__(53); +var LRU = __webpack_require__(60); var globalImageCache = new LRU(50); /** @@ -39797,30 +40006,29 @@ exports.createOrUpdateImage = createOrUpdateImage; exports.isImageReady = isImageReady; /***/ }), -/* 165 */ +/* 174 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__math_Frustum__ = __webpack_require__(52); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Renderer__ = __webpack_require__(46); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__math_Frustum__ = __webpack_require__(59); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Renderer__ = __webpack_require__(52); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Shader__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Material__ = __webpack_require__(17); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Material__ = __webpack_require__(19); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__FrameBuffer__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Texture__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Texture__ = __webpack_require__(4); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__TextureCube__ = __webpack_require__(24); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__camera_Perspective__ = __webpack_require__(36); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__camera_Orthographic__ = __webpack_require__(33); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__compositor_Pass__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__compositor_TexturePool__ = __webpack_require__(79); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_17__dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__shader_source_shadowmap_glsl_js__ = __webpack_require__(166); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__TextureCube__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__camera_Perspective__ = __webpack_require__(41); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__camera_Orthographic__ = __webpack_require__(37); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__compositor_Pass__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__compositor_TexturePool__ = __webpack_require__(86); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__shader_source_shadowmap_glsl_js__ = __webpack_require__(175); @@ -39841,13 +40049,37 @@ exports.isImageReady = isImageReady; -var mat4 = __WEBPACK_IMPORTED_MODULE_17__dep_glmatrix___default.a.mat4; var targets = ['px', 'nx', 'py', 'ny', 'pz', 'nz']; __WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_18__shader_source_shadowmap_glsl_js__["a" /* default */]); +function getDepthMaterialUniform(renderable, depthMaterial, symbol) { + if (symbol === 'alphaMap') { + return renderable.material.get('diffuseMap'); + } + else if (symbol === 'alphaCutoff') { + if (renderable.material.isDefined('fragment', 'ALPHA_TEST') + && renderable.material.get('diffuseMap') + ) { + var alphaCutoff = renderable.material.get('alphaCutoff'); + return alphaCutoff || 0; + } + return 0; + } + else { + return depthMaterial.get(symbol); + } +} + +function isDepthMaterialChanged(renderable, prevRenderable) { + var matA = renderable.material; + var matB = prevRenderable.material; + return matA.get('diffuseMap') !== matB.get('diffuseMap') + || (matA.get('alphaCutoff') || 0) !== (matB.get('alphaCutoff') || 0); +} + /** * Pass rendering shadow map. * @@ -40197,6 +40429,8 @@ var ShadowMapPass = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */]. getMaterial: function (renderable) { return renderable.shadowDepthMaterial || defaultShadowMaterial; }, + isMaterialChanged: isDepthMaterialChanged, + getUniform: getDepthMaterialUniform, ifRender: function (renderable) { return renderable.castShadow; }, @@ -40218,9 +40452,9 @@ var ShadowMapPass = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */]. var lvpMat4Arr = lightViewProjMatrix.array; lightProjMatrix.copy(lightCamera.projectionMatrix); - mat4.invert(lightViewMatrix.array, lightCamera.worldTransform.array); - mat4.multiply(lightViewMatrix.array, lightViewMatrix.array, sceneCamera.worldTransform.array); - mat4.multiply(lvpMat4Arr, lightProjMatrix.array, lightViewMatrix.array); + __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__["a" /* default */].invert(lightViewMatrix.array, lightCamera.worldTransform.array); + __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__["a" /* default */].multiply(lightViewMatrix.array, lightViewMatrix.array, sceneCamera.worldTransform.array); + __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__["a" /* default */].multiply(lvpMat4Arr, lightProjMatrix.array, lightViewMatrix.array); var clipPlanes = []; var isPerspective = sceneCamera instanceof __WEBPACK_IMPORTED_MODULE_13__camera_Perspective__["a" /* default */]; @@ -40249,10 +40483,10 @@ var ShadowMapPass = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */]. var nearPlane = clipPlanes[i]; var farPlane = clipPlanes[i + 1]; if (isPerspective) { - mat4.perspective(splitProjMatrix.array, sceneCamera.fov / 180 * Math.PI, sceneCamera.aspect, nearPlane, farPlane); + __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__["a" /* default */].perspective(splitProjMatrix.array, sceneCamera.fov / 180 * Math.PI, sceneCamera.aspect, nearPlane, farPlane); } else { - mat4.ortho( + __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__["a" /* default */].ortho( splitProjMatrix.array, sceneCamera.left, sceneCamera.right, sceneCamera.bottom, sceneCamera.top, nearPlane, farPlane @@ -40314,6 +40548,8 @@ var ShadowMapPass = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */]. getMaterial: function (renderable) { return renderable.shadowDepthMaterial || defaultShadowMaterial; }, + isMaterialChanged: isDepthMaterialChanged, + getUniform: getDepthMaterialUniform, ifRender: function (renderable) { return renderable.castShadow; }, @@ -40349,6 +40585,7 @@ var ShadowMapPass = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */]. getMaterial: function (renderable) { return renderable.shadowDepthMaterial || defaultShadowMaterial; }, + getUniform: getDepthMaterialUniform, sortCompare: __WEBPACK_IMPORTED_MODULE_6__Renderer__["a" /* default */].opaqueSortCompare }; @@ -40625,7 +40862,7 @@ var ShadowMapPass = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */]. camera.far = light.range; camera.worldTransform.copy(light.worldTransform); camera.updateProjectionMatrix(); - mat4.invert(camera.viewMatrix.array, camera.worldTransform.array); + __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__["a" /* default */].invert(camera.viewMatrix.array, camera.worldTransform.array); return camera; }, @@ -40692,42 +40929,42 @@ ShadowMapPass.PCF = 2; /***/ }), -/* 166 */ +/* 175 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("@export clay.sm.depth.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\n#ifdef SHADOW_TRANSPARENT\nattribute vec2 texcoord : TEXCOORD_0;\n#endif\n@import clay.chunk.skinning_header\nvarying vec4 v_ViewPosition;\n#ifdef SHADOW_TRANSPARENT\nvarying vec2 v_Texcoord;\n#endif\nvoid main(){\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n v_ViewPosition = worldViewProjection * vec4(skinnedPosition, 1.0);\n gl_Position = v_ViewPosition;\n#ifdef SHADOW_TRANSPARENT\n v_Texcoord = texcoord;\n#endif\n}\n@end\n@export clay.sm.depth.fragment\nvarying vec4 v_ViewPosition;\n#ifdef SHADOW_TRANSPARENT\nvarying vec2 v_Texcoord;\n#endif\nuniform float bias : 0.001;\nuniform float slopeScale : 1.0;\n#ifdef SHADOW_TRANSPARENT\nuniform sampler2D transparentMap;\n#endif\n@import clay.util.encode_float\nvoid main(){\n float depth = v_ViewPosition.z / v_ViewPosition.w;\n#ifdef USE_VSM\n depth = depth * 0.5 + 0.5;\n float moment1 = depth;\n float moment2 = depth * depth;\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n moment2 += 0.25*(dx*dx+dy*dy);\n gl_FragColor = vec4(moment1, moment2, 0.0, 1.0);\n#else\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n depth += sqrt(dx*dx + dy*dy) * slopeScale + bias;\n#ifdef SHADOW_TRANSPARENT\n if (texture2D(transparentMap, v_Texcoord).a <= 0.1) {\n gl_FragColor = encodeFloat(0.9999);\n return;\n }\n#endif\n gl_FragColor = encodeFloat(depth * 0.5 + 0.5);\n#endif\n}\n@end\n@export clay.sm.debug_depth\nuniform sampler2D depthMap;\nvarying vec2 v_Texcoord;\n@import clay.util.decode_float\nvoid main() {\n vec4 tex = texture2D(depthMap, v_Texcoord);\n#ifdef USE_VSM\n gl_FragColor = vec4(tex.rgb, 1.0);\n#else\n float depth = decodeFloat(tex);\n gl_FragColor = vec4(depth, depth, depth, 1.0);\n#endif\n}\n@end\n@export clay.sm.distance.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\n@import clay.chunk.skinning_header\nvarying vec3 v_WorldPosition;\nvoid main (){\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n gl_Position = worldViewProjection * vec4(skinnedPosition , 1.0);\n v_WorldPosition = (world * vec4(skinnedPosition, 1.0)).xyz;\n}\n@end\n@export clay.sm.distance.fragment\nuniform vec3 lightPosition;\nuniform float range : 100;\nvarying vec3 v_WorldPosition;\n@import clay.util.encode_float\nvoid main(){\n float dist = distance(lightPosition, v_WorldPosition);\n#ifdef USE_VSM\n gl_FragColor = vec4(dist, dist * dist, 0.0, 0.0);\n#else\n dist = dist / range;\n gl_FragColor = encodeFloat(dist);\n#endif\n}\n@end\n@export clay.plugin.shadow_map_common\n@import clay.util.decode_float\nfloat tapShadowMap(sampler2D map, vec2 uv, float z){\n vec4 tex = texture2D(map, uv);\n return step(z, decodeFloat(tex) * 2.0 - 1.0);\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize, vec2 scale) {\n float shadowContrib = tapShadowMap(map, uv, z);\n vec2 offset = vec2(1.0 / textureSize) * scale;\n#ifdef PCF_KERNEL_SIZE\n for (int _idx_ = 0; _idx_ < PCF_KERNEL_SIZE; _idx_++) {{\n shadowContrib += tapShadowMap(map, uv + offset * pcfKernel[_idx_], z);\n }}\n return shadowContrib / float(PCF_KERNEL_SIZE + 1);\n#else\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, -offset.y), z);\n return shadowContrib / 9.0;\n#endif\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize) {\n return pcf(map, uv, z, textureSize, vec2(1.0));\n}\nfloat chebyshevUpperBound(vec2 moments, float z){\n float p = 0.0;\n z = z * 0.5 + 0.5;\n if (z <= moments.x) {\n p = 1.0;\n }\n float variance = moments.y - moments.x * moments.x;\n variance = max(variance, 0.0000001);\n float mD = moments.x - z;\n float pMax = variance / (variance + mD * mD);\n pMax = clamp((pMax-0.4)/(1.0-0.4), 0.0, 1.0);\n return max(p, pMax);\n}\nfloat computeShadowContrib(\n sampler2D map, mat4 lightVPM, vec3 position, float textureSize, vec2 scale, vec2 offset\n) {\n vec4 posInLightSpace = lightVPM * vec4(position, 1.0);\n posInLightSpace.xyz /= posInLightSpace.w;\n float z = posInLightSpace.z;\n if(all(greaterThan(posInLightSpace.xyz, vec3(-0.99, -0.99, -1.0))) &&\n all(lessThan(posInLightSpace.xyz, vec3(0.99, 0.99, 1.0)))){\n vec2 uv = (posInLightSpace.xy+1.0) / 2.0;\n #ifdef USE_VSM\n vec2 moments = texture2D(map, uv * scale + offset).xy;\n return chebyshevUpperBound(moments, z);\n #else\n return pcf(map, uv * scale + offset, z, textureSize, scale);\n #endif\n }\n return 1.0;\n}\nfloat computeShadowContrib(sampler2D map, mat4 lightVPM, vec3 position, float textureSize) {\n return computeShadowContrib(map, lightVPM, position, textureSize, vec2(1.0), vec2(0.0));\n}\nfloat computeShadowContribOmni(samplerCube map, vec3 direction, float range)\n{\n float dist = length(direction);\n vec4 shadowTex = textureCube(map, direction);\n#ifdef USE_VSM\n vec2 moments = shadowTex.xy;\n float variance = moments.y - moments.x * moments.x;\n float mD = moments.x - dist;\n float p = variance / (variance + mD * mD);\n if(moments.x + 0.001 < dist){\n return clamp(p, 0.0, 1.0);\n }else{\n return 1.0;\n }\n#else\n return step(dist, (decodeFloat(shadowTex) + 0.0002) * range);\n#endif\n}\n@end\n@export clay.plugin.compute_shadow_map\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT) || defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT) || defined(POINT_LIGHT_SHADOWMAP_COUNT)\n#ifdef SPOT_LIGHT_SHADOWMAP_COUNT\nuniform sampler2D spotLightShadowMaps[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 spotLightMatrices[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float spotLightShadowMapSizes[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#ifdef DIRECTIONAL_LIGHT_SHADOWMAP_COUNT\n#if defined(SHADOW_CASCADE)\nuniform sampler2D directionalLightShadowMaps[1]:unconfigurable;\nuniform mat4 directionalLightMatrices[SHADOW_CASCADE]:unconfigurable;\nuniform float directionalLightShadowMapSizes[1]:unconfigurable;\nuniform float shadowCascadeClipsNear[SHADOW_CASCADE]:unconfigurable;\nuniform float shadowCascadeClipsFar[SHADOW_CASCADE]:unconfigurable;\n#else\nuniform sampler2D directionalLightShadowMaps[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 directionalLightMatrices[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float directionalLightShadowMapSizes[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#endif\n#ifdef POINT_LIGHT_SHADOWMAP_COUNT\nuniform samplerCube pointLightShadowMaps[POINT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\nuniform bool shadowEnabled : true;\n#ifdef PCF_KERNEL_SIZE\nuniform vec2 pcfKernel[PCF_KERNEL_SIZE];\n#endif\n@import clay.plugin.shadow_map_common\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfSpotLights(vec3 position, inout float shadowContribs[SPOT_LIGHT_COUNT] ) {\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < SPOT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n spotLightShadowMaps[_idx_], spotLightMatrices[_idx_], position,\n spotLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = SPOT_LIGHT_SHADOWMAP_COUNT; _idx_ < SPOT_LIGHT_COUNT; _idx_++){{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n#ifdef SHADOW_CASCADE\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float depth = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far)\n / (gl_DepthRange.far - gl_DepthRange.near);\n float shadowContrib;\n shadowContribs[0] = 1.0;\n for (int _idx_ = 0; _idx_ < SHADOW_CASCADE; _idx_++) {{\n if (\n depth >= shadowCascadeClipsNear[_idx_] &&\n depth <= shadowCascadeClipsFar[_idx_]\n ) {\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[0], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[0],\n vec2(1.0 / float(SHADOW_CASCADE), 1.0),\n vec2(float(_idx_) / float(SHADOW_CASCADE), 0.0)\n );\n shadowContribs[0] = shadowContrib;\n }\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#else\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[_idx_], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfPointLights(vec3 position, inout float shadowContribs[POINT_LIGHT_COUNT] ){\n vec3 lightPosition;\n vec3 direction;\n for(int _idx_ = 0; _idx_ < POINT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n lightPosition = pointLightPosition[_idx_];\n direction = position - lightPosition;\n shadowContribs[_idx_] = computeShadowContribOmni(pointLightShadowMaps[_idx_], direction, pointLightRange[_idx_]);\n }}\n for(int _idx_ = POINT_LIGHT_SHADOWMAP_COUNT; _idx_ < POINT_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n@end"); +/* harmony default export */ __webpack_exports__["a"] = ("@export clay.sm.depth.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n@import clay.chunk.skinning_header\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nvoid main(){\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n v_ViewPosition = worldViewProjection * vec4(skinnedPosition, 1.0);\n gl_Position = v_ViewPosition;\n v_Texcoord = texcoord;\n}\n@end\n@export clay.sm.depth.fragment\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nuniform float bias : 0.001;\nuniform float slopeScale : 1.0;\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\n@import clay.util.encode_float\nvoid main(){\n float depth = v_ViewPosition.z / v_ViewPosition.w;\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n#ifdef USE_VSM\n depth = depth * 0.5 + 0.5;\n float moment1 = depth;\n float moment2 = depth * depth;\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n moment2 += 0.25*(dx*dx+dy*dy);\n gl_FragColor = vec4(moment1, moment2, 0.0, 1.0);\n#else\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n depth += sqrt(dx*dx + dy*dy) * slopeScale + bias;\n gl_FragColor = encodeFloat(depth * 0.5 + 0.5);\n#endif\n}\n@end\n@export clay.sm.debug_depth\nuniform sampler2D depthMap;\nvarying vec2 v_Texcoord;\n@import clay.util.decode_float\nvoid main() {\n vec4 tex = texture2D(depthMap, v_Texcoord);\n#ifdef USE_VSM\n gl_FragColor = vec4(tex.rgb, 1.0);\n#else\n float depth = decodeFloat(tex);\n gl_FragColor = vec4(depth, depth, depth, 1.0);\n#endif\n}\n@end\n@export clay.sm.distance.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\n@import clay.chunk.skinning_header\nvarying vec3 v_WorldPosition;\nvoid main (){\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n gl_Position = worldViewProjection * vec4(skinnedPosition , 1.0);\n v_WorldPosition = (world * vec4(skinnedPosition, 1.0)).xyz;\n}\n@end\n@export clay.sm.distance.fragment\nuniform vec3 lightPosition;\nuniform float range : 100;\nvarying vec3 v_WorldPosition;\n@import clay.util.encode_float\nvoid main(){\n float dist = distance(lightPosition, v_WorldPosition);\n#ifdef USE_VSM\n gl_FragColor = vec4(dist, dist * dist, 0.0, 0.0);\n#else\n dist = dist / range;\n gl_FragColor = encodeFloat(dist);\n#endif\n}\n@end\n@export clay.plugin.shadow_map_common\n@import clay.util.decode_float\nfloat tapShadowMap(sampler2D map, vec2 uv, float z){\n vec4 tex = texture2D(map, uv);\n return step(z, decodeFloat(tex) * 2.0 - 1.0);\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize, vec2 scale) {\n float shadowContrib = tapShadowMap(map, uv, z);\n vec2 offset = vec2(1.0 / textureSize) * scale;\n#ifdef PCF_KERNEL_SIZE\n for (int _idx_ = 0; _idx_ < PCF_KERNEL_SIZE; _idx_++) {{\n shadowContrib += tapShadowMap(map, uv + offset * pcfKernel[_idx_], z);\n }}\n return shadowContrib / float(PCF_KERNEL_SIZE + 1);\n#else\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, -offset.y), z);\n return shadowContrib / 9.0;\n#endif\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize) {\n return pcf(map, uv, z, textureSize, vec2(1.0));\n}\nfloat chebyshevUpperBound(vec2 moments, float z){\n float p = 0.0;\n z = z * 0.5 + 0.5;\n if (z <= moments.x) {\n p = 1.0;\n }\n float variance = moments.y - moments.x * moments.x;\n variance = max(variance, 0.0000001);\n float mD = moments.x - z;\n float pMax = variance / (variance + mD * mD);\n pMax = clamp((pMax-0.4)/(1.0-0.4), 0.0, 1.0);\n return max(p, pMax);\n}\nfloat computeShadowContrib(\n sampler2D map, mat4 lightVPM, vec3 position, float textureSize, vec2 scale, vec2 offset\n) {\n vec4 posInLightSpace = lightVPM * vec4(position, 1.0);\n posInLightSpace.xyz /= posInLightSpace.w;\n float z = posInLightSpace.z;\n if(all(greaterThan(posInLightSpace.xyz, vec3(-0.99, -0.99, -1.0))) &&\n all(lessThan(posInLightSpace.xyz, vec3(0.99, 0.99, 1.0)))){\n vec2 uv = (posInLightSpace.xy+1.0) / 2.0;\n #ifdef USE_VSM\n vec2 moments = texture2D(map, uv * scale + offset).xy;\n return chebyshevUpperBound(moments, z);\n #else\n return pcf(map, uv * scale + offset, z, textureSize, scale);\n #endif\n }\n return 1.0;\n}\nfloat computeShadowContrib(sampler2D map, mat4 lightVPM, vec3 position, float textureSize) {\n return computeShadowContrib(map, lightVPM, position, textureSize, vec2(1.0), vec2(0.0));\n}\nfloat computeShadowContribOmni(samplerCube map, vec3 direction, float range)\n{\n float dist = length(direction);\n vec4 shadowTex = textureCube(map, direction);\n#ifdef USE_VSM\n vec2 moments = shadowTex.xy;\n float variance = moments.y - moments.x * moments.x;\n float mD = moments.x - dist;\n float p = variance / (variance + mD * mD);\n if(moments.x + 0.001 < dist){\n return clamp(p, 0.0, 1.0);\n }else{\n return 1.0;\n }\n#else\n return step(dist, (decodeFloat(shadowTex) + 0.0002) * range);\n#endif\n}\n@end\n@export clay.plugin.compute_shadow_map\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT) || defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT) || defined(POINT_LIGHT_SHADOWMAP_COUNT)\n#ifdef SPOT_LIGHT_SHADOWMAP_COUNT\nuniform sampler2D spotLightShadowMaps[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 spotLightMatrices[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float spotLightShadowMapSizes[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#ifdef DIRECTIONAL_LIGHT_SHADOWMAP_COUNT\n#if defined(SHADOW_CASCADE)\nuniform sampler2D directionalLightShadowMaps[1]:unconfigurable;\nuniform mat4 directionalLightMatrices[SHADOW_CASCADE]:unconfigurable;\nuniform float directionalLightShadowMapSizes[1]:unconfigurable;\nuniform float shadowCascadeClipsNear[SHADOW_CASCADE]:unconfigurable;\nuniform float shadowCascadeClipsFar[SHADOW_CASCADE]:unconfigurable;\n#else\nuniform sampler2D directionalLightShadowMaps[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 directionalLightMatrices[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float directionalLightShadowMapSizes[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#endif\n#ifdef POINT_LIGHT_SHADOWMAP_COUNT\nuniform samplerCube pointLightShadowMaps[POINT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\nuniform bool shadowEnabled : true;\n#ifdef PCF_KERNEL_SIZE\nuniform vec2 pcfKernel[PCF_KERNEL_SIZE];\n#endif\n@import clay.plugin.shadow_map_common\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfSpotLights(vec3 position, inout float shadowContribs[SPOT_LIGHT_COUNT] ) {\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < SPOT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n spotLightShadowMaps[_idx_], spotLightMatrices[_idx_], position,\n spotLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = SPOT_LIGHT_SHADOWMAP_COUNT; _idx_ < SPOT_LIGHT_COUNT; _idx_++){{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n#ifdef SHADOW_CASCADE\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float depth = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far)\n / (gl_DepthRange.far - gl_DepthRange.near);\n float shadowContrib;\n shadowContribs[0] = 1.0;\n for (int _idx_ = 0; _idx_ < SHADOW_CASCADE; _idx_++) {{\n if (\n depth >= shadowCascadeClipsNear[_idx_] &&\n depth <= shadowCascadeClipsFar[_idx_]\n ) {\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[0], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[0],\n vec2(1.0 / float(SHADOW_CASCADE), 1.0),\n vec2(float(_idx_) / float(SHADOW_CASCADE), 0.0)\n );\n shadowContribs[0] = shadowContrib;\n }\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#else\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[_idx_], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfPointLights(vec3 position, inout float shadowContribs[POINT_LIGHT_COUNT] ){\n vec3 lightPosition;\n vec3 direction;\n for(int _idx_ = 0; _idx_ < POINT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n lightPosition = pointLightPosition[_idx_];\n direction = position - lightPosition;\n shadowContribs[_idx_] = computeShadowContribOmni(pointLightShadowMaps[_idx_], direction, pointLightRange[_idx_]);\n }}\n for(int _idx_ = POINT_LIGHT_SHADOWMAP_COUNT; _idx_ < POINT_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n@end"); /***/ }), -/* 167 */ +/* 176 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Shader__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture__ = __webpack_require__(4); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_FrameBuffer__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_createCompositor__ = __webpack_require__(168); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__SSAOPass__ = __webpack_require__(181); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__SSRPass__ = __webpack_require__(183); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__poissonKernel__ = __webpack_require__(185); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__NormalPass__ = __webpack_require__(186); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__EdgePass__ = __webpack_require__(188); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_claygl_src_math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__composite_js__ = __webpack_require__(189); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13_claygl_src_shader_source_compositor_blur_glsl_js__ = __webpack_require__(80); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14_claygl_src_shader_source_compositor_lut_glsl_js__ = __webpack_require__(81); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15_claygl_src_shader_source_compositor_output_glsl_js__ = __webpack_require__(82); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16_claygl_src_shader_source_compositor_bright_glsl_js__ = __webpack_require__(83); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17_claygl_src_shader_source_compositor_downsample_glsl_js__ = __webpack_require__(84); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18_claygl_src_shader_source_compositor_upsample_glsl_js__ = __webpack_require__(85); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19_claygl_src_shader_source_compositor_hdr_glsl_js__ = __webpack_require__(86); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20_claygl_src_shader_source_compositor_blend_glsl_js__ = __webpack_require__(87); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21_claygl_src_shader_source_compositor_fxaa_glsl_js__ = __webpack_require__(88); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__DOF_glsl_js__ = __webpack_require__(190); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__edge_glsl_js__ = __webpack_require__(191); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_createCompositor__ = __webpack_require__(177); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__SSAOPass__ = __webpack_require__(189); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__SSRPass__ = __webpack_require__(191); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__poissonKernel__ = __webpack_require__(193); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__NormalPass__ = __webpack_require__(194); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__EdgePass__ = __webpack_require__(196); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_claygl_src_math_Matrix4__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__composite_js__ = __webpack_require__(197); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13_claygl_src_shader_source_compositor_blur_glsl_js__ = __webpack_require__(87); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14_claygl_src_shader_source_compositor_lut_glsl_js__ = __webpack_require__(88); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15_claygl_src_shader_source_compositor_output_glsl_js__ = __webpack_require__(89); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16_claygl_src_shader_source_compositor_bright_glsl_js__ = __webpack_require__(90); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17_claygl_src_shader_source_compositor_downsample_glsl_js__ = __webpack_require__(91); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18_claygl_src_shader_source_compositor_upsample_glsl_js__ = __webpack_require__(92); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19_claygl_src_shader_source_compositor_hdr_glsl_js__ = __webpack_require__(93); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20_claygl_src_shader_source_compositor_blend_glsl_js__ = __webpack_require__(94); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21_claygl_src_shader_source_compositor_fxaa_glsl_js__ = __webpack_require__(95); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__DOF_glsl_js__ = __webpack_require__(198); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__edge_glsl_js__ = __webpack_require__(199); @@ -41224,30 +41461,31 @@ EffectCompositor.prototype.dispose = function (renderer) { /* harmony default export */ __webpack_exports__["a"] = (EffectCompositor); /***/ }), -/* 168 */ +/* 177 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__createCompositor__ = __webpack_require__(169); -// Alias +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__createCompositor__ = __webpack_require__(178); +// DEPRECATED /* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__createCompositor__["a" /* default */]); /***/ }), -/* 169 */ +/* 178 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_util__ = __webpack_require__(20); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__compositor_Compositor__ = __webpack_require__(170); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__compositor_SceneNode__ = __webpack_require__(172); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__compositor_TextureNode__ = __webpack_require__(173); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__compositor_FilterNode__ = __webpack_require__(174); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_util__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__compositor_Compositor__ = __webpack_require__(179); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__compositor_SceneNode__ = __webpack_require__(181); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__compositor_TextureNode__ = __webpack_require__(182); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__compositor_FilterNode__ = __webpack_require__(183); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Shader__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Texture__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Texture__ = __webpack_require__(4); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__TextureCube__ = __webpack_require__(24); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__shader_builtinCompositor__ = __webpack_require__(175); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__TextureCube__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__shader_registerBuiltinCompositor__ = __webpack_require__(184); + @@ -41259,6 +41497,7 @@ EffectCompositor.prototype.dispose = function (renderer) { +Object(__WEBPACK_IMPORTED_MODULE_9__shader_registerBuiltinCompositor__["a" /* default */])(__WEBPACK_IMPORTED_MODULE_5__Shader__["a" /* default */]); var shaderSourceReg = /^#source\((.*?)\)/; @@ -41410,6 +41649,13 @@ function createNode(nodeInfo, lib, opts) { return node; } +function defaultWidthFunc(width, height) { + return width; +} +function defaultHeightFunc(width, height) { + return height; +} + function convertParameter(paramInfo) { var param = {}; if (!paramInfo) { @@ -41426,6 +41672,8 @@ function convertParameter(paramInfo) { param[name] = val; } }); + + var sizeScale = paramInfo.scale || 1; ['width', 'height'] .forEach(function(name) { if (paramInfo[name] != null) { @@ -41433,7 +41681,7 @@ function convertParameter(paramInfo) { if (typeof val === 'string') { val = val.trim(); param[name] = createSizeParser( - name, tryConvertExpr(val) + name, tryConvertExpr(val), sizeScale ); } else { @@ -41441,6 +41689,13 @@ function convertParameter(paramInfo) { } } }); + if (!param.width) { + param.width = defaultWidthFunc; + } + if (!param.height) { + param.height = defaultHeightFunc; + } + if (paramInfo.useMipmap != null) { param.useMipmap = paramInfo.useMipmap; } @@ -41508,11 +41763,12 @@ function createSizeSetHandler(name, exprFunc) { }; } -function createSizeParser(name, exprFunc) { +function createSizeParser(name, exprFunc, scale) { + scale = scale || 1; return function (renderer) { var dpr = renderer.getDevicePixelRatio(); - var width = renderer.getWidth(); - var height = renderer.getHeight(); + var width = renderer.getWidth() * scale; + var height = renderer.getHeight() * scale; return exprFunc(width, height, dpr); }; } @@ -41538,12 +41794,12 @@ function tryConvertExpr(string) { /***/ }), -/* 170 */ +/* 179 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Graph__ = __webpack_require__(171); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__TexturePool__ = __webpack_require__(79); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Graph__ = __webpack_require__(180); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__TexturePool__ = __webpack_require__(86); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__FrameBuffer__ = __webpack_require__(10); @@ -41634,12 +41890,12 @@ var Compositor = __WEBPACK_IMPORTED_MODULE_0__Graph__["a" /* default */].extend( /***/ }), -/* 171 */ +/* 180 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CompositorNode__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CompositorNode__ = __webpack_require__(48); @@ -41783,11 +42039,11 @@ var Graph = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(f /***/ }), -/* 172 */ +/* 181 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__CompositorNode__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__CompositorNode__ = __webpack_require__(48); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__FrameBuffer__ = __webpack_require__(10); @@ -41888,11 +42144,11 @@ var SceneNode = __WEBPACK_IMPORTED_MODULE_0__CompositorNode__["a" /* default */] /***/ }), -/* 173 */ +/* 182 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__CompositorNode__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__CompositorNode__ = __webpack_require__(48); /** @@ -41927,12 +42183,12 @@ var TextureNode = __WEBPACK_IMPORTED_MODULE_0__CompositorNode__["a" /* default * /***/ }), -/* 174 */ +/* 183 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Pass__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CompositorNode__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Pass__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CompositorNode__ = __webpack_require__(48); // TODO Shader library @@ -42084,7 +42340,7 @@ var FilterNode = __WEBPACK_IMPORTED_MODULE_1__CompositorNode__["a" /* default */ var texture = this._compositor.allocateTexture(parameters); this._outputTextures[name] = texture; var attachment = outputInfo.attachment || _gl.COLOR_ATTACHMENT0; - if (typeof(attachment) == 'string') { + if (typeof(attachment) === 'string') { attachment = _gl[attachment]; } attachedTextures[attachment] = texture; @@ -42102,7 +42358,7 @@ var FilterNode = __WEBPACK_IMPORTED_MODULE_1__CompositorNode__["a" /* default */ // Because the data of texture is changed over time, // Here update the mipmaps of texture each time after rendered; - this._compositor.getFrameBuffer().updateMipmap(renderer.gl); + this._compositor.getFrameBuffer().updateMipmap(renderer); } for (var inputName in this.inputLinks) { @@ -42144,6 +42400,8 @@ var FilterNode = __WEBPACK_IMPORTED_MODULE_1__CompositorNode__["a" /* default */ else { height = parameters.height; } + width = Math.ceil(width); + height = Math.ceil(height); if ( parametersCopy.width !== width || parametersCopy.height !== height @@ -42239,28 +42497,24 @@ var FilterNode = __WEBPACK_IMPORTED_MODULE_1__CompositorNode__["a" /* default */ /***/ }), -/* 175 */ +/* 184 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Shader__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__source_compositor_coloradjust_glsl_js__ = __webpack_require__(176); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__source_compositor_blur_glsl_js__ = __webpack_require__(80); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__source_compositor_lum_glsl_js__ = __webpack_require__(177); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__source_compositor_lut_glsl_js__ = __webpack_require__(81); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__source_compositor_vignette_glsl_js__ = __webpack_require__(178); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__source_compositor_output_glsl_js__ = __webpack_require__(82); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__source_compositor_bright_glsl_js__ = __webpack_require__(83); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__source_compositor_downsample_glsl_js__ = __webpack_require__(84); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__source_compositor_upsample_glsl_js__ = __webpack_require__(85); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__source_compositor_hdr_glsl_js__ = __webpack_require__(86); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__source_compositor_dof_glsl_js__ = __webpack_require__(179); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__source_compositor_lensflare_glsl_js__ = __webpack_require__(180); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__source_compositor_blend_glsl_js__ = __webpack_require__(87); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__source_compositor_fxaa_glsl_js__ = __webpack_require__(88); - - - +/* harmony export (immutable) */ __webpack_exports__["a"] = register; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__source_compositor_coloradjust_glsl_js__ = __webpack_require__(185); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__source_compositor_blur_glsl_js__ = __webpack_require__(87); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__source_compositor_lum_glsl_js__ = __webpack_require__(186); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__source_compositor_lut_glsl_js__ = __webpack_require__(88); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__source_compositor_vignette_glsl_js__ = __webpack_require__(187); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__source_compositor_output_glsl_js__ = __webpack_require__(89); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__source_compositor_bright_glsl_js__ = __webpack_require__(90); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__source_compositor_downsample_glsl_js__ = __webpack_require__(91); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__source_compositor_upsample_glsl_js__ = __webpack_require__(92); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__source_compositor_hdr_glsl_js__ = __webpack_require__(93); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__source_compositor_lensflare_glsl_js__ = __webpack_require__(188); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__source_compositor_blend_glsl_js__ = __webpack_require__(94); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__source_compositor_fxaa_glsl_js__ = __webpack_require__(95); @@ -42276,27 +42530,28 @@ var FilterNode = __WEBPACK_IMPORTED_MODULE_1__CompositorNode__["a" /* default */ // import fxaa3Essl from './source/compositor/fxaa3.glsl.js'; -// Some build in shaders -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_1__source_compositor_coloradjust_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_2__source_compositor_blur_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_3__source_compositor_lum_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_4__source_compositor_lut_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_5__source_compositor_vignette_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_6__source_compositor_output_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_7__source_compositor_bright_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_8__source_compositor_downsample_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_9__source_compositor_upsample_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_10__source_compositor_hdr_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_11__source_compositor_dof_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_12__source_compositor_lensflare_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_13__source_compositor_blend_glsl_js__["a" /* default */]); +// TODO Must export a module and be used in the other modules. Or it will be tree shaked +function register(Shader) { + // Some build in shaders + Shader['import'](__WEBPACK_IMPORTED_MODULE_0__source_compositor_coloradjust_glsl_js__["a" /* default */]); + Shader['import'](__WEBPACK_IMPORTED_MODULE_1__source_compositor_blur_glsl_js__["a" /* default */]); + Shader['import'](__WEBPACK_IMPORTED_MODULE_2__source_compositor_lum_glsl_js__["a" /* default */]); + Shader['import'](__WEBPACK_IMPORTED_MODULE_3__source_compositor_lut_glsl_js__["a" /* default */]); + Shader['import'](__WEBPACK_IMPORTED_MODULE_4__source_compositor_vignette_glsl_js__["a" /* default */]); + Shader['import'](__WEBPACK_IMPORTED_MODULE_5__source_compositor_output_glsl_js__["a" /* default */]); + Shader['import'](__WEBPACK_IMPORTED_MODULE_6__source_compositor_bright_glsl_js__["a" /* default */]); + Shader['import'](__WEBPACK_IMPORTED_MODULE_7__source_compositor_downsample_glsl_js__["a" /* default */]); + Shader['import'](__WEBPACK_IMPORTED_MODULE_8__source_compositor_upsample_glsl_js__["a" /* default */]); + Shader['import'](__WEBPACK_IMPORTED_MODULE_9__source_compositor_hdr_glsl_js__["a" /* default */]); + Shader['import'](__WEBPACK_IMPORTED_MODULE_10__source_compositor_lensflare_glsl_js__["a" /* default */]); + Shader['import'](__WEBPACK_IMPORTED_MODULE_11__source_compositor_blend_glsl_js__["a" /* default */]); -__WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_14__source_compositor_fxaa_glsl_js__["a" /* default */]); -// Shader['import'](fxaa3Essl); + Shader['import'](__WEBPACK_IMPORTED_MODULE_12__source_compositor_fxaa_glsl_js__["a" /* default */]); +} /***/ }), -/* 176 */ +/* 185 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -42304,7 +42559,7 @@ __WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMP /***/ }), -/* 177 */ +/* 186 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -42312,7 +42567,7 @@ __WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMP /***/ }), -/* 178 */ +/* 187 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -42320,15 +42575,7 @@ __WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMP /***/ }), -/* 179 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.dof.coc\nuniform sampler2D depth;\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\nuniform float focalDist: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\nvarying vec2 v_Texcoord;\n@import clay.util.encode_float\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n float aperture = focalLength / fstop;\n float coc;\n float uppper = focalDist + focalRange;\n float lower = focalDist - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 0.4) / 0.4000001;\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n gl_FragColor = encodeFloat(coc);\n}\n@end\n@export clay.compositor.dof.premultiply\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.decode_float\nvoid main() {\n float fCoc = max(abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0), 0.1);\n gl_FragColor = encodeHDR(\n vec4(decodeHDR(texture2D(texture, v_Texcoord)).rgb * fCoc, 1.0)\n );\n}\n@end\n@export clay.compositor.dof.min_coc\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform vec2 textureSize : [512.0, 512.0];\n@import clay.util.float\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord + d.xy));\n fCoc = min(fCoc, decodeFloat(texture2D(coc, v_Texcoord + d.zy)));\n fCoc = min(fCoc, decodeFloat(texture2D(coc, v_Texcoord + d.xw)));\n fCoc = min(fCoc, decodeFloat(texture2D(coc, v_Texcoord + d.zw)));\n gl_FragColor = encodeFloat(fCoc);\n}\n@end\n@export clay.compositor.dof.max_coc\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform vec2 textureSize : [512.0, 512.0];\n@import clay.util.float\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord + d.xy));\n fCoc = max(fCoc, decodeFloat(texture2D(coc, v_Texcoord + d.zy)));\n fCoc = max(fCoc, decodeFloat(texture2D(coc, v_Texcoord + d.xw)));\n fCoc = max(fCoc, decodeFloat(texture2D(coc, v_Texcoord + d.zw)));\n gl_FragColor = encodeFloat(fCoc);\n}\n@end\n@export clay.compositor.dof.coc_upsample\n#define HIGH_QUALITY\nuniform sampler2D coc;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.float\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n float s;\n s = decodeFloat(texture2D(coc, v_Texcoord - d.xy));\n s += decodeFloat(texture2D(coc, v_Texcoord - d.wy)) * 2.0;\n s += decodeFloat(texture2D(coc, v_Texcoord - d.zy));\n s += decodeFloat(texture2D(coc, v_Texcoord + d.zw)) * 2.0;\n s += decodeFloat(texture2D(coc, v_Texcoord )) * 4.0;\n s += decodeFloat(texture2D(coc, v_Texcoord + d.xw)) * 2.0;\n s += decodeFloat(texture2D(coc, v_Texcoord + d.zy));\n s += decodeFloat(texture2D(coc, v_Texcoord + d.wy)) * 2.0;\n s += decodeFloat(texture2D(coc, v_Texcoord + d.xy));\n gl_FragColor = encodeFloat(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n float s;\n s = decodeFloat(texture2D(coc, v_Texcoord + d.xy));\n s += decodeFloat(texture2D(coc, v_Texcoord + d.zy));\n s += decodeFloat(texture2D(coc, v_Texcoord + d.xw));\n s += decodeFloat(texture2D(coc, v_Texcoord + d.zw));\n gl_FragColor = encodeFloat(s / 4.0);\n#endif\n}\n@end\n@export clay.compositor.dof.upsample\n#define HIGH_QUALITY\nuniform sampler2D coc;\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.decode_float\nfloat tap(vec2 uv, inout vec4 color, float baseWeight) {\n float weight = abs(decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0) * baseWeight;\n color += decodeHDR(texture2D(texture, uv)) * weight;\n return weight;\n}\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 color = vec4(0.0);\n float baseWeight = 1.0 / 16.0;\n float w = tap(v_Texcoord - d.xy, color, baseWeight);\n w += tap(v_Texcoord - d.wy, color, baseWeight * 2.0);\n w += tap(v_Texcoord - d.zy, color, baseWeight);\n w += tap(v_Texcoord + d.zw, color, baseWeight * 2.0);\n w += tap(v_Texcoord , color, baseWeight * 4.0);\n w += tap(v_Texcoord + d.xw, color, baseWeight * 2.0);\n w += tap(v_Texcoord + d.zy, color, baseWeight);\n w += tap(v_Texcoord + d.wy, color, baseWeight * 2.0);\n w += tap(v_Texcoord + d.xy, color, baseWeight);\n gl_FragColor = encodeHDR(color / w);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 color = vec4(0.0);\n float baseWeight = 1.0 / 4.0;\n float w = tap(v_Texcoord + d.xy, color, baseWeight);\n w += tap(v_Texcoord + d.zy, color, baseWeight);\n w += tap(v_Texcoord + d.xw, color, baseWeight);\n w += tap(v_Texcoord + d.zw, color, baseWeight);\n gl_FragColor = encodeHDR(color / w);\n#endif\n}\n@end\n@export clay.compositor.dof.downsample\nuniform sampler2D texture;\nuniform sampler2D coc;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.decode_float\nfloat tap(vec2 uv, inout vec4 color) {\n float weight = abs(decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0) * 0.25;\n color += decodeHDR(texture2D(texture, uv)) * weight;\n return weight;\n}\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n vec4 color = vec4(0.0);\n float weight = tap(v_Texcoord + d.xy, color);\n weight += tap(v_Texcoord + d.zy, color);\n weight += tap(v_Texcoord + d.xw, color);\n weight += tap(v_Texcoord + d.zw, color);\n color /= weight;\n gl_FragColor = encodeHDR(color);\n}\n@end\n@export clay.compositor.dof.hexagonal_blur_frag\n@import clay.util.float\nvec4 doBlur(sampler2D targetTexture, vec2 offset) {\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n float weightSum = 0.0;\n float kernelWeight = 1.0 / float(KERNEL_SIZE);\n for (int i = 0; i < KERNEL_SIZE; i++) {\n vec2 coord = v_Texcoord + offset * float(i);\n float w = kernelWeight;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texture2D(targetTexture, coord)) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n float fCoc = decodeFloat(texture2D(coc, coord)) * 2.0 - 1.0;\n vec4 texel = texture2D(targetTexture, coord);\n #if !defined(BLUR_NEARFIELD)\n w *= abs(fCoc);\n #endif\n color += decodeHDR(texel) * w;\n#endif\n weightSum += w;\n }\n#ifdef BLUR_COC\n return encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n return color / weightSum;\n#endif\n}\n@end\n@export clay.compositor.dof.hexagonal_blur_1\n#define KERNEL_SIZE 5\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform float blurSize : 1.0;\nuniform vec2 textureSize : [512.0, 512.0];\n@import clay.util.rgbm\n@import clay.compositor.dof.hexagonal_blur_frag\nvoid main()\n{\n vec2 offset = blurSize / textureSize;\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n gl_FragColor = doBlur(texture, vec2(0.0, offset.y));\n#if !defined(BLUR_COC)\n gl_FragColor = encodeHDR(gl_FragColor);\n#endif\n}\n@end\n@export clay.compositor.dof.hexagonal_blur_2\n#define KERNEL_SIZE 5\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform float blurSize : 1.0;\nuniform vec2 textureSize : [512.0, 512.0];\n@import clay.util.rgbm\n@import clay.compositor.dof.hexagonal_blur_frag\nvoid main()\n{\n vec2 offset = blurSize / textureSize;\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n offset.y /= 2.0;\n gl_FragColor = doBlur(texture, -offset);\n#if !defined(BLUR_COC)\n gl_FragColor = encodeHDR(gl_FragColor);\n#endif\n}\n@end\n@export clay.compositor.dof.hexagonal_blur_3\n#define KERNEL_SIZE 5\nuniform sampler2D texture1;\nuniform sampler2D texture2;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform float blurSize : 1.0;\nuniform vec2 textureSize : [512.0, 512.0];\n@import clay.util.rgbm\n@import clay.compositor.dof.hexagonal_blur_frag\nvoid main()\n{\n vec2 offset = blurSize / textureSize;\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n offset.y /= 2.0;\n vec2 vDownRight = vec2(offset.x, -offset.y);\n vec4 texel1 = doBlur(texture1, -offset);\n vec4 texel2 = doBlur(texture1, vDownRight);\n vec4 texel3 = doBlur(texture2, vDownRight);\n#ifdef BLUR_COC\n float coc1 = decodeFloat(texel1) * 2.0 - 1.0;\n float coc2 = decodeFloat(texel2) * 2.0 - 1.0;\n float coc3 = decodeFloat(texel3) * 2.0 - 1.0;\n gl_FragColor = encodeFloat(\n ((coc1 + coc2 + coc3) / 3.0) * 0.5 + 0.5\n );\n#else\n vec4 color = (texel1 + texel2 + texel3) / 3.0;\n gl_FragColor = encodeHDR(color);\n#endif\n}\n@end\n@export clay.compositor.dof.composite\n#define DEBUG 0\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.float\nvoid main()\n{\n vec4 blurredColor = decodeHDR(texture2D(blurred, v_Texcoord));\n vec4 originalColor = decodeHDR(texture2D(original, v_Texcoord));\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n fCoc = abs(fCoc * 2.0 - 1.0);\n float weight = smoothstep(0.0, 1.0, fCoc);\n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = decodeHDR(texture2D(nearfield, v_Texcoord));\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n#if DEBUG == 1\n gl_FragColor = vec4(vec3(fCoc), 1.0);\n#elif DEBUG == 2\n gl_FragColor = vec4(vec3(fNearCoc), 1.0);\n#elif DEBUG == 3\n gl_FragColor = encodeHDR(blurredColor);\n#elif DEBUG == 4\n gl_FragColor = encodeHDR(nearfieldColor);\n#endif\n}\n@end"); - - -/***/ }), -/* 180 */ +/* 188 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -42336,19 +42583,19 @@ __WEBPACK_IMPORTED_MODULE_0__Shader__["a" /* default */]['import'](__WEBPACK_IMP /***/ }), -/* 181 */ +/* 189 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__ = __webpack_require__(16); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_FrameBuffer__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__halton__ = __webpack_require__(43); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__SSAO_glsl_js__ = __webpack_require__(182); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__halton__ = __webpack_require__(49); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__SSAO_glsl_js__ = __webpack_require__(190); @@ -42579,7 +42826,7 @@ SSAOPass.prototype.dispose = function (renderer) { /* harmony default export */ __webpack_exports__["a"] = (SSAOPass); /***/ }), -/* 182 */ +/* 190 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -42587,20 +42834,20 @@ SSAOPass.prototype.dispose = function (renderer) { /***/ }), -/* 183 */ +/* 191 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__ = __webpack_require__(16); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_FrameBuffer__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__halton__ = __webpack_require__(43); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_claygl_src_util_cubemap__ = __webpack_require__(70); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__SSR_glsl_js__ = __webpack_require__(184); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__halton__ = __webpack_require__(49); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_claygl_src_util_cubemap__ = __webpack_require__(77); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__SSR_glsl_js__ = __webpack_require__(192); @@ -42824,7 +43071,7 @@ SSRPass.prototype.dispose = function (renderer) { /* harmony default export */ __webpack_exports__["a"] = (SSRPass); /***/ }), -/* 184 */ +/* 192 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -42832,7 +43079,7 @@ SSRPass.prototype.dispose = function (renderer) { /***/ }), -/* 185 */ +/* 193 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -42874,18 +43121,18 @@ SSRPass.prototype.dispose = function (renderer) { ]); /***/ }), -/* 186 */ +/* 194 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture__ = __webpack_require__(4); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Shader__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_FrameBuffer__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_Material__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_compositor_Pass__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_util_texture__ = __webpack_require__(54); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__util_shader_normal_glsl_js__ = __webpack_require__(187); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_Material__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_compositor_Pass__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_util_texture__ = __webpack_require__(61); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__util_shader_normal_glsl_js__ = __webpack_require__(195); // NormalPass will generate normal and depth data. // TODO Animation @@ -43095,7 +43342,7 @@ NormalPass.prototype.dispose = function (renderer) { /* harmony default export */ __webpack_exports__["a"] = (NormalPass); /***/ }), -/* 187 */ +/* 195 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -43103,15 +43350,15 @@ NormalPass.prototype.dispose = function (renderer) { /***/ }), -/* 188 */ +/* 196 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__ = __webpack_require__(16); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_FrameBuffer__ = __webpack_require__(10); @@ -43173,7 +43420,7 @@ EdgePass.prototype.dispose = function (renderer) { /* harmony default export */ __webpack_exports__["a"] = (EdgePass); /***/ }), -/* 189 */ +/* 197 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -43749,7 +43996,7 @@ EdgePass.prototype.dispose = function (renderer) { }); /***/ }), -/* 190 */ +/* 198 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -43757,7 +44004,7 @@ EdgePass.prototype.dispose = function (renderer) { /***/ }), -/* 191 */ +/* 199 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -43765,16 +44012,16 @@ EdgePass.prototype.dispose = function (renderer) { /***/ }), -/* 192 */ +/* 200 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__halton__ = __webpack_require__(43); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_compositor_Pass__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__halton__ = __webpack_require__(49); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_compositor_Pass__ = __webpack_require__(16); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_FrameBuffer__ = __webpack_require__(10); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture2D__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__ = __webpack_require__(9); // Temporal Super Sample for static Scene @@ -43943,15 +44190,15 @@ TemporalSuperSampling.prototype = { /* harmony default export */ __webpack_exports__["a"] = (TemporalSuperSampling); /***/ }), -/* 193 */ +/* 201 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geo3D_Geo3DModel__ = __webpack_require__(194); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geo3D_Geo3DView__ = __webpack_require__(195); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__coord_geo3DCreator__ = __webpack_require__(91); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geo3D_Geo3DModel__ = __webpack_require__(202); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geo3D_Geo3DView__ = __webpack_require__(203); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__coord_geo3DCreator__ = __webpack_require__(98); @@ -43972,17 +44219,17 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({ }); /***/ }), -/* 194 */ +/* 202 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentViewControlMixin__ = __webpack_require__(38); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentPostEffectMixin__ = __webpack_require__(25); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_componentLightMixin__ = __webpack_require__(26); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_componentShadingMixin__ = __webpack_require__(28); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__coord_geo3D_geo3DModelMixin__ = __webpack_require__(89); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentViewControlMixin__ = __webpack_require__(44); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentPostEffectMixin__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_componentLightMixin__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_componentShadingMixin__ = __webpack_require__(31); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__coord_geo3D_geo3DModelMixin__ = __webpack_require__(96); @@ -44087,16 +44334,16 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Geo3DMode /* unused harmony default export */ var _unused_webpack_default_export = (Geo3DModel); /***/ }), -/* 195 */ +/* 203 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_Geo3DBuilder__ = __webpack_require__(59); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_Geo3DBuilder__ = __webpack_require__(64); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_OrbitControl__ = __webpack_require__(39); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_SceneHelper__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_OrbitControl__ = __webpack_require__(45); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_SceneHelper__ = __webpack_require__(30); @@ -44194,7 +44441,7 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Geo3DMode })); /***/ }), -/* 196 */ +/* 204 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -44818,11 +45065,29 @@ function signedArea(data, start, end, dim) { } /***/ }), -/* 197 */ +/* 205 */ /***/ (function(module, exports, __webpack_require__) { -var zrUtil = __webpack_require__(12); +var zrUtil = __webpack_require__(13); +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ var coordsOffsetMap = { '南海诸岛': [32, 80], // 全国 @@ -44848,11 +45113,29 @@ function _default(geo) { module.exports = _default; /***/ }), -/* 198 */ +/* 206 */ /***/ (function(module, exports, __webpack_require__) { -var zrUtil = __webpack_require__(12); +var zrUtil = __webpack_require__(13); +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ var geoCoordMap = { 'Russia': [100, 60], 'United States': [-99, 38], @@ -44874,15 +45157,15 @@ function _default(geo) { module.exports = _default; /***/ }), -/* 199 */ +/* 207 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__globe_GlobeModel__ = __webpack_require__(200); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__globe_GlobeView__ = __webpack_require__(201); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__coord_globeCreator__ = __webpack_require__(203); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__globe_GlobeModel__ = __webpack_require__(208); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__globe_GlobeView__ = __webpack_require__(209); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__coord_globeCreator__ = __webpack_require__(211); @@ -44911,16 +45194,16 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({ }); /***/ }), -/* 200 */ +/* 208 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentViewControlMixin__ = __webpack_require__(38); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentPostEffectMixin__ = __webpack_require__(25); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_componentLightMixin__ = __webpack_require__(26); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_componentShadingMixin__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentViewControlMixin__ = __webpack_require__(44); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentPostEffectMixin__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_componentLightMixin__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_componentShadingMixin__ = __webpack_require__(31); @@ -45122,17 +45405,17 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(GlobeMode /* unused harmony default export */ var _unused_webpack_default_export = (GlobeModel); /***/ }), -/* 201 */ +/* 209 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_OrbitControl__ = __webpack_require__(39); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_SceneHelper__ = __webpack_require__(27); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_sunCalc__ = __webpack_require__(202); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_OrbitControl__ = __webpack_require__(45); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_SceneHelper__ = __webpack_require__(30); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_sunCalc__ = __webpack_require__(210); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(2); @@ -45547,7 +45830,7 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(GlobeMode })); /***/ }), -/* 202 */ +/* 210 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -45638,18 +45921,18 @@ SunCalc.getPosition = function (date, lat, lng) { /* harmony default export */ __webpack_exports__["a"] = (SunCalc); /***/ }), -/* 203 */ +/* 211 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__globe_Globe__ = __webpack_require__(204); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__globe_Globe__ = __webpack_require__(212); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout__ = __webpack_require__(41); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout__ = __webpack_require__(47); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_retrieve__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_graphicGL__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__ = __webpack_require__(22); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_retrieve__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_graphicGL__ = __webpack_require__(1); @@ -45831,14 +46114,13 @@ __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.registerCoordinateSy /* unused harmony default export */ var _unused_webpack_default_export = (globeCreator); /***/ }), -/* 204 */ +/* 212 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix__ = __webpack_require__(6); -var vec3 = __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix___default.a.vec3; +var vec3 = __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix__["a" /* default */].vec3; function Globe(radius) { @@ -45941,15 +46223,15 @@ Globe.prototype = { /* harmony default export */ __webpack_exports__["a"] = (Globe); /***/ }), -/* 205 */ +/* 213 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__coord_mapbox3DCreator__ = __webpack_require__(206); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__mapbox3D_Mapbox3DModel__ = __webpack_require__(208); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__mapbox3D_Mapbox3DView__ = __webpack_require__(209); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__coord_mapbox3DCreator__ = __webpack_require__(214); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__mapbox3D_Mapbox3DModel__ = __webpack_require__(216); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__mapbox3D_Mapbox3DView__ = __webpack_require__(217); @@ -45971,14 +46253,14 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({ }); /***/ }), -/* 206 */ +/* 214 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mapbox3D_Mapbox3D__ = __webpack_require__(207); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mapbox3D_Mapbox3D__ = __webpack_require__(215); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__mapServiceCommon_createMapService3DCreator__ = __webpack_require__(94); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__mapServiceCommon_createMapService3DCreator__ = __webpack_require__(101); @@ -45993,11 +46275,11 @@ __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.registerCoordinateSy /* unused harmony default export */ var _unused_webpack_default_export = (mapbox3DCreator); /***/ }), -/* 207 */ +/* 215 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mapServiceCommon_MapService3D__ = __webpack_require__(93); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mapServiceCommon_MapService3D__ = __webpack_require__(100); function Mapbox3D() { @@ -46011,14 +46293,14 @@ Mapbox3D.prototype.type = 'mapbox3D'; /* harmony default export */ __webpack_exports__["a"] = (Mapbox3D); /***/ }), -/* 208 */ +/* 216 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentPostEffectMixin__ = __webpack_require__(25); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentLightMixin__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentPostEffectMixin__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentLightMixin__ = __webpack_require__(29); @@ -46095,16 +46377,16 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Mapbox3DM /* unused harmony default export */ var _unused_webpack_default_export = (Mapbox3DModel); /***/ }), -/* 209 */ +/* 217 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Mapbox3DLayer__ = __webpack_require__(210); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_SceneHelper__ = __webpack_require__(27); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_shader_displayShadow_glsl_js__ = __webpack_require__(95); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Mapbox3DLayer__ = __webpack_require__(218); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_SceneHelper__ = __webpack_require__(30); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_shader_displayShadow_glsl_js__ = __webpack_require__(102); @@ -46254,7 +46536,7 @@ var TILE_SIZE = 512; })); /***/ }), -/* 210 */ +/* 218 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -46337,15 +46619,15 @@ Mapbox3DLayer.prototype.dispose = function () { /* harmony default export */ __webpack_exports__["a"] = (Mapbox3DLayer); /***/ }), -/* 211 */ +/* 219 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__coord_maptalks3DCreator__ = __webpack_require__(212); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__maptalks3D_Maptalks3DModel__ = __webpack_require__(214); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__maptalks3D_Maptalks3DView__ = __webpack_require__(215); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__coord_maptalks3DCreator__ = __webpack_require__(220); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__maptalks3D_Maptalks3DModel__ = __webpack_require__(222); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__maptalks3D_Maptalks3DView__ = __webpack_require__(223); // Thanks to https://gitee.com/iverson_hu/maptalks-echarts-gl @@ -46368,14 +46650,14 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({ }); /***/ }), -/* 212 */ +/* 220 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__maptalks3D_Maptalks3D__ = __webpack_require__(213); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__maptalks3D_Maptalks3D__ = __webpack_require__(221); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__mapServiceCommon_createMapService3DCreator__ = __webpack_require__(94); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__mapServiceCommon_createMapService3DCreator__ = __webpack_require__(101); @@ -46390,11 +46672,11 @@ __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.registerCoordinateSy /* unused harmony default export */ var _unused_webpack_default_export = (maptalks3DCreator); /***/ }), -/* 213 */ +/* 221 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mapServiceCommon_MapService3D__ = __webpack_require__(93); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mapServiceCommon_MapService3D__ = __webpack_require__(100); function Maptalks3D() { @@ -46411,14 +46693,14 @@ Maptalks3D.prototype.type = 'maptalks3D'; /* harmony default export */ __webpack_exports__["a"] = (Maptalks3D); /***/ }), -/* 214 */ +/* 222 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentPostEffectMixin__ = __webpack_require__(25); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentLightMixin__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentPostEffectMixin__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentLightMixin__ = __webpack_require__(29); @@ -46496,16 +46778,16 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Maptalks3 /* unused harmony default export */ var _unused_webpack_default_export = (Maptalks3DModel); /***/ }), -/* 215 */ +/* 223 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Maptalks3DLayer__ = __webpack_require__(216); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_SceneHelper__ = __webpack_require__(27); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_shader_displayShadow_glsl_js__ = __webpack_require__(95); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Maptalks3DLayer__ = __webpack_require__(224); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_SceneHelper__ = __webpack_require__(30); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_shader_displayShadow_glsl_js__ = __webpack_require__(102); @@ -46674,7 +46956,7 @@ __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Shader.import(_ })); /***/ }), -/* 216 */ +/* 224 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -46768,16 +47050,16 @@ Maptalks3DLayer.prototype.dispose = function () { /***/ }), -/* 217 */ +/* 225 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__bar3D_bar3DLayout__ = __webpack_require__(218); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__bar3D_Bar3DView__ = __webpack_require__(221); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__bar3D_Bar3DSeries__ = __webpack_require__(223); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__bar3D_bar3DLayout__ = __webpack_require__(226); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__bar3D_Bar3DView__ = __webpack_require__(229); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__bar3D_Bar3DSeries__ = __webpack_require__(231); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17); @@ -46799,24 +47081,23 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerProcessor(fu }); /***/ }), -/* 218 */ +/* 226 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__cartesian3DLayout__ = __webpack_require__(219); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__evaluateBarSparseness__ = __webpack_require__(220); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__cartesian3DLayout__ = __webpack_require__(227); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__evaluateBarSparseness__ = __webpack_require__(228); -var vec3 = __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix___default.a.vec3; +var vec3 = __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix__["a" /* default */].vec3; var isDimensionStacked = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.helper.dataStack.isDimensionStacked; function globeLayout(seriesModel, coordSys) { @@ -46985,17 +47266,16 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerLayout(funct }); /***/ }), -/* 219 */ +/* 227 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(6); -var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default.a.vec3; +var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].vec3; var isDimensionStacked = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.helper.dataStack.isDimensionStacked; function ifCrossZero(extent) { @@ -47075,7 +47355,7 @@ function cartesian3DLayout(seriesModel, coordSys) { /* harmony default export */ __webpack_exports__["a"] = (cartesian3DLayout); /***/ }), -/* 220 */ +/* 228 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -47106,19 +47386,18 @@ function cartesian3DLayout(seriesModel, coordSys) { });; /***/ }), -/* 221 */ +/* 229 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_format__ = __webpack_require__(29); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_geometry_Bars3DGeometry__ = __webpack_require__(222); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__component_common_LabelsBuilder__ = __webpack_require__(61); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_claygl_src_dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_format__ = __webpack_require__(32); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_geometry_Bars3DGeometry__ = __webpack_require__(230); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__component_common_LabelsBuilder__ = __webpack_require__(66); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_dep_glmatrix__ = __webpack_require__(6); @@ -47126,7 +47405,7 @@ function cartesian3DLayout(seriesModel, coordSys) { -var vec3 = __WEBPACK_IMPORTED_MODULE_6_claygl_src_dep_glmatrix___default.a.vec3; +var vec3 = __WEBPACK_IMPORTED_MODULE_6_claygl_src_dep_glmatrix__["a" /* default */].vec3; /* unused harmony default export */ var _unused_webpack_default_export = (__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({ @@ -47442,17 +47721,16 @@ var vec3 = __WEBPACK_IMPORTED_MODULE_6_claygl_src_dep_glmatrix___default.a.vec3; })); /***/ }), -/* 222 */ +/* 230 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__dynamicConvertMixin__ = __webpack_require__(34); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__trianglesSortMixin__ = __webpack_require__(60); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Geometry__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_claygl_src_dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__dynamicConvertMixin__ = __webpack_require__(38); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__trianglesSortMixin__ = __webpack_require__(65); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Geometry__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_dep_glmatrix__ = __webpack_require__(6); /** * Geometry collecting bars data * @@ -47466,8 +47744,8 @@ var vec3 = __WEBPACK_IMPORTED_MODULE_6_claygl_src_dep_glmatrix___default.a.vec3; -var vec3 = __WEBPACK_IMPORTED_MODULE_4_claygl_src_dep_glmatrix___default.a.vec3; -var mat3 = __WEBPACK_IMPORTED_MODULE_4_claygl_src_dep_glmatrix___default.a.mat3; +var vec3 = __WEBPACK_IMPORTED_MODULE_4_claygl_src_dep_glmatrix__["a" /* default */].vec3; +var mat3 = __WEBPACK_IMPORTED_MODULE_4_claygl_src_dep_glmatrix__["a" /* default */].mat3; /** * @constructor @@ -47848,16 +48126,16 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.defaults(BarsGe /* harmony default export */ __webpack_exports__["a"] = (BarsGeometry); /***/ }), -/* 223 */ +/* 231 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_componentShadingMixin__ = __webpack_require__(28); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_format__ = __webpack_require__(29); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_formatTooltip__ = __webpack_require__(35); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_createList__ = __webpack_require__(44); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_componentShadingMixin__ = __webpack_require__(31); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_format__ = __webpack_require__(32); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_formatTooltip__ = __webpack_require__(39); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_createList__ = __webpack_require__(50); @@ -47945,17 +48223,17 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Bar3DSeri /* unused harmony default export */ var _unused_webpack_default_export = (Bar3DSeries); /***/ }), -/* 224 */ +/* 232 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__line3D_Line3DSeries__ = __webpack_require__(225); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__line3D_Line3DView__ = __webpack_require__(226); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__ = __webpack_require__(45); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__line3D_Line3DSeries__ = __webpack_require__(233); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__line3D_Line3DView__ = __webpack_require__(234); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__ = __webpack_require__(51); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17); @@ -48008,14 +48286,14 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerLayout(funct }); /***/ }), -/* 225 */ +/* 233 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_formatTooltip__ = __webpack_require__(35); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_createList__ = __webpack_require__(44); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_formatTooltip__ = __webpack_require__(39); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_createList__ = __webpack_require__(50); @@ -48054,22 +48332,21 @@ var Line3DSeries = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.e /* unused harmony default export */ var _unused_webpack_default_export = (Line3DSeries); /***/ }), -/* 226 */ +/* 234 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(22); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_math_Matrix4__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Vector3__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_zrender_lib_contain_line__ = __webpack_require__(227); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(25); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_math_Matrix4__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Vector3__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_zrender_lib_contain_line__ = __webpack_require__(235); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_zrender_lib_contain_line___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_zrender_lib_contain_line__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7_claygl_src_dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_shader_lines3D_glsl_js__ = __webpack_require__(40); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_claygl_src_dep_glmatrix__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_shader_lines3D_glsl_js__ = __webpack_require__(46); @@ -48081,7 +48358,7 @@ var Line3DSeries = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.e -var vec3 = __WEBPACK_IMPORTED_MODULE_7_claygl_src_dep_glmatrix___default.a.vec3; +var vec3 = __WEBPACK_IMPORTED_MODULE_7_claygl_src_dep_glmatrix__["a" /* default */].vec3; __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_8__util_shader_lines3D_glsl_js__["a" /* default */]); @@ -48367,7 +48644,7 @@ __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.import(_ })); /***/ }), -/* 227 */ +/* 235 */ /***/ (function(module, exports) { /** @@ -48411,17 +48688,17 @@ function containStroke(x0, y0, x1, y1, lineWidth, x, y) { exports.containStroke = containStroke; /***/ }), -/* 228 */ +/* 236 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__scatter3D_Scatter3DSeries__ = __webpack_require__(229); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__scatter3D_Scatter3DView__ = __webpack_require__(230); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__ = __webpack_require__(45); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__scatter3D_Scatter3DSeries__ = __webpack_require__(237); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__scatter3D_Scatter3DView__ = __webpack_require__(238); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__ = __webpack_require__(51); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17); @@ -48474,15 +48751,15 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerLayout({ }); /***/ }), -/* 229 */ +/* 237 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_format__ = __webpack_require__(29); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_formatTooltip__ = __webpack_require__(35); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_createList__ = __webpack_require__(44); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_format__ = __webpack_require__(32); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_formatTooltip__ = __webpack_require__(39); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_createList__ = __webpack_require__(50); @@ -48562,16 +48839,16 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({ }); /***/ }), -/* 230 */ +/* 238 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_format__ = __webpack_require__(29); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_PointsBuilder__ = __webpack_require__(62); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_format__ = __webpack_require__(32); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_PointsBuilder__ = __webpack_require__(67); @@ -48703,7 +48980,7 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({ }); /***/ }), -/* 231 */ +/* 239 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -48890,22 +49167,21 @@ var spriteUtil = { /* harmony default export */ __webpack_exports__["a"] = (spriteUtil); /***/ }), -/* 232 */ +/* 240 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_geometry_verticesSortMixin__ = __webpack_require__(233); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_geometry_verticesSortMixin__ = __webpack_require__(241); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__sdfSprite_glsl_js__ = __webpack_require__(234); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__sdfSprite_glsl_js__ = __webpack_require__(242); -var vec4 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix___default.a.vec4; +var vec4 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__["a" /* default */].vec4; __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_4__sdfSprite_glsl_js__["a" /* default */]); @@ -49018,16 +49294,15 @@ var PointsMesh = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */ /* harmony default export */ __webpack_exports__["a"] = (PointsMesh); /***/ }), -/* 233 */ +/* 241 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__ = __webpack_require__(90); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__ = __webpack_require__(97); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(6); -var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default.a.vec3; +var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].vec3; /* harmony default export */ __webpack_exports__["a"] = ({ @@ -49131,7 +49406,7 @@ var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default.a.vec3; }); /***/ }), -/* 234 */ +/* 242 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -49139,16 +49414,16 @@ var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default.a.vec3; /***/ }), -/* 235 */ +/* 243 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__lines3D_lines3DLayout__ = __webpack_require__(236); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__lines3D_Lines3DView__ = __webpack_require__(237); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__lines3D_Lines3DSeries__ = __webpack_require__(240); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__lines3D_lines3DLayout__ = __webpack_require__(244); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__lines3D_Lines3DView__ = __webpack_require__(245); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__lines3D_Lines3DSeries__ = __webpack_require__(248); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17); @@ -49180,18 +49455,17 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({ }, function () {}); /***/ }), -/* 236 */ +/* 244 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(6); -var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default.a.vec3; -var vec2 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix___default.a.vec2; +var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].vec3; +var vec2 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].vec2; var normalize = vec3.normalize; var cross = vec3.cross; var sub = vec3.sub; @@ -49356,16 +49630,16 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerLayout(funct }); /***/ }), -/* 237 */ +/* 245 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_geometry_Lines3D__ = __webpack_require__(22); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__TrailMesh2__ = __webpack_require__(238); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_shader_lines3D_glsl_js__ = __webpack_require__(40); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_geometry_Lines3D__ = __webpack_require__(25); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__TrailMesh2__ = __webpack_require__(246); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_shader_lines3D_glsl_js__ = __webpack_require__(46); @@ -49555,17 +49829,16 @@ function getCoordSysSize(coordSys) { })); /***/ }), -/* 238 */ +/* 246 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(22); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__shader_trail2_glsl_js__ = __webpack_require__(239); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(25); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__shader_trail2_glsl_js__ = __webpack_require__(247); @@ -49573,7 +49846,7 @@ function getCoordSysSize(coordSys) { -var vec3 = __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix___default.a.vec3; +var vec3 = __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix__["a" /* default */].vec3; function sign(a) { return a > 0 ? 1 : -1; @@ -49722,7 +49995,7 @@ __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.import(_ })); /***/ }), -/* 239 */ +/* 247 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -49730,7 +50003,7 @@ __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.import(_ /***/ }), -/* 240 */ +/* 248 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -49802,15 +50075,15 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({ }); /***/ }), -/* 241 */ +/* 249 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__polygons3D_Polygons3DSeries__ = __webpack_require__(242); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__polygons3D_Polygons3DView__ = __webpack_require__(243); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_opacityVisual__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__polygons3D_Polygons3DSeries__ = __webpack_require__(250); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__polygons3D_Polygons3DView__ = __webpack_require__(251); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_opacityVisual__ = __webpack_require__(17); @@ -49821,13 +50094,13 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(Object(__WEBPACK_IMPORTED_MODULE_3__common_opacityVisual__["a" /* default */])('polygons3D')); /***/ }), -/* 242 */ +/* 250 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_componentShadingMixin__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_componentShadingMixin__ = __webpack_require__(31); @@ -49940,14 +50213,14 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Polygons3 /* unused harmony default export */ var _unused_webpack_default_export = (Polygons3DSeries); /***/ }), -/* 243 */ +/* 251 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_Geo3DBuilder__ = __webpack_require__(59); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_Geo3DBuilder__ = __webpack_require__(64); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__ = __webpack_require__(1); @@ -50042,16 +50315,16 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({ }); /***/ }), -/* 244 */ +/* 252 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__surface_SurfaceSeries__ = __webpack_require__(245); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__surface_SurfaceView__ = __webpack_require__(246); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__surface_surfaceLayout__ = __webpack_require__(247); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__surface_SurfaceSeries__ = __webpack_require__(253); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__surface_SurfaceView__ = __webpack_require__(254); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__surface_surfaceLayout__ = __webpack_require__(255); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17); @@ -50064,15 +50337,15 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(Objec /***/ }), -/* 245 */ +/* 253 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_componentShadingMixin__ = __webpack_require__(28); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_formatTooltip__ = __webpack_require__(35); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_createList__ = __webpack_require__(44); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_componentShadingMixin__ = __webpack_require__(31); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_formatTooltip__ = __webpack_require__(39); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_createList__ = __webpack_require__(50); @@ -50274,24 +50547,23 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(SurfaceSe /* unused harmony default export */ var _unused_webpack_default_export = (SurfaceSeries); /***/ }), -/* 246 */ +/* 254 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_geometry_trianglesSortMixin__ = __webpack_require__(60); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_geometry_trianglesSortMixin__ = __webpack_require__(65); -var vec3 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix___default.a.vec3; +var vec3 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__["a" /* default */].vec3; function isPointsNaN(pt) { return isNaN(pt[0]) || isNaN(pt[1]) || isNaN(pt[2]); @@ -50754,7 +51026,7 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({ }); /***/ }), -/* 247 */ +/* 255 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -50797,16 +51069,16 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerLayout(funct }); /***/ }), -/* 248 */ +/* 256 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__coord_geo3D_Geo3D__ = __webpack_require__(92); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__map3D_Map3DSeries__ = __webpack_require__(249); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__map3D_Map3DView__ = __webpack_require__(250); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__coord_geo3D_Geo3D__ = __webpack_require__(99); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__map3D_Map3DSeries__ = __webpack_require__(257); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__map3D_Map3DView__ = __webpack_require__(258); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17); @@ -50830,20 +51102,20 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({ }); /***/ }), -/* 249 */ +/* 257 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_componentViewControlMixin__ = __webpack_require__(38); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__component_common_componentPostEffectMixin__ = __webpack_require__(25); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__component_common_componentLightMixin__ = __webpack_require__(26); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__component_common_componentShadingMixin__ = __webpack_require__(28); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__coord_geo3D_geo3DModelMixin__ = __webpack_require__(89); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__util_format__ = __webpack_require__(29); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__common_formatTooltip__ = __webpack_require__(35); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__coord_geo3DCreator__ = __webpack_require__(91); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_componentViewControlMixin__ = __webpack_require__(44); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__component_common_componentPostEffectMixin__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__component_common_componentLightMixin__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__component_common_componentShadingMixin__ = __webpack_require__(31); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__coord_geo3D_geo3DModelMixin__ = __webpack_require__(96); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__util_format__ = __webpack_require__(32); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__common_formatTooltip__ = __webpack_require__(39); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__coord_geo3DCreator__ = __webpack_require__(98); @@ -51002,16 +51274,16 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Map3DSeri /* unused harmony default export */ var _unused_webpack_default_export = (Map3DSeries); /***/ }), -/* 250 */ +/* 258 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_OrbitControl__ = __webpack_require__(39); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__component_common_SceneHelper__ = __webpack_require__(27); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__component_common_Geo3DBuilder__ = __webpack_require__(59); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_OrbitControl__ = __webpack_require__(45); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__component_common_SceneHelper__ = __webpack_require__(30); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__component_common_Geo3DBuilder__ = __webpack_require__(64); @@ -51124,17 +51396,17 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Map3DSeri })); /***/ }), -/* 251 */ +/* 259 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__scatterGL_ScatterGLSeries__ = __webpack_require__(252); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__scatterGL_ScatterGLView__ = __webpack_require__(253); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__ = __webpack_require__(45); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__scatterGL_ScatterGLSeries__ = __webpack_require__(260); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__scatterGL_ScatterGLView__ = __webpack_require__(261); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__ = __webpack_require__(51); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17); @@ -51193,7 +51465,7 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerLayout({ }); /***/ }), -/* 252 */ +/* 260 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -51261,17 +51533,17 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({ }); /***/ }), -/* 253 */ +/* 261 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_PointsBuilder__ = __webpack_require__(62); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_GLViewHelper__ = __webpack_require__(96); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__ = __webpack_require__(22); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_PointsBuilder__ = __webpack_require__(67); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_GLViewHelper__ = __webpack_require__(103); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(2); @@ -51393,17 +51665,17 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({ }); /***/ }), -/* 254 */ +/* 262 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__graphGL_GraphGLSeries__ = __webpack_require__(255); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__graphGL_GraphGLView__ = __webpack_require__(260); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__ = __webpack_require__(45); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__graphGL_GraphGLSeries__ = __webpack_require__(263); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__graphGL_GraphGLView__ = __webpack_require__(268); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__ = __webpack_require__(51); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17); @@ -51526,14 +51798,14 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({ }, noop); /***/ }), -/* 255 */ +/* 263 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__createGraphFromNodeEdge__ = __webpack_require__(256); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_format__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__createGraphFromNodeEdge__ = __webpack_require__(264); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_format__ = __webpack_require__(32); @@ -51807,17 +52079,17 @@ var GraphSeries = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.ex /* unused harmony default export */ var _unused_webpack_default_export = (GraphSeries); /***/ }), -/* 256 */ +/* 264 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_data_Graph__ = __webpack_require__(257); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_data_Graph__ = __webpack_require__(265); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_data_Graph___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_data_Graph__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_helper_linkList__ = __webpack_require__(259); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_helper_linkList__ = __webpack_require__(267); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_helper_linkList___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_helper_linkList__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_retrieve__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_retrieve__ = __webpack_require__(2); @@ -51876,19 +52148,38 @@ var GraphSeries = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.ex });; /***/ }), -/* 257 */ +/* 265 */ /***/ (function(module, exports, __webpack_require__) { -var _config = __webpack_require__(97); +var _config = __webpack_require__(104); var __DEV__ = _config.__DEV__; -var zrUtil = __webpack_require__(12); +var zrUtil = __webpack_require__(13); -var _clazz = __webpack_require__(258); +var _clazz = __webpack_require__(266); var enableClassCheck = _clazz.enableClassCheck; +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + /** * Graph data structure * @@ -52420,15 +52711,33 @@ var _default = Graph; module.exports = _default; /***/ }), -/* 258 */ +/* 266 */ /***/ (function(module, exports, __webpack_require__) { -var _config = __webpack_require__(97); +var _config = __webpack_require__(104); var __DEV__ = _config.__DEV__; -var zrUtil = __webpack_require__(12); +var zrUtil = __webpack_require__(13); +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ var TYPE_DELIMITER = '.'; var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___'; /** @@ -52668,10 +52977,29 @@ exports.enableClassManagement = enableClassManagement; exports.setReadOnly = setReadOnly; /***/ }), -/* 259 */ +/* 267 */ /***/ (function(module, exports, __webpack_require__) { -var zrUtil = __webpack_require__(12); +var zrUtil = __webpack_require__(13); + +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ /** * Link lists and struct (graph or tree) @@ -52801,27 +53129,26 @@ var _default = linkList; module.exports = _default; /***/ }), -/* 260 */ +/* 268 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_util_layout__ = __webpack_require__(41); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_util_layout__ = __webpack_require__(47); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_util_layout___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_util_layout__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_geometry_Lines2D__ = __webpack_require__(98); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__ForceAtlas2GPU__ = __webpack_require__(261); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__ForceAtlas2__ = __webpack_require__(263); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_zrender_lib_animation_requestAnimationFrame__ = __webpack_require__(72); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__ = __webpack_require__(22); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_geometry_Lines2D__ = __webpack_require__(105); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__ForceAtlas2GPU__ = __webpack_require__(269); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__ForceAtlas2__ = __webpack_require__(271); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_zrender_lib_animation_requestAnimationFrame__ = __webpack_require__(80); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_zrender_lib_animation_requestAnimationFrame___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8_zrender_lib_animation_requestAnimationFrame__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_claygl_src_dep_glmatrix__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_claygl_src_dep_glmatrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_9_claygl_src_dep_glmatrix__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__util_Roam2DControl__ = __webpack_require__(265); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__common_PointsBuilder__ = __webpack_require__(62); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__util_shader_lines2D_glsl_js__ = __webpack_require__(266); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_claygl_src_dep_glmatrix__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__util_Roam2DControl__ = __webpack_require__(273); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__common_PointsBuilder__ = __webpack_require__(67); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__util_shader_lines2D_glsl_js__ = __webpack_require__(274); @@ -52833,7 +53160,7 @@ module.exports = _default; -var vec2 = __WEBPACK_IMPORTED_MODULE_9_claygl_src_dep_glmatrix___default.a.vec2; +var vec2 = __WEBPACK_IMPORTED_MODULE_9_claygl_src_dep_glmatrix__["a" /* default */].vec2; @@ -53552,16 +53879,16 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({ }); /***/ }), -/* 261 */ +/* 269 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_compositor_Pass__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_compositor_Pass__ = __webpack_require__(16); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_FrameBuffer__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__forceAtlas2_glsl_js__ = __webpack_require__(262); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__forceAtlas2_glsl_js__ = __webpack_require__(270); @@ -54034,7 +54361,7 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.ForceAtlas2GPU = For /* harmony default export */ __webpack_exports__["a"] = (ForceAtlas2GPU); /***/ }), -/* 262 */ +/* 270 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54042,13 +54369,13 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.ForceAtlas2GPU = For /***/ }), -/* 263 */ +/* 271 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__forceAtlas2Worker_js__ = __webpack_require__(264); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__forceAtlas2Worker_js__ = __webpack_require__(272); @@ -54332,7 +54659,7 @@ ForceAtlas2.prototype.dispose = function (renderer) { /* harmony default export */ __webpack_exports__["a"] = (ForceAtlas2); /***/ }), -/* 264 */ +/* 272 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54999,12 +55326,12 @@ function forceAtlas2Worker() { /* harmony default export */ __webpack_exports__["a"] = (forceAtlas2Worker); /***/ }), -/* 265 */ +/* 273 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_core_Base__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__retrieve__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_core_Base__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__retrieve__ = __webpack_require__(2); @@ -55204,7 +55531,7 @@ var Roam2DControl = __WEBPACK_IMPORTED_MODULE_0_claygl_src_core_Base__["a" /* de /* harmony default export */ __webpack_exports__["a"] = (Roam2DControl); /***/ }), -/* 266 */ +/* 274 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55212,14 +55539,14 @@ var Roam2DControl = __WEBPACK_IMPORTED_MODULE_0_claygl_src_core_Base__["a" /* de /***/ }), -/* 267 */ +/* 275 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__flowGL_FlowGLView__ = __webpack_require__(268); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__flowGL_FlowGLSeries__ = __webpack_require__(272); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__flowGL_FlowGLView__ = __webpack_require__(276); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__flowGL_FlowGLSeries__ = __webpack_require__(280); @@ -55227,16 +55554,16 @@ var Roam2DControl = __WEBPACK_IMPORTED_MODULE_0_claygl_src_core_Base__["a" /* de /***/ }), -/* 268 */ +/* 276 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__VectorFieldParticleSurface__ = __webpack_require__(269); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__ = __webpack_require__(22); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__VectorFieldParticleSurface__ = __webpack_require__(277); @@ -55598,22 +55925,22 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({ /***/ }), -/* 269 */ +/* 277 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_compositor_Pass__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Geometry__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Mesh__ = __webpack_require__(31); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Material__ = __webpack_require__(17); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_compositor_Pass__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Geometry__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Mesh__ = __webpack_require__(40); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Material__ = __webpack_require__(19); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_Texture2D__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_Texture__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_claygl_src_camera_Orthographic__ = __webpack_require__(33); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_claygl_src_geometry_Plane__ = __webpack_require__(37); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_Texture__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_claygl_src_camera_Orthographic__ = __webpack_require__(37); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_claygl_src_geometry_Plane__ = __webpack_require__(43); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_claygl_src_FrameBuffer__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Line2D__ = __webpack_require__(270); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__vectorFieldParticle_glsl_js__ = __webpack_require__(271); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Line2D__ = __webpack_require__(278); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__vectorFieldParticle_glsl_js__ = __webpack_require__(279); @@ -56058,11 +56385,11 @@ VectorFieldParticleSurface.prototype = { /* harmony default export */ __webpack_exports__["a"] = (VectorFieldParticleSurface); /***/ }), -/* 270 */ +/* 278 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__ = __webpack_require__(15); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__); /** @@ -56148,7 +56475,7 @@ var LinesGeometry = __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* def /* harmony default export */ __webpack_exports__["a"] = (LinesGeometry); /***/ }), -/* 271 */ +/* 279 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56156,7 +56483,7 @@ var LinesGeometry = __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* def /***/ }), -/* 272 */ +/* 280 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56216,15 +56543,15 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({ }); /***/ }), -/* 273 */ +/* 281 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__linesGL_LinesGLSeries__ = __webpack_require__(274); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__linesGL_LinesGLView__ = __webpack_require__(275); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_opacityVisual__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__linesGL_LinesGLSeries__ = __webpack_require__(282); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__linesGL_LinesGLView__ = __webpack_require__(283); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_opacityVisual__ = __webpack_require__(17); @@ -56235,13 +56562,13 @@ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({ __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(Object(__WEBPACK_IMPORTED_MODULE_3__common_opacityVisual__["a" /* default */])('linesGL')); /***/ }), -/* 274 */ +/* 282 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_util__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_util__ = __webpack_require__(13); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_util___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_util__); @@ -56445,17 +56772,17 @@ var LinesSeries = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.ex }); /***/ }), -/* 275 */ +/* 283 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines2D__ = __webpack_require__(98); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_GLViewHelper__ = __webpack_require__(96); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__ = __webpack_require__(22); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines2D__ = __webpack_require__(105); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_GLViewHelper__ = __webpack_require__(103); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(2); diff --git a/dist/echarts-gl.min.js b/dist/echarts-gl.min.js index 554dee1a..8d6fd8f5 100644 --- a/dist/echarts-gl.min.js +++ b/dist/echarts-gl.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("echarts")):"function"==typeof define&&define.amd?define(["echarts"],t):"object"==typeof exports?exports["echarts-gl"]=t(require("echarts")):e["echarts-gl"]=t(e.echarts)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=99)}([function(t,r){t.exports=e},function(e,t,r){(function(e){!function(r){"use strict";var n={};n.exports=t,function(t){var r="undefined"==typeof window?e:window,n=r.GLMAT_EPSILON;null==n&&(n=1e-6);var i=r.GLMAT_ARRAY_TYPE||Array,a=r.GLMAT_RANDOM;a||(a=Math.random);var o={};o.setMatrixArrayType=function(e){i=e},void 0!==t&&(t.glMatrix=o);var s=Math.PI/180;o.toRadian=function(e){return e*s};var u={};u.create=function(){var e=new i(2);return e[0]=0,e[1]=0,e},u.clone=function(e){var t=new i(2);return t[0]=e[0],t[1]=e[1],t},u.fromValues=function(e,t){var r=new i(2);return r[0]=e,r[1]=t,r},u.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},u.set=function(e,t,r){return e[0]=t,e[1]=r,e},u.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e},u.subtract=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e},u.sub=u.subtract,u.multiply=function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e},u.mul=u.multiply,u.divide=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e},u.div=u.divide,u.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e},u.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e},u.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e},u.scaleAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e},u.distance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)},u.dist=u.distance,u.squaredDistance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n},u.sqrDist=u.squaredDistance,u.length=function(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)},u.len=u.length,u.squaredLength=function(e){var t=e[0],r=e[1];return t*t+r*r},u.sqrLen=u.squaredLength,u.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},u.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},u.normalize=function(e,t){var r=t[0],n=t[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},u.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},u.cross=function(e,t,r){var n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e},u.lerp=function(e,t,r,n){var i=t[0],a=t[1];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e},u.random=function(e,t){t=t||1;var r=2*a()*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e},u.transformMat2=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e},u.transformMat2d=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e},u.transformMat3=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e},u.transformMat4=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e},u.forEach=function(){var e=u.create();return function(t,r,n,i,a,o){var s,u;for(r||(r=2),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a),e},l.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},l.cross=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[0],s=r[1],u=r[2];return e[0]=i*u-a*s,e[1]=a*o-n*u,e[2]=n*s-i*o,e},l.lerp=function(e,t,r,n){var i=t[0],a=t[1],o=t[2];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e[2]=o+n*(r[2]-o),e},l.random=function(e,t){t=t||1;var r=2*a()*Math.PI,n=2*a()-1,i=Math.sqrt(1-n*n)*t;return e[0]=Math.cos(r)*i,e[1]=Math.sin(r)*i,e[2]=n*t,e},l.transformMat4=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,e[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,e[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,e[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,e},l.transformMat3=function(e,t,r){var n=t[0],i=t[1],a=t[2];return e[0]=n*r[0]+i*r[3]+a*r[6],e[1]=n*r[1]+i*r[4]+a*r[7],e[2]=n*r[2]+i*r[5]+a*r[8],e},l.transformQuat=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[0],s=r[1],u=r[2],l=r[3],c=l*n+s*a-u*i,h=l*i+u*n-o*a,d=l*a+o*i-s*n,f=-o*n-s*i-u*a;return e[0]=c*l+f*-o+h*-u-d*-s,e[1]=h*l+f*-s+d*-o-c*-u,e[2]=d*l+f*-u+c*-s-h*-o,e},l.rotateX=function(e,t,r,n){var i=[],a=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],a[0]=i[0],a[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),a[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},l.rotateY=function(e,t,r,n){var i=[],a=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],a[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),a[1]=i[1],a[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},l.rotateZ=function(e,t,r,n){var i=[],a=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],a[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),a[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),a[2]=i[2],e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},l.forEach=function(){var e=l.create();return function(t,r,n,i,a,o){var s,u;for(r||(r=3),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s1?0:Math.acos(i)},l.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},void 0!==t&&(t.vec3=l);var c={};c.create=function(){var e=new i(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},c.clone=function(e){var t=new i(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},c.fromValues=function(e,t,r,n){var a=new i(4);return a[0]=e,a[1]=t,a[2]=r,a[3]=n,a},c.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},c.set=function(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e},c.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e},c.subtract=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e},c.sub=c.subtract,c.multiply=function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e},c.mul=c.multiply,c.divide=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e},c.div=c.divide,c.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e},c.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e},c.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e},c.scaleAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e},c.distance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2],a=t[3]-e[3];return Math.sqrt(r*r+n*n+i*i+a*a)},c.dist=c.distance,c.squaredDistance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2],a=t[3]-e[3];return r*r+n*n+i*i+a*a},c.sqrDist=c.squaredDistance,c.length=function(e){var t=e[0],r=e[1],n=e[2],i=e[3];return Math.sqrt(t*t+r*r+n*n+i*i)},c.len=c.length,c.squaredLength=function(e){var t=e[0],r=e[1],n=e[2],i=e[3];return t*t+r*r+n*n+i*i},c.sqrLen=c.squaredLength,c.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},c.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e},c.normalize=function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a;return o>0&&(o=1/Math.sqrt(o),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e[3]=t[3]*o),e},c.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},c.lerp=function(e,t,r,n){var i=t[0],a=t[1],o=t[2],s=t[3];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e[2]=o+n*(r[2]-o),e[3]=s+n*(r[3]-s),e},c.random=function(e,t){return t=t||1,e[0]=a(),e[1]=a(),e[2]=a(),e[3]=a(),c.normalize(e,e),c.scale(e,e,t),e},c.transformMat4=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,e[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,e[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,e[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,e},c.transformQuat=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[0],s=r[1],u=r[2],l=r[3],c=l*n+s*a-u*i,h=l*i+u*n-o*a,d=l*a+o*i-s*n,f=-o*n-s*i-u*a;return e[0]=c*l+f*-o+h*-u-d*-s,e[1]=h*l+f*-s+d*-o-c*-u,e[2]=d*l+f*-u+c*-s-h*-o,e},c.forEach=function(){var e=c.create();return function(t,r,n,i,a,o){var s,u;for(r||(r=4),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(l.cross(e,i,a),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+o,m.normalize(n,n))}}(),m.setAxes=function(){var e=f.create();return function(t,r,n,i){return e[0]=n[0],e[3]=n[1],e[6]=n[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],m.normalize(t,m.fromMat3(t,e))}}(),m.clone=c.clone,m.fromValues=c.fromValues,m.copy=c.copy,m.set=c.set,m.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},m.setAxisAngle=function(e,t,r){r*=.5;var n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e},m.add=c.add,m.multiply=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=r[0],u=r[1],l=r[2],c=r[3];return e[0]=n*c+o*s+i*l-a*u,e[1]=i*c+o*u+a*s-n*l,e[2]=a*c+o*l+n*u-i*s,e[3]=o*c-n*s-i*u-a*l,e},m.mul=m.multiply,m.scale=c.scale,m.rotateX=function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+o*s,e[1]=i*u+a*s,e[2]=a*u-i*s,e[3]=o*u-n*s,e},m.rotateY=function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u-a*s,e[1]=i*u+o*s,e[2]=a*u+n*s,e[3]=o*u-i*s,e},m.rotateZ=function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+i*s,e[1]=i*u-n*s,e[2]=a*u+o*s,e[3]=o*u-a*s,e},m.calculateW=function(e,t){var r=t[0],n=t[1],i=t[2];return e[0]=r,e[1]=n,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),e},m.dot=c.dot,m.lerp=c.lerp,m.slerp=function(e,t,r,n){var i,a,o,s,u,l=t[0],c=t[1],h=t[2],d=t[3],f=r[0],p=r[1],m=r[2],g=r[3];return a=l*f+c*p+h*m+d*g,a<0&&(a=-a,f=-f,p=-p,m=-m,g=-g),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,u=Math.sin(n*i)/o):(s=1-n,u=n),e[0]=s*l+u*f,e[1]=s*c+u*p,e[2]=s*h+u*m,e[3]=s*d+u*g,e},m.invert=function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;return e[0]=-r*s,e[1]=-n*s,e[2]=-i*s,e[3]=a*s,e},m.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},m.length=c.length,m.len=m.length,m.squaredLength=c.squaredLength,m.sqrLen=m.squaredLength,m.normalize=c.normalize,m.fromMat3=function(e,t){var r,n=t[0]+t[4]+t[8];if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var a=(i+1)%3,o=(i+2)%3;r=Math.sqrt(t[3*i+i]-t[3*a+a]-t[3*o+o]+1),e[i]=.5*r,r=.5/r,e[3]=(t[3*a+o]-t[3*o+a])*r,e[a]=(t[3*a+i]+t[3*i+a])*r,e[o]=(t[3*o+i]+t[3*i+o])*r}return e},m.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},void 0!==t&&(t.quat=m)}(n.exports)}()}).call(t,r(63))},function(e,t,r){"use strict";function n(e){return!e||"none"===e}function i(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}function a(e){return e.getZr&&e.setOption}function o(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function s(e){if((e.wrapS===h.a.REPEAT||e.wrapT===h.a.REPEAT)&&e.image){var t=o(e.width),r=o(e.height);if(t!==e.width||r!==e.height){var n=document.createElement("canvas");n.width=t,n.height=r;n.getContext("2d").drawImage(e.image,0,0,t,r),e.image=n}}}var u=r(31),l=r(46),c=r(5),h=r(6),d=r(8),f=r(17),p=r(30),m=r(13),g=r(0),_=r.n(g),v=r(32),y=r(53),x=r.n(y),T=r(54),b=r(116),w=r(117),E=r(122),S=r(123),A=r(3),M=r(69),C=r(37),L=r(71),D=r(125),N=r(126),R=r(127),P=r(128),I=r(36),O=r(33),F=r(23),B=r(4),z=r(129),U=r(50),G=r(130),H=r(131),V=r(132),k=r(7),W=r(68),j=r(49),X=r(15),q=r(52),Z=r(133),Y=r(138),K=r(65),Q=r(139),J=r(140),$=r(141),ee=r(142),te=r(143),re=r(144);_.a.util.extend(p.a.prototype,Z.a),d.a.import(Y.a),d.a.import(K.a),d.a.import(Q.a),d.a.import(J.a),d.a.import($.a),d.a.import(ee.a),d.a.import(te.a),d.a.import(re.a);var ne=v.a.prototype.addToScene,ie=v.a.prototype.removeFromScene;v.a.prototype.addToScene=function(e){if(ne.call(this,e),this.__zr){var t=this.__zr;e.traverse(function(e){e.__zr=t,e.addAnimatorsToZr&&e.addAnimatorsToZr(t)})}},v.a.prototype.removeFromScene=function(e){ie.call(this,e),e.traverse(function(e){var t=e.__zr;e.__zr=null,t&&e.removeAnimatorsFromZr&&e.removeAnimatorsFromZr(t)})},f.a.prototype.setTextureImage=function(e,t,r,i){if(this.shader){var a,o=r.getZr(),s=this;return s.autoUpdateTextureStatus=!1,s.disableTexture(e),n(t)||(a=ae.loadTexture(t,r,i,function(t){s.enableTexture(e),o&&o.refresh()}),s.set(e,a)),a}};var ae={};ae.Renderer=l.a,ae.Node=p.a,ae.Mesh=u.a,ae.Shader=d.a,ae.Material=f.a,ae.Texture=h.a,ae.Texture2D=c.a,ae.Geometry=m.a,ae.SphereGeometry=M.a,ae.PlaneGeometry=C.a,ae.CubeGeometry=L.a,ae.AmbientLight=D.a,ae.DirectionalLight=N.a,ae.PointLight=R.a,ae.SpotLight=P.a,ae.PerspectiveCamera=I.a,ae.OrthographicCamera=O.a,ae.Vector2=F.a,ae.Vector3=B.a,ae.Vector4=z.a,ae.Quaternion=U.a,ae.Matrix2=G.a,ae.Matrix2d=H.a,ae.Matrix3=V.a,ae.Matrix4=k.a,ae.Plane=W.a,ae.Ray=j.a,ae.BoundingBox=X.a,ae.Frustum=q.a;var oe=T.a.createBlank("rgba(255,255,255,0)").image;ae.loadTexture=function(e,t,r,n){"function"==typeof r&&(n=r,r={}),r=r||{};for(var o=Object.keys(r).sort(),u="",l=0;l3?t[3]=e[3]:t[3]=1,t):(t=_.a.color.parse(e||"#000",t)||[0,0,0,0],t[0]/=255,t[1]/=255,t[2]/=255,t)},ae.directionFromAlphaBeta=function(e,t){var r=e/180*Math.PI+Math.PI/2,n=-t/180*Math.PI+Math.PI/2,i=[],a=Math.sin(r);return i[0]=a*Math.cos(n),i[1]=-Math.cos(r),i[2]=a*Math.sin(n),i},ae.getShadowResolution=function(e){var t=1024;switch(e){case"low":t=512;break;case"medium":break;case"high":t=2048;break;case"ultra":t=4096}return t},ae.COMMON_SHADERS=["lambert","color","realistic","hatching"],ae.createShader=function(e){var t=d.a.source(e+".vertex"),r=d.a.source(e+".fragment");t||console.error("Vertex shader of '%s' not exits",e),r||console.error("Fragment shader of '%s' not exits",e);var n=new d.a(t,r);return n.name=e,n},ae.createMaterial=function(e,t){t instanceof Array||(t=[t]);var r=ae.createShader(e),n=new f.a({shader:r});return t.forEach(function(e){"string"==typeof e&&n.define(e)}),n},ae.setMaterialFromModel=function(e,t,r,n){t.autoUpdateTextureStatus=!1;var i=r.getModel(e+"Material"),a=i.get("detailTexture"),o=A.a.firstNotNull(i.get("textureTiling"),1),s=A.a.firstNotNull(i.get("textureOffset"),0);"number"==typeof o&&(o=[o,o]),"number"==typeof s&&(s=[s,s]);var u=o[0]>1||o[1]>1?ae.Texture.REPEAT:ae.Texture.CLAMP_TO_EDGE,l={anisotropic:8,wrapS:u,wrapT:u};if("realistic"===e){var c=i.get("roughness"),h=i.get("metalness");null!=h?isNaN(h)&&(t.setTextureImage("metalnessMap",h,n,l),h=A.a.firstNotNull(i.get("metalnessAdjust"),.5)):h=0,null!=c?isNaN(c)&&(t.setTextureImage("roughnessMap",c,n,l),c=A.a.firstNotNull(i.get("roughnessAdjust"),.5)):c=.5;var d=i.get("normalTexture");t.setTextureImage("detailMap",a,n,l),t.setTextureImage("normalMap",d,n,l),t.set({roughness:c,metalness:h,detailUvRepeat:o,detailUvOffset:s})}else if("lambert"===e)t.setTextureImage("detailMap",a,n,l),t.set({detailUvRepeat:o,detailUvOffset:s});else if("color"===e)t.setTextureImage("detailMap",a,n,l),t.set({detailUvRepeat:o,detailUvOffset:s});else if("hatching"===e){for(var f=i.get("hatchingTextures")||[],p=0;p<6;p++)t.setTextureImage("hatch"+(p+1),f[p],n,{anisotropic:8,wrapS:ae.Texture.REPEAT,wrapT:ae.Texture.REPEAT});t.set({detailUvRepeat:o,detailUvOffset:s})}},ae.updateVertexAnimation=function(e,t,r,n){var i=n.get("animation"),a=n.get("animationDurationUpdate"),o=n.get("animationEasingUpdate"),s=r.shadowDepthMaterial;if(i&&t&&a>0&&t.geometry.vertexCount===r.geometry.vertexCount){r.material.define("vertex","VERTEX_ANIMATION"),r.ignorePreZ=!0,s&&s.define("vertex","VERTEX_ANIMATION");for(var u=0;ur?r:e}var i=r(1),a=r.n(i),o=a.a.vec3,s=function(e,t,r){e=e||0,t=t||0,r=r||0,this.array=o.fromValues(e,t,r),this._dirty=!0};s.prototype={constructor:s,add:function(e){return o.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,r){return this.array[0]=e,this.array[1]=t,this.array[2]=r,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this._dirty=!0,this},clone:function(){return new s(this.x,this.y,this.z)},copy:function(e){return o.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return o.cross(this.array,e.array,t.array),this._dirty=!0,this},dist:function(e){return o.dist(this.array,e.array)},distance:function(e){return o.distance(this.array,e.array)},div:function(e){return o.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return o.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return o.dot(this.array,e.array)},len:function(){return o.len(this.array)},length:function(){return o.length(this.array)},lerp:function(e,t,r){return o.lerp(this.array,e.array,t.array,r),this._dirty=!0,this},min:function(e){return o.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return o.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return o.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return o.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return o.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return o.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return o.random(this.array,e),this._dirty=!0,this},scale:function(e){return o.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return o.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return o.sqrDist(this.array,e.array)},squaredDistance:function(e){return o.squaredDistance(this.array,e.array)},sqrLen:function(){return o.sqrLen(this.array)},squaredLength:function(){return o.squaredLength(this.array)},sub:function(e){return o.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return o.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return o.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return o.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return o.transformQuat(this.array,this.array,e.array),this._dirty=!0,this},applyProjection:function(e){var t=this.array;if(e=e.array,0===e[15]){var r=-1/t[2];t[0]=e[0]*t[0]*r,t[1]=e[5]*t[1]*r,t[2]=(e[10]*t[2]+e[14])*r}else t[0]=e[0]*t[0]+e[12],t[1]=e[5]*t[1]+e[13],t[2]=e[10]*t[2]+e[14];return this._dirty=!0,this},eulerFromQuat:function(e,t){s.eulerFromQuat(this,e,t)},eulerFromMat3:function(e,t){s.eulerFromMat3(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var u=Object.defineProperty;if(u){var l=s.prototype;u(l,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),u(l,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),u(l,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}})}s.add=function(e,t,r){return o.add(e.array,t.array,r.array),e._dirty=!0,e},s.set=function(e,t,r,n){o.set(e.array,t,r,n),e._dirty=!0},s.copy=function(e,t){return o.copy(e.array,t.array),e._dirty=!0,e},s.cross=function(e,t,r){return o.cross(e.array,t.array,r.array),e._dirty=!0,e},s.dist=function(e,t){return o.distance(e.array,t.array)},s.distance=s.dist,s.div=function(e,t,r){return o.divide(e.array,t.array,r.array),e._dirty=!0,e},s.divide=s.div,s.dot=function(e,t){return o.dot(e.array,t.array)},s.len=function(e){return o.length(e.array)},s.lerp=function(e,t,r,n){return o.lerp(e.array,t.array,r.array,n),e._dirty=!0,e},s.min=function(e,t,r){return o.min(e.array,t.array,r.array),e._dirty=!0,e},s.max=function(e,t,r){return o.max(e.array,t.array,r.array),e._dirty=!0,e},s.mul=function(e,t,r){return o.multiply(e.array,t.array,r.array),e._dirty=!0,e},s.multiply=s.mul,s.negate=function(e,t){return o.negate(e.array,t.array),e._dirty=!0,e},s.normalize=function(e,t){return o.normalize(e.array,t.array),e._dirty=!0,e},s.random=function(e,t){return o.random(e.array,t),e._dirty=!0,e},s.scale=function(e,t,r){return o.scale(e.array,t.array,r),e._dirty=!0,e},s.scaleAndAdd=function(e,t,r,n){return o.scaleAndAdd(e.array,t.array,r.array,n),e._dirty=!0,e},s.sqrDist=function(e,t){return o.sqrDist(e.array,t.array)},s.squaredDistance=s.sqrDist,s.sqrLen=function(e){return o.sqrLen(e.array)},s.squaredLength=s.sqrLen,s.sub=function(e,t,r){return o.subtract(e.array,t.array,r.array),e._dirty=!0,e},s.subtract=s.sub,s.transformMat3=function(e,t,r){return o.transformMat3(e.array,t.array,r.array),e._dirty=!0,e},s.transformMat4=function(e,t,r){return o.transformMat4(e.array,t.array,r.array),e._dirty=!0,e},s.transformQuat=function(e,t,r){return o.transformQuat(e.array,t.array,r.array),e._dirty=!0,e};var c=Math.atan2,h=Math.asin,d=Math.abs;s.eulerFromQuat=function(e,t,r){e._dirty=!0,t=t.array;var i=e.array,a=t[0],o=t[1],s=t[2],u=t[3],l=a*a,d=o*o,f=s*s,p=u*u,r=(r||"XYZ").toUpperCase();switch(r){case"XYZ":i[0]=c(2*(a*u-o*s),p-l-d+f),i[1]=h(n(2*(a*s+o*u),-1,1)),i[2]=c(2*(s*u-a*o),p+l-d-f);break;case"YXZ":i[0]=h(n(2*(a*u-o*s),-1,1)),i[1]=c(2*(a*s+o*u),p-l-d+f),i[2]=c(2*(a*o+s*u),p-l+d-f);break;case"ZXY":i[0]=h(n(2*(a*u+o*s),-1,1)),i[1]=c(2*(o*u-s*a),p-l-d+f),i[2]=c(2*(s*u-a*o),p-l+d-f);break;case"ZYX":i[0]=c(2*(a*u+s*o),p-l-d+f),i[1]=h(n(2*(o*u-a*s),-1,1)),i[2]=c(2*(a*o+s*u),p+l-d-f);break;case"YZX":i[0]=c(2*(a*u-s*o),p-l+d-f),i[1]=c(2*(o*u-a*s),p+l-d-f),i[2]=h(n(2*(a*o+s*u),-1,1));break;case"XZY":i[0]=c(2*(a*u+o*s),p-l+d-f),i[1]=c(2*(a*s+o*u),p+l-d-f),i[2]=h(n(2*(s*u-a*o),-1,1));break;default:console.warn("Unkown order: "+r)}return e},s.eulerFromMat3=function(e,t,r){var i=t.array,a=i[0],o=i[3],s=i[6],u=i[1],l=i[4],f=i[7],p=i[2],m=i[5],g=i[8],_=e.array,r=(r||"XYZ").toUpperCase();switch(r){case"XYZ":_[1]=h(n(s,-1,1)),d(s)<.99999?(_[0]=c(-f,g),_[2]=c(-o,a)):(_[0]=c(m,l),_[2]=0);break;case"YXZ":_[0]=h(-n(f,-1,1)),d(f)<.99999?(_[1]=c(s,g),_[2]=c(u,l)):(_[1]=c(-p,a),_[2]=0);break;case"ZXY":_[0]=h(n(m,-1,1)),d(m)<.99999?(_[1]=c(-p,g),_[2]=c(-o,l)):(_[1]=0,_[2]=c(u,a));break;case"ZYX":_[1]=h(-n(p,-1,1)),d(p)<.99999?(_[0]=c(m,g),_[2]=c(u,a)):(_[0]=0,_[2]=c(-o,l));break;case"YZX":_[2]=h(n(u,-1,1)),d(u)<.99999?(_[0]=c(-f,l),_[1]=c(-p,a)):(_[0]=0,_[1]=c(s,g));break;case"XZY":_[2]=h(-n(o,-1,1)),d(o)<.99999?(_[0]=c(m,l),_[1]=c(s,a)):(_[0]=c(-f,g),_[1]=0);break;default:console.warn("Unkown order: "+r)}return e._dirty=!0,e},s.POSITIVE_X=new s(1,0,0),s.NEGATIVE_X=new s(-1,0,0),s.POSITIVE_Y=new s(0,1,0),s.NEGATIVE_Y=new s(0,-1,0),s.POSITIVE_Z=new s(0,0,1),s.NEGATIVE_Z=new s(0,0,-1),s.UP=new s(0,1,0),s.ZERO=new s(0,0,0),t.a=s},function(e,t,r){"use strict";function n(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function i(e,t){var r=n(e.width),i=n(e.height);return t=t||document.createElement("canvas"),t.width=r,t.height=i,t.getContext("2d").drawImage(e.image,0,0,r,i),t}var a=r(6),o=r(11),s=r(67),u=s.a.isPowerOfTwo,l=a.a.extend(function(){return{image:null,pixels:null,mipmaps:[],convertToPOT:!1}},{textureType:"texture2D",update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),this.updateCommon(e);var r=this.format,n=this.type,i=!(!this.convertToPOT||this.mipmaps.length||!this.image||this.wrapS!==a.a.REPEAT&&this.wrapT!==a.a.REPEAT||!this.NPOT);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,i?this.wrapS:this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,i?this.wrapT:this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,i?this.magFilter:this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,i?this.minFilter:this.getAvailableMinFilter());var s=e.getGLExtension("EXT_texture_filter_anisotropic");if(s&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_2D,s.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===n){e.getGLExtension("OES_texture_half_float")||(n=o.a.FLOAT)}if(this.mipmaps.length)for(var u=this.width,l=this.height,c=0;c=a.a.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,r,s,n,o,0,t.pixels):e.texImage2D(e.TEXTURE_2D,r,s,n,o,0,s,u,t.pixels)},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_2D))},isPowerOfTwo:function(){return u(this.width)&&u(this.height)},isRenderable:function(){return this.image?"CANVAS"===this.image.nodeName||"VIDEO"===this.image.nodeName||this.image.complete:!(!this.width||!this.height)},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},load:function(e,t){var r=new Image;t&&(r.crossOrigin=t);var n=this;return r.onload=function(){n.dirty(),n.trigger("success",n),r.onload=null},r.onerror=function(){n.trigger("error",n),r.onerror=null},r.src=e,this.image=r,this}});Object.defineProperty(l.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(e){this.image?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}}),Object.defineProperty(l.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(e){this.image?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}}),t.a=l},function(e,t,r){"use strict";var n=r(9),i=r(11),a=r(48),o=n.a.extend({width:512,height:512,type:i.a.UNSIGNED_BYTE,format:i.a.RGBA,wrapS:i.a.REPEAT,wrapT:i.a.REPEAT,minFilter:i.a.LINEAR_MIPMAP_LINEAR,magFilter:i.a.LINEAR,useMipmap:!0,anisotropic:1,flipY:!0,sRGB:!0,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1,__used:0},function(){this._cache=new a.a},{getWebGLTexture:function(e){var t=e.gl,r=this._cache;return r.use(e.__uid__),r.miss("webgl_texture")&&r.put("webgl_texture",t.createTexture()),this.dynamic?this.update(e):r.isDirty()&&(this.update(e),r.fresh()),r.get("webgl_texture")},bind:function(){},unbind:function(){},dirty:function(){this._cache&&this._cache.dirtyAll()},update:function(e){},updateCommon:function(e){var t=e.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,this.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,this.unpackAlignment),this.format===i.a.DEPTH_COMPONENT&&(this.useMipmap=!1);var r=e.getGLExtension("EXT_sRGB");this.format!==o.SRGB||r||(this.format=o.RGB),this.format!==o.SRGB_ALPHA||r||(this.format=o.RGBA),this.NPOT=!this.isPowerOfTwo()},getAvailableWrapS:function(){return this.NPOT?i.a.CLAMP_TO_EDGE:this.wrapS},getAvailableWrapT:function(){return this.NPOT?i.a.CLAMP_TO_EDGE:this.wrapT},getAvailableMinFilter:function(){var e=this.minFilter;return this.NPOT||!this.useMipmap?e===i.a.NEAREST_MIPMAP_NEAREST||e===i.a.NEAREST_MIPMAP_LINEAR?i.a.NEAREST:e===i.a.LINEAR_MIPMAP_LINEAR||e===i.a.LINEAR_MIPMAP_NEAREST?i.a.LINEAR:e:e},getAvailableMagFilter:function(){return this.magFilter},nextHighestPowerOfTwo:function(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1},dispose:function(e){var t=this._cache;t.use(e.__uid__);var r=t.get("webgl_texture");r&&e.gl.deleteTexture(r),t.deleteContext(e.__uid__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(o.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(o.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),o.BYTE=i.a.BYTE,o.UNSIGNED_BYTE=i.a.UNSIGNED_BYTE,o.SHORT=i.a.SHORT,o.UNSIGNED_SHORT=i.a.UNSIGNED_SHORT,o.INT=i.a.INT,o.UNSIGNED_INT=i.a.UNSIGNED_INT,o.FLOAT=i.a.FLOAT,o.HALF_FLOAT=36193,o.UNSIGNED_INT_24_8_WEBGL=34042,o.DEPTH_COMPONENT=i.a.DEPTH_COMPONENT,o.DEPTH_STENCIL=i.a.DEPTH_STENCIL,o.ALPHA=i.a.ALPHA,o.RGB=i.a.RGB,o.RGBA=i.a.RGBA,o.LUMINANCE=i.a.LUMINANCE,o.LUMINANCE_ALPHA=i.a.LUMINANCE_ALPHA,o.SRGB=35904,o.SRGB_ALPHA=35906,o.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,o.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,o.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,o.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,o.NEAREST=i.a.NEAREST,o.LINEAR=i.a.LINEAR,o.NEAREST_MIPMAP_NEAREST=i.a.NEAREST_MIPMAP_NEAREST,o.LINEAR_MIPMAP_NEAREST=i.a.LINEAR_MIPMAP_NEAREST,o.NEAREST_MIPMAP_LINEAR=i.a.NEAREST_MIPMAP_LINEAR,o.LINEAR_MIPMAP_LINEAR=i.a.LINEAR_MIPMAP_LINEAR,o.REPEAT=i.a.REPEAT,o.CLAMP_TO_EDGE=i.a.CLAMP_TO_EDGE,o.MIRRORED_REPEAT=i.a.MIRRORED_REPEAT,t.a=o},function(e,t,r){"use strict";var n=r(1),i=r.n(n),a=r(4),o=i.a.mat4,s=i.a.vec3,u=i.a.mat3,l=i.a.quat,c=function(){this._axisX=new a.a,this._axisY=new a.a,this._axisZ=new a.a,this.array=o.create(),this._dirty=!0};c.prototype={constructor:c,setArray:function(e){for(var t=0;t=0){if(1!==c&&4!==c){a();break}c=2,d=[]}else if(1!==c)if(4!==c)r(f),c=0;else{var p=f;x.indexOf(p)>=0||T.indexOf(p)>=0||b.indexOf(p)>=0?h[u].semantic=p:"ignore"===p||"unconfigurable"===p?h[u].ignore=!0:h[u].value="bool"===e?"true"===p:parseFloat(p)}else h[u].value="bool"===e?"true"===f:parseFloat(f),d=null;else{if(2!==c){a();break}if(!(d instanceof Array)){a();break}d.push(+i[++s])}else h[u].value=new l.a.Float32Array(d),d=null,c=5;else if(2===c){if(!(d instanceof Array)){a();break}d.push(+i[++s])}else c=5;else c=4;else{if(0!==c&&3!==c){a();break}c=1}}return h}function s(e,t){"object"==typeof e&&(t=e.fragment,e=e.vertex),e=i(e),t=i(t),this._shaderID=n(e,t),this._vertexCode=s.parseImport(e),this._fragmentCode=s.parseImport(t),this.attributeSemantics={},this.matrixSemantics={},this.uniformSemantics={},this.matrixSemanticKeys=[],this.uniformTemplates={},this.attributes={},this.textures={},this.vertexDefines={},this.fragmentDefines={},this._parseAttributes(),this._parseUniforms(),this._parseDefines()}var u=r(20),l=r(18),c=r(1),h=r.n(c),d=h.a.mat2,f=h.a.mat3,p=h.a.mat4,m=/uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g,g=/attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g,_=/#define\s+(\w+)?(\s+[\w-.]+)?\s*;?\s*\n/g,v={bool:"1i",int:"1i",sampler2D:"t",samplerCube:"t",float:"1f",vec2:"2f",vec3:"3f",vec4:"4f",ivec2:"2i",ivec3:"3i",ivec4:"4i",mat2:"m2",mat3:"m3",mat4:"m4"},y={bool:function(){return!0},int:function(){return 0},float:function(){return 0},sampler2D:function(){return null},samplerCube:function(){return null},vec2:function(){return[0,0]},vec3:function(){return[0,0,0]},vec4:function(){return[0,0,0,0]},ivec2:function(){return[0,0]},ivec3:function(){return[0,0,0]},ivec4:function(){return[0,0,0,0]},mat2:function(){return d.create()},mat3:function(){return f.create()},mat4:function(){return p.create()},array:function(){return[]}},x=["POSITION","NORMAL","BINORMAL","TANGENT","TEXCOORD","TEXCOORD_0","TEXCOORD_1","COLOR","JOINT","WEIGHT"],T=["SKIN_MATRIX","VIEWPORT_SIZE","VIEWPORT","DEVICEPIXELRATIO","WINDOW_SIZE","NEAR","FAR","TIME"],b=["WORLD","VIEW","PROJECTION","WORLDVIEW","VIEWPROJECTION","WORLDVIEWPROJECTION","WORLDINVERSE","VIEWINVERSE","PROJECTIONINVERSE","WORLDVIEWINVERSE","VIEWPROJECTIONINVERSE","WORLDVIEWPROJECTIONINVERSE","WORLDTRANSPOSE","VIEWTRANSPOSE","PROJECTIONTRANSPOSE","WORLDVIEWTRANSPOSE","VIEWPROJECTIONTRANSPOSE","WORLDVIEWPROJECTIONTRANSPOSE","WORLDINVERSETRANSPOSE","VIEWINVERSETRANSPOSE","PROJECTIONINVERSETRANSPOSE","WORLDVIEWINVERSETRANSPOSE","VIEWPROJECTIONINVERSETRANSPOSE","WORLDVIEWPROJECTIONINVERSETRANSPOSE"],w={vec4:4,vec3:3,vec2:2,float:1},E={},S={};s.prototype={constructor:s,createUniforms:function(){var e={};for(var t in this.uniformTemplates){var r=this.uniformTemplates[t];e[t]={type:r.type,value:r.value()}}return e},_parseImport:function(){this._vertexCode=s.parseImport(this.vertex),this._fragmentCode=s.parseImport(this.fragment)},_addSemanticUniform:function(e,t,r){if(x.indexOf(r)>=0)this.attributeSemantics[r]={symbol:e,type:t};else if(b.indexOf(r)>=0){var n=!1,i=r;r.match(/TRANSPOSE$/)&&(n=!0,i=r.slice(0,-9)),this.matrixSemantics[r]={symbol:e,type:t,isTranspose:n,semanticNoTranspose:i}}else T.indexOf(r)>=0&&(this.uniformSemantics[r]={symbol:e,type:t})},_addMaterialUniform:function(e,t,r,n,i,a){a[e]={type:r,value:i?y.array:n||y[t],semantic:null}},_parseUniforms:function(){function e(e){return null!=e?function(){return e}:null}function t(t,a,s){var u=o(a,s),l=[];for(var c in u){var h=u[c],d=h.semantic,f=c,p=v[a],m=e(u[c].value);u[c].isArray&&(f+="["+u[c].arraySize+"]",p+="v"),l.push(f),n._uniformList.push(c),h.ignore||("sampler2D"!==a&&"samplerCube"!==a||(n.textures[c]={shaderType:i,type:a}),d?n._addSemanticUniform(c,p,d):n._addMaterialUniform(c,a,p,m,u[c].isArray,r))}return l.length>0?"uniform "+a+" "+l.join(",")+";\n":""}var r={},n=this,i="vertex";this._uniformList=[],this._vertexCode=this._vertexCode.replace(m,t),i="fragment",this._fragmentCode=this._fragmentCode.replace(m,t),n.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=r},_parseAttributes:function(){function e(e,n,i){var a=o(n,i),s=w[n]||1,u=[];for(var l in a){var c=a[l].semantic;if(t[l]={type:"float",size:s,semantic:c||null},c){if(x.indexOf(c)<0)throw new Error('Unkown semantic "'+c+'"');r.attributeSemantics[c]={symbol:l,type:n}}u.push(l)}return"attribute "+n+" "+u.join(",")+";\n"}var t={},r=this;this._vertexCode=this._vertexCode.replace(g,e),this.attributes=t},_parseDefines:function(){function e(e,n,i){var a="vertex"===r?t.vertexDefines:t.fragmentDefines;return a[n]||(a[n]="false"!==i&&("true"===i||(i?isNaN(parseFloat(i))?i.trim():parseFloat(i):null))),""}var t=this,r="vertex";this._vertexCode=this._vertexCode.replace(_,e),r="fragment",this._fragmentCode=this._fragmentCode.replace(_,e)},clone:function(){var e=S[this._shaderID];return new s(e.vertex,e.fragment)}},Object.defineProperty&&(Object.defineProperty(s.prototype,"shaderID",{get:function(){return this._shaderID}}),Object.defineProperty(s.prototype,"vertex",{get:function(){return this._vertexCode}}),Object.defineProperty(s.prototype,"fragment",{get:function(){return this._fragmentCode}}),Object.defineProperty(s.prototype,"uniforms",{get:function(){return this._uniformList}}));var A=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;s.parseImport=function(e){return e=e.replace(A,function(e,t,r){var e=s.source(r);return e?s.parseImport(e):(console.error('Shader chunk "'+r+'" not existed in library'),"")})};var M=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;s.import=function(e){e.replace(M,function(e,t,r,n){var n=n.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"");if(n){for(var i,a=r.split("."),o=s.codes,u=0;ua[0]&&(a[0]=s),u>a[1]&&(a[1]=u),l>a[2]&&(a[2]=l)}r._dirty=!0,n._dirty=!0}},dirty:function(){for(var e=this.getEnabledAttributes(),t=0;t=0){t||(t=_());var r=this.indices;return t[0]=r[3*e],t[1]=r[3*e+1],t[2]=r[3*e+2],t}},setTriangleIndices:function(e,t){var r=this.indices;r[3*e]=t[0],r[3*e+1]=t[1],r[3*e+2]=t[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(e){var t,r=this.vertexCount>65535?h.a.Uint32Array:h.a.Uint16Array;if(e[0]&&e[0].length){var n=0;t=new r(3*e.length);for(var i=0;i=0&&(t.splice(r,1),delete this.attributes[e],!0)},getAttribute:function(e){return this.attributes[e]},getEnabledAttributes:function(){var e=this._enabledAttributes,t=this._attributeList;if(e)return e;for(var r=[],n=this.vertexCount,i=0;i65535&&(this.indices=new h.a.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,r=this.getEnabledAttributes(),n={},i=0;i=r.COLOR_ATTACHMENT0&&a<=r.COLOR_ATTACHMENT0+8&&i.push(a);n.drawBuffersEXT(i)}}this.trigger("beforerender",this,e);var o=this.clearDepth?r.DEPTH_BUFFER_BIT:0;if(r.depthMask(!0),this.clearColor){o|=r.COLOR_BUFFER_BIT,r.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&r.clearColor(s[0],s[1],s[2],s[3])}r.clear(o),this.blendWithPrevious?(r.enable(r.BLEND),this.material.transparent=!0):(r.disable(r.BLEND),this.material.transparent=!1),this.renderQuad(e),this.trigger("afterrender",this,e),t&&this.unbind(e,t)},renderQuad:function(e){d.material=this.material,e.renderPass([d],f)},dispose:function(e){}});t.a=p},function(e,t,r){"use strict";var n=r(4),i=r(1),a=r.n(i),o=a.a.vec3,s=o.copy,u=o.set,l=function(e,t){this.min=e||new n.a(1/0,1/0,1/0),this.max=t||new n.a(-1/0,-1/0,-1/0),this.vertices=null};l.prototype={constructor:l,updateFromVertices:function(e){if(e.length>0){var t=this.min,r=this.max,n=t.array,i=r.array;s(n,e[0]),s(i,e[0]);for(var a=1;ai[0]&&(i[0]=o[0]),o[1]>i[1]&&(i[1]=o[1]),o[2]>i[2]&&(i[2]=o[2])}t._dirty=!0,r._dirty=!0}},union:function(e){var t=this.min,r=this.max;return o.min(t.array,t.array,e.min.array),o.max(r.array,r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},intersection:function(e){var t=this.min,r=this.max;return o.max(t.array,t.array,e.min.array),o.min(r.array,r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},intersectBoundingBox:function(e){var t=this.min.array,r=this.max.array,n=e.min.array,i=e.max.array;return!(t[0]>i[0]||t[1]>i[1]||t[2]>i[2]||r[0]=i[0]&&r[1]>=i[1]&&r[2]>=i[2]},containPoint:function(e){var t=this.min.array,r=this.max.array,n=e.array;return t[0]<=n[0]&&t[1]<=n[1]&&t[2]<=n[2]&&r[0]>=n[0]&&r[1]>=n[1]&&r[2]>=n[2]},isFinite:function(){var e=this.min.array,t=this.max.array;return isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])&&isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])},applyTransform:function(e){this.transformFrom(this,e)},transformFrom:function(){var e=o.create(),t=o.create(),r=o.create(),n=o.create(),i=o.create(),a=o.create();return function(o,s){var u=o.min.array,l=o.max.array,c=s.array;return e[0]=c[0]*u[0],e[1]=c[1]*u[0],e[2]=c[2]*u[0],t[0]=c[0]*l[0],t[1]=c[1]*l[0],t[2]=c[2]*l[0],r[0]=c[4]*u[1],r[1]=c[5]*u[1],r[2]=c[6]*u[1],n[0]=c[4]*l[1],n[1]=c[5]*l[1],n[2]=c[6]*l[1],i[0]=c[8]*u[2],i[1]=c[9]*u[2],i[2]=c[10]*u[2],a[0]=c[8]*l[2],a[1]=c[9]*l[2],a[2]=c[10]*l[2],u=this.min.array,l=this.max.array,u[0]=Math.min(e[0],t[0])+Math.min(r[0],n[0])+Math.min(i[0],a[0])+c[12],u[1]=Math.min(e[1],t[1])+Math.min(r[1],n[1])+Math.min(i[1],a[1])+c[13],u[2]=Math.min(e[2],t[2])+Math.min(r[2],n[2])+Math.min(i[2],a[2])+c[14],l[0]=Math.max(e[0],t[0])+Math.max(r[0],n[0])+Math.max(i[0],a[0])+c[12],l[1]=Math.max(e[1],t[1])+Math.max(r[1],n[1])+Math.max(i[1],a[1])+c[13],l[2]=Math.max(e[2],t[2])+Math.max(r[2],n[2])+Math.max(i[2],a[2])+c[14],this.min._dirty=!0,this.max._dirty=!0,this}}(),applyProjection:function(e){var t=this.min.array,r=this.max.array,n=e.array,i=t[0],a=t[1],o=t[2],s=r[0],u=r[1],l=t[2],c=r[0],h=r[1],d=r[2];if(1===n[15])t[0]=n[0]*i+n[12],t[1]=n[5]*a+n[13],r[2]=n[10]*o+n[14],r[0]=n[0]*c+n[12],r[1]=n[5]*h+n[13],t[2]=n[10]*d+n[14];else{var f=-1/o;t[0]=n[0]*i*f,t[1]=n[5]*a*f,r[2]=(n[10]*o+n[14])*f,f=-1/l,r[0]=n[0]*s*f,r[1]=n[5]*u*f,f=-1/d,t[2]=(n[10]*d+n[14])*f}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){e=[];for(var t=0;t<8;t++)e[t]=o.fromValues(0,0,0);this.vertices=e}var r=this.min.array,n=this.max.array;return u(e[0],r[0],r[1],r[2]),u(e[1],r[0],n[1],r[2]),u(e[2],n[0],r[1],r[2]),u(e[3],n[0],n[1],r[2]),u(e[4],r[0],r[1],n[2]),u(e[5],r[0],n[1],n[2]),u(e[6],n[0],r[1],n[2]),u(e[7],n[0],n[1],n[2]),this},copy:function(e){var t=this.min,r=this.max;return s(t.array,e.min.array),s(r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},clone:function(){var e=new l;return e.copy(this),e}},t.a=l},function(e,t,r){"use strict";t.a=function(e,t,r){return{seriesType:e,reset:function(e,t){function r(e,t){var r=e.getItemModel(t),n=r.get(i,!0);null!=n&&e.setItemVisual(t,"opacity",n)}var n=e.getData(),i=e.visualColorAccessPath.split(".");i[i.length-1]="opacity";var a=e.get(i);return n.setVisual("opacity",null==a?1:a),{dataEach:n.hasItemOption?r:null}}}}},function(e,t,r){"use strict";function n(e){var t=Object.keys(e);t.sort();for(var r=[],n=0;n=0},getEnabledUniforms:function(){return this._enabledUniforms},getTextureUniforms:function(){return this._textureUniforms},set:function(e,t){if("object"==typeof e)for(var r in e){var n=e[r];this.setUniform(r,n)}else this.setUniform(e,t)},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){var r=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var n=this.uniforms;this._enabledUniforms=Object.keys(n),this._enabledUniforms.sort(),this._textureUniforms=this._enabledUniforms.filter(function(e){var t=this.uniforms[e].type;return"t"===t||"tv"===t},this);var i=this.vertexDefines,a=this.fragmentDefines;if(this.vertexDefines=o.a.clone(e.vertexDefines),this.fragmentDefines=o.a.clone(e.fragmentDefines),t){for(var s in r)n[s]&&(n[s].value=r[s].value);o.a.defaults(this.vertexDefines,i),o.a.defaults(this.fragmentDefines,a)}var u={};for(var l in e.textures)u[l]={shaderType:e.textures[l].shaderType,type:e.textures[l].type,enabled:!(!t||!this._textureStatus[l])&&this._textureStatus[l].enabled};this._textureStatus=u,this._programKey=""},clone:function(){var e=new this.constructor({name:this.name,shader:this.shader});for(var t in this.uniforms)e.uniforms[t].value=this.uniforms[t].value;return e.depthTest=this.depthTest,e.depthMask=this.depthMask,e.transparent=this.transparent,e.blend=this.blend,e.vertexDefines=o.a.clone(this.vertexDefines),e.fragmentDefines=o.a.clone(this.fragmentDefines),e.enableTexture(this.getEnabledTextures()),e.precision=this.precision,e},define:function(e,t,r){var n=this.vertexDefines,i=this.fragmentDefines;"vertex"!==e&&"fragment"!==e&&"both"!==e&&arguments.length<3&&(r=t,t=e,e="both"),r=null!=r?r:null,"vertex"!==e&&"both"!==e||n[t]!==r&&(n[t]=r,this._programKey=""),"fragment"!==e&&"both"!==e||i[t]!==r&&(i[t]=r,"both"!==e&&(this._programKey=""))},undefine:function(e,t){"vertex"!==e&&"fragment"!==e&&"both"!==e&&arguments.length<2&&(t=e,e="both"),"vertex"!==e&&"both"!==e||this.isDefined("vertex",t)&&(delete this.vertexDefines[t],this._programKey=""),"fragment"!==e&&"both"!==e||this.isDefined("fragment",t)&&(delete this.fragmentDefines[t],"both"!==e&&(this._programKey=""))},isDefined:function(e,t){switch(e){case"vertex":return void 0!==this.vertexDefines[t];case"fragment":return void 0!==this.fragmentDefines[t]}},getDefine:function(e,t){switch(e){case"vertex":return this.vertexDefines[t];case"fragment":return this.fragmentDefines[t]}},enableTexture:function(e){if(Array.isArray(e))for(var t=0;t=r.x&&t>=r.y&&e<=r.x+r.width&&t<=r.y+r.height};var _=new d.a;n.prototype.castRay=function(e,t,r){var n=this.layer.renderer,i=n.viewport;return n.viewport=this.viewport,n.screenToNDC(e,t,_),this.camera.castRay(_,r),n.viewport=i,r},n.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this.scene.updateLights();var e=this.scene.updateRenderList(this.camera);this._needsSortProgressively=!1;for(var t=0;t30},n.prototype._doRender=function(e,t,r){var n=this.scene,i=this.camera;r=r||0,this._updateTransparent(e,n,i,r),t||(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(e,n,i,!0)),this._updateShadowPCFKernel(r);var a=e.clearColor;if(e.gl.clearColor(a[0],a[1],a[2],a[3]),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,i),this._compositor.updateNormal(e,n,i,this._temporalSS.getFrame())),this._updateSSAO(e,n,i,this._temporalSS.getFrame()),this._enablePostEffect){var o=this._compositor.getSourceFrameBuffer();o.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),e.render(n,i,!0,!0),o.unbind(e),this.needsTemporalSS()&&t?(this._compositor.composite(e,n,i,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),this._compositor.composite(e,n,i,null,0))}else if(this.needsTemporalSS()&&t){var o=this._temporalSS.getSourceFrameBuffer();o.bind(e),e.saveClear(),e.clearBit=e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT,e.render(n,i,!0,!0),e.restoreClear(),o.unbind(e),e.setViewport(this.viewport),this._temporalSS.render(e)}else e.setViewport(this.viewport),e.render(n,i,!0,!0)},n.prototype._updateTransparent=function(e,t,r,n){for(var i=new h.a,a=new c.a,o=r.getWorldPosition(),s=t.getRenderList(r).transparent,u=0;uthis.camera.far||e65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(e){this.triangleCount!==e&&(this.indices=0===e?null:this.vertexCount>65535?new Uint32Array(3*e):new Uint16Array(3*e))},_getCubicCurveApproxStep:function(e,t,r,n){return 1/(l.dist(e,t)+l.dist(r,t)+l.dist(n,r)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?2*a:2*a+2},getCubicCurveTriangleCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?0:2*a},getLineVertexCount:function(){return this.getPolylineVertexCount(c)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(c)},getPolylineVertexCount:function(e){var t;if("number"==typeof e)t=e;else{t="number"!=typeof e[0]?e.length:e.length/3}return this.useNativeLine?2*(t-1):2*(t-1)+2},getPolylineTriangleCount:function(e){var t;if("number"==typeof e)t=e;else{t="number"!=typeof e[0]?e.length:e.length/3}return this.useNativeLine?0:2*Math.max(t-1,0)},addCubicCurve:function(e,t,r,n,i,a){null==a&&(a=1);for(var o=e[0],s=e[1],u=e[2],l=t[0],c=t[1],h=t[2],d=r[0],f=r[1],p=r[2],m=n[0],g=n[1],_=n[2],v=this._getCubicCurveApproxStep(e,t,r,n),y=v*v,x=y*v,T=3*v,b=3*y,w=6*y,E=6*x,S=o-2*l+d,A=s-2*c+f,M=u-2*h+p,C=3*(l-d)-o+m,L=3*(c-f)-s+g,D=3*(h-p)-u+_,N=o,R=s,P=u,I=(l-o)*T+S*b+C*x,O=(c-s)*T+A*b+L*x,F=(h-u)*T+M*b+D*x,B=S*w+C*E,z=A*w+L*E,U=M*w+D*E,G=C*E,H=L*E,V=D*E,k=0,W=0,j=Math.ceil(1/v),X=new Float32Array(3*(j+1)),X=[],q=0,W=0;W1&&(N=I>0?Math.min(N,m):Math.max(N,m),R=O>0?Math.min(R,g):Math.max(R,g),P=F>0?Math.min(P,_):Math.max(P,_));return this.addPolyline(X,i,a)},addLine:function(e,t,r,n){return this.addPolyline([e,t],r,n)},addPolyline:function(e,t,r,n,i){if(e.length){var a="number"!=typeof e[0];if(null==i&&(i=a?e.length:e.length/3),!(i<2)){null==n&&(n=0),null==r&&(r=1),this._itemVertexOffsets.push(this._vertexOffset);var o,s,a="number"!=typeof e[0],u=a?"number"!=typeof t[0]:t.length/4===i,l=this.attributes.position,c=this.attributes.positionPrev,h=this.attributes.positionNext,d=this.attributes.color,f=this.attributes.offset,p=this.indices,m=this._vertexOffset;r=Math.max(r,.01);for(var g=n;g1&&(l.copy(m,m-1),d.copy(m,m-1),m++):(g0&&(h.set(m-2,o),h.set(m-1,o)),l.set(m,o),l.set(m+1,o),d.set(m,s),d.set(m+1,s),f.set(m,r/2),f.set(m+1,-r/2),m+=2),this.useNativeLine)d.set(m,s),l.set(m,o),m++;else if(g>0){var y=3*this._triangleOffset,p=this.indices;p[y]=m-4,p[y+1]=m-3,p[y+2]=m-2,p[y+3]=m-3,p[y+4]=m-1,p[y+5]=m-2,this._triangleOffset+=2}}if(!this.useNativeLine){var x=this._vertexOffset,T=this._vertexOffset+2*i;c.copy(x,x+2),c.copy(x+1,x+3),h.copy(T-1,T-3),h.copy(T-2,T-4)}return this._vertexOffset=m,this._vertexOffset}}},setItemColor:function(e,t){for(var r=this._itemVertexOffsets[e],n=e1&&t.texParameterf(t.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===n){e.getGLExtension("OES_texture_half_float")||(n=a.a.FLOAT)}if(this.mipmaps.length)for(var o=this.width,s=this.height,u=0;u0)},getSkinMatricesTexture:function(){return this._skinMatricesTexture=this._skinMatricesTexture||new a.a({type:i.a.FLOAT,minFilter:i.a.NEAREST,magFilter:i.a.NEAREST,useMipmap:!1,flipY:!1}),this._skinMatricesTexture},clone:function(){var e=n.a.prototype.clone.call(this);return e.skeleton=this.skeleton,this.joints&&(e.joints=this.joints.slice()),e}});o.POINTS=i.a.POINTS,o.LINES=i.a.LINES,o.LINE_LOOP=i.a.LINE_LOOP,o.LINE_STRIP=i.a.LINE_STRIP,o.TRIANGLES=i.a.TRIANGLES,o.TRIANGLE_STRIP=i.a.TRIANGLE_STRIP,o.TRIANGLE_FAN=i.a.TRIANGLE_FAN,o.BACK=i.a.BACK,o.FRONT=i.a.FRONT,o.FRONT_AND_BACK=i.a.FRONT_AND_BACK,o.CW=i.a.CW,o.CCW=i.a.CCW,t.a=o},function(e,t,r){"use strict";function n(e){var t=[],r=Object.keys(e);r.sort();for(var n=0;n0&&console.warn("Found multiple camera in one scene. Use the fist one."),this._cameraList.push(e)):e instanceof s.a&&this.lights.push(e),e.name&&(this._nodeRepository[e.name]=e)},removeFromScene:function(e){var t;e instanceof u.a?(t=this._cameraList.indexOf(e))>=0&&this._cameraList.splice(t,1):e instanceof s.a&&(t=this.lights.indexOf(e))>=0&&this.lights.splice(t,1),e.name&&delete this._nodeRepository[e.name]},getNode:function(e){return this._nodeRepository[e]},setMainCamera:function(e){var t=this._cameraList.indexOf(e);t>=0&&this._cameraList.splice(t,1),this._cameraList.unshift(e)},getMainCamera:function(){return this._cameraList[0]},getLights:function(){return this.lights},updateLights:function(){var e=this.lights;this._previousLightNumber=this._lightNumber;for(var t={},r=0;r0&&this._doUpdateRenderList(a,t,r,n)}},isFrustumCulled:function(){var e=new l.a,t=new p.a;return function(r,n,i){var a=r.boundingBox||r.geometry.boundingBox;if(t.array=i,e.transformFrom(a,t),r.castShadow&&this.viewBoundingBoxLastFrame.union(e),r.frustumCulling&&!r.isSkinnedMesh()){if(!e.intersectBoundingBox(n.frustum.boundingBox))return!0;t.array=n.projectionMatrix.array,e.max.array[2]>0&&e.min.array[2]<0&&(e.max.array[2]=-1e-20),e.applyProjection(t);var o=e.min.array,s=e.max.array;if(s[0]<-1||o[0]>1||s[1]<-1||o[1]>1||s[2]<-1||o[2]>1)return!0}return!1}}(),_updateLightUniforms:function(){var e=this.lights;e.sort(a);var t=this._lightUniforms;for(var r in t)for(var n in t[r])t[r][n].value.length=0;for(var i=0;i0?e[t].value=new Float32Array(e[t].value):e[t].value=null;this.indices&&this.indices.length>0&&(this.indices=this.vertexCount>65535?new Uint32Array(this.indices):new Uint16Array(this.indices)),this.dirty()}}},function(e,t,r){"use strict";function n(e,t){var r=[];return a.a.util.each(e.dimensions,function(n){var i=e.getDimensionInfo(n),a=i.otherDims,o=a[t];null!=o&&!1!==o&&(r[o]=i.name)}),r}var i=r(0),a=r.n(i);t.a=function(e,t,r){var i=e.getData(),o=e.getRawValue(t),s=a.a.util.isArray(o)?function(e){function o(e,t){var n=i.getDimensionInfo(t);if(n&&!1!==n.otherDims.tooltip){var o=n.type,l=(s?"- "+(n.tooltipName||n.name)+": ":"")+("ordinal"===o?e+"":"time"===o?r?"":a.a.format.formatTime("yyyy/MM/dd hh:mm:ss",e):a.a.format.addCommas(e));l&&u.push(a.a.format.encodeHTML(l))}}var s=!0,u=[],l=n(i,"tooltip");return l.length?a.a.util.each(l,function(e){o(i.get(e,t),e)}):a.a.util.each(e,o),(s?"
":"")+u.join(s?"
":", ")}(o):a.a.format.encodeHTML(a.a.format.addCommas(o)),u=i.getName(t),l=i.getItemVisual(t,"color");a.a.util.isObject(l)&&l.colorStops&&(l=(l.colorStops[0]||{}).color),l=l||"transparent";var c=a.a.format.getTooltipMarker(l),h=e.name;return"\0-"===h&&(h=""),h=h?a.a.format.encodeHTML(h)+(r?": ":"
"):"",r?c+h+s:h+c+(u?a.a.format.encodeHTML(u)+": "+s:s)}},function(e,t,r){"use strict";var n=r(51),i=n.a.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var e=this.fov/180*Math.PI;this.projectionMatrix.perspective(e,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix.array,t=2*Math.atan(1/e[5]);this.fov=t/Math.PI*180,this.aspect=e[5]/e[0],this.near=e[14]/(e[10]-1),this.far=e[14]/(e[10]+1)},clone:function(){var e=n.a.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}});t.a=i},function(e,t,r){"use strict";var n=r(13),i=r(15),a=n.a.extend({dynamic:!1,widthSegments:1,heightSegments:1},function(){this.build()},{build:function(){for(var e=this.heightSegments,t=this.widthSegments,r=this.attributes,n=[],a=[],o=[],s=[],u=0;u<=e;u++)for(var l=u/e,c=0;c<=t;c++){var h=c/t;if(n.push([2*h-1,2*l-1,0]),a&&a.push([h,l]),o&&o.push([0,0,1]),c0&&this._notFirst?this.animateTo({alpha:c,beta:h,center:d,distance:a,targetOrthographicSize:o,easing:l.animationEasingUpdate,duration:l.animationDurationUpdate}):(this.setDistance(a),this.setAlpha(c),this.setBeta(h),this.setCenter(d),this.setOrthographicSize(o)),this._notFirst=!0,this._validateProperties()},_validateProperties:function(){},animateTo:function(e){var t=this.zr,r=this,n={},i={};return null!=e.distance&&(n.distance=this.getDistance(),i.distance=e.distance),null!=e.orthographicSize&&(n.orthographicSize=this.getOrthographicSize(),i.orthographicSize=e.orthographicSize),null!=e.alpha&&(n.alpha=this.getAlpha(),i.alpha=e.alpha),null!=e.beta&&(n.beta=this.getBeta(),i.beta=e.beta),null!=e.center&&(n.center=this.getCenter(),i.center=e.center),this._addAnimator(t.animation.animate(n).when(e.duration||1e3,i).during(function(){null!=n.alpha&&r.setAlpha(n.alpha),null!=n.beta&&r.setBeta(n.beta),null!=n.distance&&r.setDistance(n.distance),null!=n.center&&r.setCenter(n.center),null!=n.orthographicSize&&r.setOrthographicSize(n.orthographicSize),r._needsUpdate=!0})).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e0},_update:function(e){if(this._rotating){var t=("cw"===this.autoRotateDirection?1:-1)*this.autoRotateSpeed/180*Math.PI;this._phi-=t*e/1e3,this._needsUpdate=!0}else this._rotateVelocity.len()>0&&(this._needsUpdate=!0);(Math.abs(this._zoomSpeed)>.1||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(e=Math.min(e,50),this._updateDistanceOrSize(e),this._updatePan(e),this._updateRotate(e),this._updateTransform(),this.getCamera().update(),this.zr&&this.zr.refresh(),this.trigger("update"),this._needsUpdate=!1)},_updateRotate:function(e){var t=this._rotateVelocity;this._phi=t.y*e/20+this._phi,this._theta=t.x*e/20+this._theta,this.setAlpha(this.getAlpha()),this.setBeta(this.getBeta()),this._vectorDamping(t,Math.pow(this.damping,e/16))},_updateDistanceOrSize:function(e){"perspective"===this._projection?this._setDistance(this._distance+this._zoomSpeed*e/20):this._setOrthoSize(this._orthoSize+this._zoomSpeed*e/20),this._zoomSpeed*=Math.pow(this.damping,e/16)},_setDistance:function(e){this._distance=Math.max(Math.min(e,this.maxDistance),this.minDistance)},_setOrthoSize:function(e){this._orthoSize=Math.max(Math.min(e,this.maxOrthographicSize),this.minOrthographicSize);var t=this.getCamera(),r=this._orthoSize,n=r/this.viewGL.viewport.height*this.viewGL.viewport.width;t.left=-n/2,t.right=n/2,t.top=r/2,t.bottom=-r/2},_updatePan:function(e){var t=this._panVelocity,r=this._distance,n=this.getCamera(),i=n.worldTransform.y,a=n.worldTransform.x;this._center.scaleAndAdd(a,-t.x*r/200).scaleAndAdd(i,-t.y*r/200),this._vectorDamping(t,0)},_updateTransform:function(){var e=this.getCamera(),t=new o.a,r=this._theta+Math.PI/2,n=this._phi+Math.PI/2,i=Math.sin(r);t.x=i*Math.cos(n),t.y=-Math.cos(r),t.z=i*Math.sin(n),e.position.copy(this._center).scaleAndAdd(t,this._distance),e.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var e=this.autoRotateAfterStill,t=this;!isNaN(e)&&e>0&&(this._stillTimeout=setTimeout(function(){t._rotating=!0},1e3*e))},_vectorDamping:function(e,t){var r=e.len();r*=t,r<1e-4&&(r=0),e.normalize().scale(r)},_decomposeTransform:function(){if(this.getCamera()){this.getCamera().updateWorldTransform();var e=this.getCamera().worldTransform.z,t=Math.asin(e.y),r=Math.atan2(e.x,e.z);this._theta=t,this._phi=-r,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this.getCamera().aspect?this._setDistance(this.getCamera().position.dist(this._center)):this._setOrthoSize(this.getCamera().top-this.getCamera().bottom)}},_mouseDownHandler:function(e){if(!e.target&&!this._isAnimating()){var t=e.offsetX,r=e.offsetY;this.viewGL&&!this.viewGL.containPoint(t,r)||(this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler),e.event.targetTouches?1===e.event.targetTouches.length&&(this._mode="rotate"):e.event.button===l[this.rotateMouseButton]?this._mode="rotate":e.event.button===l[this.panMouseButton]?this._mode="pan":this._mode="",this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=e.offsetX,this._mouseY=e.offsetY)}},_mouseMoveHandler:function(e){if(!(e.target&&e.target.__isGLToZRProxy||this._isAnimating())){var t=n(this.panSensitivity),r=n(this.rotateSensitivity);"rotate"===this._mode?(this._rotateVelocity.y=(e.offsetX-this._mouseX)/this.zr.getHeight()*2*r[0],this._rotateVelocity.x=(e.offsetY-this._mouseY)/this.zr.getWidth()*2*r[1]):"pan"===this._mode&&(this._panVelocity.x=(e.offsetX-this._mouseX)/this.zr.getWidth()*t[0]*400,this._panVelocity.y=(-e.offsetY+this._mouseY)/this.zr.getHeight()*t[1]*400),this._mouseX=e.offsetX,this._mouseY=e.offsetY,e.event.preventDefault()}},_mouseWheelHandler:function(e){if(!this._isAnimating()){var t=e.event.wheelDelta||-e.event.detail;this._zoomHandler(e,t)}},_pinchHandler:function(e){this._isAnimating()||(this._zoomHandler(e,e.pinchScale>1?1:-1),this._mode="")},_zoomHandler:function(e,t){if(0!==t){var r=e.offsetX,n=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(r,n)){var i;i="perspective"===this._projection?Math.max(Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance))/20,.5):Math.max(Math.max(Math.min(this._orthoSize-this.minOrthographicSize,this.maxOrthographicSize-this._orthoSize))/20,.5),this._zoomSpeed=(t>0?-1:1)*i*this.zoomSensitivity,this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),e.event.preventDefault()}}},_mouseUpHandler:function(){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_isRightMouseButtonUsed:function(){return"right"===this.rotateMouseButton||"right"===this.panMouseButton},_contextMenuHandler:function(e){this._isRightMouseButtonUsed()&&e.preventDefault()},_addAnimator:function(e){var t=this._animators;return t.push(e),e.done(function(){var r=t.indexOf(e);r>=0&&t.splice(r,1)}),e}});Object.defineProperty(c.prototype,"autoRotate",{get:function(e){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}}),t.a=c},function(e,t,r){"use strict";t.a="@export ecgl.lines3D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n}\n@end\n\n\n\n@export ecgl.lines3D.clipNear\n\nvec4 clipNear(vec4 p1, vec4 p2) {\n float n = (p1.w - near) / (p1.w - p2.w);\n return vec4(mix(p1.xy, p2.xy, n), -near, near);\n}\n\n@end\n\n@export ecgl.lines3D.expandLine\n#ifdef VERTEX_ANIMATION\n vec4 prevProj = worldViewProjection * vec4(mix(prevPositionPrev, positionPrev, percent), 1.0);\n vec4 currProj = worldViewProjection * vec4(mix(prevPosition, position, percent), 1.0);\n vec4 nextProj = worldViewProjection * vec4(mix(prevPositionNext, positionNext, percent), 1.0);\n#else\n vec4 prevProj = worldViewProjection * vec4(positionPrev, 1.0);\n vec4 currProj = worldViewProjection * vec4(position, 1.0);\n vec4 nextProj = worldViewProjection * vec4(positionNext, 1.0);\n#endif\n\n if (currProj.w < 0.0) {\n if (nextProj.w > 0.0) {\n currProj = clipNear(currProj, nextProj);\n }\n else if (prevProj.w > 0.0) {\n currProj = clipNear(currProj, prevProj);\n }\n }\n\n vec2 prevScreen = (prevProj.xy / abs(prevProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 currScreen = (currProj.xy / abs(currProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 nextScreen = (nextProj.xy / abs(nextProj.w) + 1.0) * 0.5 * viewport.zw;\n\n vec2 dir;\n float len = offset;\n if (position == positionPrev) {\n dir = normalize(nextScreen - currScreen);\n }\n else if (position == positionNext) {\n dir = normalize(currScreen - prevScreen);\n }\n else {\n vec2 dirA = normalize(currScreen - prevScreen);\n vec2 dirB = normalize(nextScreen - currScreen);\n\n vec2 tanget = normalize(dirA + dirB);\n\n float miter = 1.0 / max(dot(tanget, dirA), 0.5);\n len *= miter;\n dir = tanget;\n }\n\n dir = vec2(-dir.y, dir.x) * len;\n currScreen += dir;\n\n currProj.xy = (currScreen / viewport.zw - 0.5) * 2.0 * abs(currProj.w);\n@end\n\n\n@export ecgl.meshLines3D.vertex\n\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevPositionPrev;\nattribute vec3 prevPositionNext;\nuniform float percent : 1.0;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n}\n@end\n\n\n@export ecgl.meshLines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"},function(e,t,r){function n(e,t,r,n,i){var a=0,o=0;null==n&&(n=1/0),null==i&&(i=1/0);var s=0;t.eachChild(function(u,l){var c,h,d=u.position,f=u.getBoundingRect(),p=t.childAt(l+1),m=p&&p.getBoundingRect();if("horizontal"===e){var g=f.width+(m?-m.x+f.x:0);c=a+g,c>n||u.newline?(a=0,c=g,o+=s+r,s=f.height):s=Math.max(s,f.height)}else{var _=f.height+(m?-m.y+f.y:0);h=o+_,h>i||u.newline?(a+=s+r,o=0,h=_,s=f.width):s=Math.max(s,f.width)}u.newline||(d[0]=a,d[1]=o,"horizontal"===e?a=c+r:o=h+r)})}function i(e,t,r){var n=t.width,i=t.height,a=p(e.x,n),o=p(e.y,i),s=p(e.x2,n),u=p(e.y2,i);return(isNaN(a)||isNaN(parseFloat(e.x)))&&(a=0),(isNaN(s)||isNaN(parseFloat(e.x2)))&&(s=n),(isNaN(o)||isNaN(parseFloat(e.y)))&&(o=0),(isNaN(u)||isNaN(parseFloat(e.y2)))&&(u=i),r=m.normalizeCssArray(r||0),{width:Math.max(s-a-r[1]-r[3],0),height:Math.max(u-o-r[0]-r[2],0)}}function a(e,t,r){r=m.normalizeCssArray(r||0);var n=t.width,i=t.height,a=p(e.left,n),o=p(e.top,i),s=p(e.right,n),u=p(e.bottom,i),l=p(e.width,n),c=p(e.height,i),h=r[2]+r[0],f=r[1]+r[3],g=e.aspect;switch(isNaN(l)&&(l=n-s-f-a),isNaN(c)&&(c=i-u-h-o),null!=g&&(isNaN(l)&&isNaN(c)&&(g>n/i?l=.8*n:c=.8*i),isNaN(l)&&(l=g*c),isNaN(c)&&(c=l/g)),isNaN(a)&&(a=n-s-l-f),isNaN(o)&&(o=i-u-c-h),e.left||e.right){case"center":a=n/2-l/2-r[3];break;case"right":a=n-l-f}switch(e.top||e.bottom){case"middle":case"center":o=i/2-c/2-r[0];break;case"bottom":o=i-c-h}a=a||0,o=o||0,isNaN(l)&&(l=n-f-a-(s||0)),isNaN(c)&&(c=i-h-o-(u||0));var _=new d(a+r[3],o+r[0],l,c);return _.margin=r,_}function o(e,t,r,n,i){var o=!i||!i.hv||i.hv[0],s=!i||!i.hv||i.hv[1],u=i&&i.boundingMode||"all";if(o||s){var l;if("raw"===u)l="group"===e.type?new d(0,0,+t.width||0,+t.height||0):e.getBoundingRect();else if(l=e.getBoundingRect(),e.needLocalTransform()){var c=e.getLocalTransform();l=l.clone(),l.applyTransform(c)}t=a(h.defaults({width:l.width,height:l.height},t),r,n);var f=e.position,p=o?t.x-l.x:0,m=s?t.y-l.y:0;e.attr("position","raw"===u?[p,m]:[f[0]+p,f[1]+m])}}function s(e,t){return null!=e[v[t][0]]||null!=e[v[t][1]]&&null!=e[v[t][2]]}function u(e,t,r){function n(r,n){var o={},u=0,l={},c=0;if(g(r,function(t){l[t]=e[t]}),g(r,function(e){i(t,e)&&(o[e]=l[e]=t[e]),a(o,e)&&u++,a(l,e)&&c++}),s[n])return a(t,r[1])?l[r[2]]=null:a(t,r[2])&&(l[r[1]]=null),l;if(2!==c&&u){if(u>=2)return o;for(var h=0;h0){var t=this.outputs[e];t.keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}}});t.a=i},function(e,t,r){"use strict";function n(e,t){for(var r=0,n=1/t,i=e;i>0;)r+=n*(i%t),i=Math.floor(i/t),n/=t;return r}t.a=n},function(e,t,r){"use strict";var n=r(0),i=r.n(n);t.a=function(e,t,r){r=r||e.getSource();var n=t||i.a.getCoordinateSystemDimensions(e.get("coordinateSystem"))||["x","y","z"],a=i.a.helper.createDimensions(r,{dimensionsDefine:r.dimensionsDefine||e.get("dimensions"),encodeDefine:r.encodeDefine||e.get("encode"),coordDimensions:n.map(function(t){var r=e.getReferringComponents(t+"Axis3D")[0];return{type:r&&"category"===r.get("type")?"ordinal":"float",name:t}})});"cartesian3D"===e.get("coordinateSystem")&&a.forEach(function(t){if(n.indexOf(t.coordDim)>=0){var r=e.getReferringComponents(t.coordDim+"Axis3D")[0];r&&"category"===r.get("type")&&(t.ordinalMeta=r.getOrdinalMeta())}});var o=i.a.helper.dataStack.enableDataStack(e,a,{byIndex:!0,stackedCoordDimension:"z"}),s=new i.a.List(a,e);return s.setCalculationInfo(o),s.initData(r),s}},function(e,t){function r(e,t,r){return{seriesType:e,performRawSeries:!0,reset:function(e,n,i){function a(t,r){if("function"==typeof u){var n=e.getRawValue(r),i=e.getDataParams(r);t.setItemVisual(r,"symbolSize",u(n,i))}if(t.hasItemOption){var a=t.getItemModel(r),o=a.getShallow("symbol",!0),s=a.getShallow("symbolSize",!0);null!=o&&t.setItemVisual(r,"symbol",o),null!=s&&t.setItemVisual(r,"symbolSize",s)}}var o=e.getData(),s=e.get("symbol")||t,u=e.get("symbolSize");if(o.setVisual({legendSymbol:r||s,symbol:s,symbolSize:u}),!n.isSeriesFiltered(e)){var l="function"==typeof u;return{dataEach:o.hasItemOption||l?a:null}}}}}e.exports=r},function(e,t,r){"use strict";function n(e){return e.material}function i(){}function a(e,t,r){this.availableAttributes=e,this.availableAttributeSymbols=t,this.indicesBuffer=r,this.vao=null}var o=r(9),s=r(104),u=r(11),l=(r(18),r(15),r(7),r(17)),c=r(23),h=r(107),d=r(8),f=r(109),p=r(65),m=r(1),g=r.n(m);d.a.import(f.a),d.a.import(p.a);var _=g.a.mat4,v=g.a.vec3,y=_.create,x={},T={float:u.a.FLOAT,byte:u.a.BYTE,ubyte:u.a.UNSIGNED_BYTE,short:u.a.SHORT,ushort:u.a.UNSIGNED_SHORT},b=o.a.extend(function(){return{canvas:null,_width:100,_height:100,devicePixelRatio:window&&window.devicePixelRatio||1,clearColor:[0,0,0,0],clearBit:17664,alpha:!0,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,throwError:!0,gl:null,viewport:{},__currentFrameBuffer:null,_viewportStack:[],_clearStack:[],_sceneRendering:null}},function(){this.canvas||(this.canvas=document.createElement("canvas"));var e=this.canvas;try{var t={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!this.gl)throw new Error;this._glinfo=new s.a(this.gl),this.gl.targetRenderer&&console.error("Already created a renderer"),this.gl.targetRenderer=this,this.resize()}catch(e){throw"Error creating WebGL Context "+e}this._programMgr=new h.a(this)},{resize:function(e,t){var r=this.canvas,n=this.devicePixelRatio;null!=e?(r.style.width=e+"px",r.style.height=t+"px",r.width=e*n,r.height=t*n,this._width=e,this._height=t):(this._width=r.width/n,this._height=r.height/n),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var e=this.viewport;return e.width/e.height},setDevicePixelRatio:function(e){this.devicePixelRatio=e,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getGLExtension:function(e){return this._glinfo.getExtension(e)},getGLParameter:function(e){return this._glinfo.getParameter(e)},setViewport:function(e,t,r,n,i){if("object"==typeof e){var a=e;e=a.x,t=a.y,r=a.width,n=a.height,i=a.devicePixelRatio}i=i||this.devicePixelRatio,this.gl.viewport(e*i,t*i,r*i,n*i),this.viewport={x:e,y:t,width:r,height:n,devicePixelRatio:i}},saveViewport:function(){this._viewportStack.push(this.viewport)},restoreViewport:function(){this._viewportStack.length>0&&this.setViewport(this._viewportStack.pop())},saveClear:function(){this._clearStack.push({clearBit:this.clearBit,clearColor:this.clearColor})},restoreClear:function(){if(this._clearStack.length>0){var e=this._clearStack.pop();this.clearColor=e.clearColor,this.clearBit=e.clearBit}},bindSceneRendering:function(e){this._sceneRendering=e},render:function(e,t,r,n){var i=this.gl,a=this.clearColor;if(this.clearBit){i.colorMask(!0,!0,!0,!0),i.depthMask(!0);var o=this.viewport,s=!1,u=o.devicePixelRatio;(o.width!==this._width||o.height!==this._height||u&&u!==this.devicePixelRatio||o.x||o.y)&&(s=!0,i.enable(i.SCISSOR_TEST),i.scissor(o.x*u,o.y*u,o.width*u,o.height*u)),i.clearColor(a[0],a[1],a[2],a[3]),i.clear(this.clearBit),s&&i.disable(i.SCISSOR_TEST)}if(r||e.update(!1),e.updateLights(),!(t=t||e.getMainCamera()))return void console.error("Can't find camera in the scene.");t.update();var l=e.updateRenderList(t);this._sceneRendering=e;var c=l.opaque,h=l.transparent,d=e.material;e.trigger("beforerender",this,e,t,l),n?(this.renderPreZ(c,e,t),i.depthFunc(i.LEQUAL)):i.depthFunc(i.LESS);for(var f=y(),p=v.create(),m=0;m0){var u=e[a-1],l=u.joints?u.joints.length:0;if((o.joints?o.joints.length:0)===l&&o.material===u.material&&o.lightGroup===u.lightGroup){o.__program=u.__program;continue}}var c=this._programMgr.getProgram(o,s,t);this.validateProgram(c),o.__program=c}},renderPass:function(e,t,r){this.trigger("beforerenderpass",this,e,t,r),r=r||{},r.getMaterial=r.getMaterial||n,r.beforeRender=r.beforeRender||i,r.afterRender=r.afterRender||i,this.updatePrograms(e,this._sceneRendering,r),r.sortCompare&&e.sort(r.sortCompare);var a=this.viewport,o=a.devicePixelRatio,s=[a.x*o,a.y*o,a.width*o,a.height*o],u=this.devicePixelRatio,l=this.__currentFrameBuffer?[this.__currentFrameBuffer.getTextureWidth(),this.__currentFrameBuffer.getTextureHeight()]:[this._width*u,this._height*u],c=[s[2],s[3]],h=Date.now();_.copy(w.VIEW,t.viewMatrix.array),_.copy(w.PROJECTION,t.projectionMatrix.array),_.multiply(w.VIEWPROJECTION,t.projectionMatrix.array,w.VIEW),_.copy(w.VIEWINVERSE,t.worldTransform.array),_.invert(w.PROJECTIONINVERSE,w.PROJECTION),_.invert(w.VIEWPROJECTIONINVERSE,w.VIEWPROJECTION);for(var d,f,p,m,g,v,y,x,T,b,E=this.gl,S=this._sceneRendering,A=this.getGLExtension("OES_vertex_array_object"),M=0;Mh)){var d=Math.sqrt(h-c),f=u-d,p=u+d;return i||(i=new n.a),f<0?p<0?null:(o.scaleAndAdd(i.array,a,s,p),i):(o.scaleAndAdd(i.array,a,s,f),i)}}}(),intersectBoundingBox:function(e,t){var r,i,a,s,u,l,c=this.direction.array,h=this.origin.array,d=e.min.array,f=e.max.array,p=1/c[0],m=1/c[1],g=1/c[2];if(p>=0?(r=(d[0]-h[0])*p,i=(f[0]-h[0])*p):(i=(d[0]-h[0])*p,r=(f[0]-h[0])*p),m>=0?(a=(d[1]-h[1])*m,s=(f[1]-h[1])*m):(s=(d[1]-h[1])*m,a=(f[1]-h[1])*m),r>s||a>i)return null;if((a>r||r!==r)&&(r=a),(s=0?(u=(d[2]-h[2])*g,l=(f[2]-h[2])*g):(l=(d[2]-h[2])*g,u=(f[2]-h[2])*g),r>l||u>i)return null;if((u>r||r!==r)&&(r=u),(l=0?r:i;return t||(t=new n.a),o.scaleAndAdd(t.array,h,c,_),t},intersectTriangle:function(){var e=o.create(),t=o.create(),r=o.create(),i=o.create();return function(a,s,u,l,c,h){var d=this.direction.array,f=this.origin.array;a=a.array,s=s.array,u=u.array,o.sub(e,s,a),o.sub(t,u,a),o.cross(i,t,d);var p=o.dot(e,i);if(l){if(p>-1e-5)return null}else if(p>-1e-5&&p<1e-5)return null;o.sub(r,f,a);var m=o.dot(i,r)/p;if(m<0||m>1)return null;o.cross(i,e,r);var g=o.dot(d,i)/p;if(g<0||g>1||m+g>1)return null;o.cross(i,e,t);var _=-o.dot(r,i)/p;return _<0?null:(c||(c=new n.a),h&&n.a.set(h,1-m-g,m,g),o.scaleAndAdd(c.array,f,d,_),c)}}(),applyTransform:function(e){n.a.add(this.direction,this.direction,this.origin),n.a.transformMat4(this.origin,this.origin,e),n.a.transformMat4(this.direction,this.direction,e),n.a.sub(this.direction,this.direction,this.origin),n.a.normalize(this.direction,this.direction)},copy:function(e){n.a.copy(this.origin,e.origin),n.a.copy(this.direction,e.direction)},clone:function(){var e=new s;return e.copy(this),e}},t.a=s},function(e,t,r){"use strict";var n=r(1),i=r.n(n),a=i.a.quat,o=function(e,t,r,n){e=e||0,t=t||0,r=r||0,n=void 0===n?1:n,this.array=a.fromValues(e,t,r,n),this._dirty=!0};o.prototype={constructor:o,add:function(e){return a.add(this.array,this.array,e.array),this._dirty=!0,this},calculateW:function(){return a.calculateW(this.array,this.array),this._dirty=!0,this},set:function(e,t,r,n){return this.array[0]=e,this.array[1]=t,this.array[2]=r,this.array[3]=n,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this.array[3]=e[3],this._dirty=!0,this},clone:function(){return new o(this.x,this.y,this.z,this.w)},conjugate:function(){return a.conjugate(this.array,this.array),this._dirty=!0,this},copy:function(e){return a.copy(this.array,e.array),this._dirty=!0,this},dot:function(e){return a.dot(this.array,e.array)},fromMat3:function(e){return a.fromMat3(this.array,e.array),this._dirty=!0,this},fromMat4:function(){var e=i.a.mat3,t=e.create();return function(r){return e.fromMat4(t,r.array),e.transpose(t,t),a.fromMat3(this.array,t),this._dirty=!0,this}}(),identity:function(){return a.identity(this.array),this._dirty=!0,this},invert:function(){return a.invert(this.array,this.array),this._dirty=!0,this},len:function(){return a.len(this.array)},length:function(){return a.length(this.array)},lerp:function(e,t,r){return a.lerp(this.array,e.array,t.array,r),this._dirty=!0,this},mul:function(e){return a.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return a.multiply(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return a.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return a.multiply(this.array,e.array,this.array),this._dirty=!0,this},normalize:function(){return a.normalize(this.array,this.array),this._dirty=!0,this},rotateX:function(e){return a.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return a.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return a.rotateZ(this.array,this.array,e),this._dirty=!0,this},rotationTo:function(e,t){return a.rotationTo(this.array,e.array,t.array),this._dirty=!0,this},setAxes:function(e,t,r){return a.setAxes(this.array,e.array,t.array,r.array),this._dirty=!0,this},setAxisAngle:function(e,t){return a.setAxisAngle(this.array,e.array,t),this._dirty=!0,this},slerp:function(e,t,r){return a.slerp(this.array,e.array,t.array,r),this._dirty=!0,this},sqrLen:function(){return a.sqrLen(this.array)},squaredLength:function(){return a.squaredLength(this.array)},fromEuler:function(e,t){return o.fromEuler(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var s=Object.defineProperty;if(s){var u=o.prototype;s(u,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),s(u,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),s(u,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),s(u,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}o.add=function(e,t,r){return a.add(e.array,t.array,r.array),e._dirty=!0,e},o.set=function(e,t,r,n,i){a.set(e.array,t,r,n,i),e._dirty=!0},o.copy=function(e,t){return a.copy(e.array,t.array),e._dirty=!0,e},o.calculateW=function(e,t){return a.calculateW(e.array,t.array),e._dirty=!0,e},o.conjugate=function(e,t){return a.conjugate(e.array,t.array),e._dirty=!0,e},o.identity=function(e){return a.identity(e.array),e._dirty=!0,e},o.invert=function(e,t){return a.invert(e.array,t.array),e._dirty=!0,e},o.dot=function(e,t){return a.dot(e.array,t.array)},o.len=function(e){return a.length(e.array)},o.lerp=function(e,t,r,n){return a.lerp(e.array,t.array,r.array,n),e._dirty=!0,e},o.slerp=function(e,t,r,n){return a.slerp(e.array,t.array,r.array,n),e._dirty=!0,e},o.mul=function(e,t,r){return a.multiply(e.array,t.array,r.array),e._dirty=!0,e},o.multiply=o.mul,o.rotateX=function(e,t,r){return a.rotateX(e.array,t.array,r),e._dirty=!0,e},o.rotateY=function(e,t,r){return a.rotateY(e.array,t.array,r),e._dirty=!0,e},o.rotateZ=function(e,t,r){return a.rotateZ(e.array,t.array,r),e._dirty=!0,e},o.setAxisAngle=function(e,t,r){return a.setAxisAngle(e.array,t.array,r),e._dirty=!0,e},o.normalize=function(e,t){return a.normalize(e.array,t.array),e._dirty=!0,e},o.sqrLen=function(e){return a.sqrLen(e.array)},o.squaredLength=o.sqrLen,o.fromMat3=function(e,t){return a.fromMat3(e.array,t.array),e._dirty=!0,e},o.setAxes=function(e,t,r,n){return a.setAxes(e.array,t.array,r.array,n.array),e._dirty=!0,e},o.rotationTo=function(e,t,r){return a.rotationTo(e.array,t.array,r.array),e._dirty=!0,e},o.fromEuler=function(e,t,r){e._dirty=!0,t=t.array;var n=e.array,i=Math.cos(t[0]/2),a=Math.cos(t[1]/2),o=Math.cos(t[2]/2),s=Math.sin(t[0]/2),u=Math.sin(t[1]/2),l=Math.sin(t[2]/2),r=(r||"XYZ").toUpperCase();switch(r){case"XYZ":n[0]=s*a*o+i*u*l,n[1]=i*u*o-s*a*l,n[2]=i*a*l+s*u*o,n[3]=i*a*o-s*u*l;break;case"YXZ":n[0]=s*a*o+i*u*l,n[1]=i*u*o-s*a*l,n[2]=i*a*l-s*u*o,n[3]=i*a*o+s*u*l;break;case"ZXY":n[0]=s*a*o-i*u*l,n[1]=i*u*o+s*a*l,n[2]=i*a*l+s*u*o,n[3]=i*a*o-s*u*l;break;case"ZYX":n[0]=s*a*o-i*u*l,n[1]=i*u*o+s*a*l,n[2]=i*a*l-s*u*o,n[3]=i*a*o+s*u*l;break;case"YZX":n[0]=s*a*o+i*u*l,n[1]=i*u*o+s*a*l,n[2]=i*a*l-s*u*o,n[3]=i*a*o-s*u*l;break;case"XZY":n[0]=s*a*o-i*u*l,n[1]=i*u*o-s*a*l,n[2]=i*a*l+s*u*o,n[3]=i*a*o+s*u*l}},t.a=o},function(e,t,r){"use strict";var n=r(30),i=r(7),a=r(52),o=r(49),s=r(1),u=r.n(s),l=u.a.vec3,c=u.a.vec4,h=n.a.extend(function(){return{projectionMatrix:new i.a,invProjectionMatrix:new i.a,viewMatrix:new i.a,frustum:new a.a}},function(){this.update(!0)},{update:function(e){n.a.prototype.update.call(this,e),i.a.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),i.a.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(e){i.a.copy(this.viewMatrix,e),i.a.invert(this.worldTransform,e),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(e){i.a.copy(this.projectionMatrix,e),i.a.invert(this.invProjectionMatrix,e),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:function(){var e=c.create();return function(t,r){var n=void 0!==r?r:new o.a,i=t.array[0],a=t.array[1];return c.set(e,i,a,-1,1),c.transformMat4(e,e,this.invProjectionMatrix.array),c.transformMat4(e,e,this.worldTransform.array),l.scale(n.origin.array,e,1/e[3]),c.set(e,i,a,1,1),c.transformMat4(e,e,this.invProjectionMatrix.array),c.transformMat4(e,e,this.worldTransform.array),l.scale(e,e,1/e[3]),l.sub(n.direction.array,e,n.origin.array),l.normalize(n.direction.array,n.direction.array),n.direction._dirty=!0,n.origin._dirty=!0,n}}()});t.a=h},function(e,t,r){"use strict";var n=(r(4),r(15)),i=r(68),a=r(1),o=r.n(a),s=o.a.vec3,u=s.set,l=s.copy,c=s.transformMat4,h=Math.min,d=Math.max,f=function(){this.planes=[];for(var e=0;e<6;e++)this.planes.push(new i.a);this.boundingBox=new n.a,this.vertices=[];for(var e=0;e<8;e++)this.vertices[e]=s.fromValues(0,0,0)};f.prototype={setFromProjection:function(e){var t=this.planes,r=e.array,n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],l=r[5],c=r[6],h=r[7],d=r[8],f=r[9],p=r[10],m=r[11],g=r[12],_=r[13],v=r[14],y=r[15];u(t[0].normal.array,o-n,h-s,m-d),t[0].distance=-(y-g),t[0].normalize(),u(t[1].normal.array,o+n,h+s,m+d),t[1].distance=-(y+g),t[1].normalize(),u(t[2].normal.array,o+i,h+l,m+f),t[2].distance=-(y+_),t[2].normalize(),u(t[3].normal.array,o-i,h-l,m-f),t[3].distance=-(y-_),t[3].normalize(),u(t[4].normal.array,o-a,h-c,m-p),t[4].distance=-(y-v),t[4].normalize(),u(t[5].normal.array,o+a,h+c,m+p),t[5].distance=-(y+v),t[5].normalize();var x=this.boundingBox,T=this.vertices;if(0===y){var b=l/n,w=-v/(p-1),E=-v/(p+1),S=-E/l,A=-w/l;x.min.set(-S*b,-S,E),x.max.set(S*b,S,w),u(T[0],-S*b,-S,E),u(T[1],-S*b,S,E),u(T[2],S*b,-S,E),u(T[3],S*b,S,E),u(T[4],-A*b,-A,w),u(T[5],-A*b,A,w),u(T[6],A*b,-A,w),u(T[7],A*b,A,w)}else{var M=(-1-g)/n,C=(1-g)/n,L=(1-_)/l,D=(-1-_)/l,N=(-1-v)/p,R=(1-v)/p;x.min.set(Math.min(M,C),Math.min(D,L),Math.min(R,N)),x.max.set(Math.max(C,M),Math.max(L,D),Math.max(N,R));var P=x.min.array,I=x.max.array;u(T[0],P[0],P[1],P[2]),u(T[1],P[0],I[1],P[2]),u(T[2],I[0],P[1],P[2]),u(T[3],I[0],I[1],P[2]),u(T[4],P[0],P[1],I[2]),u(T[5],P[0],I[1],I[2]),u(T[6],I[0],P[1],I[2]),u(T[7],I[0],I[1],I[2])}},getTransformedBoundingBox:function(){var e=s.create();return function(t,r){var n=this.vertices,i=r.array,a=t.min,o=t.max,s=a.array,u=o.array,f=n[0];c(e,f,i),l(s,e),l(u,e);for(var p=1;p<8;p++)f=n[p],c(e,f,i),s[0]=h(e[0],s[0]),s[1]=h(e[1],s[1]),s[2]=h(e[2],s[2]),u[0]=d(e[0],u[0]),u[1]=d(e[1],u[1]),u[2]=d(e[2],u[2]);return a._dirty=!0,o._dirty=!0,t}}()},t.a=f},function(e,t){var r=function(){this.head=null,this.tail=null,this._len=0},n=r.prototype;n.insert=function(e){var t=new i(e);return this.insertEntry(t),t},n.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,e.next=null,this.tail=e):this.head=this.tail=e,this._len++},n.remove=function(e){var t=e.prev,r=e.next;t?t.next=r:this.head=r,r?r.prev=t:this.tail=t,e.next=e.prev=null,this._len--},n.len=function(){return this._len},n.clear=function(){this.head=this.tail=null,this._len=0};var i=function(e){this.value=e,this.next,this.prev},a=function(e){this._list=new r,this._map={},this._maxSize=e||10,this._lastRemovedEntry=null},o=a.prototype;o.put=function(e,t){var r=this._list,n=this._map,a=null;if(null==n[e]){var o=r.len(),s=this._lastRemovedEntry;if(o>=this._maxSize&&o>0){var u=r.head;r.remove(u),delete n[u.key],a=u.value,this._lastRemovedEntry=u}s?s.value=t:s=new i(t),s.key=e,r.insertEntry(s),n[e]=s}return a},o.get=function(e){var t=this._map[e],r=this._list;if(null!=t)return t!==r.tail&&(r.remove(t),r.insertEntry(t)),t.value},o.clear=function(){this._list.clear(),this._map={}};var s=a;e.exports=s},function(e,t,r){"use strict";var n=r(5),i=r(24),a=r(112),o=r(55),s=r(56),u=r(32),l=r(114),c=r(115),h={loadTexture:function(e,t,r,a){var o;if("function"==typeof t?(r=t,a=r,t={}):t=t||{},"string"==typeof e){if(e.match(/.hdr$/)||"hdr"===t.fileType)return o=new n.a({width:0,height:0,sRGB:!1}),h._fetchTexture(e,function(e){c.a.parseRGBE(e,o,t.exposure),o.dirty(),r&&r(o)},a),o;e.match(/.dds$/)||"dds"===t.fileType?(o=new n.a({width:0,height:0}),h._fetchTexture(e,function(e){l.a.parse(e,o),o.dirty(),r&&r(o)},a)):(o=new n.a,o.load(e),o.success(r),o.error(a))}else"object"==typeof e&&void 0!==e.px&&(o=new i.a,o.load(e),o.success(r),o.error(a));return o},loadPanorama:function(e,t,r,n,i,a){var o=this;"function"==typeof n?(i=n,a=i,n={}):n=n||{},h.loadTexture(t,n,function(t){t.flipY=n.flipY||!1,o.panoramaToCubeMap(e,t,r,n),t.dispose(e),i&&i(r)},a)},panoramaToCubeMap:function(e,t,r,n){var i=new o.a,a=new s.a({scene:new u.a});return a.setEnvironmentMap(t),n=n||{},n.encodeRGBM&&a.material.define("fragment","RGBM_ENCODE"),r.sRGB=t.sRGB,i.texture=r,i.render(e,a.scene),i.texture=null,i.dispose(e),r},heightToNormal:function(e,t){var r=document.createElement("canvas"),n=r.width=e.width,i=r.height=e.height,a=r.getContext("2d");a.drawImage(e,0,0,n,i),t=t||!1;for(var o=a.getImageData(0,0,n,i),s=a.createImageData(n,i),u=0;u20)return console.warn("Given image is not a height map"),e}var d,f,p,m;u%(4*n)==0?(d=o.data[u],p=o.data[u+4]):u%(4*n)==4*(n-1)?(d=o.data[u-4],p=o.data[u]):(d=o.data[u-4],p=o.data[u+4]),u<4*n?(f=o.data[u],m=o.data[u+4*n]):u>n*(i-1)*4?(f=o.data[u-4*n],m=o.data[u]):(f=o.data[u-4*n],m=o.data[u+4*n]),s.data[u]=d-p+127,s.data[u+1]=f-m+127,s.data[u+2]=255,s.data[u+3]=255}return a.putImageData(s,0,0),r},isHeightImage:function(e,t,r){if(!e||!e.width||!e.height)return!1;var n=document.createElement("canvas"),i=n.getContext("2d"),a=t||32;r=r||20,n.width=n.height=a,i.drawImage(e,0,0,a,a);for(var o=i.getImageData(0,0,a,a),s=0;sr)return!1}return!0},_fetchTexture:function(e,t,r){a.a.get({url:e,responseType:"arraybuffer",onload:t,onerror:r})},createChessboard:function(e,t,r,i){e=e||512,t=t||64,r=r||"black",i=i||"white";var a=Math.ceil(e/t),o=document.createElement("canvas");o.width=e,o.height=e;var s=o.getContext("2d");s.fillStyle=i,s.fillRect(0,0,e,e),s.fillStyle=r;for(var u=0;u0?this.material.define("fragment","LOD"):this.material.undefine("fragment","LOD"),e.renderPass([this],t)}});t.a=u},function(e,t,r){"use strict";var n=r(2),i=r(156),a=r(157);n.a.Shader.import(a.a),t.a=n.a.Mesh.extend(function(){return{geometry:new i.a({dynamic:!0}),material:new n.a.Material({shader:n.a.createShader("ecgl.labels"),transparent:!0,depthMask:!1}),culling:!1,castShadow:!1,ignorePicking:!0}})},function(e,t,r){"use strict";function n(e){this.rootNode=new o.a.Node,this._triangulationResults={},this._shadersMap=o.a.COMMON_SHADERS.reduce(function(e,t){return e[t]=o.a.createShader("ecgl."+t),e},{}),this._linesShader=o.a.createShader("ecgl.meshLines3D");var t={};o.a.COMMON_SHADERS.forEach(function(e){t[e]=new o.a.Material({shader:o.a.createShader("ecgl."+e)})}),this._groundMaterials=t,this._groundMesh=new o.a.Mesh({geometry:new o.a.PlaneGeometry({dynamic:!0}),castShadow:!1,renderNormal:!0,$ignorePicking:!0}),this._groundMesh.rotation.rotateX(-Math.PI/2),this._labelsBuilder=new f.a(512,512,e),this._labelsBuilder.getMesh().renderOrder=100,this._labelsBuilder.getMesh().material.depthTest=!1,this.rootNode.add(this._labelsBuilder.getMesh()),this._initMeshes(),this._api=e}var i=r(0),a=r.n(i),o=r(2),s=r(196),u=r(22),l=r(3),c=r(1),h=r.n(c),d=r(60),f=r(61),p=r(40),m=h.a.vec3;o.a.Shader.import(p.a),n.prototype={constructor:n,extrudeY:!0,update:function(e,t,r,n,i){var a=e.getData();null==n&&(n=0),null==i&&(i=a.count()),this._startIndex=n,this._endIndex=i-1,this._triangulation(e,n,i);var o=this._getShader(e.get("shading"));this._prepareMesh(e,o,r,n,i),this.rootNode.updateWorldTransform(),this._updateRegionMesh(e,r,n,i);var s=e.coordinateSystem;"geo3D"===s.type&&this._updateGroundPlane(e,s,r);var u=this;this._labelsBuilder.updateData(a,n,i),this._labelsBuilder.getLabelPosition=function(e,t,r){var n,i=a.getName(e),o=r;if("geo3D"===s.type){var l=s.getRegion(i);if(!l)return[NaN,NaN,NaN];n=l.center;return s.dataToPoint([n[0],n[1],o])}var c=u._triangulationResults[e-u._startIndex],n=u.extrudeY?[(c.max[0]+c.min[0])/2,c.max[1]+o,(c.max[2]+c.min[2])/2]:[(c.max[0]+c.min[0])/2,(c.max[1]+c.min[1])/2,c.max[2]+o]},this._data=a,this._labelsBuilder.updateLabels(),this._updateDebugWireframe(e),this._lastHoverDataIndex=0},_initMeshes:function(){var e=this,t=function(){var t=new o.a.Mesh({name:"Polygon",material:new o.a.Material({shader:e._shadersMap.lambert}),geometry:new o.a.Geometry({sortTriangles:!0,dynamic:!0}),culling:!1,ignorePicking:!0,renderNormal:!0});return a.a.util.extend(t.geometry,d.a),t}(),r=new o.a.Mesh({material:new o.a.Material({shader:this._linesShader}),castShadow:!1,ignorePicking:!0,$ignorePicking:!0,geometry:new u.a({useNativeLine:!1})});this.rootNode.add(t),this.rootNode.add(r),t.material.define("both","VERTEX_COLOR"),t.material.define("fragment","DOUBLE_SIDED"),this._polygonMesh=t,this._linesMesh=r,this.rootNode.add(this._groundMesh)},_getShader:function(e){var t=this._shadersMap[e];return t||(t=this._shadersMap.lambert),t.__shading=e,t},_prepareMesh:function(e,t,r,n,i){for(var a=0,s=0,u=0,l=0,c=n;c65535?new Uint32Array(3*s):new Uint16Array(3*s),f.material.shader!==t&&f.material.attachShader(t,!0),o.a.setMaterialFromModel(t.__shading,f.material,e,r),u>0&&(this._linesMesh.geometry.resetOffset(),this._linesMesh.geometry.setVertexCount(u),this._linesMesh.geometry.setTriangleCount(l)),this._dataIndexOfVertex=new Uint32Array(a),this._vertexRangeOfDataIndex=new Uint32Array(2*(i-n))},_updateRegionMesh:function(e,t,r,n){for(var i=e.getData(),a=0,s=0,u=!1,c=this._polygonMesh,h=this._linesMesh,d=r;d0;E&&(w*=t.getDevicePixelRatio(),this._updateLinesGeometry(h.geometry,e,d,x,w,e.coordinateSystem.transform)),h.invisible=!E,h.material.set({color:v})}var c=this._polygonMesh;c.material.transparent=u,c.material.depthMask=!u,c.geometry.updateBoundingBox(),c.frontFace=this.extrudeY?o.a.Mesh.CCW:o.a.Mesh.CW,c.material.get("normalMap")&&c.geometry.generateTangents(),c.seriesIndex=e.seriesIndex,c.on("mousemove",this._onmousemove,this),c.on("mouseout",this._onmouseout,this)},_updateDebugWireframe:function(e){var t=e.getModel("debug.wireframe");if(t.get("show")){var r=o.a.parseColor(t.get("lineStyle.color")||"rgba(0,0,0,0.5)"),n=l.a.firstNotNull(t.get("lineStyle.width"),1),i=this._polygonMesh;i.geometry.generateBarycentric(),i.material.define("both","WIREFRAME_TRIANGLE"),i.material.set("wireframeLineColor",r),i.material.set("wireframeLineWidth",n)}},_onmousemove:function(e){var t=this._dataIndexOfVertex[e.triangle[0]];null==t&&(t=-1),t!==this._lastHoverDataIndex&&(this.downplay(this._lastHoverDataIndex),this.highlight(t),this._labelsBuilder.updateLabels([t])),this._lastHoverDataIndex=t,this._polygonMesh.dataIndex=t},_onmouseout:function(e){e.target&&(this.downplay(this._lastHoverDataIndex),this._lastHoverDataIndex=-1,this._polygonMesh.dataIndex=-1),this._labelsBuilder.updateLabels([])},_updateGroundPlane:function(e,t,r){var n=e.getModel("groundPlane",e);if(this._groundMesh.invisible=!n.get("show",!0),!this._groundMesh.invisible){var i=e.get("shading"),a=this._groundMaterials[i];a||(a=this._groundMaterials.lambert),o.a.setMaterialFromModel(i,a,n,r),a.get("normalMap")&&this._groundMesh.geometry.generateTangents(),this._groundMesh.material=a,this._groundMesh.material.set("color",o.a.parseColor(n.get("color"))),this._groundMesh.scale.set(t.size[0],t.size[2],1)}},_triangulation:function(e,t,r){this._triangulationResults=[];for(var n=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0],a=e.coordinateSystem,o=t;o1?n:0,R[V][y]=C.points[W+2],c.set(i+V,R[V]),l?(F[0]=(C.points[W]*x[0]-T[0])/w,F[1]=(C.points[W+2]*x[y]-T[y])/w):(F[0]=(k?B:B+H)/w,F[1]=(R[V][v]*x[v]-T[v])/w),d.set(i+V,F)}m.sub(P,R[1],R[0]),m.sub(I,R[3],R[0]),m.cross(O,P,I),m.normalize(O,O);for(var V=0;V<4;V++)h.set(i+V,O),g&&f.set(i+V,o);for(var V=0;V<6;V++)_[3*a+V]=N[V]+i;i+=4,a+=2,B+=H}}return t.dirty(),{vertexOffset:i,triangleOffset:a}},_getRegionLinesInfo:function(e,t,r){var n=0,i=0;t.getRegionModel(e).getModel("itemStyle").get("borderWidth")>0&&t.getRegionPolygonCoords(e).forEach(function(e){var t=e.exterior,a=e.interiors;n+=r.getPolylineVertexCount(t),i+=r.getPolylineTriangleCount(t);for(var o=0;othis._endIndex)){t-=this._startIndex;for(var n=this._vertexRangeOfDataIndex[2*t];n=2e4},doSortTriangles:function(e,t){var r=this.indices;if(0===t){var n=this.attributes.position,e=e.array;this._triangleZList&&this._triangleZList.length===this.triangleCount||(this._triangleZList=new Float32Array(this.triangleCount),this._sortedTriangleIndices=new Uint32Array(this.triangleCount),this._indicesTmp=new r.constructor(r.length),this._triangleZListTmp=new Float32Array(this.triangleCount));for(var i,a=0,c=0;c0,r={},n=0;n2?(g=this._updateSymbolSprite(e,p,d,f),u.enableTexture("sprite")):u.disableTexture("sprite"),h.position.init(i-n);var _=[];if(m){u.undefine("VERTEX_SIZE"),u.undefine("VERTEX_COLOR");var v=o.getVisual("color"),y=o.getVisual("opacity");s.a.parseColor(v,_),_[3]*=y,u.set({color:_,u_Size:d.maxSize*this._sizeScale})}else u.set({color:[1,1,1,1]}),u.define("VERTEX_SIZE"),u.define("VERTEX_COLOR"),h.size.init(i-n),h.color.init(i-n),this._originalOpacity=new Float32Array(i-n);for(var x=o.getLayout("points"),T=h.position.value,b=0;b1?(a[0]=r.maxSize,a[1]=r.maxSize/r.aspect):(a[1]=r.maxSize,a[0]=r.maxSize*r.aspect),a[0]=a[0]||1,a[1]=a[1]||1,this._symbolType===r.type&&n(this._symbolSize,a)&&this._lineWidth===t.lineWidth||(u.a.createSymbolSprite(r.type,a,{fill:"#fff",lineWidth:t.lineWidth,stroke:"transparent",shadowColor:"transparent",minMargin:Math.min(a[0]/2,10)},this._spriteImageCanvas),u.a.createSDFFromCanvas(this._spriteImageCanvas,Math.min(this._spriteImageCanvas.width,32),20,this._mesh.material.get("sprite").image),this._symbolType=r.type,this._symbolSize=a,this._lineWidth=t.lineWidth),this._spriteImageCanvas.width/r.maxSize*i},_updateMaterial:function(e,t){var r="lighter"===e.get("blendMode")?s.a.additiveBlend:null,n=this._mesh.material;n.blend=r,n.set("lineWidth",t.lineWidth/20);var i=s.a.parseColor(t.stroke);n.set("strokeColor",i),n.transparent=!0,n.depthMask=!1,n.depthTest=!this.is2D,n.sortVertices=!this.is2D},_updateLabelBuilder:function(e,t,r){var n=e.getData(),i=this._mesh.geometry,a=i.attributes.position.value,t=this._startDataIndex,o=this._mesh.sizeScale;this._labelsBuilder.updateData(n,t,r),this._labelsBuilder.getLabelPosition=function(e,r,n){var i=3*(e-t);return[a[i],a[i+1],a[i+2]]},this._labelsBuilder.getLabelDistance=function(e,r,n){return i.attributes.size.get(e-t)/o/2+n},this._labelsBuilder.updateLabels()},_updateAnimation:function(e){s.a.updateVertexAnimation([["prevPosition","position"],["prevSize","size"]],this._prevMesh,this._mesh,e)},_updateHandler:function(e,t,r){var n,i=e.getData(),a=this._mesh,o=this,s=-1,u=e.coordinateSystem&&"cartesian3D"===e.coordinateSystem.type;u&&(n=e.coordinateSystem.model),a.seriesIndex=e.seriesIndex,a.off("mousemove"),a.off("mouseout"),a.on("mousemove",function(t){var l=t.vertexIndex+o._startDataIndex;l!==s&&(this.highlightOnMouseover&&(this.downplay(i,s),this.highlight(i,l),this._labelsBuilder.updateLabels([l])),u&&r.dispatchAction({type:"grid3DShowAxisPointer",value:[i.get(e.coordDimToDataDim("x")[0],l),i.get(e.coordDimToDataDim("y")[0],l),i.get(e.coordDimToDataDim("z")[0],l)],grid3DIndex:n.componentIndex})),a.dataIndex=l,s=l},this),a.on("mouseout",function(e){var t=e.vertexIndex+o._startDataIndex;this.highlightOnMouseover&&(this.downplay(i,t),this._labelsBuilder.updateLabels()),s=-1,a.dataIndex=-1,u&&r.dispatchAction({type:"grid3DHideAxisPointer",grid3DIndex:n.componentIndex})},this)},updateLayout:function(e,t,r){var n=e.getData();if(this._mesh){var i=this._mesh.geometry.attributes.position.value,a=n.getLayout("points");if(this.is2D)for(var o=0;othis._endDataIndex||tthis._endDataIndex||t=this._maxSize&&r>0){var n=this._list.head;this._list.remove(n),delete this._map[n.key]}var i=this._list.insert(t);i.key=e,this._map[e]=i}},i.prototype.get=function(e){var t=this._map[e];if(void 0!==t)return t!==this._list.tail&&(this._list.remove(t),this._list.insertEntry(t)),t.value},i.prototype.remove=function(e){var t=this._map[e];void 0!==t&&(delete this._map[e],this._list.remove(t))},i.prototype.clear=function(){this._list.clear(),this._map={}},t.a=i},function(e,t,r){"use strict";t.a="@export clay.prez.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\n@import clay.chunk.skinning_header\nvoid main()\n{\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n}\n@end\n@export clay.prez.fragment\nvoid main()\n{\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n@end"},function(e,t,r){"use strict";var n=r(30),i=r(11),a=n.a.extend({material:null,geometry:null,mode:i.a.TRIANGLES,_renderInfo:null},{__program:null,lightGroup:0,renderOrder:0,culling:!0,cullFace:i.a.BACK,frontFace:i.a.CCW,frustumCulling:!0,receiveShadow:!0,castShadow:!0,ignorePicking:!1,ignorePreZ:!1,ignoreGBuffer:!1,isRenderable:function(){return this.geometry&&this.material&&this.material.shader&&!this.invisible&&this.geometry.vertexCount>0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=n.a.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},clone:function(){var e=["castShadow","receiveShadow","mode","culling","cullFace","frontFace","frustumCulling","renderOrder","lineWidth","ignorePicking","ignorePreZ","ignoreGBuffer"];return function(){var t=n.a.prototype.clone.call(this);t.geometry=this.geometry,t.material=this.material;for(var r=0;r>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},n.nearestPowerOfTwo=function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))},t.a=n},function(e,t,r){"use strict";var n=r(4),i=r(1),a=r.n(i),o=a.a.vec3,s=a.a.mat4,u=a.a.vec4,l=function(e,t){this.normal=e||new n.a(0,1,0),this.distance=t||0};l.prototype={constructor:l,distanceToPoint:function(e){return o.dot(e.array,this.normal.array)-this.distance},projectPoint:function(e,t){t||(t=new n.a);var r=this.distanceToPoint(e);return o.scaleAndAdd(t.array,e.array,this.normal.array,-r),t._dirty=!0,t},normalize:function(){var e=1/o.len(this.normal.array);o.scale(this.normal.array,e),this.distance*=e},intersectFrustum:function(e){for(var t=e.vertices,r=this.normal.array,n=o.dot(t[0].array,r)>this.distance,i=1;i<8;i++)if(o.dot(t[i].array,r)>this.distance!=n)return!0},intersectLine:function(){var e=o.create();return function(t,r,i){var a=this.distanceToPoint(t),s=this.distanceToPoint(r);if(a>0&&s>0||a<0&&s<0)return null;var u=this.normal.array,l=this.distance,c=t.array;o.sub(e,r.array,t.array),o.normalize(e,e);var h=o.dot(u,e);if(0===h)return null;i||(i=new n.a);var d=(o.dot(u,c)-l)/h;return o.scaleAndAdd(i.array,c,e,-d),i._dirty=!0,i}}(),applyTransform:function(){var e=s.create(),t=u.create(),r=u.create();return r[3]=1,function(n){n=n.array,o.scale(r,this.normal.array,this.distance),u.transformMat4(r,r,n),this.distance=o.dot(r,this.normal.array),s.invert(e,n),s.transpose(e,e),t[3]=0,o.copy(t,this.normal.array),u.transformMat4(t,t,e),o.copy(this.normal.array,t)}}(),copy:function(e){o.copy(this.normal.array,e.normal.array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new l;return e.copy(this),e}},t.a=l},function(e,t,r){"use strict";var n=r(13),i=r(15),a=n.a.extend({dynamic:!1,widthSegments:40,heightSegments:20,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI,radius:1},function(){this.build()},{build:function(){var e=this.heightSegments,t=this.widthSegments,r=this.attributes.position,n=this.attributes.texcoord0,a=this.attributes.normal,o=(t+1)*(e+1);r.init(o),n.init(o),a.init(o);var s,u,l,c,h,d,f,p=o>65535?Uint32Array:Uint16Array,m=this.indices=new p(t*e*6),g=this.radius,_=this.phiStart,v=this.phiLength,y=this.thetaStart,x=this.thetaLength,g=this.radius,T=[],b=[],w=0,E=1/g;for(f=0;f<=e;f++)for(d=0;d<=t;d++)c=d/t,h=f/e,s=-g*Math.cos(_+c*v)*Math.sin(y+h*x),u=g*Math.cos(y+h*x),l=g*Math.sin(_+c*v)*Math.sin(y+h*x),T[0]=s,T[1]=u,T[2]=l,b[0]=c,b[1]=h,r.set(w,T),n.set(w,b),T[0]*=E,T[1]*=E,T[2]*=E,a.set(w,T),w++;var S,A,M,C,L=t+1,D=0;for(f=0;f=32&&(I/=4),A.material.set("maxSampleNumber",Math.min(I,1024));for(var O=D.width,F=2*Math.atan(O/(O-.5))/Math.PI*180,B=0;B>>16)>>>0;h=((1431655765&h)<<1|(2863311530&h)>>>1)>>>0,h=((858993459&h)<<2|(3435973836&h)>>>2)>>>0,h=((252645135&h)<<4|(4042322160&h)>>>4)>>>0,h=(((16711935&h)<<8|(4278255360&h)>>>8)>>>0)/4294967296;var d=Math.sqrt((1-h)/(1+(l*l-1)*h));o[c]=d}for(var c=0;co&&(i=this._x=0,a+=this._rowHeight+u,this._y=a,this._rowHeight=0),this._x+=t+u,this._rowHeight=Math.max(this._rowHeight,r),a+r+u>s)return null;e.position[0]+=this.offsetX*this.dpr+i,e.position[1]+=this.offsetY*this.dpr+a,this._zr.add(e);var l=[this.offsetX/this.width,this.offsetY/this.height];return[[i/o+l[0],a/s+l[1]],[(i+t)/o+l[0],(a+r)/s+l[1]]]},_fitElement:function(e,t,r){var n=e.getBoundingRect(),i=t/n.width,a=r/n.height;e.position=[-n.x*i,-n.y*a],e.scale=[i,a],e.update()}},i.prototype={clear:function(){for(var e=0;e=e)){var o=(i+this._nodeWidth)*this._dpr,s=(a+this._nodeHeight)*this._dpr;try{this._zr.resize({width:o,height:s})}catch(e){this._canvas.width=o,this._canvas.height=s}var u=new n(this._zr,i,a,this._nodeWidth,this._nodeHeight,this._gap,this._dpr);return this._textureAtlasNodes.push(u),u}},add:function(e,t,r){if(this._coords[e.id])return this._coords[e.id];var n=this._getCurrentNode().add(e,t,r);if(!n){var i=this._expand();if(!i)return;n=i.add(e,t,r)}return this._coords[e.id]=n,n},getCoordsScale:function(){var e=this._dpr;return[this._nodeWidth/this._canvas.width*e,this._nodeHeight/this._canvas.height*e]},getCoords:function(e){return this._coords[e]}},t.a=i},function(e,t,r){"use strict";function n(e,t,r){var n,i=e.scale;return"ordinal"===i.type&&("function"==typeof r?(n=i.getTicks()[t],!r(n,i.getLabel(n))):t%(r+1))}t.a=n},function(e,t,r){function n(e,t,r,n){r<0&&(e+=r,r=-r),n<0&&(t+=n,n=-n),this.x=e,this.y=t,this.width=r,this.height=n}var i=r(76),a=r(77),o=i.applyTransform,s=Math.min,u=Math.max;n.prototype={constructor:n,union:function(e){var t=s(e.x,this.x),r=s(e.y,this.y);this.width=u(e.x+e.width,this.x+this.width)-t,this.height=u(e.y+e.height,this.y+this.height)-r,this.x=t,this.y=r},applyTransform:function(){var e=[],t=[],r=[],n=[];return function(i){if(i){e[0]=r[0]=this.x,e[1]=n[1]=this.y,t[0]=n[0]=this.x+this.width,t[1]=r[1]=this.y+this.height,o(e,e,i),o(t,t,i),o(r,r,i),o(n,n,i),this.x=s(e[0],t[0],r[0],n[0]),this.y=s(e[1],t[1],r[1],n[1]);var a=u(e[0],t[0],r[0],n[0]),l=u(e[1],t[1],r[1],n[1]);this.width=a-this.x,this.height=l-this.y}}}(),calculateTransform:function(e){var t=this,r=e.width/t.width,n=e.height/t.height,i=a.create();return a.translate(i,i,[-t.x,-t.y]),a.scale(i,i,[r,n]),a.translate(i,i,[e.x,e.y]),i},intersect:function(e){if(!e)return!1;e instanceof n||(e=n.create(e));var t=this,r=t.x,i=t.x+t.width,a=t.y,o=t.y+t.height,s=e.x,u=e.x+e.width,l=e.y,c=e.y+e.height;return!(i=r.x&&e<=r.x+r.width&&t>=r.y&&t<=r.y+r.height},clone:function(){return new n(this.x,this.y,this.width,this.height)},copy:function(e){this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height},plain:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}}},n.create=function(e){return new n(e.x,e.y,e.width,e.height)};var l=n;e.exports=l},function(e,t){function r(e,t){var r=new w(2);return null==e&&(e=0),null==t&&(t=0),r[0]=e,r[1]=t,r}function n(e,t){return e[0]=t[0],e[1]=t[1],e}function i(e){var t=new w(2);return t[0]=e[0],t[1]=e[1],t}function a(e,t,r){return e[0]=t,e[1]=r,e}function o(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function s(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e}function u(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function l(e){return Math.sqrt(c(e))}function c(e){return e[0]*e[0]+e[1]*e[1]}function h(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function d(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function f(e,t){return e[0]*t[0]+e[1]*t[1]}function p(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function m(e,t){var r=l(t);return 0===r?(e[0]=0,e[1]=0):(e[0]=t[0]/r,e[1]=t[1]/r),e}function g(e,t){return Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1]))}function _(e,t){return(e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])}function v(e,t){return e[0]=-t[0],e[1]=-t[1],e}function y(e,t,r,n){return e[0]=t[0]+n*(r[0]-t[0]),e[1]=t[1]+n*(r[1]-t[1]),e}function x(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e}function T(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e}function b(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e}var w="undefined"==typeof Float32Array?Array:Float32Array,E=l,S=c,A=g,M=_;t.create=r,t.copy=n,t.clone=i,t.set=a,t.add=o,t.scaleAndAdd=s,t.sub=u,t.len=l,t.length=E,t.lenSquare=c,t.lengthSquare=S,t.mul=h,t.div=d,t.dot=f,t.scale=p,t.normalize=m,t.distance=g,t.dist=A,t.distanceSquare=_,t.distSquare=M,t.negate=v,t.lerp=y,t.applyTransform=x,t.min=T,t.max=b},function(e,t){function r(){var e=new h(6);return n(e),e}function n(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e}function i(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function a(e,t,r){var n=t[0]*r[0]+t[2]*r[1],i=t[1]*r[0]+t[3]*r[1],a=t[0]*r[2]+t[2]*r[3],o=t[1]*r[2]+t[3]*r[3],s=t[0]*r[4]+t[2]*r[5]+t[4],u=t[1]*r[4]+t[3]*r[5]+t[5];return e[0]=n,e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=u,e}function o(e,t,r){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4]+r[0],e[5]=t[5]+r[1],e}function s(e,t,r){var n=t[0],i=t[2],a=t[4],o=t[1],s=t[3],u=t[5],l=Math.sin(r),c=Math.cos(r);return e[0]=n*c+o*l,e[1]=-n*l+o*c,e[2]=i*c+s*l,e[3]=-i*l+c*s,e[4]=c*a+l*u,e[5]=c*u-l*a,e}function u(e,t,r){var n=r[0],i=r[1];return e[0]=t[0]*n,e[1]=t[1]*i,e[2]=t[2]*n,e[3]=t[3]*i,e[4]=t[4]*n,e[5]=t[5]*i,e}function l(e,t){var r=t[0],n=t[2],i=t[4],a=t[1],o=t[3],s=t[5],u=r*o-a*n;return u?(u=1/u,e[0]=o*u,e[1]=-a*u,e[2]=-n*u,e[3]=r*u,e[4]=(n*s-o*i)*u,e[5]=(a*i-r*s)*u,e):null}function c(e){var t=r();return i(t,e),t}var h="undefined"==typeof Float32Array?Array:Float32Array;t.create=r,t.identity=n,t.copy=i,t.mul=a,t.translate=o,t.rotate=s,t.scale=u,t.invert=l,t.clone=c},function(e,t,r){function n(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}function i(e,t,r,n){var i=t[1]-t[0],a=r[1]-r[0];if(0===i)return 0===a?r[0]:(r[0]+r[1])/2;if(n)if(i>0){if(e<=t[0])return r[0];if(e>=t[1])return r[1]}else{if(e>=t[0])return r[0];if(e<=t[1])return r[1]}else{if(e===t[0])return r[0];if(e===t[1])return r[1]}return(e-t[0])/i*a+r[0]}function a(e,t){switch(e){case"center":case"middle":e="50%";break;case"left":case"top":e="0%";break;case"right":case"bottom":e="100%"}return"string"==typeof e?n(e).match(/%$/)?parseFloat(e)/100*t:parseFloat(e):null==e?NaN:+e}function o(e,t,r){return null==t&&(t=10),t=Math.min(Math.max(0,t),20),e=(+e).toFixed(t),r?e:+e}function s(e){return e.sort(function(e,t){return e-t}),e}function u(e){if(e=+e,isNaN(e))return 0;for(var t=1,r=0;Math.round(e*t)/t!==e;)t*=10,r++;return r}function l(e){var t=e.toString(),r=t.indexOf("e");if(r>0){var n=+t.slice(r+1);return n<0?-n:0}var i=t.indexOf(".");return i<0?0:t.length-1-i}function c(e,t){var r=Math.log,n=Math.LN10,i=Math.floor(r(e[1]-e[0])/n),a=Math.round(r(Math.abs(t[1]-t[0]))/n),o=Math.min(Math.max(-i+a,0),20);return isFinite(o)?o:20}function h(e,t,r){if(!e[t])return 0;var n=x.reduce(e,function(e,t){return e+(isNaN(t)?0:t)},0);if(0===n)return 0;for(var i=Math.pow(10,r),a=x.map(e,function(e){return(isNaN(e)?0:e)/n*i*100}),o=100*i,s=x.map(a,function(e){return Math.floor(e)}),u=x.reduce(s,function(e,t){return e+t},0),l=x.map(a,function(e,t){return e-s[t]});uc&&(c=l[d],h=d);++s[h],l[h]=0,++u}return s[t]/i}function d(e){var t=2*Math.PI;return(e%t+t)%t}function f(e){return e>-T&&e=-20?+e.toFixed(n<0?-n:0):e}function v(e){function t(e,r,n){return e.interval[n]=0}var x=r(12),T=1e-4,b=/^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d\d)(?::(\d\d)(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/;t.linearMap=i,t.parsePercent=a,t.round=o,t.asc=s,t.getPrecision=u,t.getPrecisionSafe=l,t.getPixelPrecision=c,t.getPercentWithPrecision=h,t.MAX_SAFE_INTEGER=9007199254740991,t.remRadian=d,t.isRadianAroundZero=f,t.parseDate=p,t.quantity=m,t.nice=_,t.reformIntervals=v,t.isNumeric=y},function(e,t,r){"use strict";function n(e){u.a.defaultsWithPropList(e,c,h),i(e);for(var t="",r=0;rc&&l.push({pivot:Math.floor((h+c)/2),left:c,right:h});var c=s[u].pivot+1,h=s[u].right;h>c&&l.push({pivot:Math.floor((h+c)/2),left:c,right:h})}s=this._parts=l}else for(var u=0;u50&&(a=1e3);var u=[];o.perspective(u,s,this.width/this.height,1,a),this.viewGL.camera.projectionMatrix.setArray(u),this.viewGL.camera.decomposeProjectionMatrix();var u=o.identity([]),l=this.dataToPoint(this.center);o.scale(u,u,[1,-1,1]),o.translate(u,u,[0,0,-e]),o.rotateX(u,u,t),o.rotateZ(u,u,-this.bearing/180*Math.PI),o.translate(u,u,[-l[0]*this.getScale()*.1,-l[1]*this.getScale()*.1,0]),this.viewGL.camera.viewMatrix.array=u;var c=[];o.invert(c,u),this.viewGL.camera.worldTransform.array=c,this.viewGL.camera.decomposeWorldTransform();var h,d=512*this.getScale();if(this.altitudeExtent&&!isNaN(this.boxHeight)){var f=this.altitudeExtent[1]-this.altitudeExtent[0];h=this.boxHeight/f*this.getScale()/Math.pow(2,this._initialZoom-this.zoomOffset)}else h=d/(2*Math.PI*6378e3*Math.abs(Math.cos(this.center[1]*(Math.PI/180))))*this.altitudeScale*.1;this.viewGL.rootNode.scale.set(.1*this.getScale(),.1*this.getScale(),h)}},getScale:function(){return Math.pow(2,this.zoom-this.zoomOffset)},projectOnTile:function(e,t){return this.projectOnTileWithScale(e,512*this.getScale(),t)},projectOnTileWithScale:function(e,t,r){var n=e[0],i=e[1],a=n*u/180,o=i*u/180,s=t*(a+u)/(2*u),l=t*(u-Math.log(Math.tan(u/4+.5*o)))/(2*u);return r=r||[],r[0]=s,r[1]=l,r},unprojectFromTile:function(e,t){return this.unprojectOnTileWithScale(e,512*this.getScale(),t)},unprojectOnTileWithScale:function(e,t,r){var n=e[0],i=e[1],a=n/t*(2*u)-u,o=2*(Math.atan(Math.exp(u-i/t*(2*u)))-u/4);return r=r||[],r[0]=180*a/u,r[1]=180*o/u,r},dataToPoint:function(e,t){return t=this.projectOnTileWithScale(e,512,t),t[0]-=this._origin[0],t[1]-=this._origin[1],t[2]=isNaN(e[2])?0:e[2],isNaN(e[2])||(t[2]=e[2],this.altitudeExtent&&(t[2]-=this.altitudeExtent[0])),t}},t.a=n},function(e,t,r){"use strict";var n=r(3),i=r(2),a=r(19);t.a=function(e,t,r){function o(e,t){var r=t.getWidth(),n=t.getHeight(),i=t.getDevicePixelRatio();this.viewGL.setViewport(0,0,r,n,i),this.width=r,this.height=n,this.altitudeScale=e.get("altitudeScale"),this.boxHeight=e.get("boxHeight")}function s(e,t){if("auto"!==this.model.get("boxHeight")){var r=[1/0,-1/0];e.eachSeries(function(e){if(e.coordinateSystem===this){var t=e.getData(),n=e.coordDimToDataDim("alt")[0];if(n){var i=t.getDataExtent(n,!0);r[0]=Math.min(r[0],i[0]),r[1]=Math.max(r[1],i[1])}}},this),r&&isFinite(r[1]-r[0])&&(this.altitudeExtent=r)}}return{dimensions:t.prototype.dimensions,create:function(u,l){var c=[];return u.eachComponent(e,function(e){var r=e.__viewGL;r||(r=e.__viewGL=new a.a,r.setRootNode(new i.a.Node));var n=new t;n.viewGL=e.__viewGL,n.resize=o,n.resize(e,l),c.push(n),e.coordinateSystem=n,n.model=e,n.update=s}),u.eachSeries(function(t){if(t.get("coordinateSystem")===e){var r=t.getReferringComponents(e)[0];if(r||(r=u.getComponent(e)),!r)throw new Error(e+' "'+n.a.firstNotNull(t.get(e+"Index"),t.get(e+"Id"),0)+'" not found');t.coordinateSystem=r.coordinateSystem}}),r&&r(c,u,l),c}}}},function(e,t,r){"use strict";t.a="\n@export ecgl.displayShadow.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_WorldPosition;\n\nvarying vec3 v_Normal;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n\n@export ecgl.displayShadow.fragment\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform float roughness: 0.2;\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.ssaoMap.header\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n float shadow = 1.0;\n\n @import ecgl.common.ssaoMap.main\n\n#if defined(DIRECTIONAL_LIGHT_COUNT) && defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n for (int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++) {\n shadow = min(shadow, shadowContribsDir[i] * 0.5 + 0.5);\n }\n#endif\n\n shadow *= 0.5 + ao * 0.5;\n shadow = clamp(shadow, 0.0, 1.0);\n\n gl_FragColor = vec4(vec3(0.0), 1.0 - shadow);\n}\n\n@end"},function(e,t,r){"use strict";function n(e){this.viewGL=e}var i=r(77),a=r.n(i),o=r(76),s=r.n(o);n.prototype.reset=function(e,t){this._updateCamera(t.getWidth(),t.getHeight(),t.getDevicePixelRatio()),this._viewTransform=a.a.create(),this.updateTransform(e,t)},n.prototype.updateTransform=function(e,t){var r=e.coordinateSystem;r.getRoamTransform&&(a.a.invert(this._viewTransform,r.getRoamTransform()),this._setCameraTransform(this._viewTransform),t.getZr().refresh())},n.prototype.dataToPoint=function(e,t,r){r=e.dataToPoint(t,null,r);var n=this._viewTransform;n&&s.a.applyTransform(r,r,n)},n.prototype.removeTransformInPoint=function(e){return this._viewTransform&&s.a.applyTransform(e,e,this._viewTransform),e},n.prototype.getZoom=function(){if(this._viewTransform){var e=this._viewTransform;return 1/Math.max(Math.sqrt(e[0]*e[0]+e[1]*e[1]),Math.sqrt(e[2]*e[2]+e[3]*e[3]))}return 1},n.prototype._setCameraTransform=function(e){var t=this.viewGL.camera;t.position.set(e[4],e[5],0),t.scale.set(Math.sqrt(e[0]*e[0]+e[1]*e[1]),Math.sqrt(e[2]*e[2]+e[3]*e[3]),1)},n.prototype._updateCamera=function(e,t,r){this.viewGL.setViewport(0,0,e,t,r);var n=this.viewGL.camera;n.left=n.top=0,n.bottom=t,n.right=e,n.near=0,n.far=100},t.a=n},function(e,t,r){(function(e){var r;"undefined"!=typeof window?r=window.__DEV__:void 0!==e&&(r=e.__DEV__),void 0===r&&(r=!0);var n=r;t.__DEV__=n}).call(t,r(63))},function(e,t,r){"use strict";var n=r(13),i=r(0),a=r.n(i),o=r(34),s=r(1),u=r.n(s),l=u.a.vec2,c=[[0,0],[1,1]],h=n.a.extend(function(){return{segmentScale:4,dynamic:!0,useNativeLine:!0,attributes:{position:new n.a.Attribute("position","float",2,"POSITION"),normal:new n.a.Attribute("normal","float",2),offset:new n.a.Attribute("offset","float",1),color:new n.a.Attribute("color","float",4,"COLOR")}}},{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(e){var t=this.attributes;this.vertexCount!==e&&(t.position.init(e),t.color.init(e),this.useNativeLine||(t.offset.init(e),t.normal.init(e)),e>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(e){this.triangleCount!==e&&(this.indices=0===e?null:this.vertexCount>65535?new Uint32Array(3*e):new Uint16Array(3*e))},_getCubicCurveApproxStep:function(e,t,r,n){return 1/(l.dist(e,t)+l.dist(r,t)+l.dist(n,r)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?2*a:2*a+2},getCubicCurveTriangleCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?0:2*a},getLineVertexCount:function(){return this.getPolylineVertexCount(c)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(c)},getPolylineVertexCount:function(e){var t;if("number"==typeof e)t=e;else{t="number"!=typeof e[0]?e.length:e.length/2}return this.useNativeLine?2*(t-1):2*(t-1)+2},getPolylineTriangleCount:function(e){var t;if("number"==typeof e)t=e;else{t="number"!=typeof e[0]?e.length:e.length/2}return this.useNativeLine?0:2*(t-1)},addCubicCurve:function(e,t,r,n,i,a){null==a&&(a=1);for(var o=e[0],s=e[1],u=t[0],l=t[1],c=r[0],h=r[1],d=n[0],f=n[1],p=this._getCubicCurveApproxStep(e,t,r,n),m=p*p,g=m*p,_=3*p,v=3*m,y=6*m,x=6*g,T=o-2*u+c,b=s-2*l+h,w=3*(u-c)-o+d,E=3*(l-h)-s+f,S=o,A=s,M=(u-o)*_+T*v+w*g,C=(l-s)*_+b*v+E*g,L=T*y+w*x,D=b*y+E*x,N=w*x,R=E*x,P=0,I=0,O=Math.ceil(1/p),F=new Float32Array(3*(O+1)),F=[],B=0,I=0;I1&&(S=M>0?Math.min(S,d):Math.max(S,d),A=C>0?Math.min(A,f):Math.max(A,f));this.addPolyline(F,i,a)},addLine:function(e,t,r,n){this.addPolyline([e,t],r,n)},addPolyline:function(){var e=l.create(),t=l.create(),r=l.create(),n=l.create(),i=[],a=[],o=[];return function(s,u,c,h,d){if(s.length){var f="number"!=typeof s[0];if(null==d&&(d=f?s.length:s.length/2),!(d<2)){null==h&&(h=0),null==c&&(c=1),this._itemVertexOffsets.push(this._vertexOffset);for(var p,m=f?"number"!=typeof u[0]:u.length/4===d,g=this.attributes.position,_=this.attributes.color,v=this.attributes.offset,y=this.attributes.normal,x=this.indices,T=this._vertexOffset,b=0;b1&&(g.copy(T,T-1),_.copy(T,T-1),T++);else{var S;if(b0){l.sub(e,i,o),l.sub(t,a,i),l.normalize(e,e),l.normalize(t,t),l.add(n,e,t),l.normalize(n,n);var A=c/2*Math.min(1/l.dot(e,n),2);r[0]=-n[1],r[1]=n[0],S=A}else l.sub(e,a,i),l.normalize(e,e),r[0]=-e[1],r[1]=e[0],S=c/2}else l.sub(e,i,o),l.normalize(e,e),r[0]=-e[1],r[1]=e[0],S=c/2;y.set(T,r),y.set(T+1,r),v.set(T,S),v.set(T+1,-S),l.copy(o,i),g.set(T,i),g.set(T+1,i),_.set(T,p),_.set(T+1,p),T+=2}if(this.useNativeLine)_.set(T,p),g.set(T,i),T++;else if(b>0){var M=3*this._faceOffset,x=this.indices;x[M]=T-4,x[M+1]=T-3,x[M+2]=T-2,x[M+3]=T-3,x[M+4]=T-1,x[M+5]=T-2,this._faceOffset+=2}}this._vertexOffset=T}}}}(),setItemColor:function(e,t){for(var r=this._itemVertexOffsets[e],n=ee&&o=0&&this._viewsToDispose.splice(t,1),this.views.push(e),e.layer=this;var r=this.zr;e.scene.traverse(function(e){e.__zr=r,e.addAnimatorsToZr&&e.addAnimatorsToZr(r)})}},_.prototype.removeView=function(e){if(e.layer===this){var t=this.views.indexOf(e);t>=0&&(this.views.splice(t,1),e.scene.traverse(n,this),e.layer=null,this._viewsToDispose.push(e))}},_.prototype.removeViewsAll=function(){this.views.forEach(function(e){e.scene.traverse(n,this),e.layer=null,this._viewsToDispose.push(e)},this),this.views.length=0},_.prototype.resize=function(e,t){this.renderer.resize(e,t)},_.prototype.clear=function(){var e=this.renderer.gl,t=this._backgroundColor||[0,0,0,0];e.clearColor(t[0],t[1],t[2],t[3]),e.depthMask(!0),e.colorMask(!0,!0,!0,!0),e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT)},_.prototype.clearDepth=function(){var e=this.renderer.gl;e.clear(e.DEPTH_BUFFER_BIT)},_.prototype.clearColor=function(){var e=this.renderer.gl;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)},_.prototype.needsRefresh=function(){this.zr.refresh()},_.prototype.refresh=function(e){this._backgroundColor=e?f.a.parseColor(e):[0,0,0,0],this.renderer.clearColor=this._backgroundColor;for(var t=0;t20)){e=e.event;var n=this.pickObject(e.offsetX,e.offsetY);n&&(this._dispatchEvent(e.type,e,n),this._dispatchDataEvent(e.type,e,n));var i=this._clickToSetFocusPoint(e);if(i){i.view.setDOFFocusOnPoint(i.distance)&&this.zr.refresh()}}}},_.prototype._clickToSetFocusPoint=function(e){for(var t=this.renderer,r=t.viewport,n=this.views.length-1;n>=0;n--){var i=this.views[n];if(i.hasDOF()&&i.containPoint(e.offsetX,e.offsetY)){this._picking.scene=i.scene,this._picking.camera=i.camera,t.viewport=i.viewport;var a=this._picking.pick(e.offsetX,e.offsetY,!0);if(a)return a.view=i,a}}t.viewport=r},_.prototype.onglobalout=function(e){var t=this._hovered;t&&this._dispatchEvent("mouseout",e,{target:t.target})},_.prototype.pickObject=function(e,t){for(var r=[],n=this.renderer,i=n.viewport,a=0;a=0&&(u.dataIndex=this._lastDataIndex,u.seriesIndex=this._lastSeriesIndex,this.zr.handler.dispatchToElement(l,"mouseout",t)),s=!0):null!=o&&o!==this._lastEventData&&(null!=this._lastEventData&&(u.eventData=this._lastEventData,this.zr.handler.dispatchToElement(l,"mouseout",t)),s=!0),this._lastEventData=o,this._lastDataIndex=i,this._lastSeriesIndex=a),u.eventData=o,u.dataIndex=i,u.seriesIndex=a,(null!=o||parseInt(i,10)>=0&&parseInt(a,10)>=0)&&(this.zr.handler.dispatchToElement(l,e,t),s&&this.zr.handler.dispatchToElement(l,"mouseover",t))},_.prototype._dispatchToView=function(e,t){for(var r=0;r255?255:e}function i(e){return e=Math.round(e),e<0?0:e>360?360:e}function a(e){return e<0?0:e>1?1:e}function o(e){return n(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100*255:parseInt(e,10))}function s(e){return a(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100:parseFloat(e))}function u(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e}function l(e,t,r){return e+(t-e)*r}function c(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e}function h(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function d(e,t){y&&h(y,t),y=v.put(e,y||t.slice())}function f(e,t){var r=(parseFloat(e[0])%360+360)%360/360,i=s(e[1]),a=s(e[2]),o=a<=.5?a*(i+1):a+i-a*i,l=2*a-o;return t=t||[],c(t,n(255*u(l,o,r+1/3)),n(255*u(l,o,r)),n(255*u(l,o,r-1/3)),1),4===e.length&&(t[3]=e[3]),t}function p(e){if(e){var t,r,n=e[0]/255,i=e[1]/255,a=e[2]/255,o=Math.min(n,i,a),s=Math.max(n,i,a),u=s-o,l=(s+o)/2;if(0===u)t=0,r=0;else{r=l<.5?u/(s+o):u/(2-s-o);var c=((s-n)/6+u/2)/u,h=((s-i)/6+u/2)/u,d=((s-a)/6+u/2)/u;n===s?t=d-h:i===s?t=1/3+c-d:a===s&&(t=2/3+h-c),t<0&&(t+=1),t>1&&(t-=1)}var f=[360*t,r,l];return null!=e[3]&&f.push(e[3]),f}}var m=r(64),g={},_={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]},v=new m.a(20),y=null;g.parse=function(e,t){if(e){t=t||[];var r=v.get(e);if(r)return h(t,r);e+="";var n=e.replace(/ /g,"").toLowerCase();if(n in _)return h(t,_[n]),d(e,t),t;if("#"!==n.charAt(0)){var i=n.indexOf("("),a=n.indexOf(")");if(-1!==i&&a+1===n.length){var u=n.substr(0,i),l=n.substr(i+1,a-(i+1)).split(","),p=1;switch(u){case"rgba":if(4!==l.length)return void c(t,0,0,0,1);p=s(l.pop());case"rgb":return 3!==l.length?void c(t,0,0,0,1):(c(t,o(l[0]),o(l[1]),o(l[2]),p),d(e,t),t);case"hsla":return 4!==l.length?void c(t,0,0,0,1):(l[3]=s(l[3]),f(l,t),d(e,t),t);case"hsl":return 3!==l.length?void c(t,0,0,0,1):(f(l,t),d(e,t),t);default:return}}c(t,0,0,0,1)}else{if(4===n.length){var m=parseInt(n.substr(1),16);return m>=0&&m<=4095?(c(t,(3840&m)>>4|(3840&m)>>8,240&m|(240&m)>>4,15&m|(15&m)<<4,1),d(e,t),t):void c(t,0,0,0,1)}if(7===n.length){var m=parseInt(n.substr(1),16);return m>=0&&m<=16777215?(c(t,(16711680&m)>>16,(65280&m)>>8,255&m,1),d(e,t),t):void c(t,0,0,0,1)}}}},g.parseToFloat=function(e,t){if(t=g.parse(e,t))return t[0]/=255,t[1]/=255,t[2]/=255,t},g.lift=function(e,t){var r=g.parse(e);if(r){for(var n=0;n<3;n++)r[n]=t<0?r[n]*(1-t)|0:(255-r[n])*t+r[n]|0;return g.stringify(r,4===r.length?"rgba":"rgb")}},g.toHex=function(e){var t=g.parse(e);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)},g.fastLerp=function(e,t,r){if(t&&t.length&&e>=0&&e<=1){r=r||[];var i=e*(t.length-1),o=Math.floor(i),s=Math.ceil(i),u=t[o],c=t[s],h=i-o;return r[0]=n(l(u[0],c[0],h)),r[1]=n(l(u[1],c[1],h)),r[2]=n(l(u[2],c[2],h)),r[3]=a(l(u[3],c[3],h)),r}},g.fastMapToColor=g.fastLerp,g.lerp=function(e,t,r){if(t&&t.length&&e>=0&&e<=1){var i=e*(t.length-1),o=Math.floor(i),s=Math.ceil(i),u=g.parse(t[o]),c=g.parse(t[s]),h=i-o,d=g.stringify([n(l(u[0],c[0],h)),n(l(u[1],c[1],h)),n(l(u[2],c[2],h)),a(l(u[3],c[3],h))],"rgba");return r?{color:d,leftIndex:o,rightIndex:s,value:i}:d}},g.mapToColor=g.lerp,g.modifyHSL=function(e,t,r,n){if(e=g.parse(e))return e=p(e),null!=t&&(e[0]=i(t)),null!=r&&(e[1]=s(r)),null!=n&&(e[2]=s(n)),g.stringify(f(e),"rgba")},g.modifyAlpha=function(e,t){if((e=g.parse(e))&&null!=t)return e[3]=a(t),g.stringify(e,"rgba")},g.stringify=function(e,t){if(e&&e.length){var r=e[0]+","+e[1]+","+e[2];return"rgba"!==t&&"hsva"!==t&&"hsla"!==t||(r+=","+e[3]),t+"("+r+")"}},t.a=g},function(e,t,r){"use strict";var n=function(){this.head=null,this.tail=null,this._length=0};n.prototype.insert=function(e){var t=new n.Entry(e);return this.insertEntry(t),t},n.prototype.insertAt=function(e,t){if(!(e<0)){for(var r=this.head,i=0;r&&i!=e;)r=r.next,i++;if(r){var a=new n.Entry(t),o=r.prev;o?(o.next=a,a.prev=o):this.head=a,a.next=r,r.prev=a}else this.insert(t)}},n.prototype.insertBeforeEntry=function(e,t){var r=new n.Entry(e),i=t.prev;i?(i.next=r,r.prev=i):this.head=r,r.next=t,t.prev=r,this._length++},n.prototype.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,this.tail=e):this.head=this.tail=e,this._length++},n.prototype.remove=function(e){var t=e.prev,r=e.next;t?t.next=r:this.head=r,r?r.prev=t:this.tail=t,e.next=e.prev=null,this._length--},n.prototype.removeAt=function(e){if(!(e<0)){for(var t=this.head,r=0;t&&r!=e;)t=t.next,r++;return t?(this.remove(t),t.value):void 0}},n.prototype.getHead=function(){if(this.head)return this.head.value},n.prototype.getTail=function(){if(this.tail)return this.tail.value},n.prototype.getAt=function(e){if(!(e<0)){for(var t=this.head,r=0;t&&r!=e;)t=t.next,r++;return t.value}},n.prototype.indexOf=function(e){for(var t=this.head,r=0;t;){if(t.value===e)return r;t=t.next,r++}},n.prototype.length=function(){return this._length},n.prototype.isEmpty=function(){return 0===this._length},n.prototype.forEach=function(e,t){for(var r=this.head,n=0,i=void 0!==t;r;)i?e.call(t,r.value,n):e(r.value,n),r=r.next,n++},n.prototype.clear=function(){this.tail=this.head=null,this._length=0},n.Entry=function(e){this.value=e,this.next=null,this.prev=null},t.a=n},function(e,t,r){"use strict";function n(e,t,r){function n(e,r,n,a){var o="";isNaN(r)&&(r=r in t?t[r]:i[r]),isNaN(n)&&(n=n in t?t[n]:i[n]);for(var s=parseInt(r);s0&&n.push("#define "+i.toUpperCase()+"_COUNT "+a)}if(r)for(var o=0;o=0&&S[w]>1e-4&&(d.transformMat4(C,E,T[A[w]]),d.scaleAndAdd(M,M,C,S[w]));L.set(b,M)}}for(var b=0;b<_.length;b+=3){var D=_[b],N=_[b+1],R=_[b+2],P=c?h.attributes.skinnedPosition:v;if(P.get(D,e.array),P.get(N,t.array),P.get(R,r.array),p=g?n.intersectTriangle(e,t,r,i.culling):n.intersectTriangle(e,r,t,i.culling)){var I=new o.a;c?o.a.copy(I,p):o.a.transformMat4(I,p,i.worldTransform),u.push(new f.Intersection(p,I,i,[D,N,R],b/3,o.a.dist(I,this._ray.origin)))}}}}}}(),_intersectionCompareFunc:function(e,t){return e.distance-t.distance}});f.Intersection=function(e,t,r,n,i,a){this.point=e,this.pointWorld=t,this.target=r,this.triangle=n,this.triangleIndex=i,this.distance=a},t.a=f},function(e,t,r){"use strict";function n(e){var t=new XMLHttpRequest;t.open("get",e.url),t.responseType=e.responseType||"text",e.onprogress&&(t.onprogress=function(t){if(t.lengthComputable){var r=t.loaded/t.total;e.onprogress(r,t.loaded,t.total)}else e.onprogress(null)}),t.onload=function(r){t.status>=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}t.a={get:n}},function(e,t,r){"use strict";t.a="@export clay.skydome.vertex\n#define SHADER_NAME skydome\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position : POSITION;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n v_Texcoord = texcoord;\n}\n@end\n@export clay.skydome.fragment\nuniform sampler2D environmentMap;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(environmentMap, v_Texcoord));\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end"},function(e,t,r){"use strict";function n(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var i=r(6),a=r(5),o=(r(24),n("DXT1")),s=n("DXT3"),u=n("DXT5"),l={parse:function(e,t){var r=new Int32Array(e,0,31);if(542327876!==r[0])return null;if(4&!r(20))return null;var n,l,c=r(21),h=r[4],d=r[3],f=512&r[28],p=131072&r[2];switch(c){case o:n=8,l=i.a.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case s:n=16,l=i.a.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case u:n=16,l=i.a.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}var m=r[1]+4,g=f?6:1,_=1;p&&(_=Math.max(1,r[7]));for(var v=[],y=0;y0){var i=Math.pow(2,e[3]-128-8+n);t[r+0]=e[0]*i,t[r+1]=e[1]*i,t[r+2]=e[2]*i}else t[r+0]=0,t[r+1]=0,t[r+2]=0;return t[r+3]=1,t}function i(e,t,r){for(var n="",i=t;i0;)if(e[o][0]=t[r++],e[o][1]=t[r++],e[o][2]=t[r++],e[o][3]=t[r++],1===e[o][0]&&1===e[o][1]&&1===e[o][2]){for(var u=e[o][3]<>>0;u>0;u--)a(e[o-1],e[o]),o++,s--;i+=8}else o++,s--,i=0;return r}function s(e,t,r,n){if(nd)return o(e,t,r,n);var i=t[r++];if(2!=i)return o(e,t,r-1,n);if(e[0][1]=t[r++],e[0][2]=t[r++],i=t[r++],(e[0][2]<<8>>>0|i)>>>0!==n)return null;for(var i=0;i<4;i++)for(var a=0;a128){s=(127&s)>>>0;for(var u=t[r++];s--;)e[a++][i]=u}else for(;s--;)e[a++][i]=t[r++]}return r}var u=r(6),l=r(5),c=String.fromCharCode,h=8,d=32767,f={parseRGBE:function(e,t,r){null==r&&(r=0);var a=new Uint8Array(e),o=a.length;if("#?"===i(a,0,2)){for(var h=2;h=o)){h+=2;for(var d="";h=0||(s.forEach(function(t){e.on(t,this[n(t)],this)},this),this._meshes.push(e))},detachFromMesh:function(e){var t=this._meshes.indexOf(e);t>=0&&this._meshes.splice(t,1),s.forEach(function(t){e.off(t,this[n(t)])},this)},dispose:function(){this._meshes.forEach(function(e){this.detachFromMesh(e)},this)}},t.a=u},function(e,t,r){"use strict";var n=r(21),i=r(70),a=n.a.extend({cubemap:null,castShadow:!1,_normalDistribution:null,_brdfLookup:null},{type:"AMBIENT_CUBEMAP_LIGHT",prefilter:function(e,t){this._brdfLookup||(this._normalDistribution=i.a.generateNormalDistribution(),this._brdfLookup=i.a.integrateBRDF(e,this._normalDistribution));var r=this.cubemap;if(!r.__prefiltered){var n=i.a.prefilterEnvironmentMap(e,r,{encodeRGBM:!0,width:t,height:t},this._normalDistribution,this._brdfLookup);this.cubemap=n.environmentMap,this.cubemap.__prefiltered=!0,r.dispose(e)}},uniformTemplates:{ambientCubemapLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}},ambientCubemapLightCubemap:{type:"t",value:function(e){return e.cubemap}},ambientCubemapLightBRDFLookup:{type:"t",value:function(e){return e._brdfLookup}}}});t.a=a},function(e,t,r){"use strict";t.a="\n@export clay.compositor.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n v_Texcoord = texcoord;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end"},function(e,t,r){"use strict";t.a="@export clay.skybox.vertex\n#define SHADER_NAME skybox\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export clay.skybox.fragment\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 viewDirection = normalize(v_WorldPosition - eyePos);\n#ifdef LOD\n vec4 texel = decodeHDR(textureCubeLodEXT(environmentMap, viewDirection, lod));\n#else\n vec4 texel = decodeHDR(textureCube(environmentMap, viewDirection));\n#endif\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end"},function(e,t,r){"use strict";t.a="#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform sampler2D normalDistribution;\nuniform vec2 viewportSize : [512, 256];\nconst vec3 N = vec3(0.0, 0.0, 1.0);\nconst float fSampleNumber = float(SAMPLE_NUMBER);\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nfloat G_Smith(float roughness, float NoV, float NoL) {\n float k = roughness * roughness / 2.0;\n float G1V = NoV / (NoV * (1.0 - k) + k);\n float G1L = NoL / (NoL * (1.0 - k) + k);\n return G1L * G1V;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / viewportSize;\n float NoV = uv.x;\n float roughness = uv.y;\n vec3 V;\n V.x = sqrt(1.0 - NoV * NoV);\n V.y = 0.0;\n V.z = NoV;\n float A = 0.0;\n float B = 0.0;\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(L.z, 0.0, 1.0);\n float NoH = clamp(H.z, 0.0, 1.0);\n float VoH = clamp(dot(V, H), 0.0, 1.0);\n if (NoL > 0.0) {\n float G = G_Smith(roughness, NoV, NoL);\n float G_Vis = G * VoH / (NoH * NoV);\n float Fc = pow(1.0 - VoH, 5.0);\n A += (1.0 - Fc) * G_Vis;\n B += Fc * G_Vis;\n }\n }\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n"},function(e,t,r){"use strict";t.a="#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nuniform int maxSampleNumber: 1024\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(maxSampleNumber);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n if (i > maxSampleNumber) {\n break;\n }\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"},function(e,t,r){"use strict";var n=r(21),i=r(18),a=n.a.extend({castShadow:!1,coefficients:[]},function(){this._coefficientsTmpArr=new i.a.Float32Array(27)},{type:"AMBIENT_SH_LIGHT",uniformTemplates:{ambientSHLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}},ambientSHLightCoefficients:{type:"3f",value:function(e){for(var t=e._coefficientsTmpArr,r=0;r=0&&l.splice(e,1)}),l.push(c),this.__zr&&this.__zr.animation.addAnimator(c),c},stopAnimation:function(e){this._animators=this._animators||[];for(var t=this._animators,r=t.length,n=0;n.5?t:e}function s(e,t,r,n,i){var o=e.length;if(1==i)for(var s=0;si)e.length=i;else for(var a=n;a=0&&!(C[r]<=t);r--);r=Math.min(r,T-2)}else{for(r=V;rt);r++);r=Math.min(r-1,T-2)}V=r,k=t;var n=C[r+1]-C[r];if(0!==n)if(B=(t-C[r])/n,x)if(U=L[r],z=L[0===r?r:r-1],G=L[r>T-2?T-1:r+1],H=L[r>T-3?T-1:r+2],E)c(z,U,G,H,B,B*B,B*B*B,m(e,i),M);else{var u;if(S)u=c(z,U,G,H,B,B*B,B*B*B,W,1),u=f(W);else{if(A)return o(U,G,B);u=h(z,U,G,H,B,B*B,B*B*B)}v(e,i,u)}else if(E)s(L[r],L[r+1],B,m(e,i),M);else{var u;if(S)s(L[r],L[r+1],B,W,1),u=f(W);else{if(A)return o(L[r],L[r+1],B);u=a(L[r],L[r+1],B)}v(e,i,u)}},X=new g({target:e._target,life:b,loop:e._loop,delay:e._delay,onframe:j,ondestroy:r});return t&&"spline"!==t&&(X.easing=t),X}}}var g=r(135),_=r(137),v=r(12),y=v.isArrayLike,x=Array.prototype.slice,T=function(e,t,r,a){this._tracks={},this._target=e,this._loop=t||!1,this._getter=r||n,this._setter=a||i,this._clipCount=0,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]};T.prototype={when:function(e,t){var r=this._tracks;for(var n in t)if(t.hasOwnProperty(n)){if(!r[n]){r[n]=[];var i=this._getter(this._target,n);if(null==i)continue;0!==e&&r[n].push({time:0,value:d(i)})}r[n].push({time:e,value:t[n]})}return this},during:function(e){return this._onframeList.push(e),this},pause:function(){for(var e=0;e255?255:e}function i(e){return e=Math.round(e),e<0?0:e>360?360:e}function a(e){return e<0?0:e>1?1:e}function o(e){return n(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100*255:parseInt(e,10))}function s(e){return a(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100:parseFloat(e))}function u(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e}function l(e,t,r){return e+(t-e)*r}function c(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e}function h(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function d(e,t){A&&h(A,t),A=S.put(e,A||t.slice())}function f(e,t){if(e){t=t||[];var r=S.get(e);if(r)return h(t,r);e+="";var n=e.replace(/ /g,"").toLowerCase();if(n in E)return h(t,E[n]),d(e,t),t;if("#"!==n.charAt(0)){var i=n.indexOf("("),a=n.indexOf(")");if(-1!==i&&a+1===n.length){var u=n.substr(0,i),l=n.substr(i+1,a-(i+1)).split(","),f=1;switch(u){case"rgba":if(4!==l.length)return void c(t,0,0,0,1);f=s(l.pop());case"rgb":return 3!==l.length?void c(t,0,0,0,1):(c(t,o(l[0]),o(l[1]),o(l[2]),f),d(e,t),t);case"hsla":return 4!==l.length?void c(t,0,0,0,1):(l[3]=s(l[3]),p(l,t),d(e,t),t);case"hsl":return 3!==l.length?void c(t,0,0,0,1):(p(l,t),d(e,t),t);default:return}}c(t,0,0,0,1)}else{if(4===n.length){var m=parseInt(n.substr(1),16);return m>=0&&m<=4095?(c(t,(3840&m)>>4|(3840&m)>>8,240&m|(240&m)>>4,15&m|(15&m)<<4,1),d(e,t),t):void c(t,0,0,0,1)}if(7===n.length){var m=parseInt(n.substr(1),16);return m>=0&&m<=16777215?(c(t,(16711680&m)>>16,(65280&m)>>8,255&m,1),d(e,t),t):void c(t,0,0,0,1)}}}}function p(e,t){var r=(parseFloat(e[0])%360+360)%360/360,i=s(e[1]),a=s(e[2]),o=a<=.5?a*(i+1):a+i-a*i,l=2*a-o;return t=t||[],c(t,n(255*u(l,o,r+1/3)),n(255*u(l,o,r)),n(255*u(l,o,r-1/3)),1),4===e.length&&(t[3]=e[3]),t}function m(e){if(e){var t,r,n=e[0]/255,i=e[1]/255,a=e[2]/255,o=Math.min(n,i,a),s=Math.max(n,i,a),u=s-o,l=(s+o)/2;if(0===u)t=0,r=0;else{r=l<.5?u/(s+o):u/(2-s-o);var c=((s-n)/6+u/2)/u,h=((s-i)/6+u/2)/u,d=((s-a)/6+u/2)/u;n===s?t=d-h:i===s?t=1/3+c-d:a===s&&(t=2/3+h-c),t<0&&(t+=1),t>1&&(t-=1)}var f=[360*t,r,l];return null!=e[3]&&f.push(e[3]),f}}function g(e,t){var r=f(e);if(r){for(var n=0;n<3;n++)r[n]=t<0?r[n]*(1-t)|0:(255-r[n])*t+r[n]|0;return b(r,4===r.length?"rgba":"rgb")}}function _(e){var t=f(e);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)}function v(e,t,r){if(t&&t.length&&e>=0&&e<=1){r=r||[];var i=e*(t.length-1),o=Math.floor(i),s=Math.ceil(i),u=t[o],c=t[s],h=i-o;return r[0]=n(l(u[0],c[0],h)),r[1]=n(l(u[1],c[1],h)),r[2]=n(l(u[2],c[2],h)),r[3]=a(l(u[3],c[3],h)),r}}function y(e,t,r){if(t&&t.length&&e>=0&&e<=1){var i=e*(t.length-1),o=Math.floor(i),s=Math.ceil(i),u=f(t[o]),c=f(t[s]),h=i-o,d=b([n(l(u[0],c[0],h)),n(l(u[1],c[1],h)),n(l(u[2],c[2],h)),a(l(u[3],c[3],h))],"rgba");return r?{color:d,leftIndex:o,rightIndex:s,value:i}:d}}function x(e,t,r,n){if(e=f(e))return e=m(e),null!=t&&(e[0]=i(t)),null!=r&&(e[1]=s(r)),null!=n&&(e[2]=s(n)),b(p(e),"rgba")}function T(e,t){if((e=f(e))&&null!=t)return e[3]=a(t),b(e,"rgba")}function b(e,t){if(e&&e.length){var r=e[0]+","+e[1]+","+e[2];return"rgba"!==t&&"hsva"!==t&&"hsla"!==t||(r+=","+e[3]),t+"("+r+")"}}var w=r(53),E={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]},S=new w(20),A=null,M=v,C=y;t.parse=f,t.lift=g,t.toHex=_,t.fastLerp=v,t.fastMapToColor=M,t.lerp=y,t.mapToColor=C,t.modifyHSL=x,t.modifyAlpha=T,t.stringify=b},function(e,t,r){"use strict";t.a="\n@export clay.util.rand\nhighp float rand(vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\nvec4 sRGBToLinear(in vec4 value) {\n return vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.w);\n}\nvec4 linearTosRGB(in vec4 value) {\n return vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92, vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.w);\n}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end"},function(e,t,r){"use strict";t.a="\n@export ecgl.common.transformUniforms\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n@end\n\n@export ecgl.common.attributes\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\n@end\n\n@export ecgl.common.uv.header\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nuniform vec2 detailUvRepeat : [1.0, 1.0];\nuniform vec2 detailUvOffset : [0.0, 0.0];\n\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n@export ecgl.common.uv.main\nv_Texcoord = texcoord * uvRepeat + uvOffset;\nv_DetailTexcoord = texcoord * detailUvRepeat + detailUvOffset;\n@end\n\n@export ecgl.common.uv.fragmentHeader\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n\n@export ecgl.common.albedo.main\n\n vec4 albedoTexel = vec4(1.0);\n#ifdef DIFFUSEMAP_ENABLED\n albedoTexel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n albedoTexel = sRGBToLinear(albedoTexel);\n #endif\n#endif\n\n#ifdef DETAILMAP_ENABLED\n vec4 detailTexel = texture2D(detailMap, v_DetailTexcoord);\n #ifdef SRGB_DECODE\n detailTexel = sRGBToLinear(detailTexel);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, detailTexel.rgb, detailTexel.a);\n albedoTexel.a = detailTexel.a + (1.0 - detailTexel.a) * albedoTexel.a;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexHeader\n\n#ifdef WIREFRAME_QUAD\nattribute vec4 barycentric;\nvarying vec4 v_Barycentric;\n#elif defined(WIREFRAME_TRIANGLE)\nattribute vec3 barycentric;\nvarying vec3 v_Barycentric;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n v_Barycentric = barycentric;\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentHeader\n\nuniform float wireframeLineWidth : 1;\nuniform vec4 wireframeLineColor: [0, 0, 0, 0.5];\n\n#ifdef WIREFRAME_QUAD\nvarying vec4 v_Barycentric;\nfloat edgeFactor () {\n vec4 d = fwidth(v_Barycentric);\n vec4 a4 = smoothstep(vec4(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(min(a4.x, a4.y), a4.z), a4.w);\n}\n#elif defined(WIREFRAME_TRIANGLE)\nvarying vec3 v_Barycentric;\nfloat edgeFactor () {\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n if (wireframeLineWidth > 0.) {\n vec4 lineColor = wireframeLineColor;\n#ifdef SRGB_DECODE\n lineColor = sRGBToLinear(lineColor);\n#endif\n\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor()) * lineColor.a);\n }\n#endif\n@end\n\n\n\n\n@export ecgl.common.bumpMap.header\n\n#ifdef BUMPMAP_ENABLED\nuniform sampler2D bumpMap;\nuniform float bumpScale : 1.0;\n\n\nvec3 bumpNormal(vec3 surfPos, vec3 surfNormal, vec3 baseNormal)\n{\n vec2 dSTdx = dFdx(v_Texcoord);\n vec2 dSTdy = dFdy(v_Texcoord);\n\n float Hll = bumpScale * texture2D(bumpMap, v_Texcoord).x;\n float dHx = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdx).x - Hll;\n float dHy = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdy).x - Hll;\n\n vec3 vSigmaX = dFdx(surfPos);\n vec3 vSigmaY = dFdy(surfPos);\n vec3 vN = surfNormal;\n\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n\n float fDet = dot(vSigmaX, R1);\n\n vec3 vGrad = sign(fDet) * (dHx * R1 + dHy * R2);\n return normalize(abs(fDet) * baseNormal - vGrad);\n\n}\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexHeader\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexMain\n\n#ifdef NORMALMAP_ENABLED\n if (dot(tangent, tangent) > 0.0) {\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n#endif\n\n@end\n\n\n@export ecgl.common.normalMap.fragmentHeader\n\n#ifdef NORMALMAP_ENABLED\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.fragmentMain\n#ifdef NORMALMAP_ENABLED\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_DetailTexcoord).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n mat3 tbn = mat3(v_Tangent, v_Bitangent, v_Normal);\n N = normalize(tbn * N);\n }\n }\n#endif\n@end\n\n\n\n@export ecgl.common.vertexAnimation.header\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevNormal;\nuniform float percent;\n#endif\n\n@end\n\n@export ecgl.common.vertexAnimation.main\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n vec3 norm = mix(prevNormal, normal, percent);\n#else\n vec3 pos = position;\n vec3 norm = normal;\n#endif\n\n@end\n\n\n@export ecgl.common.ssaoMap.header\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n@end\n\n@export ecgl.common.ssaoMap.main\n float ao = 1.0;\n#ifdef SSAOMAP_ENABLED\n ao = texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n@end\n\n\n\n\n@export ecgl.common.diffuseLayer.header\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\nuniform float layerDiffuseIntensity[LAYER_DIFFUSEMAP_COUNT];\nuniform sampler2D layerDiffuseMap[LAYER_DIFFUSEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.header\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\nuniform float layerEmissionIntensity[LAYER_EMISSIVEMAP_COUNT];\nuniform sampler2D layerEmissiveMap[LAYER_EMISSIVEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.layers.header\n@import ecgl.common.diffuseLayer.header\n@import ecgl.common.emissiveLayer.header\n@end\n\n@export ecgl.common.diffuseLayer.main\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_DIFFUSEMAP_COUNT; _idx_++) {{\n float intensity = layerDiffuseIntensity[_idx_];\n vec4 texel2 = texture2D(layerDiffuseMap[_idx_], v_Texcoord);\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, texel2.rgb * intensity, texel2.a);\n albedoTexel.a = texel2.a + (1.0 - texel2.a) * albedoTexel.a;\n }}\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.main\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_EMISSIVEMAP_COUNT; _idx_++)\n {{\n vec4 texel2 = texture2D(layerEmissiveMap[_idx_], v_Texcoord) * layerEmissionIntensity[_idx_];\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n float intensity = layerEmissionIntensity[_idx_];\n gl_FragColor.rgb += texel2.rgb * texel2.a * intensity;\n }}\n#endif\n\n@end\n"},function(e,t,r){"use strict";t.a="@export ecgl.color.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\n@import ecgl.common.uv.header\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position: POSITION;\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvoid main()\n{\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n @import ecgl.common.uv.main\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n@export ecgl.color.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.layers.header\n\n@import ecgl.common.uv.fragmentHeader\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n\n}\n@end"},function(e,t,r){"use strict";t.a="/**\n * http: */\n\n@export ecgl.lambert.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n\n@import ecgl.common.attributes\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.vertexAnimation.header\n\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n}\n\n@end\n\n\n@export ecgl.lambert.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n gl_FragColor *= sRGBToLinear(v_Color);\n #else\n gl_FragColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n diffuseColor += ambientLightColor[i] * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"},function(e,t,r){"use strict";t.a="@export ecgl.realistic.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@import ecgl.common.vertexAnimation.header\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n\n\n@export ecgl.realistic.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n#define PI 3.14159265358979\n#define ROUGHNESS_CHANEL 0\n#define METALNESS_CHANEL 1\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\n\nuniform sampler2D detailMap;\nuniform sampler2D metalnessMap;\nuniform sampler2D roughnessMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform float metalness : 0.0;\nuniform float roughness : 0.5;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import clay.header.ambient_cubemap_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.normalMap.fragmentHeader\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import clay.util.rgbm\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nvoid main()\n{\n vec4 albedoColor = color;\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n albedoColor *= sRGBToLinear(v_Color);\n #else\n albedoColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n albedoColor *= albedoTexel;\n\n float m = metalness;\n\n#ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_DetailTexcoord)[METALNESS_CHANEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 specFactor = mix(vec3(0.04), baseColor, m);\n\n float g = 1.0 - roughness;\n\n#ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n@import ecgl.common.normalMap.fragmentMain\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseTerm = vec3(0.0);\n vec3 specularTerm = vec3(0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, specFactor);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_] * ambientFactor * ao;\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -directionalLightDirection[_idx_];\n vec3 lc = directionalLightColor[_idx_];\n\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, normalize(L)), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\n L = vec3(L.x, L[NORMAL_UP_AXIS], L[NORMAL_FRONT_AXIS]);\n float rough2 = clamp(1.0 - g, 0.0, 1.0);\n float bias2 = rough2 * 5.0;\n vec2 brdfParam2 = texture2D(ambientCubemapLightBRDFLookup[0], vec2(rough2, ndv)).xy;\n vec3 envWeight2 = specFactor * brdfParam2.x + brdfParam2.y;\n vec3 envTexel2;\n for(int _idx_ = 0; _idx_ < AMBIENT_CUBEMAP_LIGHT_COUNT; _idx_++)\n {{\n envTexel2 = RGBMDecode(textureCubeLodEXT(ambientCubemapLightCubemap[_idx_], L, bias2), 8.12);\n specularTerm += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2 * ao;\n }}\n#endif\n\n gl_FragColor.rgb = albedoColor.rgb * diffuseTerm + specularTerm;\n gl_FragColor.a = albedoColor.a;\n\n#ifdef SRGB_ENCODE\n gl_FragColor = linearTosRGB(gl_FragColor);\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"},function(e,t,r){"use strict";t.a="@export ecgl.hatching.vertex\n\n@import ecgl.realistic.vertex\n\n@end\n\n\n@export ecgl.hatching.fragment\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [0.0, 0.0, 0.0, 1.0];\nuniform vec4 paperColor : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nuniform sampler2D hatch1;\nuniform sampler2D hatch2;\nuniform sampler2D hatch3;\nuniform sampler2D hatch4;\nuniform sampler2D hatch5;\nuniform sampler2D hatch6;\n\nfloat shade(in float tone) {\n vec4 c = vec4(1. ,1., 1., 1.);\n float step = 1. / 6.;\n vec2 uv = v_DetailTexcoord;\n if (tone <= step / 2.0) {\n c = mix(vec4(0.), texture2D(hatch6, uv), 12. * tone);\n }\n else if (tone <= step) {\n c = mix(texture2D(hatch6, uv), texture2D(hatch5, uv), 6. * tone);\n }\n if(tone > step && tone <= 2. * step){\n c = mix(texture2D(hatch5, uv), texture2D(hatch4, uv) , 6. * (tone - step));\n }\n if(tone > 2. * step && tone <= 3. * step){\n c = mix(texture2D(hatch4, uv), texture2D(hatch3, uv), 6. * (tone - 2. * step));\n }\n if(tone > 3. * step && tone <= 4. * step){\n c = mix(texture2D(hatch3, uv), texture2D(hatch2, uv), 6. * (tone - 3. * step));\n }\n if(tone > 4. * step && tone <= 5. * step){\n c = mix(texture2D(hatch2, uv), texture2D(hatch1, uv), 6. * (tone - 4. * step));\n }\n if(tone > 5. * step){\n c = mix(texture2D(hatch1, uv), vec4(1.), 6. * (tone - 5. * step));\n }\n\n return c.r;\n}\n\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n vec4 inkColor = sRGBToLinear(color);\n#else\n vec4 inkColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n inkColor *= sRGBToLinear(v_Color);\n #else\n inkColor *= v_Color;\n #endif\n#endif\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float tone = 0.0;\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n tone += dot(ambientLightColor[i], w) * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n tone += dot(calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_], w) * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n float lightTone = dot(directionalLightColor[i], w);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n tone += lightTone * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor = mix(inkColor, paperColor, shade(clamp(tone, 0.0, 1.0)));\n }\n@end\n"},function(e,t,r){"use strict";t.a="@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end"},function(e,t,r){"use strict";function n(e,t){if(e&&e[t]&&(e[t].normal||e[t].emphasis)){var r=e[t].normal,n=e[t].emphasis;r&&(e[t]=r),n&&(e.emphasis=e.emphasis||{},e.emphasis[t]=n)}}function i(e){n(e,"itemStyle"),n(e,"lineStyle"),n(e,"areaStyle"),n(e,"label")}function a(e){e&&(e instanceof Array||(e=[e]),s.a.util.each(e,function(e){if(e.axisLabel){var t=e.axisLabel;s.a.util.extend(t,t.textStyle),t.textStyle=null}}))}var o=r(0),s=r.n(o),u=["bar3D","line3D","map3D","scatter3D","surface","lines3D","scatterGL","scatter3D"];t.a=function(e){s.a.util.each(e.series,function(t){s.a.util.indexOf(u,t.type)>=0&&(i(t),"mapbox"===t.coordinateSystem&&(t.coordinateSystem="mapbox3D",e.mapbox3D=e.mapbox))}),a(e.xAxis3D),a(e.yAxis3D),a(e.zAxis3D),a(e.grid3D),n(e.geo3D)}},function(e,t,r){"use strict";var n=(r(147),r(151),r(152),r(158),r(0)),i=r.n(n);i.a.registerAction({type:"grid3DChangeCamera",event:"grid3dcamerachanged",update:"series:updateCamera"},function(e,t){t.eachComponent({mainType:"grid3D",query:e},function(t){t.setView(e)})}),i.a.registerAction({type:"grid3DShowAxisPointer",event:"grid3dshowaxispointer",update:"grid3D:showAxisPointer"},function(e,t){}),i.a.registerAction({type:"grid3DHideAxisPointer",event:"grid3dhideaxispointer",update:"grid3D:hideAxisPointer"},function(e,t){})},function(e,t,r){"use strict";function n(e,t){return t.type||(t.data?"category":"value")}var i=r(0),a=r.n(i),o=r(148),s=a.a.extendComponentModel({type:"cartesian3DAxis",axis:null,getCoordSysModel:function(){return this.ecModel.queryComponents({mainType:"grid3D",index:this.option.gridIndex,id:this.option.gridId})[0]}});a.a.helper.mixinAxisModelCommonMethods(s),Object(o.a)("x",s,n,{name:"X"}),Object(o.a)("y",s,n,{name:"Y"}),Object(o.a)("z",s,n,{name:"Z"})},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(149),o=r(150),s=r.n(o),u=["value","category","time","log"];t.a=function(e,t,r,n){i.a.util.each(u,function(o){t.extend({type:e+"Axis3D."+o,__ordinalMeta:null,mergeDefaultAndTheme:function(t,n){var a=n.getTheme();i.a.util.merge(t,a.get(o+"Axis3D")),i.a.util.merge(t,this.getDefaultOption()),t.type=r(e,t)},optionUpdated:function(){"category"===this.option.type&&(this.__ordinalMeta=s.a.createByAxisModel(this))},getCategories:function(){if("category"===this.option.type)return this.__ordinalMeta.categories},getOrdinalMeta:function(){return this.__ordinalMeta},defaultOption:i.a.util.merge(i.a.util.clone(a.a[o+"Axis3D"]),n||{},!0)})}),t.superClass.registerSubTypeDefaulter(e+"Axis3D",i.a.util.curry(r,e))}},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a={show:!0,grid3DIndex:0,inverse:!1,name:"",nameLocation:"middle",nameTextStyle:{fontSize:16},nameGap:20,axisPointer:{},axisLine:{},axisTick:{},axisLabel:{},splitArea:{}},o=i.a.util.merge({boundaryGap:!0,axisTick:{alignWithLabel:!1,interval:"auto"},axisLabel:{interval:"auto"},axisPointer:{label:{show:!1}}},a),s=i.a.util.merge({boundaryGap:[0,0],splitNumber:5,axisPointer:{label:{}}},a),u=i.a.util.defaults({scale:!0,min:"dataMin",max:"dataMax"},s),l=i.a.util.defaults({logBase:10},s);l.scale=!0,t.a={categoryAxis3D:o,valueAxis3D:s,timeAxis3D:u,logAxis3D:l}},function(e,t,r){function n(e){this.categories=e.categories||[],this._needCollect=e.needCollect,this._deduplication=e.deduplication,this._map}function i(e){return e._map||(e._map=s(e.categories))}function a(e){return u(e)&&null!=e.value?e.value:e+""}var o=r(12),s=o.createHashMap,u=o.isObject,l=o.map;n.createByAxisModel=function(e){var t=e.option,r=t.data,i=r&&l(r,a);return new n({categories:i,needCollect:!i,deduplication:!1!==t.dedplication})};var c=n.prototype;c.getOrdinal=function(e){return i(this).get(e)},c.parseAndCollect=function(e){var t,r=this._needCollect;if("string"!=typeof e&&!r)return e;if(r&&!this._deduplication)return t=this.categories.length,this.categories[t]=e,t;var n=i(this);return t=n.get(e),null==t&&(r?(t=this.categories.length,this.categories[t]=e,n.set(e,t)):t=NaN),t};var h=n;e.exports=h},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(38),o=r(25),s=r(26),u=i.a.extendComponentModel({type:"grid3D",dependencies:["xAxis3D","yAxis3D","zAxis3D"],defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",boxWidth:100,boxHeight:100,boxDepth:100,axisPointer:{show:!0,lineStyle:{color:"rgba(0, 0, 0, 0.8)",width:1},label:{show:!0,formatter:null,margin:8,textStyle:{fontSize:14,color:"#fff",backgroundColor:"rgba(0,0,0,0.5)",padding:3,borderRadius:3}}},axisLine:{show:!0,lineStyle:{color:"#333",width:2,type:"solid"}},axisTick:{show:!0,inside:!1,length:3,lineStyle:{width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}},light:{main:{alpha:30,beta:40},ambient:{intensity:.4}},viewControl:{alpha:20,beta:40,autoRotate:!1,distance:200,minDistance:40,maxDistance:400}}});i.a.util.merge(u.prototype,a.a),i.a.util.merge(u.prototype,o.a),i.a.util.merge(u.prototype,s.a)},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(2),o=r(39),s=r(22),u=r(3),l=r(73),c=r(27),h=r(153),d=r(155),f=r(58),p=r(40),m=u.a.firstNotNull;a.a.Shader.import(p.a),["x","y","z"].forEach(function(e){i.a.extendComponentView({type:e+"Axis3D"})});var g={x:0,y:2,z:1};i.a.extendComponentView({type:"grid3D",__ecgl__:!0,init:function(e,t){var r=[["y","z","x",-1,"left"],["y","z","x",1,"right"],["x","y","z",-1,"bottom"],["x","y","z",1,"top"],["x","z","y",-1,"far"],["x","z","y",1,"near"]],n=["x","y","z"],i=new a.a.Material({shader:a.a.createShader("ecgl.color"),depthMask:!1,transparent:!0}),u=new a.a.Material({shader:a.a.createShader("ecgl.meshLines3D"),depthMask:!1,transparent:!0});i.define("fragment","DOUBLE_SIDED"),i.define("both","VERTEX_COLOR"),this.groupGL=new a.a.Node,this._control=new o.a({zr:t.getZr()}),this._control.init(),this._faces=r.map(function(e){var t=new h.a(e,u,i);return this.groupGL.add(t.rootNode),t},this),this._axes=n.map(function(e){var t=new d.a(e,u);return this.groupGL.add(t.rootNode),t},this);var p=t.getDevicePixelRatio();this._axisLabelSurface=new l.a({width:256,height:256,devicePixelRatio:p}),this._axisLabelSurface.onupdate=function(){t.getZr().refresh()},this._axisPointerLineMesh=new a.a.Mesh({geometry:new s.a({useNativeLine:!1}),material:u,castShadow:!1,ignorePicking:!0,renderOrder:3}),this.groupGL.add(this._axisPointerLineMesh),this._axisPointerLabelsSurface=new l.a({width:128,height:128,devicePixelRatio:p}),this._axisPointerLabelsMesh=new f.a({ignorePicking:!0,renderOrder:4,castShadow:!1}),this._axisPointerLabelsMesh.material.set("textureAtlas",this._axisPointerLabelsSurface.getTexture()),this.groupGL.add(this._axisPointerLabelsMesh),this._lightRoot=new a.a.Node,this._sceneHelper=new c.a,this._sceneHelper.initLight(this._lightRoot)},render:function(e,t,r){this._model=e,this._api=r;var n=e.coordinateSystem;n.viewGL.add(this._lightRoot),e.get("show")?n.viewGL.add(this.groupGL):n.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(n.viewGL);var a=e.getModel("viewControl");i.setFromViewControlModel(a,0),this._axisLabelSurface.clear();var o=["x","y","z"].reduce(function(t,r){var i=n.getAxis(r),a=i.model;return t[r]=m(a.get("axisLabel.interval"),e.get("axisLabel.interval")),"ordinal"===i.scale.type&&(null!=t[r]&&"auto"!=t[r]||(t[r]=Math.floor(i.scale.getTicks().length/8))),t},{});i.off("update"),e.get("show")&&(this._faces.forEach(function(n){n.update(o,e,t,r)},this),this._axes.forEach(function(t){t.update(e,o,this._axisLabelSurface,r)},this)),i.on("update",this._onCameraChange.bind(this,e,r),this),this._sceneHelper.setScene(n.viewGL.scene),this._sceneHelper.updateLight(e),n.viewGL.setPostEffect(e.getModel("postEffect"),r),n.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._initMouseHandler(e)},afterRender:function(e,t,r,n){var i=n.renderer;this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r)},showAxisPointer:function(e,t,r,n){this._doShowAxisPointer(),this._updateAxisPointer(n.value)},hideAxisPointer:function(e,t,r,n){this._doHideAxisPointer()},_initMouseHandler:function(e){var t=e.coordinateSystem,r=t.viewGL;e.get("show")&&e.get("axisPointer.show")?r.on("mousemove",this._updateAxisPointerOnMousePosition,this):r.off("mousemove",this._updateAxisPointerOnMousePosition)},_updateAxisPointerOnMousePosition:function(e){if(!e.target){for(var t,r=this._model,n=r.coordinateSystem,i=n.viewGL,o=i.castRay(e.offsetX,e.offsetY,new a.a.Ray),s=0;sn[1]?0:1,s=this._faces[2*r+o],u=this._faces[2*r+1-o];s.rootNode.invisible=!0,u.rootNode.invisible=!1}},_updateAxisLinePosition:function(){var e=this._model.coordinateSystem,t=e.getAxis("x"),r=e.getAxis("y"),n=e.getAxis("z"),i=n.getExtentMax(),a=n.getExtentMin(),o=t.getExtentMin(),s=t.getExtentMax(),u=r.getExtentMax(),l=r.getExtentMin(),c=this._axes[0].rootNode,h=this._axes[1].rootNode,d=this._axes[2].rootNode,f=this._faces,p=f[4].rootNode.invisible?l:u,m=f[2].rootNode.invisible?i:a,g=f[0].rootNode.invisible?o:s,_=f[2].rootNode.invisible?i:a,v=f[0].rootNode.invisible?s:o,y=f[4].rootNode.invisible?l:u;c.rotation.identity(),h.rotation.identity(),d.rotation.identity(),f[4].rootNode.invisible&&(this._axes[0].flipped=!0,c.rotation.rotateX(Math.PI)),f[0].rootNode.invisible&&(this._axes[1].flipped=!0,h.rotation.rotateZ(Math.PI)),f[4].rootNode.invisible&&(this._axes[2].flipped=!0,d.rotation.rotateY(Math.PI)),c.position.set(0,m,p),h.position.set(g,_,0),d.position.set(v,0,y),c.update(),h.update(),d.update(),this._updateAxisLabelAlign()},_updateAxisLabelAlign:function(){var e=this._control.getCamera(),t=[new a.a.Vector4,new a.a.Vector4],r=new a.a.Vector4;this.groupGL.getWorldPosition(r),r.w=1,r.transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),r.x/=r.w,r.y/=r.w,this._axes.forEach(function(n){for(var i=n.axisLineCoords,a=(n.labelsMesh.geometry,0);ar.y?"bottom":"top"):(s="middle",o=c>r.x?"left":"right"),n.setSpriteAlign(o,s,this._api)},this)},_doShowAxisPointer:function(){this._axisPointerLineMesh.invisible&&(this._axisPointerLineMesh.invisible=!1,this._axisPointerLabelsMesh.invisible=!1,this._api.getZr().refresh())},_doHideAxisPointer:function(){this._axisPointerLineMesh.invisible||(this._axisPointerLineMesh.invisible=!0,this._axisPointerLabelsMesh.invisible=!0,this._api.getZr().refresh())},_updateAxisPointer:function(e){function t(e){return u.a.firstNotNull(e.model.get("axisPointer.show"),l.get("show"))}function r(e){var t=e.model.getModel("axisPointer",l),r=t.getModel("lineStyle"),n=a.a.parseColor(r.get("color")),i=m(r.get("width"),1),o=m(r.get("opacity"),1);return n[3]*=o,{color:n,lineWidth:i}}var n=this._model.coordinateSystem,i=n.dataToPoint(e),o=this._axisPointerLineMesh,s=o.geometry,l=this._model.getModel("axisPointer"),c=this._api.getDevicePixelRatio();s.convertToDynamicArray(!0);for(var h=0;h0&&e.rotation.rotateY(Math.PI),t.normal.z=-n)}function i(e,t,r){this.rootNode=new s.a.Node;var n=new s.a.Mesh({geometry:new l.a({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:1}),i=new s.a.Mesh({geometry:new c.a,material:r,castShadow:!1,culling:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:0});this.rootNode.add(i),this.rootNode.add(n),this.faceInfo=e,this.plane=new s.a.Plane,this.linesMesh=n,this.quadsMesh=i}var a=r(0),o=r.n(a),s=r(2),u=r(3),l=r(22),c=r(154),h=r(74),d=u.a.firstNotNull,f={x:0,y:2,z:1};i.prototype.update=function(e,t,r,i){var a=t.coordinateSystem,o=[a.getAxis(this.faceInfo[0]),a.getAxis(this.faceInfo[1])],s=this.linesMesh.geometry,u=this.quadsMesh.geometry;s.convertToDynamicArray(!0),u.convertToDynamicArray(!0),this._updateSplitLines(s,o,t,e,i),this._udpateSplitAreas(u,o,t,e,i),s.convertToTypedArray(),u.convertToTypedArray();var l=a.getAxis(this.faceInfo[2]);n(this.rootNode,this.plane,l,this.faceInfo[3])},i.prototype._updateSplitLines=function(e,t,r,n,i){var a=i.getDevicePixelRatio();t.forEach(function(i,u){var l=i.model,c=t[1-u].getExtent();if(!i.scale.isBlank()){var f=l.getModel("splitLine",r.getModel("splitLine"));if(f.get("show")){var p=f.getModel("lineStyle"),m=p.get("color"),g=d(p.get("opacity"),1),_=d(p.get("width"),1),v=f.get("interval");null!=v&&"auto"!==v||(v=n[i.dim]),m=o.a.util.isArray(m)?m:[m];for(var y=i.getTicksCoords(),x=0,T=0;T65535?new Uint32Array(3*n):new Uint16Array(3*n))},getQuadVertexCount:function(){return 4},getQuadTriangleCount:function(){return 2},addQuad:function(){var e=l.create(),t=l.create(),r=l.create(),n=[0,3,1,3,2,1];return function(i,a){var o=this.attributes.position,s=this.attributes.normal,u=this.attributes.color;l.sub(e,i[1],i[0]),l.sub(t,i[2],i[1]),l.cross(r,e,t),l.normalize(r,r);for(var c=0;c<4;c++)o.set(this._vertexOffset+c,i[c]),u.set(this._vertexOffset+c,a),s.set(this._vertexOffset+c,r);for(var h=3*this._faceOffset,c=0;c<6;c++)this.indices[h+c]=n[c]+this._vertexOffset;this._vertexOffset+=4,this._faceOffset+=2}}()});a.a.util.defaults(c.prototype,o.a),t.a=c},function(e,t,r){"use strict";function n(e,t){var r=new o.a.Mesh({geometry:new s.a({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,renderOrder:2}),n=new l.a;n.material.depthMask=!1;var i=new o.a.Node;i.add(r),i.add(n),this.rootNode=i,this.dim=e,this.linesMesh=r,this.labelsMesh=n,this.axisLineCoords=null,this.labelElements=[]}var i=r(0),a=r.n(i),o=r(2),s=r(22),u=r(3),l=r(58),c=r(74),h=u.a.firstNotNull,d={x:0,y:2,z:1},f={x:"y",y:"x",z:"y"};n.prototype.update=function(e,t,r,n){var i=e.coordinateSystem,s=i.getAxis(this.dim),u=t[this.dim],l=this.linesMesh.geometry,p=this.labelsMesh.geometry;l.convertToDynamicArray(!0),p.convertToDynamicArray(!0);var m=s.model,g=s.getExtent(),_=n.getDevicePixelRatio(),v=m.getModel("axisLine",e.getModel("axisLine")),y=m.getModel("axisTick",e.getModel("axisTick")),x=m.getModel("axisLabel",e.getModel("axisLabel")),T=v.get("lineStyle.color");if(v.get("show")){var b=v.getModel("lineStyle"),w=[0,0,0],E=[0,0,0],S=d[s.dim];w[S]=g[0],E[S]=g[1],this.axisLineCoords=[w,E];var A=o.a.parseColor(T),M=h(b.get("width"),1),C=h(b.get("opacity"),1);A[3]*=C,l.addLine(w,E,A,M*_)}if(y.get("show")){var L=y.getModel("lineStyle"),D=o.a.parseColor(h(L.get("color"),T)),M=h(L.get("width"),1);D[3]*=h(L.get("opacity"),1);var N=s.getTicksCoords(),R=y.get("interval");null!=R&&"auto"!==R||(R=u);for(var P=y.get("length"),I=0;I65535?new Uint32Array(3*r):new Uint16Array(3*r))},setSpriteAlign:function(e,t,r,n,i){null==r&&(r="left"),null==n&&(n="top");var a,o,s,u;switch(i=i||0,r){case"left":a=i,s=t[0]+i;break;case"center":case"middle":a=-t[0]/2,s=t[0]/2;break;case"right":a=-t[0]-i,s=-i}switch(n){case"bottom":o=i,u=t[1]+i;break;case"middle":o=-t[1]/2,u=t[1]/2;break;case"top":o=-t[1]-i,u=-i}var l=4*e,c=this.attributes.offset;c.set(l,[a,u]),c.set(l+1,[s,u]),c.set(l+2,[s,o]),c.set(l+3,[a,o])},addSprite:function(e,t,r,n,i,a){var o=this._vertexOffset;this.setSprite(this._vertexOffset/4,e,t,r,n,i,a);for(var u=0;u1?"."+e[1]:""))}function i(e,t){return e=(e||"").toLowerCase().replace(/-(.)/g,function(e,t){return t.toUpperCase()}),t&&e&&(e=e.charAt(0).toUpperCase()+e.slice(1)),e}function a(e){return String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function o(e,t,r){d.isArray(t)||(t=[t]);var n=t.length;if(!n)return"";for(var i=t[0].$vars||[],o=0;o':'':""}function l(e,t){return e+="","0000".substr(0,t-e.length)+e}function c(e,t,r){"week"!==e&&"month"!==e&&"quarter"!==e&&"half-year"!==e&&"year"!==e||(e="MM-dd\nyyyy");var n=p.parseDate(t),i=r?"UTC":"",a=n["get"+i+"FullYear"](),o=n["get"+i+"Month"]()+1,s=n["get"+i+"Date"](),u=n["get"+i+"Hours"](),c=n["get"+i+"Minutes"](),h=n["get"+i+"Seconds"](),d=n["get"+i+"Milliseconds"]();return e=e.replace("MM",l(o,2)).replace("M",o).replace("yyyy",a).replace("yy",a%100).replace("dd",l(s,2)).replace("d",s).replace("hh",l(u,2)).replace("h",u).replace("mm",l(c,2)).replace("m",c).replace("ss",l(h,2)).replace("s",h).replace("SSS",l(d,3))}function h(e){return e?e.charAt(0).toUpperCase()+e.substr(1):e}var d=r(12),f=r(163),p=r(78),m=d.normalizeCssArray,g=["a","b","c","d","e","f","g"],_=function(e,t){return"{"+e+(null==t?"":t)+"}"},v=f.truncateText,y=f.getBoundingRect;t.addCommas=n,t.toCamelCase=i,t.normalizeCssArray=m,t.encodeHTML=a,t.formatTpl=o,t.formatTplSimple=s,t.getTooltipMarker=u,t.formatTime=c,t.capitalFirst=h,t.truncateText=v,t.getTextRect=y},function(e,t,r){function n(e,t){I[e]=t}function i(e,t){t=t||P;var r=e+":"+t;if(L[r])return L[r];for(var n=(e+"").split("\n"),i=0,a=0,o=n.length;aN&&(D=0,L={}),D++,L[r]=i,i}function a(e,t,r,n,i,a,u){return a?s(e,t,r,n,i,a,u):o(e,t,r,n,i,u)}function o(e,t,r,n,a,o){var s=_(e,t,a,o),c=i(e,t);a&&(c+=a[1]+a[3]);var h=s.outerHeight,d=u(0,c,r),f=l(0,h,n),p=new T(d,f,c,h);return p.lineHeight=s.lineHeight,p}function s(e,t,r,n,i,a,o){var s=v(e,{rich:a,truncate:o,font:t,textAlign:r,textPadding:i}),c=s.outerWidth,h=s.outerHeight,d=u(0,c,r),f=l(0,h,n);return new T(d,f,c,h)}function u(e,t,r){return"right"===r?e-=t:"center"===r&&(e-=t/2),e}function l(e,t,r){return"middle"===r?e-=t/2:"bottom"===r&&(e-=t),e}function c(e,t,r){var n=t.x,i=t.y,a=t.height,o=t.width,s=a/2,u="left",l="top";switch(e){case"left":n-=r,i+=s,u="right",l="middle";break;case"right":n+=r+o,i+=s,l="middle";break;case"top":n+=o/2,i-=r,u="center",l="bottom";break;case"bottom":n+=o/2,i+=a+r,u="center";break;case"inside":n+=o/2,i+=s,u="center",l="middle";break;case"insideLeft":n+=r,i+=s,l="middle";break;case"insideRight":n+=o-r,i+=s,u="right",l="middle";break;case"insideTop":n+=o/2,i+=r,u="center";break;case"insideBottom":n+=o/2,i+=a-r,u="center",l="bottom";break;case"insideTopLeft":n+=r,i+=r;break;case"insideTopRight":n+=o-r,i+=r,u="right";break;case"insideBottomLeft":n+=r,i+=a-r,l="bottom";break;case"insideBottomRight":n+=o-r,i+=a-r,u="right",l="bottom"}return{x:n,y:i,textAlign:u,textVerticalAlign:l}}function h(e,t,r,n,i){if(!t)return"";var a=(e+"").split("\n");i=d(t,r,n,i);for(var o=0,s=a.length;o=o;u++)s-=o;var l=i(r);return l>s&&(r="",l=0),s=e-l,n.ellipsis=r,n.ellipsisWidth=l,n.contentWidth=s,n.containerWidth=e,n}function f(e,t){var r=t.containerWidth,n=t.font,a=t.contentWidth;if(!r)return"";var o=i(e,n);if(o<=r)return e;for(var s=0;;s++){if(o<=a||s>=t.maxIterations){e+=t.ellipsis;break}var u=0===s?p(e,a,t.ascCharWidth,t.cnCharWidth):o>0?Math.floor(e.length*a/o):0;e=e.substr(0,u),o=i(e,n)}return""===e&&(e=t.placeholder),e}function p(e,t,r,n){for(var i=0,a=0,o=e.length;au)e="",a=[];else if(null!=l)for(var c=d(l-(r?r[1]+r[3]:0),t,n.ellipsis,{minChar:n.minChar,placeholder:n.placeholder}),h=0,p=a.length;ha&&y(r,e.substring(a,o)),y(r,n[2],n[1]),a=R.lastIndex}ag)return{lines:[],width:0,height:0};E.textWidth=i(E.text,L);var N=S.textWidth,P=null==N||"auto"===N;if("string"==typeof N&&"%"===N.charAt(N.length-1))E.percentWidth=N,c.push(E),N=0;else{if(P){N=E.textWidth;var I=S.textBackgroundColor,O=I&&I.image;O&&(O=b.findExistImage(O),b.isImageReady(O)&&(N=Math.max(N,O.width*D/O.height)))}var F=C?C[1]+C[3]:0;N+=F;var B=null!=p?p-T:null;null!=B&&B4){console.warn("Support at most 4 cascade");continue}m.shadowCascade>1&&(s=m),this.renderDirectionalLightShadow(e,t,r,m,d,h,c)}else"SPOT_LIGHT"===m.type?this.renderSpotLightShadow(e,t,m,l,u):"POINT_LIGHT"===m.type&&this.renderPointLightShadow(e,t,m,f);this._shadowMapNumber[m.type]++}for(var g in this._shadowMapNumber)for(var _=this._shadowMapNumber[g],v=g+"_SHADOWMAP_COUNT",p=0;p0?x.define("fragment",v,_):x.isDefined("fragment",v)&&x.undefine("fragment",v))}for(var p=0;p0){var b=c.map(i);if(T.directionalLightShadowMaps={value:c,type:"tv"},T.directionalLightMatrices={value:h,type:"m4v"},T.directionalLightShadowMapSizes={value:b,type:"1fv"},s){var w=d.slice(),E=d.slice();w.pop(),E.shift(),w.reverse(),E.reverse(),h.reverse(),T.shadowCascadeClipsNear={value:w,type:"1fv"},T.shadowCascadeClipsFar={value:E,type:"1fv"}}}if(u.length>0){var S=u.map(i),T=t.shadowUniforms;T.spotLightShadowMaps={value:u,type:"tv"},T.spotLightMatrices={value:l,type:"m4v"},T.spotLightShadowMapSizes={value:S,type:"1fv"}}f.length>0&&(T.pointLightShadowMaps={value:f,type:"tv"})}},renderDirectionalLightShadow:function(){var e=new s.a,t=new u.a,r=new o.a,n=new u.a,i=new u.a,a=new u.a,c=new u.a;return function(o,s,h,d,f,p,m){var _=this._getDepthMaterial(d),v={getMaterial:function(e){return e.shadowDepthMaterial||_},ifRender:function(e){return e.castShadow},sortCompare:l.a.opaqueSortCompare};if(!s.viewBoundingBoxLastFrame.isFinite()){var y=s.getBoundingBox();s.viewBoundingBoxLastFrame.copy(y).applyTransform(h.viewMatrix)}var x=Math.min(-s.viewBoundingBoxLastFrame.min.z,h.far),T=Math.max(-s.viewBoundingBoxLastFrame.max.z,h.near),b=this._getDirectionalLightCamera(d,s,h),E=a.array;c.copy(b.projectionMatrix),w.invert(i.array,b.worldTransform.array),w.multiply(i.array,i.array,h.worldTransform.array),w.multiply(E,c.array,i.array);for(var A=[],M=h instanceof g.a,C=(h.near+h.far)/(h.near-h.far),L=2*h.near*h.far/(h.near-h.far),D=0;D<=d.shadowCascade;D++){var N=T*Math.pow(x/T,D/d.shadowCascade),R=T+(x-T)*D/d.shadowCascade,P=N*d.cascadeSplitLogFactor+R*(1-d.cascadeSplitLogFactor);A.push(P),f.push(-(-P*C+L)/-P)}var I=this._getTexture(d,d.shadowCascade);m.push(I);var O=o.viewport,F=o.gl;this._frameBuffer.attach(I),this._frameBuffer.bind(o),F.clear(F.COLOR_BUFFER_BIT|F.DEPTH_BUFFER_BIT);for(var D=0;Du?s>l?_[i>0?"px":"nx"]=!0:_[o>0?"pz":"nz"]=!0:u>l?_[a>0?"py":"ny"]=!0:_[o>0?"pz":"nz"]=!0}for(var r=0;r=0||(this.nodes.push(e),this._dirty=!0)},removeNode:function(e){"string"==typeof e&&(e=this.getNodeByName(e));var t=this.nodes.indexOf(e);t>=0&&(this.nodes.splice(t,1),this._dirty=!0)},getNodeByName:function(e){for(var t=0;t=t.COLOR_ATTACHMENT0&&l<=t.COLOR_ATTACHMENT0+8&&h.push(l);c.drawBuffersEXT(h)}e.saveClear(),e.clearBit=i.a.DEPTH_BUFFER_BIT|i.a.COLOR_BUFFER_BIT,r=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),e.restoreClear(),n.unbind(e)}else r=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",r),this._rendering=!1,this._rendered=!0}});t.a=o},function(e,t,r){"use strict";var n=r(42),i=n.a.extend(function(){return{texture:null,outputs:{color:{}}}},function(){},{getOutput:function(e,t){return this.texture},beforeFrame:function(){},afterFrame:function(){}});t.a=i},function(e,t,r){"use strict";var n=r(14),i=r(42),a=i.a.extend(function(){return{name:"",inputs:{},outputs:null,shader:"",inputLinks:{},outputLinks:{},pass:null,_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}},function(){var e=new n.a({fragment:this.shader});this.pass=e},{render:function(e,t){this.trigger("beforerender",e),this._rendering=!0;var r=e.gl;for(var n in this.inputLinks){var i=this.inputLinks[n],a=i.node.getOutput(e,i.pin);this.pass.setUniform(n,a)}if(this.outputs){this.pass.outputs={};var o={};for(var s in this.outputs){var u=this.updateParameter(s,e);isNaN(u.width)&&this.updateParameter(s,e);var l=this.outputs[s],c=this._compositor.allocateTexture(u);this._outputTextures[s]=c;var h=l.attachment||r.COLOR_ATTACHMENT0;"string"==typeof h&&(h=r[h]),o[h]=c}this._compositor.getFrameBuffer().bind(e);for(var h in o)this._compositor.getFrameBuffer().attach(o[h],h);this.pass.render(e),this._compositor.getFrameBuffer().updateMipmap(e.gl)}else this.pass.outputs=null,this._compositor.getFrameBuffer().unbind(e),this.pass.render(e,t);for(var n in this.inputLinks){var i=this.inputLinks[n];i.node.removeReference(i.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",e)},updateParameter:function(e,t){var r=this.outputs[e],n=r.parameters,i=r._parametersCopy;if(i||(i=r._parametersCopy={}),n)for(var a in n)"width"!==a&&"height"!==a&&(i[a]=n[a]);var o,s;return o=n.width instanceof Function?n.width.call(this,t):n.width,s=n.height instanceof Function?n.height.call(this,t):n.height,i.width===o&&i.height===s||this._outputTextures[e]&&this._outputTextures[e].dispose(t),i.width=o,i.height=s,i},setParameter:function(e,t){this.pass.setUniform(e,t)},getParameter:function(e){return this.pass.getUniform(e)},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},define:function(e,t){this.pass.material.define("fragment",e,t)},undefine:function(e){this.pass.material.undefine("fragment",e)},removeReference:function(e){if(0===--this._outputReferences[e]){this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}},clear:function(){i.a.prototype.clear.call(this),this.pass.material.disableTexturesAll()}});t.a=a},function(e,t,r){"use strict";var n=r(8),i=r(176),a=r(80),o=r(177),s=r(81),u=r(178),l=r(82),c=r(83),h=r(84),d=r(85),f=r(86),p=r(179),m=r(180),g=r(87),_=r(88);n.a.import(i.a),n.a.import(a.a),n.a.import(o.a),n.a.import(s.a),n.a.import(u.a),n.a.import(l.a),n.a.import(c.a),n.a.import(h.a),n.a.import(d.a),n.a.import(f.a),n.a.import(p.a),n.a.import(m.a),n.a.import(g.a),n.a.import(_.a)},function(e,t,r){"use strict";t.a="@export clay.compositor.coloradjust\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float exposure : 0.0;\nuniform float gamma : 1.0;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = clamp(tex.rgb + vec3(brightness), 0.0, 1.0);\n color = clamp( (color-vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n color = clamp( color * pow(2.0, exposure), 0.0, 1.0);\n color = clamp( pow(color, vec3(gamma)), 0.0, 1.0);\n float luminance = dot( color, w );\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.brightness\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = tex.rgb + vec3(brightness);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.contrast\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float contrast : 1.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = (tex.rgb-vec3(0.5))*contrast+vec3(0.5);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.exposure\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float exposure : 0.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb * pow(2.0, exposure);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.gamma\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float gamma : 1.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = pow(tex.rgb, vec3(gamma));\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.saturation\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb;\n float luminance = dot(color, w);\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end"},function(e,t,r){"use strict";t.a="@export clay.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n float luminance = dot(tex.rgb, w);\n luminance = log(luminance + 0.001);\n gl_FragColor = encodeHDR(vec4(vec3(luminance), 1.0));\n}\n@end\n@export clay.compositor.hdr.lum_adaption\nvarying vec2 v_Texcoord;\nuniform sampler2D adaptedLum;\nuniform sampler2D currentLum;\nuniform float frameTime : 0.02;\n@import clay.util.rgbm\nvoid main()\n{\n float fAdaptedLum = decodeHDR(texture2D(adaptedLum, vec2(0.5, 0.5))).r;\n float fCurrentLum = exp(encodeHDR(texture2D(currentLum, vec2(0.5, 0.5))).r);\n fAdaptedLum += (fCurrentLum - fAdaptedLum) * (1.0 - pow(0.98, 30.0 * frameTime));\n gl_FragColor = encodeHDR(vec4(vec3(fAdaptedLum), 1.0));\n}\n@end\n@export clay.compositor.lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord );\n float luminance = dot(tex.rgb, w);\n gl_FragColor = vec4(vec3(luminance), 1.0);\n}\n@end"},function(e,t,r){"use strict";t.a="@export clay.compositor.vignette\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float darkness: 1;\nuniform float offset: 1;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = texel.rgb;\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(offset);\n gl_FragColor = encodeHDR(vec4(mix(texel.rgb, vec3(1.0 - darkness), dot(uv, uv)), texel.a));\n}\n@end"},function(e,t,r){"use strict";t.a="@export clay.compositor.dof.coc\nuniform sampler2D depth;\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\nuniform float focalDist: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\nvarying vec2 v_Texcoord;\n@import clay.util.encode_float\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n float aperture = focalLength / fstop;\n float coc;\n float uppper = focalDist + focalRange;\n float lower = focalDist - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 0.4) / 0.4000001;\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n gl_FragColor = encodeFloat(coc);\n}\n@end\n@export clay.compositor.dof.premultiply\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.decode_float\nvoid main() {\n float fCoc = max(abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0), 0.1);\n gl_FragColor = encodeHDR(\n vec4(decodeHDR(texture2D(texture, v_Texcoord)).rgb * fCoc, 1.0)\n );\n}\n@end\n@export clay.compositor.dof.min_coc\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform vec2 textureSize : [512.0, 512.0];\n@import clay.util.float\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord + d.xy));\n fCoc = min(fCoc, decodeFloat(texture2D(coc, v_Texcoord + d.zy)));\n fCoc = min(fCoc, decodeFloat(texture2D(coc, v_Texcoord + d.xw)));\n fCoc = min(fCoc, decodeFloat(texture2D(coc, v_Texcoord + d.zw)));\n gl_FragColor = encodeFloat(fCoc);\n}\n@end\n@export clay.compositor.dof.max_coc\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform vec2 textureSize : [512.0, 512.0];\n@import clay.util.float\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord + d.xy));\n fCoc = max(fCoc, decodeFloat(texture2D(coc, v_Texcoord + d.zy)));\n fCoc = max(fCoc, decodeFloat(texture2D(coc, v_Texcoord + d.xw)));\n fCoc = max(fCoc, decodeFloat(texture2D(coc, v_Texcoord + d.zw)));\n gl_FragColor = encodeFloat(fCoc);\n}\n@end\n@export clay.compositor.dof.coc_upsample\n#define HIGH_QUALITY\nuniform sampler2D coc;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.float\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n float s;\n s = decodeFloat(texture2D(coc, v_Texcoord - d.xy));\n s += decodeFloat(texture2D(coc, v_Texcoord - d.wy)) * 2.0;\n s += decodeFloat(texture2D(coc, v_Texcoord - d.zy));\n s += decodeFloat(texture2D(coc, v_Texcoord + d.zw)) * 2.0;\n s += decodeFloat(texture2D(coc, v_Texcoord )) * 4.0;\n s += decodeFloat(texture2D(coc, v_Texcoord + d.xw)) * 2.0;\n s += decodeFloat(texture2D(coc, v_Texcoord + d.zy));\n s += decodeFloat(texture2D(coc, v_Texcoord + d.wy)) * 2.0;\n s += decodeFloat(texture2D(coc, v_Texcoord + d.xy));\n gl_FragColor = encodeFloat(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n float s;\n s = decodeFloat(texture2D(coc, v_Texcoord + d.xy));\n s += decodeFloat(texture2D(coc, v_Texcoord + d.zy));\n s += decodeFloat(texture2D(coc, v_Texcoord + d.xw));\n s += decodeFloat(texture2D(coc, v_Texcoord + d.zw));\n gl_FragColor = encodeFloat(s / 4.0);\n#endif\n}\n@end\n@export clay.compositor.dof.upsample\n#define HIGH_QUALITY\nuniform sampler2D coc;\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.decode_float\nfloat tap(vec2 uv, inout vec4 color, float baseWeight) {\n float weight = abs(decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0) * baseWeight;\n color += decodeHDR(texture2D(texture, uv)) * weight;\n return weight;\n}\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 color = vec4(0.0);\n float baseWeight = 1.0 / 16.0;\n float w = tap(v_Texcoord - d.xy, color, baseWeight);\n w += tap(v_Texcoord - d.wy, color, baseWeight * 2.0);\n w += tap(v_Texcoord - d.zy, color, baseWeight);\n w += tap(v_Texcoord + d.zw, color, baseWeight * 2.0);\n w += tap(v_Texcoord , color, baseWeight * 4.0);\n w += tap(v_Texcoord + d.xw, color, baseWeight * 2.0);\n w += tap(v_Texcoord + d.zy, color, baseWeight);\n w += tap(v_Texcoord + d.wy, color, baseWeight * 2.0);\n w += tap(v_Texcoord + d.xy, color, baseWeight);\n gl_FragColor = encodeHDR(color / w);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 color = vec4(0.0);\n float baseWeight = 1.0 / 4.0;\n float w = tap(v_Texcoord + d.xy, color, baseWeight);\n w += tap(v_Texcoord + d.zy, color, baseWeight);\n w += tap(v_Texcoord + d.xw, color, baseWeight);\n w += tap(v_Texcoord + d.zw, color, baseWeight);\n gl_FragColor = encodeHDR(color / w);\n#endif\n}\n@end\n@export clay.compositor.dof.downsample\nuniform sampler2D texture;\nuniform sampler2D coc;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.decode_float\nfloat tap(vec2 uv, inout vec4 color) {\n float weight = abs(decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0) * 0.25;\n color += decodeHDR(texture2D(texture, uv)) * weight;\n return weight;\n}\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n vec4 color = vec4(0.0);\n float weight = tap(v_Texcoord + d.xy, color);\n weight += tap(v_Texcoord + d.zy, color);\n weight += tap(v_Texcoord + d.xw, color);\n weight += tap(v_Texcoord + d.zw, color);\n color /= weight;\n gl_FragColor = encodeHDR(color);\n}\n@end\n@export clay.compositor.dof.hexagonal_blur_frag\n@import clay.util.float\nvec4 doBlur(sampler2D targetTexture, vec2 offset) {\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n float weightSum = 0.0;\n float kernelWeight = 1.0 / float(KERNEL_SIZE);\n for (int i = 0; i < KERNEL_SIZE; i++) {\n vec2 coord = v_Texcoord + offset * float(i);\n float w = kernelWeight;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texture2D(targetTexture, coord)) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n float fCoc = decodeFloat(texture2D(coc, coord)) * 2.0 - 1.0;\n vec4 texel = texture2D(targetTexture, coord);\n #if !defined(BLUR_NEARFIELD)\n w *= abs(fCoc);\n #endif\n color += decodeHDR(texel) * w;\n#endif\n weightSum += w;\n }\n#ifdef BLUR_COC\n return encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n return color / weightSum;\n#endif\n}\n@end\n@export clay.compositor.dof.hexagonal_blur_1\n#define KERNEL_SIZE 5\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform float blurSize : 1.0;\nuniform vec2 textureSize : [512.0, 512.0];\n@import clay.util.rgbm\n@import clay.compositor.dof.hexagonal_blur_frag\nvoid main()\n{\n vec2 offset = blurSize / textureSize;\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n gl_FragColor = doBlur(texture, vec2(0.0, offset.y));\n#if !defined(BLUR_COC)\n gl_FragColor = encodeHDR(gl_FragColor);\n#endif\n}\n@end\n@export clay.compositor.dof.hexagonal_blur_2\n#define KERNEL_SIZE 5\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform float blurSize : 1.0;\nuniform vec2 textureSize : [512.0, 512.0];\n@import clay.util.rgbm\n@import clay.compositor.dof.hexagonal_blur_frag\nvoid main()\n{\n vec2 offset = blurSize / textureSize;\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n offset.y /= 2.0;\n gl_FragColor = doBlur(texture, -offset);\n#if !defined(BLUR_COC)\n gl_FragColor = encodeHDR(gl_FragColor);\n#endif\n}\n@end\n@export clay.compositor.dof.hexagonal_blur_3\n#define KERNEL_SIZE 5\nuniform sampler2D texture1;\nuniform sampler2D texture2;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform float blurSize : 1.0;\nuniform vec2 textureSize : [512.0, 512.0];\n@import clay.util.rgbm\n@import clay.compositor.dof.hexagonal_blur_frag\nvoid main()\n{\n vec2 offset = blurSize / textureSize;\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n offset.y /= 2.0;\n vec2 vDownRight = vec2(offset.x, -offset.y);\n vec4 texel1 = doBlur(texture1, -offset);\n vec4 texel2 = doBlur(texture1, vDownRight);\n vec4 texel3 = doBlur(texture2, vDownRight);\n#ifdef BLUR_COC\n float coc1 = decodeFloat(texel1) * 2.0 - 1.0;\n float coc2 = decodeFloat(texel2) * 2.0 - 1.0;\n float coc3 = decodeFloat(texel3) * 2.0 - 1.0;\n gl_FragColor = encodeFloat(\n ((coc1 + coc2 + coc3) / 3.0) * 0.5 + 0.5\n );\n#else\n vec4 color = (texel1 + texel2 + texel3) / 3.0;\n gl_FragColor = encodeHDR(color);\n#endif\n}\n@end\n@export clay.compositor.dof.composite\n#define DEBUG 0\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.float\nvoid main()\n{\n vec4 blurredColor = decodeHDR(texture2D(blurred, v_Texcoord));\n vec4 originalColor = decodeHDR(texture2D(original, v_Texcoord));\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n fCoc = abs(fCoc * 2.0 - 1.0);\n float weight = smoothstep(0.0, 1.0, fCoc);\n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = decodeHDR(texture2D(nearfield, v_Texcoord));\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n#if DEBUG == 1\n gl_FragColor = vec4(vec3(fCoc), 1.0);\n#elif DEBUG == 2\n gl_FragColor = vec4(vec3(fNearCoc), 1.0);\n#elif DEBUG == 3\n gl_FragColor = encodeHDR(blurredColor);\n#elif DEBUG == 4\n gl_FragColor = encodeHDR(nearfieldColor);\n#endif\n}\n@end"},function(e,t,r){"use strict";t.a="@export clay.compositor.lensflare\n#define SAMPLE_NUMBER 8\nuniform sampler2D texture;\nuniform sampler2D lenscolor;\nuniform vec2 textureSize : [512, 512];\nuniform float dispersal : 0.3;\nuniform float haloWidth : 0.4;\nuniform float distortion : 1.0;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvec4 textureDistorted(\n in vec2 texcoord,\n in vec2 direction,\n in vec3 distortion\n) {\n return vec4(\n decodeHDR(texture2D(texture, texcoord + direction * distortion.r)).r,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.g)).g,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.b)).b,\n 1.0\n );\n}\nvoid main()\n{\n vec2 texcoord = -v_Texcoord + vec2(1.0); vec2 textureOffset = 1.0 / textureSize;\n vec2 ghostVec = (vec2(0.5) - texcoord) * dispersal;\n vec2 haloVec = normalize(ghostVec) * haloWidth;\n vec3 distortion = vec3(-textureOffset.x * distortion, 0.0, textureOffset.x * distortion);\n vec4 result = vec4(0.0);\n for (int i = 0; i < SAMPLE_NUMBER; i++)\n {\n vec2 offset = fract(texcoord + ghostVec * float(i));\n float weight = length(vec2(0.5) - offset) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n }\n result *= texture2D(lenscolor, vec2(length(vec2(0.5) - texcoord)) / length(vec2(0.5)));\n float weight = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n vec2 offset = fract(texcoord + haloVec);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n gl_FragColor = result;\n}\n@end"},function(e,t,r){"use strict";function n(e){for(var t=new Uint8Array(e*e*4),r=0,n=new u.a,i=0;i=1?.95:0,weight2:n>=1?.05:1}),p.render(e)),c.attach(u),d.setUniform("texture",this._physicallyCorrect?this._currentTexture:s),d.render(e),c.attach(l),f.setUniform("texture",u),f.render(e),c.unbind(e),this._physicallyCorrect){var v=this._prevTexture;this._prevTexture=this._currentTexture,this._currentTexture=v}},n.prototype.getTargetTexture=function(){return this._texture3},n.prototype.setParameter=function(e,t){"maxIteration"===e?this._ssrPass.material.define("fragment","MAX_ITERATION",t):this._ssrPass.setUniform(e,t)},n.prototype.setPhysicallyCorrect=function(e){e?(this._normalDistribution||(this._normalDistribution=c.a.generateNormalDistribution(64,this._totalSamples)),this._ssrPass.material.define("fragment","PHYSICALLY_CORRECT"),this._ssrPass.material.set("normalDistribution",this._normalDistribution),this._ssrPass.material.set("normalDistributionSize",[64,this._totalSamples])):this._ssrPass.material.undefine("fragment","PHYSICALLY_CORRECT"),this._physicallyCorrect=e},n.prototype.setSSAOTexture=function(e){var t=this._blurPass2;e?(t.material.enableTexture("ssaoTex"),t.material.set("ssaoTex",e)):t.material.disableTexture("ssaoTex")},n.prototype.isFinished=function(e){return!this._physicallyCorrect||e>this._totalSamples/this._samplePerFrame},n.prototype.dispose=function(e){this._ssrTexture.dispose(e),this._texture2.dispose(e),this._texture3.dispose(e),this._prevTexture.dispose(e),this._currentTexture.dispose(e),this._frameBuffer.dispose(e)},t.a=n},function(e,t,r){"use strict";t.a="@export ecgl.ssr.main\n\n#define SHADER_NAME SSR\n#define MAX_ITERATION 20;\n#define SAMPLE_PER_FRAME 5;\n#define TOTAL_SAMPLES 128;\n\nuniform sampler2D sourceTexture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform sampler2D gBufferTexture3;\nuniform samplerCube specularCubemap;\nuniform float specularIntensity: 1;\n\nuniform mat4 projection;\nuniform mat4 projectionInv;\nuniform mat4 toViewSpace;\nuniform mat4 toWorldSpace;\n\nuniform float maxRayDistance: 200;\n\nuniform float pixelStride: 16;\nuniform float pixelStrideZCutoff: 50; \nuniform float screenEdgeFadeStart: 0.9; \nuniform float eyeFadeStart : 0.2; uniform float eyeFadeEnd: 0.8; \nuniform float minGlossiness: 0.2; uniform float zThicknessThreshold: 1;\n\nuniform float nearZ;\nuniform vec2 viewportSize : VIEWPORT_SIZE;\n\nuniform float jitterOffset: 0;\n\nvarying vec2 v_Texcoord;\n\n#ifdef DEPTH_DECODE\n@import clay.util.decode_float\n#endif\n\n#ifdef PHYSICALLY_CORRECT\nuniform sampler2D normalDistribution;\nuniform float sampleOffset: 0;\nuniform vec2 normalDistributionSize;\n\nvec3 transformNormal(vec3 H, vec3 N) {\n vec3 upVector = N.y > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvec3 importanceSampleNormalGGX(float i, float roughness, vec3 N) {\n float p = fract((i + sampleOffset) / float(TOTAL_SAMPLES));\n vec3 H = texture2D(normalDistribution,vec2(roughness, p)).rgb;\n return transformNormal(H, N);\n}\nfloat G_Smith(float g, float ndv, float ndl) {\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n#endif\n\nfloat fetchDepth(sampler2D depthTexture, vec2 uv)\n{\n vec4 depthTexel = texture2D(depthTexture, uv);\n return depthTexel.r * 2.0 - 1.0;\n}\n\nfloat linearDepth(float depth)\n{\n if (projection[3][3] == 0.0) {\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n }\n else {\n return (depth - projection[3][2]) / projection[2][2];\n }\n}\n\nbool rayIntersectDepth(float rayZNear, float rayZFar, vec2 hitPixel)\n{\n if (rayZFar > rayZNear)\n {\n float t = rayZFar; rayZFar = rayZNear; rayZNear = t;\n }\n float cameraZ = linearDepth(fetchDepth(gBufferTexture2, hitPixel));\n return rayZFar <= cameraZ && rayZNear >= cameraZ - zThicknessThreshold;\n}\n\n\nbool traceScreenSpaceRay(\n vec3 rayOrigin, vec3 rayDir, float jitter,\n out vec2 hitPixel, out vec3 hitPoint, out float iterationCount\n)\n{\n float rayLength = ((rayOrigin.z + rayDir.z * maxRayDistance) > -nearZ)\n ? (-nearZ - rayOrigin.z) / rayDir.z : maxRayDistance;\n\n vec3 rayEnd = rayOrigin + rayDir * rayLength;\n\n vec4 H0 = projection * vec4(rayOrigin, 1.0);\n vec4 H1 = projection * vec4(rayEnd, 1.0);\n\n float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\n\n vec3 Q0 = rayOrigin * k0, Q1 = rayEnd * k1;\n\n vec2 P0 = (H0.xy * k0 * 0.5 + 0.5) * viewportSize;\n vec2 P1 = (H1.xy * k1 * 0.5 + 0.5) * viewportSize;\n\n P1 += dot(P1 - P0, P1 - P0) < 0.0001 ? 0.01 : 0.0;\n vec2 delta = P1 - P0;\n\n bool permute = false;\n if (abs(delta.x) < abs(delta.y)) {\n permute = true;\n delta = delta.yx;\n P0 = P0.yx;\n P1 = P1.yx;\n }\n float stepDir = sign(delta.x);\n float invdx = stepDir / delta.x;\n\n vec3 dQ = (Q1 - Q0) * invdx;\n float dk = (k1 - k0) * invdx;\n\n vec2 dP = vec2(stepDir, delta.y * invdx);\n\n float strideScaler = 1.0 - min(1.0, -rayOrigin.z / pixelStrideZCutoff);\n float pixStride = 1.0 + strideScaler * pixelStride;\n\n dP *= pixStride; dQ *= pixStride; dk *= pixStride;\n\n vec4 pqk = vec4(P0, Q0.z, k0);\n vec4 dPQK = vec4(dP, dQ.z, dk);\n\n pqk += dPQK * jitter;\n float rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n float rayZNear;\n\n bool intersect = false;\n\n vec2 texelSize = 1.0 / viewportSize;\n\n iterationCount = 0.0;\n\n for (int i = 0; i < MAX_ITERATION; i++)\n {\n pqk += dPQK;\n\n rayZNear = rayZFar;\n rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n\n hitPixel = permute ? pqk.yx : pqk.xy;\n hitPixel *= texelSize;\n\n intersect = rayIntersectDepth(rayZNear, rayZFar, hitPixel);\n\n iterationCount += 1.0;\n\n dPQK *= 1.2;\n\n if (intersect) {\n break;\n }\n }\n\n Q0.xy += dQ.xy * iterationCount;\n Q0.z = pqk.z;\n hitPoint = Q0 / pqk.w;\n\n return intersect;\n}\n\nfloat calculateAlpha(\n float iterationCount, float reflectivity,\n vec2 hitPixel, vec3 hitPoint, float dist, vec3 rayDir\n)\n{\n float alpha = clamp(reflectivity, 0.0, 1.0);\n alpha *= 1.0 - (iterationCount / float(MAX_ITERATION));\n vec2 hitPixelNDC = hitPixel * 2.0 - 1.0;\n float maxDimension = min(1.0, max(abs(hitPixelNDC.x), abs(hitPixelNDC.y)));\n alpha *= 1.0 - max(0.0, maxDimension - screenEdgeFadeStart) / (1.0 - screenEdgeFadeStart);\n\n float _eyeFadeStart = eyeFadeStart;\n float _eyeFadeEnd = eyeFadeEnd;\n if (_eyeFadeStart > _eyeFadeEnd) {\n float tmp = _eyeFadeEnd;\n _eyeFadeEnd = _eyeFadeStart;\n _eyeFadeStart = tmp;\n }\n\n float eyeDir = clamp(rayDir.z, _eyeFadeStart, _eyeFadeEnd);\n alpha *= 1.0 - (eyeDir - _eyeFadeStart) / (_eyeFadeEnd - _eyeFadeStart);\n\n alpha *= 1.0 - clamp(dist / maxRayDistance, 0.0, 1.0);\n\n return alpha;\n}\n\n@import clay.util.rand\n\n@import clay.util.rgbm\n\nvoid main()\n{\n vec4 normalAndGloss = texture2D(gBufferTexture1, v_Texcoord);\n\n if (dot(normalAndGloss.rgb, vec3(1.0)) == 0.0) {\n discard;\n }\n\n float g = normalAndGloss.a;\n#if !defined(PHYSICALLY_CORRECT)\n if (g <= minGlossiness) {\n discard;\n }\n#endif\n\n float reflectivity = (g - minGlossiness) / (1.0 - minGlossiness);\n\n vec3 N = normalize(normalAndGloss.rgb * 2.0 - 1.0);\n N = normalize((toViewSpace * vec4(N, 0.0)).xyz);\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, fetchDepth(gBufferTexture2, v_Texcoord), 1.0);\n vec4 pos = projectionInv * projectedPos;\n vec3 rayOrigin = pos.xyz / pos.w;\n vec3 V = -normalize(rayOrigin);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n float iterationCount;\n float jitter = rand(fract(v_Texcoord + jitterOffset));\n\n#ifdef PHYSICALLY_CORRECT\n vec4 color = vec4(vec3(0.0), 1.0);\n vec4 albedoMetalness = texture2D(gBufferTexture3, v_Texcoord);\n vec3 albedo = albedoMetalness.rgb;\n float m = albedoMetalness.a;\n vec3 diffuseColor = albedo * (1.0 - m);\n vec3 spec = mix(vec3(0.04), albedo, m);\n\n float jitter2 = rand(fract(v_Texcoord)) * float(TOTAL_SAMPLES);\n\n for (int i = 0; i < SAMPLE_PER_FRAME; i++) {\n vec3 H = importanceSampleNormalGGX(float(i) + jitter2, 1.0 - g, N);\n vec3 rayDir = normalize(reflect(-V, H));\n#else\n vec3 rayDir = normalize(reflect(-V, N));\n#endif\n vec2 hitPixel;\n vec3 hitPoint;\n\n bool intersect = traceScreenSpaceRay(rayOrigin, rayDir, jitter, hitPixel, hitPoint, iterationCount);\n\n float dist = distance(rayOrigin, hitPoint);\n\n vec3 hitNormal = texture2D(gBufferTexture1, hitPixel).rgb * 2.0 - 1.0;\n hitNormal = normalize((toViewSpace * vec4(hitNormal, 0.0)).xyz);\n#ifdef PHYSICALLY_CORRECT\n float ndl = clamp(dot(N, rayDir), 0.0, 1.0);\n float vdh = clamp(dot(V, H), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n vec3 litTexel = vec3(0.0);\n if (dot(hitNormal, rayDir) < 0.0 && intersect) {\n litTexel = texture2D(sourceTexture, hitPixel).rgb;\n litTexel *= pow(clamp(1.0 - dist / 200.0, 0.0, 1.0), 3.0);\n\n }\n else {\n #ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n litTexel = RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, 0.0), 8.12).rgb * specularIntensity;\n#endif\n }\n color.rgb += ndl * litTexel * (\n F_Schlick(ndl, spec) * G_Smith(g, ndv, ndl) * vdh / (ndh * ndv + 0.001)\n );\n }\n color.rgb /= float(SAMPLE_PER_FRAME);\n#else\n #if !defined(SPECULARCUBEMAP_ENABLED)\n if (dot(hitNormal, rayDir) >= 0.0) {\n discard;\n }\n if (!intersect) {\n discard;\n }\n#endif\n float alpha = clamp(calculateAlpha(iterationCount, reflectivity, hitPixel, hitPoint, dist, rayDir), 0.0, 1.0);\n vec4 color = texture2D(sourceTexture, hitPixel);\n color.rgb *= alpha;\n\n#ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n alpha = alpha * (intersect ? 1.0 : 0.0);\n float bias = (1.0 -g) * 5.0;\n color.rgb += (1.0 - alpha)\n * RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, bias), 8.12).rgb\n * specularIntensity;\n#endif\n\n#endif\n\n gl_FragColor = encodeHDR(color);\n}\n@end\n\n@export ecgl.ssr.blur\n\nuniform sampler2D texture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform mat4 projection;\nuniform float depthRange : 0.05;\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\n#ifdef BLEND\n #ifdef SSAOTEX_ENABLED\nuniform sampler2D ssaoTex;\n #endif\nuniform sampler2D sourceTexture;\n#endif\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(gBufferTexture2, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n\n@import clay.util.rgbm\n\n\nvoid main()\n{\n @import clay.compositor.kernel.gaussian_9\n\n vec4 centerNTexel = texture2D(gBufferTexture1, v_Texcoord);\n float g = centerNTexel.a;\n float maxBlurSize = clamp(1.0 - g, 0.0, 1.0) * blurSize;\n#ifdef VERTICAL\n vec2 off = vec2(0.0, maxBlurSize / textureSize.y);\n#else\n vec2 off = vec2(maxBlurSize / textureSize.x, 0.0);\n#endif\n\n vec2 coord = v_Texcoord;\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\n vec3 cN = centerNTexel.rgb * 2.0 - 1.0;\n float cD = getLinearDepth(v_Texcoord);\n for (int i = 0; i < 9; i++) {\n vec2 coord = clamp((float(i) - 4.0) * off + v_Texcoord, vec2(0.0), vec2(1.0));\n float w = gaussianKernel[i]\n * clamp(dot(cN, texture2D(gBufferTexture1, coord).rgb * 2.0 - 1.0), 0.0, 1.0);\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(cD - d) / depthRange, 0.0, 1.0));\n\n weightAll += w;\n sum += decodeHDR(texture2D(texture, coord)) * w;\n }\n\n#ifdef BLEND\n float aoFactor = 1.0;\n #ifdef SSAOTEX_ENABLED\n aoFactor = texture2D(ssaoTex, v_Texcoord).r;\n #endif\n gl_FragColor = encodeHDR(\n sum / weightAll * aoFactor + decodeHDR(texture2D(sourceTexture, v_Texcoord))\n );\n#else\n gl_FragColor = encodeHDR(sum / weightAll);\n#endif\n}\n\n@end"},function(e,t,r){"use strict";t.a=[0,0,-.321585265978,-.154972575841,.458126042375,.188473391593,.842080129861,.527766490688,.147304551086,-.659453822776,-.331943915203,-.940619700594,.0479226680259,.54812163202,.701581552186,-.709825561388,-.295436780218,.940589268233,-.901489676764,.237713156085,.973570876096,-.109899459384,-.866792314779,-.451805525005,.330975007087,.800048655954,-.344275183665,.381779221166,-.386139432542,-.437418421534,-.576478634965,-.0148463392551,.385798197415,-.262426961053,-.666302061145,.682427250835,-.628010632582,-.732836215494,.10163141741,-.987658134403,.711995289051,-.320024291314,.0296005138058,.950296523438,.0130612307608,-.351024443122,-.879596633704,-.10478487883,.435712737232,.504254490347,.779203817497,.206477676721,.388264289969,-.896736162545,-.153106280781,-.629203242522,-.245517550697,.657969239148,.126830499058,.26862328493,-.634888119007,-.302301223431,.617074219636,.779817204925]},function(e,t,r){"use strict";function n(e,t,r,n,i){var a=e.gl;t.setUniform(a,"1i",r,i),a.activeTexture(a.TEXTURE0+i),n.isRenderable()?n.bind(e):n.unbind(e)}function i(e,t,r,i,a){var o,s,u,l,c=e.gl;return function(a,h,d){if(!l||l.material!==a.material){var f=a.material,p=a.__program,m=f.get("roughness");null==m&&(m=1);var g=f.get("normalMap")||t,_=f.get("roughnessMap"),v=f.get("bumpMap"),y=f.get("uvRepeat"),x=f.get("uvOffset"),T=f.get("detailUvRepeat"),b=f.get("detailUvOffset"),w=!!v&&f.isTextureEnabled("bumpMap"),E=!!_&&f.isTextureEnabled("roughnessMap"),S=f.isDefined("fragment","DOUBLE_SIDED");v=v||r,_=_||i,d!==h?(h.set("normalMap",g),h.set("bumpMap",v),h.set("roughnessMap",_),h.set("useBumpMap",w),h.set("useRoughnessMap",E),h.set("doubleSide",S),null!=y&&h.set("uvRepeat",y),null!=x&&h.set("uvOffset",x),null!=T&&h.set("detailUvRepeat",T),null!=b&&h.set("detailUvOffset",b),h.set("roughness",m)):(p.setUniform(c,"1f","roughness",m),o!==g&&n(e,p,"normalMap",g,0),s!==v&&v&&n(e,p,"bumpMap",v,1),u!==_&&_&&n(e,p,"roughnessMap",_,2),null!=y&&p.setUniform(c,"2f","uvRepeat",y),null!=x&&p.setUniform(c,"2f","uvOffset",x),null!=T&&p.setUniform(c,"2f","detailUvRepeat",T),null!=b&&p.setUniform(c,"2f","detailUvOffset",b),p.setUniform(c,"1i","useBumpMap",+w),p.setUniform(c,"1i","useRoughnessMap",+E),p.setUniform(c,"1i","doubleSide",+S)),o=g,s=v,u=_,l=a}}}function a(e){e=e||{},this._depthTex=new o.a({format:s.a.DEPTH_COMPONENT,type:s.a.UNSIGNED_INT}),this._normalTex=new o.a({type:s.a.HALF_FLOAT}),this._framebuffer=new l.a,this._framebuffer.attach(this._normalTex),this._framebuffer.attach(this._depthTex,l.a.DEPTH_ATTACHMENT),this._normalMaterial=new c.a({shader:new u.a(u.a.source("ecgl.normal.vertex"),u.a.source("ecgl.normal.fragment"))}),this._normalMaterial.enableTexture(["normalMap","bumpMap","roughnessMap"]),this._defaultNormalMap=d.a.createBlank("#000"),this._defaultBumpMap=d.a.createBlank("#000"),this._defaultRoughessMap=d.a.createBlank("#000"),this._debugPass=new h.a({fragment:u.a.source("clay.compositor.output")}),this._debugPass.setUniform("texture",this._normalTex),this._debugPass.material.undefine("fragment","OUTPUT_ALPHA")}var o=r(5),s=r(6),u=r(8),l=r(10),c=r(17),h=r(14),d=r(54),f=r(187);u.a.import(f.a),a.prototype.getDepthTexture=function(){return this._depthTex},a.prototype.getNormalTexture=function(){return this._normalTex},a.prototype.update=function(e,t,r){var n=e.getWidth(),a=e.getHeight(),o=this._depthTex,s=this._normalTex,u=this._normalMaterial;o.width=n,o.height=a,s.width=n,s.height=a;var l=t.getRenderList(r).opaque;this._framebuffer.bind(e),e.gl.clearColor(0,0,0,0),e.gl.clear(e.gl.COLOR_BUFFER_BIT|e.gl.DEPTH_BUFFER_BIT),e.gl.disable(e.gl.BLEND),e.renderPass(l,r,{getMaterial:function(){return u},ifRender:function(e){return e.renderNormal},beforeRender:i(e,this._defaultNormalMap,this._defaultBumpMap,this._defaultRoughessMap,this._normalMaterial),sort:e.opaqueSortCompare}),this._framebuffer.unbind(e)},a.prototype.renderDebug=function(e){this._debugPass.render(e)},a.prototype.dispose=function(e){this._depthTex.dispose(e),this._normalTex.dispose(e)},t.a=a},function(e,t,r){"use strict";t.a="@export ecgl.normal.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n@import ecgl.common.normalMap.vertexHeader\n\n@import ecgl.common.vertexAnimation.header\n\nvoid main()\n{\n\n @import ecgl.common.vertexAnimation.main\n\n @import ecgl.common.uv.main\n\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n @import ecgl.common.normalMap.vertexMain\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n}\n\n\n@end\n\n\n@export ecgl.normal.fragment\n\n#define ROUGHNESS_CHANEL 0\n\nuniform bool useBumpMap;\nuniform bool useRoughnessMap;\nuniform bool doubleSide;\nuniform float roughness;\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n@import ecgl.common.normalMap.fragmentHeader\n@import ecgl.common.bumpMap.header\n\nuniform sampler2D roughnessMap;\n\nvoid main()\n{\n vec3 N = v_Normal;\n \n bool flipNormal = false;\n if (doubleSide) {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n flipNormal = true;\n }\n }\n\n @import ecgl.common.normalMap.fragmentMain\n\n if (useBumpMap) {\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n }\n\n float g = 1.0 - roughness;\n\n if (useRoughnessMap) {\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n }\n\n if (flipNormal) {\n N = -N;\n }\n\n gl_FragColor.rgb = (N.xyz + 1.0) * 0.5;\n gl_FragColor.a = g;\n}\n@end"},function(e,t,r){"use strict";function n(e){e=e||{},this._edgePass=new o.a({fragment:s.a.source("ecgl.edge")}),this._edgePass.setUniform("normalTexture",e.normalTexture),this._edgePass.setUniform("depthTexture",e.depthTexture),this._targetTexture=new i.a({type:a.a.HALF_FLOAT}),this._frameBuffer=new u.a,this._frameBuffer.attach(this._targetTexture)}var i=(r(7),r(4),r(5)),a=r(6),o=r(14),s=r(8),u=r(10);n.prototype.update=function(e,t,r,n){var i=e.getWidth(),a=e.getHeight(),o=this._targetTexture;o.width=i,o.height=a;var s=this._frameBuffer;s.bind(e),this._edgePass.setUniform("projectionInv",t.invProjectionMatrix.array),this._edgePass.setUniform("textureSize",[i,a]),this._edgePass.setUniform("texture",r),this._edgePass.render(e),s.unbind(e)},n.prototype.getTargetTexture=function(){return this._targetTexture},n.prototype.setParameter=function(e,t){this._edgePass.setUniform(e,t)},n.prototype.dispose=function(e){this._targetTexture.dispose(e),this._frameBuffer.dispose(e)},t.a=n},function(e,t,r){"use strict";t.a={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(clay.compositor.downsample)",inputs:{texture:"source"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bright",shader:"#source(clay.compositor.bright)",inputs:{texture:"source_half"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{threshold:2,scale:4,textureSize:"expr([width * 1.0 / 2, height / 2])"}},{name:"bright_downsample_4",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 2, height / 2] )"}},{name:"bright_downsample_8",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 4, height / 4] )"}},{name:"bright_downsample_16",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 8, height / 8] )"}},{name:"bright_downsample_32",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 32)",height:"expr(height * 1.0 / 32)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 16, height / 16] )"}},{name:"bright_upsample_16_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_32"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 32, height / 32] )"}},{name:"bright_upsample_16_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_16_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_8_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_8_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_8_blur_v",texture2:"bright_upsample_16_blur_v"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_4_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_4_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_4_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_4_blur_v",texture2:"bright_upsample_8_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_2_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_2_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_2_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_2_blur_v",texture2:"bright_upsample_4_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_full_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_full_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_full_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bloom_composite",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_full_blur_v",texture2:"bright_upsample_2_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"coc",shader:"#source(ecgl.dof.coc)",outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{focalDist:50,focalRange:30}},{name:"dof_far_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"dof_near_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_NEARFIELD:null}},{name:"dof_coc_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"coc"},outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_COC:null}},{name:"dof_composite",shader:"#source(ecgl.dof.composite)",inputs:{original:"source",blurred:"dof_far_blur",nearfield:"dof_near_blur",coc:"coc",nearcoc:"dof_coc_blur"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}}},{name:"composite",shader:"#source(clay.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},defines:{}},{name:"FXAA",shader:"#source(clay.compositor.fxaa)",inputs:{texture:"composite"}}]}},function(e,t,r){"use strict";t.a="@export ecgl.dof.coc\n\nuniform sampler2D depth;\n\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\n\nuniform float focalDistance: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\n\nvarying vec2 v_Texcoord;\n\n@import clay.util.encode_float\n\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n\n float aperture = focalLength / fstop;\n\n float coc;\n\n float uppper = focalDistance + focalRange;\n float lower = focalDistance - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 2.0) / 2.00001;\n\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n\n gl_FragColor = encodeFloat(coc);\n}\n@end\n\n\n@export ecgl.dof.composite\n\n#define DEBUG 0\n\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n\n@import clay.util.rgbm\n@import clay.util.float\n\nvoid main()\n{\n vec4 blurredColor = texture2D(blurred, v_Texcoord);\n vec4 originalColor = texture2D(original, v_Texcoord);\n\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n\n fCoc = abs(fCoc * 2.0 - 1.0);\n\n float weight = smoothstep(0.0, 1.0, fCoc);\n \n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = texture2D(nearfield, v_Texcoord);\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n\n}\n\n@end\n\n\n\n@export ecgl.dof.diskBlur\n\n#define POISSON_KERNEL_SIZE 16;\n\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n\nuniform float blurRadius : 10.0;\nuniform vec2 textureSize : [512.0, 512.0];\n\nuniform vec2 poissonKernel[POISSON_KERNEL_SIZE];\n\nuniform float percent;\n\nfloat nrand(const in vec2 n) {\n return fract(sin(dot(n.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\n@import clay.util.rgbm\n@import clay.util.float\n\n\nvoid main()\n{\n vec2 offset = blurRadius / textureSize;\n\n float rnd = 6.28318 * nrand(v_Texcoord + 0.07 * percent );\n float cosa = cos(rnd);\n float sina = sin(rnd);\n vec4 basis = vec4(cosa, -sina, sina, cosa);\n\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n\n\n float weightSum = 0.0;\n\n for (int i = 0; i < POISSON_KERNEL_SIZE; i++) {\n vec2 ofs = poissonKernel[i];\n\n ofs = vec2(dot(ofs, basis.xy), dot(ofs, basis.zw));\n\n vec2 uv = v_Texcoord + ofs * offset;\n vec4 texel = texture2D(texture, uv);\n\n float w = 1.0;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texel) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n texel = texel;\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\n texel.rgb *= texel.a;\n color += texel * w;\n#endif\n\n weightSum += w;\n }\n\n#ifdef BLUR_COC\n gl_FragColor = encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n color /= weightSum;\n color.rgb /= (color.a + 0.0001);\n gl_FragColor = color;\n#endif\n}\n\n@end"},function(e,t,r){"use strict";t.a="@export ecgl.edge\n\nuniform sampler2D texture;\n\nuniform sampler2D normalTexture;\nuniform sampler2D depthTexture;\n\nuniform mat4 projectionInv;\n\nuniform vec2 textureSize;\n\nuniform vec4 edgeColor: [0,0,0,0.8];\n\nvarying vec2 v_Texcoord;\n\nvec3 packColor(vec2 coord) {\n float z = texture2D(depthTexture, coord).r * 2.0 - 1.0;\n vec4 p = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * p;\n\n return vec3(\n texture2D(normalTexture, coord).rg,\n -p4.z / p4.w / 5.0\n );\n}\n\nvoid main() {\n vec2 cc = v_Texcoord;\n vec3 center = packColor(cc);\n\n float size = clamp(1.0 - (center.z - 10.0) / 100.0, 0.0, 1.0) * 0.5;\n float dx = size / textureSize.x;\n float dy = size / textureSize.y;\n\n vec2 coord;\n vec3 topLeft = packColor(cc+vec2(-dx, -dy));\n vec3 top = packColor(cc+vec2(0.0, -dy));\n vec3 topRight = packColor(cc+vec2(dx, -dy));\n vec3 left = packColor(cc+vec2(-dx, 0.0));\n vec3 right = packColor(cc+vec2(dx, 0.0));\n vec3 bottomLeft = packColor(cc+vec2(-dx, dy));\n vec3 bottom = packColor(cc+vec2(0.0, dy));\n vec3 bottomRight = packColor(cc+vec2(dx, dy));\n\n vec3 v = -topLeft-2.0*top-topRight+bottomLeft+2.0*bottom+bottomRight;\n vec3 h = -bottomLeft-2.0*left-topLeft+bottomRight+2.0*right+topRight;\n\n float edge = sqrt(dot(h, h) + dot(v, v));\n\n edge = smoothstep(0.8, 1.0, edge);\n\n gl_FragColor = mix(texture2D(texture, v_Texcoord), vec4(edgeColor.rgb, 1.0), edgeColor.a * edge);\n}\n@end"},function(e,t,r){"use strict";function n(e){for(var t=[],r=0;r<30;r++)t.push([Object(i.a)(r,2),Object(i.a)(r,3)]);this._haltonSequence=t,this._frame=0,this._sourceTex=new s.a,this._sourceFb=new o.a,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new s.a,this._outputTex=new s.a;var n=this._blendPass=new a.a({fragment:u.a.source("clay.compositor.blend")});n.material.disableTexturesAll(),n.material.enableTexture(["texture1","texture2"]),this._blendFb=new o.a({depthBuffer:!1}),this._outputPass=new a.a({fragment:u.a.source("clay.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.define("fragment","OUTPUT_ALPHA"),this._outputPass.material.blend=function(e){e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}}var i=r(43),a=r(14),o=r(10),s=r(5),u=r(8),l=r(7);n.prototype={constructor:n,jitterProjection:function(e,t){var r=e.viewport,n=r.devicePixelRatio||e.getDevicePixelRatio(),i=r.width*n,a=r.height*n,o=this._haltonSequence[this._frame%this._haltonSequence.length],s=new l.a;s.array[12]=(2*o[0]-1)/i,s.array[13]=(2*o[1]-1)/a,l.a.mul(t.projectionMatrix,s,t.projectionMatrix),l.a.invert(t.invProjectionMatrix,t.projectionMatrix)},resetFrame:function(){this._frame=0},getFrame:function(){return this._frame},getSourceFrameBuffer:function(){return this._sourceFb},getOutputTexture:function(){return this._outputTex},resize:function(e,t){this._prevFrameTex.width=e,this._prevFrameTex.height=t,this._outputTex.width=e,this._outputTex.height=t,this._sourceTex.width=e,this._sourceTex.height=t,this._prevFrameTex.dirty(),this._outputTex.dirty(),this._sourceTex.dirty()},isFinished:function(){return this._frame>=this._haltonSequence.length},render:function(e,t,r){var n=this._blendPass;0===this._frame?(n.setUniform("weight1",0),n.setUniform("weight2",1)):(n.setUniform("weight1",.9),n.setUniform("weight2",.1)),n.setUniform("texture1",this._prevFrameTex),n.setUniform("texture2",t||this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),n.render(e),this._blendFb.unbind(e),r||(this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e));var i=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=i,this._frame++},dispose:function(e){this._sourceFb.dispose(e),this._blendFb.dispose(e),this._prevFrameTex.dispose(e),this._outputTex.dispose(e),this._sourceTex.dispose(e),this._outputPass.dispose(e),this._blendPass.dispose(e)}},t.a=n},function(e,t,r){"use strict";var n=r(0),i=r.n(n);r(194),r(195),r(91);i.a.registerAction({type:"geo3DChangeCamera",event:"geo3dcamerachanged",update:"series:updateCamera"},function(e,t){t.eachComponent({mainType:"geo3D",query:e},function(t){t.setView(e)})})},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(38),o=r(25),s=r(26),u=r(28),l=r(89),c=i.a.extendComponentModel({type:"geo3D",layoutMode:"box",coordinateSystem:null,optionUpdated:function(){var e=this.option;e.regions=this.getFilledRegions(e.regions,e.map);var t=i.a.helper.completeDimensions(["value"],e.data,{encodeDef:this.get("encode"),dimsDef:this.get("dimensions")}),r=new i.a.List(t,this);r.initData(e.regions);var n={};r.each(function(e){var t=r.getName(e),i=r.getItemModel(e);n[t]=i}),this._regionModelMap=n,this._data=r},getData:function(){return this._data},getRegionModel:function(e){var t=this.getData().getName(e);return this._regionModelMap[t]||new i.a.Model(null,this)},getRegionPolygonCoords:function(e){var t=this.getData().getName(e),r=this.coordinateSystem.getRegion(t);return r?r.geometries:[]},getFormattedLabel:function(e,t){var r=this._data.getName(e),n=this.getRegionModel(r),i=n.get("normal"===t?["label","formatter"]:["emphasis","label","formatter"]);null==i&&(i=n.get(["label","formatter"]));var a={name:r};if("function"==typeof i)return a.status=t,i(a);if("string"==typeof i){var o=a.seriesName;return i.replace("{a}",null!=o?o:"")}return r},defaultOption:{regions:[]}});i.a.util.merge(c.prototype,l.a),i.a.util.merge(c.prototype,a.a),i.a.util.merge(c.prototype,o.a),i.a.util.merge(c.prototype,s.a),i.a.util.merge(c.prototype,u.a)},function(e,t,r){"use strict";var n=r(59),i=r(0),a=r.n(i),o=r(2),s=r(39),u=r(27);a.a.extendComponentView({type:"geo3D",__ecgl__:!0,init:function(e,t){this._geo3DBuilder=new n.a(t),this.groupGL=new o.a.Node,this._lightRoot=new o.a.Node,this._sceneHelper=new u.a(this._lightRoot),this._sceneHelper.initLight(this._lightRoot),this._control=new s.a({zr:t.getZr()}),this._control.init()},render:function(e,t,r){this.groupGL.add(this._geo3DBuilder.rootNode);var n=e.coordinateSystem;if(n&&n.viewGL){n.viewGL.add(this._lightRoot),e.get("show")?n.viewGL.add(this.groupGL):n.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(n.viewGL);var a=e.getModel("viewControl");i.setFromViewControlModel(a,0),this._sceneHelper.setScene(n.viewGL.scene),this._sceneHelper.updateLight(e),n.viewGL.setPostEffect(e.getModel("postEffect"),r),n.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._geo3DBuilder.update(e,t,r,0,e.getData().count());var o=n.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse(function(e){e.material&&e.material[o]("fragment","SRGB_DECODE")}),i.off("update"),i.on("update",function(){r.dispatchAction({type:"geo3DChangeCamera",alpha:i.getAlpha(),beta:i.getBeta(),distance:i.getDistance(),center:i.getCenter(),from:this.uid,geo3DId:e.id})}),i.update()}},afterRender:function(e,t,r,n){var i=n.renderer;this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r)},dispose:function(){this._control.dispose()}})},function(e,t,r){"use strict";function n(e,t,r){r=r||2;var n=t&&t.length,a=n?t[0]*r:e.length,s=i(e,0,a,r,!0),u=[];if(!s)return u;var l,c,d,f,p,m,g;if(n&&(s=h(e,t,s,r)),e.length>80*r){l=d=e[0],c=f=e[1];for(var _=r;_d&&(d=p),m>f&&(f=m);g=Math.max(d-l,f-c)}return o(s,u,r,l,c,g),u}function i(e,t,r,n,i){var a,o;if(i===N(e,t,r,n)>0)for(a=t;a=t;a-=n)o=C(a,e[a],e[a+1],o);return o&&b(o,o.next)&&(L(o),o=o.next),o}function a(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!b(n,n.next)&&0!==T(n.prev,n,n.next))n=n.next;else{if(L(n),(n=t=n.prev)===n.next)return null;r=!0}}while(r||n!==t);return t}function o(e,t,r,n,i,h,d){if(e){!d&&h&&m(e,n,i,h);for(var f,p,g=e;e.prev!==e.next;)if(f=e.prev,p=e.next,h?u(e,n,i,h):s(e))t.push(f.i/r),t.push(e.i/r),t.push(p.i/r),L(e),e=p.next,g=p.next;else if((e=p)===g){d?1===d?(e=l(e,t,r),o(e,t,r,n,i,h,2)):2===d&&c(e,t,r,n,i,h):o(a(e),t,r,n,i,h,1);break}}}function s(e){var t=e.prev,r=e,n=e.next;if(T(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(y(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&T(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function u(e,t,r,n){var i=e.prev,a=e,o=e.next;if(T(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,c=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=_(s,u,t,r,n),d=_(l,c,t,r,n),f=e.nextZ;f&&f.z<=d;){if(f!==e.prev&&f!==e.next&&y(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&T(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=e.prevZ;f&&f.z>=h;){if(f!==e.prev&&f!==e.next&&y(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&T(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}function l(e,t,r){var n=e;do{var i=n.prev,a=n.next.next;!b(i,a)&&w(i,n,n.next,a)&&S(i,a)&&S(a,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(a.i/r),L(n),L(n.next),n=e=a),n=n.next}while(n!==e);return n}function c(e,t,r,n,i,s){var u=e;do{for(var l=u.next.next;l!==u.prev;){if(u.i!==l.i&&x(u,l)){var c=M(u,l);return u=a(u,u.next),c=a(c,c.next),o(u,t,r,n,i,s),void o(c,t,r,n,i,s)}l=l.next}u=u.next}while(u!==e)}function h(e,t,r,n){var o,s,u,l,c,h=[];for(o=0,s=t.length;o=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o){if(o=s,s===i){if(a===n.y)return n;if(a===n.next.y)return n.next}r=n.x=n.x&&n.x>=c&&i!==n.x&&y(ar.x)&&S(n,e)&&(r=n,d=u),n=n.next;return r}function m(e,t,r,n){var i=e;do{null===i.z&&(i.z=_(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,g(i)}function g(e){var t,r,n,i,a,o,s,u,l=1;do{for(r=e,e=null,a=null,o=0;r;){for(o++,n=r,s=0,t=0;t0||u>0&&n;)0!==s&&(0===u||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,u--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=n}a.nextZ=null,l*=2}while(o>1);return e}function _(e,t,r,n,i){return e=32767*(e-r)/i,t=32767*(t-n)/i,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function v(e){var t=e,r=e;do{t.x=0&&(e-o)*(n-s)-(r-o)*(t-s)>=0&&(r-o)*(a-s)-(i-o)*(n-s)>=0}function x(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!E(e,t)&&S(e,t)&&S(t,e)&&A(e,t)}function T(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function b(e,t){return e.x===t.x&&e.y===t.y}function w(e,t,r,n){return!!(b(e,t)&&b(r,n)||b(e,n)&&b(r,t))||T(e,t,r)>0!=T(e,t,n)>0&&T(r,n,e)>0!=T(r,n,t)>0}function E(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&w(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function S(e,t){return T(e.prev,e,e.next)<0?T(e,t,e.next)>=0&&T(e,e.prev,t)>=0:T(e,t,e.prev)<0||T(e,e.next,t)<0}function A(e,t){var r=e,n=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==e);return n}function M(e,t){var r=new D(e.i,e.x,e.y),n=new D(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function C(e,t,r,n){var i=new D(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function L(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function D(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function N(e,t,r,n){for(var i=0,a=t,o=r-n;a0},_displacementChanged:!0,_displacementScale:0,updateDisplacementHash:function(){var e=this.getDisplacementTexture(),t=this.getDisplacemenScale();this._displacementChanged=this._displacementTexture!==e||this._displacementScale!==t,this._displacementTexture=e,this._displacementScale=t},isDisplacementChanged:function(){return this._displacementChanged}});a.a.util.merge(c.prototype,o.a),a.a.util.merge(c.prototype,s.a),a.a.util.merge(c.prototype,u.a),a.a.util.merge(c.prototype,l.a)},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(2),o=r(39),s=r(27),u=r(202),l=r(3);i.a.extendComponentView({type:"globe",__ecgl__:!0,_displacementScale:0,init:function(e,t){this.groupGL=new a.a.Node,this._sphereGeometry=new a.a.SphereGeometry({widthSegments:200,heightSegments:100,dynamic:!0}),this._overlayGeometry=new a.a.SphereGeometry({widthSegments:80,heightSegments:40}),this._planeGeometry=new a.a.PlaneGeometry,this._earthMesh=new a.a.Mesh({renderNormal:!0}),this._lightRoot=new a.a.Node,this._sceneHelper=new s.a,this._sceneHelper.initLight(this._lightRoot),this.groupGL.add(this._earthMesh),this._control=new o.a({zr:t.getZr()}),this._control.init(),this._layerMeshes={}},render:function(e,t,r){var n=e.coordinateSystem,i=e.get("shading");n.viewGL.add(this._lightRoot),e.get("show")?n.viewGL.add(this.groupGL):n.viewGL.remove(this.groupGL),this._sceneHelper.setScene(n.viewGL.scene),n.viewGL.setPostEffect(e.getModel("postEffect"),r),n.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));var o=this._earthMesh;o.geometry=this._sphereGeometry;var s="ecgl."+i;o.material&&o.material.shader.name===s||(o.material=a.a.createMaterial(s)),a.a.setMaterialFromModel(i,o.material,e,r),["roughnessMap","metalnessMap","detailMap","normalMap"].forEach(function(e){var t=o.material.get(e);t&&(t.flipY=!1)}),o.material.set("color",a.a.parseColor(e.get("baseColor")));var u=.99*n.radius;o.scale.set(u,u,u);var l=o.material.setTextureImage("diffuseMap",e.get("baseTexture"),r,{flipY:!1,anisotropic:8});l&&l.surface&&l.surface.attachToMesh(o);var c=o.material.setTextureImage("bumpMap",e.get("heightTexture"),r,{flipY:!1,anisotropic:8});c&&c.surface&&c.surface.attachToMesh(o),o.material[e.get("postEffect.enable")?"define":"undefine"]("fragment","SRGB_DECODE"),this._updateLight(e,r),this._displaceVertices(e,r),this._updateViewControl(e,r),this._updateLayers(e,r)},afterRender:function(e,t,r,n){var i=n.renderer;this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r)},_updateLayers:function(e,t){var r=e.coordinateSystem,n=e.get("layers"),o=r.radius,s=[],u=[],c=[],h=[];i.a.util.each(n,function(e){var n=new i.a.Model(e),d=n.get("type"),f=a.a.loadTexture(n.get("texture"),t,{flipY:!1,anisotropic:8});if(f.surface&&f.surface.attachToMesh(this._earthMesh),"blend"===d){var p=n.get("blendTo"),m=l.a.firstNotNull(n.get("intensity"),1);"emission"===p?(c.push(f),h.push(m)):(s.push(f),u.push(m))}else{var g=n.get("id"),_=this._layerMeshes[g];_||(_=this._layerMeshes[g]=new a.a.Mesh({geometry:this._overlayGeometry,castShadow:!1,ignorePicking:!0}));"lambert"===n.get("shading")?(_.material=_.__lambertMaterial||new a.a.Material({autoUpdateTextureStatus:!1,shader:a.a.createShader("ecgl.lambert"),transparent:!0,depthMask:!1}),_.__lambertMaterial=_.material):(_.material=_.__colorMaterial||new a.a.Material({autoUpdateTextureStatus:!1,shader:a.a.createShader("ecgl.color"),transparent:!0,depthMask:!1}),_.__colorMaterial=_.material),_.material.enableTexture("diffuseMap");var v=n.get("distance"),y=o+(null==v?r.radius/100:v);_.scale.set(y,y,y),o=y;var x=this._blankTexture||(this._blankTexture=a.a.createBlankTexture("rgba(255, 255, 255, 0)"));_.material.set("diffuseMap",x),a.a.loadTexture(n.get("texture"),t,{flipY:!1,anisotropic:8},function(e){e.surface&&e.surface.attachToMesh(_),_.material.set("diffuseMap",e),t.getZr().refresh()}),n.get("show")?this.groupGL.add(_):this.groupGL.remove(_)}},this);var d=this._earthMesh.material;d.define("fragment","LAYER_DIFFUSEMAP_COUNT",s.length),d.define("fragment","LAYER_EMISSIVEMAP_COUNT",c.length),d.set("layerDiffuseMap",s),d.set("layerDiffuseIntensity",u),d.set("layerEmissiveMap",c),d.set("layerEmissionIntensity",h);var f=e.getModel("debug.wireframe");if(f.get("show")){d.define("both","WIREFRAME_TRIANGLE");var p=a.a.parseColor(f.get("lineStyle.color")||"rgba(0,0,0,0.5)"),m=l.a.firstNotNull(f.get("lineStyle.width"),1);d.set("wireframeLineWidth",m),d.set("wireframeLineColor",p)}else d.undefine("both","WIREFRAME_TRIANGLE")},_updateViewControl:function(e,t){function r(){return{type:"globeChangeCamera",alpha:o.getAlpha(),beta:o.getBeta(),distance:o.getDistance()-n.radius,center:o.getCenter(),from:a.uid,globeId:e.id}}var n=e.coordinateSystem,i=e.getModel("viewControl"),a=(n.viewGL.camera,this),o=this._control;o.setViewGL(n.viewGL);var s,u,l=i.get("targetCoord");null!=l&&(u=l[0]+90,s=l[1]),o.setFromViewControlModel(i,{baseDistance:n.radius,alpha:s,beta:u}),o.off("update"),o.on("update",function(){t.dispatchAction(r())})},_displaceVertices:function(e,t){var r=e.get("displacementQuality"),n=e.get("debug.wireframe.show"),i=e.coordinateSystem;if(e.isDisplacementChanged()||r!==this._displacementQuality||n!==this._showDebugWireframe){this._displacementQuality=r,this._showDebugWireframe=n;var a=this._sphereGeometry,o={low:100,medium:200,high:400,ultra:800}[r]||200,s=o/2;(a.widthSegments!==o||n)&&(a.widthSegments=o,a.heightSegments=s,a.build()),this._doDisplaceVertices(a,i),n&&a.generateBarycentric()}},_doDisplaceVertices:function(e,t){var r=e.attributes.position.value,n=e.attributes.texcoord0.value,i=e.__originalPosition;i&&i.length===r.length||(i=new Float32Array(r.length),i.set(r),e.__originalPosition=i);for(var a=t.displacementWidth,o=t.displacementHeight,s=t.displacementData,u=0;uOpenStreetMap contributors, © CARTO',center:[0,0],zoom:0,pitch:0,bearing:0,light:{main:{alpha:20,beta:30}},altitudeScale:1,boxHeight:"auto"},getMaptalksCameraOption:function(){var e=this;return s.reduce(function(t,r){return t[r]=e.get(r),t},{})},setMaptalksCameraOption:function(e){null!=e&&s.forEach(function(t){null!=e[t]&&(this.option[t]=e[t])},this)},getMaptalks:function(){return this._maptalks},setMaptalks:function(e){this._maptalks=e}});i.a.util.merge(u.prototype,a.a),i.a.util.merge(u.prototype,o.a)},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(216),o=r(27),s=r(2),u=r(95);s.a.Shader.import(u.a);i.a.extendComponentView({type:"maptalks3D",__ecgl__:!0,init:function(e,t){this._groundMesh=new s.a.Mesh({geometry:new s.a.PlaneGeometry,material:new s.a.Material({shader:new s.a.Shader({vertex:s.a.Shader.source("ecgl.displayShadow.vertex"),fragment:s.a.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},_initMaptalksLayer:function(e,t){var r=t.getZr();this._zrLayer=new a.a("maptalks3D",r,e.get("center"),e.get("zoom")),r.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new s.a.Node,this._sceneHelper=new o.a(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var n=this._zrLayer.getMaptalks(),i=this._dispatchInteractAction.bind(this,t,n);["zoomend","zooming","zoomstart","dragrotating","pitch","pitchend","movestart","moving","moveend","resize","touchstart","touchmove","touchend"].forEach(function(e){n.on(e,i)})},render:function(e,t,r){this._zrLayer||this._initMaptalksLayer(e,r);var n=this._zrLayer.getMaptalks(),i=e.get("urlTemplate"),a=n.getBaseLayer();i!==this._oldUrlTemplate&&(a?a.setOptions({urlTemplate:i,attribution:e.get("attribution")}):(a=new maptalks.TileLayer("maptalks-echarts-gl-baselayer",{urlTemplate:i,subdomains:["a","b","c"],attribution:e.get("attribution")}),n.setBaseLayer(a))),this._oldUrlTemplate=i,n.setCenter(e.get("center")),n.setZoom(e.get("zoom"),{animation:!1}),n.setPitch(e.get("pitch")),n.setBearing(e.get("bearing")),e.setMaptalks(n);var o=e.coordinateSystem;o.viewGL.scene.add(this._lightRoot),o.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(o.viewGL.scene),this._sceneHelper.updateLight(e),o.viewGL.setPostEffect(e.getModel("postEffect"),r),o.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._maptalks3DModel=e},afterRender:function(e,t,r,n){var i=n.renderer;this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r),e.coordinateSystem.viewGL.scene.traverse(function(e){e.material&&(e.material.define("fragment","NORMAL_UP_AXIS",2),e.material.define("fragment","NORMAL_FRONT_AXIS",1))})},updateCamera:function(e,t,r,n){e.coordinateSystem.setCameraOption(n),this._updateGroundMesh(),r.getZr().refresh()},_dispatchInteractAction:function(e,t,r){e.dispatchAction({type:"maptalks3DChangeCamera",pitch:t.getPitch(),zoom:t.getZoom(),center:t.getCenter().toArray(),bearing:t.getBearing(),maptalks3DId:this._maptalks3DModel&&this._maptalks3DModel.id})},_updateGroundMesh:function(){if(this._maptalks3DModel){var e=this._maptalks3DModel.coordinateSystem,t=e.dataToPoint(e.center);this._groundMesh.position.set(t[0],t[1],-.001);var r=new s.a.Plane(new s.a.Vector3(0,0,1),0),n=e.viewGL.camera.castRay(new s.a.Vector2(-1,-1)),i=e.viewGL.camera.castRay(new s.a.Vector2(1,1)),a=n.intersectPlane(r),o=i.intersectPlane(r),u=a.dist(o)/e.viewGL.rootNode.scale.x;this._groundMesh.scale.set(u,u,1)}},dispose:function(e,t){this._zrLayer&&this._zrLayer.dispose(),t.getZr().painter.delLayer(-1e3)}})},function(e,t,r){"use strict";function n(e,t,r,n){if(this.id=e,this.zr=t,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute;left:0;right:0;top:0;bottom:0;",!maptalks)throw new Error("Maptalks library must be included. See https://maptalks.org");this._maptalks=new maptalks.Map(this.dom,{center:r,zoom:n,fog:!1}),this._initEvents()}n.prototype.resize=function(){this._maptalks.checkSize()},n.prototype.getMaptalks=function(){return this._maptalks},n.prototype.clear=function(){},n.prototype.refresh=function(){this._maptalks.checkSize()};var i=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","DOMMouseScroll","touchstart","touchend","touchmove","touchcancel"];n.prototype._initEvents=function(){var e=this.dom;this._handlers=this._handlers||{contextmenu:function(e){return e.preventDefault(),!1}},i.forEach(function(t){this._handlers[t]=function(r){var n={};for(var i in r)n[i]=r[i];n.bubbles=!1;var a=new r.constructor(r.type,n);"mousewheel"===t||"DOMMouseScroll"===t?e.dispatchEvent(a):e.firstElementChild.dispatchEvent(a)},this.zr.dom.addEventListener(t,this._handlers[t])},this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},n.prototype.dispose=function(){i.forEach(function(e){this.zr.dom.removeEventListener(e,this._handlers[e])},this),this._maptalks.remove()},t.a=n},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=(r(218),r(221),r(223),r(16));i.a.registerVisual(Object(a.a)("bar3D")),i.a.registerProcessor(function(e,t){e.eachSeriesByType("bar3d",function(e){var t=e.getData();t.filterSelf(function(e){return t.hasValue(e)})})})},function(e,t,r){"use strict";function n(e,t){var r=e.getData(),n=e.get("minHeight")||0,i=e.get("barSize"),a=["lng","lat","alt"].map(function(t){return e.coordDimToDataDim(t)[0]});if(null==i){var s=t.radius*Math.PI,c=Object(f.a)(r,a[0],a[1]);i=[s/Math.sqrt(r.count()/c),s/Math.sqrt(r.count()/c)]}else u.a.util.isArray(i)||(i=[i,i]);var h=o(r,a);r.each(a,function(e,a,o,s){var u=r.get(h.dimension,s),l=h.isStacked?u-o:t.altitudeAxis.scale.getExtent()[0],c=Math.max(t.altitudeAxis.dataToCoord(o),n),d=t.dataToPoint([e,a,l]),f=t.dataToPoint([e,a,u]),m=p.sub([],f,d);p.normalize(m,m);var g=[i[0],c,i[1]];r.setItemLayout(s,[d,m,g])}),r.setLayout("orient",l.a.UP.array)}function i(e,t){var r=e.getData(),n=e.get("barSize"),i=e.get("minHeight")||0,a=["lng","lat","alt"].map(function(t){return e.coordDimToDataDim(t)[0]});if(null==n){var s=Math.min(t.size[0],t.size[2]),l=Object(f.a)(r,a[0],a[1]);n=[s/Math.sqrt(r.count()/l),s/Math.sqrt(r.count()/l)]}else u.a.util.isArray(n)||(n=[n,n]);var c=[0,1,0],h=o(r,a);r.each(a,function(e,a,o,s){var u=r.get(h.dimension,s),l=h.isStacked?u-o:t.altitudeAxis.scale.getExtent()[0],d=Math.max(t.altitudeAxis.dataToCoord(o),i),f=t.dataToPoint([e,a,l]),p=[n[0],d,n[1]];r.setItemLayout(s,[f,c,p])}),r.setLayout("orient",[1,0,0])}function a(e,t){var r=e.getData(),n=e.coordDimToDataDim("lng")[0],i=e.coordDimToDataDim("lat")[0],a=e.coordDimToDataDim("alt")[0],s=e.get("barSize"),l=e.get("minHeight")||0;if(null==s){var c=r.getDataExtent(n),h=r.getDataExtent(i),d=t.dataToPoint([c[0],h[0]]),p=t.dataToPoint([c[1],h[1]]),m=Math.min(Math.abs(d[0]-p[0]),Math.abs(d[1]-p[1]))||1,g=Object(f.a)(r,n,i);s=[m/Math.sqrt(r.count()/g),m/Math.sqrt(r.count()/g)]}else u.a.util.isArray(s)||(s=[s,s]),s[0]/=t.getScale()/16,s[1]/=t.getScale()/16;var _=[0,0,1],v=[n,i,a],y=o(r,v);r.each(v,function(e,n,i,a){var o=r.get(y.dimension,a),u=y.isStacked?o-i:0,c=t.dataToPoint([e,n,u]),h=t.dataToPoint([e,n,o]),d=Math.max(h[2]-c[2],l),f=[s[0],d,s[1]];r.setItemLayout(a,[c,_,f])}),r.setLayout("orient",[1,0,0])}function o(e,t){var r=m(e,t[2]);return{dimension:r?e.getCalculationInfo("stackResultDimension"):t[2],isStacked:r}}var s=r(0),u=r.n(s),l=r(4),c=r(1),h=r.n(c),d=r(219),f=r(220),p=h.a.vec3,m=u.a.helper.dataStack.isDimensionStacked;u.a.registerLayout(function(e,t){e.eachSeriesByType("bar3D",function(e){var t=e.coordinateSystem,r=t&&t.type;"globe"===r?n(e,t):"cartesian3D"===r?Object(d.a)(e,t):"geo3D"===r?i(e,t):"mapbox3D"!==r&&"maptalks3D"!==r||a(e,t)})})},function(e,t,r){"use strict";function n(e){var t=e[0],r=e[1];return!(t>0&&r>0||t<0&&r<0)}function i(e,t){var r=e.getData(),i=e.get("barSize");if(null==i){var a,s,u=t.size,h=t.getAxis("x"),d=t.getAxis("y");a="category"===h.type?.7*h.getBandWidth():.6*Math.round(u[0]/Math.sqrt(r.count())),s="category"===d.type?.7*d.getBandWidth():.6*Math.round(u[1]/Math.sqrt(r.count())),i=[a,s]}else o.a.util.isArray(i)||(i=[i,i]);var f=t.getAxis("z").scale.getExtent(),p=n(f),m=["x","y","z"].map(function(t){return e.coordDimToDataDim(t)[0]}),g=c(r,m[2]),_=g?r.getCalculationInfo("stackResultDimension"):m[2];r.each(m,function(e,n,a,o){var s=r.get(_,o),u=g?s-a:p?0:f[0],c=t.dataToPoint([e,n,u]),h=t.dataToPoint([e,n,s]),d=l.dist(c,h),m=[0,h[1]0&&(p++,h[3]<.99&&(m=!0))}}),s.geometry.setBarCount(p);var g=r.getLayout("orient"),_=this._barIndexOfData=new Int32Array(r.count()),p=0;r.each(function(e){if(!r.hasValue(e))return void(_[e]=-1);var t=r.getItemLayout(e),n=t[0],i=t[1],a=t[2],s=4*e;h[0]=d[s++],h[1]=d[s++],h[2]=d[s++],h[3]=d[s++],h[3]>0&&(o._barMesh.geometry.addBar(n,i,g,a,h,e),_[e]=p++)}),s.geometry.dirty(),s.geometry.updateBoundingBox();var v=s.material;v.transparent=m,v.depthMask=!m,s.geometry.sortTriangles=m,this._initHandler(e,t)},_initHandler:function(e,t){var r=e.getData(),n=this._barMesh,i="cartesian3D"===e.coordinateSystem.type;n.seriesIndex=e.seriesIndex;var a=-1;n.off("mousemove"),n.off("mouseout"),n.on("mousemove",function(e){var o=n.geometry.getDataIndexOfVertex(e.triangle[0]);o!==a&&(this._downplay(a),this._highlight(o),this._labelsBuilder.updateLabels([o]),i&&t.dispatchAction({type:"grid3DShowAxisPointer",value:[r.get("x",o),r.get("y",o),r.get("z",o,!0)]})),a=o,n.dataIndex=o},this),n.on("mouseout",function(e){this._downplay(a),this._labelsBuilder.updateLabels(),a=-1,n.dataIndex=-1,i&&t.dispatchAction({type:"grid3DHideAxisPointer"})},this)},_highlight:function(e){var t=this._data;if(t){var r=this._barIndexOfData[e];if(!(r<0)){var n=t.getItemModel(e),o=n.getModel("emphasis.itemStyle"),s=o.get("color"),u=o.get("opacity");if(null==s){var l=t.getItemVisual(e,"color");s=i.a.color.lift(l,-.4)}null==u&&(u=t.getItemVisual(e,"opacity"));var c=a.a.parseColor(s);c[3]*=u,this._barMesh.geometry.setColor(r,c),this._api.getZr().refresh()}}},_downplay:function(e){var t=this._data;if(t){var r=this._barIndexOfData[e];if(!(r<0)){var n=t.getItemVisual(e,"color"),i=t.getItemVisual(e,"opacity"),o=a.a.parseColor(n);o[3]*=i,this._barMesh.geometry.setColor(r,o),this._api.getZr().refresh()}}},highlight:function(e,t,r,n){this._toggleStatus("highlight",e,t,r,n)},downplay:function(e,t,r,n){this._toggleStatus("downplay",e,t,r,n)},_toggleStatus:function(e,t,r,n,a){var u=t.getData(),l=o.a.queryDataIndex(u,a),c=this;null!=l?i.a.util.each(s.a.normalizeToArray(l),function(t){"highlight"===e?this._highlight(t):this._downplay(t)},this):u.each(function(t){"highlight"===e?c._highlight(t):c._downplay(t)})},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}})},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(34),o=r(60),s=r(13),u=r(1),l=r.n(u),c=l.a.vec3,h=l.a.mat3,d=s.a.extend(function(){return{attributes:{position:new s.a.Attribute("position","float",3,"POSITION"),normal:new s.a.Attribute("normal","float",3,"NORMAL"),color:new s.a.Attribute("color","float",4,"COLOR"),prevPosition:new s.a.Attribute("prevPosition","float",3),prevNormal:new s.a.Attribute("prevNormal","float",3)},dynamic:!0,enableNormal:!1,bevelSize:1,bevelSegments:0,_dataIndices:null,_vertexOffset:0,_triangleOffset:0}},{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0},setBarCount:function(e){var t=this.enableNormal,r=this.getBarVertexCount()*e,n=this.getBarTriangleCount()*e;this.vertexCount!==r&&(this.attributes.position.init(r),t?this.attributes.normal.init(r):this.attributes.normal.value=null,this.attributes.color.init(r)),this.triangleCount!==n&&(this.indices=r>65535?new Uint32Array(3*n):new Uint16Array(3*n),this._dataIndices=new Uint32Array(r))},getBarVertexCount:function(){var e=this.bevelSize>0?this.bevelSegments:0;return e>0?this._getBevelBarVertexCount(e):this.enableNormal?24:8},getBarTriangleCount:function(){var e=this.bevelSize>0?this.bevelSegments:0;return e>0?this._getBevelBarTriangleCount(e):12},_getBevelBarVertexCount:function(e){return 4*(e+1)*(e+1)*2},_getBevelBarTriangleCount:function(e){return(4*e+3+1)*(2*e+1)*2+4},setColor:function(e,t){for(var r=this.getBarVertexCount(),n=r*e,i=r*(e+1),a=n;a0&&this.bevelSegments>0)this._addBevelBar(e,d,g,_,this.bevelSize,this.bevelSegments,v);else{c.copy(i,d),c.normalize(i,i),c.cross(a,g,i),c.normalize(a,a),c.cross(n,i,a),c.normalize(a,a),c.negate(o,n),c.negate(s,i),c.negate(u,a),t(l[0],e,n,_[0]/2),t(l[0],l[0],a,_[2]/2),t(l[1],e,n,_[0]/2),t(l[1],l[1],u,_[2]/2),t(l[2],e,o,_[0]/2),t(l[2],l[2],u,_[2]/2),t(l[3],e,o,_[0]/2),t(l[3],l[3],a,_[2]/2),t(r,e,i,_[1]),t(l[4],r,n,_[0]/2),t(l[4],l[4],a,_[2]/2),t(l[5],r,n,_[0]/2),t(l[5],l[5],u,_[2]/2),t(l[6],r,o,_[0]/2),t(l[6],l[6],u,_[2]/2),t(l[7],r,o,_[0]/2),t(l[7],l[7],a,_[2]/2);var T=this.attributes;if(this.enableNormal){h[0]=n,h[1]=o,h[2]=i,h[3]=s,h[4]=a,h[5]=u;for(var b=this._vertexOffset,w=0;w=0){var T=3*c,b=new l.a(this._points[T],this._points[T+1],this._points[T+2]);a.push({dataIndex:c,point:b,pointWorld:b.clone(),target:this._line3DMesh,distance:this._camera.getWorldPosition().dist(b)})}},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}})},function(e,t){function r(e,t,r,n,i,a,o){if(0===i)return!1;var s=i,u=0,l=e;if(o>t+s&&o>n+s||oe+s&&a>r+s||ao?l.position[1]+=(c-o)/2:l.position[0]+=(c-a)/2;var h=l.getBoundingRect();return l.position[0]-=h.x,l.position[1]-=h.y,l.setStyle(r),l.update(),l.__size=c,l}function a(e,t,r){function n(e){return e<128?1:-1}for(var i=t.width,a=t.height,o=e.canvas.width,s=e.canvas.height,u=i/o,l=a/s,c=e.createImageData(o,s),h=0;h=0;h--){var d;d=this.geometry.indices?this.geometry.indices[h]:h;var f=s[2*d],p=s[2*d+1],m=this.geometry.attributes.size.get(d)/this.sizeScale,g=m/2;if(e>f-g*l&&ep-g*c&&t=2e4},doSortVertices:function(e,t){var r=this.indices,n=o.create();if(!r){r=this.indices=this.vertexCount>65535?new Uint32Array(this.vertexCount):new Uint16Array(this.vertexCount);for(var i=0;i.05);else for(var i=0;i<3;i++)this._progressiveQuickSort(3*t+i);this.dirtyIndices()},_simpleSort:function(e){function t(e,t){return r[t]-r[e]}var r=this._zList,i=this.indices;e?Array.prototype.sort.call(i,t):n.a.sort(i,t,0,i.length-1)},_progressiveQuickSort:function(e){var t=this._zList,r=this.indices;this._quickSort=this._quickSort||new n.a,this._quickSort.step(r,function(e,r){return t[r]-t[e]},e)}}},function(e,t,r){"use strict";t.a="@export ecgl.sdfSprite.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform float elapsedTime : 0;\n\nattribute vec3 position : POSITION;\n\n#ifdef VERTEX_SIZE\nattribute float size;\n#else\nuniform float u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_FillColor: COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute float prevSize;\nuniform float percent : 1.0;\n#endif\n\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvarying float v_Size;\n\nvoid main()\n{\n\n#ifdef POSITIONTEXTURE_ENABLED\n gl_Position = worldViewProjection * vec4(texture2D(positionTexture, position.xy).xy, -10.0, 1.0);\n#else\n\n #ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n #else\n vec3 pos = position;\n #endif\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n#endif\n\n#ifdef VERTEX_SIZE\n#ifdef VERTEX_ANIMATION\n v_Size = mix(prevSize, size, percent);\n#else\n v_Size = size;\n#endif\n#else\n v_Size = u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = a_FillColor;\n #endif\n\n gl_PointSize = v_Size;\n}\n\n@end\n\n@export ecgl.sdfSprite.fragment\n\nuniform vec4 color: [1, 1, 1, 1];\nuniform vec4 strokeColor: [1, 1, 1, 1];\nuniform float smoothing: 0.07;\n\nuniform float lineWidth: 0.0;\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\nvarying float v_Size;\n\nuniform sampler2D sprite;\n\n@import clay.util.srgb\n\nvoid main()\n{\n gl_FragColor = color;\n\n vec4 _strokeColor = strokeColor;\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n #endif\n\n#ifdef SPRITE_ENABLED\n float d = texture2D(sprite, gl_PointCoord).r;\n gl_FragColor.a *= smoothstep(0.5 - smoothing, 0.5 + smoothing, d);\n\n if (lineWidth > 0.0) {\n float sLineWidth = lineWidth / 2.0;\n\n float outlineMaxValue0 = 0.5 + sLineWidth;\n float outlineMaxValue1 = 0.5 + sLineWidth + smoothing;\n float outlineMinValue0 = 0.5 - sLineWidth - smoothing;\n float outlineMinValue1 = 0.5 - sLineWidth;\n\n if (d <= outlineMaxValue1 && d >= outlineMinValue0) {\n float a = _strokeColor.a;\n if (d <= outlineMinValue1) {\n a = a * smoothstep(outlineMinValue0, outlineMinValue1, d);\n }\n else {\n a = a * smoothstep(outlineMaxValue1, outlineMaxValue0, d);\n }\n gl_FragColor.rgb = mix(gl_FragColor.rgb * gl_FragColor.a, _strokeColor.rgb, a);\n gl_FragColor.a = gl_FragColor.a * (1.0 - a) + a;\n }\n }\n#endif\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(gl_FragColor);\n#endif\n}\n@end"},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=(r(236),r(237),r(240),r(16));i.a.registerVisual(Object(a.a)("lines3D")),i.a.registerAction({type:"lines3DPauseEffect",event:"lines3deffectpaused",update:"series.lines3D:pauseEffect"},function(){}),i.a.registerAction({type:"lines3DResumeEffect",event:"lines3deffectresumed",update:"series.lines3D:resumeEffect"},function(){}),i.a.registerAction({type:"lines3DToggleEffect",event:"lines3deffectchanged",update:"series.lines3D:toggleEffect"},function(){})},function(e,t,r){"use strict";function n(e,t){p.copy(E,e[0]),p.copy(S,e[1]);var r=[],n=r[0]=y(),i=r[1]=y(),a=r[2]=y(),o=r[3]=y();t.dataToPoint(E,n),t.dataToPoint(S,o),m(x,n),_(T,o,n),m(T,T),g(b,T,x),m(b,b),g(T,x,b),v(i,x,T),m(i,i),m(x,o),_(T,n,o),m(T,T),g(b,T,x),m(b,b),g(T,x,b),v(a,x,T),m(a,a),v(w,n,o),m(w,w);var s=f.dot(n,w),u=f.dot(w,i),l=(Math.max(f.len(n),f.len(o))-s)/u*2;return f.scaleAndAdd(i,n,i,l),f.scaleAndAdd(a,o,a,l),r}function i(e,t,r){var n=[],i=n[0]=f.create(),a=n[1]=f.create(),o=n[2]=f.create(),s=n[3]=f.create();t.dataToPoint(e[0],i),t.dataToPoint(e[1],s);var u=f.dist(i,s);return f.lerp(a,i,s,.3),f.lerp(o,i,s,.3),f.scaleAndAdd(a,a,r,Math.min(.1*u,10)),f.scaleAndAdd(o,o,r,Math.min(.1*u,10)),n}function a(e,t){for(var r=new Float32Array(3*e.length),n=0,i=[],a=0;a0?1:-1}var i=r(0),a=(r.n(i),r(2)),o=r(1),s=r.n(o),u=r(22),l=r(239),c=s.a.vec3;a.a.Shader.import(l.a),t.a=a.a.Mesh.extend(function(){var e=new a.a.Material({shader:new a.a.Shader(a.a.Shader.source("ecgl.trail2.vertex"),a.a.Shader.source("ecgl.trail2.fragment")),transparent:!0,depthMask:!1}),t=new u.a({dynamic:!0});return t.createAttribute("dist","float",1),t.createAttribute("distAll","float",1),t.createAttribute("start","float",1),{geometry:t,material:e,culling:!1,$ignorePicking:!0}},{updateData:function(e,t,r){var i=e.hostModel,o=this.geometry,s=i.getModel("effect"),u=s.get("trailWidth")*t.getDevicePixelRatio(),l=s.get("trailLength"),h=i.get("effect.constantSpeed"),d=1e3*i.get("effect.period"),f=null!=h;f?this.material.set("speed",h/1e3):this.material.set("period",d),this.material[f?"define":"undefine"]("vertex","CONSTANT_SPEED");var p=i.get("polyline");o.trailLength=l,this.material.set("trailLength",l),o.resetOffset(),["position","positionPrev","positionNext"].forEach(function(e){o.attributes[e].value=r.attributes[e].value}),["dist","distAll","start","offset","color"].forEach(function(e){o.attributes[e].init(o.vertexCount)}),o.indices=r.indices;var m=[],g=s.get("trailColor"),_=s.get("trailOpacity"),v=null!=g,y=null!=_;this.updateWorldTransform();var x=this.worldTransform.x.len(),T=this.worldTransform.y.len(),b=this.worldTransform.z.len(),w=0,E=0;e.each(function(t){var i=e.getItemLayout(t),s=y?_:e.getItemVisual(t,"opacity"),l=e.getItemVisual(t,"color");null==s&&(s=1),m=a.a.parseColor(v?g:l,m),m[3]*=s;for(var h=p?r.getPolylineVertexCount(i):r.getCubicCurveVertexCount(i[0],i[1],i[2],i[3]),S=0,A=[],M=[],C=w;Cw&&(S+=c.dist(A,M)),o.attributes.dist.set(C,S),c.copy(M,A);E=Math.max(E,S);for(var L=Math.random()*(f?S:d),C=w;C0;this._updateSurfaceMesh(this._surfaceMesh,e,h,p);var m=this._surfaceMesh.material;p?(m.define("WIREFRAME_QUAD"),m.set("wireframeLineWidth",f),m.set("wireframeLineColor",o.a.parseColor(d.get("lineStyle.color")))):m.undefine("WIREFRAME_QUAD"),this._initHandler(e,r),this._updateAnimation(e)},_updateAnimation:function(e){o.a.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevSurfaceMesh,this._surfaceMesh,e)},_createSurfaceMesh:function(){var e=new o.a.Mesh({geometry:new o.a.Geometry({dynamic:!0,sortTriangles:!0}),shadowDepthMaterial:new o.a.Material({shader:new o.a.Shader(o.a.Shader.source("ecgl.sm.depth.vertex"),o.a.Shader.source("ecgl.sm.depth.fragment"))}),culling:!1,renderOrder:10,renderNormal:!0});return e.geometry.createAttribute("barycentric","float",4),e.geometry.createAttribute("prevPosition","float",3),e.geometry.createAttribute("prevNormal","float",3),a.a.util.extend(e.geometry,l.a),e},_initHandler:function(e,t){function r(e,t){for(var r=1/0,n=-1,a=[],o=0;o=0){var u=[];i.geometry.attributes.position.get(s,u);for(var l=a.pointToData(u),h=1/0,d=-1,f=[],p=0;p65535?Uint32Array:Uint16Array)((_-1)*(v-1)*6),S=function(e,t,r){r[1]=e*v+t,r[0]=e*v+t+1,r[3]=(e+1)*v+t+1,r[2]=(e+1)*v+t},A=!1;if(h){var M=[],C=[],L=0;x?f.init(a.vertexCount):f.value=null;for(var D=[[],[],[]],N=[],R=[],P=c.create(),I=function(e,t,r){var n=3*t;return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r},O=new Float32Array(u.length),F=new Float32Array(u.length/3*4),B=0;B ")),a.value&&(c+=" : "+i.a.format.encodeHTML(a.value)),c}return s.superApply(this,"formatTooltip",arguments)},_updateCategoriesData:function(){var e=(this.option.categories||[]).map(function(e){return null!=e.value?e:i.a.util.extend({value:0},e)}),t=new i.a.List(["value"],this);t.initData(e),this._categoriesData=t,this._categoriesModels=t.mapArray(function(e){return t.getItemModel(e,!0)})},setView:function(e){null!=e.zoom&&(this.option.zoom=e.zoom),null!=e.offset&&(this.option.offset=e.offset)},setNodePosition:function(e){for(var t=0;t "+g)),f++)}var _,v=i.a.helper.completeDimensions(["value"],e);_=new i.a.List(v,r),_.initData(e);var y=new i.a.List(["value"],r);return y.initData(d,h),a&&a(_,y),u()({mainData:_,struct:s,structAttr:"graph",datas:{node:_,edge:y},datasAttr:{node:"data",edge:"edgeData"}}),s.update(),s}},function(e,t,r){function n(e){return"_EC_"+e}function i(e,t){this.id=null==e?"":e,this.inEdges=[],this.outEdges=[],this.edges=[],this.hostGraph,this.dataIndex=null==t?-1:t}function a(e,t,r){this.node1=e,this.node2=t,this.dataIndex=null==r?-1:r}var o=r(97),s=(o.__DEV__,r(12)),u=r(258),l=u.enableClassCheck,c=function(e){this._directed=e||!1,this.nodes=[],this.edges=[],this._nodesMap={},this._edgesMap={},this.data,this.edgeData},h=c.prototype;h.type="graph",h.isDirected=function(){return this._directed},h.addNode=function(e,t){e=e||""+t;var r=this._nodesMap;if(!r[n(e)]){var a=new i(e,t);return a.hostGraph=this,this.nodes.push(a),r[n(e)]=a,a}},h.getNodeByIndex=function(e){var t=this.data.getRawIndex(e);return this.nodes[t]},h.getNodeById=function(e){return this._nodesMap[n(e)]},h.addEdge=function(e,t,r){var o=this._nodesMap,s=this._edgesMap;if("number"==typeof e&&(e=this.nodes[e]),"number"==typeof t&&(t=this.nodes[t]),i.isInstance(e)||(e=o[n(e)]),i.isInstance(t)||(t=o[n(t)]),e&&t){var u=e.id+"-"+t.id;if(!s[u]){var l=new a(e,t,r);return l.hostGraph=this,this._directed&&(e.outEdges.push(l),t.inEdges.push(l)),e.edges.push(l),e!==t&&t.edges.push(l),this.edges.push(l),s[u]=l,l}}},h.getEdgeByIndex=function(e){var t=this.edgeData.getRawIndex(e);return this.edges[t]},h.getEdge=function(e,t){i.isInstance(e)&&(e=e.id),i.isInstance(t)&&(t=t.id);var r=this._edgesMap;return this._directed?r[e+"-"+t]:r[e+"-"+t]||r[t+"-"+e]},h.eachNode=function(e,t){for(var r=this.nodes,n=r.length,i=0;i=0&&e.call(t,r[i],i)},h.eachEdge=function(e,t){for(var r=this.edges,n=r.length,i=0;i=0&&r[i].node1.dataIndex>=0&&r[i].node2.dataIndex>=0&&e.call(t,r[i],i)},h.breadthFirstTraverse=function(e,t,r,a){if(i.isInstance(t)||(t=this._nodesMap[n(t)]),t){for(var o="out"===r?"outEdges":"in"===r?"inEdges":"edges",s=0;s=0&&r.node2.dataIndex>=0});for(var i=0,a=n.length;i=0&&this[e][t].setItemVisual(this.dataIndex,r,n)},getVisual:function(r,n){return this[e][t].getItemVisual(this.dataIndex,r,n)},setLayout:function(r,n){this.dataIndex>=0&&this[e][t].setItemLayout(this.dataIndex,r,n)},getLayout:function(){return this[e][t].getItemLayout(this.dataIndex)},getGraphicEl:function(){return this[e][t].getItemGraphicEl(this.dataIndex)},getRawIndex:function(){return this[e][t].getRawIndex(this.dataIndex)}}};s.mixin(i,d("hostGraph","data")),s.mixin(a,d("hostGraph","edgeData")),c.Node=i,c.Edge=a,l(i),l(a);var f=c;e.exports=f},function(e,t,r){function n(e){var t={main:"",sub:""};return e&&(e=e.split(f),t.main=e[0]||"",t.sub=e[1]||""),t}function i(e){d.assert(/^[a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)?$/.test(e),'componentType "'+e+'" illegal')}function a(e,t){e.$constructor=e,e.extend=function(e){var t=this,r=function(){e.$constructor?e.$constructor.apply(this,arguments):t.apply(this,arguments)};return d.extend(r.prototype,e),r.extend=this.extend,r.superCall=s,r.superApply=u,d.inherits(r,this),r.superClass=t,r}}function o(e){var t=["__\0is_clz",m++,Math.random().toFixed(3)].join("_");e.prototype[t]=!0,e.isInstance=function(e){return!(!e||!e[t])}}function s(e,t){var r=d.slice(arguments,2);return this.superClass.prototype[t].apply(e,r)}function u(e,t,r){return this.superClass.prototype[t].apply(e,r)}function l(e,t){function r(e){var t=a[e.main];return t&&t[p]||(t=a[e.main]={},t[p]=!0),t}t=t||{};var a={};if(e.registerClass=function(e,t){if(t)if(i(t),t=n(t),t.sub){if(t.sub!==p){var o=r(t);o[t.sub]=e}}else a[t.main]=e;return e},e.getClass=function(e,t,r){var n=a[e];if(n&&n[p]&&(n=t?n[t]:null),r&&!n)throw new Error(t?"Component "+e+"."+(t||"")+" not exists. Load it first.":e+".type should be specified.");return n},e.getClassesByMainType=function(e){e=n(e);var t=[],r=a[e.main];return r&&r[p]?d.each(r,function(e,r){r!==p&&t.push(e)}):t.push(r),t},e.hasClass=function(e){return e=n(e),!!a[e.main]},e.getAllClassMainTypes=function(){var e=[];return d.each(a,function(t,r){e.push(r)}),e},e.hasSubTypes=function(e){e=n(e);var t=a[e.main];return t&&t[p]},e.parseClassType=n,t.registerWhenExtend){var o=e.extend;o&&(e.extend=function(t){var r=o.call(this,t);return e.registerClass(r,t.type)})}return e}function c(e,t){}var h=r(97),d=(h.__DEV__,r(12)),f=".",p="___EC__COMPONENT__CONTAINER___",m=0;t.parseClassType=n,t.enableClassExtend=a,t.enableClassCheck=o,t.enableClassManagement=l,t.setReadOnly=c},function(e,t,r){function n(e){var t=e.mainData,r=e.datas;r||(r={main:t},e.datasAttr={main:"data"}),e.datas=e.mainData=null,l(t,r,e),d(r,function(r){d(t.TRANSFERABLE_METHODS,function(t){r.wrapMethod(t,h.curry(i,e))})}),t.wrapMethod("cloneShallow",h.curry(o,e)),d(t.CHANGABLE_METHODS,function(r){t.wrapMethod(r,h.curry(a,e))}),h.assert(r[t.dataType]===t)}function i(e,t){if(u(this)){var r=h.extend({},this[f]);r[this.dataType]=t,l(t,r,e)}else c(t,this.dataType,this[p],e);return t}function a(e,t){return e.struct&&e.struct.update(this),t}function o(e,t){return d(t[f],function(r,n){r!==t&&c(r.cloneShallow(),n,t,e)}),t}function s(e){var t=this[p];return null==e||null==t?t:t[f][e]}function u(e){return e[p]===e}function l(e,t,r){e[f]={},d(t,function(t,n){c(t,n,e,r)})}function c(e,t,r,n){r[f][t]=e,e[p]=r,e.dataType=t,n.struct&&(e[n.structAttr]=n.struct,n.struct[n.datasAttr[t]]=e),e.getLinkedData=s}var h=r(12),d=h.each,f="\0__link_datas",p="\0__link_mainData",m=n;e.exports=m},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(41),o=r.n(a),s=r(2),u=r(19),l=r(98),c=r(3),h=r(261),d=r(263),f=r(72),p=r.n(f),m=r(1),g=r.n(m),_=r(265),v=r(62),y=r(266),x=g.a.vec2;s.a.Shader.import(y.a);var T=1;i.a.extendChartView({type:"graphGL",__ecgl__:!0,init:function(e,t){this.groupGL=new s.a.Node,this.viewGL=new u.a("orthographic"),this.viewGL.camera.left=this.viewGL.camera.right=0,this.viewGL.add(this.groupGL),this._pointsBuilder=new v.a(!0,t),this._forceEdgesMesh=new s.a.Mesh({material:new s.a.Material({shader:s.a.createShader("ecgl.forceAtlas2.edges"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new s.a.Geometry({attributes:{node:new s.a.Geometry.Attribute("node","float",2),color:new s.a.Geometry.Attribute("color","float",4,"COLOR")},dynamic:!0,mainAttribute:"node"}),renderOrder:-1,mode:s.a.Mesh.LINES}),this._edgesMesh=new s.a.Mesh({material:new s.a.Material({shader:s.a.createShader("ecgl.meshLines2D"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new l.a({useNativeLine:!1,dynamic:!0}),renderOrder:-1,culling:!1}),this._layoutId=0,this._control=new _.a({zr:t.getZr(),viewGL:this.viewGL}),this._control.setTarget(this.groupGL),this._control.init(),this._clickHandler=this._clickHandler.bind(this)},render:function(e,t,r){this.groupGL.add(this._pointsBuilder.rootNode),this._model=e,this._api=r,this._initLayout(e,t,r),this._pointsBuilder.update(e,t,r),this._forceLayoutInstance instanceof h.a||this.groupGL.remove(this._forceEdgesMesh),this._updateCamera(e,r),this._control.off("update"),this._control.on("update",function(){r.dispatchAction({type:"graphGLRoam",seriesId:e.id,zoom:this._control.getZoom(),offset:this._control.getOffset()}),this._pointsBuilder.updateView(this.viewGL.camera)},this),this._control.setZoom(c.a.firstNotNull(e.get("zoom"),1)),this._control.setOffset(e.get("offset")||[0,0]);var n=this._pointsBuilder.getPointsMesh();if(n.off("mousemove",this._mousemoveHandler),n.off("mouseout",this._mouseOutHandler,this),r.getZr().off("click",this._clickHandler),this._pointsBuilder.highlightOnMouseover=!0,e.get("focusNodeAdjacency")){var i=e.get("focusNodeAdjacencyOn");"click"===i?r.getZr().on("click",this._clickHandler):"mouseover"===i&&(n.on("mousemove",this._mousemoveHandler,this),n.on("mouseout",this._mouseOutHandler,this),this._pointsBuilder.highlightOnMouseover=!1)}this._lastMouseOverDataIndex=-1},_clickHandler:function(e){if(!this._layouting){var t=this._pointsBuilder.getPointsMesh().dataIndex;t>=0?this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:t}):this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id})}},_mousemoveHandler:function(e){if(!this._layouting){var t=this._pointsBuilder.getPointsMesh().dataIndex;t>=0?t!==this._lastMouseOverDataIndex&&this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:t}):this._mouseOutHandler(e),this._lastMouseOverDataIndex=t}},_mouseOutHandler:function(e){this._layouting||(this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id}),this._lastMouseOverDataIndex=-1)},_updateForceEdgesGeometry:function(e,t){var r=this._forceEdgesMesh.geometry,n=t.getEdgeData(),i=0,a=this._forceLayoutInstance,o=2*n.count();r.attributes.node.init(o),r.attributes.color.init(o),n.each(function(t){var o=e[t];r.attributes.node.set(i,a.getNodeUV(o.node1)),r.attributes.node.set(i+1,a.getNodeUV(o.node2));var u=n.getItemVisual(o.dataIndex,"color"),l=s.a.parseColor(u);l[3]*=c.a.firstNotNull(n.getItemVisual(o.dataIndex,"opacity"),1),r.attributes.color.set(i,l),r.attributes.color.set(i+1,l),i+=2}),r.dirty()},_updateMeshLinesGeometry:function(){var e=this._model.getEdgeData(),t=this._edgesMesh.geometry,e=this._model.getEdgeData(),r=this._model.getData().getLayout("points");t.resetOffset(),t.setVertexCount(e.count()*t.getLineVertexCount()),t.setTriangleCount(e.count()*t.getLineTriangleCount());var n=[],i=[],a=["lineStyle","width"];this._originalEdgeColors=new Float32Array(4*e.count()),this._edgeIndicesMap=new Float32Array(e.count()),e.each(function(o){var u=e.graph.getEdgeByIndex(o),l=2*u.node1.dataIndex,h=2*u.node2.dataIndex;n[0]=r[l],n[1]=r[l+1],i[0]=r[h],i[1]=r[h+1];var d=e.getItemVisual(u.dataIndex,"color"),f=s.a.parseColor(d);f[3]*=c.a.firstNotNull(e.getItemVisual(u.dataIndex,"opacity"),1);var p=e.getItemModel(u.dataIndex),m=c.a.firstNotNull(p.get(a),1)*this._api.getDevicePixelRatio();t.addLine(n,i,f,m);for(var g=0;g<4;g++)this._originalEdgeColors[4*u.dataIndex+g]=f[g];this._edgeIndicesMap[u.dataIndex]=o},this),t.dirty()},_updateForceNodesGeometry:function(e){for(var t=this._pointsBuilder.getPointsMesh(),r=[],n=0;n=f&&(u._syncNodePosition(e),d=0),r.getZr().refresh(),p()(function(){m(t)})})};p()(function(){u._forceLayoutInstanceToDispose&&(u._forceLayoutInstanceToDispose.dispose(i.layer.renderer),u._forceLayoutInstanceToDispose=null),m(l)}),this._layouting=!0}}},stopLayout:function(e,t,r,n){n&&null!=n.from&&n.from!==this.uid||(this._layoutId=0,this.groupGL.remove(this._forceEdgesMesh),this.groupGL.add(this._edgesMesh),this._forceLayoutInstance&&this.viewGL.layer&&(n&&n.beforeLayout||(this._syncNodePosition(e),this._updateAfterLayout(e,t,r)),this._api.getZr().refresh(),this._layouting=!1))},_syncNodePosition:function(e){var t=this._forceLayoutInstance.getNodePosition(this.viewGL.layer.renderer);e.getData().setLayout("points",t),e.setNodePosition(t)},_updateAfterLayout:function(e,t,r){this._updateMeshLinesGeometry(),this._pointsBuilder.removePositionTexture(),this._pointsBuilder.updateLayout(e,t,r),this._pointsBuilder.updateView(this.viewGL.camera),this._pointsBuilder.updateLabels(),this._pointsBuilder.showLabels()},focusNodeAdjacency:function(e,t,r,n){var i=this._model.getData();this._downplayAll();var a=n.dataIndex,o=i.graph,s=[],u=o.getNodeByIndex(a);s.push(u),u.edges.forEach(function(e){e.dataIndex<0||(e.node1!==u&&s.push(e.node1),e.node2!==u&&s.push(e.node2))},this),this._pointsBuilder.fadeOutAll(.05),this._fadeOutEdgesAll(.05),s.forEach(function(e){this._pointsBuilder.highlight(i,e.dataIndex)},this),this._pointsBuilder.updateLabels(s.map(function(e){return e.dataIndex}));var l=[];u.edges.forEach(function(e){e.dataIndex>=0&&(this._highlightEdge(e.dataIndex),l.push(e))},this),this._focusNodes=s,this._focusEdges=l},unfocusNodeAdjacency:function(e,t,r,n){this._downplayAll(),this._pointsBuilder.fadeInAll(),this._fadeInEdgesAll(),this._pointsBuilder.updateLabels()},_highlightEdge:function(e){var t=this._model.getEdgeData().getItemModel(e),r=s.a.parseColor(t.get("emphasis.lineStyle.color")||t.get("lineStyle.color")),n=c.a.firstNotNull(t.get("emphasis.lineStyle.opacity"),t.get("lineStyle.opacity"),1);r[3]*=n,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e],r)},_downplayAll:function(){this._focusNodes&&this._focusNodes.forEach(function(e){this._pointsBuilder.downplay(this._model.getData(),e.dataIndex)},this),this._focusEdges&&this._focusEdges.forEach(function(e){this._downplayEdge(e.dataIndex)},this)},_downplayEdge:function(e){var t=this._getColor(e,[]);this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e],t)},_setEdgeFade:function(){var e=[];return function(t,r){this._getColor(t,e),e[3]*=r,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],e)}}(),_getColor:function(e,t){for(var r=0;r<4;r++)t[r]=this._originalEdgeColors[4*e+r];return t},_fadeOutEdgesAll:function(e){this._model.getData().graph.eachEdge(function(t){this._setEdgeFade(t.dataIndex,e)},this)},_fadeInEdgesAll:function(){this._fadeOutEdgesAll(1)},_updateCamera:function(e,t){this.viewGL.setViewport(0,0,t.getWidth(),t.getHeight(),t.getDevicePixelRatio());for(var r=this.viewGL.camera,n=e.getData(),i=n.getLayout("points"),a=x.create(1/0,1/0),o=x.create(-1/0,-1/0),s=[],u=0;ur.left&&cr.top)){var h=Math.max(o[0]-a[0],10),d=h/t.getWidth()*t.getHeight();h*=1.4,d*=1.4,a[0]-=.2*h,r.left=a[0],r.top=l-d/2,r.bottom=l+d/2,r.right=h+a[0],r.near=0,r.far=100}},dispose:function(){var e=this.viewGL.layer.renderer;this._forceLayoutInstance&&this._forceLayoutInstance.dispose(e),this.groupGL.removeAll(),this._layoutId=-1},remove:function(){this.groupGL.removeAll(),this._control.dispose()}})},function(e,t,r){"use strict";function n(e){var t={type:o.a.Texture.FLOAT,minFilter:o.a.Texture.NEAREST,magFilter:o.a.Texture.NEAREST};this._positionSourceTex=new o.a.Texture2D(t),this._positionSourceTex.flipY=!1,this._positionTex=new o.a.Texture2D(t),this._positionPrevTex=new o.a.Texture2D(t),this._forceTex=new o.a.Texture2D(t),this._forcePrevTex=new o.a.Texture2D(t),this._weightedSumTex=new o.a.Texture2D(t),this._weightedSumTex.width=this._weightedSumTex.height=1,this._globalSpeedTex=new o.a.Texture2D(t),this._globalSpeedPrevTex=new o.a.Texture2D(t),this._globalSpeedTex.width=this._globalSpeedTex.height=1,this._globalSpeedPrevTex.width=this._globalSpeedPrevTex.height=1,this._nodeRepulsionPass=new s.a({fragment:o.a.Shader.source("ecgl.forceAtlas2.updateNodeRepulsion")}),this._positionPass=new s.a({fragment:o.a.Shader.source("ecgl.forceAtlas2.updatePosition")}),this._globalSpeedPass=new s.a({fragment:o.a.Shader.source("ecgl.forceAtlas2.calcGlobalSpeed")}),this._copyPass=new s.a({fragment:o.a.Shader.source("clay.compositor.output")});var r=function(e){e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE)};this._edgeForceMesh=new o.a.Mesh({geometry:new o.a.Geometry({attributes:{node1:new o.a.Geometry.Attribute("node1","float",2),node2:new o.a.Geometry.Attribute("node2","float",2),weight:new o.a.Geometry.Attribute("weight","float",1)},dynamic:!0,mainAttribute:"node1"}),material:new o.a.Material({transparent:!0,shader:o.a.createShader("ecgl.forceAtlas2.updateEdgeAttraction"),blend:r,depthMask:!1,depthText:!1}),mode:o.a.Mesh.POINTS}),this._weightedSumMesh=new o.a.Mesh({geometry:new o.a.Geometry({attributes:{node:new o.a.Geometry.Attribute("node","float",2)},dynamic:!0,mainAttribute:"node"}),material:new o.a.Material({transparent:!0,shader:o.a.createShader("ecgl.forceAtlas2.calcWeightedSum"),blend:r,depthMask:!1,depthText:!1}),mode:o.a.Mesh.POINTS}),this._framebuffer=new u.a({depthBuffer:!1}),this._dummyCamera=new o.a.OrthographicCamera({left:-1,right:1,top:1,bottom:-1,near:0,far:100}),this._globalSpeed=0}var i=r(0),a=r.n(i),o=r(2),s=r(14),u=r(10),l=r(262);o.a.Shader.import(l.a);var c={repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null};n.prototype.updateOption=function(e){for(var t in c)this[t]=c[t];var r=this._nodes.length;if(this.jitterTolerence=r>5e4?10:r>5e3?1:.1,this.scaling=r>100?2:10,e)for(var t in c)null!=e[t]&&(this[t]=e[t]);if(this.repulsionByDegree)for(var n=this._positionSourceTex.pixels,i=0;ie},n.prototype._swapTexture=function(){var e=this._positionPrevTex;this._positionPrevTex=this._positionTex,this._positionTex=e;var e=this._forcePrevTex;this._forcePrevTex=this._forceTex,this._forceTex=e;var e=this._globalSpeedPrevTex;this._globalSpeedPrevTex=this._globalSpeedTex,this._globalSpeedTex=e},n.prototype._initFromSource=function(e){this._framebuffer.attach(this._positionPrevTex),this._framebuffer.bind(e),this._copyPass.setUniform("texture",this._positionSourceTex),this._copyPass.render(e),e.gl.clearColor(0,0,0,0),this._framebuffer.attach(this._forcePrevTex),e.gl.clear(e.gl.COLOR_BUFFER_BIT),this._framebuffer.attach(this._globalSpeedPrevTex),e.gl.clear(e.gl.COLOR_BUFFER_BIT),this._framebuffer.unbind(e)},n.prototype._resize=function(e,t){["_positionSourceTex","_positionTex","_positionPrevTex","_forceTex","_forcePrevTex"].forEach(function(r){this[r].width=e,this[r].height=t,this[r].dirty()},this)},n.prototype.dispose=function(e){this._framebuffer.dispose(e),this._copyPass.dispose(e),this._nodeRepulsionPass.dispose(e),this._positionPass.dispose(e),this._globalSpeedPass.dispose(e),this._edgeForceMesh.geometry.dispose(e),this._weightedSumMesh.geometry.dispose(e),this._positionSourceTex.dispose(e),this._positionTex.dispose(e),this._positionPrevTex.dispose(e),this._forceTex.dispose(e),this._forcePrevTex.dispose(e),this._weightedSumTex.dispose(e),this._globalSpeedTex.dispose(e),this._globalSpeedPrevTex.dispose(e)},a.a.ForceAtlas2GPU=n,t.a=n},function(e,t,r){"use strict";t.a="@export ecgl.forceAtlas2.updateNodeRepulsion\n\n#define NODE_COUNT 0\n\nuniform sampler2D positionTex;\n\nuniform vec2 textureSize;\nuniform float gravity;\nuniform float scaling;\nuniform vec2 gravityCenter;\n\nuniform bool strongGravityMode;\nuniform bool preventOverlap;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, v_Texcoord);\n\n vec2 force = vec2(0.0);\n for (int i = 0; i < NODE_COUNT; i++) {\n vec2 uv = vec2(\n mod(float(i), textureSize.x) / (textureSize.x - 1.0),\n floor(float(i) / textureSize.x) / (textureSize.y - 1.0)\n );\n vec4 n1 = texture2D(positionTex, uv);\n\n vec2 dir = n0.xy - n1.xy;\n float d2 = dot(dir, dir);\n\n if (d2 > 0.0) {\n float factor = 0.0;\n if (preventOverlap) {\n float d = sqrt(d2);\n d = d - n0.w - n1.w;\n if (d > 0.0) {\n factor = scaling * n0.z * n1.z / (d * d);\n }\n else if (d < 0.0) {\n factor = scaling * 100.0 * n0.z * n1.z;\n }\n }\n else {\n factor = scaling * n0.z * n1.z / d2;\n }\n force += dir * factor;\n }\n }\n\n vec2 dir = gravityCenter - n0.xy;\n float d = 1.0;\n if (!strongGravityMode) {\n d = length(dir);\n }\n\n force += dir * n0.z * gravity / (d + 1.0);\n\n gl_FragColor = vec4(force, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.vertex\n\nattribute vec2 node1;\nattribute vec2 node2;\nattribute float weight;\n\nuniform sampler2D positionTex;\nuniform float edgeWeightInfluence;\nuniform bool preventOverlap;\nuniform bool linLogMode;\n\nuniform vec2 windowSize: WINDOW_SIZE;\n\nvarying vec2 v_Force;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, node1);\n vec4 n1 = texture2D(positionTex, node2);\n\n vec2 dir = n1.xy - n0.xy;\n float d = length(dir);\n float w;\n if (edgeWeightInfluence == 0.0) {\n w = 1.0;\n }\n else if (edgeWeightInfluence == 1.0) {\n w = weight;\n }\n else {\n w = pow(weight, edgeWeightInfluence);\n }\n vec2 offset = vec2(1.0 / windowSize.x, 1.0 / windowSize.y);\n vec2 scale = vec2((windowSize.x - 1.0) / windowSize.x, (windowSize.y - 1.0) / windowSize.y);\n vec2 pos = node1 * scale * 2.0 - 1.0;\n gl_Position = vec4(pos + offset, 0.0, 1.0);\n gl_PointSize = 1.0;\n\n float factor;\n if (preventOverlap) {\n d = d - n1.w - n0.w;\n }\n if (d <= 0.0) {\n v_Force = vec2(0.0);\n return;\n }\n\n if (linLogMode) {\n factor = w * log(d) / d;\n }\n else {\n factor = w;\n }\n v_Force = dir * factor;\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.fragment\n\nvarying vec2 v_Force;\n\nvoid main() {\n gl_FragColor = vec4(v_Force, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.vertex\n\nattribute vec2 node;\n\nvarying vec2 v_NodeUv;\n\nvoid main() {\n\n v_NodeUv = node;\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n gl_PointSize = 1.0;\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.fragment\n\nvarying vec2 v_NodeUv;\n\nuniform sampler2D positionTex;\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_NodeUv).rg;\n vec2 forcePrev = texture2D(forcePrevTex, v_NodeUv).rg;\n\n float mass = texture2D(positionTex, v_NodeUv).z;\n float swing = length(force - forcePrev) * mass;\n float traction = length(force + forcePrev) * 0.5 * mass;\n\n gl_FragColor = vec4(swing, traction, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcGlobalSpeed\n\nuniform sampler2D globalSpeedPrevTex;\nuniform sampler2D weightedSumTex;\nuniform float jitterTolerence;\n\nvoid main() {\n vec2 weightedSum = texture2D(weightedSumTex, vec2(0.5)).xy;\n float prevGlobalSpeed = texture2D(globalSpeedPrevTex, vec2(0.5)).x;\n float globalSpeed = jitterTolerence * jitterTolerence\n * weightedSum.y / weightedSum.x;\n if (prevGlobalSpeed > 0.0) {\n globalSpeed = min(globalSpeed / prevGlobalSpeed, 1.5) * prevGlobalSpeed;\n }\n gl_FragColor = vec4(globalSpeed, 0.0, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updatePosition\n\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\nuniform sampler2D positionTex;\nuniform sampler2D globalSpeedTex;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_Texcoord).xy;\n vec2 forcePrev = texture2D(forcePrevTex, v_Texcoord).xy;\n vec4 node = texture2D(positionTex, v_Texcoord);\n\n float globalSpeed = texture2D(globalSpeedTex, vec2(0.5)).r;\n float swing = length(force - forcePrev);\n float speed = 0.1 * globalSpeed / (0.1 + globalSpeed * sqrt(swing));\n\n float df = length(force);\n if (df > 0.0) {\n speed = min(df * speed, 10.0) / df;\n\n gl_FragColor = vec4(node.xy + speed * force, node.zw);\n }\n else {\n gl_FragColor = node;\n }\n}\n@end\n\n@export ecgl.forceAtlas2.edges.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 node;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nuniform sampler2D positionTex;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(\n texture2D(positionTex, node).xy, -10.0, 1.0\n );\n v_Color = a_Color;\n}\n@end\n\n@export ecgl.forceAtlas2.edges.fragment\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nvarying vec4 v_Color;\nvoid main() {\n gl_FragColor = color * v_Color;\n}\n@end"},function(e,t,r){"use strict";var n=r(5),i=r(6),a=r(264),o=a.a.toString();o=o.slice(o.indexOf("{")+1,o.lastIndexOf("}"));var s={barnesHutOptimize:!0,barnesHutTheta:1.5,repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null},u=function(e){for(var t in s)this[t]=s[t];if(e)for(var t in e)this[t]=e[t];this._nodes=[],this._edges=[],this._disposed=!1,this._positionTex=new n.a({type:i.a.FLOAT,flipY:!1,minFilter:i.a.NEAREST,magFilter:i.a.NEAREST})};u.prototype.initData=function(e,t){var r=new Blob([o]),n=window.URL.createObjectURL(r);this._worker=new Worker(n),this._worker.onmessage=this._$onupdate.bind(this),this._nodes=e,this._edges=t,this._frame=0;for(var i=e.length,a=t.length,s=new Float32Array(2*i),u=new Float32Array(i),l=new Float32Array(i),c=new Float32Array(2*a),h=new Float32Array(a),d=0;d5e4?10:a>5e3?1:.1,t.scaling=a>100?2:10,t.barnesHutOptimize=a>1e3,e)for(var r in s)null!=e[r]&&(t[r]=e[r]);if(!t.gravityCenter){for(var o=[1/0,1/0],u=[-1/0,-1/0],l=0;le},u.prototype.getNodePosition=function(e,t){if(t||(t=new Float32Array(2*this._nodes.length)),this._positionArr)for(var r=0;r0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},negate:function(e,t){return e[0]=-t[0],e[1]=-t[1],e},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e},set:function(e,t,r){return e[0]=t,e[1]=r,e}},a=e.prototype;a.beforeUpdate=function(){for(var e=0;e=e&&this.bbox[1]<=t&&this.bbox[3]>=t},a.setBBox=function(e,t,r,n){this.bbox[0]=e,this.bbox[1]=t,this.bbox[2]=r,this.bbox[3]=n,this.size=(r-e+n-t)/2},a._newSubRegion=function(){var t=this.subRegions[this.nSubRegions];return t||(t=new e,this.subRegions[this.nSubRegions]=t),this.nSubRegions++,t},a._addNodeToSubRegion=function(e){var t=this.findSubRegion(e.position[0],e.position[1]),r=this.bbox;if(!t){var n=(r[0]+r[2])/2,i=(r[1]+r[3])/2,a=(r[2]-r[0])/2,o=(r[3]-r[1])/2,s=e.position[0]>=n?1:0,u=e.position[1]>=i?1:0,t=this._newSubRegion();t.setBBox(s*a+r[0],u*o+r[1],(s+1)*a+r[0],(u+1)*o+r[1])}t.addNode(e)},a._updateCenterOfMass=function(e){null==this.centerOfMass&&(this.centerOfMass=new Float32Array(2));var t=this.centerOfMass[0]*this.mass,r=this.centerOfMass[1]*this.mass;t+=e.position[0]*e.mass,r+=e.position[1]*e.mass,this.mass+=e.mass,this.centerOfMass[0]=t/this.mass,this.centerOfMass[1]=r/this.mass};var o=n.prototype;o.initNodes=function(e,r,n){var i=r.length;this.nodes.length=0;for(var a=void 0!==n,o=0;o0&&(this.strongGravityMode?this.applyNodeStrongGravity(n):this.applyNodeGravity(n))}for(var t=0;t0&&(h=Math.min(h/this._globalSpeed,1.5)*this._globalSpeed),this._globalSpeed=h;for(var t=0;t0&&(d=Math.min(f*d,10)/f,i.scaleAndAdd(r.position,r.position,r.force,d))}},o.applyRegionToNodeRepulsion=function(){var e=i.create();return function(t,r){if(t.node)this.applyNodeToNodeRepulsion(t.node,r,!0);else{i.sub(e,r.position,t.centerOfMass);var n=e[0]*e[0]+e[1]*e[1];if(n>this.barnesHutTheta*t.size*t.size){var a=this.scaling*r.mass*t.mass/n;i.scaleAndAdd(r.force,r.force,e,a)}else for(var o=0;o0)o=this.scaling*t.mass*r.mass/(s*s);else{if(!(s<0))return;o=100*this.scaling*t.mass*r.mass}}else o=this.scaling*t.mass*r.mass/a;i.scaleAndAdd(t.force,t.force,e,o),i.scaleAndAdd(r.force,r.force,e,-o)}}}}(),o.applyEdgeAttraction=function(){var e=i.create();return function(t){var r=t.source,n=t.target;i.sub(e,r.position,n.position);var a,o=i.len(e);a=0===this.edgeWeightInfluence?1:1===this.edgeWeightInfluence?t.weight:Math.pow(t.weight,this.edgeWeightInfluence);var s;this.preventOverlap&&(o=o-r.size-n.size)<=0||(s=this.linLogMode?-a*Math.log(o+1)/(o+1):-a,i.scaleAndAdd(r.force,r.force,e,s),i.scaleAndAdd(n.force,n.force,e,-s))}}(),o.applyNodeGravity=function(){var e=i.create();return function(t){i.sub(e,this.gravityCenter,t.position);var r=i.len(e);i.scaleAndAdd(t.force,t.force,e,this.gravity*t.mass/(r+1))}}(),o.applyNodeStrongGravity=function(){var e=i.create();return function(t){i.sub(e,this.gravityCenter,t.position),i.scaleAndAdd(t.force,t.force,e,this.gravity*t.mass)}}(),o.updateBBox=function(){for(var e=1/0,t=1/0,r=-1/0,n=-1/0,i=0;i0?1.1:.9,a=Math.max(Math.min(this._zoom*i,this.maxZoom),this.minZoom);i=a/this._zoom;var o=this._convertPos(r,n),s=(o.x-this._dx)*(i-1),u=(o.y-this._dy)*(i-1);this._dx-=s,this._dy-=u,this._zoom=a,this._needsUpdate=!0}}},dispose:function(){var e=this.zr;e.off("mousedown",this._mouseDownHandler),e.off("mousemove",this._mouseMoveHandler),e.off("mouseup",this._mouseUpHandler),e.off("mousewheel",this._mouseWheelHandler),e.off("globalout",this._mouseUpHandler),e.animation.off("frame",this._update)}}));t.a=i},function(e,t,r){"use strict";t.a="@export ecgl.lines2D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.vertex\n\nattribute vec2 position: POSITION;\nattribute vec2 normal;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n vec4 p2 = worldViewProjection * vec4(position + normal, -10.0, 1.0);\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n p2.xy /= p2.w;\n gl_Position.xy /= gl_Position.w;\n\n vec2 N = normalize(p2.xy - gl_Position.xy);\n gl_Position.xy += N * offset / viewport.zw * 2.0;\n\n gl_Position.xy *= gl_Position.w;\n\n v_Color = a_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n\n@end"},function(e,t,r){"use strict";var n=r(0);r.n(n),r(268),r(272)},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(2),o=r(3),s=r(19),u=r(269);i.a.extendChartView({type:"flowGL",__ecgl__:!0,init:function(e,t){this.viewGL=new s.a("orthographic"),this.groupGL=new a.a.Node,this.viewGL.add(this.groupGL),this._particleSurface=new u.a;var r=new a.a.Mesh({geometry:new a.a.PlaneGeometry,material:new a.a.Material({shader:new a.a.Shader({vertex:a.a.Shader.source("ecgl.color.vertex"),fragment:a.a.Shader.source("ecgl.color.fragment")}),transparent:!0})});r.material.enableTexture("diffuseMap"),this.groupGL.add(r),this._planeMesh=r},render:function(e,t,r){var n=this._particleSurface;n.setParticleType(e.get("particleType")),n.setSupersampling(e.get("supersampling")),this._updateData(e,r),this._updateCamera(r.getWidth(),r.getHeight(),r.getDevicePixelRatio());var i=o.a.firstNotNull(e.get("particleDensity"),128);n.setParticleDensity(i,i);var s=this._planeMesh,u=+new Date,l=this,c=!0;s.__percent=0,s.stopAnimation(),s.animate("",{loop:!0}).when(1e5,{__percent:1}).during(function(){var e=+new Date,t=Math.min(e-u,20);u+=t,l._renderer&&(n.update(l._renderer,r,t/1e3,c),s.material.set("diffuseMap",n.getSurfaceTexture())),c=!1}).start();var h=e.getModel("itemStyle"),d=a.a.parseColor(h.get("color"));d[3]*=o.a.firstNotNull(h.get("opacity"),1),s.material.set("color",d),n.setColorTextureImage(e.get("colorTexture"),r),n.setParticleSize(e.get("particleSize")),n.particleSpeedScaling=e.get("particleSpeed"),n.motionBlurFactor=1-Math.pow(.1,e.get("particleTrail"))},updateTransform:function(e,t,r){this._updateData(e,r)},afterRender:function(e,t,r,n){var i=n.renderer;this._renderer=i},_updateData:function(e,t){var r=e.coordinateSystem,n=r.dimensions.map(function(t){return e.coordDimToDataDim(t)[0]}),i=e.getData(),a=i.getDataExtent(n[0]),o=i.getDataExtent(n[1]),s=e.get("gridWidth"),u=e.get("gridHeight");if(null==s||"auto"===s){var l=(a[1]-a[0])/(o[1]-o[0]);s=Math.round(Math.sqrt(l*i.count()))}null!=u&&"auto"!==u||(u=Math.ceil(i.count()/s));var c=this._particleSurface.vectorFieldTexture,h=c.pixels;if(h&&h.length===u*s*4)for(var d=0;d=359&&(i[0]>0&&(i[0]=0),a[0]0?e[e.length-1]:this._lastFrameTexture},setRegion:function(e){this._particlePass.setUniform("region",e)},resize:function(e,t){this._lastFrameTexture.width=e*this._supersampling,this._lastFrameTexture.height=t*this._supersampling,this._thisFrameTexture.width=e*this._supersampling,this._thisFrameTexture.height=t*this._supersampling,this._width=e,this._height=t},setParticleSize:function(e){var t=this._getParticleMesh();if(e<=2)return t.material.disableTexture("spriteTexture"),void(t.material.transparent=!1);this._spriteTexture||(this._spriteTexture=new l.a),this._spriteTexture.image&&this._spriteTexture.image.width===e||(this._spriteTexture.image=n(e),this._spriteTexture.dirty()),t.material.transparent=!0,t.material.enableTexture("spriteTexture"),t.material.set("spriteTexture",this._spriteTexture),this._particleSize=e},setGradientTexture:function(e){var t=this._getParticleMesh().material;t[e?"enableTexture":"disableTexture"]("gradientTexture"),t.setUniform("gradientTexture",e)},setColorTextureImage:function(e,t){this._getParticleMesh().material.setTextureImage("colorTexture",e,t,{flipY:!0})},setParticleType:function(e){this._particleType=e},clearFrame:function(e){var t=this._frameBuffer;t.attach(this._lastFrameTexture),t.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),t.unbind(e)},setSupersampling:function(e){this._supersampling=e,this.resize(this._width,this._height)},_updateDownsampleTextures:function(e,t){for(var r=this._downsampleTextures,n=Math.max(Math.floor(Math.log(this._supersampling/t.getDevicePixelRatio())/Math.log(2)),0),i=2,a=this._width*this._supersampling,o=this._height*this._supersampling,s=0;s65535?new Uint32Array(3*n):new Uint16Array(3*n))},addLine:function(e){var t=this._vertexOffset;this.attributes.position.set(t,[e[0],e[1],1]),this.attributes.position.set(t+1,[e[0],e[1],-1]),this.attributes.position.set(t+2,[e[0],e[1],2]),this.attributes.position.set(t+3,[e[0],e[1],-2]),this.setTriangleIndices(this._faceOffset++,[t,t+1,t+2]),this.setTriangleIndices(this._faceOffset++,[t+1,t+2,t+3]),this._vertexOffset+=4}}));t.a=a},function(e,t,r){"use strict";t.a="@export ecgl.vfParticle.particle.fragment\n\nuniform sampler2D particleTexture;\nuniform sampler2D spawnTexture;\nuniform sampler2D velocityTexture;\n\nuniform float deltaTime;\nuniform float elapsedTime;\n\nuniform float speedScaling : 1.0;\n\nuniform vec2 textureSize;\nuniform vec4 region : [0, 0, 1, 1];\nuniform float firstFrameTime;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, v_Texcoord);\n bool spawn = false;\n if (p.w <= 0.0) {\n p = texture2D(spawnTexture, fract(v_Texcoord + elapsedTime / 10.0));\n p.w -= firstFrameTime;\n spawn = true;\n }\n vec2 v = texture2D(velocityTexture, fract(p.xy * region.zw + region.xy)).xy;\n v = (v - 0.5) * 2.0;\n p.z = length(v);\n p.xy += v * deltaTime / 10.0 * speedScaling;\n p.w -= deltaTime;\n\n if (spawn || p.xy != fract(p.xy)) {\n p.z = 0.0;\n }\n p.xy = fract(p.xy);\n\n gl_FragColor = p;\n}\n@end\n\n@export ecgl.vfParticle.renderPoints.vertex\n\n#define PI 3.1415926\n\nattribute vec2 texcoord : TEXCOORD_0;\n\nuniform sampler2D particleTexture;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nuniform float size : 1.0;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, texcoord);\n\n if (p.w > 0.0 && p.z > 1e-5) {\n gl_Position = worldViewProjection * vec4(p.xy * 2.0 - 1.0, 0.0, 1.0);\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n\n v_Mag = p.z;\n v_Uv = p.xy;\n\n gl_PointSize = size;\n}\n\n@end\n\n@export ecgl.vfParticle.renderPoints.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\nuniform sampler2D spriteTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n#ifdef SPRITETEXTURE_ENABLED\n gl_FragColor *= texture2D(spriteTexture, gl_PointCoord);\n if (color.a == 0.0) {\n discard;\n }\n#endif\n#ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.vertex\n\n#define PI 3.1415926\n\nattribute vec3 position : POSITION;\n\nuniform sampler2D particleTexture;\nuniform sampler2D prevParticleTexture;\n\nuniform float size : 1.0;\nuniform vec4 vp: VIEWPORT;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\n@import clay.util.rand\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, position.xy);\n vec4 p2 = texture2D(prevParticleTexture, position.xy);\n\n p.xy = p.xy * 2.0 - 1.0;\n p2.xy = p2.xy * 2.0 - 1.0;\n\n if (p.w > 0.0 && p.z > 1e-5) {\n vec2 dir = normalize(p.xy - p2.xy);\n vec2 norm = vec2(dir.y / vp.z, -dir.x / vp.w) * sign(position.z) * size;\n if (abs(position.z) == 2.0) {\n gl_Position = vec4(p.xy + norm, 0.0, 1.0);\n v_Uv = p.xy;\n v_Mag = p.z;\n }\n else {\n gl_Position = vec4(p2.xy + norm, 0.0, 1.0);\n v_Mag = p2.z;\n v_Uv = p2.xy;\n }\n gl_Position = worldViewProjection * gl_Position;\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n #ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n"},function(e,t,r){"use strict";var n=r(0),i=r.n(n);i.a.extendSeriesModel({type:"series.flowGL",dependencies:["geo","grid","bmap"],visualColorAccessPath:"itemStyle.color",getInitialData:function(e,t){var r=i.a.getCoordinateSystemDimensions(this.get("coordinateSystem"))||["x","y"];r.push("vx","vy");var n=i.a.helper.completeDimensions(r,this.getSource(),{encodeDef:this.get("encode"),dimsDef:this.get("dimensions")}),a=new i.a.List(n,this);return a.initData(this.getSource()),a},defaultOption:{coordinateSystem:"cartesian2d",zlevel:10,supersampling:1,particleType:"point",particleDensity:128,particleSize:1,particleSpeed:1,particleTrail:2,colorTexture:null,gridWidth:"auto",gridHeight:"auto",itemStyle:{color:"#fff",opacity:.8}}})},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=(r(274),r(275),r(16));i.a.registerVisual(Object(a.a)("linesGL"))},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(12),o=(r.n(a),i.a.extendSeriesModel({type:"series.linesGL",dependencies:["grid","geo"],visualColorAccessPath:"lineStyle.color",streamEnabled:!0,init:function(e){var t=this._processFlatCoordsArray(e.data);this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset,t.flatCoords&&(e.data=new Float32Array(t.count)),o.superApply(this,"init",arguments)},mergeOption:function(e){var t=this._processFlatCoordsArray(e.data);this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset,t.flatCoords&&(e.data=new Float32Array(t.count)),o.superApply(this,"mergeOption",arguments)},appendData:function(e){var t=this._processFlatCoordsArray(e.data);t.flatCoords&&(this._flatCoords?(this._flatCoords=Object(a.concatArray)(this._flatCoords,t.flatCoords),this._flatCoordsOffset=Object(a.concatArray)(this._flatCoordsOffset,t.flatCoordsOffset)):(this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset),e.data=new Float32Array(t.count)),this.getRawData().appendData(e.data)},_getCoordsFromItemModel:function(e){var t=this.getData().getItemModel(e),r=t.option instanceof Array?t.option:t.getShallow("coords");return r},getLineCoordsCount:function(e){return this._flatCoordsOffset?this._flatCoordsOffset[2*e+1]:this._getCoordsFromItemModel(e).length},getLineCoords:function(e,t){if(this._flatCoordsOffset){for(var r=this._flatCoordsOffset[2*e],n=this._flatCoordsOffset[2*e+1],i=0;i1?(t.material.shader!==this._meshLinesShader&&t.material.attachShader(this._meshLinesShader),t.mode=a.a.Mesh.TRIANGLES):(t.material.shader!==this._nativeLinesShader&&t.material.attachShader(this._nativeLinesShader),t.mode=a.a.Mesh.LINES),r=r||0,n=n||o.count(),c.resetOffset();var f=0,p=0,m=[],g=[],_=[],v=[],y=[],x=.3,T=.7;if(u||0!==s)for(var b=r;b3?t[3]=e[3]:t[3]=1,t):(t=_.a.color.parse(e||"#000",t)||[0,0,0,0],t[0]/=255,t[1]/=255,t[2]/=255,t)},ae.directionFromAlphaBeta=function(e,t){var r=e/180*Math.PI+Math.PI/2,n=-t/180*Math.PI+Math.PI/2,i=[],a=Math.sin(r);return i[0]=a*Math.cos(n),i[1]=-Math.cos(r),i[2]=a*Math.sin(n),i},ae.getShadowResolution=function(e){var t=1024;switch(e){case"low":t=512;break;case"medium":break;case"high":t=2048;break;case"ultra":t=4096}return t},ae.COMMON_SHADERS=["lambert","color","realistic","hatching"],ae.createShader=function(e){var t=d.a.source(e+".vertex"),r=d.a.source(e+".fragment");t||console.error("Vertex shader of '%s' not exits",e),r||console.error("Fragment shader of '%s' not exits",e);var n=new d.a(t,r);return n.name=e,n},ae.createMaterial=function(e,t){t instanceof Array||(t=[t]);var r=ae.createShader(e),n=new f.a({shader:r});return t.forEach(function(e){"string"==typeof e&&n.define(e)}),n},ae.setMaterialFromModel=function(e,t,r,n){t.autoUpdateTextureStatus=!1;var i=r.getModel(e+"Material"),a=i.get("detailTexture"),o=A.a.firstNotNull(i.get("textureTiling"),1),s=A.a.firstNotNull(i.get("textureOffset"),0);"number"==typeof o&&(o=[o,o]),"number"==typeof s&&(s=[s,s]);var u=o[0]>1||o[1]>1?ae.Texture.REPEAT:ae.Texture.CLAMP_TO_EDGE,l={anisotropic:8,wrapS:u,wrapT:u};if("realistic"===e){var h=i.get("roughness"),c=i.get("metalness");null!=c?isNaN(c)&&(t.setTextureImage("metalnessMap",c,n,l),c=A.a.firstNotNull(i.get("metalnessAdjust"),.5)):c=0,null!=h?isNaN(h)&&(t.setTextureImage("roughnessMap",h,n,l),h=A.a.firstNotNull(i.get("roughnessAdjust"),.5)):h=.5;var d=i.get("normalTexture");t.setTextureImage("detailMap",a,n,l),t.setTextureImage("normalMap",d,n,l),t.set({roughness:h,metalness:c,detailUvRepeat:o,detailUvOffset:s})}else if("lambert"===e)t.setTextureImage("detailMap",a,n,l),t.set({detailUvRepeat:o,detailUvOffset:s});else if("color"===e)t.setTextureImage("detailMap",a,n,l),t.set({detailUvRepeat:o,detailUvOffset:s});else if("hatching"===e){for(var f=i.get("hatchingTextures")||[],p=0;p<6;p++)t.setTextureImage("hatch"+(p+1),f[p],n,{anisotropic:8,wrapS:ae.Texture.REPEAT,wrapT:ae.Texture.REPEAT});t.set({detailUvRepeat:o,detailUvOffset:s})}},ae.updateVertexAnimation=function(e,t,r,n){var i=n.get("animation"),a=n.get("animationDurationUpdate"),o=n.get("animationEasingUpdate"),s=r.shadowDepthMaterial;if(i&&t&&a>0&&t.geometry.vertexCount===r.geometry.vertexCount){r.material.define("vertex","VERTEX_ANIMATION"),r.ignorePreZ=!0,s&&s.define("vertex","VERTEX_ANIMATION");for(var u=0;ur?r:e}var i=r(12),a=function(e,t,r){e=e||0,t=t||0,r=r||0,this.array=i.a.fromValues(e,t,r),this._dirty=!0};a.prototype={constructor:a,add:function(e){return i.a.add(this.array,this.array,e.array),this._dirty=!0,this},set:function(e,t,r){return this.array[0]=e,this.array[1]=t,this.array[2]=r,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this._dirty=!0,this},clone:function(){return new a(this.x,this.y,this.z)},copy:function(e){return i.a.copy(this.array,e.array),this._dirty=!0,this},cross:function(e,t){return i.a.cross(this.array,e.array,t.array),this._dirty=!0,this},dist:function(e){return i.a.dist(this.array,e.array)},distance:function(e){return i.a.distance(this.array,e.array)},div:function(e){return i.a.div(this.array,this.array,e.array),this._dirty=!0,this},divide:function(e){return i.a.divide(this.array,this.array,e.array),this._dirty=!0,this},dot:function(e){return i.a.dot(this.array,e.array)},len:function(){return i.a.len(this.array)},length:function(){return i.a.length(this.array)},lerp:function(e,t,r){return i.a.lerp(this.array,e.array,t.array,r),this._dirty=!0,this},min:function(e){return i.a.min(this.array,this.array,e.array),this._dirty=!0,this},max:function(e){return i.a.max(this.array,this.array,e.array),this._dirty=!0,this},mul:function(e){return i.a.mul(this.array,this.array,e.array),this._dirty=!0,this},multiply:function(e){return i.a.multiply(this.array,this.array,e.array),this._dirty=!0,this},negate:function(){return i.a.negate(this.array,this.array),this._dirty=!0,this},normalize:function(){return i.a.normalize(this.array,this.array),this._dirty=!0,this},random:function(e){return i.a.random(this.array,e),this._dirty=!0,this},scale:function(e){return i.a.scale(this.array,this.array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return i.a.scaleAndAdd(this.array,this.array,e.array,t),this._dirty=!0,this},sqrDist:function(e){return i.a.sqrDist(this.array,e.array)},squaredDistance:function(e){return i.a.squaredDistance(this.array,e.array)},sqrLen:function(){return i.a.sqrLen(this.array)},squaredLength:function(){return i.a.squaredLength(this.array)},sub:function(e){return i.a.sub(this.array,this.array,e.array),this._dirty=!0,this},subtract:function(e){return i.a.subtract(this.array,this.array,e.array),this._dirty=!0,this},transformMat3:function(e){return i.a.transformMat3(this.array,this.array,e.array),this._dirty=!0,this},transformMat4:function(e){return i.a.transformMat4(this.array,this.array,e.array),this._dirty=!0,this},transformQuat:function(e){return i.a.transformQuat(this.array,this.array,e.array),this._dirty=!0,this},applyProjection:function(e){var t=this.array;if(e=e.array,0===e[15]){var r=-1/t[2];t[0]=e[0]*t[0]*r,t[1]=e[5]*t[1]*r,t[2]=(e[10]*t[2]+e[14])*r}else t[0]=e[0]*t[0]+e[12],t[1]=e[5]*t[1]+e[13],t[2]=e[10]*t[2]+e[14];return this._dirty=!0,this},eulerFromQuat:function(e,t){a.eulerFromQuat(this,e,t)},eulerFromMat3:function(e,t){a.eulerFromMat3(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var o=Object.defineProperty;if(o){var s=a.prototype;o(s,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),o(s,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),o(s,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}})}a.add=function(e,t,r){return i.a.add(e.array,t.array,r.array),e._dirty=!0,e},a.set=function(e,t,r,n){i.a.set(e.array,t,r,n),e._dirty=!0},a.copy=function(e,t){return i.a.copy(e.array,t.array),e._dirty=!0,e},a.cross=function(e,t,r){return i.a.cross(e.array,t.array,r.array),e._dirty=!0,e},a.dist=function(e,t){return i.a.distance(e.array,t.array)},a.distance=a.dist,a.div=function(e,t,r){return i.a.divide(e.array,t.array,r.array),e._dirty=!0,e},a.divide=a.div,a.dot=function(e,t){return i.a.dot(e.array,t.array)},a.len=function(e){return i.a.length(e.array)},a.lerp=function(e,t,r,n){return i.a.lerp(e.array,t.array,r.array,n),e._dirty=!0,e},a.min=function(e,t,r){return i.a.min(e.array,t.array,r.array),e._dirty=!0,e},a.max=function(e,t,r){return i.a.max(e.array,t.array,r.array),e._dirty=!0,e},a.mul=function(e,t,r){return i.a.multiply(e.array,t.array,r.array),e._dirty=!0,e},a.multiply=a.mul,a.negate=function(e,t){return i.a.negate(e.array,t.array),e._dirty=!0,e},a.normalize=function(e,t){return i.a.normalize(e.array,t.array),e._dirty=!0,e},a.random=function(e,t){return i.a.random(e.array,t),e._dirty=!0,e},a.scale=function(e,t,r){return i.a.scale(e.array,t.array,r),e._dirty=!0,e},a.scaleAndAdd=function(e,t,r,n){return i.a.scaleAndAdd(e.array,t.array,r.array,n),e._dirty=!0,e},a.sqrDist=function(e,t){return i.a.sqrDist(e.array,t.array)},a.squaredDistance=a.sqrDist,a.sqrLen=function(e){return i.a.sqrLen(e.array)},a.squaredLength=a.sqrLen,a.sub=function(e,t,r){return i.a.subtract(e.array,t.array,r.array),e._dirty=!0,e},a.subtract=a.sub,a.transformMat3=function(e,t,r){return i.a.transformMat3(e.array,t.array,r.array),e._dirty=!0,e},a.transformMat4=function(e,t,r){return i.a.transformMat4(e.array,t.array,r.array),e._dirty=!0,e},a.transformQuat=function(e,t,r){return i.a.transformQuat(e.array,t.array,r.array),e._dirty=!0,e};var u=Math.atan2,l=Math.asin,h=Math.abs;a.eulerFromQuat=function(e,t,r){e._dirty=!0,t=t.array;var i=e.array,a=t[0],o=t[1],s=t[2],h=t[3],c=a*a,d=o*o,f=s*s,p=h*h,r=(r||"XYZ").toUpperCase();switch(r){case"XYZ":i[0]=u(2*(a*h-o*s),p-c-d+f),i[1]=l(n(2*(a*s+o*h),-1,1)),i[2]=u(2*(s*h-a*o),p+c-d-f);break;case"YXZ":i[0]=l(n(2*(a*h-o*s),-1,1)),i[1]=u(2*(a*s+o*h),p-c-d+f),i[2]=u(2*(a*o+s*h),p-c+d-f);break;case"ZXY":i[0]=l(n(2*(a*h+o*s),-1,1)),i[1]=u(2*(o*h-s*a),p-c-d+f),i[2]=u(2*(s*h-a*o),p-c+d-f);break;case"ZYX":i[0]=u(2*(a*h+s*o),p-c-d+f),i[1]=l(n(2*(o*h-a*s),-1,1)),i[2]=u(2*(a*o+s*h),p+c-d-f);break;case"YZX":i[0]=u(2*(a*h-s*o),p-c+d-f),i[1]=u(2*(o*h-a*s),p+c-d-f),i[2]=l(n(2*(a*o+s*h),-1,1));break;case"XZY":i[0]=u(2*(a*h+o*s),p-c+d-f),i[1]=u(2*(a*s+o*h),p+c-d-f),i[2]=l(n(2*(s*h-a*o),-1,1));break;default:console.warn("Unkown order: "+r)}return e},a.eulerFromMat3=function(e,t,r){var i=t.array,a=i[0],o=i[3],s=i[6],c=i[1],d=i[4],f=i[7],p=i[2],m=i[5],g=i[8],_=e.array,r=(r||"XYZ").toUpperCase();switch(r){case"XYZ":_[1]=l(n(s,-1,1)),h(s)<.99999?(_[0]=u(-f,g),_[2]=u(-o,a)):(_[0]=u(m,d),_[2]=0);break;case"YXZ":_[0]=l(-n(f,-1,1)),h(f)<.99999?(_[1]=u(s,g),_[2]=u(c,d)):(_[1]=u(-p,a),_[2]=0);break;case"ZXY":_[0]=l(n(m,-1,1)),h(m)<.99999?(_[1]=u(-p,g),_[2]=u(-o,d)):(_[1]=0,_[2]=u(c,a));break;case"ZYX":_[1]=l(-n(p,-1,1)),h(p)<.99999?(_[0]=u(m,g),_[2]=u(c,a)):(_[0]=0,_[2]=u(-o,d));break;case"YZX":_[2]=l(n(c,-1,1)),h(c)<.99999?(_[0]=u(-f,d),_[1]=u(-p,a)):(_[0]=0,_[1]=u(s,g));break;case"XZY":_[2]=l(-n(o,-1,1)),h(o)<.99999?(_[0]=u(m,d),_[1]=u(s,a)):(_[0]=u(-f,g),_[1]=0);break;default:console.warn("Unkown order: "+r)}return e._dirty=!0,e},Object.defineProperties(a,{POSITIVE_X:{get:function(){return new a(1,0,0)}},NEGATIVE_X:{get:function(){return new a(-1,0,0)}},POSITIVE_Y:{get:function(){return new a(0,1,0)}},NEGATIVE_Y:{get:function(){return new a(0,-1,0)}},POSITIVE_Z:{get:function(){return new a(0,0,1)}},NEGATIVE_Z:{get:function(){return new a(0,0,-1)}},UP:{get:function(){return new a(0,1,0)}},ZERO:{get:function(){return new a}}}),t.a=a},function(e,t,r){"use strict";var n=r(7),i=r(11),a=r(57),o=n.a.extend({width:512,height:512,type:i.a.UNSIGNED_BYTE,format:i.a.RGBA,wrapS:i.a.REPEAT,wrapT:i.a.REPEAT,minFilter:i.a.LINEAR_MIPMAP_LINEAR,magFilter:i.a.LINEAR,useMipmap:!0,anisotropic:1,flipY:!0,sRGB:!0,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1,__used:0},function(){this._cache=new a.a},{getWebGLTexture:function(e){var t=e.gl,r=this._cache;return r.use(e.__uid__),r.miss("webgl_texture")&&r.put("webgl_texture",t.createTexture()),this.dynamic?this.update(e):r.isDirty()&&(this.update(e),r.fresh()),r.get("webgl_texture")},bind:function(){},unbind:function(){},dirty:function(){this._cache&&this._cache.dirtyAll()},update:function(e){},updateCommon:function(e){var t=e.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,this.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,this.unpackAlignment),this.format===i.a.DEPTH_COMPONENT&&(this.useMipmap=!1);var r=e.getGLExtension("EXT_sRGB");this.format!==o.SRGB||r||(this.format=o.RGB),this.format!==o.SRGB_ALPHA||r||(this.format=o.RGBA),this.NPOT=!this.isPowerOfTwo()},getAvailableWrapS:function(){return this.NPOT?i.a.CLAMP_TO_EDGE:this.wrapS},getAvailableWrapT:function(){return this.NPOT?i.a.CLAMP_TO_EDGE:this.wrapT},getAvailableMinFilter:function(){var e=this.minFilter;return this.NPOT||!this.useMipmap?e===i.a.NEAREST_MIPMAP_NEAREST||e===i.a.NEAREST_MIPMAP_LINEAR?i.a.NEAREST:e===i.a.LINEAR_MIPMAP_LINEAR||e===i.a.LINEAR_MIPMAP_NEAREST?i.a.LINEAR:e:e},getAvailableMagFilter:function(){return this.magFilter},nextHighestPowerOfTwo:function(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1},dispose:function(e){var t=this._cache;t.use(e.__uid__);var r=t.get("webgl_texture");r&&e.gl.deleteTexture(r),t.deleteContext(e.__uid__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(o.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(o.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),o.BYTE=i.a.BYTE,o.UNSIGNED_BYTE=i.a.UNSIGNED_BYTE,o.SHORT=i.a.SHORT,o.UNSIGNED_SHORT=i.a.UNSIGNED_SHORT,o.INT=i.a.INT,o.UNSIGNED_INT=i.a.UNSIGNED_INT,o.FLOAT=i.a.FLOAT,o.HALF_FLOAT=36193,o.UNSIGNED_INT_24_8_WEBGL=34042,o.DEPTH_COMPONENT=i.a.DEPTH_COMPONENT,o.DEPTH_STENCIL=i.a.DEPTH_STENCIL,o.ALPHA=i.a.ALPHA,o.RGB=i.a.RGB,o.RGBA=i.a.RGBA,o.LUMINANCE=i.a.LUMINANCE,o.LUMINANCE_ALPHA=i.a.LUMINANCE_ALPHA,o.SRGB=35904,o.SRGB_ALPHA=35906,o.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,o.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,o.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,o.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,o.NEAREST=i.a.NEAREST,o.LINEAR=i.a.LINEAR,o.NEAREST_MIPMAP_NEAREST=i.a.NEAREST_MIPMAP_NEAREST,o.LINEAR_MIPMAP_NEAREST=i.a.LINEAR_MIPMAP_NEAREST,o.NEAREST_MIPMAP_LINEAR=i.a.NEAREST_MIPMAP_LINEAR,o.LINEAR_MIPMAP_LINEAR=i.a.LINEAR_MIPMAP_LINEAR,o.REPEAT=i.a.REPEAT,o.CLAMP_TO_EDGE=i.a.CLAMP_TO_EDGE,o.MIRRORED_REPEAT=i.a.MIRRORED_REPEAT,t.a=o},function(e,t,r){"use strict";function n(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function i(e,t){var r=n(e.width),i=n(e.height);return t=t||document.createElement("canvas"),t.width=r,t.height=i,t.getContext("2d").drawImage(e.image,0,0,r,i),t}var a=r(4),o=r(11),s=r(14),u=r(73),l=u.a.isPowerOfTwo,h=a.a.extend(function(){return{image:null,pixels:null,mipmaps:[],convertToPOT:!1}},{textureType:"texture2D",update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),this.updateCommon(e);var r=this.format,n=this.type,i=!(!this.convertToPOT||this.mipmaps.length||!this.image||this.wrapS!==a.a.REPEAT&&this.wrapT!==a.a.REPEAT||!this.NPOT);t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,i?this.wrapS:this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,i?this.wrapT:this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,i?this.magFilter:this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,i?this.minFilter:this.getAvailableMinFilter());var s=e.getGLExtension("EXT_texture_filter_anisotropic");if(s&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_2D,s.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===n){e.getGLExtension("OES_texture_half_float")||(n=o.a.FLOAT)}if(this.mipmaps.length)for(var u=this.width,l=this.height,h=0;h=a.a.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,r,s,n,o,0,t.pixels):e.texImage2D(e.TEXTURE_2D,r,s,n,o,0,s,u,t.pixels)},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_2D))},isPowerOfTwo:function(){return l(this.width)&&l(this.height)},isRenderable:function(){return this.image?"CANVAS"===this.image.nodeName||"VIDEO"===this.image.nodeName||this.image.complete:!(!this.width||!this.height)},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},load:function(e,t){var r=s.a.createImage();t&&(r.crossOrigin=t);var n=this;return r.onload=function(){n.dirty(),n.trigger("success",n),r.onload=null},r.onerror=function(){n.trigger("error",n),r.onerror=null},r.src=e,this.image=r,this}});Object.defineProperty(h.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(e){this.image?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}}),Object.defineProperty(h.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(e){this.image?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}}),t.a=h},function(e,t,r){"use strict";var n=r(161);t.a=n.a},function(e,t,r){"use strict";var n=r(110),i=r(53),a=r(23),o=function(){this.__uid__=a.a.genGUID()};o.__initializers__=[function(e){a.a.extend(this,e)}],a.a.extend(o,n.a),a.a.extend(o.prototype,i.a),t.a=o},function(e,t,r){"use strict";function n(e){for(var t=[],r=0;r=0){if(1!==l&&4!==l){o();break}l=2,d=[]}else if(1!==l)if(4!==l)r(f),l=0;else{var p=f;g.indexOf(p)>=0||_.indexOf(p)>=0||v.indexOf(p)>=0?c[u].semantic=p:"ignore"===p||"unconfigurable"===p?c[u].ignore=!0:c[u].value="bool"===e?"true"===p:parseFloat(p)}else c[u].value="bool"===e?"true"===f:parseFloat(f),d=null;else{if(2!==l){o();break}if(!(d instanceof Array)){o();break}d.push(+i[++s])}else c[u].value=new h.a.Float32Array(d),d=null,l=5;else if(2===l){if(!(d instanceof Array)){o();break}d.push(+i[++s])}else l=5;else l=4;else{if(0!==l&&3!==l){o();break}l=1}}return c}function u(e,t){"object"==typeof e&&(t=e.fragment,e=e.vertex),e=a(e),t=a(t),this._shaderID=i(e,t),this._vertexCode=u.parseImport(e),this._fragmentCode=u.parseImport(t),this.attributeSemantics={},this.matrixSemantics={},this.uniformSemantics={},this.matrixSemanticKeys=[],this.uniformTemplates={},this.attributes={},this.textures={},this.vertexDefines={},this.fragmentDefines={},this._parseAttributes(),this._parseUniforms(),this._parseDefines()}var l=r(23),h=r(14),c=/uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g,d=/attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g,f=/#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g,p={bool:"1i",int:"1i",sampler2D:"t",samplerCube:"t",float:"1f",vec2:"2f",vec3:"3f",vec4:"4f",ivec2:"2i",ivec3:"3i",ivec4:"4i",mat2:"m2",mat3:"m3",mat4:"m4"},m={bool:function(){return!0},int:function(){return 0},float:function(){return 0},sampler2D:function(){return null},samplerCube:function(){return null},vec2:function(){return n(2)},vec3:function(){return n(3)},vec4:function(){return n(4)},ivec2:function(){return n(2)},ivec3:function(){return n(3)},ivec4:function(){return n(4)},mat2:function(){return n(4)},mat3:function(){return n(9)},mat4:function(){return n(16)},array:function(){return[]}},g=["POSITION","NORMAL","BINORMAL","TANGENT","TEXCOORD","TEXCOORD_0","TEXCOORD_1","COLOR","JOINT","WEIGHT"],_=["SKIN_MATRIX","VIEWPORT_SIZE","VIEWPORT","DEVICEPIXELRATIO","WINDOW_SIZE","NEAR","FAR","TIME"],v=["WORLD","VIEW","PROJECTION","WORLDVIEW","VIEWPROJECTION","WORLDVIEWPROJECTION","WORLDINVERSE","VIEWINVERSE","PROJECTIONINVERSE","WORLDVIEWINVERSE","VIEWPROJECTIONINVERSE","WORLDVIEWPROJECTIONINVERSE","WORLDTRANSPOSE","VIEWTRANSPOSE","PROJECTIONTRANSPOSE","WORLDVIEWTRANSPOSE","VIEWPROJECTIONTRANSPOSE","WORLDVIEWPROJECTIONTRANSPOSE","WORLDINVERSETRANSPOSE","VIEWINVERSETRANSPOSE","PROJECTIONINVERSETRANSPOSE","WORLDVIEWINVERSETRANSPOSE","VIEWPROJECTIONINVERSETRANSPOSE","WORLDVIEWPROJECTIONINVERSETRANSPOSE"],y={vec4:4,vec3:3,vec2:2,float:1},x={},T={};u.prototype={constructor:u,createUniforms:function(){var e={};for(var t in this.uniformTemplates){var r=this.uniformTemplates[t];e[t]={type:r.type,value:r.value()}}return e},_parseImport:function(){this._vertexCode=u.parseImport(this.vertex),this._fragmentCode=u.parseImport(this.fragment)},_addSemanticUniform:function(e,t,r){if(g.indexOf(r)>=0)this.attributeSemantics[r]={symbol:e,type:t};else if(v.indexOf(r)>=0){var n=!1,i=r;r.match(/TRANSPOSE$/)&&(n=!0,i=r.slice(0,-9)),this.matrixSemantics[r]={symbol:e,type:t,isTranspose:n,semanticNoTranspose:i}}else _.indexOf(r)>=0&&(this.uniformSemantics[r]={symbol:e,type:t})},_addMaterialUniform:function(e,t,r,n,i,a){a[e]={type:r,value:i?m.array:n||m[t],semantic:null}},_parseUniforms:function(){function e(e){return null!=e?function(){return e}:null}function t(t,a,o){var u=s(a,o),l=[];for(var h in u){var c=u[h],d=c.semantic,f=h,m=p[a],g=e(u[h].value);u[h].isArray&&(f+="["+u[h].arraySize+"]",m+="v"),l.push(f),n._uniformList.push(h),c.ignore||("sampler2D"!==a&&"samplerCube"!==a||(n.textures[h]={shaderType:i,type:a}),d?n._addSemanticUniform(h,m,d):n._addMaterialUniform(h,a,m,g,u[h].isArray,r))}return l.length>0?"uniform "+a+" "+l.join(",")+";\n":""}var r={},n=this,i="vertex";this._uniformList=[],this._vertexCode=this._vertexCode.replace(c,t),i="fragment",this._fragmentCode=this._fragmentCode.replace(c,t),n.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=r},_parseAttributes:function(){function e(e,n,i){var a=s(n,i),o=y[n]||1,u=[];for(var l in a){var h=a[l].semantic;if(t[l]={type:"float",size:o,semantic:h||null},h){if(g.indexOf(h)<0)throw new Error('Unkown semantic "'+h+'"');r.attributeSemantics[h]={symbol:l,type:n}}u.push(l)}return"attribute "+n+" "+u.join(",")+";\n"}var t={},r=this;this._vertexCode=this._vertexCode.replace(d,e),this.attributes=t},_parseDefines:function(){function e(e,n,i){var a="vertex"===r?t.vertexDefines:t.fragmentDefines;return a[n]||(a[n]="false"!==i&&("true"===i||(i?isNaN(parseFloat(i))?i.trim():parseFloat(i):null))),""}var t=this,r="vertex";this._vertexCode=this._vertexCode.replace(f,e),r="fragment",this._fragmentCode=this._fragmentCode.replace(f,e)},clone:function(){var e=T[this._shaderID];return new u(e.vertex,e.fragment)}},Object.defineProperty&&(Object.defineProperty(u.prototype,"shaderID",{get:function(){return this._shaderID}}),Object.defineProperty(u.prototype,"vertex",{get:function(){return this._vertexCode}}),Object.defineProperty(u.prototype,"fragment",{get:function(){return this._fragmentCode}}),Object.defineProperty(u.prototype,"uniforms",{get:function(){return this._uniformList}}));var b=/(@import)\s*([0-9a-zA-Z_\-\.]*)/g;u.parseImport=function(e){return e=e.replace(b,function(e,t,r){var e=u.source(r);return e?u.parseImport(e):(console.error('Shader chunk "'+r+'" not existed in library'),"")})};var w=/(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;u.import=function(e){e.replace(w,function(e,t,r,n){var n=n.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g,"");if(n){for(var i,a=r.split("."),o=u.codes,s=0;s0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a),e},i.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},i.cross=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[0],s=r[1],u=r[2];return e[0]=i*u-a*s,e[1]=a*o-n*u,e[2]=n*s-i*o,e},i.lerp=function(e,t,r,n){var i=t[0],a=t[1],o=t[2];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e[2]=o+n*(r[2]-o),e},i.random=function(e,t){t=t||1;var r=2*Object(n.c)()*Math.PI,i=2*Object(n.c)()-1,a=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(r)*a,e[1]=Math.sin(r)*a,e[2]=i*t,e},i.transformMat4=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,e[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,e[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,e[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,e},i.transformMat3=function(e,t,r){var n=t[0],i=t[1],a=t[2];return e[0]=n*r[0]+i*r[3]+a*r[6],e[1]=n*r[1]+i*r[4]+a*r[7],e[2]=n*r[2]+i*r[5]+a*r[8],e},i.transformQuat=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[0],s=r[1],u=r[2],l=r[3],h=l*n+s*a-u*i,c=l*i+u*n-o*a,d=l*a+o*i-s*n,f=-o*n-s*i-u*a;return e[0]=h*l+f*-o+c*-u-d*-s,e[1]=c*l+f*-s+d*-o-h*-u,e[2]=d*l+f*-u+h*-s-c*-o,e},i.rotateX=function(e,t,r,n){var i=[],a=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],a[0]=i[0],a[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),a[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},i.rotateY=function(e,t,r,n){var i=[],a=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],a[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),a[1]=i[1],a[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},i.rotateZ=function(e,t,r,n){var i=[],a=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],a[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),a[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),a[2]=i[2],e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},i.forEach=function(){var e=i.create();return function(t,r,n,i,a,o){var s,u;for(r||(r=3),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s1?0:Math.acos(a)},t.a=i},function(e,t){function r(e,t){"createCanvas"===e&&(J=null),K[e]=t}function n(e){if(null==e||"object"!=typeof e)return e;var t=e,r=k.call(e);if("[object Array]"===r){if(!F(e)){t=[];for(var i=0,a=e.length;is[0]&&(s[0]=l),h>s[1]&&(s[1]=h),c>s[2]&&(s[2]=c)}r._dirty=!0,n._dirty=!0}},generateVertexNormals:function(){if(this.vertexCount){var e=this.indices,t=this.attributes,r=t.position.value,a=t.normal.value;if(a&&a.length===r.length)for(var o=0;o65535&&(this.indices=new n.a.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,r=this.getEnabledAttributes(),i={},a=0;a=r.COLOR_ATTACHMENT0&&a<=r.COLOR_ATTACHMENT0+8&&i.push(a);n.drawBuffersEXT(i)}}this.trigger("beforerender",this,e);var o=this.clearDepth?r.DEPTH_BUFFER_BIT:0;if(r.depthMask(!0),this.clearColor){o|=r.COLOR_BUFFER_BIT,r.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&r.clearColor(s[0],s[1],s[2],s[3])}r.clear(o),this.blendWithPrevious?(r.enable(r.BLEND),this.material.transparent=!0):(r.disable(r.BLEND),this.material.transparent=!1),this.renderQuad(e),this.trigger("afterrender",this,e),t&&this.unbind(e,t)},renderQuad:function(e){d.material=this.material,e.renderPass([d],f)},dispose:function(e){}});t.a=p},function(e,t,r){"use strict";t.a=function(e,t,r){return{seriesType:e,reset:function(e,t){function r(e,t){var r=e.getItemModel(t),n=r.get(i,!0);null!=n&&e.setItemVisual(t,"opacity",n)}var n=e.getData(),i=e.visualColorAccessPath.split(".");i[i.length-1]="opacity";var a=e.get(i);return n.setVisual("opacity",null==a?1:a),{dataEach:n.hasItemOption?r:null}}}}},function(e,t,r){"use strict";var n=r(3),i=r(12),a=i.a.set,o=i.a.copy,s=function(e,t){this.min=e||new n.a(1/0,1/0,1/0),this.max=t||new n.a(-1/0,-1/0,-1/0),this.vertices=null};s.prototype={constructor:s,updateFromVertices:function(e){if(e.length>0){var t=this.min,r=this.max,n=t.array,i=r.array;o(n,e[0]),o(i,e[0]);for(var a=1;ai[0]&&(i[0]=s[0]),s[1]>i[1]&&(i[1]=s[1]),s[2]>i[2]&&(i[2]=s[2])}t._dirty=!0,r._dirty=!0}},union:function(e){var t=this.min,r=this.max;return i.a.min(t.array,t.array,e.min.array),i.a.max(r.array,r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},intersection:function(e){var t=this.min,r=this.max;return i.a.max(t.array,t.array,e.min.array),i.a.min(r.array,r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},intersectBoundingBox:function(e){var t=this.min.array,r=this.max.array,n=e.min.array,i=e.max.array;return!(t[0]>i[0]||t[1]>i[1]||t[2]>i[2]||r[0]=i[0]&&r[1]>=i[1]&&r[2]>=i[2]},containPoint:function(e){var t=this.min.array,r=this.max.array,n=e.array;return t[0]<=n[0]&&t[1]<=n[1]&&t[2]<=n[2]&&r[0]>=n[0]&&r[1]>=n[1]&&r[2]>=n[2]},isFinite:function(){var e=this.min.array,t=this.max.array;return isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])&&isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])},applyTransform:function(e){this.transformFrom(this,e)},transformFrom:function(){var e=i.a.create(),t=i.a.create(),r=i.a.create(),n=i.a.create(),a=i.a.create(),o=i.a.create();return function(i,s){var u=i.min.array,l=i.max.array,h=s.array;return e[0]=h[0]*u[0],e[1]=h[1]*u[0],e[2]=h[2]*u[0],t[0]=h[0]*l[0],t[1]=h[1]*l[0],t[2]=h[2]*l[0],r[0]=h[4]*u[1],r[1]=h[5]*u[1],r[2]=h[6]*u[1],n[0]=h[4]*l[1],n[1]=h[5]*l[1],n[2]=h[6]*l[1],a[0]=h[8]*u[2],a[1]=h[9]*u[2],a[2]=h[10]*u[2],o[0]=h[8]*l[2],o[1]=h[9]*l[2],o[2]=h[10]*l[2],u=this.min.array,l=this.max.array,u[0]=Math.min(e[0],t[0])+Math.min(r[0],n[0])+Math.min(a[0],o[0])+h[12],u[1]=Math.min(e[1],t[1])+Math.min(r[1],n[1])+Math.min(a[1],o[1])+h[13],u[2]=Math.min(e[2],t[2])+Math.min(r[2],n[2])+Math.min(a[2],o[2])+h[14],l[0]=Math.max(e[0],t[0])+Math.max(r[0],n[0])+Math.max(a[0],o[0])+h[12],l[1]=Math.max(e[1],t[1])+Math.max(r[1],n[1])+Math.max(a[1],o[1])+h[13],l[2]=Math.max(e[2],t[2])+Math.max(r[2],n[2])+Math.max(a[2],o[2])+h[14],this.min._dirty=!0,this.max._dirty=!0,this}}(),applyProjection:function(e){var t=this.min.array,r=this.max.array,n=e.array,i=t[0],a=t[1],o=t[2],s=r[0],u=r[1],l=t[2],h=r[0],c=r[1],d=r[2];if(1===n[15])t[0]=n[0]*i+n[12],t[1]=n[5]*a+n[13],r[2]=n[10]*o+n[14],r[0]=n[0]*h+n[12],r[1]=n[5]*c+n[13],t[2]=n[10]*d+n[14];else{var f=-1/o;t[0]=n[0]*i*f,t[1]=n[5]*a*f,r[2]=(n[10]*o+n[14])*f,f=-1/l,r[0]=n[0]*s*f,r[1]=n[5]*u*f,f=-1/d,t[2]=(n[10]*d+n[14])*f}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){e=[];for(var t=0;t<8;t++)e[t]=i.a.fromValues(0,0,0);this.vertices=e}var r=this.min.array,n=this.max.array;return a(e[0],r[0],r[1],r[2]),a(e[1],r[0],n[1],r[2]),a(e[2],n[0],r[1],r[2]),a(e[3],n[0],n[1],r[2]),a(e[4],r[0],r[1],n[2]),a(e[5],r[0],n[1],n[2]),a(e[6],n[0],r[1],n[2]),a(e[7],n[0],n[1],n[2]),this},copy:function(e){var t=this.min,r=this.max;return o(t.array,e.min.array),o(r.array,e.max.array),t._dirty=!0,r._dirty=!0,this},clone:function(){var e=new s;return e.copy(this),e}},t.a=s},function(e,t,r){"use strict";function n(e){var t=Object.keys(e);t.sort();for(var r=[],n=0;n=0},getEnabledUniforms:function(){return this._enabledUniforms},getTextureUniforms:function(){return this._textureUniforms},set:function(e,t){if("object"==typeof e)for(var r in e){var n=e[r];this.setUniform(r,n)}else this.setUniform(e,t)},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){var r=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var n=this.uniforms;this._enabledUniforms=Object.keys(n),this._enabledUniforms.sort(),this._textureUniforms=this._enabledUniforms.filter(function(e){var t=this.uniforms[e].type;return"t"===t||"tv"===t},this);var i=this.vertexDefines,a=this.fragmentDefines;if(this.vertexDefines=o.a.clone(e.vertexDefines),this.fragmentDefines=o.a.clone(e.fragmentDefines),t){for(var s in r)n[s]&&(n[s].value=r[s].value);o.a.defaults(this.vertexDefines,i),o.a.defaults(this.fragmentDefines,a)}var u={};for(var l in e.textures)u[l]={shaderType:e.textures[l].shaderType,type:e.textures[l].type,enabled:!(!t||!this._textureStatus[l])&&this._textureStatus[l].enabled};this._textureStatus=u,this._programKey=""},clone:function(){var e=new this.constructor({name:this.name,shader:this.shader});for(var t in this.uniforms)e.uniforms[t].value=this.uniforms[t].value;return e.depthTest=this.depthTest,e.depthMask=this.depthMask,e.transparent=this.transparent,e.blend=this.blend,e.vertexDefines=o.a.clone(this.vertexDefines),e.fragmentDefines=o.a.clone(this.fragmentDefines),e.enableTexture(this.getEnabledTextures()),e.precision=this.precision,e},define:function(e,t,r){var n=this.vertexDefines,i=this.fragmentDefines;"vertex"!==e&&"fragment"!==e&&"both"!==e&&arguments.length<3&&(r=t,t=e,e="both"),r=null!=r?r:null,"vertex"!==e&&"both"!==e||n[t]!==r&&(n[t]=r,this._programKey=""),"fragment"!==e&&"both"!==e||i[t]!==r&&(i[t]=r,"both"!==e&&(this._programKey=""))},undefine:function(e,t){"vertex"!==e&&"fragment"!==e&&"both"!==e&&arguments.length<2&&(t=e,e="both"),"vertex"!==e&&"both"!==e||this.isDefined("vertex",t)&&(delete this.vertexDefines[t],this._programKey=""),"fragment"!==e&&"both"!==e||this.isDefined("fragment",t)&&(delete this.fragmentDefines[t],"both"!==e&&(this._programKey=""))},isDefined:function(e,t){switch(e){case"vertex":return void 0!==this.vertexDefines[t];case"fragment":return void 0!==this.fragmentDefines[t]}},getDefine:function(e,t){switch(e){case"vertex":return this.vertexDefines[t];case"fragment":return this.fragmentDefines[t]}},enableTexture:function(e){if(Array.isArray(e))for(var t=0;t=r.x&&t>=r.y&&e<=r.x+r.width&&t<=r.y+r.height};var _=new d.a;n.prototype.castRay=function(e,t,r){var n=this.layer.renderer,i=n.viewport;return n.viewport=this.viewport,n.screenToNDC(e,t,_),this.camera.castRay(_,r),n.viewport=i,r},n.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this.scene.updateLights();var e=this.scene.updateRenderList(this.camera);this._needsSortProgressively=!1;for(var t=0;t30},n.prototype._doRender=function(e,t,r){var n=this.scene,i=this.camera;r=r||0,this._updateTransparent(e,n,i,r),t||(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(e,n,i,!0)),this._updateShadowPCFKernel(r);var a=e.clearColor;if(e.gl.clearColor(a[0],a[1],a[2],a[3]),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,i),this._compositor.updateNormal(e,n,i,this._temporalSS.getFrame())),this._updateSSAO(e,n,i,this._temporalSS.getFrame()),this._enablePostEffect){var o=this._compositor.getSourceFrameBuffer();o.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),e.render(n,i,!0,!0),o.unbind(e),this.needsTemporalSS()&&t?(this._compositor.composite(e,n,i,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),e.setViewport(this.viewport),this._temporalSS.render(e)):(e.setViewport(this.viewport),this._compositor.composite(e,n,i,null,0))}else if(this.needsTemporalSS()&&t){var o=this._temporalSS.getSourceFrameBuffer();o.bind(e),e.saveClear(),e.clearBit=e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT,e.render(n,i,!0,!0),e.restoreClear(),o.unbind(e),e.setViewport(this.viewport),this._temporalSS.render(e)}else e.setViewport(this.viewport),e.render(n,i,!0,!0)},n.prototype._updateTransparent=function(e,t,r,n){for(var i=new c.a,a=new h.a,o=r.getWorldPosition(),s=t.getRenderList(r).transparent,u=0;uthis.camera.far||e65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(e){this.triangleCount!==e&&(this.indices=0===e?null:this.vertexCount>65535?new Uint32Array(3*e):new Uint16Array(3*e))},_getCubicCurveApproxStep:function(e,t,r,n){return 1/(u.dist(e,t)+u.dist(r,t)+u.dist(n,r)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?2*a:2*a+2},getCubicCurveTriangleCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?0:2*a},getLineVertexCount:function(){return this.getPolylineVertexCount(l)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(l)},getPolylineVertexCount:function(e){var t;if("number"==typeof e)t=e;else{t="number"!=typeof e[0]?e.length:e.length/3}return this.useNativeLine?2*(t-1):2*(t-1)+2},getPolylineTriangleCount:function(e){var t;if("number"==typeof e)t=e;else{t="number"!=typeof e[0]?e.length:e.length/3}return this.useNativeLine?0:2*Math.max(t-1,0)},addCubicCurve:function(e,t,r,n,i,a){null==a&&(a=1);for(var o=e[0],s=e[1],u=e[2],l=t[0],h=t[1],c=t[2],d=r[0],f=r[1],p=r[2],m=n[0],g=n[1],_=n[2],v=this._getCubicCurveApproxStep(e,t,r,n),y=v*v,x=y*v,T=3*v,b=3*y,w=6*y,E=6*x,S=o-2*l+d,A=s-2*h+f,M=u-2*c+p,C=3*(l-d)-o+m,L=3*(h-f)-s+g,D=3*(c-p)-u+_,N=o,R=s,P=u,I=(l-o)*T+S*b+C*x,O=(h-s)*T+A*b+L*x,F=(c-u)*T+M*b+D*x,B=S*w+C*E,U=A*w+L*E,z=M*w+D*E,G=C*E,H=L*E,V=D*E,k=0,W=0,j=Math.ceil(1/v),X=new Float32Array(3*(j+1)),X=[],q=0,W=0;W1&&(N=I>0?Math.min(N,m):Math.max(N,m),R=O>0?Math.min(R,g):Math.max(R,g),P=F>0?Math.min(P,_):Math.max(P,_));return this.addPolyline(X,i,a)},addLine:function(e,t,r,n){return this.addPolyline([e,t],r,n)},addPolyline:function(e,t,r,n,i){if(e.length){var a="number"!=typeof e[0];if(null==i&&(i=a?e.length:e.length/3),!(i<2)){null==n&&(n=0),null==r&&(r=1),this._itemVertexOffsets.push(this._vertexOffset);var o,s,a="number"!=typeof e[0],u=a?"number"!=typeof t[0]:t.length/4===i,l=this.attributes.position,h=this.attributes.positionPrev,c=this.attributes.positionNext,d=this.attributes.color,f=this.attributes.offset,p=this.indices,m=this._vertexOffset;r=Math.max(r,.01);for(var g=n;g1&&(l.copy(m,m-1),d.copy(m,m-1),m++):(g0&&(c.set(m-2,o),c.set(m-1,o)),l.set(m,o),l.set(m+1,o),d.set(m,s),d.set(m+1,s),f.set(m,r/2),f.set(m+1,-r/2),m+=2),this.useNativeLine)d.set(m,s),l.set(m,o),m++;else if(g>0){var y=3*this._triangleOffset,p=this.indices;p[y]=m-4,p[y+1]=m-3,p[y+2]=m-2,p[y+3]=m-3,p[y+4]=m-1,p[y+5]=m-2,this._triangleOffset+=2}}if(!this.useNativeLine){var x=this._vertexOffset,T=this._vertexOffset+2*i;h.copy(x,x+2),h.copy(x+1,x+3),c.copy(T-1,T-3),c.copy(T-2,T-4)}return this._vertexOffset=m,this._vertexOffset}}},setItemColor:function(e,t){for(var r=this._itemVertexOffsets[e],n=e1&&t.texParameterf(t.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===n){e.getGLExtension("OES_texture_half_float")||(n=a.a.FLOAT)}if(this.mipmaps.length)for(var o=this.width,s=this.height,u=0;u0&&(o=1/Math.sqrt(o),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e[3]=t[3]*o),e},i.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},i.lerp=function(e,t,r,n){var i=t[0],a=t[1],o=t[2],s=t[3];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e[2]=o+n*(r[2]-o),e[3]=s+n*(r[3]-s),e},i.random=function(e,t){return t=t||1,e[0]=Object(n.c)(),e[1]=Object(n.c)(),e[2]=Object(n.c)(),e[3]=Object(n.c)(),i.normalize(e,e),i.scale(e,e,t),e},i.transformMat4=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,e[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,e[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,e[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,e},i.transformQuat=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[0],s=r[1],u=r[2],l=r[3],h=l*n+s*a-u*i,c=l*i+u*n-o*a,d=l*a+o*i-s*n,f=-o*n-s*i-u*a;return e[0]=h*l+f*-o+c*-u-d*-s,e[1]=c*l+f*-s+d*-o-h*-u,e[2]=d*l+f*-u+h*-s-c*-o,e},i.forEach=function(){var e=i.create();return function(t,r,n,i,a,o){var s,u;for(r||(r=4),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s0&&console.warn("Found multiple camera in one scene. Use the fist one."),this._cameraList.push(e)):e instanceof s.a&&this.lights.push(e),e.name&&(this._nodeRepository[e.name]=e)},removeFromScene:function(e){var t;e instanceof u.a?(t=this._cameraList.indexOf(e))>=0&&this._cameraList.splice(t,1):e instanceof s.a&&(t=this.lights.indexOf(e))>=0&&this.lights.splice(t,1),e.name&&delete this._nodeRepository[e.name]},getNode:function(e){return this._nodeRepository[e]},setMainCamera:function(e){var t=this._cameraList.indexOf(e);t>=0&&this._cameraList.splice(t,1),this._cameraList.unshift(e)},getMainCamera:function(){return this._cameraList[0]},getLights:function(){return this.lights},updateLights:function(){var e=this.lights;this._previousLightNumber=this._lightNumber;for(var t={},r=0;r0&&this._doUpdateRenderList(o,t,r,n,i)}},isFrustumCulled:function(){var e=new l.a,t=new f.a;return function(r,n,i){var a=r.boundingBox;if(a||(a=r.skeleton&&r.skeleton.boundingBox?r.skeleton.boundingBox:r.geometry.boundingBox),!a)return!1;if(t.array=i,e.transformFrom(a,t),r.castShadow&&this.viewBoundingBoxLastFrame.union(e),r.frustumCulling){if(!e.intersectBoundingBox(n.frustum.boundingBox))return!0;t.array=n.projectionMatrix.array,e.max.array[2]>0&&e.min.array[2]<0&&(e.max.array[2]=-1e-20),e.applyProjection(t);var o=e.min.array,s=e.max.array;if(s[0]<-1||o[0]>1||s[1]<-1||o[1]>1||s[2]<-1||o[2]>1)return!0}return!1}}(),_updateLightUniforms:function(){var e=this.lights;e.sort(a);var t=this._lightUniforms;for(var r in t)for(var n in t[r])t[r][n].value.length=0;for(var i=0;i0?e[t].value=new Float32Array(e[t].value):e[t].value=null;this.indices&&this.indices.length>0&&(this.indices=this.vertexCount>65535?new Uint32Array(this.indices):new Uint16Array(this.indices)),this.dirty()}}},function(e,t,r){"use strict";function n(e,t){var r=[];return a.a.util.each(e.dimensions,function(n){var i=e.getDimensionInfo(n),a=i.otherDims,o=a[t];null!=o&&!1!==o&&(r[o]=i.name)}),r}var i=r(0),a=r.n(i);t.a=function(e,t,r){var i=e.getData(),o=e.getRawValue(t),s=a.a.util.isArray(o)?function(e){function o(e,t){var n=i.getDimensionInfo(t);if(n&&!1!==n.otherDims.tooltip){var o=n.type,l=(s?"- "+(n.tooltipName||n.name)+": ":"")+("ordinal"===o?e+"":"time"===o?r?"":a.a.format.formatTime("yyyy/MM/dd hh:mm:ss",e):a.a.format.addCommas(e));l&&u.push(a.a.format.encodeHTML(l))}}var s=!0,u=[],l=n(i,"tooltip");return l.length?a.a.util.each(l,function(e){o(i.get(e,t),e)}):a.a.util.each(e,o),(s?"
":"")+u.join(s?"
":", ")}(o):a.a.format.encodeHTML(a.a.format.addCommas(o)),u=i.getName(t),l=i.getItemVisual(t,"color");a.a.util.isObject(l)&&l.colorStops&&(l=(l.colorStops[0]||{}).color),l=l||"transparent";var h=a.a.format.getTooltipMarker(l),c=e.name;return"\0-"===c&&(c=""),c=c?a.a.format.encodeHTML(c)+(r?": ":"
"):"",r?h+c+s:c+h+(u?a.a.format.encodeHTML(u)+": "+s:s)}},function(e,t,r){"use strict";var n=r(72),i=r(11),a=n.a.extend({skeleton:null,joints:null,useSkinMatricesTexture:!1},function(){this.joints||(this.joints=[])},{isSkinnedMesh:function(){return!!(this.skeleton&&this.joints&&this.joints.length>0)},clone:function(){var e=n.a.prototype.clone.call(this);return e.skeleton=this.skeleton,this.joints&&(e.joints=this.joints.slice()),e}});a.POINTS=i.a.POINTS,a.LINES=i.a.LINES,a.LINE_LOOP=i.a.LINE_LOOP,a.LINE_STRIP=i.a.LINE_STRIP,a.TRIANGLES=i.a.TRIANGLES,a.TRIANGLE_STRIP=i.a.TRIANGLE_STRIP,a.TRIANGLE_FAN=i.a.TRIANGLE_FAN,a.BACK=i.a.BACK,a.FRONT=i.a.FRONT,a.FRONT_AND_BACK=i.a.FRONT_AND_BACK,a.CW=i.a.CW,a.CCW=i.a.CCW,t.a=a},function(e,t,r){"use strict";var n=r(58),i=n.a.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var e=this.fov/180*Math.PI;this.projectionMatrix.perspective(e,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix.array,t=2*Math.atan(1/e[5]);this.fov=t/Math.PI*180,this.aspect=e[5]/e[0],this.near=e[14]/(e[10]-1),this.far=e[14]/(e[10]+1)},clone:function(){var e=n.a.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}});t.a=i},function(e,t,r){"use strict";var n=r(40),i=r(76),a=r(8),o=r(19),s=r(4),u=r(121);a.a.import(u.a);var l=n.a.extend(function(){var e=new a.a({vertex:a.a.source("clay.skybox.vertex"),fragment:a.a.source("clay.skybox.fragment")}),t=new o.a({shader:e,depthMask:!1});return{scene:null,geometry:new i.a,material:t,environmentMap:null,culling:!1}},function(){var e=this.scene;e&&this.attachScene(e),this.environmentMap&&this.setEnvironmentMap(this.environmentMap)},{attachScene:function(e){this.scene&&this.detachScene(),e.skybox=this,this.scene=e,e.on("beforerender",this._beforeRenderScene,this)},detachScene:function(){this.scene&&(this.scene.off("beforerender",this._beforeRenderScene),this.scene.skybox=null),this.scene=null},dispose:function(e){this.detachScene(),this.geometry.dispose(e)},setEnvironmentMap:function(e){"texture2D"===e.textureType?(this.material.define("EQUIRECTANGULAR"),e.minFilter=s.a.LINEAR):this.material.undefine("EQUIRECTANGULAR"),this.material.set("environmentMap",e)},getEnvironmentMap:function(){return this.material.get("environmentMap")},_beforeRenderScene:function(e,t,r){this.renderSkybox(e,r)},renderSkybox:function(e,t){this.position.copy(t.getWorldPosition()),this.update(),e.gl.disable(e.gl.BLEND),this.material.get("lod")>0?this.material.define("fragment","LOD"):this.material.undefine("fragment","LOD"),e.renderPass([this],t)}});t.a=l},function(e,t,r){"use strict";var n=r(15),i=r(18),a=n.a.extend({dynamic:!1,widthSegments:1,heightSegments:1},function(){this.build()},{build:function(){for(var e=this.heightSegments,t=this.widthSegments,r=this.attributes,n=[],a=[],o=[],s=[],u=0;u<=e;u++)for(var l=u/e,h=0;h<=t;h++){var c=h/t;if(n.push([2*c-1,2*l-1,0]),a&&a.push([c,l]),o&&o.push([0,0,1]),h0&&this._notFirst?this.animateTo({alpha:h,beta:c,center:d,distance:a,targetOrthographicSize:o,easing:l.animationEasingUpdate,duration:l.animationDurationUpdate}):(this.setDistance(a),this.setAlpha(h),this.setBeta(c),this.setCenter(d),this.setOrthographicSize(o)),this._notFirst=!0,this._validateProperties()},_validateProperties:function(){},animateTo:function(e){var t=this.zr,r=this,n={},i={};return null!=e.distance&&(n.distance=this.getDistance(),i.distance=e.distance),null!=e.orthographicSize&&(n.orthographicSize=this.getOrthographicSize(),i.orthographicSize=e.orthographicSize),null!=e.alpha&&(n.alpha=this.getAlpha(),i.alpha=e.alpha),null!=e.beta&&(n.beta=this.getBeta(),i.beta=e.beta),null!=e.center&&(n.center=this.getCenter(),i.center=e.center),this._addAnimator(t.animation.animate(n).when(e.duration||1e3,i).during(function(){null!=n.alpha&&r.setAlpha(n.alpha),null!=n.beta&&r.setBeta(n.beta),null!=n.distance&&r.setDistance(n.distance),null!=n.center&&r.setCenter(n.center),null!=n.orthographicSize&&r.setOrthographicSize(n.orthographicSize),r._needsUpdate=!0})).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e0},_update:function(e){if(this._rotating){var t=("cw"===this.autoRotateDirection?1:-1)*this.autoRotateSpeed/180*Math.PI;this._phi-=t*e/1e3,this._needsUpdate=!0}else this._rotateVelocity.len()>0&&(this._needsUpdate=!0);(Math.abs(this._zoomSpeed)>.1||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(e=Math.min(e,50),this._updateDistanceOrSize(e),this._updatePan(e),this._updateRotate(e),this._updateTransform(),this.getCamera().update(),this.zr&&this.zr.refresh(),this.trigger("update"),this._needsUpdate=!1)},_updateRotate:function(e){var t=this._rotateVelocity;this._phi=t.y*e/20+this._phi,this._theta=t.x*e/20+this._theta,this.setAlpha(this.getAlpha()),this.setBeta(this.getBeta()),this._vectorDamping(t,Math.pow(this.damping,e/16))},_updateDistanceOrSize:function(e){"perspective"===this._projection?this._setDistance(this._distance+this._zoomSpeed*e/20):this._setOrthoSize(this._orthoSize+this._zoomSpeed*e/20),this._zoomSpeed*=Math.pow(this.damping,e/16)},_setDistance:function(e){this._distance=Math.max(Math.min(e,this.maxDistance),this.minDistance)},_setOrthoSize:function(e){this._orthoSize=Math.max(Math.min(e,this.maxOrthographicSize),this.minOrthographicSize);var t=this.getCamera(),r=this._orthoSize,n=r/this.viewGL.viewport.height*this.viewGL.viewport.width;t.left=-n/2,t.right=n/2,t.top=r/2,t.bottom=-r/2},_updatePan:function(e){var t=this._panVelocity,r=this._distance,n=this.getCamera(),i=n.worldTransform.y,a=n.worldTransform.x;this._center.scaleAndAdd(a,-t.x*r/200).scaleAndAdd(i,-t.y*r/200),this._vectorDamping(t,0)},_updateTransform:function(){var e=this.getCamera(),t=new o.a,r=this._theta+Math.PI/2,n=this._phi+Math.PI/2,i=Math.sin(r);t.x=i*Math.cos(n),t.y=-Math.cos(r),t.z=i*Math.sin(n),e.position.copy(this._center).scaleAndAdd(t,this._distance),e.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var e=this.autoRotateAfterStill,t=this;!isNaN(e)&&e>0&&(this._stillTimeout=setTimeout(function(){t._rotating=!0},1e3*e))},_vectorDamping:function(e,t){var r=e.len();r*=t,r<1e-4&&(r=0),e.normalize().scale(r)},_decomposeTransform:function(){if(this.getCamera()){this.getCamera().updateWorldTransform();var e=this.getCamera().worldTransform.z,t=Math.asin(e.y),r=Math.atan2(e.x,e.z);this._theta=t,this._phi=-r,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this.getCamera().aspect?this._setDistance(this.getCamera().position.dist(this._center)):this._setOrthoSize(this.getCamera().top-this.getCamera().bottom)}},_mouseDownHandler:function(e){if(!e.target&&!this._isAnimating()){var t=e.offsetX,r=e.offsetY;this.viewGL&&!this.viewGL.containPoint(t,r)||(this.zr.on("mousemove",this._mouseMoveHandler),this.zr.on("mouseup",this._mouseUpHandler),e.event.targetTouches?1===e.event.targetTouches.length&&(this._mode="rotate"):e.event.button===l[this.rotateMouseButton]?this._mode="rotate":e.event.button===l[this.panMouseButton]?this._mode="pan":this._mode="",this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=e.offsetX,this._mouseY=e.offsetY)}},_mouseMoveHandler:function(e){if(!(e.target&&e.target.__isGLToZRProxy||this._isAnimating())){var t=n(this.panSensitivity),r=n(this.rotateSensitivity);"rotate"===this._mode?(this._rotateVelocity.y=(e.offsetX-this._mouseX)/this.zr.getHeight()*2*r[0],this._rotateVelocity.x=(e.offsetY-this._mouseY)/this.zr.getWidth()*2*r[1]):"pan"===this._mode&&(this._panVelocity.x=(e.offsetX-this._mouseX)/this.zr.getWidth()*t[0]*400,this._panVelocity.y=(-e.offsetY+this._mouseY)/this.zr.getHeight()*t[1]*400),this._mouseX=e.offsetX,this._mouseY=e.offsetY,e.event.preventDefault()}},_mouseWheelHandler:function(e){if(!this._isAnimating()){var t=e.event.wheelDelta||-e.event.detail;this._zoomHandler(e,t)}},_pinchHandler:function(e){this._isAnimating()||(this._zoomHandler(e,e.pinchScale>1?1:-1),this._mode="")},_zoomHandler:function(e,t){if(0!==t){var r=e.offsetX,n=e.offsetY;if(!this.viewGL||this.viewGL.containPoint(r,n)){var i;i="perspective"===this._projection?Math.max(Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance))/20,.5):Math.max(Math.max(Math.min(this._orthoSize-this.minOrthographicSize,this.maxOrthographicSize-this._orthoSize))/20,.5),this._zoomSpeed=(t>0?-1:1)*i*this.zoomSensitivity,this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),e.event.preventDefault()}}},_mouseUpHandler:function(){this.zr.off("mousemove",this._mouseMoveHandler),this.zr.off("mouseup",this._mouseUpHandler)},_isRightMouseButtonUsed:function(){return"right"===this.rotateMouseButton||"right"===this.panMouseButton},_contextMenuHandler:function(e){this._isRightMouseButtonUsed()&&e.preventDefault()},_addAnimator:function(e){var t=this._animators;return t.push(e),e.done(function(){var r=t.indexOf(e);r>=0&&t.splice(r,1)}),e}});Object.defineProperty(h.prototype,"autoRotate",{get:function(e){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}}),t.a=h},function(e,t,r){"use strict";t.a="@export ecgl.lines3D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n}\n@end\n\n\n\n@export ecgl.lines3D.clipNear\n\nvec4 clipNear(vec4 p1, vec4 p2) {\n float n = (p1.w - near) / (p1.w - p2.w);\n return vec4(mix(p1.xy, p2.xy, n), -near, near);\n}\n\n@end\n\n@export ecgl.lines3D.expandLine\n#ifdef VERTEX_ANIMATION\n vec4 prevProj = worldViewProjection * vec4(mix(prevPositionPrev, positionPrev, percent), 1.0);\n vec4 currProj = worldViewProjection * vec4(mix(prevPosition, position, percent), 1.0);\n vec4 nextProj = worldViewProjection * vec4(mix(prevPositionNext, positionNext, percent), 1.0);\n#else\n vec4 prevProj = worldViewProjection * vec4(positionPrev, 1.0);\n vec4 currProj = worldViewProjection * vec4(position, 1.0);\n vec4 nextProj = worldViewProjection * vec4(positionNext, 1.0);\n#endif\n\n if (currProj.w < 0.0) {\n if (nextProj.w > 0.0) {\n currProj = clipNear(currProj, nextProj);\n }\n else if (prevProj.w > 0.0) {\n currProj = clipNear(currProj, prevProj);\n }\n }\n\n vec2 prevScreen = (prevProj.xy / abs(prevProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 currScreen = (currProj.xy / abs(currProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 nextScreen = (nextProj.xy / abs(nextProj.w) + 1.0) * 0.5 * viewport.zw;\n\n vec2 dir;\n float len = offset;\n if (position == positionPrev) {\n dir = normalize(nextScreen - currScreen);\n }\n else if (position == positionNext) {\n dir = normalize(currScreen - prevScreen);\n }\n else {\n vec2 dirA = normalize(currScreen - prevScreen);\n vec2 dirB = normalize(nextScreen - currScreen);\n\n vec2 tanget = normalize(dirA + dirB);\n\n float miter = 1.0 / max(dot(tanget, dirA), 0.5);\n len *= miter;\n dir = tanget;\n }\n\n dir = vec2(-dir.y, dir.x) * len;\n currScreen += dir;\n\n currProj.xy = (currScreen / viewport.zw - 0.5) * 2.0 * abs(currProj.w);\n@end\n\n\n@export ecgl.meshLines3D.vertex\n\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevPositionPrev;\nattribute vec3 prevPositionNext;\nuniform float percent : 1.0;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n}\n@end\n\n\n@export ecgl.meshLines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"},function(e,t,r){function n(e,t,r,n,i){var a=0,o=0;null==n&&(n=1/0),null==i&&(i=1/0);var s=0;t.eachChild(function(u,l){var h,c,d=u.position,f=u.getBoundingRect(),p=t.childAt(l+1),m=p&&p.getBoundingRect();if("horizontal"===e){var g=f.width+(m?-m.x+f.x:0);h=a+g,h>n||u.newline?(a=0,h=g,o+=s+r,s=f.height):s=Math.max(s,f.height)}else{var _=f.height+(m?-m.y+f.y:0);c=o+_,c>i||u.newline?(a+=s+r,o=0,c=_,s=f.width):s=Math.max(s,f.width)}u.newline||(d[0]=a,d[1]=o,"horizontal"===e?a=h+r:o=c+r)})}function i(e,t,r){var n=t.width,i=t.height,a=p(e.x,n),o=p(e.y,i),s=p(e.x2,n),u=p(e.y2,i);return(isNaN(a)||isNaN(parseFloat(e.x)))&&(a=0),(isNaN(s)||isNaN(parseFloat(e.x2)))&&(s=n),(isNaN(o)||isNaN(parseFloat(e.y)))&&(o=0),(isNaN(u)||isNaN(parseFloat(e.y2)))&&(u=i),r=m.normalizeCssArray(r||0),{width:Math.max(s-a-r[1]-r[3],0),height:Math.max(u-o-r[0]-r[2],0)}}function a(e,t,r){r=m.normalizeCssArray(r||0);var n=t.width,i=t.height,a=p(e.left,n),o=p(e.top,i),s=p(e.right,n),u=p(e.bottom,i),l=p(e.width,n),h=p(e.height,i),c=r[2]+r[0],f=r[1]+r[3],g=e.aspect;switch(isNaN(l)&&(l=n-s-f-a),isNaN(h)&&(h=i-u-c-o),null!=g&&(isNaN(l)&&isNaN(h)&&(g>n/i?l=.8*n:h=.8*i),isNaN(l)&&(l=g*h),isNaN(h)&&(h=l/g)),isNaN(a)&&(a=n-s-l-f),isNaN(o)&&(o=i-u-h-c),e.left||e.right){case"center":a=n/2-l/2-r[3];break;case"right":a=n-l-f}switch(e.top||e.bottom){case"middle":case"center":o=i/2-h/2-r[0];break;case"bottom":o=i-h-c}a=a||0,o=o||0,isNaN(l)&&(l=n-f-a-(s||0)),isNaN(h)&&(h=i-c-o-(u||0));var _=new d(a+r[3],o+r[0],l,h);return _.margin=r,_}function o(e,t,r,n,i){var o=!i||!i.hv||i.hv[0],s=!i||!i.hv||i.hv[1],u=i&&i.boundingMode||"all";if(o||s){var l;if("raw"===u)l="group"===e.type?new d(0,0,+t.width||0,+t.height||0):e.getBoundingRect();else if(l=e.getBoundingRect(),e.needLocalTransform()){var h=e.getLocalTransform();l=l.clone(),l.applyTransform(h)}t=a(c.defaults({width:l.width,height:l.height},t),r,n);var f=e.position,p=o?t.x-l.x:0,m=s?t.y-l.y:0;e.attr("position","raw"===u?[p,m]:[f[0]+p,f[1]+m])}}function s(e,t){return null!=e[v[t][0]]||null!=e[v[t][1]]&&null!=e[v[t][2]]}function u(e,t,r){function n(r,n){var o={},u=0,l={},h=0;if(g(r,function(t){l[t]=e[t]}),g(r,function(e){i(t,e)&&(o[e]=l[e]=t[e]),a(o,e)&&u++,a(l,e)&&h++}),s[n])return a(t,r[1])?l[r[2]]=null:a(t,r[2])&&(l[r[1]]=null),l;if(2!==h&&u){if(u>=2)return o;for(var c=0;c0){var t=this.outputs[e];t.keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}}});t.a=i},function(e,t,r){"use strict";function n(e,t){for(var r=0,n=1/t,i=e;i>0;)r+=n*(i%t),i=Math.floor(i/t),n/=t;return r}t.a=n},function(e,t,r){"use strict";var n=r(0),i=r.n(n);t.a=function(e,t,r){r=r||e.getSource();var n=t||i.a.getCoordinateSystemDimensions(e.get("coordinateSystem"))||["x","y","z"],a=i.a.helper.createDimensions(r,{dimensionsDefine:r.dimensionsDefine||e.get("dimensions"),encodeDefine:r.encodeDefine||e.get("encode"),coordDimensions:n.map(function(t){var r=e.getReferringComponents(t+"Axis3D")[0];return{type:r&&"category"===r.get("type")?"ordinal":"float",name:t}})});"cartesian3D"===e.get("coordinateSystem")&&a.forEach(function(t){if(n.indexOf(t.coordDim)>=0){var r=e.getReferringComponents(t.coordDim+"Axis3D")[0];r&&"category"===r.get("type")&&(t.ordinalMeta=r.getOrdinalMeta())}});var o=i.a.helper.dataStack.enableDataStack(e,a,{byIndex:!0,stackedCoordDimension:"z"}),s=new i.a.List(a,e);return s.setCalculationInfo(o),s.initData(r),s}},function(e,t){function r(e,t,r){return{seriesType:e,performRawSeries:!0,reset:function(e,n,i){function a(t,r){if("function"==typeof u){var n=e.getRawValue(r),i=e.getDataParams(r);t.setItemVisual(r,"symbolSize",u(n,i))}if(t.hasItemOption){var a=t.getItemModel(r),o=a.getShallow("symbol",!0),s=a.getShallow("symbolSize",!0),l=a.getShallow("symbolKeepAspect",!0);null!=o&&t.setItemVisual(r,"symbol",o),null!=s&&t.setItemVisual(r,"symbolSize",s),null!=l&&t.setItemVisual(r,"symbolKeepAspect",l)}}var o=e.getData(),s=e.get("symbol")||t,u=e.get("symbolSize"),l=e.get("symbolKeepAspect");if(o.setVisual({legendSymbol:r||s,symbol:s,symbolSize:u,symbolKeepAspect:l}),!n.isSeriesFiltered(e)){var h="function"==typeof u;return{dataEach:o.hasItemOption||h?a:null}}}}}e.exports=r},function(e,t,r){"use strict";function n(e){return e.material}function i(e,t,r){return t.uniforms[r].value}function a(e,t,r,n){return r!==n}function o(e){return!0}function s(){}function u(e,t,r){this.availableAttributes=e,this.availableAttributeSymbols=t,this.indicesBuffer=r,this.vao=null}function l(e){var t,r;this.bind=function(e){t||(t=f.a.createCanvas(),t.width=t.height=1,t.getContext("2d"));var n=e.gl,i=!r;i&&(r=n.createTexture()),n.bindTexture(n.TEXTURE_2D,r),i&&n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t)},this.unbind=function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},this.isRenderable=function(){return!0}}var h=r(7),c=r(111),d=r(11),f=r(14),p=r(19),m=r(26),g=r(115),_=r(8),v=r(71),y=r(21),x=r(12);_.a.import(v.a);var T=y.a.create,b={},w={float:d.a.FLOAT,byte:d.a.BYTE,ubyte:d.a.UNSIGNED_BYTE,short:d.a.SHORT,ushort:d.a.UNSIGNED_SHORT},E=h.a.extend(function(){return{canvas:null,_width:100,_height:100,devicePixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,clearColor:[0,0,0,0],clearBit:17664,alpha:!0,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,throwError:!0,gl:null,viewport:{},__currentFrameBuffer:null,_viewportStack:[],_clearStack:[],_sceneRendering:null}},function(){this.canvas||(this.canvas=f.a.createCanvas());var e=this.canvas;try{var t={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!this.gl)throw new Error;this._glinfo=new c.a(this.gl),this.gl.targetRenderer&&console.error("Already created a renderer"),this.gl.targetRenderer=this,this.resize()}catch(e){throw"Error creating WebGL Context "+e}this._programMgr=new g.a(this),this._placeholderTexture=new l(this)},{resize:function(e,t){var r=this.canvas,n=this.devicePixelRatio;null!=e?(r.style.width=e+"px",r.style.height=t+"px",r.width=e*n,r.height=t*n,this._width=e,this._height=t):(this._width=r.width/n,this._height=r.height/n),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var e=this.viewport;return e.width/e.height},setDevicePixelRatio:function(e){this.devicePixelRatio=e,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getGLExtension:function(e){return this._glinfo.getExtension(e)},getGLParameter:function(e){return this._glinfo.getParameter(e)},setViewport:function(e,t,r,n,i){if("object"==typeof e){var a=e;e=a.x,t=a.y,r=a.width,n=a.height,i=a.devicePixelRatio}i=i||this.devicePixelRatio,this.gl.viewport(e*i,t*i,r*i,n*i),this.viewport={x:e,y:t,width:r,height:n,devicePixelRatio:i}},saveViewport:function(){this._viewportStack.push(this.viewport)},restoreViewport:function(){this._viewportStack.length>0&&this.setViewport(this._viewportStack.pop())},saveClear:function(){this._clearStack.push({clearBit:this.clearBit,clearColor:this.clearColor})},restoreClear:function(){if(this._clearStack.length>0){var e=this._clearStack.pop();this.clearColor=e.clearColor,this.clearBit=e.clearBit}},bindSceneRendering:function(e){this._sceneRendering=e},render:function(e,t,r,n){var i=this.gl,a=this.clearColor;if(this.clearBit){i.colorMask(!0,!0,!0,!0),i.depthMask(!0);var o=this.viewport,s=!1,u=o.devicePixelRatio;(o.width!==this._width||o.height!==this._height||u&&u!==this.devicePixelRatio||o.x||o.y)&&(s=!0,i.enable(i.SCISSOR_TEST),i.scissor(o.x*u,o.y*u,o.width*u,o.height*u)),i.clearColor(a[0],a[1],a[2],a[3]),i.clear(this.clearBit),s&&i.disable(i.SCISSOR_TEST)}if(r||e.update(!1),e.updateLights(),!(t=t||e.getMainCamera()))return void console.error("Can't find camera in the scene.");t.update();var l=e.updateRenderList(t,!0);this._sceneRendering=e;var h=l.opaque,c=l.transparent,d=e.material;e.trigger("beforerender",this,e,t,l),n?(this.renderPreZ(h,e,t),i.depthFunc(i.LEQUAL)):i.depthFunc(i.LESS);for(var f=T(),p=x.a.create(),m=0;m0){var u=e[a-1],l=u.joints?u.joints.length:0;if((o.joints?o.joints.length:0)===l&&o.material===u.material&&o.lightGroup===u.lightGroup){o.__program=u.__program;continue}}var h=this._programMgr.getProgram(o,s,t);this.validateProgram(h),o.__program=h}},renderPass:function(e,t,r){this.trigger("beforerenderpass",this,e,t,r),r=r||{},r.getMaterial=r.getMaterial||n,r.getUniform=r.getUniform||i,r.isMaterialChanged=r.isMaterialChanged||a,r.beforeRender=r.beforeRender||s,r.afterRender=r.afterRender||s;var u=r.ifRender||o;this.updatePrograms(e,this._sceneRendering,r),r.sortCompare&&e.sort(r.sortCompare);var l=this.viewport,h=l.devicePixelRatio,c=[l.x*h,l.y*h,l.width*h,l.height*h],d=this.devicePixelRatio,f=this.__currentFrameBuffer?[this.__currentFrameBuffer.getTextureWidth(),this.__currentFrameBuffer.getTextureHeight()]:[this._width*d,this._height*d],p=[c[2],c[3]],m=Date.now();t?(y.a.copy(S.VIEW,t.viewMatrix.array),y.a.copy(S.PROJECTION,t.projectionMatrix.array),y.a.copy(S.VIEWINVERSE,t.worldTransform.array)):(y.a.identity(S.VIEW),y.a.identity(S.PROJECTION),y.a.identity(S.VIEWINVERSE)),y.a.multiply(S.VIEWPROJECTION,S.PROJECTION,S.VIEW),y.a.invert(S.PROJECTIONINVERSE,S.PROJECTION),y.a.invert(S.VIEWPROJECTIONINVERSE,S.VIEWPROJECTION);for(var g,_,v,x,T,b,w,E,A,M,C,L,D=this.gl,N=this._sceneRendering,R=this.getGLExtension("OES_vertex_array_object"),P=0;Pthis._glinfo.getMaxJointNumber()){var a=i.getSubSkinMatricesTexture(e.__uid__,e.joints);t.useTextureSlot(this,a,r),t.setUniform(n,"1i","skinMatricesTexture",r),t.setUniform(n,"1f","skinMatricesTextureSize",a.width)}else{var o=i.getSubSkinMatrices(e.__uid__,e.joints);t.setUniformOfSemantic(n,"SKIN_MATRIX",o)}},_renderObject:function(e,t){var r=this.gl,n=e.geometry,i=e.mode;if(null==i&&(i=4),t.indicesBuffer){var a=this.getGLExtension("OES_element_index_uint"),o=a&&n.indices instanceof Uint32Array,s=o?r.UNSIGNED_INT:r.UNSIGNED_SHORT;r.drawElements(i,t.indicesBuffer.count,s,0)}else r.drawArrays(i,0,n.vertexCount)},_bindMaterial:function(e,t,r,n,i,a,o){for(var s=this.gl,u=a===r,l=r.currentTextureSlot(),h=t.getEnabledUniforms(),c=t.getTextureUniforms(),d=this._placeholderTexture,f=0;fc)){var d=Math.sqrt(c-h),f=u-d,p=u+d;return a||(a=new n.a),f<0?p<0?null:(i.a.scaleAndAdd(a.array,o,s,p),a):(i.a.scaleAndAdd(a.array,o,s,f),a)}}}(),intersectBoundingBox:function(e,t){var r,a,o,s,u,l,h=this.direction.array,c=this.origin.array,d=e.min.array,f=e.max.array,p=1/h[0],m=1/h[1],g=1/h[2];if(p>=0?(r=(d[0]-c[0])*p,a=(f[0]-c[0])*p):(a=(d[0]-c[0])*p,r=(f[0]-c[0])*p),m>=0?(o=(d[1]-c[1])*m,s=(f[1]-c[1])*m):(s=(d[1]-c[1])*m,o=(f[1]-c[1])*m),r>s||o>a)return null;if((o>r||r!==r)&&(r=o),(s=0?(u=(d[2]-c[2])*g,l=(f[2]-c[2])*g):(l=(d[2]-c[2])*g,u=(f[2]-c[2])*g),r>l||u>a)return null;if((u>r||r!==r)&&(r=u),(l=0?r:a;return t||(t=new n.a),i.a.scaleAndAdd(t.array,c,h,_),t},intersectTriangle:function(){var e=i.a.create(),t=i.a.create(),r=i.a.create(),a=i.a.create();return function(o,s,u,l,h,c){var d=this.direction.array,f=this.origin.array;o=o.array,s=s.array,u=u.array,i.a.sub(e,s,o),i.a.sub(t,u,o),i.a.cross(a,t,d);var p=i.a.dot(e,a);if(l){if(p>-1e-5)return null}else if(p>-1e-5&&p<1e-5)return null;i.a.sub(r,f,o);var m=i.a.dot(a,r)/p;if(m<0||m>1)return null;i.a.cross(a,e,r);var g=i.a.dot(d,a)/p;if(g<0||g>1||m+g>1)return null;i.a.cross(a,e,t);var _=-i.a.dot(r,a)/p;return _<0?null:(h||(h=new n.a),c&&n.a.set(c,1-m-g,m,g),i.a.scaleAndAdd(h.array,f,d,_),h)}}(),applyTransform:function(e){n.a.add(this.direction,this.direction,this.origin),n.a.transformMat4(this.origin,this.origin,e),n.a.transformMat4(this.direction,this.direction,e),n.a.sub(this.direction,this.direction,this.origin),n.a.normalize(this.direction,this.direction)},copy:function(e){n.a.copy(this.origin,e.origin),n.a.copy(this.direction,e.direction)},clone:function(){var e=new a;return e.copy(this),e}},t.a=a},function(e,t,r){"use strict";var n=r(20),i=r(12),a=r(33),o=r(34),s={};s.create=function(){var e=new n.a(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},s.rotationTo=function(){var e=i.a.create(),t=i.a.fromValues(1,0,0),r=i.a.fromValues(0,1,0);return function(n,a,o){var u=i.a.dot(a,o);return u<-.999999?(i.a.cross(e,t,a),i.a.length(e)<1e-6&&i.a.cross(e,r,a),i.a.normalize(e,e),s.setAxisAngle(n,e,Math.PI),n):u>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(i.a.cross(e,a,o),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+u,s.normalize(n,n))}}(),s.setAxes=function(){var e=o.a.create();return function(t,r,n,i){return e[0]=n[0],e[3]=n[1],e[6]=n[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],s.normalize(t,s.fromMat3(t,e))}}(),s.clone=a.a.clone,s.fromValues=a.a.fromValues,s.copy=a.a.copy,s.set=a.a.set,s.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},s.setAxisAngle=function(e,t,r){r*=.5;var n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e},s.add=a.a.add,s.multiply=function(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=r[0],u=r[1],l=r[2],h=r[3];return e[0]=n*h+o*s+i*l-a*u,e[1]=i*h+o*u+a*s-n*l,e[2]=a*h+o*l+n*u-i*s,e[3]=o*h-n*s-i*u-a*l,e},s.mul=s.multiply,s.scale=a.a.scale,s.rotateX=function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+o*s,e[1]=i*u+a*s,e[2]=a*u-i*s,e[3]=o*u-n*s,e},s.rotateY=function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u-a*s,e[1]=i*u+o*s,e[2]=a*u+n*s,e[3]=o*u-i*s,e},s.rotateZ=function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);return e[0]=n*u+i*s,e[1]=i*u-n*s,e[2]=a*u+o*s,e[3]=o*u-a*s,e},s.calculateW=function(e,t){var r=t[0],n=t[1],i=t[2];return e[0]=r,e[1]=n,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),e},s.dot=a.a.dot,s.lerp=a.a.lerp,s.slerp=function(e,t,r,n){var i,a,o,s,u,l=t[0],h=t[1],c=t[2],d=t[3],f=r[0],p=r[1],m=r[2],g=r[3];return a=l*f+h*p+c*m+d*g,a<0&&(a=-a,f=-f,p=-p,m=-m,g=-g),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,u=Math.sin(n*i)/o):(s=1-n,u=n),e[0]=s*l+u*f,e[1]=s*h+u*p,e[2]=s*c+u*m,e[3]=s*d+u*g,e},s.invert=function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;return e[0]=-r*s,e[1]=-n*s,e[2]=-i*s,e[3]=a*s,e},s.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},s.length=a.a.length,s.len=s.length,s.squaredLength=a.a.squaredLength,s.sqrLen=s.squaredLength,s.normalize=a.a.normalize,s.fromMat3=function(e,t){var r,n=t[0]+t[4]+t[8];if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var a=(i+1)%3,o=(i+2)%3;r=Math.sqrt(t[3*i+i]-t[3*a+a]-t[3*o+o]+1),e[i]=.5*r,r=.5/r,e[3]=(t[3*a+o]-t[3*o+a])*r,e[a]=(t[3*a+i]+t[3*i+a])*r,e[o]=(t[3*o+i]+t[3*i+o])*r}return e},t.a=s},function(e,t,r){"use strict";var n=r(55),i=r(34),a=function(e,t,r,i){e=e||0,t=t||0,r=r||0,i=void 0===i?1:i,this.array=n.a.fromValues(e,t,r,i),this._dirty=!0};a.prototype={constructor:a,add:function(e){return n.a.add(this.array,this.array,e.array),this._dirty=!0,this},calculateW:function(){return n.a.calculateW(this.array,this.array),this._dirty=!0,this},set:function(e,t,r,n){return this.array[0]=e,this.array[1]=t,this.array[2]=r,this.array[3]=n,this._dirty=!0,this},setArray:function(e){return this.array[0]=e[0],this.array[1]=e[1],this.array[2]=e[2],this.array[3]=e[3],this._dirty=!0,this},clone:function(){return new a(this.x,this.y,this.z,this.w)},conjugate:function(){return n.a.conjugate(this.array,this.array),this._dirty=!0,this},copy:function(e){return n.a.copy(this.array,e.array),this._dirty=!0,this},dot:function(e){return n.a.dot(this.array,e.array)},fromMat3:function(e){return n.a.fromMat3(this.array,e.array),this._dirty=!0,this},fromMat4:function(){var e=i.a.create();return function(t){return i.a.fromMat4(e,t.array),i.a.transpose(e,e),n.a.fromMat3(this.array,e),this._dirty=!0,this}}(),identity:function(){return n.a.identity(this.array),this._dirty=!0,this},invert:function(){return n.a.invert(this.array,this.array),this._dirty=!0,this},len:function(){return n.a.len(this.array)},length:function(){return n.a.length(this.array)},lerp:function(e,t,r){return n.a.lerp(this.array,e.array,t.array,r),this._dirty=!0,this},mul:function(e){return n.a.mul(this.array,this.array,e.array),this._dirty=!0,this},mulLeft:function(e){return n.a.multiply(this.array,e.array,this.array),this._dirty=!0,this},multiply:function(e){return n.a.multiply(this.array,this.array,e.array),this._dirty=!0,this},multiplyLeft:function(e){return n.a.multiply(this.array,e.array,this.array),this._dirty=!0,this},normalize:function(){return n.a.normalize(this.array,this.array),this._dirty=!0,this},rotateX:function(e){return n.a.rotateX(this.array,this.array,e),this._dirty=!0,this},rotateY:function(e){return n.a.rotateY(this.array,this.array,e),this._dirty=!0,this},rotateZ:function(e){return n.a.rotateZ(this.array,this.array,e),this._dirty=!0,this},rotationTo:function(e,t){return n.a.rotationTo(this.array,e.array,t.array),this._dirty=!0,this},setAxes:function(e,t,r){return n.a.setAxes(this.array,e.array,t.array,r.array),this._dirty=!0,this},setAxisAngle:function(e,t){return n.a.setAxisAngle(this.array,e.array,t),this._dirty=!0,this},slerp:function(e,t,r){return n.a.slerp(this.array,e.array,t.array,r),this._dirty=!0,this},sqrLen:function(){return n.a.sqrLen(this.array)},squaredLength:function(){return n.a.squaredLength(this.array)},fromEuler:function(e,t){return a.fromEuler(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this.array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this.array)}};var o=Object.defineProperty;if(o){var s=a.prototype;o(s,"x",{get:function(){return this.array[0]},set:function(e){this.array[0]=e,this._dirty=!0}}),o(s,"y",{get:function(){return this.array[1]},set:function(e){this.array[1]=e,this._dirty=!0}}),o(s,"z",{get:function(){return this.array[2]},set:function(e){this.array[2]=e,this._dirty=!0}}),o(s,"w",{get:function(){return this.array[3]},set:function(e){this.array[3]=e,this._dirty=!0}})}a.add=function(e,t,r){return n.a.add(e.array,t.array,r.array),e._dirty=!0,e},a.set=function(e,t,r,i,a){n.a.set(e.array,t,r,i,a),e._dirty=!0},a.copy=function(e,t){return n.a.copy(e.array,t.array),e._dirty=!0,e},a.calculateW=function(e,t){return n.a.calculateW(e.array,t.array),e._dirty=!0,e},a.conjugate=function(e,t){return n.a.conjugate(e.array,t.array),e._dirty=!0,e},a.identity=function(e){return n.a.identity(e.array),e._dirty=!0,e},a.invert=function(e,t){return n.a.invert(e.array,t.array),e._dirty=!0,e},a.dot=function(e,t){return n.a.dot(e.array,t.array)},a.len=function(e){return n.a.length(e.array)},a.lerp=function(e,t,r,i){return n.a.lerp(e.array,t.array,r.array,i),e._dirty=!0,e},a.slerp=function(e,t,r,i){return n.a.slerp(e.array,t.array,r.array,i),e._dirty=!0,e},a.mul=function(e,t,r){return n.a.multiply(e.array,t.array,r.array),e._dirty=!0,e},a.multiply=a.mul,a.rotateX=function(e,t,r){return n.a.rotateX(e.array,t.array,r),e._dirty=!0,e},a.rotateY=function(e,t,r){return n.a.rotateY(e.array,t.array,r),e._dirty=!0,e},a.rotateZ=function(e,t,r){return n.a.rotateZ(e.array,t.array,r),e._dirty=!0,e},a.setAxisAngle=function(e,t,r){return n.a.setAxisAngle(e.array,t.array,r),e._dirty=!0,e},a.normalize=function(e,t){return n.a.normalize(e.array,t.array),e._dirty=!0,e},a.sqrLen=function(e){return n.a.sqrLen(e.array)},a.squaredLength=a.sqrLen,a.fromMat3=function(e,t){return n.a.fromMat3(e.array,t.array),e._dirty=!0,e},a.setAxes=function(e,t,r,i){return n.a.setAxes(e.array,t.array,r.array,i.array),e._dirty=!0,e},a.rotationTo=function(e,t,r){return n.a.rotationTo(e.array,t.array,r.array),e._dirty=!0,e},a.fromEuler=function(e,t,r){e._dirty=!0,t=t.array;var n=e.array,i=Math.cos(t[0]/2),a=Math.cos(t[1]/2),o=Math.cos(t[2]/2),s=Math.sin(t[0]/2),u=Math.sin(t[1]/2),l=Math.sin(t[2]/2),r=(r||"XYZ").toUpperCase();switch(r){case"XYZ":n[0]=s*a*o+i*u*l,n[1]=i*u*o-s*a*l,n[2]=i*a*l+s*u*o,n[3]=i*a*o-s*u*l;break;case"YXZ":n[0]=s*a*o+i*u*l,n[1]=i*u*o-s*a*l,n[2]=i*a*l-s*u*o,n[3]=i*a*o+s*u*l;break;case"ZXY":n[0]=s*a*o-i*u*l,n[1]=i*u*o+s*a*l,n[2]=i*a*l+s*u*o,n[3]=i*a*o-s*u*l;break;case"ZYX":n[0]=s*a*o-i*u*l,n[1]=i*u*o+s*a*l,n[2]=i*a*l-s*u*o,n[3]=i*a*o+s*u*l;break;case"YZX":n[0]=s*a*o+i*u*l,n[1]=i*u*o+s*a*l,n[2]=i*a*l-s*u*o,n[3]=i*a*o-s*u*l;break;case"XZY":n[0]=s*a*o-i*u*l,n[1]=i*u*o-s*a*l,n[2]=i*a*l+s*u*o,n[3]=i*a*o+s*u*l}},t.a=a},function(e,t,r){"use strict";var n=function(){this._contextId=0,this._caches=[],this._context={}};n.prototype={use:function(e,t){var r=this._caches;r[e]||(r[e]={},t&&(r[e]=t())),this._contextId=e,this._context=r[e]},put:function(e,t){this._context[e]=t},get:function(e){return this._context[e]},dirty:function(e){e=e||"";var t="__dt__"+e;this.put(t,!0)},dirtyAll:function(e){e=e||"";for(var t="__dt__"+e,r=this._caches,n=0;n=this._maxSize&&o>0){var u=r.head;r.remove(u),delete n[u.key],a=u.value,this._lastRemovedEntry=u}s?s.value=t:s=new i(t),s.key=e,r.insertEntry(s),n[e]=s}return a},o.get=function(e){var t=this._map[e],r=this._list;if(null!=t)return t!==r.tail&&(r.remove(t),r.insertEntry(t)),t.value},o.clear=function(){this._list.clear(),this._map={}};var s=a;e.exports=s},function(e,t,r){"use strict";var n=r(5),i=r(27),a=r(14),o=r(62),s=r(75),u=r(36),l=r(122),h=r(123),c={loadTexture:function(e,t,r,a){var o;if("function"==typeof t?(r=t,a=r,t={}):t=t||{},"string"==typeof e){if(e.match(/.hdr$/)||"hdr"===t.fileType)return o=new n.a({width:0,height:0,sRGB:!1}),c._fetchTexture(e,function(e){h.a.parseRGBE(e,o,t.exposure),o.dirty(),r&&r(o)},a),o;e.match(/.dds$/)||"dds"===t.fileType?(o=new n.a({width:0,height:0}),c._fetchTexture(e,function(e){l.a.parse(e,o),o.dirty(),r&&r(o)},a)):(o=new n.a,o.load(e),o.success(r),o.error(a))}else"object"==typeof e&&void 0!==e.px&&(o=new i.a,o.load(e),o.success(r),o.error(a));return o},loadPanorama:function(e,t,r,n,i,a){var o=this;"function"==typeof n?(i=n,a=i,n={}):n=n||{},c.loadTexture(t,n,function(t){t.flipY=n.flipY||!1,o.panoramaToCubeMap(e,t,r,n),t.dispose(e),i&&i(r)},a)},panoramaToCubeMap:function(e,t,r,n){var i=new o.a,a=new s.a({scene:new u.a});return a.setEnvironmentMap(t),n=n||{},n.encodeRGBM&&a.material.define("fragment","RGBM_ENCODE"),r.sRGB=t.sRGB,i.texture=r,i.render(e,a.scene),i.texture=null,i.dispose(e),r},heightToNormal:function(e,t){var r=document.createElement("canvas"),n=r.width=e.width,i=r.height=e.height,a=r.getContext("2d");a.drawImage(e,0,0,n,i),t=t||!1;for(var o=a.getImageData(0,0,n,i),s=a.createImageData(n,i),u=0;u20)return console.warn("Given image is not a height map"),e}var d,f,p,m;u%(4*n)==0?(d=o.data[u],p=o.data[u+4]):u%(4*n)==4*(n-1)?(d=o.data[u-4],p=o.data[u]):(d=o.data[u-4],p=o.data[u+4]),u<4*n?(f=o.data[u],m=o.data[u+4*n]):u>n*(i-1)*4?(f=o.data[u-4*n],m=o.data[u]):(f=o.data[u-4*n],m=o.data[u+4*n]),s.data[u]=d-p+127,s.data[u+1]=f-m+127,s.data[u+2]=255,s.data[u+3]=255}return a.putImageData(s,0,0),r},isHeightImage:function(e,t,r){if(!e||!e.width||!e.height)return!1;var n=document.createElement("canvas"),i=n.getContext("2d"),a=t||32;r=r||20,n.width=n.height=a,i.drawImage(e,0,0,a,a);for(var o=i.getImageData(0,0,a,a),s=0;sr)return!1}return!0},_fetchTexture:function(e,t,r){a.a.request.get({url:e,responseType:"arraybuffer",onload:t,onerror:r})},createChessboard:function(e,t,r,i){e=e||512,t=t||64,r=r||"black",i=i||"white";var a=Math.ceil(e/t),o=document.createElement("canvas");o.width=e,o.height=e;var s=o.getContext("2d");s.fillStyle=i,s.fillRect(0,0,e,e),s.fillStyle=r;for(var u=0;u65535?new Uint32Array(3*s):new Uint16Array(3*s),f.material.shader!==t&&f.material.attachShader(t,!0),o.a.setMaterialFromModel(t.__shading,f.material,e,r),u>0&&(this._linesMesh.geometry.resetOffset(),this._linesMesh.geometry.setVertexCount(u),this._linesMesh.geometry.setTriangleCount(l)),this._dataIndexOfVertex=new Uint32Array(a),this._vertexRangeOfDataIndex=new Uint32Array(2*(i-n))},_updateRegionMesh:function(e,t,r,n){for(var i=e.getData(),a=0,s=0,u=!1,h=this._polygonMesh,c=this._linesMesh,d=r;d0;E&&(w*=t.getDevicePixelRatio(),this._updateLinesGeometry(c.geometry,e,d,x,w,e.coordinateSystem.transform)),c.invisible=!E,c.material.set({color:v})}var h=this._polygonMesh;h.material.transparent=u,h.material.depthMask=!u,h.geometry.updateBoundingBox(),h.frontFace=this.extrudeY?o.a.Mesh.CCW:o.a.Mesh.CW,h.material.get("normalMap")&&h.geometry.generateTangents(),h.seriesIndex=e.seriesIndex,h.on("mousemove",this._onmousemove,this),h.on("mouseout",this._onmouseout,this)},_updateDebugWireframe:function(e){var t=e.getModel("debug.wireframe");if(t.get("show")){var r=o.a.parseColor(t.get("lineStyle.color")||"rgba(0,0,0,0.5)"),n=l.a.firstNotNull(t.get("lineStyle.width"),1),i=this._polygonMesh;i.geometry.generateBarycentric(),i.material.define("both","WIREFRAME_TRIANGLE"),i.material.set("wireframeLineColor",r),i.material.set("wireframeLineWidth",n)}},_onmousemove:function(e){var t=this._dataIndexOfVertex[e.triangle[0]];null==t&&(t=-1),t!==this._lastHoverDataIndex&&(this.downplay(this._lastHoverDataIndex),this.highlight(t),this._labelsBuilder.updateLabels([t])),this._lastHoverDataIndex=t,this._polygonMesh.dataIndex=t},_onmouseout:function(e){e.target&&(this.downplay(this._lastHoverDataIndex),this._lastHoverDataIndex=-1,this._polygonMesh.dataIndex=-1),this._labelsBuilder.updateLabels([])},_updateGroundPlane:function(e,t,r){var n=e.getModel("groundPlane",e);if(this._groundMesh.invisible=!n.get("show",!0),!this._groundMesh.invisible){var i=e.get("shading"),a=this._groundMaterials[i];a||(a=this._groundMaterials.lambert),o.a.setMaterialFromModel(i,a,n,r),a.get("normalMap")&&this._groundMesh.geometry.generateTangents(),this._groundMesh.material=a,this._groundMesh.material.set("color",o.a.parseColor(n.get("color"))),this._groundMesh.scale.set(t.size[0],t.size[2],1)}},_triangulation:function(e,t,r){this._triangulationResults=[];for(var n=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0],a=e.coordinateSystem,o=t;o1?n:0,R[V][y]=C.points[W+2],h.set(i+V,R[V]),l?(F[0]=(C.points[W]*x[0]-T[0])/w,F[1]=(C.points[W+2]*x[y]-T[y])/w):(F[0]=(k?B:B+H)/w,F[1]=(R[V][v]*x[v]-T[v])/w),d.set(i+V,F)}p.sub(P,R[1],R[0]),p.sub(I,R[3],R[0]),p.cross(O,P,I),p.normalize(O,O);for(var V=0;V<4;V++)c.set(i+V,O),g&&f.set(i+V,o);for(var V=0;V<6;V++)_[3*a+V]=N[V]+i;i+=4,a+=2,B+=H}}return t.dirty(),{vertexOffset:i,triangleOffset:a}},_getRegionLinesInfo:function(e,t,r){var n=0,i=0;t.getRegionModel(e).getModel("itemStyle").get("borderWidth")>0&&t.getRegionPolygonCoords(e).forEach(function(e){var t=e.exterior,a=e.interiors;n+=r.getPolylineVertexCount(t),i+=r.getPolylineTriangleCount(t);for(var o=0;othis._endIndex)){t-=this._startIndex;for(var n=this._vertexRangeOfDataIndex[2*t];n=2e4},doSortTriangles:function(e,t){var r=this.indices;if(0===t){var n=this.attributes.position,e=e.array;this._triangleZList&&this._triangleZList.length===this.triangleCount||(this._triangleZList=new Float32Array(this.triangleCount),this._sortedTriangleIndices=new Uint32Array(this.triangleCount),this._indicesTmp=new r.constructor(r.length),this._triangleZListTmp=new Float32Array(this.triangleCount));for(var i,l=0,h=0;h0,r={},n=0;n2?(g=this._updateSymbolSprite(e,p,d,f),u.enableTexture("sprite")):u.disableTexture("sprite"),c.position.init(i-n);var _=[];if(m){u.undefine("VERTEX_SIZE"),u.undefine("VERTEX_COLOR");var v=o.getVisual("color"),y=o.getVisual("opacity");s.a.parseColor(v,_),_[3]*=y,u.set({color:_,u_Size:d.maxSize*this._sizeScale})}else u.set({color:[1,1,1,1]}),u.define("VERTEX_SIZE"),u.define("VERTEX_COLOR"),c.size.init(i-n),c.color.init(i-n),this._originalOpacity=new Float32Array(i-n);for(var x=o.getLayout("points"),T=c.position.value,b=0;b1?(a[0]=r.maxSize,a[1]=r.maxSize/r.aspect):(a[1]=r.maxSize,a[0]=r.maxSize*r.aspect),a[0]=a[0]||1,a[1]=a[1]||1,this._symbolType===r.type&&n(this._symbolSize,a)&&this._lineWidth===t.lineWidth||(u.a.createSymbolSprite(r.type,a,{fill:"#fff",lineWidth:t.lineWidth,stroke:"transparent",shadowColor:"transparent",minMargin:Math.min(a[0]/2,10)},this._spriteImageCanvas),u.a.createSDFFromCanvas(this._spriteImageCanvas,Math.min(this._spriteImageCanvas.width,32),20,this._mesh.material.get("sprite").image),this._symbolType=r.type,this._symbolSize=a,this._lineWidth=t.lineWidth),this._spriteImageCanvas.width/r.maxSize*i},_updateMaterial:function(e,t){var r="lighter"===e.get("blendMode")?s.a.additiveBlend:null,n=this._mesh.material;n.blend=r,n.set("lineWidth",t.lineWidth/20);var i=s.a.parseColor(t.stroke);n.set("strokeColor",i),n.transparent=!0,n.depthMask=!1,n.depthTest=!this.is2D,n.sortVertices=!this.is2D},_updateLabelBuilder:function(e,t,r){var n=e.getData(),i=this._mesh.geometry,a=i.attributes.position.value,t=this._startDataIndex,o=this._mesh.sizeScale;this._labelsBuilder.updateData(n,t,r),this._labelsBuilder.getLabelPosition=function(e,r,n){var i=3*(e-t);return[a[i],a[i+1],a[i+2]]},this._labelsBuilder.getLabelDistance=function(e,r,n){return i.attributes.size.get(e-t)/o/2+n},this._labelsBuilder.updateLabels()},_updateAnimation:function(e){s.a.updateVertexAnimation([["prevPosition","position"],["prevSize","size"]],this._prevMesh,this._mesh,e)},_updateHandler:function(e,t,r){var n,i=e.getData(),a=this._mesh,o=this,s=-1,u=e.coordinateSystem&&"cartesian3D"===e.coordinateSystem.type;u&&(n=e.coordinateSystem.model),a.seriesIndex=e.seriesIndex,a.off("mousemove"),a.off("mouseout"),a.on("mousemove",function(t){var l=t.vertexIndex+o._startDataIndex;l!==s&&(this.highlightOnMouseover&&(this.downplay(i,s),this.highlight(i,l),this._labelsBuilder.updateLabels([l])),u&&r.dispatchAction({type:"grid3DShowAxisPointer",value:[i.get(e.coordDimToDataDim("x")[0],l),i.get(e.coordDimToDataDim("y")[0],l),i.get(e.coordDimToDataDim("z")[0],l)],grid3DIndex:n.componentIndex})),a.dataIndex=l,s=l},this),a.on("mouseout",function(e){var t=e.vertexIndex+o._startDataIndex;this.highlightOnMouseover&&(this.downplay(i,t),this._labelsBuilder.updateLabels()),s=-1,a.dataIndex=-1,u&&r.dispatchAction({type:"grid3DHideAxisPointer",grid3DIndex:n.componentIndex})},this)},updateLayout:function(e,t,r){var n=e.getData();if(this._mesh){var i=this._mesh.geometry.attributes.position.value,a=n.getLayout("points");if(this.is2D)for(var o=0;othis._endDataIndex||tthis._endDataIndex||t=this._maxSize&&r>0){var n=this._list.head;this._list.remove(n),delete this._map[n.key]}var i=this._list.insert(t);i.key=e,this._map[e]=i}},i.prototype.get=function(e){var t=this._map[e];if(this._map.hasOwnProperty(e))return t!==this._list.tail&&(this._list.remove(t),this._list.insertEntry(t)),t.value},i.prototype.remove=function(e){var t=this._map[e];void 0!==t&&(delete this._map[e],this._list.remove(t))},i.prototype.clear=function(){this._list.clear(),this._map={}},t.a=i},function(e,t,r){"use strict";var n=r(20),i={};i.create=function(){var e=new n.a(2);return e[0]=0,e[1]=0,e},i.clone=function(e){var t=new n.a(2);return t[0]=e[0],t[1]=e[1],t},i.fromValues=function(e,t){var r=new n.a(2);return r[0]=e,r[1]=t,r},i.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},i.set=function(e,t,r){return e[0]=t,e[1]=r,e},i.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e},i.subtract=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e},i.sub=i.subtract,i.multiply=function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e},i.mul=i.multiply,i.divide=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e},i.div=i.divide,i.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e},i.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e},i.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e},i.scaleAndAdd=function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e},i.distance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)},i.dist=i.distance,i.squaredDistance=function(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n},i.sqrDist=i.squaredDistance,i.length=function(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)},i.len=i.length,i.squaredLength=function(e){var t=e[0],r=e[1];return t*t+r*r},i.sqrLen=i.squaredLength,i.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},i.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},i.normalize=function(e,t){var r=t[0],n=t[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},i.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},i.cross=function(e,t,r){var n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e},i.lerp=function(e,t,r,n){var i=t[0],a=t[1];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e},i.random=function(e,t){t=t||1;var r=2*GLMAT_RANDOM()*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e},i.transformMat2=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e},i.transformMat2d=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e},i.transformMat3=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e},i.transformMat4=function(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e},i.forEach=function(){var e=i.create();return function(t,r,n,i,a,o){var s,u;for(r||(r=2),n||(n=0),u=i?Math.min(i*r+n,t.length):t.length,s=n;s0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=n.a.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},clone:function(){var e=["castShadow","receiveShadow","mode","culling","cullFace","frontFace","frustumCulling","renderOrder","lineWidth","ignorePicking","ignorePreZ","ignoreGBuffer"];return function(){var t=n.a.prototype.clone.call(this);t.geometry=this.geometry,t.material=this.material;for(var r=0;r>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},n.nearestPowerOfTwo=function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))},t.a=n},function(e,t,r){"use strict";var n=r(3),i=r(21),a=r(12),o=r(33),s=function(e,t){this.normal=e||new n.a(0,1,0),this.distance=t||0};s.prototype={constructor:s,distanceToPoint:function(e){return a.a.dot(e.array,this.normal.array)-this.distance},projectPoint:function(e,t){t||(t=new n.a);var r=this.distanceToPoint(e);return a.a.scaleAndAdd(t.array,e.array,this.normal.array,-r),t._dirty=!0,t},normalize:function(){var e=1/a.a.len(this.normal.array);a.a.scale(this.normal.array,e),this.distance*=e},intersectFrustum:function(e){for(var t=e.vertices,r=this.normal.array,n=a.a.dot(t[0].array,r)>this.distance,i=1;i<8;i++)if(a.a.dot(t[i].array,r)>this.distance!=n)return!0},intersectLine:function(){var e=a.a.create();return function(t,r,i){var o=this.distanceToPoint(t),s=this.distanceToPoint(r);if(o>0&&s>0||o<0&&s<0)return null;var u=this.normal.array,l=this.distance,h=t.array;a.a.sub(e,r.array,t.array),a.a.normalize(e,e);var c=a.a.dot(u,e);if(0===c)return null;i||(i=new n.a);var d=(a.a.dot(u,h)-l)/c;return a.a.scaleAndAdd(i.array,h,e,-d),i._dirty=!0,i}}(),applyTransform:function(){var e=i.a.create(),t=o.a.create(),r=o.a.create();return r[3]=1,function(n){n=n.array,a.a.scale(r,this.normal.array,this.distance),o.a.transformMat4(r,r,n),this.distance=a.a.dot(r,this.normal.array),i.a.invert(e,n),i.a.transpose(e,e),t[3]=0,a.a.copy(t,this.normal.array),o.a.transformMat4(t,t,e),a.a.copy(this.normal.array,t)}}(),copy:function(e){a.a.copy(this.normal.array,e.normal.array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new s;return e.copy(this),e}},t.a=s},function(e,t,r){"use strict";var n=r(42);t.a=n.a},function(e,t,r){"use strict";function n(e,t,r){h.identity();var n=new a.a({widthSegments:t,heightSegments:r});switch(e){case"px":o.a.translate(h,h,s.a.POSITIVE_X),o.a.rotateY(h,h,Math.PI/2);break;case"nx":o.a.translate(h,h,s.a.NEGATIVE_X),o.a.rotateY(h,h,-Math.PI/2);break;case"py":o.a.translate(h,h,s.a.POSITIVE_Y),o.a.rotateX(h,h,-Math.PI/2);break;case"ny":o.a.translate(h,h,s.a.NEGATIVE_Y),o.a.rotateX(h,h,Math.PI/2);break;case"pz":o.a.translate(h,h,s.a.POSITIVE_Z);break;case"nz":o.a.translate(h,h,s.a.NEGATIVE_Z),o.a.rotateY(h,h,Math.PI)}return n.applyTransform(h),n}var i=r(15),a=r(43),o=r(9),s=r(3),u=r(18),l=r(14),h=new o.a,c=i.a.extend({dynamic:!1,widthSegments:1,heightSegments:1,depthSegments:1,inside:!1},function(){this.build()},{build:function(){var e={px:n("px",this.depthSegments,this.heightSegments),nx:n("nx",this.depthSegments,this.heightSegments),py:n("py",this.widthSegments,this.depthSegments),ny:n("ny",this.widthSegments,this.depthSegments),pz:n("pz",this.widthSegments,this.heightSegments),nz:n("nz",this.widthSegments,this.heightSegments)},t=["position","texcoord0","normal"],r=0,i=0;for(var a in e)r+=e[a].vertexCount,i+=e[a].indices.length;for(var o=0;o>>16)>>>0;c=((1431655765&c)<<1|(2863311530&c)>>>1)>>>0,c=((858993459&c)<<2|(3435973836&c)>>>2)>>>0,c=((252645135&c)<<4|(4042322160&c)>>>4)>>>0,c=(((16711935&c)<<8|(4278255360&c)>>>8)>>>0)/4294967296;var d=Math.sqrt((1-c)/(1+(l*l-1)*c));o[h]=d}for(var h=0;ho&&(i=this._x=0,a+=this._rowHeight+u,this._y=a,this._rowHeight=0),this._x+=t+u,this._rowHeight=Math.max(this._rowHeight,r),a+r+u>s)return null;e.position[0]+=this.offsetX*this.dpr+i,e.position[1]+=this.offsetY*this.dpr+a,this._zr.add(e);var l=[this.offsetX/this.width,this.offsetY/this.height];return[[i/o+l[0],a/s+l[1]],[(i+t)/o+l[0],(a+r)/s+l[1]]]},_fitElement:function(e,t,r){var n=e.getBoundingRect(),i=t/n.width,a=r/n.height;e.position=[-n.x*i,-n.y*a],e.scale=[i,a],e.update()}},i.prototype={clear:function(){for(var e=0;e=e)){var o=(i+this._nodeWidth)*this._dpr,s=(a+this._nodeHeight)*this._dpr;try{this._zr.resize({width:o,height:s})}catch(e){this._canvas.width=o,this._canvas.height=s}var u=new n(this._zr,i,a,this._nodeWidth,this._nodeHeight,this._gap,this._dpr);return this._textureAtlasNodes.push(u),u}},add:function(e,t,r){if(this._coords[e.id])return this._coords[e.id];var n=this._getCurrentNode().add(e,t,r);if(!n){var i=this._expand();if(!i)return;n=i.add(e,t,r)}return this._coords[e.id]=n,n},getCoordsScale:function(){var e=this._dpr;return[this._nodeWidth/this._canvas.width*e,this._nodeHeight/this._canvas.height*e]},getCoords:function(e){return this._coords[e]}},t.a=i},function(e,t,r){function n(e,t,r,n){r<0&&(e+=r,r=-r),n<0&&(t+=n,n=-n),this.x=e,this.y=t,this.width=r,this.height=n}var i=r(83),a=r(84),o=i.applyTransform,s=Math.min,u=Math.max;n.prototype={constructor:n,union:function(e){var t=s(e.x,this.x),r=s(e.y,this.y);this.width=u(e.x+e.width,this.x+this.width)-t,this.height=u(e.y+e.height,this.y+this.height)-r,this.x=t,this.y=r},applyTransform:function(){var e=[],t=[],r=[],n=[];return function(i){if(i){e[0]=r[0]=this.x,e[1]=n[1]=this.y,t[0]=n[0]=this.x+this.width,t[1]=r[1]=this.y+this.height,o(e,e,i),o(t,t,i),o(r,r,i),o(n,n,i),this.x=s(e[0],t[0],r[0],n[0]),this.y=s(e[1],t[1],r[1],n[1]);var a=u(e[0],t[0],r[0],n[0]),l=u(e[1],t[1],r[1],n[1]);this.width=a-this.x,this.height=l-this.y}}}(),calculateTransform:function(e){var t=this,r=e.width/t.width,n=e.height/t.height,i=a.create();return a.translate(i,i,[-t.x,-t.y]),a.scale(i,i,[r,n]),a.translate(i,i,[e.x,e.y]),i},intersect:function(e){if(!e)return!1;e instanceof n||(e=n.create(e));var t=this,r=t.x,i=t.x+t.width,a=t.y,o=t.y+t.height,s=e.x,u=e.x+e.width,l=e.y,h=e.y+e.height;return!(i=r.x&&e<=r.x+r.width&&t>=r.y&&t<=r.y+r.height},clone:function(){return new n(this.x,this.y,this.width,this.height)},copy:function(e){this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height},plain:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}}},n.create=function(e){return new n(e.x,e.y,e.width,e.height)};var l=n;e.exports=l},function(e,t){function r(e,t){var r=new w(2);return null==e&&(e=0),null==t&&(t=0),r[0]=e,r[1]=t,r}function n(e,t){return e[0]=t[0],e[1]=t[1],e}function i(e){var t=new w(2);return t[0]=e[0],t[1]=e[1],t}function a(e,t,r){return e[0]=t,e[1]=r,e}function o(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function s(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e}function u(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function l(e){return Math.sqrt(h(e))}function h(e){return e[0]*e[0]+e[1]*e[1]}function c(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function d(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function f(e,t){return e[0]*t[0]+e[1]*t[1]}function p(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function m(e,t){var r=l(t);return 0===r?(e[0]=0,e[1]=0):(e[0]=t[0]/r,e[1]=t[1]/r),e}function g(e,t){return Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1]))}function _(e,t){return(e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])}function v(e,t){return e[0]=-t[0],e[1]=-t[1],e}function y(e,t,r,n){return e[0]=t[0]+n*(r[0]-t[0]),e[1]=t[1]+n*(r[1]-t[1]),e}function x(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e}function T(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e}function b(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e}var w="undefined"==typeof Float32Array?Array:Float32Array,E=l,S=h,A=g,M=_;t.create=r,t.copy=n,t.clone=i,t.set=a,t.add=o,t.scaleAndAdd=s,t.sub=u,t.len=l,t.length=E,t.lenSquare=h,t.lengthSquare=S,t.mul=c,t.div=d,t.dot=f,t.scale=p,t.normalize=m,t.distance=g,t.dist=A,t.distanceSquare=_,t.distSquare=M,t.negate=v,t.lerp=y,t.applyTransform=x,t.min=T,t.max=b},function(e,t){function r(){var e=new c(6);return n(e),e}function n(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e}function i(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function a(e,t,r){var n=t[0]*r[0]+t[2]*r[1],i=t[1]*r[0]+t[3]*r[1],a=t[0]*r[2]+t[2]*r[3],o=t[1]*r[2]+t[3]*r[3],s=t[0]*r[4]+t[2]*r[5]+t[4],u=t[1]*r[4]+t[3]*r[5]+t[5];return e[0]=n,e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=u,e}function o(e,t,r){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4]+r[0],e[5]=t[5]+r[1],e}function s(e,t,r){var n=t[0],i=t[2],a=t[4],o=t[1],s=t[3],u=t[5],l=Math.sin(r),h=Math.cos(r);return e[0]=n*h+o*l,e[1]=-n*l+o*h,e[2]=i*h+s*l,e[3]=-i*l+h*s,e[4]=h*a+l*u,e[5]=h*u-l*a,e}function u(e,t,r){var n=r[0],i=r[1];return e[0]=t[0]*n,e[1]=t[1]*i,e[2]=t[2]*n,e[3]=t[3]*i,e[4]=t[4]*n,e[5]=t[5]*i,e}function l(e,t){var r=t[0],n=t[2],i=t[4],a=t[1],o=t[3],s=t[5],u=r*o-a*n;return u?(u=1/u,e[0]=o*u,e[1]=-a*u,e[2]=-n*u,e[3]=r*u,e[4]=(n*s-o*i)*u,e[5]=(a*i-r*s)*u,e):null}function h(e){var t=r();return i(t,e),t}var c="undefined"==typeof Float32Array?Array:Float32Array;t.create=r,t.identity=n,t.copy=i,t.mul=a,t.translate=o,t.rotate=s,t.scale=u,t.invert=l,t.clone=h},function(e,t,r){function n(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}function i(e,t,r,n){var i=t[1]-t[0],a=r[1]-r[0];if(0===i)return 0===a?r[0]:(r[0]+r[1])/2;if(n)if(i>0){if(e<=t[0])return r[0];if(e>=t[1])return r[1]}else{if(e>=t[0])return r[0];if(e<=t[1])return r[1]}else{if(e===t[0])return r[0];if(e===t[1])return r[1]}return(e-t[0])/i*a+r[0]}function a(e,t){switch(e){case"center":case"middle":e="50%";break;case"left":case"top":e="0%";break;case"right":case"bottom":e="100%"}return"string"==typeof e?n(e).match(/%$/)?parseFloat(e)/100*t:parseFloat(e):null==e?NaN:+e}function o(e,t,r){return null==t&&(t=10),t=Math.min(Math.max(0,t),20),e=(+e).toFixed(t),r?e:+e}function s(e){return e.sort(function(e,t){return e-t}),e}function u(e){if(e=+e,isNaN(e))return 0;for(var t=1,r=0;Math.round(e*t)/t!==e;)t*=10,r++;return r}function l(e){var t=e.toString(),r=t.indexOf("e");if(r>0){var n=+t.slice(r+1);return n<0?-n:0}var i=t.indexOf(".");return i<0?0:t.length-1-i}function h(e,t){var r=Math.log,n=Math.LN10,i=Math.floor(r(e[1]-e[0])/n),a=Math.round(r(Math.abs(t[1]-t[0]))/n),o=Math.min(Math.max(-i+a,0),20);return isFinite(o)?o:20}function c(e,t,r){if(!e[t])return 0;var n=x.reduce(e,function(e,t){return e+(isNaN(t)?0:t)},0);if(0===n)return 0;for(var i=Math.pow(10,r),a=x.map(e,function(e){return(isNaN(e)?0:e)/n*i*100}),o=100*i,s=x.map(a,function(e){return Math.floor(e)}),u=x.reduce(s,function(e,t){return e+t},0),l=x.map(a,function(e,t){return e-s[t]});uh&&(h=l[d],c=d);++s[c],l[c]=0,++u}return s[t]/i}function d(e){var t=2*Math.PI;return(e%t+t)%t}function f(e){return e>-T&&e=-20?+e.toFixed(n<0?-n:0):e}function v(e){function t(e,r,n){return e.interval[n]=0}var x=r(13),T=1e-4,b=/^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d\d)(?::(\d\d)(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/;t.linearMap=i,t.parsePercent=a,t.round=o,t.asc=s,t.getPrecision=u,t.getPrecisionSafe=l,t.getPixelPrecision=h,t.getPercentWithPrecision=c,t.MAX_SAFE_INTEGER=9007199254740991,t.remRadian=d,t.isRadianAroundZero=f,t.parseDate=p,t.quantity=m,t.nice=_,t.reformIntervals=v,t.isNumeric=y},function(e,t,r){"use strict";function n(e){u.a.defaultsWithPropList(e,h,c),i(e);for(var t="",r=0;rh&&l.push({pivot:Math.floor((c+h)/2),left:h,right:c});var h=s[u].pivot+1,c=s[u].right;c>h&&l.push({pivot:Math.floor((c+h)/2),left:h,right:c})}s=this._parts=l}else for(var u=0;u50&&(s=1e3);var u=[];a.perspective(u,o,this.width/this.height,1,s),this.viewGL.camera.projectionMatrix.setArray(u),this.viewGL.camera.decomposeProjectionMatrix();var u=a.identity([]),l=this.dataToPoint(this.center);a.scale(u,u,[1,-1,1]),a.translate(u,u,[0,0,-e]),a.rotateX(u,u,t),a.rotateZ(u,u,-this.bearing/180*Math.PI),a.translate(u,u,[-l[0]*this.getScale()*.1,-l[1]*this.getScale()*.1,0]),this.viewGL.camera.viewMatrix.array=u;var h=[];a.invert(h,u),this.viewGL.camera.worldTransform.array=h,this.viewGL.camera.decomposeWorldTransform();var c,d=512*this.getScale();if(this.altitudeExtent&&!isNaN(this.boxHeight)){var f=this.altitudeExtent[1]-this.altitudeExtent[0];c=this.boxHeight/f*this.getScale()/Math.pow(2,this._initialZoom-this.zoomOffset)}else c=d/(2*Math.PI*6378e3*Math.abs(Math.cos(this.center[1]*(Math.PI/180))))*this.altitudeScale*.1;this.viewGL.rootNode.scale.set(.1*this.getScale(),.1*this.getScale(),c)}},getScale:function(){return Math.pow(2,this.zoom-this.zoomOffset)},projectOnTile:function(e,t){return this.projectOnTileWithScale(e,512*this.getScale(),t)},projectOnTileWithScale:function(e,t,r){var n=e[0],i=e[1],a=n*s/180,o=i*s/180,u=t*(a+s)/(2*s),l=t*(s-Math.log(Math.tan(s/4+.5*o)))/(2*s);return r=r||[],r[0]=u,r[1]=l,r},unprojectFromTile:function(e,t){return this.unprojectOnTileWithScale(e,512*this.getScale(),t)},unprojectOnTileWithScale:function(e,t,r){var n=e[0],i=e[1],a=n/t*(2*s)-s,o=2*(Math.atan(Math.exp(s-i/t*(2*s)))-s/4);return r=r||[],r[0]=180*a/s,r[1]=180*o/s,r},dataToPoint:function(e,t){return t=this.projectOnTileWithScale(e,512,t),t[0]-=this._origin[0],t[1]-=this._origin[1],t[2]=isNaN(e[2])?0:e[2],isNaN(e[2])||(t[2]=e[2],this.altitudeExtent&&(t[2]-=this.altitudeExtent[0])),t}},t.a=n},function(e,t,r){"use strict";var n=r(2),i=r(1),a=r(22);t.a=function(e,t,r){function o(e,t){var r=t.getWidth(),n=t.getHeight(),i=t.getDevicePixelRatio();this.viewGL.setViewport(0,0,r,n,i),this.width=r,this.height=n,this.altitudeScale=e.get("altitudeScale"),this.boxHeight=e.get("boxHeight")}function s(e,t){if("auto"!==this.model.get("boxHeight")){var r=[1/0,-1/0];e.eachSeries(function(e){if(e.coordinateSystem===this){var t=e.getData(),n=e.coordDimToDataDim("alt")[0];if(n){var i=t.getDataExtent(n,!0);r[0]=Math.min(r[0],i[0]),r[1]=Math.max(r[1],i[1])}}},this),r&&isFinite(r[1]-r[0])&&(this.altitudeExtent=r)}}return{dimensions:t.prototype.dimensions,create:function(u,l){var h=[];return u.eachComponent(e,function(e){var r=e.__viewGL;r||(r=e.__viewGL=new a.a,r.setRootNode(new i.a.Node));var n=new t;n.viewGL=e.__viewGL,n.resize=o,n.resize(e,l),h.push(n),e.coordinateSystem=n,n.model=e,n.update=s}),u.eachSeries(function(t){if(t.get("coordinateSystem")===e){var r=t.getReferringComponents(e)[0];if(r||(r=u.getComponent(e)),!r)throw new Error(e+' "'+n.a.firstNotNull(t.get(e+"Index"),t.get(e+"Id"),0)+'" not found');t.coordinateSystem=r.coordinateSystem}}),r&&r(h,u,l),h}}}},function(e,t,r){"use strict";t.a="\n@export ecgl.displayShadow.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_WorldPosition;\n\nvarying vec3 v_Normal;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n\n@export ecgl.displayShadow.fragment\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform float roughness: 0.2;\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.ssaoMap.header\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n float shadow = 1.0;\n\n @import ecgl.common.ssaoMap.main\n\n#if defined(DIRECTIONAL_LIGHT_COUNT) && defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n for (int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++) {\n shadow = min(shadow, shadowContribsDir[i] * 0.5 + 0.5);\n }\n#endif\n\n shadow *= 0.5 + ao * 0.5;\n shadow = clamp(shadow, 0.0, 1.0);\n\n gl_FragColor = vec4(vec3(0.0), 1.0 - shadow);\n}\n\n@end"},function(e,t,r){"use strict";function n(e){this.viewGL=e}var i=r(84),a=r.n(i),o=r(83),s=r.n(o);n.prototype.reset=function(e,t){this._updateCamera(t.getWidth(),t.getHeight(),t.getDevicePixelRatio()),this._viewTransform=a.a.create(),this.updateTransform(e,t)},n.prototype.updateTransform=function(e,t){var r=e.coordinateSystem;r.getRoamTransform&&(a.a.invert(this._viewTransform,r.getRoamTransform()),this._setCameraTransform(this._viewTransform),t.getZr().refresh())},n.prototype.dataToPoint=function(e,t,r){r=e.dataToPoint(t,null,r);var n=this._viewTransform;n&&s.a.applyTransform(r,r,n)},n.prototype.removeTransformInPoint=function(e){return this._viewTransform&&s.a.applyTransform(e,e,this._viewTransform),e},n.prototype.getZoom=function(){if(this._viewTransform){var e=this._viewTransform;return 1/Math.max(Math.sqrt(e[0]*e[0]+e[1]*e[1]),Math.sqrt(e[2]*e[2]+e[3]*e[3]))}return 1},n.prototype._setCameraTransform=function(e){var t=this.viewGL.camera;t.position.set(e[4],e[5],0),t.scale.set(Math.sqrt(e[0]*e[0]+e[1]*e[1]),Math.sqrt(e[2]*e[2]+e[3]*e[3]),1)},n.prototype._updateCamera=function(e,t,r){this.viewGL.setViewport(0,0,e,t,r);var n=this.viewGL.camera;n.left=n.top=0,n.bottom=t,n.right=e,n.near=0,n.far=100},t.a=n},function(e,t,r){(function(e){var r;"undefined"!=typeof window?r=window.__DEV__:void 0!==e&&(r=e.__DEV__),void 0===r&&(r=!0);var n=r;t.__DEV__=n}).call(t,r(68))},function(e,t,r){"use strict";var n=r(15),i=r(0),a=r.n(i),o=r(38),s=r(6),u=s.a.vec2,l=[[0,0],[1,1]],h=n.a.extend(function(){return{segmentScale:4,dynamic:!0,useNativeLine:!0,attributes:{position:new n.a.Attribute("position","float",2,"POSITION"),normal:new n.a.Attribute("normal","float",2),offset:new n.a.Attribute("offset","float",1),color:new n.a.Attribute("color","float",4,"COLOR")}}},{resetOffset:function(){this._vertexOffset=0,this._faceOffset=0,this._itemVertexOffsets=[]},setVertexCount:function(e){var t=this.attributes;this.vertexCount!==e&&(t.position.init(e),t.color.init(e),this.useNativeLine||(t.offset.init(e),t.normal.init(e)),e>65535?this.indices instanceof Uint16Array&&(this.indices=new Uint32Array(this.indices)):this.indices instanceof Uint32Array&&(this.indices=new Uint16Array(this.indices)))},setTriangleCount:function(e){this.triangleCount!==e&&(this.indices=0===e?null:this.vertexCount>65535?new Uint32Array(3*e):new Uint16Array(3*e))},_getCubicCurveApproxStep:function(e,t,r,n){return 1/(u.dist(e,t)+u.dist(r,t)+u.dist(n,r)+1)*this.segmentScale},getCubicCurveVertexCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?2*a:2*a+2},getCubicCurveTriangleCount:function(e,t,r,n){var i=this._getCubicCurveApproxStep(e,t,r,n),a=Math.ceil(1/i);return this.useNativeLine?0:2*a},getLineVertexCount:function(){return this.getPolylineVertexCount(l)},getLineTriangleCount:function(){return this.getPolylineTriangleCount(l)},getPolylineVertexCount:function(e){var t;if("number"==typeof e)t=e;else{t="number"!=typeof e[0]?e.length:e.length/2}return this.useNativeLine?2*(t-1):2*(t-1)+2},getPolylineTriangleCount:function(e){var t;if("number"==typeof e)t=e;else{t="number"!=typeof e[0]?e.length:e.length/2}return this.useNativeLine?0:2*(t-1)},addCubicCurve:function(e,t,r,n,i,a){null==a&&(a=1);for(var o=e[0],s=e[1],u=t[0],l=t[1],h=r[0],c=r[1],d=n[0],f=n[1],p=this._getCubicCurveApproxStep(e,t,r,n),m=p*p,g=m*p,_=3*p,v=3*m,y=6*m,x=6*g,T=o-2*u+h,b=s-2*l+c,w=3*(u-h)-o+d,E=3*(l-c)-s+f,S=o,A=s,M=(u-o)*_+T*v+w*g,C=(l-s)*_+b*v+E*g,L=T*y+w*x,D=b*y+E*x,N=w*x,R=E*x,P=0,I=0,O=Math.ceil(1/p),F=new Float32Array(3*(O+1)),F=[],B=0,I=0;I1&&(S=M>0?Math.min(S,d):Math.max(S,d),A=C>0?Math.min(A,f):Math.max(A,f));this.addPolyline(F,i,a)},addLine:function(e,t,r,n){this.addPolyline([e,t],r,n)},addPolyline:function(){var e=u.create(),t=u.create(),r=u.create(),n=u.create(),i=[],a=[],o=[];return function(s,l,h,c,d){if(s.length){var f="number"!=typeof s[0];if(null==d&&(d=f?s.length:s.length/2),!(d<2)){null==c&&(c=0),null==h&&(h=1),this._itemVertexOffsets.push(this._vertexOffset);for(var p,m=f?"number"!=typeof l[0]:l.length/4===d,g=this.attributes.position,_=this.attributes.color,v=this.attributes.offset,y=this.attributes.normal,x=this.indices,T=this._vertexOffset,b=0;b1&&(g.copy(T,T-1),_.copy(T,T-1),T++);else{var S;if(b0){u.sub(e,i,o),u.sub(t,a,i),u.normalize(e,e),u.normalize(t,t),u.add(n,e,t),u.normalize(n,n);var A=h/2*Math.min(1/u.dot(e,n),2);r[0]=-n[1],r[1]=n[0],S=A}else u.sub(e,a,i),u.normalize(e,e),r[0]=-e[1],r[1]=e[0],S=h/2}else u.sub(e,i,o),u.normalize(e,e),r[0]=-e[1],r[1]=e[0],S=h/2;y.set(T,r),y.set(T+1,r),v.set(T,S),v.set(T+1,-S),u.copy(o,i),g.set(T,i),g.set(T+1,i),_.set(T,p),_.set(T+1,p),T+=2}if(this.useNativeLine)_.set(T,p),g.set(T,i),T++;else if(b>0){var M=3*this._faceOffset,x=this.indices;x[M]=T-4,x[M+1]=T-3,x[M+2]=T-2,x[M+3]=T-3,x[M+4]=T-1,x[M+5]=T-2,this._faceOffset+=2}}this._vertexOffset=T}}}}(),setItemColor:function(e,t){for(var r=this._itemVertexOffsets[e],n=ee&&o=0&&this._viewsToDispose.splice(t,1),this.views.push(e),e.layer=this;var r=this.zr;e.scene.traverse(function(e){e.__zr=r,e.addAnimatorsToZr&&e.addAnimatorsToZr(r)})}},_.prototype.removeView=function(e){if(e.layer===this){var t=this.views.indexOf(e);t>=0&&(this.views.splice(t,1),e.scene.traverse(n,this),e.layer=null,this._viewsToDispose.push(e))}},_.prototype.removeViewsAll=function(){this.views.forEach(function(e){e.scene.traverse(n,this),e.layer=null,this._viewsToDispose.push(e)},this),this.views.length=0},_.prototype.resize=function(e,t){this.renderer.resize(e,t)},_.prototype.clear=function(){var e=this.renderer.gl,t=this._backgroundColor||[0,0,0,0];e.clearColor(t[0],t[1],t[2],t[3]),e.depthMask(!0),e.colorMask(!0,!0,!0,!0),e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT)},_.prototype.clearDepth=function(){var e=this.renderer.gl;e.clear(e.DEPTH_BUFFER_BIT)},_.prototype.clearColor=function(){var e=this.renderer.gl;e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)},_.prototype.needsRefresh=function(){this.zr.refresh()},_.prototype.refresh=function(e){this._backgroundColor=e?f.a.parseColor(e):[0,0,0,0],this.renderer.clearColor=this._backgroundColor;for(var t=0;t20)){e=e.event;var n=this.pickObject(e.offsetX,e.offsetY);n&&(this._dispatchEvent(e.type,e,n),this._dispatchDataEvent(e.type,e,n));var i=this._clickToSetFocusPoint(e);if(i){i.view.setDOFFocusOnPoint(i.distance)&&this.zr.refresh()}}}},_.prototype._clickToSetFocusPoint=function(e){for(var t=this.renderer,r=t.viewport,n=this.views.length-1;n>=0;n--){var i=this.views[n];if(i.hasDOF()&&i.containPoint(e.offsetX,e.offsetY)){this._picking.scene=i.scene,this._picking.camera=i.camera,t.viewport=i.viewport;var a=this._picking.pick(e.offsetX,e.offsetY,!0);if(a)return a.view=i,a}}t.viewport=r},_.prototype.onglobalout=function(e){var t=this._hovered;t&&this._dispatchEvent("mouseout",e,{target:t.target})},_.prototype.pickObject=function(e,t){for(var r=[],n=this.renderer,i=n.viewport,a=0;a=0&&(u.dataIndex=this._lastDataIndex,u.seriesIndex=this._lastSeriesIndex,this.zr.handler.dispatchToElement(l,"mouseout",t)),s=!0):null!=o&&o!==this._lastEventData&&(null!=this._lastEventData&&(u.eventData=this._lastEventData,this.zr.handler.dispatchToElement(l,"mouseout",t)),s=!0),this._lastEventData=o,this._lastDataIndex=i,this._lastSeriesIndex=a),u.eventData=o,u.dataIndex=i,u.seriesIndex=a,(null!=o||parseInt(i,10)>=0&&parseInt(a,10)>=0)&&(this.zr.handler.dispatchToElement(l,e,t),s&&this.zr.handler.dispatchToElement(l,"mouseover",t))},_.prototype._dispatchToView=function(e,t){for(var r=0;r=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}t.a={get:n}},function(e,t,r){"use strict";function n(e){return e=Math.round(e),e<0?0:e>255?255:e}function i(e){return e=Math.round(e),e<0?0:e>360?360:e}function a(e){return e<0?0:e>1?1:e}function o(e){return n(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100*255:parseInt(e,10))}function s(e){return a(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100:parseFloat(e))}function u(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e}function l(e,t,r){return e+(t-e)*r}function h(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e}function c(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function d(e,t){y&&c(y,t),y=v.put(e,y||t.slice())}function f(e,t){var r=(parseFloat(e[0])%360+360)%360/360,i=s(e[1]),a=s(e[2]),o=a<=.5?a*(i+1):a+i-a*i,l=2*a-o;return t=t||[],h(t,n(255*u(l,o,r+1/3)),n(255*u(l,o,r)),n(255*u(l,o,r-1/3)),1),4===e.length&&(t[3]=e[3]),t}function p(e){if(e){var t,r,n=e[0]/255,i=e[1]/255,a=e[2]/255,o=Math.min(n,i,a),s=Math.max(n,i,a),u=s-o,l=(s+o)/2;if(0===u)t=0,r=0;else{r=l<.5?u/(s+o):u/(2-s-o);var h=((s-n)/6+u/2)/u,c=((s-i)/6+u/2)/u,d=((s-a)/6+u/2)/u;n===s?t=d-c:i===s?t=1/3+h-d:a===s&&(t=2/3+c-h),t<0&&(t+=1),t>1&&(t-=1)}var f=[360*t,r,l];return null!=e[3]&&f.push(e[3]),f}}var m=r(69),g={},_={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]},v=new m.a(20),y=null;g.parse=function(e,t){if(e){t=t||[];var r=v.get(e);if(r)return c(t,r);e+="";var n=e.replace(/ /g,"").toLowerCase();if(n in _)return c(t,_[n]),d(e,t),t;if("#"!==n.charAt(0)){var i=n.indexOf("("),a=n.indexOf(")");if(-1!==i&&a+1===n.length){var u=n.substr(0,i),l=n.substr(i+1,a-(i+1)).split(","),p=1;switch(u){case"rgba":if(4!==l.length)return void h(t,0,0,0,1);p=s(l.pop());case"rgb":return 3!==l.length?void h(t,0,0,0,1):(h(t,o(l[0]),o(l[1]),o(l[2]),p),d(e,t),t);case"hsla":return 4!==l.length?void h(t,0,0,0,1):(l[3]=s(l[3]),f(l,t),d(e,t),t);case"hsl":return 3!==l.length?void h(t,0,0,0,1):(f(l,t),d(e,t),t);default:return}}h(t,0,0,0,1)}else{if(4===n.length){var m=parseInt(n.substr(1),16);return m>=0&&m<=4095?(h(t,(3840&m)>>4|(3840&m)>>8,240&m|(240&m)>>4,15&m|(15&m)<<4,1),d(e,t),t):void h(t,0,0,0,1)}if(7===n.length){var m=parseInt(n.substr(1),16);return m>=0&&m<=16777215?(h(t,(16711680&m)>>16,(65280&m)>>8,255&m,1),d(e,t),t):void h(t,0,0,0,1)}}}},g.parseToFloat=function(e,t){if(t=g.parse(e,t))return t[0]/=255,t[1]/=255,t[2]/=255,t},g.lift=function(e,t){var r=g.parse(e);if(r){for(var n=0;n<3;n++)r[n]=t<0?r[n]*(1-t)|0:(255-r[n])*t+r[n]|0;return g.stringify(r,4===r.length?"rgba":"rgb")}},g.toHex=function(e){var t=g.parse(e);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)},g.fastLerp=function(e,t,r){if(t&&t.length&&e>=0&&e<=1){r=r||[];var i=e*(t.length-1),o=Math.floor(i),s=Math.ceil(i),u=t[o],h=t[s],c=i-o;return r[0]=n(l(u[0],h[0],c)),r[1]=n(l(u[1],h[1],c)),r[2]=n(l(u[2],h[2],c)),r[3]=a(l(u[3],h[3],c)),r}},g.fastMapToColor=g.fastLerp,g.lerp=function(e,t,r){if(t&&t.length&&e>=0&&e<=1){var i=e*(t.length-1),o=Math.floor(i),s=Math.ceil(i),u=g.parse(t[o]),h=g.parse(t[s]),c=i-o,d=g.stringify([n(l(u[0],h[0],c)),n(l(u[1],h[1],c)),n(l(u[2],h[2],c)),a(l(u[3],h[3],c))],"rgba");return r?{color:d,leftIndex:o,rightIndex:s,value:i}:d}},g.mapToColor=g.lerp,g.modifyHSL=function(e,t,r,n){if(e=g.parse(e))return e=p(e),null!=t&&(e[0]=i(t)),null!=r&&(e[1]=s(r)),null!=n&&(e[2]=s(n)),g.stringify(f(e),"rgba")},g.modifyAlpha=function(e,t){if((e=g.parse(e))&&null!=t)return e[3]=a(t),g.stringify(e,"rgba")},g.stringify=function(e,t){if(e&&e.length){var r=e[0]+","+e[1]+","+e[2];return"rgba"!==t&&"hsva"!==t&&"hsla"!==t||(r+=","+e[3]),t+"("+r+")"}},t.a=g},function(e,t,r){"use strict";var n=function(){this.head=null,this.tail=null,this._length=0};n.prototype.insert=function(e){var t=new n.Entry(e);return this.insertEntry(t),t},n.prototype.insertAt=function(e,t){if(!(e<0)){for(var r=this.head,i=0;r&&i!=e;)r=r.next,i++;if(r){var a=new n.Entry(t),o=r.prev;o?(o.next=a,a.prev=o):this.head=a,a.next=r,r.prev=a}else this.insert(t)}},n.prototype.insertBeforeEntry=function(e,t){var r=new n.Entry(e),i=t.prev;i?(i.next=r,r.prev=i):this.head=r,r.next=t,t.prev=r,this._length++},n.prototype.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,this.tail=e):this.head=this.tail=e,this._length++},n.prototype.remove=function(e){var t=e.prev,r=e.next;t?t.next=r:this.head=r,r?r.prev=t:this.tail=t,e.next=e.prev=null,this._length--},n.prototype.removeAt=function(e){if(!(e<0)){for(var t=this.head,r=0;t&&r!=e;)t=t.next,r++;return t?(this.remove(t),t.value):void 0}},n.prototype.getHead=function(){if(this.head)return this.head.value},n.prototype.getTail=function(){if(this.tail)return this.tail.value},n.prototype.getAt=function(e){if(!(e<0)){for(var t=this.head,r=0;t&&r!=e;)t=t.next,r++;return t.value}},n.prototype.indexOf=function(e){for(var t=this.head,r=0;t;){if(t.value===e)return r;t=t.next,r++}},n.prototype.length=function(){return this._length},n.prototype.isEmpty=function(){return 0===this._length},n.prototype.forEach=function(e,t){for(var r=this.head,n=0,i=void 0!==t;r;)i?e.call(t,r.value,n):e(r.value,n),r=r.next,n++},n.prototype.clear=function(){this.tail=this.head=null,this._length=0},n.Entry=function(e){this.value=e,this.next=null,this.prev=null},t.a=n},function(e,t,r){"use strict";function n(e,t,r){function n(e,r,n,a){var o="";isNaN(r)&&(r=r in t?t[r]:i[r]),isNaN(n)&&(n=n in t?t[n]:i[n]);for(var s=parseInt(r);s0&&n.push("#define "+i.toUpperCase()+"_COUNT "+a)}if(r)for(var o=0;of.getMaxJointNumber()&&(_.USE_SKIN_MATRICES_TEXTURE=null),g="\n"+i(_)+"\n"}var v=g+i(t.vertexDefines,d,m),y=g+i(t.fragmentDefines,d,m),x=v+"\n"+t.shader.vertex,T=["OES_standard_derivatives","EXT_shader_texture_lod"].filter(function(e){return null!=f.getGLExtension(e)});T.indexOf("EXT_shader_texture_lod")>=0&&(y+="\n#define SUPPORT_TEXTURE_LOD"),T.indexOf("OES_standard_derivatives")>=0&&(y+="\n#define SUPPORT_STANDARD_DERIVATIVES");var b=a(T)+"\n"+o(t.precision)+"\n"+y+"\n"+t.shader.fragment,w=n(x,t.vertexDefines,d),E=n(b,t.fragmentDefines,d),c=new u.a;c.uniformSemantics=t.shader.uniformSemantics,c.attributes=t.shader.attributes;var S=c.buildProgram(p,t.shader,w,E);return c.__error=S,s[h]=c,c},t.a=s},function(e,t,r){"use strict";function n(e){for(var t=e.split("\n"),r=0,n=t.length;r=0&&A[E]>1e-4&&(h.a.transformMat4(L,S,b[M[E]]),h.a.scaleAndAdd(C,C,L,A[E]));D.set(w,C)}}for(var w=0;w=0){t||(t=[]);var r=this.indices;return t[0]=r[3*e],t[1]=r[3*e+1],t[2]=r[3*e+2],t}},setTriangleIndices:function(e,t){var r=this.indices;r[3*e]=t[0],r[3*e+1]=t[1],r[3*e+2]=t[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(e){var t,r=this.vertexCount>65535?c.a.Uint32Array:c.a.Uint16Array;if(e[0]&&e[0].length){var n=0;t=new r(3*e.length);for(var i=0;i=0&&(t.splice(r,1),delete this.attributes[e],!0)},getAttribute:function(e){return this.attributes[e]},getEnabledAttributes:function(){var e=this._enabledAttributes,t=this._attributeList;if(e)return e;for(var r=[],n=this.vertexCount,i=0;i0){var i=Math.pow(2,e[3]-128-8+n);t[r+0]=e[0]*i,t[r+1]=e[1]*i,t[r+2]=e[2]*i}else t[r+0]=0,t[r+1]=0,t[r+2]=0;return t[r+3]=1,t}function i(e,t,r){for(var n="",i=t;i0;)if(e[o][0]=t[r++],e[o][1]=t[r++],e[o][2]=t[r++],e[o][3]=t[r++],1===e[o][0]&&1===e[o][1]&&1===e[o][2]){for(var u=e[o][3]<>>0;u>0;u--)a(e[o-1],e[o]),o++,s--;i+=8}else o++,s--,i=0;return r}function s(e,t,r,n){if(nd)return o(e,t,r,n);var i=t[r++];if(2!=i)return o(e,t,r-1,n);if(e[0][1]=t[r++],e[0][2]=t[r++],i=t[r++],(e[0][2]<<8>>>0|i)>>>0!==n)return null;for(var i=0;i<4;i++)for(var a=0;a128){s=(127&s)>>>0;for(var u=t[r++];s--;)e[a++][i]=u}else for(;s--;)e[a++][i]=t[r++]}return r}var u=r(4),l=r(5),h=String.fromCharCode,c=8,d=32767,f={parseRGBE:function(e,t,r){null==r&&(r=0);var a=new Uint8Array(e),o=a.length;if("#?"===i(a,0,2)){for(var c=2;c=o)){c+=2;for(var d="";c=0||(s.forEach(function(t){e.on(t,this[n(t)],this)},this),this._meshes.push(e))},detachFromMesh:function(e){var t=this._meshes.indexOf(e);t>=0&&this._meshes.splice(t,1),s.forEach(function(t){e.off(t,this[n(t)])},this)},dispose:function(){this._meshes.forEach(function(e){this.detachFromMesh(e)},this)}},t.a=u},function(e,t,r){"use strict";var n=r(24),i=r(77),a=n.a.extend({cubemap:null,castShadow:!1,_normalDistribution:null,_brdfLookup:null},{type:"AMBIENT_CUBEMAP_LIGHT",prefilter:function(e,t){if(!e.getGLExtension("EXT_shader_texture_lod"))return void console.warn("Device not support textureCubeLodEXT");this._brdfLookup||(this._normalDistribution=i.a.generateNormalDistribution(),this._brdfLookup=i.a.integrateBRDF(e,this._normalDistribution));var r=this.cubemap;if(!r.__prefiltered){var n=i.a.prefilterEnvironmentMap(e,r,{encodeRGBM:!0,width:t,height:t},this._normalDistribution,this._brdfLookup);this.cubemap=n.environmentMap,this.cubemap.__prefiltered=!0,r.dispose(e)}},getBRDFLookup:function(){return this._brdfLookup},uniformTemplates:{ambientCubemapLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}},ambientCubemapLightCubemap:{type:"t",value:function(e){return e.cubemap}},ambientCubemapLightBRDFLookup:{type:"t",value:function(e){return e._brdfLookup}}}});t.a=a},function(e,t,r){"use strict";t.a="\n@export clay.compositor.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n v_Texcoord = texcoord;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end"},function(e,t,r){"use strict";t.a="#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform sampler2D normalDistribution;\nuniform vec2 viewportSize : [512, 256];\nconst vec3 N = vec3(0.0, 0.0, 1.0);\nconst float fSampleNumber = float(SAMPLE_NUMBER);\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nfloat G_Smith(float roughness, float NoV, float NoL) {\n float k = roughness * roughness / 2.0;\n float G1V = NoV / (NoV * (1.0 - k) + k);\n float G1L = NoL / (NoL * (1.0 - k) + k);\n return G1L * G1V;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / viewportSize;\n float NoV = uv.x;\n float roughness = uv.y;\n vec3 V;\n V.x = sqrt(1.0 - NoV * NoV);\n V.y = 0.0;\n V.z = NoV;\n float A = 0.0;\n float B = 0.0;\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(L.z, 0.0, 1.0);\n float NoH = clamp(H.z, 0.0, 1.0);\n float VoH = clamp(dot(V, H), 0.0, 1.0);\n if (NoL > 0.0) {\n float G = G_Smith(roughness, NoV, NoL);\n float G_Vis = G * VoH / (NoH * NoV);\n float Fc = pow(1.0 - VoH, 5.0);\n A += (1.0 - Fc) * G_Vis;\n B += Fc * G_Vis;\n }\n }\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n"},function(e,t,r){"use strict";t.a="#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(SAMPLE_NUMBER);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"},function(e,t,r){"use strict";var n=r(24),i=r(14),a=n.a.extend({castShadow:!1,coefficients:[]},function(){this._coefficientsTmpArr=new i.a.Float32Array(27)},{type:"AMBIENT_SH_LIGHT",uniformTemplates:{ambientSHLightColor:{type:"3f",value:function(e){var t=e.color,r=e.intensity;return[t[0]*r,t[1]*r,t[2]*r]}},ambientSHLightCoefficients:{type:"3f",value:function(e){for(var t=e._coefficientsTmpArr,r=0;r65535?Uint32Array:Uint16Array,m=this.indices=new p(t*e*6),g=this.radius,_=this.phiStart,v=this.phiLength,y=this.thetaStart,x=this.thetaLength,g=this.radius,T=[],b=[],w=0,E=1/g;for(f=0;f<=e;f++)for(d=0;d<=t;d++)h=d/t,c=f/e,s=-g*Math.cos(_+h*v)*Math.sin(y+c*x),u=g*Math.cos(y+c*x),l=g*Math.sin(_+h*v)*Math.sin(y+c*x),T[0]=s,T[1]=u,T[2]=l,b[0]=h,b[1]=c,r.set(w,T),n.set(w,b),T[0]*=E,T[1]*=E,T[2]*=E,a.set(w,T),w++;var S,A,M,C,L=t+1,D=0;for(f=0;f=0&&l.splice(e,1)}),l.push(h),this.__zr&&this.__zr.animation.addAnimator(h),h},stopAnimation:function(e){this._animators=this._animators||[];for(var t=this._animators,r=t.length,n=0;n.5?t:e}function s(e,t,r,n,i){var o=e.length;if(1==i)for(var s=0;si)e.length=i;else for(var a=n;a=0&&!(C[r]<=t);r--);r=Math.min(r,T-2)}else{for(r=V;rt);r++);r=Math.min(r-1,T-2)}V=r,k=t;var n=C[r+1]-C[r];if(0!==n)if(B=(t-C[r])/n,x)if(z=L[r],U=L[0===r?r:r-1],G=L[r>T-2?T-1:r+1],H=L[r>T-3?T-1:r+2],E)h(U,z,G,H,B,B*B,B*B*B,m(e,i),M);else{var u;if(S)u=h(U,z,G,H,B,B*B,B*B*B,W,1),u=f(W);else{if(A)return o(z,G,B);u=c(U,z,G,H,B,B*B,B*B*B)}v(e,i,u)}else if(E)s(L[r],L[r+1],B,m(e,i),M);else{var u;if(S)s(L[r],L[r+1],B,W,1),u=f(W);else{if(A)return o(L[r],L[r+1],B);u=a(L[r],L[r+1],B)}v(e,i,u)}},X=new g({target:e._target,life:b,loop:e._loop,delay:e._delay,onframe:j,ondestroy:r});return t&&"spline"!==t&&(X.easing=t),X}}}var g=r(143),_=r(145),v=r(13),y=v.isArrayLike,x=Array.prototype.slice,T=function(e,t,r,a){this._tracks={},this._target=e,this._loop=t||!1,this._getter=r||n,this._setter=a||i,this._clipCount=0,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]};T.prototype={when:function(e,t){var r=this._tracks;for(var n in t)if(t.hasOwnProperty(n)){if(!r[n]){r[n]=[];var i=this._getter(this._target,n);if(null==i)continue;0!==e&&r[n].push({time:0,value:d(i)})}r[n].push({time:e,value:t[n]})}return this},during:function(e){return this._onframeList.push(e),this},pause:function(){for(var e=0;e255?255:e}function i(e){return e=Math.round(e),e<0?0:e>360?360:e}function a(e){return e<0?0:e>1?1:e}function o(e){return n(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100*255:parseInt(e,10))}function s(e){return a(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100:parseFloat(e))}function u(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e}function l(e,t,r){return e+(t-e)*r}function h(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e}function c(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function d(e,t){A&&c(A,t),A=S.put(e,A||t.slice())}function f(e,t){if(e){t=t||[];var r=S.get(e);if(r)return c(t,r);e+="";var n=e.replace(/ /g,"").toLowerCase();if(n in E)return c(t,E[n]),d(e,t),t;if("#"!==n.charAt(0)){var i=n.indexOf("("),a=n.indexOf(")");if(-1!==i&&a+1===n.length){var u=n.substr(0,i),l=n.substr(i+1,a-(i+1)).split(","),f=1;switch(u){case"rgba":if(4!==l.length)return void h(t,0,0,0,1);f=s(l.pop());case"rgb":return 3!==l.length?void h(t,0,0,0,1):(h(t,o(l[0]),o(l[1]),o(l[2]),f),d(e,t),t);case"hsla":return 4!==l.length?void h(t,0,0,0,1):(l[3]=s(l[3]),p(l,t),d(e,t),t);case"hsl":return 3!==l.length?void h(t,0,0,0,1):(p(l,t),d(e,t),t);default:return}}h(t,0,0,0,1)}else{if(4===n.length){var m=parseInt(n.substr(1),16);return m>=0&&m<=4095?(h(t,(3840&m)>>4|(3840&m)>>8,240&m|(240&m)>>4,15&m|(15&m)<<4,1),d(e,t),t):void h(t,0,0,0,1)}if(7===n.length){var m=parseInt(n.substr(1),16);return m>=0&&m<=16777215?(h(t,(16711680&m)>>16,(65280&m)>>8,255&m,1),d(e,t),t):void h(t,0,0,0,1)}}}}function p(e,t){var r=(parseFloat(e[0])%360+360)%360/360,i=s(e[1]),a=s(e[2]),o=a<=.5?a*(i+1):a+i-a*i,l=2*a-o;return t=t||[],h(t,n(255*u(l,o,r+1/3)),n(255*u(l,o,r)),n(255*u(l,o,r-1/3)),1),4===e.length&&(t[3]=e[3]),t}function m(e){if(e){var t,r,n=e[0]/255,i=e[1]/255,a=e[2]/255,o=Math.min(n,i,a),s=Math.max(n,i,a),u=s-o,l=(s+o)/2;if(0===u)t=0,r=0;else{r=l<.5?u/(s+o):u/(2-s-o);var h=((s-n)/6+u/2)/u,c=((s-i)/6+u/2)/u,d=((s-a)/6+u/2)/u;n===s?t=d-c:i===s?t=1/3+h-d:a===s&&(t=2/3+c-h),t<0&&(t+=1),t>1&&(t-=1)}var f=[360*t,r,l];return null!=e[3]&&f.push(e[3]),f}}function g(e,t){var r=f(e);if(r){for(var n=0;n<3;n++)r[n]=t<0?r[n]*(1-t)|0:(255-r[n])*t+r[n]|0,r[n]>255?r[n]=255:e[n]<0&&(r[n]=0);return b(r,4===r.length?"rgba":"rgb")}}function _(e){var t=f(e);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)}function v(e,t,r){if(t&&t.length&&e>=0&&e<=1){r=r||[];var i=e*(t.length-1),o=Math.floor(i),s=Math.ceil(i),u=t[o],h=t[s],c=i-o;return r[0]=n(l(u[0],h[0],c)),r[1]=n(l(u[1],h[1],c)),r[2]=n(l(u[2],h[2],c)),r[3]=a(l(u[3],h[3],c)),r}}function y(e,t,r){if(t&&t.length&&e>=0&&e<=1){var i=e*(t.length-1),o=Math.floor(i),s=Math.ceil(i),u=f(t[o]),h=f(t[s]),c=i-o,d=b([n(l(u[0],h[0],c)),n(l(u[1],h[1],c)),n(l(u[2],h[2],c)),a(l(u[3],h[3],c))],"rgba");return r?{color:d,leftIndex:o,rightIndex:s,value:i}:d}}function x(e,t,r,n){if(e=f(e))return e=m(e),null!=t&&(e[0]=i(t)),null!=r&&(e[1]=s(r)),null!=n&&(e[2]=s(n)),b(p(e),"rgba")}function T(e,t){if((e=f(e))&&null!=t)return e[3]=a(t),b(e,"rgba")}function b(e,t){if(e&&e.length){var r=e[0]+","+e[1]+","+e[2];return"rgba"!==t&&"hsva"!==t&&"hsla"!==t||(r+=","+e[3]),t+"("+r+")"}}var w=r(60),E={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]},S=new w(20),A=null,M=v,C=y;t.parse=f,t.lift=g,t.toHex=_,t.fastLerp=v,t.fastMapToColor=M,t.lerp=y,t.mapToColor=C,t.modifyHSL=x,t.modifyAlpha=T,t.stringify=b},function(e,t,r){"use strict";t.a="\n@export clay.util.rand\nhighp float rand(vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\n#ifdef SUPPORT_STANDARD_DERIVATIVES\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#else\nfloat edgeFactor(float width)\n{\n return 1.0;\n}\n#endif\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\nvec4 sRGBToLinear(in vec4 value) {\n return vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.w);\n}\nvec4 linearTosRGB(in vec4 value) {\n return vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92, vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.w);\n}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n#ifdef USE_SKIN_MATRICES_TEXTURE\nuniform sampler2D skinMatricesTexture : ignore;\nuniform float skinMatricesTextureSize: ignore;\nmat4 getSkinMatrix(sampler2D tex, float idx) {\n float j = idx * 4.0;\n float x = mod(j, skinMatricesTextureSize);\n float y = floor(j / skinMatricesTextureSize) + 0.5;\n vec2 scale = vec2(skinMatricesTextureSize);\n return mat4(\n texture2D(tex, vec2(x + 0.5, y) / scale),\n texture2D(tex, vec2(x + 1.5, y) / scale),\n texture2D(tex, vec2(x + 2.5, y) / scale),\n texture2D(tex, vec2(x + 3.5, y) / scale)\n );\n}\nmat4 getSkinMatrix(float idx) {\n return getSkinMatrix(skinMatricesTexture, idx);\n}\n#else\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end"},function(e,t,r){"use strict";t.a="\n@export ecgl.common.transformUniforms\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n@end\n\n@export ecgl.common.attributes\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\n@end\n\n@export ecgl.common.uv.header\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nuniform vec2 detailUvRepeat : [1.0, 1.0];\nuniform vec2 detailUvOffset : [0.0, 0.0];\n\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n@export ecgl.common.uv.main\nv_Texcoord = texcoord * uvRepeat + uvOffset;\nv_DetailTexcoord = texcoord * detailUvRepeat + detailUvOffset;\n@end\n\n@export ecgl.common.uv.fragmentHeader\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n\n@export ecgl.common.albedo.main\n\n vec4 albedoTexel = vec4(1.0);\n#ifdef DIFFUSEMAP_ENABLED\n albedoTexel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n albedoTexel = sRGBToLinear(albedoTexel);\n #endif\n#endif\n\n#ifdef DETAILMAP_ENABLED\n vec4 detailTexel = texture2D(detailMap, v_DetailTexcoord);\n #ifdef SRGB_DECODE\n detailTexel = sRGBToLinear(detailTexel);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, detailTexel.rgb, detailTexel.a);\n albedoTexel.a = detailTexel.a + (1.0 - detailTexel.a) * albedoTexel.a;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexHeader\n\n#ifdef WIREFRAME_QUAD\nattribute vec4 barycentric;\nvarying vec4 v_Barycentric;\n#elif defined(WIREFRAME_TRIANGLE)\nattribute vec3 barycentric;\nvarying vec3 v_Barycentric;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n v_Barycentric = barycentric;\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentHeader\n\nuniform float wireframeLineWidth : 1;\nuniform vec4 wireframeLineColor: [0, 0, 0, 0.5];\n\n#ifdef WIREFRAME_QUAD\nvarying vec4 v_Barycentric;\nfloat edgeFactor () {\n vec4 d = fwidth(v_Barycentric);\n vec4 a4 = smoothstep(vec4(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(min(a4.x, a4.y), a4.z), a4.w);\n}\n#elif defined(WIREFRAME_TRIANGLE)\nvarying vec3 v_Barycentric;\nfloat edgeFactor () {\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n if (wireframeLineWidth > 0.) {\n vec4 lineColor = wireframeLineColor;\n#ifdef SRGB_DECODE\n lineColor = sRGBToLinear(lineColor);\n#endif\n\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor()) * lineColor.a);\n }\n#endif\n@end\n\n\n\n\n@export ecgl.common.bumpMap.header\n\n#ifdef BUMPMAP_ENABLED\nuniform sampler2D bumpMap;\nuniform float bumpScale : 1.0;\n\n\nvec3 bumpNormal(vec3 surfPos, vec3 surfNormal, vec3 baseNormal)\n{\n vec2 dSTdx = dFdx(v_Texcoord);\n vec2 dSTdy = dFdy(v_Texcoord);\n\n float Hll = bumpScale * texture2D(bumpMap, v_Texcoord).x;\n float dHx = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdx).x - Hll;\n float dHy = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdy).x - Hll;\n\n vec3 vSigmaX = dFdx(surfPos);\n vec3 vSigmaY = dFdy(surfPos);\n vec3 vN = surfNormal;\n\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n\n float fDet = dot(vSigmaX, R1);\n\n vec3 vGrad = sign(fDet) * (dHx * R1 + dHy * R2);\n return normalize(abs(fDet) * baseNormal - vGrad);\n\n}\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexHeader\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexMain\n\n#ifdef NORMALMAP_ENABLED\n if (dot(tangent, tangent) > 0.0) {\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n#endif\n\n@end\n\n\n@export ecgl.common.normalMap.fragmentHeader\n\n#ifdef NORMALMAP_ENABLED\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.fragmentMain\n#ifdef NORMALMAP_ENABLED\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_DetailTexcoord).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n mat3 tbn = mat3(v_Tangent, v_Bitangent, v_Normal);\n N = normalize(tbn * N);\n }\n }\n#endif\n@end\n\n\n\n@export ecgl.common.vertexAnimation.header\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevNormal;\nuniform float percent;\n#endif\n\n@end\n\n@export ecgl.common.vertexAnimation.main\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n vec3 norm = mix(prevNormal, normal, percent);\n#else\n vec3 pos = position;\n vec3 norm = normal;\n#endif\n\n@end\n\n\n@export ecgl.common.ssaoMap.header\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n@end\n\n@export ecgl.common.ssaoMap.main\n float ao = 1.0;\n#ifdef SSAOMAP_ENABLED\n ao = texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n@end\n\n\n\n\n@export ecgl.common.diffuseLayer.header\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\nuniform float layerDiffuseIntensity[LAYER_DIFFUSEMAP_COUNT];\nuniform sampler2D layerDiffuseMap[LAYER_DIFFUSEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.header\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\nuniform float layerEmissionIntensity[LAYER_EMISSIVEMAP_COUNT];\nuniform sampler2D layerEmissiveMap[LAYER_EMISSIVEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.layers.header\n@import ecgl.common.diffuseLayer.header\n@import ecgl.common.emissiveLayer.header\n@end\n\n@export ecgl.common.diffuseLayer.main\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_DIFFUSEMAP_COUNT; _idx_++) {{\n float intensity = layerDiffuseIntensity[_idx_];\n vec4 texel2 = texture2D(layerDiffuseMap[_idx_], v_Texcoord);\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, texel2.rgb * intensity, texel2.a);\n albedoTexel.a = texel2.a + (1.0 - texel2.a) * albedoTexel.a;\n }}\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.main\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_EMISSIVEMAP_COUNT; _idx_++)\n {{\n vec4 texel2 = texture2D(layerEmissiveMap[_idx_], v_Texcoord) * layerEmissionIntensity[_idx_];\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n float intensity = layerEmissionIntensity[_idx_];\n gl_FragColor.rgb += texel2.rgb * texel2.a * intensity;\n }}\n#endif\n\n@end\n"},function(e,t,r){"use strict";t.a="@export ecgl.color.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\n@import ecgl.common.uv.header\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position: POSITION;\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvoid main()\n{\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n @import ecgl.common.uv.main\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n@export ecgl.color.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.layers.header\n\n@import ecgl.common.uv.fragmentHeader\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n\n}\n@end"},function(e,t,r){"use strict";t.a="/**\n * http: */\n\n@export ecgl.lambert.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n\n@import ecgl.common.attributes\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.vertexAnimation.header\n\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n}\n\n@end\n\n\n@export ecgl.lambert.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n gl_FragColor *= sRGBToLinear(v_Color);\n #else\n gl_FragColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n diffuseColor += ambientLightColor[i] * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"},function(e,t,r){"use strict";t.a="@export ecgl.realistic.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@import ecgl.common.vertexAnimation.header\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n\n\n@export ecgl.realistic.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n#define PI 3.14159265358979\n#define ROUGHNESS_CHANEL 0\n#define METALNESS_CHANEL 1\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\n\nuniform sampler2D detailMap;\nuniform sampler2D metalnessMap;\nuniform sampler2D roughnessMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform float metalness : 0.0;\nuniform float roughness : 0.5;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import clay.header.ambient_cubemap_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.normalMap.fragmentHeader\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import clay.util.rgbm\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nvoid main()\n{\n vec4 albedoColor = color;\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n albedoColor *= sRGBToLinear(v_Color);\n #else\n albedoColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n albedoColor *= albedoTexel;\n\n float m = metalness;\n\n#ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_DetailTexcoord)[METALNESS_CHANEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 specFactor = mix(vec3(0.04), baseColor, m);\n\n float g = 1.0 - roughness;\n\n#ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n@import ecgl.common.normalMap.fragmentMain\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseTerm = vec3(0.0);\n vec3 specularTerm = vec3(0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, specFactor);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_] * ambientFactor * ao;\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -directionalLightDirection[_idx_];\n vec3 lc = directionalLightColor[_idx_];\n\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, normalize(L)), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\n L = vec3(L.x, L[NORMAL_UP_AXIS], L[NORMAL_FRONT_AXIS]);\n float rough2 = clamp(1.0 - g, 0.0, 1.0);\n float bias2 = rough2 * 5.0;\n vec2 brdfParam2 = texture2D(ambientCubemapLightBRDFLookup[0], vec2(rough2, ndv)).xy;\n vec3 envWeight2 = specFactor * brdfParam2.x + brdfParam2.y;\n vec3 envTexel2;\n for(int _idx_ = 0; _idx_ < AMBIENT_CUBEMAP_LIGHT_COUNT; _idx_++)\n {{\n envTexel2 = RGBMDecode(textureCubeLodEXT(ambientCubemapLightCubemap[_idx_], L, bias2), 8.12);\n specularTerm += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2 * ao;\n }}\n#endif\n\n gl_FragColor.rgb = albedoColor.rgb * diffuseTerm + specularTerm;\n gl_FragColor.a = albedoColor.a;\n\n#ifdef SRGB_ENCODE\n gl_FragColor = linearTosRGB(gl_FragColor);\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end"},function(e,t,r){"use strict";t.a="@export ecgl.hatching.vertex\n\n@import ecgl.realistic.vertex\n\n@end\n\n\n@export ecgl.hatching.fragment\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [0.0, 0.0, 0.0, 1.0];\nuniform vec4 paperColor : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nuniform sampler2D hatch1;\nuniform sampler2D hatch2;\nuniform sampler2D hatch3;\nuniform sampler2D hatch4;\nuniform sampler2D hatch5;\nuniform sampler2D hatch6;\n\nfloat shade(in float tone) {\n vec4 c = vec4(1. ,1., 1., 1.);\n float step = 1. / 6.;\n vec2 uv = v_DetailTexcoord;\n if (tone <= step / 2.0) {\n c = mix(vec4(0.), texture2D(hatch6, uv), 12. * tone);\n }\n else if (tone <= step) {\n c = mix(texture2D(hatch6, uv), texture2D(hatch5, uv), 6. * tone);\n }\n if(tone > step && tone <= 2. * step){\n c = mix(texture2D(hatch5, uv), texture2D(hatch4, uv) , 6. * (tone - step));\n }\n if(tone > 2. * step && tone <= 3. * step){\n c = mix(texture2D(hatch4, uv), texture2D(hatch3, uv), 6. * (tone - 2. * step));\n }\n if(tone > 3. * step && tone <= 4. * step){\n c = mix(texture2D(hatch3, uv), texture2D(hatch2, uv), 6. * (tone - 3. * step));\n }\n if(tone > 4. * step && tone <= 5. * step){\n c = mix(texture2D(hatch2, uv), texture2D(hatch1, uv), 6. * (tone - 4. * step));\n }\n if(tone > 5. * step){\n c = mix(texture2D(hatch1, uv), vec4(1.), 6. * (tone - 5. * step));\n }\n\n return c.r;\n}\n\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n vec4 inkColor = sRGBToLinear(color);\n#else\n vec4 inkColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n inkColor *= sRGBToLinear(v_Color);\n #else\n inkColor *= v_Color;\n #endif\n#endif\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float tone = 0.0;\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n tone += dot(ambientLightColor[i], w) * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n tone += dot(calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_], w) * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n float lightTone = dot(directionalLightColor[i], w);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n tone += lightTone * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor = mix(inkColor, paperColor, shade(clamp(tone, 0.0, 1.0)));\n }\n@end\n"},function(e,t,r){"use strict";t.a="@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n v_Texcoord = texcoord;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end"},function(e,t,r){"use strict";function n(e,t){if(e&&e[t]&&(e[t].normal||e[t].emphasis)){var r=e[t].normal,n=e[t].emphasis;r&&(e[t]=r),n&&(e.emphasis=e.emphasis||{},e.emphasis[t]=n)}}function i(e){n(e,"itemStyle"),n(e,"lineStyle"),n(e,"areaStyle"),n(e,"label")}function a(e){e&&(e instanceof Array||(e=[e]),s.a.util.each(e,function(e){if(e.axisLabel){var t=e.axisLabel;s.a.util.extend(t,t.textStyle),t.textStyle=null}}))}var o=r(0),s=r.n(o),u=["bar3D","line3D","map3D","scatter3D","surface","lines3D","scatterGL","scatter3D"];t.a=function(e){s.a.util.each(e.series,function(t){s.a.util.indexOf(u,t.type)>=0&&(i(t),"mapbox"===t.coordinateSystem&&(t.coordinateSystem="mapbox3D",e.mapbox3D=e.mapbox))}),a(e.xAxis3D),a(e.yAxis3D),a(e.zAxis3D),a(e.grid3D),n(e.geo3D)}},function(e,t,r){"use strict";var n=(r(155),r(159),r(160),r(167),r(0)),i=r.n(n);i.a.registerAction({type:"grid3DChangeCamera",event:"grid3dcamerachanged",update:"series:updateCamera"},function(e,t){t.eachComponent({mainType:"grid3D",query:e},function(t){t.setView(e)})}),i.a.registerAction({type:"grid3DShowAxisPointer",event:"grid3dshowaxispointer",update:"grid3D:showAxisPointer"},function(e,t){}),i.a.registerAction({type:"grid3DHideAxisPointer",event:"grid3dhideaxispointer",update:"grid3D:hideAxisPointer"},function(e,t){})},function(e,t,r){"use strict";function n(e,t){return t.type||(t.data?"category":"value")}var i=r(0),a=r.n(i),o=r(156),s=a.a.extendComponentModel({type:"cartesian3DAxis",axis:null,getCoordSysModel:function(){return this.ecModel.queryComponents({mainType:"grid3D",index:this.option.gridIndex,id:this.option.gridId})[0]}});a.a.helper.mixinAxisModelCommonMethods(s),Object(o.a)("x",s,n,{name:"X"}),Object(o.a)("y",s,n,{name:"Y"}),Object(o.a)("z",s,n,{name:"Z"})},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(157),o=r(158),s=r.n(o),u=["value","category","time","log"];t.a=function(e,t,r,n){i.a.util.each(u,function(o){t.extend({type:e+"Axis3D."+o,__ordinalMeta:null,mergeDefaultAndTheme:function(t,n){var a=n.getTheme();i.a.util.merge(t,a.get(o+"Axis3D")),i.a.util.merge(t,this.getDefaultOption()),t.type=r(e,t)},optionUpdated:function(){"category"===this.option.type&&(this.__ordinalMeta=s.a.createByAxisModel(this))},getCategories:function(){if("category"===this.option.type)return this.__ordinalMeta.categories},getOrdinalMeta:function(){return this.__ordinalMeta},defaultOption:i.a.util.merge(i.a.util.clone(a.a[o+"Axis3D"]),n||{},!0)})}),t.superClass.registerSubTypeDefaulter(e+"Axis3D",i.a.util.curry(r,e))}},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a={show:!0,grid3DIndex:0,inverse:!1,name:"",nameLocation:"middle",nameTextStyle:{fontSize:16},nameGap:20,axisPointer:{},axisLine:{},axisTick:{},axisLabel:{},splitArea:{}},o=i.a.util.merge({boundaryGap:!0,axisTick:{alignWithLabel:!1,interval:"auto"},axisLabel:{interval:"auto"},axisPointer:{label:{show:!1}}},a),s=i.a.util.merge({boundaryGap:[0,0],splitNumber:5,axisPointer:{label:{}}},a),u=i.a.util.defaults({scale:!0,min:"dataMin",max:"dataMax"},s),l=i.a.util.defaults({logBase:10},s);l.scale=!0,t.a={categoryAxis3D:o,valueAxis3D:s,timeAxis3D:u,logAxis3D:l}},function(e,t,r){function n(e){this.categories=e.categories||[],this._needCollect=e.needCollect,this._deduplication=e.deduplication,this._map}function i(e){return e._map||(e._map=s(e.categories))}function a(e){return u(e)&&null!=e.value?e.value:e+""}var o=r(13),s=o.createHashMap,u=o.isObject,l=o.map;n.createByAxisModel=function(e){var t=e.option,r=t.data,i=r&&l(r,a);return new n({categories:i,needCollect:!i,deduplication:!1!==t.dedplication})};var h=n.prototype;h.getOrdinal=function(e){return i(this).get(e)},h.parseAndCollect=function(e){var t,r=this._needCollect;if("string"!=typeof e&&!r)return e;if(r&&!this._deduplication)return t=this.categories.length,this.categories[t]=e,t;var n=i(this);return t=n.get(e),null==t&&(r?(t=this.categories.length,this.categories[t]=e,n.set(e,t)):t=NaN),t};var c=n;e.exports=c},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(44),o=r(28),s=r(29),u=i.a.extendComponentModel({type:"grid3D",dependencies:["xAxis3D","yAxis3D","zAxis3D"],defaultOption:{show:!0,zlevel:-10,left:0,top:0,width:"100%",height:"100%",environment:"auto",boxWidth:100,boxHeight:100,boxDepth:100,axisPointer:{show:!0,lineStyle:{color:"rgba(0, 0, 0, 0.8)",width:1},label:{show:!0,formatter:null,margin:8,textStyle:{fontSize:14,color:"#fff",backgroundColor:"rgba(0,0,0,0.5)",padding:3,borderRadius:3}}},axisLine:{show:!0,lineStyle:{color:"#333",width:2,type:"solid"}},axisTick:{show:!0,inside:!1,length:3,lineStyle:{width:1}},axisLabel:{show:!0,inside:!1,rotate:0,margin:8,textStyle:{fontSize:12}},splitLine:{show:!0,lineStyle:{color:["#ccc"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.3)","rgba(200,200,200,0.3)"]}},light:{main:{alpha:30,beta:40},ambient:{intensity:.4}},viewControl:{alpha:20,beta:40,autoRotate:!1,distance:200,minDistance:40,maxDistance:400}}});i.a.util.merge(u.prototype,a.a),i.a.util.merge(u.prototype,o.a),i.a.util.merge(u.prototype,s.a)},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(1),o=r(45),s=r(25),u=r(2),l=r(81),h=r(30),c=r(162),d=r(164),f=r(63),p=r(46),m=u.a.firstNotNull;a.a.Shader.import(p.a),["x","y","z"].forEach(function(e){i.a.extendComponentView({type:e+"Axis3D"})});var g={x:0,y:2,z:1};i.a.extendComponentView({type:"grid3D",__ecgl__:!0,init:function(e,t){var r=[["y","z","x",-1,"left"],["y","z","x",1,"right"],["x","y","z",-1,"bottom"],["x","y","z",1,"top"],["x","z","y",-1,"far"],["x","z","y",1,"near"]],n=["x","y","z"],i=new a.a.Material({shader:a.a.createShader("ecgl.color"),depthMask:!1,transparent:!0}),u=new a.a.Material({shader:a.a.createShader("ecgl.meshLines3D"),depthMask:!1,transparent:!0});i.define("fragment","DOUBLE_SIDED"),i.define("both","VERTEX_COLOR"),this.groupGL=new a.a.Node,this._control=new o.a({zr:t.getZr()}),this._control.init(),this._faces=r.map(function(e){var t=new c.a(e,u,i);return this.groupGL.add(t.rootNode),t},this),this._axes=n.map(function(e){var t=new d.a(e,u);return this.groupGL.add(t.rootNode),t},this);var p=t.getDevicePixelRatio();this._axisLabelSurface=new l.a({width:256,height:256,devicePixelRatio:p}),this._axisLabelSurface.onupdate=function(){t.getZr().refresh()},this._axisPointerLineMesh=new a.a.Mesh({geometry:new s.a({useNativeLine:!1}),material:u,castShadow:!1,ignorePicking:!0,renderOrder:3}),this.groupGL.add(this._axisPointerLineMesh),this._axisPointerLabelsSurface=new l.a({width:128,height:128,devicePixelRatio:p}),this._axisPointerLabelsMesh=new f.a({ignorePicking:!0,renderOrder:4,castShadow:!1}),this._axisPointerLabelsMesh.material.set("textureAtlas",this._axisPointerLabelsSurface.getTexture()),this.groupGL.add(this._axisPointerLabelsMesh),this._lightRoot=new a.a.Node,this._sceneHelper=new h.a,this._sceneHelper.initLight(this._lightRoot)},render:function(e,t,r){this._model=e,this._api=r;var n=e.coordinateSystem;n.viewGL.add(this._lightRoot),e.get("show")?n.viewGL.add(this.groupGL):n.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(n.viewGL);var a=e.getModel("viewControl");i.setFromViewControlModel(a,0),this._axisLabelSurface.clear(),i.off("update"),e.get("show")&&(this._faces.forEach(function(n){n.update(e,t,r)},this),this._axes.forEach(function(t){t.update(e,this._axisLabelSurface,r)},this)),i.on("update",this._onCameraChange.bind(this,e,r),this),this._sceneHelper.setScene(n.viewGL.scene),this._sceneHelper.updateLight(e),n.viewGL.setPostEffect(e.getModel("postEffect"),r),n.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._initMouseHandler(e)},afterRender:function(e,t,r,n){var i=n.renderer;this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r)},showAxisPointer:function(e,t,r,n){this._doShowAxisPointer(),this._updateAxisPointer(n.value)},hideAxisPointer:function(e,t,r,n){this._doHideAxisPointer()},_initMouseHandler:function(e){var t=e.coordinateSystem,r=t.viewGL;e.get("show")&&e.get("axisPointer.show")?r.on("mousemove",this._updateAxisPointerOnMousePosition,this):r.off("mousemove",this._updateAxisPointerOnMousePosition)},_updateAxisPointerOnMousePosition:function(e){if(!e.target){for(var t,r=this._model,n=r.coordinateSystem,i=n.viewGL,o=i.castRay(e.offsetX,e.offsetY,new a.a.Ray),s=0;sn[1]?0:1,s=this._faces[2*r+o],u=this._faces[2*r+1-o];s.rootNode.invisible=!0,u.rootNode.invisible=!1}},_updateAxisLinePosition:function(){var e=this._model.coordinateSystem,t=e.getAxis("x"),r=e.getAxis("y"),n=e.getAxis("z"),i=n.getExtentMax(),a=n.getExtentMin(),o=t.getExtentMin(),s=t.getExtentMax(),u=r.getExtentMax(),l=r.getExtentMin(),h=this._axes[0].rootNode,c=this._axes[1].rootNode,d=this._axes[2].rootNode,f=this._faces,p=f[4].rootNode.invisible?l:u,m=f[2].rootNode.invisible?i:a,g=f[0].rootNode.invisible?o:s,_=f[2].rootNode.invisible?i:a,v=f[0].rootNode.invisible?s:o,y=f[4].rootNode.invisible?l:u;h.rotation.identity(),c.rotation.identity(),d.rotation.identity(),f[4].rootNode.invisible&&(this._axes[0].flipped=!0,h.rotation.rotateX(Math.PI)),f[0].rootNode.invisible&&(this._axes[1].flipped=!0,c.rotation.rotateZ(Math.PI)),f[4].rootNode.invisible&&(this._axes[2].flipped=!0,d.rotation.rotateY(Math.PI)),h.position.set(0,m,p),c.position.set(g,_,0),d.position.set(v,0,y),h.update(),c.update(),d.update(),this._updateAxisLabelAlign()},_updateAxisLabelAlign:function(){var e=this._control.getCamera(),t=[new a.a.Vector4,new a.a.Vector4],r=new a.a.Vector4;this.groupGL.getWorldPosition(r),r.w=1,r.transformMat4(e.viewMatrix).transformMat4(e.projectionMatrix),r.x/=r.w,r.y/=r.w,this._axes.forEach(function(n){for(var i=n.axisLineCoords,a=(n.labelsMesh.geometry,0);ar.y?"bottom":"top"):(s="middle",o=h>r.x?"left":"right"),n.setSpriteAlign(o,s,this._api)},this)},_doShowAxisPointer:function(){this._axisPointerLineMesh.invisible&&(this._axisPointerLineMesh.invisible=!1,this._axisPointerLabelsMesh.invisible=!1,this._api.getZr().refresh())},_doHideAxisPointer:function(){this._axisPointerLineMesh.invisible||(this._axisPointerLineMesh.invisible=!0,this._axisPointerLabelsMesh.invisible=!0,this._api.getZr().refresh())},_updateAxisPointer:function(e){function t(e){return u.a.firstNotNull(e.model.get("axisPointer.show"),l.get("show"))}function r(e){var t=e.model.getModel("axisPointer",l),r=t.getModel("lineStyle"),n=a.a.parseColor(r.get("color")),i=m(r.get("width"),1),o=m(r.get("opacity"),1);return n[3]*=o,{color:n,lineWidth:i}}var n=this._model.coordinateSystem,i=n.dataToPoint(e),o=this._axisPointerLineMesh,s=o.geometry,l=this._model.getModel("axisPointer"),h=this._api.getDevicePixelRatio();s.convertToDynamicArray(!0);for(var c=0;c0&&e.rotation.rotateY(Math.PI),t.normal.z=-n)}function i(e,t,r){this.rootNode=new s.a.Node;var n=new s.a.Mesh({geometry:new l.a({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:1}),i=new s.a.Mesh({geometry:new h.a,material:r,castShadow:!1,culling:!1,ignorePicking:!0,$ignorePicking:!0,renderOrder:0});this.rootNode.add(i),this.rootNode.add(n),this.faceInfo=e,this.plane=new s.a.Plane,this.linesMesh=n,this.quadsMesh=i}var a=r(0),o=r.n(a),s=r(1),u=r(2),l=r(25),h=r(163),c=u.a.firstNotNull,d={x:0,y:2,z:1};i.prototype.update=function(e,t,r){var i=e.coordinateSystem,a=[i.getAxis(this.faceInfo[0]),i.getAxis(this.faceInfo[1])],o=this.linesMesh.geometry,s=this.quadsMesh.geometry;o.convertToDynamicArray(!0),s.convertToDynamicArray(!0),this._updateSplitLines(o,a,e,r),this._udpateSplitAreas(s,a,e,r),o.convertToTypedArray(),s.convertToTypedArray();var u=i.getAxis(this.faceInfo[2]);n(this.rootNode,this.plane,u,this.faceInfo[3])},i.prototype._updateSplitLines=function(e,t,r,n){var i=n.getDevicePixelRatio();t.forEach(function(n,a){var u=n.model,l=t[1-a].getExtent();if(!n.scale.isBlank()){var h=u.getModel("splitLine",r.getModel("splitLine"));if(h.get("show")){var d=h.getModel("lineStyle"),f=d.get("color"),p=c(d.get("opacity"),1),m=c(d.get("width"),1);f=o.a.util.isArray(f)?f:[f];for(var g=n.getTicksCoords({tickModel:h}),_=0,v=0;v65535?new Uint32Array(3*n):new Uint16Array(3*n))},getQuadVertexCount:function(){return 4},getQuadTriangleCount:function(){return 2},addQuad:function(){var e=u.create(),t=u.create(),r=u.create(),n=[0,3,1,3,2,1];return function(i,a){var o=this.attributes.position,s=this.attributes.normal,l=this.attributes.color;u.sub(e,i[1],i[0]),u.sub(t,i[2],i[1]),u.cross(r,e,t),u.normalize(r,r);for(var h=0;h<4;h++)o.set(this._vertexOffset+h,i[h]),l.set(this._vertexOffset+h,a),s.set(this._vertexOffset+h,r);for(var c=3*this._faceOffset,h=0;h<6;h++)this.indices[c+h]=n[h]+this._vertexOffset;this._vertexOffset+=4,this._faceOffset+=2}}()});a.a.util.defaults(l.prototype,o.a),t.a=l},function(e,t,r){"use strict";function n(e,t){var r=new o.a.Mesh({geometry:new s.a({useNativeLine:!1}),material:t,castShadow:!1,ignorePicking:!0,renderOrder:2}),n=new l.a;n.material.depthMask=!1;var i=new o.a.Node;i.add(r),i.add(n),this.rootNode=i,this.dim=e,this.linesMesh=r,this.labelsMesh=n,this.axisLineCoords=null,this.labelElements=[]}var i=r(0),a=r.n(i),o=r(1),s=r(25),u=r(2),l=r(63),h=u.a.firstNotNull,c={x:0,y:2,z:1},d={x:"y",y:"x",z:"y"};n.prototype.update=function(e,t,r){var n=e.coordinateSystem,i=n.getAxis(this.dim),s=this.linesMesh.geometry,u=this.labelsMesh.geometry;s.convertToDynamicArray(!0),u.convertToDynamicArray(!0);var l=i.model,f=i.getExtent(),p=r.getDevicePixelRatio(),m=l.getModel("axisLine",e.getModel("axisLine")),g=l.getModel("axisTick",e.getModel("axisTick")),_=l.getModel("axisLabel",e.getModel("axisLabel")),v=m.get("lineStyle.color");if(m.get("show")){var y=m.getModel("lineStyle"),x=[0,0,0],T=[0,0,0],b=c[i.dim];x[b]=f[0],T[b]=f[1],this.axisLineCoords=[x,T];var w=o.a.parseColor(v),E=h(y.get("width"),1),S=h(y.get("opacity"),1);w[3]*=S,s.addLine(x,T,w,E*p)}if(g.get("show")){var A=g.getModel("lineStyle"),M=o.a.parseColor(h(A.get("color"),v)),E=h(A.get("width"),1);M[3]*=h(A.get("opacity"),1);for(var C=i.getTicksCoords(),L=g.get("length"),D=0;D65535?new Uint32Array(3*r):new Uint16Array(3*r))},setSpriteAlign:function(e,t,r,n,i){null==r&&(r="left"),null==n&&(n="top");var a,o,s,u;switch(i=i||0,r){case"left":a=i,s=t[0]+i;break;case"center":case"middle":a=-t[0]/2,s=t[0]/2;break;case"right":a=-t[0]-i,s=-i}switch(n){case"bottom":o=i,u=t[1]+i;break;case"middle":o=-t[1]/2,u=t[1]/2;break;case"top":o=-t[1]-i,u=-i}var l=4*e,h=this.attributes.offset;h.set(l,[a,u]),h.set(l+1,[s,u]),h.set(l+2,[s,o]),h.set(l+3,[a,o])},addSprite:function(e,t,r,n,i,a){var o=this._vertexOffset;this.setSprite(this._vertexOffset/4,e,t,r,n,i,a);for(var u=0;u1?"."+e[1]:""))}function i(e,t){return e=(e||"").toLowerCase().replace(/-(.)/g,function(e,t){return t.toUpperCase()}),t&&e&&(e=e.charAt(0).toUpperCase()+e.slice(1)),e}function a(e){return null==e?"":(e+"").replace(g,function(e,t){return _[t]})}function o(e,t,r){d.isArray(t)||(t=[t]);var n=t.length;if(!n)return"";for(var i=t[0].$vars||[],o=0;o':'':""}function l(e,t){return e+="","0000".substr(0,t-e.length)+e}function h(e,t,r){"week"!==e&&"month"!==e&&"quarter"!==e&&"half-year"!==e&&"year"!==e||(e="MM-dd\nyyyy");var n=p.parseDate(t),i=r?"UTC":"",a=n["get"+i+"FullYear"](),o=n["get"+i+"Month"]()+1,s=n["get"+i+"Date"](),u=n["get"+i+"Hours"](),h=n["get"+i+"Minutes"](),c=n["get"+i+"Seconds"](),d=n["get"+i+"Milliseconds"]();return e=e.replace("MM",l(o,2)).replace("M",o).replace("yyyy",a).replace("yy",a%100).replace("dd",l(s,2)).replace("d",s).replace("hh",l(u,2)).replace("h",u).replace("mm",l(h,2)).replace("m",h).replace("ss",l(c,2)).replace("s",c).replace("SSS",l(d,3))}function c(e){return e?e.charAt(0).toUpperCase()+e.substr(1):e}var d=r(13),f=r(172),p=r(85),m=d.normalizeCssArray,g=/([&<>"'])/g,_={"&":"&","<":"<",">":">",'"':""","'":"'"},v=["a","b","c","d","e","f","g"],y=function(e,t){return"{"+e+(null==t?"":t)+"}"},x=f.truncateText,T=f.getBoundingRect;t.addCommas=n,t.toCamelCase=i,t.normalizeCssArray=m,t.encodeHTML=a,t.formatTpl=o,t.formatTplSimple=s,t.getTooltipMarker=u,t.formatTime=h,t.capitalFirst=c,t.truncateText=x,t.getTextRect=T},function(e,t,r){function n(e,t){I[e]=t}function i(e,t){t=t||P;var r=e+":"+t;if(L[r])return L[r];for(var n=(e+"").split("\n"),i=0,a=0,o=n.length;aN&&(D=0,L={}),D++,L[r]=i,i}function a(e,t,r,n,i,a,u){return a?s(e,t,r,n,i,a,u):o(e,t,r,n,i,u)}function o(e,t,r,n,a,o){var s=_(e,t,a,o),h=i(e,t);a&&(h+=a[1]+a[3]);var c=s.outerHeight,d=u(0,h,r),f=l(0,c,n),p=new T(d,f,h,c);return p.lineHeight=s.lineHeight,p}function s(e,t,r,n,i,a,o){var s=v(e,{rich:a,truncate:o,font:t,textAlign:r,textPadding:i}),h=s.outerWidth,c=s.outerHeight,d=u(0,h,r),f=l(0,c,n);return new T(d,f,h,c)}function u(e,t,r){return"right"===r?e-=t:"center"===r&&(e-=t/2),e}function l(e,t,r){return"middle"===r?e-=t/2:"bottom"===r&&(e-=t),e}function h(e,t,r){var n=t.x,i=t.y,a=t.height,o=t.width,s=a/2,u="left",l="top";switch(e){case"left":n-=r,i+=s,u="right",l="middle";break;case"right":n+=r+o,i+=s,l="middle";break;case"top":n+=o/2,i-=r,u="center",l="bottom";break;case"bottom":n+=o/2,i+=a+r,u="center";break;case"inside":n+=o/2,i+=s,u="center",l="middle";break;case"insideLeft":n+=r,i+=s,l="middle";break;case"insideRight":n+=o-r,i+=s,u="right",l="middle";break;case"insideTop":n+=o/2,i+=r,u="center";break;case"insideBottom":n+=o/2,i+=a-r,u="center",l="bottom";break;case"insideTopLeft":n+=r,i+=r;break;case"insideTopRight":n+=o-r,i+=r,u="right";break;case"insideBottomLeft":n+=r,i+=a-r,l="bottom";break;case"insideBottomRight":n+=o-r,i+=a-r,u="right",l="bottom"}return{x:n,y:i,textAlign:u,textVerticalAlign:l}}function c(e,t,r,n,i){if(!t)return"";var a=(e+"").split("\n");i=d(t,r,n,i);for(var o=0,s=a.length;o=o;u++)s-=o;var l=i(r);return l>s&&(r="",l=0),s=e-l,n.ellipsis=r,n.ellipsisWidth=l,n.contentWidth=s,n.containerWidth=e,n}function f(e,t){var r=t.containerWidth,n=t.font,a=t.contentWidth;if(!r)return"";var o=i(e,n);if(o<=r)return e;for(var s=0;;s++){if(o<=a||s>=t.maxIterations){e+=t.ellipsis;break}var u=0===s?p(e,a,t.ascCharWidth,t.cnCharWidth):o>0?Math.floor(e.length*a/o):0;e=e.substr(0,u),o=i(e,n)}return""===e&&(e=t.placeholder),e}function p(e,t,r,n){for(var i=0,a=0,o=e.length;au)e="",a=[];else if(null!=l)for(var h=d(l-(r?r[1]+r[3]:0),t,n.ellipsis,{minChar:n.minChar,placeholder:n.placeholder}),c=0,p=a.length;ca&&y(r,e.substring(a,o)),y(r,n[2],n[1]),a=R.lastIndex}ag)return{lines:[],width:0,height:0};E.textWidth=i(E.text,L);var N=S.textWidth,P=null==N||"auto"===N;if("string"==typeof N&&"%"===N.charAt(N.length-1))E.percentWidth=N,h.push(E),N=0;else{if(P){N=E.textWidth;var I=S.textBackgroundColor,O=I&&I.image;O&&(O=b.findExistImage(O),b.isImageReady(O)&&(N=Math.max(N,O.width*D/O.height)))}var F=C?C[1]+C[3]:0;N+=F;var B=null!=p?p-T:null;null!=B&&B4){console.warn("Support at most 4 cascade");continue}m.shadowCascade>1&&(s=m),this.renderDirectionalLightShadow(e,t,r,m,d,c,h)}else"SPOT_LIGHT"===m.type?this.renderSpotLightShadow(e,t,m,l,u):"POINT_LIGHT"===m.type&&this.renderPointLightShadow(e,t,m,f);this._shadowMapNumber[m.type]++}for(var g in this._shadowMapNumber)for(var _=this._shadowMapNumber[g],v=g+"_SHADOWMAP_COUNT",p=0;p0?x.define("fragment",v,_):x.isDefined("fragment",v)&&x.undefine("fragment",v))}for(var p=0;p0){var b=h.map(i);if(T.directionalLightShadowMaps={value:h,type:"tv"},T.directionalLightMatrices={value:c,type:"m4v"},T.directionalLightShadowMapSizes={value:b,type:"1fv"},s){var w=d.slice(),E=d.slice();w.pop(),E.shift(),w.reverse(),E.reverse(),c.reverse(),T.shadowCascadeClipsNear={value:w,type:"1fv"},T.shadowCascadeClipsFar={value:E,type:"1fv"}}}if(u.length>0){var S=u.map(i),T=t.shadowUniforms;T.spotLightShadowMaps={value:u,type:"tv"},T.spotLightMatrices={value:l,type:"m4v"},T.spotLightShadowMapSizes={value:S,type:"1fv"}}f.length>0&&(T.pointLightShadowMaps={value:f,type:"tv"})}},renderDirectionalLightShadow:function(){var e=new l.a,t=new h.a,r=new u.a,a=new h.a,o=new h.a,s=new h.a,d=new h.a;return function(u,l,f,p,m,g,_){var y=this._getDepthMaterial(p),x={getMaterial:function(e){return e.shadowDepthMaterial||y},isMaterialChanged:i,getUniform:n,ifRender:function(e){return e.castShadow},sortCompare:c.a.opaqueSortCompare};if(!l.viewBoundingBoxLastFrame.isFinite()){var T=l.getBoundingBox();l.viewBoundingBoxLastFrame.copy(T).applyTransform(f.viewMatrix)}var w=Math.min(-l.viewBoundingBoxLastFrame.min.z,f.far),E=Math.max(-l.viewBoundingBoxLastFrame.max.z,f.near),A=this._getDirectionalLightCamera(p,l,f),M=s.array;d.copy(A.projectionMatrix),b.a.invert(o.array,A.worldTransform.array),b.a.multiply(o.array,o.array,f.worldTransform.array),b.a.multiply(M,d.array,o.array);for(var C=[],L=f instanceof v.a,D=(f.near+f.far)/(f.near-f.far),N=2*f.near*f.far/(f.near-f.far),R=0;R<=p.shadowCascade;R++){var P=E*Math.pow(w/E,R/p.shadowCascade),I=E+(w-E)*R/p.shadowCascade,O=P*p.cascadeSplitLogFactor+I*(1-p.cascadeSplitLogFactor);C.push(O),m.push(-(-O*D+N)/-O)}var F=this._getTexture(p,p.shadowCascade);_.push(F);var B=u.viewport,U=u.gl;this._frameBuffer.attach(F),this._frameBuffer.bind(u),U.clear(U.COLOR_BUFFER_BIT|U.DEPTH_BUFFER_BIT);for(var R=0;Ru?s>l?v[i>0?"px":"nx"]=!0:v[o>0?"pz":"nz"]=!0:u>l?v[a>0?"py":"ny"]=!0:v[o>0?"pz":"nz"]=!0}for(var r=0;r=0||(this.nodes.push(e),this._dirty=!0)},removeNode:function(e){"string"==typeof e&&(e=this.getNodeByName(e));var t=this.nodes.indexOf(e);t>=0&&(this.nodes.splice(t,1),this._dirty=!0)},getNodeByName:function(e){for(var t=0;t=t.COLOR_ATTACHMENT0&&l<=t.COLOR_ATTACHMENT0+8&&c.push(l);h.drawBuffersEXT(c)}e.saveClear(),e.clearBit=i.a.DEPTH_BUFFER_BIT|i.a.COLOR_BUFFER_BIT,r=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),e.restoreClear(),n.unbind(e)}else r=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",r),this._rendering=!1,this._rendered=!0}});t.a=o},function(e,t,r){"use strict";var n=r(48),i=n.a.extend(function(){return{texture:null,outputs:{color:{}}}},function(){},{getOutput:function(e,t){return this.texture},beforeFrame:function(){},afterFrame:function(){}});t.a=i},function(e,t,r){"use strict";var n=r(16),i=r(48),a=i.a.extend(function(){return{name:"",inputs:{},outputs:null,shader:"",inputLinks:{},outputLinks:{},pass:null,_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}},function(){var e=new n.a({fragment:this.shader});this.pass=e},{render:function(e,t){this.trigger("beforerender",e),this._rendering=!0;var r=e.gl;for(var n in this.inputLinks){var i=this.inputLinks[n],a=i.node.getOutput(e,i.pin);this.pass.setUniform(n,a)}if(this.outputs){this.pass.outputs={};var o={};for(var s in this.outputs){var u=this.updateParameter(s,e);isNaN(u.width)&&this.updateParameter(s,e);var l=this.outputs[s],h=this._compositor.allocateTexture(u);this._outputTextures[s]=h;var c=l.attachment||r.COLOR_ATTACHMENT0;"string"==typeof c&&(c=r[c]),o[c]=h}this._compositor.getFrameBuffer().bind(e);for(var c in o)this._compositor.getFrameBuffer().attach(o[c],c);this.pass.render(e),this._compositor.getFrameBuffer().updateMipmap(e)}else this.pass.outputs=null,this._compositor.getFrameBuffer().unbind(e),this.pass.render(e,t);for(var n in this.inputLinks){var i=this.inputLinks[n];i.node.removeReference(i.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",e)},updateParameter:function(e,t){var r=this.outputs[e],n=r.parameters,i=r._parametersCopy;if(i||(i=r._parametersCopy={}),n)for(var a in n)"width"!==a&&"height"!==a&&(i[a]=n[a]);var o,s;return o=n.width instanceof Function?n.width.call(this,t):n.width,s=n.height instanceof Function?n.height.call(this,t):n.height,o=Math.ceil(o),s=Math.ceil(s),i.width===o&&i.height===s||this._outputTextures[e]&&this._outputTextures[e].dispose(t),i.width=o,i.height=s,i},setParameter:function(e,t){this.pass.setUniform(e,t)},getParameter:function(e){return this.pass.getUniform(e)},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},define:function(e,t){this.pass.material.define("fragment",e,t)},undefine:function(e){this.pass.material.undefine("fragment",e)},removeReference:function(e){if(0===--this._outputReferences[e]){this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}},clear:function(){i.a.prototype.clear.call(this),this.pass.material.disableTexturesAll()}});t.a=a},function(e,t,r){"use strict";function n(e){e.import(i.a),e.import(a.a),e.import(o.a),e.import(s.a),e.import(u.a),e.import(l.a),e.import(h.a),e.import(c.a),e.import(d.a),e.import(f.a),e.import(p.a),e.import(m.a),e.import(g.a)}t.a=n;var i=r(185),a=r(87),o=r(186),s=r(88),u=r(187),l=r(89),h=r(90),c=r(91),d=r(92),f=r(93),p=r(188),m=r(94),g=r(95)},function(e,t,r){"use strict";t.a="@export clay.compositor.coloradjust\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float exposure : 0.0;\nuniform float gamma : 1.0;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = clamp(tex.rgb + vec3(brightness), 0.0, 1.0);\n color = clamp( (color-vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n color = clamp( color * pow(2.0, exposure), 0.0, 1.0);\n color = clamp( pow(color, vec3(gamma)), 0.0, 1.0);\n float luminance = dot( color, w );\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.brightness\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = tex.rgb + vec3(brightness);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.contrast\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float contrast : 1.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = (tex.rgb-vec3(0.5))*contrast+vec3(0.5);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.exposure\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float exposure : 0.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb * pow(2.0, exposure);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.gamma\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float gamma : 1.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = pow(tex.rgb, vec3(gamma));\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.saturation\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb;\n float luminance = dot(color, w);\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end"},function(e,t,r){"use strict";t.a="@export clay.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n float luminance = dot(tex.rgb, w);\n luminance = log(luminance + 0.001);\n gl_FragColor = encodeHDR(vec4(vec3(luminance), 1.0));\n}\n@end\n@export clay.compositor.hdr.lum_adaption\nvarying vec2 v_Texcoord;\nuniform sampler2D adaptedLum;\nuniform sampler2D currentLum;\nuniform float frameTime : 0.02;\n@import clay.util.rgbm\nvoid main()\n{\n float fAdaptedLum = decodeHDR(texture2D(adaptedLum, vec2(0.5, 0.5))).r;\n float fCurrentLum = exp(encodeHDR(texture2D(currentLum, vec2(0.5, 0.5))).r);\n fAdaptedLum += (fCurrentLum - fAdaptedLum) * (1.0 - pow(0.98, 30.0 * frameTime));\n gl_FragColor = encodeHDR(vec4(vec3(fAdaptedLum), 1.0));\n}\n@end\n@export clay.compositor.lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord );\n float luminance = dot(tex.rgb, w);\n gl_FragColor = vec4(vec3(luminance), 1.0);\n}\n@end"},function(e,t,r){"use strict";t.a="@export clay.compositor.vignette\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float darkness: 1;\nuniform float offset: 1;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = texel.rgb;\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(offset);\n gl_FragColor = encodeHDR(vec4(mix(texel.rgb, vec3(1.0 - darkness), dot(uv, uv)), texel.a));\n}\n@end"},function(e,t,r){"use strict";t.a="@export clay.compositor.lensflare\n#define SAMPLE_NUMBER 8\nuniform sampler2D texture;\nuniform sampler2D lenscolor;\nuniform vec2 textureSize : [512, 512];\nuniform float dispersal : 0.3;\nuniform float haloWidth : 0.4;\nuniform float distortion : 1.0;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvec4 textureDistorted(\n in vec2 texcoord,\n in vec2 direction,\n in vec3 distortion\n) {\n return vec4(\n decodeHDR(texture2D(texture, texcoord + direction * distortion.r)).r,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.g)).g,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.b)).b,\n 1.0\n );\n}\nvoid main()\n{\n vec2 texcoord = -v_Texcoord + vec2(1.0); vec2 textureOffset = 1.0 / textureSize;\n vec2 ghostVec = (vec2(0.5) - texcoord) * dispersal;\n vec2 haloVec = normalize(ghostVec) * haloWidth;\n vec3 distortion = vec3(-textureOffset.x * distortion, 0.0, textureOffset.x * distortion);\n vec4 result = vec4(0.0);\n for (int i = 0; i < SAMPLE_NUMBER; i++)\n {\n vec2 offset = fract(texcoord + ghostVec * float(i));\n float weight = length(vec2(0.5) - offset) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n }\n result *= texture2D(lenscolor, vec2(length(vec2(0.5) - texcoord)) / length(vec2(0.5)));\n float weight = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n vec2 offset = fract(texcoord + haloVec);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n gl_FragColor = result;\n}\n@end"},function(e,t,r){"use strict";function n(e){for(var t=new Uint8Array(e*e*4),r=0,n=new u.a,i=0;i=1?.95:0,weight2:n>=1?.05:1}),p.render(e)),h.attach(u),d.setUniform("texture",this._physicallyCorrect?this._currentTexture:s),d.render(e),h.attach(l),f.setUniform("texture",u),f.render(e),h.unbind(e),this._physicallyCorrect){var v=this._prevTexture;this._prevTexture=this._currentTexture,this._currentTexture=v}},n.prototype.getTargetTexture=function(){return this._texture3},n.prototype.setParameter=function(e,t){"maxIteration"===e?this._ssrPass.material.define("fragment","MAX_ITERATION",t):this._ssrPass.setUniform(e,t)},n.prototype.setPhysicallyCorrect=function(e){e?(this._normalDistribution||(this._normalDistribution=h.a.generateNormalDistribution(64,this._totalSamples)),this._ssrPass.material.define("fragment","PHYSICALLY_CORRECT"),this._ssrPass.material.set("normalDistribution",this._normalDistribution),this._ssrPass.material.set("normalDistributionSize",[64,this._totalSamples])):this._ssrPass.material.undefine("fragment","PHYSICALLY_CORRECT"),this._physicallyCorrect=e},n.prototype.setSSAOTexture=function(e){var t=this._blurPass2;e?(t.material.enableTexture("ssaoTex"),t.material.set("ssaoTex",e)):t.material.disableTexture("ssaoTex")},n.prototype.isFinished=function(e){return!this._physicallyCorrect||e>this._totalSamples/this._samplePerFrame},n.prototype.dispose=function(e){this._ssrTexture.dispose(e),this._texture2.dispose(e),this._texture3.dispose(e),this._prevTexture.dispose(e),this._currentTexture.dispose(e),this._frameBuffer.dispose(e)},t.a=n},function(e,t,r){"use strict";t.a="@export ecgl.ssr.main\n\n#define SHADER_NAME SSR\n#define MAX_ITERATION 20;\n#define SAMPLE_PER_FRAME 5;\n#define TOTAL_SAMPLES 128;\n\nuniform sampler2D sourceTexture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform sampler2D gBufferTexture3;\nuniform samplerCube specularCubemap;\nuniform float specularIntensity: 1;\n\nuniform mat4 projection;\nuniform mat4 projectionInv;\nuniform mat4 toViewSpace;\nuniform mat4 toWorldSpace;\n\nuniform float maxRayDistance: 200;\n\nuniform float pixelStride: 16;\nuniform float pixelStrideZCutoff: 50; \nuniform float screenEdgeFadeStart: 0.9; \nuniform float eyeFadeStart : 0.2; uniform float eyeFadeEnd: 0.8; \nuniform float minGlossiness: 0.2; uniform float zThicknessThreshold: 1;\n\nuniform float nearZ;\nuniform vec2 viewportSize : VIEWPORT_SIZE;\n\nuniform float jitterOffset: 0;\n\nvarying vec2 v_Texcoord;\n\n#ifdef DEPTH_DECODE\n@import clay.util.decode_float\n#endif\n\n#ifdef PHYSICALLY_CORRECT\nuniform sampler2D normalDistribution;\nuniform float sampleOffset: 0;\nuniform vec2 normalDistributionSize;\n\nvec3 transformNormal(vec3 H, vec3 N) {\n vec3 upVector = N.y > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvec3 importanceSampleNormalGGX(float i, float roughness, vec3 N) {\n float p = fract((i + sampleOffset) / float(TOTAL_SAMPLES));\n vec3 H = texture2D(normalDistribution,vec2(roughness, p)).rgb;\n return transformNormal(H, N);\n}\nfloat G_Smith(float g, float ndv, float ndl) {\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n#endif\n\nfloat fetchDepth(sampler2D depthTexture, vec2 uv)\n{\n vec4 depthTexel = texture2D(depthTexture, uv);\n return depthTexel.r * 2.0 - 1.0;\n}\n\nfloat linearDepth(float depth)\n{\n if (projection[3][3] == 0.0) {\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n }\n else {\n return (depth - projection[3][2]) / projection[2][2];\n }\n}\n\nbool rayIntersectDepth(float rayZNear, float rayZFar, vec2 hitPixel)\n{\n if (rayZFar > rayZNear)\n {\n float t = rayZFar; rayZFar = rayZNear; rayZNear = t;\n }\n float cameraZ = linearDepth(fetchDepth(gBufferTexture2, hitPixel));\n return rayZFar <= cameraZ && rayZNear >= cameraZ - zThicknessThreshold;\n}\n\n\nbool traceScreenSpaceRay(\n vec3 rayOrigin, vec3 rayDir, float jitter,\n out vec2 hitPixel, out vec3 hitPoint, out float iterationCount\n)\n{\n float rayLength = ((rayOrigin.z + rayDir.z * maxRayDistance) > -nearZ)\n ? (-nearZ - rayOrigin.z) / rayDir.z : maxRayDistance;\n\n vec3 rayEnd = rayOrigin + rayDir * rayLength;\n\n vec4 H0 = projection * vec4(rayOrigin, 1.0);\n vec4 H1 = projection * vec4(rayEnd, 1.0);\n\n float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\n\n vec3 Q0 = rayOrigin * k0, Q1 = rayEnd * k1;\n\n vec2 P0 = (H0.xy * k0 * 0.5 + 0.5) * viewportSize;\n vec2 P1 = (H1.xy * k1 * 0.5 + 0.5) * viewportSize;\n\n P1 += dot(P1 - P0, P1 - P0) < 0.0001 ? 0.01 : 0.0;\n vec2 delta = P1 - P0;\n\n bool permute = false;\n if (abs(delta.x) < abs(delta.y)) {\n permute = true;\n delta = delta.yx;\n P0 = P0.yx;\n P1 = P1.yx;\n }\n float stepDir = sign(delta.x);\n float invdx = stepDir / delta.x;\n\n vec3 dQ = (Q1 - Q0) * invdx;\n float dk = (k1 - k0) * invdx;\n\n vec2 dP = vec2(stepDir, delta.y * invdx);\n\n float strideScaler = 1.0 - min(1.0, -rayOrigin.z / pixelStrideZCutoff);\n float pixStride = 1.0 + strideScaler * pixelStride;\n\n dP *= pixStride; dQ *= pixStride; dk *= pixStride;\n\n vec4 pqk = vec4(P0, Q0.z, k0);\n vec4 dPQK = vec4(dP, dQ.z, dk);\n\n pqk += dPQK * jitter;\n float rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n float rayZNear;\n\n bool intersect = false;\n\n vec2 texelSize = 1.0 / viewportSize;\n\n iterationCount = 0.0;\n\n for (int i = 0; i < MAX_ITERATION; i++)\n {\n pqk += dPQK;\n\n rayZNear = rayZFar;\n rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n\n hitPixel = permute ? pqk.yx : pqk.xy;\n hitPixel *= texelSize;\n\n intersect = rayIntersectDepth(rayZNear, rayZFar, hitPixel);\n\n iterationCount += 1.0;\n\n dPQK *= 1.2;\n\n if (intersect) {\n break;\n }\n }\n\n Q0.xy += dQ.xy * iterationCount;\n Q0.z = pqk.z;\n hitPoint = Q0 / pqk.w;\n\n return intersect;\n}\n\nfloat calculateAlpha(\n float iterationCount, float reflectivity,\n vec2 hitPixel, vec3 hitPoint, float dist, vec3 rayDir\n)\n{\n float alpha = clamp(reflectivity, 0.0, 1.0);\n alpha *= 1.0 - (iterationCount / float(MAX_ITERATION));\n vec2 hitPixelNDC = hitPixel * 2.0 - 1.0;\n float maxDimension = min(1.0, max(abs(hitPixelNDC.x), abs(hitPixelNDC.y)));\n alpha *= 1.0 - max(0.0, maxDimension - screenEdgeFadeStart) / (1.0 - screenEdgeFadeStart);\n\n float _eyeFadeStart = eyeFadeStart;\n float _eyeFadeEnd = eyeFadeEnd;\n if (_eyeFadeStart > _eyeFadeEnd) {\n float tmp = _eyeFadeEnd;\n _eyeFadeEnd = _eyeFadeStart;\n _eyeFadeStart = tmp;\n }\n\n float eyeDir = clamp(rayDir.z, _eyeFadeStart, _eyeFadeEnd);\n alpha *= 1.0 - (eyeDir - _eyeFadeStart) / (_eyeFadeEnd - _eyeFadeStart);\n\n alpha *= 1.0 - clamp(dist / maxRayDistance, 0.0, 1.0);\n\n return alpha;\n}\n\n@import clay.util.rand\n\n@import clay.util.rgbm\n\nvoid main()\n{\n vec4 normalAndGloss = texture2D(gBufferTexture1, v_Texcoord);\n\n if (dot(normalAndGloss.rgb, vec3(1.0)) == 0.0) {\n discard;\n }\n\n float g = normalAndGloss.a;\n#if !defined(PHYSICALLY_CORRECT)\n if (g <= minGlossiness) {\n discard;\n }\n#endif\n\n float reflectivity = (g - minGlossiness) / (1.0 - minGlossiness);\n\n vec3 N = normalize(normalAndGloss.rgb * 2.0 - 1.0);\n N = normalize((toViewSpace * vec4(N, 0.0)).xyz);\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, fetchDepth(gBufferTexture2, v_Texcoord), 1.0);\n vec4 pos = projectionInv * projectedPos;\n vec3 rayOrigin = pos.xyz / pos.w;\n vec3 V = -normalize(rayOrigin);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n float iterationCount;\n float jitter = rand(fract(v_Texcoord + jitterOffset));\n\n#ifdef PHYSICALLY_CORRECT\n vec4 color = vec4(vec3(0.0), 1.0);\n vec4 albedoMetalness = texture2D(gBufferTexture3, v_Texcoord);\n vec3 albedo = albedoMetalness.rgb;\n float m = albedoMetalness.a;\n vec3 diffuseColor = albedo * (1.0 - m);\n vec3 spec = mix(vec3(0.04), albedo, m);\n\n float jitter2 = rand(fract(v_Texcoord)) * float(TOTAL_SAMPLES);\n\n for (int i = 0; i < SAMPLE_PER_FRAME; i++) {\n vec3 H = importanceSampleNormalGGX(float(i) + jitter2, 1.0 - g, N);\n vec3 rayDir = normalize(reflect(-V, H));\n#else\n vec3 rayDir = normalize(reflect(-V, N));\n#endif\n vec2 hitPixel;\n vec3 hitPoint;\n\n bool intersect = traceScreenSpaceRay(rayOrigin, rayDir, jitter, hitPixel, hitPoint, iterationCount);\n\n float dist = distance(rayOrigin, hitPoint);\n\n vec3 hitNormal = texture2D(gBufferTexture1, hitPixel).rgb * 2.0 - 1.0;\n hitNormal = normalize((toViewSpace * vec4(hitNormal, 0.0)).xyz);\n#ifdef PHYSICALLY_CORRECT\n float ndl = clamp(dot(N, rayDir), 0.0, 1.0);\n float vdh = clamp(dot(V, H), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n vec3 litTexel = vec3(0.0);\n if (dot(hitNormal, rayDir) < 0.0 && intersect) {\n litTexel = texture2D(sourceTexture, hitPixel).rgb;\n litTexel *= pow(clamp(1.0 - dist / 200.0, 0.0, 1.0), 3.0);\n\n }\n else {\n #ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n litTexel = RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, 0.0), 8.12).rgb * specularIntensity;\n#endif\n }\n color.rgb += ndl * litTexel * (\n F_Schlick(ndl, spec) * G_Smith(g, ndv, ndl) * vdh / (ndh * ndv + 0.001)\n );\n }\n color.rgb /= float(SAMPLE_PER_FRAME);\n#else\n #if !defined(SPECULARCUBEMAP_ENABLED)\n if (dot(hitNormal, rayDir) >= 0.0) {\n discard;\n }\n if (!intersect) {\n discard;\n }\n#endif\n float alpha = clamp(calculateAlpha(iterationCount, reflectivity, hitPixel, hitPoint, dist, rayDir), 0.0, 1.0);\n vec4 color = texture2D(sourceTexture, hitPixel);\n color.rgb *= alpha;\n\n#ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n alpha = alpha * (intersect ? 1.0 : 0.0);\n float bias = (1.0 -g) * 5.0;\n color.rgb += (1.0 - alpha)\n * RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, bias), 8.12).rgb\n * specularIntensity;\n#endif\n\n#endif\n\n gl_FragColor = encodeHDR(color);\n}\n@end\n\n@export ecgl.ssr.blur\n\nuniform sampler2D texture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform mat4 projection;\nuniform float depthRange : 0.05;\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\n#ifdef BLEND\n #ifdef SSAOTEX_ENABLED\nuniform sampler2D ssaoTex;\n #endif\nuniform sampler2D sourceTexture;\n#endif\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(gBufferTexture2, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n\n@import clay.util.rgbm\n\n\nvoid main()\n{\n @import clay.compositor.kernel.gaussian_9\n\n vec4 centerNTexel = texture2D(gBufferTexture1, v_Texcoord);\n float g = centerNTexel.a;\n float maxBlurSize = clamp(1.0 - g, 0.0, 1.0) * blurSize;\n#ifdef VERTICAL\n vec2 off = vec2(0.0, maxBlurSize / textureSize.y);\n#else\n vec2 off = vec2(maxBlurSize / textureSize.x, 0.0);\n#endif\n\n vec2 coord = v_Texcoord;\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\n vec3 cN = centerNTexel.rgb * 2.0 - 1.0;\n float cD = getLinearDepth(v_Texcoord);\n for (int i = 0; i < 9; i++) {\n vec2 coord = clamp((float(i) - 4.0) * off + v_Texcoord, vec2(0.0), vec2(1.0));\n float w = gaussianKernel[i]\n * clamp(dot(cN, texture2D(gBufferTexture1, coord).rgb * 2.0 - 1.0), 0.0, 1.0);\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(cD - d) / depthRange, 0.0, 1.0));\n\n weightAll += w;\n sum += decodeHDR(texture2D(texture, coord)) * w;\n }\n\n#ifdef BLEND\n float aoFactor = 1.0;\n #ifdef SSAOTEX_ENABLED\n aoFactor = texture2D(ssaoTex, v_Texcoord).r;\n #endif\n gl_FragColor = encodeHDR(\n sum / weightAll * aoFactor + decodeHDR(texture2D(sourceTexture, v_Texcoord))\n );\n#else\n gl_FragColor = encodeHDR(sum / weightAll);\n#endif\n}\n\n@end"},function(e,t,r){"use strict";t.a=[0,0,-.321585265978,-.154972575841,.458126042375,.188473391593,.842080129861,.527766490688,.147304551086,-.659453822776,-.331943915203,-.940619700594,.0479226680259,.54812163202,.701581552186,-.709825561388,-.295436780218,.940589268233,-.901489676764,.237713156085,.973570876096,-.109899459384,-.866792314779,-.451805525005,.330975007087,.800048655954,-.344275183665,.381779221166,-.386139432542,-.437418421534,-.576478634965,-.0148463392551,.385798197415,-.262426961053,-.666302061145,.682427250835,-.628010632582,-.732836215494,.10163141741,-.987658134403,.711995289051,-.320024291314,.0296005138058,.950296523438,.0130612307608,-.351024443122,-.879596633704,-.10478487883,.435712737232,.504254490347,.779203817497,.206477676721,.388264289969,-.896736162545,-.153106280781,-.629203242522,-.245517550697,.657969239148,.126830499058,.26862328493,-.634888119007,-.302301223431,.617074219636,.779817204925]},function(e,t,r){"use strict";function n(e,t,r,n,i){var a=e.gl;t.setUniform(a,"1i",r,i),a.activeTexture(a.TEXTURE0+i),n.isRenderable()?n.bind(e):n.unbind(e)}function i(e,t,r,i,a){var o,s,u,l,h=e.gl;return function(a,c,d){if(!l||l.material!==a.material){var f=a.material,p=a.__program,m=f.get("roughness");null==m&&(m=1);var g=f.get("normalMap")||t,_=f.get("roughnessMap"),v=f.get("bumpMap"),y=f.get("uvRepeat"),x=f.get("uvOffset"),T=f.get("detailUvRepeat"),b=f.get("detailUvOffset"),w=!!v&&f.isTextureEnabled("bumpMap"),E=!!_&&f.isTextureEnabled("roughnessMap"),S=f.isDefined("fragment","DOUBLE_SIDED");v=v||r,_=_||i,d!==c?(c.set("normalMap",g),c.set("bumpMap",v),c.set("roughnessMap",_),c.set("useBumpMap",w),c.set("useRoughnessMap",E),c.set("doubleSide",S),null!=y&&c.set("uvRepeat",y),null!=x&&c.set("uvOffset",x),null!=T&&c.set("detailUvRepeat",T),null!=b&&c.set("detailUvOffset",b),c.set("roughness",m)):(p.setUniform(h,"1f","roughness",m),o!==g&&n(e,p,"normalMap",g,0),s!==v&&v&&n(e,p,"bumpMap",v,1),u!==_&&_&&n(e,p,"roughnessMap",_,2),null!=y&&p.setUniform(h,"2f","uvRepeat",y),null!=x&&p.setUniform(h,"2f","uvOffset",x),null!=T&&p.setUniform(h,"2f","detailUvRepeat",T),null!=b&&p.setUniform(h,"2f","detailUvOffset",b),p.setUniform(h,"1i","useBumpMap",+w),p.setUniform(h,"1i","useRoughnessMap",+E),p.setUniform(h,"1i","doubleSide",+S)),o=g,s=v,u=_,l=a}}}function a(e){e=e||{},this._depthTex=new o.a({format:s.a.DEPTH_COMPONENT,type:s.a.UNSIGNED_INT}),this._normalTex=new o.a({type:s.a.HALF_FLOAT}),this._framebuffer=new l.a,this._framebuffer.attach(this._normalTex),this._framebuffer.attach(this._depthTex,l.a.DEPTH_ATTACHMENT),this._normalMaterial=new h.a({shader:new u.a(u.a.source("ecgl.normal.vertex"),u.a.source("ecgl.normal.fragment"))}),this._normalMaterial.enableTexture(["normalMap","bumpMap","roughnessMap"]),this._defaultNormalMap=d.a.createBlank("#000"),this._defaultBumpMap=d.a.createBlank("#000"),this._defaultRoughessMap=d.a.createBlank("#000"),this._debugPass=new c.a({fragment:u.a.source("clay.compositor.output")}),this._debugPass.setUniform("texture",this._normalTex),this._debugPass.material.undefine("fragment","OUTPUT_ALPHA")}var o=r(5),s=r(4),u=r(8),l=r(10),h=r(19),c=r(16),d=r(61),f=r(195);u.a.import(f.a),a.prototype.getDepthTexture=function(){return this._depthTex},a.prototype.getNormalTexture=function(){return this._normalTex},a.prototype.update=function(e,t,r){var n=e.getWidth(),a=e.getHeight(),o=this._depthTex,s=this._normalTex,u=this._normalMaterial;o.width=n,o.height=a,s.width=n,s.height=a;var l=t.getRenderList(r).opaque;this._framebuffer.bind(e),e.gl.clearColor(0,0,0,0),e.gl.clear(e.gl.COLOR_BUFFER_BIT|e.gl.DEPTH_BUFFER_BIT),e.gl.disable(e.gl.BLEND),e.renderPass(l,r,{getMaterial:function(){return u},ifRender:function(e){return e.renderNormal},beforeRender:i(e,this._defaultNormalMap,this._defaultBumpMap,this._defaultRoughessMap,this._normalMaterial),sort:e.opaqueSortCompare}),this._framebuffer.unbind(e)},a.prototype.renderDebug=function(e){this._debugPass.render(e)},a.prototype.dispose=function(e){this._depthTex.dispose(e),this._normalTex.dispose(e)},t.a=a},function(e,t,r){"use strict";t.a="@export ecgl.normal.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n@import ecgl.common.normalMap.vertexHeader\n\n@import ecgl.common.vertexAnimation.header\n\nvoid main()\n{\n\n @import ecgl.common.vertexAnimation.main\n\n @import ecgl.common.uv.main\n\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n @import ecgl.common.normalMap.vertexMain\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n}\n\n\n@end\n\n\n@export ecgl.normal.fragment\n\n#define ROUGHNESS_CHANEL 0\n\nuniform bool useBumpMap;\nuniform bool useRoughnessMap;\nuniform bool doubleSide;\nuniform float roughness;\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n@import ecgl.common.normalMap.fragmentHeader\n@import ecgl.common.bumpMap.header\n\nuniform sampler2D roughnessMap;\n\nvoid main()\n{\n vec3 N = v_Normal;\n \n bool flipNormal = false;\n if (doubleSide) {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n flipNormal = true;\n }\n }\n\n @import ecgl.common.normalMap.fragmentMain\n\n if (useBumpMap) {\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n }\n\n float g = 1.0 - roughness;\n\n if (useRoughnessMap) {\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n }\n\n if (flipNormal) {\n N = -N;\n }\n\n gl_FragColor.rgb = (N.xyz + 1.0) * 0.5;\n gl_FragColor.a = g;\n}\n@end"},function(e,t,r){"use strict";function n(e){e=e||{},this._edgePass=new o.a({fragment:s.a.source("ecgl.edge")}),this._edgePass.setUniform("normalTexture",e.normalTexture),this._edgePass.setUniform("depthTexture",e.depthTexture),this._targetTexture=new i.a({type:a.a.HALF_FLOAT}),this._frameBuffer=new u.a,this._frameBuffer.attach(this._targetTexture)}var i=(r(9),r(3),r(5)),a=r(4),o=r(16),s=r(8),u=r(10);n.prototype.update=function(e,t,r,n){var i=e.getWidth(),a=e.getHeight(),o=this._targetTexture;o.width=i,o.height=a;var s=this._frameBuffer;s.bind(e),this._edgePass.setUniform("projectionInv",t.invProjectionMatrix.array),this._edgePass.setUniform("textureSize",[i,a]),this._edgePass.setUniform("texture",r),this._edgePass.render(e),s.unbind(e)},n.prototype.getTargetTexture=function(){return this._targetTexture},n.prototype.setParameter=function(e,t){this._edgePass.setUniform(e,t)},n.prototype.dispose=function(e){this._targetTexture.dispose(e),this._frameBuffer.dispose(e)},t.a=n},function(e,t,r){"use strict";t.a={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(clay.compositor.downsample)",inputs:{texture:"source"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bright",shader:"#source(clay.compositor.bright)",inputs:{texture:"source_half"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{threshold:2,scale:4,textureSize:"expr([width * 1.0 / 2, height / 2])"}},{name:"bright_downsample_4",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 2, height / 2] )"}},{name:"bright_downsample_8",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 4, height / 4] )"}},{name:"bright_downsample_16",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 8, height / 8] )"}},{name:"bright_downsample_32",shader:"#source(clay.compositor.downsample)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 32)",height:"expr(height * 1.0 / 32)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 16, height / 16] )"}},{name:"bright_upsample_16_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_32"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 32, height / 32] )"}},{name:"bright_upsample_16_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_16_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_8_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_8_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_8_blur_v",texture2:"bright_upsample_16_blur_v"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_4_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_4_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_4_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_4_blur_v",texture2:"bright_upsample_8_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_2_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_2_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_2_blend",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_2_blur_v",texture2:"bright_upsample_4_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_full_blur_h",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_full_blur_v",shader:"#source(clay.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_full_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bloom_composite",shader:"#source(clay.compositor.blend)",inputs:{texture1:"bright_upsample_full_blur_v",texture2:"bright_upsample_2_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"coc",shader:"#source(ecgl.dof.coc)",outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{focalDist:50,focalRange:30}},{name:"dof_far_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"dof_near_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_NEARFIELD:null}},{name:"dof_coc_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"coc"},outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_COC:null}},{name:"dof_composite",shader:"#source(ecgl.dof.composite)",inputs:{original:"source",blurred:"dof_far_blur",nearfield:"dof_near_blur",coc:"coc",nearcoc:"dof_coc_blur"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}}},{name:"composite",shader:"#source(clay.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},defines:{}},{name:"FXAA",shader:"#source(clay.compositor.fxaa)",inputs:{texture:"composite"}}]}},function(e,t,r){"use strict";t.a="@export ecgl.dof.coc\n\nuniform sampler2D depth;\n\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\n\nuniform float focalDistance: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\n\nvarying vec2 v_Texcoord;\n\n@import clay.util.encode_float\n\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n\n float aperture = focalLength / fstop;\n\n float coc;\n\n float uppper = focalDistance + focalRange;\n float lower = focalDistance - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 2.0) / 2.00001;\n\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n\n gl_FragColor = encodeFloat(coc);\n}\n@end\n\n\n@export ecgl.dof.composite\n\n#define DEBUG 0\n\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n\n@import clay.util.rgbm\n@import clay.util.float\n\nvoid main()\n{\n vec4 blurredColor = texture2D(blurred, v_Texcoord);\n vec4 originalColor = texture2D(original, v_Texcoord);\n\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n\n fCoc = abs(fCoc * 2.0 - 1.0);\n\n float weight = smoothstep(0.0, 1.0, fCoc);\n \n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = texture2D(nearfield, v_Texcoord);\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n\n}\n\n@end\n\n\n\n@export ecgl.dof.diskBlur\n\n#define POISSON_KERNEL_SIZE 16;\n\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n\nuniform float blurRadius : 10.0;\nuniform vec2 textureSize : [512.0, 512.0];\n\nuniform vec2 poissonKernel[POISSON_KERNEL_SIZE];\n\nuniform float percent;\n\nfloat nrand(const in vec2 n) {\n return fract(sin(dot(n.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\n@import clay.util.rgbm\n@import clay.util.float\n\n\nvoid main()\n{\n vec2 offset = blurRadius / textureSize;\n\n float rnd = 6.28318 * nrand(v_Texcoord + 0.07 * percent );\n float cosa = cos(rnd);\n float sina = sin(rnd);\n vec4 basis = vec4(cosa, -sina, sina, cosa);\n\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n\n\n float weightSum = 0.0;\n\n for (int i = 0; i < POISSON_KERNEL_SIZE; i++) {\n vec2 ofs = poissonKernel[i];\n\n ofs = vec2(dot(ofs, basis.xy), dot(ofs, basis.zw));\n\n vec2 uv = v_Texcoord + ofs * offset;\n vec4 texel = texture2D(texture, uv);\n\n float w = 1.0;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texel) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n texel = texel;\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\n texel.rgb *= texel.a;\n color += texel * w;\n#endif\n\n weightSum += w;\n }\n\n#ifdef BLUR_COC\n gl_FragColor = encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n color /= weightSum;\n color.rgb /= (color.a + 0.0001);\n gl_FragColor = color;\n#endif\n}\n\n@end"},function(e,t,r){"use strict";t.a="@export ecgl.edge\n\nuniform sampler2D texture;\n\nuniform sampler2D normalTexture;\nuniform sampler2D depthTexture;\n\nuniform mat4 projectionInv;\n\nuniform vec2 textureSize;\n\nuniform vec4 edgeColor: [0,0,0,0.8];\n\nvarying vec2 v_Texcoord;\n\nvec3 packColor(vec2 coord) {\n float z = texture2D(depthTexture, coord).r * 2.0 - 1.0;\n vec4 p = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * p;\n\n return vec3(\n texture2D(normalTexture, coord).rg,\n -p4.z / p4.w / 5.0\n );\n}\n\nvoid main() {\n vec2 cc = v_Texcoord;\n vec3 center = packColor(cc);\n\n float size = clamp(1.0 - (center.z - 10.0) / 100.0, 0.0, 1.0) * 0.5;\n float dx = size / textureSize.x;\n float dy = size / textureSize.y;\n\n vec2 coord;\n vec3 topLeft = packColor(cc+vec2(-dx, -dy));\n vec3 top = packColor(cc+vec2(0.0, -dy));\n vec3 topRight = packColor(cc+vec2(dx, -dy));\n vec3 left = packColor(cc+vec2(-dx, 0.0));\n vec3 right = packColor(cc+vec2(dx, 0.0));\n vec3 bottomLeft = packColor(cc+vec2(-dx, dy));\n vec3 bottom = packColor(cc+vec2(0.0, dy));\n vec3 bottomRight = packColor(cc+vec2(dx, dy));\n\n vec3 v = -topLeft-2.0*top-topRight+bottomLeft+2.0*bottom+bottomRight;\n vec3 h = -bottomLeft-2.0*left-topLeft+bottomRight+2.0*right+topRight;\n\n float edge = sqrt(dot(h, h) + dot(v, v));\n\n edge = smoothstep(0.8, 1.0, edge);\n\n gl_FragColor = mix(texture2D(texture, v_Texcoord), vec4(edgeColor.rgb, 1.0), edgeColor.a * edge);\n}\n@end"},function(e,t,r){"use strict";function n(e){for(var t=[],r=0;r<30;r++)t.push([Object(i.a)(r,2),Object(i.a)(r,3)]);this._haltonSequence=t,this._frame=0,this._sourceTex=new s.a,this._sourceFb=new o.a,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new s.a,this._outputTex=new s.a;var n=this._blendPass=new a.a({fragment:u.a.source("clay.compositor.blend")});n.material.disableTexturesAll(),n.material.enableTexture(["texture1","texture2"]),this._blendFb=new o.a({depthBuffer:!1}),this._outputPass=new a.a({fragment:u.a.source("clay.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.define("fragment","OUTPUT_ALPHA"),this._outputPass.material.blend=function(e){e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}}var i=r(49),a=r(16),o=r(10),s=r(5),u=r(8),l=r(9);n.prototype={constructor:n,jitterProjection:function(e,t){var r=e.viewport,n=r.devicePixelRatio||e.getDevicePixelRatio(),i=r.width*n,a=r.height*n,o=this._haltonSequence[this._frame%this._haltonSequence.length],s=new l.a;s.array[12]=(2*o[0]-1)/i,s.array[13]=(2*o[1]-1)/a,l.a.mul(t.projectionMatrix,s,t.projectionMatrix),l.a.invert(t.invProjectionMatrix,t.projectionMatrix)},resetFrame:function(){this._frame=0},getFrame:function(){return this._frame},getSourceFrameBuffer:function(){return this._sourceFb},getOutputTexture:function(){return this._outputTex},resize:function(e,t){this._prevFrameTex.width=e,this._prevFrameTex.height=t,this._outputTex.width=e,this._outputTex.height=t,this._sourceTex.width=e,this._sourceTex.height=t,this._prevFrameTex.dirty(),this._outputTex.dirty(),this._sourceTex.dirty()},isFinished:function(){return this._frame>=this._haltonSequence.length},render:function(e,t,r){var n=this._blendPass;0===this._frame?(n.setUniform("weight1",0),n.setUniform("weight2",1)):(n.setUniform("weight1",.9),n.setUniform("weight2",.1)),n.setUniform("texture1",this._prevFrameTex),n.setUniform("texture2",t||this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),n.render(e),this._blendFb.unbind(e),r||(this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e));var i=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=i,this._frame++},dispose:function(e){this._sourceFb.dispose(e),this._blendFb.dispose(e),this._prevFrameTex.dispose(e),this._outputTex.dispose(e),this._sourceTex.dispose(e),this._outputPass.dispose(e),this._blendPass.dispose(e)}},t.a=n},function(e,t,r){"use strict";var n=r(0),i=r.n(n);r(202),r(203),r(98);i.a.registerAction({type:"geo3DChangeCamera",event:"geo3dcamerachanged",update:"series:updateCamera"},function(e,t){t.eachComponent({mainType:"geo3D",query:e},function(t){t.setView(e)})})},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(44),o=r(28),s=r(29),u=r(31),l=r(96),h=i.a.extendComponentModel({type:"geo3D",layoutMode:"box",coordinateSystem:null,optionUpdated:function(){var e=this.option;e.regions=this.getFilledRegions(e.regions,e.map);var t=i.a.helper.completeDimensions(["value"],e.data,{encodeDef:this.get("encode"),dimsDef:this.get("dimensions")}),r=new i.a.List(t,this);r.initData(e.regions);var n={};r.each(function(e){var t=r.getName(e),i=r.getItemModel(e);n[t]=i}),this._regionModelMap=n,this._data=r},getData:function(){return this._data},getRegionModel:function(e){var t=this.getData().getName(e);return this._regionModelMap[t]||new i.a.Model(null,this)},getRegionPolygonCoords:function(e){var t=this.getData().getName(e),r=this.coordinateSystem.getRegion(t);return r?r.geometries:[]},getFormattedLabel:function(e,t){var r=this._data.getName(e),n=this.getRegionModel(r),i=n.get("normal"===t?["label","formatter"]:["emphasis","label","formatter"]);null==i&&(i=n.get(["label","formatter"]));var a={name:r};if("function"==typeof i)return a.status=t,i(a);if("string"==typeof i){var o=a.seriesName;return i.replace("{a}",null!=o?o:"")}return r},defaultOption:{regions:[]}});i.a.util.merge(h.prototype,l.a),i.a.util.merge(h.prototype,a.a),i.a.util.merge(h.prototype,o.a),i.a.util.merge(h.prototype,s.a),i.a.util.merge(h.prototype,u.a)},function(e,t,r){"use strict";var n=r(64),i=r(0),a=r.n(i),o=r(1),s=r(45),u=r(30);a.a.extendComponentView({type:"geo3D",__ecgl__:!0,init:function(e,t){this._geo3DBuilder=new n.a(t),this.groupGL=new o.a.Node,this._lightRoot=new o.a.Node,this._sceneHelper=new u.a(this._lightRoot),this._sceneHelper.initLight(this._lightRoot),this._control=new s.a({zr:t.getZr()}),this._control.init()},render:function(e,t,r){this.groupGL.add(this._geo3DBuilder.rootNode);var n=e.coordinateSystem;if(n&&n.viewGL){n.viewGL.add(this._lightRoot),e.get("show")?n.viewGL.add(this.groupGL):n.viewGL.remove(this.groupGL);var i=this._control;i.setViewGL(n.viewGL);var a=e.getModel("viewControl");i.setFromViewControlModel(a,0),this._sceneHelper.setScene(n.viewGL.scene),this._sceneHelper.updateLight(e),n.viewGL.setPostEffect(e.getModel("postEffect"),r),n.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._geo3DBuilder.update(e,t,r,0,e.getData().count());var o=n.viewGL.isLinearSpace()?"define":"undefine";this._geo3DBuilder.rootNode.traverse(function(e){e.material&&e.material[o]("fragment","SRGB_DECODE")}),i.off("update"),i.on("update",function(){r.dispatchAction({type:"geo3DChangeCamera",alpha:i.getAlpha(),beta:i.getBeta(),distance:i.getDistance(),center:i.getCenter(),from:this.uid,geo3DId:e.id})}),i.update()}},afterRender:function(e,t,r,n){var i=n.renderer;this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r)},dispose:function(){this._control.dispose()}})},function(e,t,r){"use strict";function n(e,t,r){r=r||2;var n=t&&t.length,a=n?t[0]*r:e.length,s=i(e,0,a,r,!0),u=[];if(!s)return u;var l,h,d,f,p,m,g;if(n&&(s=c(e,t,s,r)),e.length>80*r){l=d=e[0],h=f=e[1];for(var _=r;_d&&(d=p),m>f&&(f=m);g=Math.max(d-l,f-h)}return o(s,u,r,l,h,g),u}function i(e,t,r,n,i){var a,o;if(i===N(e,t,r,n)>0)for(a=t;a=t;a-=n)o=C(a,e[a],e[a+1],o);return o&&b(o,o.next)&&(L(o),o=o.next),o}function a(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!b(n,n.next)&&0!==T(n.prev,n,n.next))n=n.next;else{if(L(n),(n=t=n.prev)===n.next)return null;r=!0}}while(r||n!==t);return t}function o(e,t,r,n,i,c,d){if(e){!d&&c&&m(e,n,i,c);for(var f,p,g=e;e.prev!==e.next;)if(f=e.prev,p=e.next,c?u(e,n,i,c):s(e))t.push(f.i/r),t.push(e.i/r),t.push(p.i/r),L(e),e=p.next,g=p.next;else if((e=p)===g){d?1===d?(e=l(e,t,r),o(e,t,r,n,i,c,2)):2===d&&h(e,t,r,n,i,c):o(a(e),t,r,n,i,c,1);break}}}function s(e){var t=e.prev,r=e,n=e.next;if(T(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(y(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&T(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function u(e,t,r,n){var i=e.prev,a=e,o=e.next;if(T(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,h=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,c=_(s,u,t,r,n),d=_(l,h,t,r,n),f=e.nextZ;f&&f.z<=d;){if(f!==e.prev&&f!==e.next&&y(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&T(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=e.prevZ;f&&f.z>=c;){if(f!==e.prev&&f!==e.next&&y(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&T(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}function l(e,t,r){var n=e;do{var i=n.prev,a=n.next.next;!b(i,a)&&w(i,n,n.next,a)&&S(i,a)&&S(a,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(a.i/r),L(n),L(n.next),n=e=a),n=n.next}while(n!==e);return n}function h(e,t,r,n,i,s){var u=e;do{for(var l=u.next.next;l!==u.prev;){if(u.i!==l.i&&x(u,l)){var h=M(u,l);return u=a(u,u.next),h=a(h,h.next),o(u,t,r,n,i,s),void o(h,t,r,n,i,s)}l=l.next}u=u.next}while(u!==e)}function c(e,t,r,n){var o,s,u,l,h,c=[];for(o=0,s=t.length;o=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o){if(o=s,s===i){if(a===n.y)return n;if(a===n.next.y)return n.next}r=n.x=n.x&&n.x>=h&&i!==n.x&&y(ar.x)&&S(n,e)&&(r=n,d=u),n=n.next;return r}function m(e,t,r,n){var i=e;do{null===i.z&&(i.z=_(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,g(i)}function g(e){var t,r,n,i,a,o,s,u,l=1;do{for(r=e,e=null,a=null,o=0;r;){for(o++,n=r,s=0,t=0;t0||u>0&&n;)0!==s&&(0===u||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,u--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=n}a.nextZ=null,l*=2}while(o>1);return e}function _(e,t,r,n,i){return e=32767*(e-r)/i,t=32767*(t-n)/i,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function v(e){var t=e,r=e;do{t.x=0&&(e-o)*(n-s)-(r-o)*(t-s)>=0&&(r-o)*(a-s)-(i-o)*(n-s)>=0}function x(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!E(e,t)&&S(e,t)&&S(t,e)&&A(e,t)}function T(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function b(e,t){return e.x===t.x&&e.y===t.y}function w(e,t,r,n){return!!(b(e,t)&&b(r,n)||b(e,n)&&b(r,t))||T(e,t,r)>0!=T(e,t,n)>0&&T(r,n,e)>0!=T(r,n,t)>0}function E(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&w(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function S(e,t){return T(e.prev,e,e.next)<0?T(e,t,e.next)>=0&&T(e,e.prev,t)>=0:T(e,t,e.prev)<0||T(e,e.next,t)<0}function A(e,t){var r=e,n=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==e);return n}function M(e,t){var r=new D(e.i,e.x,e.y),n=new D(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function C(e,t,r,n){var i=new D(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function L(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function D(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function N(e,t,r,n){for(var i=0,a=t,o=r-n;a0},_displacementChanged:!0,_displacementScale:0,updateDisplacementHash:function(){var e=this.getDisplacementTexture(),t=this.getDisplacemenScale();this._displacementChanged=this._displacementTexture!==e||this._displacementScale!==t,this._displacementTexture=e,this._displacementScale=t},isDisplacementChanged:function(){return this._displacementChanged}});a.a.util.merge(h.prototype,o.a),a.a.util.merge(h.prototype,s.a),a.a.util.merge(h.prototype,u.a),a.a.util.merge(h.prototype,l.a)},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(1),o=r(45),s=r(30),u=r(210),l=r(2);i.a.extendComponentView({type:"globe",__ecgl__:!0,_displacementScale:0,init:function(e,t){this.groupGL=new a.a.Node,this._sphereGeometry=new a.a.SphereGeometry({widthSegments:200,heightSegments:100,dynamic:!0}),this._overlayGeometry=new a.a.SphereGeometry({widthSegments:80,heightSegments:40}),this._planeGeometry=new a.a.PlaneGeometry,this._earthMesh=new a.a.Mesh({renderNormal:!0}),this._lightRoot=new a.a.Node,this._sceneHelper=new s.a,this._sceneHelper.initLight(this._lightRoot),this.groupGL.add(this._earthMesh),this._control=new o.a({zr:t.getZr()}),this._control.init(),this._layerMeshes={}},render:function(e,t,r){var n=e.coordinateSystem,i=e.get("shading");n.viewGL.add(this._lightRoot),e.get("show")?n.viewGL.add(this.groupGL):n.viewGL.remove(this.groupGL),this._sceneHelper.setScene(n.viewGL.scene),n.viewGL.setPostEffect(e.getModel("postEffect"),r),n.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling"));var o=this._earthMesh;o.geometry=this._sphereGeometry;var s="ecgl."+i;o.material&&o.material.shader.name===s||(o.material=a.a.createMaterial(s)),a.a.setMaterialFromModel(i,o.material,e,r),["roughnessMap","metalnessMap","detailMap","normalMap"].forEach(function(e){var t=o.material.get(e);t&&(t.flipY=!1)}),o.material.set("color",a.a.parseColor(e.get("baseColor")));var u=.99*n.radius;o.scale.set(u,u,u);var l=o.material.setTextureImage("diffuseMap",e.get("baseTexture"),r,{flipY:!1,anisotropic:8});l&&l.surface&&l.surface.attachToMesh(o);var h=o.material.setTextureImage("bumpMap",e.get("heightTexture"),r,{flipY:!1,anisotropic:8});h&&h.surface&&h.surface.attachToMesh(o),o.material[e.get("postEffect.enable")?"define":"undefine"]("fragment","SRGB_DECODE"),this._updateLight(e,r),this._displaceVertices(e,r),this._updateViewControl(e,r),this._updateLayers(e,r)},afterRender:function(e,t,r,n){var i=n.renderer;this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r)},_updateLayers:function(e,t){var r=e.coordinateSystem,n=e.get("layers"),o=r.radius,s=[],u=[],h=[],c=[];i.a.util.each(n,function(e){var n=new i.a.Model(e),d=n.get("type"),f=a.a.loadTexture(n.get("texture"),t,{flipY:!1,anisotropic:8});if(f.surface&&f.surface.attachToMesh(this._earthMesh),"blend"===d){var p=n.get("blendTo"),m=l.a.firstNotNull(n.get("intensity"),1);"emission"===p?(h.push(f),c.push(m)):(s.push(f),u.push(m))}else{var g=n.get("id"),_=this._layerMeshes[g];_||(_=this._layerMeshes[g]=new a.a.Mesh({geometry:this._overlayGeometry,castShadow:!1,ignorePicking:!0}));"lambert"===n.get("shading")?(_.material=_.__lambertMaterial||new a.a.Material({autoUpdateTextureStatus:!1,shader:a.a.createShader("ecgl.lambert"),transparent:!0,depthMask:!1}),_.__lambertMaterial=_.material):(_.material=_.__colorMaterial||new a.a.Material({autoUpdateTextureStatus:!1,shader:a.a.createShader("ecgl.color"),transparent:!0,depthMask:!1}),_.__colorMaterial=_.material),_.material.enableTexture("diffuseMap");var v=n.get("distance"),y=o+(null==v?r.radius/100:v);_.scale.set(y,y,y),o=y;var x=this._blankTexture||(this._blankTexture=a.a.createBlankTexture("rgba(255, 255, 255, 0)"));_.material.set("diffuseMap",x),a.a.loadTexture(n.get("texture"),t,{flipY:!1,anisotropic:8},function(e){e.surface&&e.surface.attachToMesh(_),_.material.set("diffuseMap",e),t.getZr().refresh()}),n.get("show")?this.groupGL.add(_):this.groupGL.remove(_)}},this);var d=this._earthMesh.material;d.define("fragment","LAYER_DIFFUSEMAP_COUNT",s.length),d.define("fragment","LAYER_EMISSIVEMAP_COUNT",h.length),d.set("layerDiffuseMap",s),d.set("layerDiffuseIntensity",u),d.set("layerEmissiveMap",h),d.set("layerEmissionIntensity",c);var f=e.getModel("debug.wireframe");if(f.get("show")){d.define("both","WIREFRAME_TRIANGLE");var p=a.a.parseColor(f.get("lineStyle.color")||"rgba(0,0,0,0.5)"),m=l.a.firstNotNull(f.get("lineStyle.width"),1);d.set("wireframeLineWidth",m),d.set("wireframeLineColor",p)}else d.undefine("both","WIREFRAME_TRIANGLE")},_updateViewControl:function(e,t){function r(){return{type:"globeChangeCamera",alpha:o.getAlpha(),beta:o.getBeta(),distance:o.getDistance()-n.radius,center:o.getCenter(),from:a.uid,globeId:e.id}}var n=e.coordinateSystem,i=e.getModel("viewControl"),a=(n.viewGL.camera,this),o=this._control;o.setViewGL(n.viewGL);var s,u,l=i.get("targetCoord");null!=l&&(u=l[0]+90,s=l[1]),o.setFromViewControlModel(i,{baseDistance:n.radius,alpha:s,beta:u}),o.off("update"),o.on("update",function(){t.dispatchAction(r())})},_displaceVertices:function(e,t){var r=e.get("displacementQuality"),n=e.get("debug.wireframe.show"),i=e.coordinateSystem;if(e.isDisplacementChanged()||r!==this._displacementQuality||n!==this._showDebugWireframe){this._displacementQuality=r,this._showDebugWireframe=n;var a=this._sphereGeometry,o={low:100,medium:200,high:400,ultra:800}[r]||200,s=o/2;(a.widthSegments!==o||n)&&(a.widthSegments=o,a.heightSegments=s,a.build()),this._doDisplaceVertices(a,i),n&&a.generateBarycentric()}},_doDisplaceVertices:function(e,t){var r=e.attributes.position.value,n=e.attributes.texcoord0.value,i=e.__originalPosition;i&&i.length===r.length||(i=new Float32Array(r.length),i.set(r),e.__originalPosition=i);for(var a=t.displacementWidth,o=t.displacementHeight,s=t.displacementData,u=0;uOpenStreetMap contributors, © CARTO',center:[0,0],zoom:0,pitch:0,bearing:0,light:{main:{alpha:20,beta:30}},altitudeScale:1,boxHeight:"auto"},getMaptalksCameraOption:function(){var e=this;return s.reduce(function(t,r){return t[r]=e.get(r),t},{})},setMaptalksCameraOption:function(e){null!=e&&s.forEach(function(t){null!=e[t]&&(this.option[t]=e[t])},this)},getMaptalks:function(){return this._maptalks},setMaptalks:function(e){this._maptalks=e}});i.a.util.merge(u.prototype,a.a),i.a.util.merge(u.prototype,o.a)},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(224),o=r(30),s=r(1),u=r(102);s.a.Shader.import(u.a);i.a.extendComponentView({type:"maptalks3D",__ecgl__:!0,init:function(e,t){this._groundMesh=new s.a.Mesh({geometry:new s.a.PlaneGeometry,material:new s.a.Material({shader:new s.a.Shader({vertex:s.a.Shader.source("ecgl.displayShadow.vertex"),fragment:s.a.Shader.source("ecgl.displayShadow.fragment")}),depthMask:!1}),renderOrder:-100,culling:!1,castShadow:!1,$ignorePicking:!0,renderNormal:!0})},_initMaptalksLayer:function(e,t){var r=t.getZr();this._zrLayer=new a.a("maptalks3D",r,e.get("center"),e.get("zoom")),r.painter.insertLayer(-1e3,this._zrLayer),this._lightRoot=new s.a.Node,this._sceneHelper=new o.a(this._lightRoot),this._sceneHelper.initLight(this._lightRoot);var n=this._zrLayer.getMaptalks(),i=this._dispatchInteractAction.bind(this,t,n);["zoomend","zooming","zoomstart","dragrotating","pitch","pitchend","movestart","moving","moveend","resize","touchstart","touchmove","touchend"].forEach(function(e){n.on(e,i)})},render:function(e,t,r){this._zrLayer||this._initMaptalksLayer(e,r);var n=this._zrLayer.getMaptalks(),i=e.get("urlTemplate"),a=n.getBaseLayer();i!==this._oldUrlTemplate&&(a?a.setOptions({urlTemplate:i,attribution:e.get("attribution")}):(a=new maptalks.TileLayer("maptalks-echarts-gl-baselayer",{urlTemplate:i,subdomains:["a","b","c"],attribution:e.get("attribution")}),n.setBaseLayer(a))),this._oldUrlTemplate=i,n.setCenter(e.get("center")),n.setZoom(e.get("zoom"),{animation:!1}),n.setPitch(e.get("pitch")),n.setBearing(e.get("bearing")),e.setMaptalks(n);var o=e.coordinateSystem;o.viewGL.scene.add(this._lightRoot),o.viewGL.add(this._groundMesh),this._updateGroundMesh(),this._sceneHelper.setScene(o.viewGL.scene),this._sceneHelper.updateLight(e),o.viewGL.setPostEffect(e.getModel("postEffect"),r),o.viewGL.setTemporalSuperSampling(e.getModel("temporalSuperSampling")),this._maptalks3DModel=e},afterRender:function(e,t,r,n){var i=n.renderer;this._sceneHelper.updateAmbientCubemap(i,e,r),this._sceneHelper.updateSkybox(i,e,r),e.coordinateSystem.viewGL.scene.traverse(function(e){e.material&&(e.material.define("fragment","NORMAL_UP_AXIS",2),e.material.define("fragment","NORMAL_FRONT_AXIS",1))})},updateCamera:function(e,t,r,n){e.coordinateSystem.setCameraOption(n),this._updateGroundMesh(),r.getZr().refresh()},_dispatchInteractAction:function(e,t,r){e.dispatchAction({type:"maptalks3DChangeCamera",pitch:t.getPitch(),zoom:t.getZoom(),center:t.getCenter().toArray(),bearing:t.getBearing(),maptalks3DId:this._maptalks3DModel&&this._maptalks3DModel.id})},_updateGroundMesh:function(){if(this._maptalks3DModel){var e=this._maptalks3DModel.coordinateSystem,t=e.dataToPoint(e.center);this._groundMesh.position.set(t[0],t[1],-.001);var r=new s.a.Plane(new s.a.Vector3(0,0,1),0),n=e.viewGL.camera.castRay(new s.a.Vector2(-1,-1)),i=e.viewGL.camera.castRay(new s.a.Vector2(1,1)),a=n.intersectPlane(r),o=i.intersectPlane(r),u=a.dist(o)/e.viewGL.rootNode.scale.x;this._groundMesh.scale.set(u,u,1)}},dispose:function(e,t){this._zrLayer&&this._zrLayer.dispose(),t.getZr().painter.delLayer(-1e3)}})},function(e,t,r){"use strict";function n(e,t,r,n){if(this.id=e,this.zr=t,this.dom=document.createElement("div"),this.dom.style.cssText="position:absolute;left:0;right:0;top:0;bottom:0;",!maptalks)throw new Error("Maptalks library must be included. See https://maptalks.org");this._maptalks=new maptalks.Map(this.dom,{center:r,zoom:n,fog:!1}),this._initEvents()}n.prototype.resize=function(){this._maptalks.checkSize()},n.prototype.getMaptalks=function(){return this._maptalks},n.prototype.clear=function(){},n.prototype.refresh=function(){this._maptalks.checkSize()};var i=["mousedown","mouseup","click","dblclick","mousemove","mousewheel","DOMMouseScroll","touchstart","touchend","touchmove","touchcancel"];n.prototype._initEvents=function(){var e=this.dom;this._handlers=this._handlers||{contextmenu:function(e){return e.preventDefault(),!1}},i.forEach(function(t){this._handlers[t]=function(r){var n={};for(var i in r)n[i]=r[i];n.bubbles=!1;var a=new r.constructor(r.type,n);"mousewheel"===t||"DOMMouseScroll"===t?e.dispatchEvent(a):e.firstElementChild.dispatchEvent(a)},this.zr.dom.addEventListener(t,this._handlers[t])},this),this.zr.dom.addEventListener("contextmenu",this._handlers.contextmenu)},n.prototype.dispose=function(){i.forEach(function(e){this.zr.dom.removeEventListener(e,this._handlers[e])},this),this._maptalks.remove()},t.a=n},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=(r(226),r(229),r(231),r(17));i.a.registerVisual(Object(a.a)("bar3D")),i.a.registerProcessor(function(e,t){e.eachSeriesByType("bar3d",function(e){var t=e.getData();t.filterSelf(function(e){return t.hasValue(e)})})})},function(e,t,r){"use strict";function n(e,t){var r=e.getData(),n=e.get("minHeight")||0,i=e.get("barSize"),a=["lng","lat","alt"].map(function(t){return e.coordDimToDataDim(t)[0]});if(null==i){var s=t.radius*Math.PI,h=Object(d.a)(r,a[0],a[1]);i=[s/Math.sqrt(r.count()/h),s/Math.sqrt(r.count()/h)]}else u.a.util.isArray(i)||(i=[i,i]);var c=o(r,a);r.each(a,function(e,a,o,s){var u=r.get(c.dimension,s),l=c.isStacked?u-o:t.altitudeAxis.scale.getExtent()[0],h=Math.max(t.altitudeAxis.dataToCoord(o),n),d=t.dataToPoint([e,a,l]),p=t.dataToPoint([e,a,u]),m=f.sub([],p,d);f.normalize(m,m);var g=[i[0],h,i[1]];r.setItemLayout(s,[d,m,g])}),r.setLayout("orient",l.a.UP.array)}function i(e,t){var r=e.getData(),n=e.get("barSize"),i=e.get("minHeight")||0,a=["lng","lat","alt"].map(function(t){return e.coordDimToDataDim(t)[0]});if(null==n){var s=Math.min(t.size[0],t.size[2]),l=Object(d.a)(r,a[0],a[1]);n=[s/Math.sqrt(r.count()/l),s/Math.sqrt(r.count()/l)]}else u.a.util.isArray(n)||(n=[n,n]);var h=[0,1,0],c=o(r,a);r.each(a,function(e,a,o,s){var u=r.get(c.dimension,s),l=c.isStacked?u-o:t.altitudeAxis.scale.getExtent()[0],d=Math.max(t.altitudeAxis.dataToCoord(o),i),f=t.dataToPoint([e,a,l]),p=[n[0],d,n[1]];r.setItemLayout(s,[f,h,p])}),r.setLayout("orient",[1,0,0])}function a(e,t){var r=e.getData(),n=e.coordDimToDataDim("lng")[0],i=e.coordDimToDataDim("lat")[0],a=e.coordDimToDataDim("alt")[0],s=e.get("barSize"),l=e.get("minHeight")||0;if(null==s){var h=r.getDataExtent(n),c=r.getDataExtent(i),f=t.dataToPoint([h[0],c[0]]),p=t.dataToPoint([h[1],c[1]]),m=Math.min(Math.abs(f[0]-p[0]),Math.abs(f[1]-p[1]))||1,g=Object(d.a)(r,n,i);s=[m/Math.sqrt(r.count()/g),m/Math.sqrt(r.count()/g)]}else u.a.util.isArray(s)||(s=[s,s]),s[0]/=t.getScale()/16,s[1]/=t.getScale()/16;var _=[0,0,1],v=[n,i,a],y=o(r,v);r.each(v,function(e,n,i,a){var o=r.get(y.dimension,a),u=y.isStacked?o-i:0,h=t.dataToPoint([e,n,u]),c=t.dataToPoint([e,n,o]),d=Math.max(c[2]-h[2],l),f=[s[0],d,s[1]];r.setItemLayout(a,[h,_,f])}),r.setLayout("orient",[1,0,0])}function o(e,t){var r=p(e,t[2]);return{dimension:r?e.getCalculationInfo("stackResultDimension"):t[2],isStacked:r}}var s=r(0),u=r.n(s),l=r(3),h=r(6),c=r(227),d=r(228),f=h.a.vec3,p=u.a.helper.dataStack.isDimensionStacked;u.a.registerLayout(function(e,t){e.eachSeriesByType("bar3D",function(e){var t=e.coordinateSystem,r=t&&t.type;"globe"===r?n(e,t):"cartesian3D"===r?Object(c.a)(e,t):"geo3D"===r?i(e,t):"mapbox3D"!==r&&"maptalks3D"!==r||a(e,t)})})},function(e,t,r){"use strict";function n(e){var t=e[0],r=e[1];return!(t>0&&r>0||t<0&&r<0)}function i(e,t){var r=e.getData(),i=e.get("barSize");if(null==i){var a,s,h=t.size,c=t.getAxis("x"),d=t.getAxis("y");a="category"===c.type?.7*c.getBandWidth():.6*Math.round(h[0]/Math.sqrt(r.count())),s="category"===d.type?.7*d.getBandWidth():.6*Math.round(h[1]/Math.sqrt(r.count())),i=[a,s]}else o.a.util.isArray(i)||(i=[i,i]);var f=t.getAxis("z").scale.getExtent(),p=n(f),m=["x","y","z"].map(function(t){return e.coordDimToDataDim(t)[0]}),g=l(r,m[2]),_=g?r.getCalculationInfo("stackResultDimension"):m[2];r.each(m,function(e,n,a,o){var s=r.get(_,o),l=g?s-a:p?0:f[0],h=t.dataToPoint([e,n,l]),c=t.dataToPoint([e,n,s]),d=u.dist(h,c),m=[0,c[1]0&&(p++,c[3]<.99&&(m=!0))}}),s.geometry.setBarCount(p);var g=r.getLayout("orient"),_=this._barIndexOfData=new Int32Array(r.count()),p=0;r.each(function(e){if(!r.hasValue(e))return void(_[e]=-1);var t=r.getItemLayout(e),n=t[0],i=t[1],a=t[2],s=4*e;c[0]=d[s++],c[1]=d[s++],c[2]=d[s++],c[3]=d[s++],c[3]>0&&(o._barMesh.geometry.addBar(n,i,g,a,c,e),_[e]=p++)}),s.geometry.dirty(),s.geometry.updateBoundingBox();var v=s.material;v.transparent=m,v.depthMask=!m,s.geometry.sortTriangles=m,this._initHandler(e,t)},_initHandler:function(e,t){var r=e.getData(),n=this._barMesh,i="cartesian3D"===e.coordinateSystem.type;n.seriesIndex=e.seriesIndex;var a=-1;n.off("mousemove"),n.off("mouseout"),n.on("mousemove",function(e){var o=n.geometry.getDataIndexOfVertex(e.triangle[0]);o!==a&&(this._downplay(a),this._highlight(o),this._labelsBuilder.updateLabels([o]),i&&t.dispatchAction({type:"grid3DShowAxisPointer",value:[r.get("x",o),r.get("y",o),r.get("z",o,!0)]})),a=o,n.dataIndex=o},this),n.on("mouseout",function(e){this._downplay(a),this._labelsBuilder.updateLabels(),a=-1,n.dataIndex=-1,i&&t.dispatchAction({type:"grid3DHideAxisPointer"})},this)},_highlight:function(e){var t=this._data;if(t){var r=this._barIndexOfData[e];if(!(r<0)){var n=t.getItemModel(e),o=n.getModel("emphasis.itemStyle"),s=o.get("color"),u=o.get("opacity");if(null==s){var l=t.getItemVisual(e,"color");s=i.a.color.lift(l,-.4)}null==u&&(u=t.getItemVisual(e,"opacity"));var h=a.a.parseColor(s);h[3]*=u,this._barMesh.geometry.setColor(r,h),this._api.getZr().refresh()}}},_downplay:function(e){var t=this._data;if(t){var r=this._barIndexOfData[e];if(!(r<0)){var n=t.getItemVisual(e,"color"),i=t.getItemVisual(e,"opacity"),o=a.a.parseColor(n);o[3]*=i,this._barMesh.geometry.setColor(r,o),this._api.getZr().refresh()}}},highlight:function(e,t,r,n){this._toggleStatus("highlight",e,t,r,n)},downplay:function(e,t,r,n){this._toggleStatus("downplay",e,t,r,n)},_toggleStatus:function(e,t,r,n,a){var u=t.getData(),l=o.a.queryDataIndex(u,a),h=this;null!=l?i.a.util.each(s.a.normalizeToArray(l),function(t){"highlight"===e?this._highlight(t):this._downplay(t)},this):u.each(function(t){"highlight"===e?h._highlight(t):h._downplay(t)})},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}})},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(38),o=r(65),s=r(15),u=r(6),l=u.a.vec3,h=u.a.mat3,c=s.a.extend(function(){return{attributes:{position:new s.a.Attribute("position","float",3,"POSITION"),normal:new s.a.Attribute("normal","float",3,"NORMAL"),color:new s.a.Attribute("color","float",4,"COLOR"),prevPosition:new s.a.Attribute("prevPosition","float",3),prevNormal:new s.a.Attribute("prevNormal","float",3)},dynamic:!0,enableNormal:!1,bevelSize:1,bevelSegments:0,_dataIndices:null,_vertexOffset:0,_triangleOffset:0}},{resetOffset:function(){this._vertexOffset=0,this._triangleOffset=0},setBarCount:function(e){var t=this.enableNormal,r=this.getBarVertexCount()*e,n=this.getBarTriangleCount()*e;this.vertexCount!==r&&(this.attributes.position.init(r),t?this.attributes.normal.init(r):this.attributes.normal.value=null,this.attributes.color.init(r)),this.triangleCount!==n&&(this.indices=r>65535?new Uint32Array(3*n):new Uint16Array(3*n),this._dataIndices=new Uint32Array(r))},getBarVertexCount:function(){var e=this.bevelSize>0?this.bevelSegments:0;return e>0?this._getBevelBarVertexCount(e):this.enableNormal?24:8},getBarTriangleCount:function(){var e=this.bevelSize>0?this.bevelSegments:0;return e>0?this._getBevelBarTriangleCount(e):12},_getBevelBarVertexCount:function(e){return 4*(e+1)*(e+1)*2},_getBevelBarTriangleCount:function(e){return(4*e+3+1)*(2*e+1)*2+4},setColor:function(e,t){for(var r=this.getBarVertexCount(),n=r*e,i=r*(e+1),a=n;a0&&this.bevelSegments>0)this._addBevelBar(e,d,g,_,this.bevelSize,this.bevelSegments,v);else{l.copy(i,d),l.normalize(i,i),l.cross(a,g,i),l.normalize(a,a),l.cross(n,i,a),l.normalize(a,a),l.negate(o,n),l.negate(s,i),l.negate(u,a),t(h[0],e,n,_[0]/2),t(h[0],h[0],a,_[2]/2),t(h[1],e,n,_[0]/2),t(h[1],h[1],u,_[2]/2),t(h[2],e,o,_[0]/2),t(h[2],h[2],u,_[2]/2),t(h[3],e,o,_[0]/2),t(h[3],h[3],a,_[2]/2),t(r,e,i,_[1]),t(h[4],r,n,_[0]/2),t(h[4],h[4],a,_[2]/2),t(h[5],r,n,_[0]/2),t(h[5],h[5],u,_[2]/2),t(h[6],r,o,_[0]/2),t(h[6],h[6],u,_[2]/2),t(h[7],r,o,_[0]/2),t(h[7],h[7],a,_[2]/2);var T=this.attributes;if(this.enableNormal){c[0]=n,c[1]=o,c[2]=i,c[3]=s,c[4]=a,c[5]=u;for(var b=this._vertexOffset,w=0;w=0){var T=3*h,b=new l.a(this._points[T],this._points[T+1],this._points[T+2]);a.push({dataIndex:h,point:b,pointWorld:b.clone(),target:this._line3DMesh,distance:this._camera.getWorldPosition().dist(b)})}},remove:function(){this.groupGL.removeAll()},dispose:function(){this.groupGL.removeAll()}})},function(e,t){function r(e,t,r,n,i,a,o){if(0===i)return!1;var s=i,u=0,l=e;if(o>t+s&&o>n+s||oe+s&&a>r+s||ao?l.position[1]+=(h-o)/2:l.position[0]+=(h-a)/2;var c=l.getBoundingRect();return l.position[0]-=c.x,l.position[1]-=c.y,l.setStyle(r),l.update(),l.__size=h,l}function a(e,t,r){function n(e){return e<128?1:-1}for(var i=t.width,a=t.height,o=e.canvas.width,s=e.canvas.height,u=i/o,l=a/s,h=e.createImageData(o,s),c=0;c=0;c--){var d;d=this.geometry.indices?this.geometry.indices[c]:c;var f=s[2*d],p=s[2*d+1],m=this.geometry.attributes.size.get(d)/this.sizeScale,g=m/2;if(e>f-g*l&&ep-g*h&&t=2e4},doSortVertices:function(e,t){var r=this.indices,n=a.create();if(!r){r=this.indices=this.vertexCount>65535?new Uint32Array(this.vertexCount):new Uint16Array(this.vertexCount);for(var i=0;i.05);else for(var i=0;i<3;i++)this._progressiveQuickSort(3*t+i);this.dirtyIndices()},_simpleSort:function(e){function t(e,t){return r[t]-r[e]}var r=this._zList,i=this.indices;e?Array.prototype.sort.call(i,t):n.a.sort(i,t,0,i.length-1)},_progressiveQuickSort:function(e){var t=this._zList,r=this.indices;this._quickSort=this._quickSort||new n.a,this._quickSort.step(r,function(e,r){return t[r]-t[e]},e)}}},function(e,t,r){"use strict";t.a="@export ecgl.sdfSprite.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform float elapsedTime : 0;\n\nattribute vec3 position : POSITION;\n\n#ifdef VERTEX_SIZE\nattribute float size;\n#else\nuniform float u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_FillColor: COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute float prevSize;\nuniform float percent : 1.0;\n#endif\n\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvarying float v_Size;\n\nvoid main()\n{\n\n#ifdef POSITIONTEXTURE_ENABLED\n gl_Position = worldViewProjection * vec4(texture2D(positionTexture, position.xy).xy, -10.0, 1.0);\n#else\n\n #ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n #else\n vec3 pos = position;\n #endif\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n#endif\n\n#ifdef VERTEX_SIZE\n#ifdef VERTEX_ANIMATION\n v_Size = mix(prevSize, size, percent);\n#else\n v_Size = size;\n#endif\n#else\n v_Size = u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = a_FillColor;\n #endif\n\n gl_PointSize = v_Size;\n}\n\n@end\n\n@export ecgl.sdfSprite.fragment\n\nuniform vec4 color: [1, 1, 1, 1];\nuniform vec4 strokeColor: [1, 1, 1, 1];\nuniform float smoothing: 0.07;\n\nuniform float lineWidth: 0.0;\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\nvarying float v_Size;\n\nuniform sampler2D sprite;\n\n@import clay.util.srgb\n\nvoid main()\n{\n gl_FragColor = color;\n\n vec4 _strokeColor = strokeColor;\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n #endif\n\n#ifdef SPRITE_ENABLED\n float d = texture2D(sprite, gl_PointCoord).r;\n gl_FragColor.a *= smoothstep(0.5 - smoothing, 0.5 + smoothing, d);\n\n if (lineWidth > 0.0) {\n float sLineWidth = lineWidth / 2.0;\n\n float outlineMaxValue0 = 0.5 + sLineWidth;\n float outlineMaxValue1 = 0.5 + sLineWidth + smoothing;\n float outlineMinValue0 = 0.5 - sLineWidth - smoothing;\n float outlineMinValue1 = 0.5 - sLineWidth;\n\n if (d <= outlineMaxValue1 && d >= outlineMinValue0) {\n float a = _strokeColor.a;\n if (d <= outlineMinValue1) {\n a = a * smoothstep(outlineMinValue0, outlineMinValue1, d);\n }\n else {\n a = a * smoothstep(outlineMaxValue1, outlineMaxValue0, d);\n }\n gl_FragColor.rgb = mix(gl_FragColor.rgb * gl_FragColor.a, _strokeColor.rgb, a);\n gl_FragColor.a = gl_FragColor.a * (1.0 - a) + a;\n }\n }\n#endif\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(gl_FragColor);\n#endif\n}\n@end"},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=(r(244),r(245),r(248),r(17));i.a.registerVisual(Object(a.a)("lines3D")),i.a.registerAction({type:"lines3DPauseEffect",event:"lines3deffectpaused",update:"series.lines3D:pauseEffect"},function(){}),i.a.registerAction({type:"lines3DResumeEffect",event:"lines3deffectresumed",update:"series.lines3D:resumeEffect"},function(){}),i.a.registerAction({type:"lines3DToggleEffect",event:"lines3deffectchanged",update:"series.lines3D:toggleEffect"},function(){})},function(e,t,r){"use strict";function n(e,t){f.copy(w,e[0]),f.copy(E,e[1]);var r=[],n=r[0]=v(),i=r[1]=v(),a=r[2]=v(),o=r[3]=v();t.dataToPoint(w,n),t.dataToPoint(E,o),p(y,n),g(x,o,n),p(x,x),m(T,x,y),p(T,T),m(x,y,T),_(i,y,x),p(i,i),p(y,o),g(x,n,o),p(x,x),m(T,x,y),p(T,T),m(x,y,T),_(a,y,x),p(a,a),_(b,n,o),p(b,b);var s=d.dot(n,b),u=d.dot(b,i),l=(Math.max(d.len(n),d.len(o))-s)/u*2;return d.scaleAndAdd(i,n,i,l),d.scaleAndAdd(a,o,a,l),r}function i(e,t,r){var n=[],i=n[0]=d.create(),a=n[1]=d.create(),o=n[2]=d.create(),s=n[3]=d.create();t.dataToPoint(e[0],i),t.dataToPoint(e[1],s);var u=d.dist(i,s);return d.lerp(a,i,s,.3),d.lerp(o,i,s,.3),d.scaleAndAdd(a,a,r,Math.min(.1*u,10)),d.scaleAndAdd(o,o,r,Math.min(.1*u,10)),n}function a(e,t){for(var r=new Float32Array(3*e.length),n=0,i=[],a=0;a0?1:-1}var i=r(0),a=(r.n(i),r(1)),o=r(6),s=r(25),u=r(247),l=o.a.vec3;a.a.Shader.import(u.a),t.a=a.a.Mesh.extend(function(){var e=new a.a.Material({shader:new a.a.Shader(a.a.Shader.source("ecgl.trail2.vertex"),a.a.Shader.source("ecgl.trail2.fragment")),transparent:!0,depthMask:!1}),t=new s.a({dynamic:!0});return t.createAttribute("dist","float",1),t.createAttribute("distAll","float",1),t.createAttribute("start","float",1),{geometry:t,material:e,culling:!1,$ignorePicking:!0}},{updateData:function(e,t,r){var i=e.hostModel,o=this.geometry,s=i.getModel("effect"),u=s.get("trailWidth")*t.getDevicePixelRatio(),h=s.get("trailLength"),c=i.get("effect.constantSpeed"),d=1e3*i.get("effect.period"),f=null!=c;f?this.material.set("speed",c/1e3):this.material.set("period",d),this.material[f?"define":"undefine"]("vertex","CONSTANT_SPEED");var p=i.get("polyline");o.trailLength=h,this.material.set("trailLength",h),o.resetOffset(),["position","positionPrev","positionNext"].forEach(function(e){o.attributes[e].value=r.attributes[e].value}),["dist","distAll","start","offset","color"].forEach(function(e){o.attributes[e].init(o.vertexCount)}),o.indices=r.indices;var m=[],g=s.get("trailColor"),_=s.get("trailOpacity"),v=null!=g,y=null!=_;this.updateWorldTransform();var x=this.worldTransform.x.len(),T=this.worldTransform.y.len(),b=this.worldTransform.z.len(),w=0,E=0;e.each(function(t){var i=e.getItemLayout(t),s=y?_:e.getItemVisual(t,"opacity"),h=e.getItemVisual(t,"color");null==s&&(s=1),m=a.a.parseColor(v?g:h,m),m[3]*=s;for(var c=p?r.getPolylineVertexCount(i):r.getCubicCurveVertexCount(i[0],i[1],i[2],i[3]),S=0,A=[],M=[],C=w;Cw&&(S+=l.dist(A,M)),o.attributes.dist.set(C,S),l.copy(M,A);E=Math.max(E,S);for(var L=Math.random()*(f?S:d),C=w;C0;this._updateSurfaceMesh(this._surfaceMesh,e,c,p);var m=this._surfaceMesh.material;p?(m.define("WIREFRAME_QUAD"),m.set("wireframeLineWidth",f),m.set("wireframeLineColor",o.a.parseColor(d.get("lineStyle.color")))):m.undefine("WIREFRAME_QUAD"),this._initHandler(e,r),this._updateAnimation(e)},_updateAnimation:function(e){o.a.updateVertexAnimation([["prevPosition","position"],["prevNormal","normal"]],this._prevSurfaceMesh,this._surfaceMesh,e)},_createSurfaceMesh:function(){var e=new o.a.Mesh({geometry:new o.a.Geometry({dynamic:!0,sortTriangles:!0}),shadowDepthMaterial:new o.a.Material({shader:new o.a.Shader(o.a.Shader.source("ecgl.sm.depth.vertex"),o.a.Shader.source("ecgl.sm.depth.fragment"))}),culling:!1,renderOrder:10,renderNormal:!0});return e.geometry.createAttribute("barycentric","float",4),e.geometry.createAttribute("prevPosition","float",3),e.geometry.createAttribute("prevNormal","float",3),a.a.util.extend(e.geometry,u.a),e},_initHandler:function(e,t){function r(e,t){for(var r=1/0,n=-1,a=[],o=0;o=0){var u=[];i.geometry.attributes.position.get(s,u);for(var h=a.pointToData(u),c=1/0,d=-1,f=[],p=0;p65535?Uint32Array:Uint16Array)((_-1)*(v-1)*6),S=function(e,t,r){r[1]=e*v+t,r[0]=e*v+t+1,r[3]=(e+1)*v+t+1,r[2]=(e+1)*v+t},A=!1;if(c){var M=[],C=[],L=0;x?f.init(a.vertexCount):f.value=null;for(var D=[[],[],[]],N=[],R=[],P=l.create(),I=function(e,t,r){var n=3*t;return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r},O=new Float32Array(u.length),F=new Float32Array(u.length/3*4),B=0;B ")),a.value&&(h+=" : "+i.a.format.encodeHTML(a.value)),h}return s.superApply(this,"formatTooltip",arguments)},_updateCategoriesData:function(){var e=(this.option.categories||[]).map(function(e){return null!=e.value?e:i.a.util.extend({value:0},e)}),t=new i.a.List(["value"],this);t.initData(e),this._categoriesData=t,this._categoriesModels=t.mapArray(function(e){return t.getItemModel(e,!0)})},setView:function(e){null!=e.zoom&&(this.option.zoom=e.zoom),null!=e.offset&&(this.option.offset=e.offset)},setNodePosition:function(e){for(var t=0;t "+g)),f++)}var _,v=i.a.helper.completeDimensions(["value"],e);_=new i.a.List(v,r),_.initData(e);var y=new i.a.List(["value"],r);return y.initData(d,c),a&&a(_,y),u()({mainData:_,struct:s,structAttr:"graph",datas:{node:_,edge:y},datasAttr:{node:"data",edge:"edgeData"}}),s.update(),s}},function(e,t,r){function n(e){return"_EC_"+e}function i(e,t){this.id=null==e?"":e,this.inEdges=[],this.outEdges=[],this.edges=[],this.hostGraph,this.dataIndex=null==t?-1:t}function a(e,t,r){this.node1=e,this.node2=t,this.dataIndex=null==r?-1:r}var o=r(104),s=(o.__DEV__,r(13)),u=r(266),l=u.enableClassCheck,h=function(e){this._directed=e||!1,this.nodes=[],this.edges=[],this._nodesMap={},this._edgesMap={},this.data,this.edgeData},c=h.prototype;c.type="graph",c.isDirected=function(){return this._directed},c.addNode=function(e,t){e=e||""+t;var r=this._nodesMap;if(!r[n(e)]){var a=new i(e,t);return a.hostGraph=this,this.nodes.push(a),r[n(e)]=a,a}},c.getNodeByIndex=function(e){var t=this.data.getRawIndex(e);return this.nodes[t]},c.getNodeById=function(e){return this._nodesMap[n(e)]},c.addEdge=function(e,t,r){var o=this._nodesMap,s=this._edgesMap;if("number"==typeof e&&(e=this.nodes[e]),"number"==typeof t&&(t=this.nodes[t]),i.isInstance(e)||(e=o[n(e)]),i.isInstance(t)||(t=o[n(t)]),e&&t){var u=e.id+"-"+t.id;if(!s[u]){var l=new a(e,t,r);return l.hostGraph=this,this._directed&&(e.outEdges.push(l),t.inEdges.push(l)),e.edges.push(l),e!==t&&t.edges.push(l),this.edges.push(l),s[u]=l,l}}},c.getEdgeByIndex=function(e){var t=this.edgeData.getRawIndex(e);return this.edges[t]},c.getEdge=function(e,t){i.isInstance(e)&&(e=e.id),i.isInstance(t)&&(t=t.id);var r=this._edgesMap;return this._directed?r[e+"-"+t]:r[e+"-"+t]||r[t+"-"+e]},c.eachNode=function(e,t){for(var r=this.nodes,n=r.length,i=0;i=0&&e.call(t,r[i],i)},c.eachEdge=function(e,t){for(var r=this.edges,n=r.length,i=0;i=0&&r[i].node1.dataIndex>=0&&r[i].node2.dataIndex>=0&&e.call(t,r[i],i)},c.breadthFirstTraverse=function(e,t,r,a){if(i.isInstance(t)||(t=this._nodesMap[n(t)]),t){for(var o="out"===r?"outEdges":"in"===r?"inEdges":"edges",s=0;s=0&&r.node2.dataIndex>=0});for(var i=0,a=n.length;i=0&&this[e][t].setItemVisual(this.dataIndex,r,n)},getVisual:function(r,n){return this[e][t].getItemVisual(this.dataIndex,r,n)},setLayout:function(r,n){this.dataIndex>=0&&this[e][t].setItemLayout(this.dataIndex,r,n)},getLayout:function(){return this[e][t].getItemLayout(this.dataIndex)},getGraphicEl:function(){return this[e][t].getItemGraphicEl(this.dataIndex)},getRawIndex:function(){return this[e][t].getRawIndex(this.dataIndex)}}};s.mixin(i,d("hostGraph","data")),s.mixin(a,d("hostGraph","edgeData")),h.Node=i,h.Edge=a,l(i),l(a);var f=h;e.exports=f},function(e,t,r){function n(e){var t={main:"",sub:""};return e&&(e=e.split(f),t.main=e[0]||"",t.sub=e[1]||""),t}function i(e){d.assert(/^[a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)?$/.test(e),'componentType "'+e+'" illegal')}function a(e,t){e.$constructor=e,e.extend=function(e){var t=this,r=function(){e.$constructor?e.$constructor.apply(this,arguments):t.apply(this,arguments)};return d.extend(r.prototype,e),r.extend=this.extend,r.superCall=s,r.superApply=u,d.inherits(r,this),r.superClass=t,r}}function o(e){var t=["__\0is_clz",m++,Math.random().toFixed(3)].join("_");e.prototype[t]=!0,e.isInstance=function(e){return!(!e||!e[t])}}function s(e,t){var r=d.slice(arguments,2);return this.superClass.prototype[t].apply(e,r)}function u(e,t,r){return this.superClass.prototype[t].apply(e,r)}function l(e,t){function r(e){var t=a[e.main];return t&&t[p]||(t=a[e.main]={},t[p]=!0),t}t=t||{};var a={};if(e.registerClass=function(e,t){if(t)if(i(t),t=n(t),t.sub){if(t.sub!==p){var o=r(t);o[t.sub]=e}}else a[t.main]=e;return e},e.getClass=function(e,t,r){var n=a[e];if(n&&n[p]&&(n=t?n[t]:null),r&&!n)throw new Error(t?"Component "+e+"."+(t||"")+" not exists. Load it first.":e+".type should be specified.");return n},e.getClassesByMainType=function(e){e=n(e);var t=[],r=a[e.main];return r&&r[p]?d.each(r,function(e,r){r!==p&&t.push(e)}):t.push(r),t},e.hasClass=function(e){return e=n(e),!!a[e.main]},e.getAllClassMainTypes=function(){var e=[];return d.each(a,function(t,r){e.push(r)}),e},e.hasSubTypes=function(e){e=n(e);var t=a[e.main];return t&&t[p]},e.parseClassType=n,t.registerWhenExtend){var o=e.extend;o&&(e.extend=function(t){var r=o.call(this,t);return e.registerClass(r,t.type)})}return e}function h(e,t){}var c=r(104),d=(c.__DEV__,r(13)),f=".",p="___EC__COMPONENT__CONTAINER___",m=0;t.parseClassType=n,t.enableClassExtend=a,t.enableClassCheck=o,t.enableClassManagement=l,t.setReadOnly=h},function(e,t,r){function n(e){var t=e.mainData,r=e.datas;r||(r={main:t},e.datasAttr={main:"data"}),e.datas=e.mainData=null,l(t,r,e),d(r,function(r){d(t.TRANSFERABLE_METHODS,function(t){r.wrapMethod(t,c.curry(i,e))})}),t.wrapMethod("cloneShallow",c.curry(o,e)),d(t.CHANGABLE_METHODS,function(r){t.wrapMethod(r,c.curry(a,e))}),c.assert(r[t.dataType]===t)}function i(e,t){if(u(this)){var r=c.extend({},this[f]);r[this.dataType]=t,l(t,r,e)}else h(t,this.dataType,this[p],e);return t}function a(e,t){return e.struct&&e.struct.update(this),t}function o(e,t){return d(t[f],function(r,n){r!==t&&h(r.cloneShallow(),n,t,e)}),t}function s(e){var t=this[p];return null==e||null==t?t:t[f][e]}function u(e){return e[p]===e}function l(e,t,r){e[f]={},d(t,function(t,n){h(t,n,e,r)})}function h(e,t,r,n){r[f][t]=e,e[p]=r,e.dataType=t,n.struct&&(e[n.structAttr]=n.struct,n.struct[n.datasAttr[t]]=e),e.getLinkedData=s}var c=r(13),d=c.each,f="\0__link_datas",p="\0__link_mainData",m=n;e.exports=m},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(47),o=r.n(a),s=r(1),u=r(22),l=r(105),h=r(2),c=r(269),d=r(271),f=r(80),p=r.n(f),m=r(6),g=r(273),_=r(67),v=r(274),y=m.a.vec2;s.a.Shader.import(v.a);var x=1;i.a.extendChartView({type:"graphGL",__ecgl__:!0,init:function(e,t){this.groupGL=new s.a.Node,this.viewGL=new u.a("orthographic"),this.viewGL.camera.left=this.viewGL.camera.right=0,this.viewGL.add(this.groupGL),this._pointsBuilder=new _.a(!0,t),this._forceEdgesMesh=new s.a.Mesh({material:new s.a.Material({shader:s.a.createShader("ecgl.forceAtlas2.edges"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new s.a.Geometry({attributes:{node:new s.a.Geometry.Attribute("node","float",2),color:new s.a.Geometry.Attribute("color","float",4,"COLOR")},dynamic:!0,mainAttribute:"node"}),renderOrder:-1,mode:s.a.Mesh.LINES}),this._edgesMesh=new s.a.Mesh({material:new s.a.Material({shader:s.a.createShader("ecgl.meshLines2D"),transparent:!0,depthMask:!1,depthTest:!1}),$ignorePicking:!0,geometry:new l.a({useNativeLine:!1,dynamic:!0}),renderOrder:-1,culling:!1}),this._layoutId=0,this._control=new g.a({zr:t.getZr(),viewGL:this.viewGL}),this._control.setTarget(this.groupGL),this._control.init(),this._clickHandler=this._clickHandler.bind(this)},render:function(e,t,r){this.groupGL.add(this._pointsBuilder.rootNode),this._model=e,this._api=r,this._initLayout(e,t,r),this._pointsBuilder.update(e,t,r),this._forceLayoutInstance instanceof c.a||this.groupGL.remove(this._forceEdgesMesh),this._updateCamera(e,r),this._control.off("update"),this._control.on("update",function(){r.dispatchAction({type:"graphGLRoam",seriesId:e.id,zoom:this._control.getZoom(),offset:this._control.getOffset()}),this._pointsBuilder.updateView(this.viewGL.camera)},this),this._control.setZoom(h.a.firstNotNull(e.get("zoom"),1)),this._control.setOffset(e.get("offset")||[0,0]);var n=this._pointsBuilder.getPointsMesh();if(n.off("mousemove",this._mousemoveHandler),n.off("mouseout",this._mouseOutHandler,this),r.getZr().off("click",this._clickHandler),this._pointsBuilder.highlightOnMouseover=!0,e.get("focusNodeAdjacency")){var i=e.get("focusNodeAdjacencyOn");"click"===i?r.getZr().on("click",this._clickHandler):"mouseover"===i&&(n.on("mousemove",this._mousemoveHandler,this),n.on("mouseout",this._mouseOutHandler,this),this._pointsBuilder.highlightOnMouseover=!1)}this._lastMouseOverDataIndex=-1},_clickHandler:function(e){if(!this._layouting){var t=this._pointsBuilder.getPointsMesh().dataIndex;t>=0?this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:t}):this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id})}},_mousemoveHandler:function(e){if(!this._layouting){var t=this._pointsBuilder.getPointsMesh().dataIndex;t>=0?t!==this._lastMouseOverDataIndex&&this._api.dispatchAction({type:"graphGLFocusNodeAdjacency",seriesId:this._model.id,dataIndex:t}):this._mouseOutHandler(e),this._lastMouseOverDataIndex=t}},_mouseOutHandler:function(e){this._layouting||(this._api.dispatchAction({type:"graphGLUnfocusNodeAdjacency",seriesId:this._model.id}),this._lastMouseOverDataIndex=-1)},_updateForceEdgesGeometry:function(e,t){var r=this._forceEdgesMesh.geometry,n=t.getEdgeData(),i=0,a=this._forceLayoutInstance,o=2*n.count();r.attributes.node.init(o),r.attributes.color.init(o),n.each(function(t){var o=e[t];r.attributes.node.set(i,a.getNodeUV(o.node1)),r.attributes.node.set(i+1,a.getNodeUV(o.node2));var u=n.getItemVisual(o.dataIndex,"color"),l=s.a.parseColor(u);l[3]*=h.a.firstNotNull(n.getItemVisual(o.dataIndex,"opacity"),1),r.attributes.color.set(i,l),r.attributes.color.set(i+1,l),i+=2}),r.dirty()},_updateMeshLinesGeometry:function(){var e=this._model.getEdgeData(),t=this._edgesMesh.geometry,e=this._model.getEdgeData(),r=this._model.getData().getLayout("points");t.resetOffset(),t.setVertexCount(e.count()*t.getLineVertexCount()),t.setTriangleCount(e.count()*t.getLineTriangleCount());var n=[],i=[],a=["lineStyle","width"];this._originalEdgeColors=new Float32Array(4*e.count()),this._edgeIndicesMap=new Float32Array(e.count()),e.each(function(o){var u=e.graph.getEdgeByIndex(o),l=2*u.node1.dataIndex,c=2*u.node2.dataIndex;n[0]=r[l],n[1]=r[l+1],i[0]=r[c],i[1]=r[c+1];var d=e.getItemVisual(u.dataIndex,"color"),f=s.a.parseColor(d);f[3]*=h.a.firstNotNull(e.getItemVisual(u.dataIndex,"opacity"),1);var p=e.getItemModel(u.dataIndex),m=h.a.firstNotNull(p.get(a),1)*this._api.getDevicePixelRatio();t.addLine(n,i,f,m);for(var g=0;g<4;g++)this._originalEdgeColors[4*u.dataIndex+g]=f[g];this._edgeIndicesMap[u.dataIndex]=o},this),t.dirty()},_updateForceNodesGeometry:function(e){for(var t=this._pointsBuilder.getPointsMesh(),r=[],n=0;n=f&&(u._syncNodePosition(e),d=0),r.getZr().refresh(),p()(function(){m(t)})})};p()(function(){u._forceLayoutInstanceToDispose&&(u._forceLayoutInstanceToDispose.dispose(i.layer.renderer),u._forceLayoutInstanceToDispose=null),m(l)}),this._layouting=!0}}},stopLayout:function(e,t,r,n){n&&null!=n.from&&n.from!==this.uid||(this._layoutId=0,this.groupGL.remove(this._forceEdgesMesh),this.groupGL.add(this._edgesMesh),this._forceLayoutInstance&&this.viewGL.layer&&(n&&n.beforeLayout||(this._syncNodePosition(e),this._updateAfterLayout(e,t,r)),this._api.getZr().refresh(),this._layouting=!1))},_syncNodePosition:function(e){var t=this._forceLayoutInstance.getNodePosition(this.viewGL.layer.renderer);e.getData().setLayout("points",t),e.setNodePosition(t)},_updateAfterLayout:function(e,t,r){this._updateMeshLinesGeometry(),this._pointsBuilder.removePositionTexture(),this._pointsBuilder.updateLayout(e,t,r),this._pointsBuilder.updateView(this.viewGL.camera),this._pointsBuilder.updateLabels(),this._pointsBuilder.showLabels()},focusNodeAdjacency:function(e,t,r,n){var i=this._model.getData();this._downplayAll();var a=n.dataIndex,o=i.graph,s=[],u=o.getNodeByIndex(a);s.push(u),u.edges.forEach(function(e){e.dataIndex<0||(e.node1!==u&&s.push(e.node1),e.node2!==u&&s.push(e.node2))},this),this._pointsBuilder.fadeOutAll(.05),this._fadeOutEdgesAll(.05),s.forEach(function(e){this._pointsBuilder.highlight(i,e.dataIndex)},this),this._pointsBuilder.updateLabels(s.map(function(e){return e.dataIndex}));var l=[];u.edges.forEach(function(e){e.dataIndex>=0&&(this._highlightEdge(e.dataIndex),l.push(e))},this),this._focusNodes=s,this._focusEdges=l},unfocusNodeAdjacency:function(e,t,r,n){this._downplayAll(),this._pointsBuilder.fadeInAll(),this._fadeInEdgesAll(),this._pointsBuilder.updateLabels()},_highlightEdge:function(e){var t=this._model.getEdgeData().getItemModel(e),r=s.a.parseColor(t.get("emphasis.lineStyle.color")||t.get("lineStyle.color")),n=h.a.firstNotNull(t.get("emphasis.lineStyle.opacity"),t.get("lineStyle.opacity"),1);r[3]*=n,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e],r)},_downplayAll:function(){this._focusNodes&&this._focusNodes.forEach(function(e){this._pointsBuilder.downplay(this._model.getData(),e.dataIndex)},this),this._focusEdges&&this._focusEdges.forEach(function(e){this._downplayEdge(e.dataIndex)},this)},_downplayEdge:function(e){var t=this._getColor(e,[]);this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[e],t)},_setEdgeFade:function(){var e=[];return function(t,r){this._getColor(t,e),e[3]*=r,this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[t],e)}}(),_getColor:function(e,t){for(var r=0;r<4;r++)t[r]=this._originalEdgeColors[4*e+r];return t},_fadeOutEdgesAll:function(e){this._model.getData().graph.eachEdge(function(t){this._setEdgeFade(t.dataIndex,e)},this)},_fadeInEdgesAll:function(){this._fadeOutEdgesAll(1)},_updateCamera:function(e,t){this.viewGL.setViewport(0,0,t.getWidth(),t.getHeight(),t.getDevicePixelRatio());for(var r=this.viewGL.camera,n=e.getData(),i=n.getLayout("points"),a=y.create(1/0,1/0),o=y.create(-1/0,-1/0),s=[],u=0;ur.left&&hr.top)){var c=Math.max(o[0]-a[0],10),d=c/t.getWidth()*t.getHeight();c*=1.4,d*=1.4,a[0]-=.2*c,r.left=a[0],r.top=l-d/2,r.bottom=l+d/2,r.right=c+a[0],r.near=0,r.far=100}},dispose:function(){var e=this.viewGL.layer.renderer;this._forceLayoutInstance&&this._forceLayoutInstance.dispose(e),this.groupGL.removeAll(),this._layoutId=-1},remove:function(){this.groupGL.removeAll(),this._control.dispose()}})},function(e,t,r){"use strict";function n(e){var t={type:o.a.Texture.FLOAT,minFilter:o.a.Texture.NEAREST,magFilter:o.a.Texture.NEAREST};this._positionSourceTex=new o.a.Texture2D(t),this._positionSourceTex.flipY=!1,this._positionTex=new o.a.Texture2D(t),this._positionPrevTex=new o.a.Texture2D(t),this._forceTex=new o.a.Texture2D(t),this._forcePrevTex=new o.a.Texture2D(t),this._weightedSumTex=new o.a.Texture2D(t),this._weightedSumTex.width=this._weightedSumTex.height=1,this._globalSpeedTex=new o.a.Texture2D(t),this._globalSpeedPrevTex=new o.a.Texture2D(t),this._globalSpeedTex.width=this._globalSpeedTex.height=1,this._globalSpeedPrevTex.width=this._globalSpeedPrevTex.height=1,this._nodeRepulsionPass=new s.a({fragment:o.a.Shader.source("ecgl.forceAtlas2.updateNodeRepulsion")}),this._positionPass=new s.a({fragment:o.a.Shader.source("ecgl.forceAtlas2.updatePosition")}),this._globalSpeedPass=new s.a({fragment:o.a.Shader.source("ecgl.forceAtlas2.calcGlobalSpeed")}),this._copyPass=new s.a({fragment:o.a.Shader.source("clay.compositor.output")});var r=function(e){e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE)};this._edgeForceMesh=new o.a.Mesh({geometry:new o.a.Geometry({attributes:{node1:new o.a.Geometry.Attribute("node1","float",2),node2:new o.a.Geometry.Attribute("node2","float",2),weight:new o.a.Geometry.Attribute("weight","float",1)},dynamic:!0,mainAttribute:"node1"}),material:new o.a.Material({transparent:!0,shader:o.a.createShader("ecgl.forceAtlas2.updateEdgeAttraction"),blend:r,depthMask:!1,depthText:!1}),mode:o.a.Mesh.POINTS}),this._weightedSumMesh=new o.a.Mesh({geometry:new o.a.Geometry({attributes:{node:new o.a.Geometry.Attribute("node","float",2)},dynamic:!0,mainAttribute:"node"}),material:new o.a.Material({transparent:!0,shader:o.a.createShader("ecgl.forceAtlas2.calcWeightedSum"),blend:r,depthMask:!1,depthText:!1}),mode:o.a.Mesh.POINTS}),this._framebuffer=new u.a({depthBuffer:!1}),this._dummyCamera=new o.a.OrthographicCamera({left:-1,right:1,top:1,bottom:-1,near:0,far:100}),this._globalSpeed=0}var i=r(0),a=r.n(i),o=r(1),s=r(16),u=r(10),l=r(270);o.a.Shader.import(l.a);var h={repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null};n.prototype.updateOption=function(e){for(var t in h)this[t]=h[t];var r=this._nodes.length;if(this.jitterTolerence=r>5e4?10:r>5e3?1:.1,this.scaling=r>100?2:10,e)for(var t in h)null!=e[t]&&(this[t]=e[t]);if(this.repulsionByDegree)for(var n=this._positionSourceTex.pixels,i=0;ie},n.prototype._swapTexture=function(){var e=this._positionPrevTex;this._positionPrevTex=this._positionTex,this._positionTex=e;var e=this._forcePrevTex;this._forcePrevTex=this._forceTex,this._forceTex=e;var e=this._globalSpeedPrevTex;this._globalSpeedPrevTex=this._globalSpeedTex,this._globalSpeedTex=e},n.prototype._initFromSource=function(e){this._framebuffer.attach(this._positionPrevTex),this._framebuffer.bind(e),this._copyPass.setUniform("texture",this._positionSourceTex),this._copyPass.render(e),e.gl.clearColor(0,0,0,0),this._framebuffer.attach(this._forcePrevTex),e.gl.clear(e.gl.COLOR_BUFFER_BIT),this._framebuffer.attach(this._globalSpeedPrevTex),e.gl.clear(e.gl.COLOR_BUFFER_BIT),this._framebuffer.unbind(e)},n.prototype._resize=function(e,t){["_positionSourceTex","_positionTex","_positionPrevTex","_forceTex","_forcePrevTex"].forEach(function(r){this[r].width=e,this[r].height=t,this[r].dirty()},this)},n.prototype.dispose=function(e){this._framebuffer.dispose(e),this._copyPass.dispose(e),this._nodeRepulsionPass.dispose(e),this._positionPass.dispose(e),this._globalSpeedPass.dispose(e),this._edgeForceMesh.geometry.dispose(e),this._weightedSumMesh.geometry.dispose(e),this._positionSourceTex.dispose(e),this._positionTex.dispose(e),this._positionPrevTex.dispose(e),this._forceTex.dispose(e),this._forcePrevTex.dispose(e),this._weightedSumTex.dispose(e),this._globalSpeedTex.dispose(e),this._globalSpeedPrevTex.dispose(e)},a.a.ForceAtlas2GPU=n,t.a=n},function(e,t,r){"use strict";t.a="@export ecgl.forceAtlas2.updateNodeRepulsion\n\n#define NODE_COUNT 0\n\nuniform sampler2D positionTex;\n\nuniform vec2 textureSize;\nuniform float gravity;\nuniform float scaling;\nuniform vec2 gravityCenter;\n\nuniform bool strongGravityMode;\nuniform bool preventOverlap;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, v_Texcoord);\n\n vec2 force = vec2(0.0);\n for (int i = 0; i < NODE_COUNT; i++) {\n vec2 uv = vec2(\n mod(float(i), textureSize.x) / (textureSize.x - 1.0),\n floor(float(i) / textureSize.x) / (textureSize.y - 1.0)\n );\n vec4 n1 = texture2D(positionTex, uv);\n\n vec2 dir = n0.xy - n1.xy;\n float d2 = dot(dir, dir);\n\n if (d2 > 0.0) {\n float factor = 0.0;\n if (preventOverlap) {\n float d = sqrt(d2);\n d = d - n0.w - n1.w;\n if (d > 0.0) {\n factor = scaling * n0.z * n1.z / (d * d);\n }\n else if (d < 0.0) {\n factor = scaling * 100.0 * n0.z * n1.z;\n }\n }\n else {\n factor = scaling * n0.z * n1.z / d2;\n }\n force += dir * factor;\n }\n }\n\n vec2 dir = gravityCenter - n0.xy;\n float d = 1.0;\n if (!strongGravityMode) {\n d = length(dir);\n }\n\n force += dir * n0.z * gravity / (d + 1.0);\n\n gl_FragColor = vec4(force, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.vertex\n\nattribute vec2 node1;\nattribute vec2 node2;\nattribute float weight;\n\nuniform sampler2D positionTex;\nuniform float edgeWeightInfluence;\nuniform bool preventOverlap;\nuniform bool linLogMode;\n\nuniform vec2 windowSize: WINDOW_SIZE;\n\nvarying vec2 v_Force;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, node1);\n vec4 n1 = texture2D(positionTex, node2);\n\n vec2 dir = n1.xy - n0.xy;\n float d = length(dir);\n float w;\n if (edgeWeightInfluence == 0.0) {\n w = 1.0;\n }\n else if (edgeWeightInfluence == 1.0) {\n w = weight;\n }\n else {\n w = pow(weight, edgeWeightInfluence);\n }\n vec2 offset = vec2(1.0 / windowSize.x, 1.0 / windowSize.y);\n vec2 scale = vec2((windowSize.x - 1.0) / windowSize.x, (windowSize.y - 1.0) / windowSize.y);\n vec2 pos = node1 * scale * 2.0 - 1.0;\n gl_Position = vec4(pos + offset, 0.0, 1.0);\n gl_PointSize = 1.0;\n\n float factor;\n if (preventOverlap) {\n d = d - n1.w - n0.w;\n }\n if (d <= 0.0) {\n v_Force = vec2(0.0);\n return;\n }\n\n if (linLogMode) {\n factor = w * log(d) / d;\n }\n else {\n factor = w;\n }\n v_Force = dir * factor;\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.fragment\n\nvarying vec2 v_Force;\n\nvoid main() {\n gl_FragColor = vec4(v_Force, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.vertex\n\nattribute vec2 node;\n\nvarying vec2 v_NodeUv;\n\nvoid main() {\n\n v_NodeUv = node;\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n gl_PointSize = 1.0;\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.fragment\n\nvarying vec2 v_NodeUv;\n\nuniform sampler2D positionTex;\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_NodeUv).rg;\n vec2 forcePrev = texture2D(forcePrevTex, v_NodeUv).rg;\n\n float mass = texture2D(positionTex, v_NodeUv).z;\n float swing = length(force - forcePrev) * mass;\n float traction = length(force + forcePrev) * 0.5 * mass;\n\n gl_FragColor = vec4(swing, traction, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcGlobalSpeed\n\nuniform sampler2D globalSpeedPrevTex;\nuniform sampler2D weightedSumTex;\nuniform float jitterTolerence;\n\nvoid main() {\n vec2 weightedSum = texture2D(weightedSumTex, vec2(0.5)).xy;\n float prevGlobalSpeed = texture2D(globalSpeedPrevTex, vec2(0.5)).x;\n float globalSpeed = jitterTolerence * jitterTolerence\n * weightedSum.y / weightedSum.x;\n if (prevGlobalSpeed > 0.0) {\n globalSpeed = min(globalSpeed / prevGlobalSpeed, 1.5) * prevGlobalSpeed;\n }\n gl_FragColor = vec4(globalSpeed, 0.0, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updatePosition\n\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\nuniform sampler2D positionTex;\nuniform sampler2D globalSpeedTex;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_Texcoord).xy;\n vec2 forcePrev = texture2D(forcePrevTex, v_Texcoord).xy;\n vec4 node = texture2D(positionTex, v_Texcoord);\n\n float globalSpeed = texture2D(globalSpeedTex, vec2(0.5)).r;\n float swing = length(force - forcePrev);\n float speed = 0.1 * globalSpeed / (0.1 + globalSpeed * sqrt(swing));\n\n float df = length(force);\n if (df > 0.0) {\n speed = min(df * speed, 10.0) / df;\n\n gl_FragColor = vec4(node.xy + speed * force, node.zw);\n }\n else {\n gl_FragColor = node;\n }\n}\n@end\n\n@export ecgl.forceAtlas2.edges.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 node;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nuniform sampler2D positionTex;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(\n texture2D(positionTex, node).xy, -10.0, 1.0\n );\n v_Color = a_Color;\n}\n@end\n\n@export ecgl.forceAtlas2.edges.fragment\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nvarying vec4 v_Color;\nvoid main() {\n gl_FragColor = color * v_Color;\n}\n@end"},function(e,t,r){"use strict";var n=r(5),i=r(4),a=r(272),o=a.a.toString();o=o.slice(o.indexOf("{")+1,o.lastIndexOf("}"));var s={barnesHutOptimize:!0,barnesHutTheta:1.5,repulsionByDegree:!0,linLogMode:!1,strongGravityMode:!1,gravity:1,scaling:1,edgeWeightInfluence:1,jitterTolerence:.1,preventOverlap:!1,dissuadeHubs:!1,gravityCenter:null},u=function(e){for(var t in s)this[t]=s[t];if(e)for(var t in e)this[t]=e[t];this._nodes=[],this._edges=[],this._disposed=!1,this._positionTex=new n.a({type:i.a.FLOAT,flipY:!1,minFilter:i.a.NEAREST,magFilter:i.a.NEAREST})};u.prototype.initData=function(e,t){var r=new Blob([o]),n=window.URL.createObjectURL(r);this._worker=new Worker(n),this._worker.onmessage=this._$onupdate.bind(this),this._nodes=e,this._edges=t,this._frame=0;for(var i=e.length,a=t.length,s=new Float32Array(2*i),u=new Float32Array(i),l=new Float32Array(i),h=new Float32Array(2*a),c=new Float32Array(a),d=0;d5e4?10:a>5e3?1:.1,t.scaling=a>100?2:10,t.barnesHutOptimize=a>1e3,e)for(var r in s)null!=e[r]&&(t[r]=e[r]);if(!t.gravityCenter){for(var o=[1/0,1/0],u=[-1/0,-1/0],l=0;le},u.prototype.getNodePosition=function(e,t){if(t||(t=new Float32Array(2*this._nodes.length)),this._positionArr)for(var r=0;r0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},negate:function(e,t){return e[0]=-t[0],e[1]=-t[1],e},copy:function(e,t){return e[0]=t[0],e[1]=t[1],e},set:function(e,t,r){return e[0]=t,e[1]=r,e}},a=e.prototype;a.beforeUpdate=function(){for(var e=0;e=e&&this.bbox[1]<=t&&this.bbox[3]>=t},a.setBBox=function(e,t,r,n){this.bbox[0]=e,this.bbox[1]=t,this.bbox[2]=r,this.bbox[3]=n,this.size=(r-e+n-t)/2},a._newSubRegion=function(){var t=this.subRegions[this.nSubRegions];return t||(t=new e,this.subRegions[this.nSubRegions]=t),this.nSubRegions++,t},a._addNodeToSubRegion=function(e){var t=this.findSubRegion(e.position[0],e.position[1]),r=this.bbox;if(!t){var n=(r[0]+r[2])/2,i=(r[1]+r[3])/2,a=(r[2]-r[0])/2,o=(r[3]-r[1])/2,s=e.position[0]>=n?1:0,u=e.position[1]>=i?1:0,t=this._newSubRegion();t.setBBox(s*a+r[0],u*o+r[1],(s+1)*a+r[0],(u+1)*o+r[1])}t.addNode(e)},a._updateCenterOfMass=function(e){null==this.centerOfMass&&(this.centerOfMass=new Float32Array(2));var t=this.centerOfMass[0]*this.mass,r=this.centerOfMass[1]*this.mass;t+=e.position[0]*e.mass,r+=e.position[1]*e.mass,this.mass+=e.mass,this.centerOfMass[0]=t/this.mass,this.centerOfMass[1]=r/this.mass};var o=n.prototype;o.initNodes=function(e,r,n){var i=r.length;this.nodes.length=0;for(var a=void 0!==n,o=0;o0&&(this.strongGravityMode?this.applyNodeStrongGravity(n):this.applyNodeGravity(n))}for(var t=0;t0&&(c=Math.min(c/this._globalSpeed,1.5)*this._globalSpeed),this._globalSpeed=c;for(var t=0;t0&&(d=Math.min(f*d,10)/f,i.scaleAndAdd(r.position,r.position,r.force,d))}},o.applyRegionToNodeRepulsion=function(){var e=i.create();return function(t,r){if(t.node)this.applyNodeToNodeRepulsion(t.node,r,!0);else{i.sub(e,r.position,t.centerOfMass);var n=e[0]*e[0]+e[1]*e[1];if(n>this.barnesHutTheta*t.size*t.size){var a=this.scaling*r.mass*t.mass/n;i.scaleAndAdd(r.force,r.force,e,a)}else for(var o=0;o0)o=this.scaling*t.mass*r.mass/(s*s);else{if(!(s<0))return;o=100*this.scaling*t.mass*r.mass}}else o=this.scaling*t.mass*r.mass/a;i.scaleAndAdd(t.force,t.force,e,o),i.scaleAndAdd(r.force,r.force,e,-o)}}}}(),o.applyEdgeAttraction=function(){var e=i.create();return function(t){var r=t.source,n=t.target;i.sub(e,r.position,n.position);var a,o=i.len(e);a=0===this.edgeWeightInfluence?1:1===this.edgeWeightInfluence?t.weight:Math.pow(t.weight,this.edgeWeightInfluence);var s;this.preventOverlap&&(o=o-r.size-n.size)<=0||(s=this.linLogMode?-a*Math.log(o+1)/(o+1):-a,i.scaleAndAdd(r.force,r.force,e,s),i.scaleAndAdd(n.force,n.force,e,-s))}}(),o.applyNodeGravity=function(){var e=i.create();return function(t){i.sub(e,this.gravityCenter,t.position);var r=i.len(e);i.scaleAndAdd(t.force,t.force,e,this.gravity*t.mass/(r+1))}}(),o.applyNodeStrongGravity=function(){var e=i.create();return function(t){i.sub(e,this.gravityCenter,t.position),i.scaleAndAdd(t.force,t.force,e,this.gravity*t.mass)}}(),o.updateBBox=function(){for(var e=1/0,t=1/0,r=-1/0,n=-1/0,i=0;i0?1.1:.9,a=Math.max(Math.min(this._zoom*i,this.maxZoom),this.minZoom);i=a/this._zoom;var o=this._convertPos(r,n),s=(o.x-this._dx)*(i-1),u=(o.y-this._dy)*(i-1);this._dx-=s,this._dy-=u,this._zoom=a,this._needsUpdate=!0}}},dispose:function(){var e=this.zr;e.off("mousedown",this._mouseDownHandler),e.off("mousemove",this._mouseMoveHandler),e.off("mouseup",this._mouseUpHandler),e.off("mousewheel",this._mouseWheelHandler),e.off("globalout",this._mouseUpHandler),e.animation.off("frame",this._update)}}));t.a=i},function(e,t,r){"use strict";t.a="@export ecgl.lines2D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.vertex\n\nattribute vec2 position: POSITION;\nattribute vec2 normal;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n vec4 p2 = worldViewProjection * vec4(position + normal, -10.0, 1.0);\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n p2.xy /= p2.w;\n gl_Position.xy /= gl_Position.w;\n\n vec2 N = normalize(p2.xy - gl_Position.xy);\n gl_Position.xy += N * offset / viewport.zw * 2.0;\n\n gl_Position.xy *= gl_Position.w;\n\n v_Color = a_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n\n@end"},function(e,t,r){"use strict";var n=r(0);r.n(n),r(276),r(280)},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(1),o=r(2),s=r(22),u=r(277);i.a.extendChartView({type:"flowGL",__ecgl__:!0,init:function(e,t){this.viewGL=new s.a("orthographic"),this.groupGL=new a.a.Node,this.viewGL.add(this.groupGL),this._particleSurface=new u.a;var r=new a.a.Mesh({geometry:new a.a.PlaneGeometry,material:new a.a.Material({shader:new a.a.Shader({vertex:a.a.Shader.source("ecgl.color.vertex"),fragment:a.a.Shader.source("ecgl.color.fragment")}),transparent:!0})});r.material.enableTexture("diffuseMap"),this.groupGL.add(r),this._planeMesh=r},render:function(e,t,r){var n=this._particleSurface;n.setParticleType(e.get("particleType")),n.setSupersampling(e.get("supersampling")),this._updateData(e,r),this._updateCamera(r.getWidth(),r.getHeight(),r.getDevicePixelRatio());var i=o.a.firstNotNull(e.get("particleDensity"),128);n.setParticleDensity(i,i);var s=this._planeMesh,u=+new Date,l=this,h=!0;s.__percent=0,s.stopAnimation(),s.animate("",{loop:!0}).when(1e5,{__percent:1}).during(function(){var e=+new Date,t=Math.min(e-u,20);u+=t,l._renderer&&(n.update(l._renderer,r,t/1e3,h),s.material.set("diffuseMap",n.getSurfaceTexture())),h=!1}).start();var c=e.getModel("itemStyle"),d=a.a.parseColor(c.get("color"));d[3]*=o.a.firstNotNull(c.get("opacity"),1),s.material.set("color",d),n.setColorTextureImage(e.get("colorTexture"),r),n.setParticleSize(e.get("particleSize")),n.particleSpeedScaling=e.get("particleSpeed"),n.motionBlurFactor=1-Math.pow(.1,e.get("particleTrail"))},updateTransform:function(e,t,r){this._updateData(e,r)},afterRender:function(e,t,r,n){var i=n.renderer;this._renderer=i},_updateData:function(e,t){var r=e.coordinateSystem,n=r.dimensions.map(function(t){return e.coordDimToDataDim(t)[0]}),i=e.getData(),a=i.getDataExtent(n[0]),o=i.getDataExtent(n[1]),s=e.get("gridWidth"),u=e.get("gridHeight");if(null==s||"auto"===s){var l=(a[1]-a[0])/(o[1]-o[0]);s=Math.round(Math.sqrt(l*i.count()))}null!=u&&"auto"!==u||(u=Math.ceil(i.count()/s));var h=this._particleSurface.vectorFieldTexture,c=h.pixels;if(c&&c.length===u*s*4)for(var d=0;d=359&&(i[0]>0&&(i[0]=0),a[0]0?e[e.length-1]:this._lastFrameTexture},setRegion:function(e){this._particlePass.setUniform("region",e)},resize:function(e,t){this._lastFrameTexture.width=e*this._supersampling,this._lastFrameTexture.height=t*this._supersampling,this._thisFrameTexture.width=e*this._supersampling,this._thisFrameTexture.height=t*this._supersampling,this._width=e,this._height=t},setParticleSize:function(e){var t=this._getParticleMesh();if(e<=2)return t.material.disableTexture("spriteTexture"),void(t.material.transparent=!1);this._spriteTexture||(this._spriteTexture=new l.a),this._spriteTexture.image&&this._spriteTexture.image.width===e||(this._spriteTexture.image=n(e),this._spriteTexture.dirty()),t.material.transparent=!0,t.material.enableTexture("spriteTexture"),t.material.set("spriteTexture",this._spriteTexture),this._particleSize=e},setGradientTexture:function(e){var t=this._getParticleMesh().material;t[e?"enableTexture":"disableTexture"]("gradientTexture"),t.setUniform("gradientTexture",e)},setColorTextureImage:function(e,t){this._getParticleMesh().material.setTextureImage("colorTexture",e,t,{flipY:!0})},setParticleType:function(e){this._particleType=e},clearFrame:function(e){var t=this._frameBuffer;t.attach(this._lastFrameTexture),t.bind(e),e.gl.clear(e.gl.DEPTH_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),t.unbind(e)},setSupersampling:function(e){this._supersampling=e,this.resize(this._width,this._height)},_updateDownsampleTextures:function(e,t){for(var r=this._downsampleTextures,n=Math.max(Math.floor(Math.log(this._supersampling/t.getDevicePixelRatio())/Math.log(2)),0),i=2,a=this._width*this._supersampling,o=this._height*this._supersampling,s=0;s65535?new Uint32Array(3*n):new Uint16Array(3*n))},addLine:function(e){var t=this._vertexOffset;this.attributes.position.set(t,[e[0],e[1],1]),this.attributes.position.set(t+1,[e[0],e[1],-1]),this.attributes.position.set(t+2,[e[0],e[1],2]),this.attributes.position.set(t+3,[e[0],e[1],-2]),this.setTriangleIndices(this._faceOffset++,[t,t+1,t+2]),this.setTriangleIndices(this._faceOffset++,[t+1,t+2,t+3]),this._vertexOffset+=4}}));t.a=a},function(e,t,r){"use strict";t.a="@export ecgl.vfParticle.particle.fragment\n\nuniform sampler2D particleTexture;\nuniform sampler2D spawnTexture;\nuniform sampler2D velocityTexture;\n\nuniform float deltaTime;\nuniform float elapsedTime;\n\nuniform float speedScaling : 1.0;\n\nuniform vec2 textureSize;\nuniform vec4 region : [0, 0, 1, 1];\nuniform float firstFrameTime;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, v_Texcoord);\n bool spawn = false;\n if (p.w <= 0.0) {\n p = texture2D(spawnTexture, fract(v_Texcoord + elapsedTime / 10.0));\n p.w -= firstFrameTime;\n spawn = true;\n }\n vec2 v = texture2D(velocityTexture, fract(p.xy * region.zw + region.xy)).xy;\n v = (v - 0.5) * 2.0;\n p.z = length(v);\n p.xy += v * deltaTime / 10.0 * speedScaling;\n p.w -= deltaTime;\n\n if (spawn || p.xy != fract(p.xy)) {\n p.z = 0.0;\n }\n p.xy = fract(p.xy);\n\n gl_FragColor = p;\n}\n@end\n\n@export ecgl.vfParticle.renderPoints.vertex\n\n#define PI 3.1415926\n\nattribute vec2 texcoord : TEXCOORD_0;\n\nuniform sampler2D particleTexture;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nuniform float size : 1.0;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, texcoord);\n\n if (p.w > 0.0 && p.z > 1e-5) {\n gl_Position = worldViewProjection * vec4(p.xy * 2.0 - 1.0, 0.0, 1.0);\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n\n v_Mag = p.z;\n v_Uv = p.xy;\n\n gl_PointSize = size;\n}\n\n@end\n\n@export ecgl.vfParticle.renderPoints.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\nuniform sampler2D spriteTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n#ifdef SPRITETEXTURE_ENABLED\n gl_FragColor *= texture2D(spriteTexture, gl_PointCoord);\n if (color.a == 0.0) {\n discard;\n }\n#endif\n#ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.vertex\n\n#define PI 3.1415926\n\nattribute vec3 position : POSITION;\n\nuniform sampler2D particleTexture;\nuniform sampler2D prevParticleTexture;\n\nuniform float size : 1.0;\nuniform vec4 vp: VIEWPORT;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\n@import clay.util.rand\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, position.xy);\n vec4 p2 = texture2D(prevParticleTexture, position.xy);\n\n p.xy = p.xy * 2.0 - 1.0;\n p2.xy = p2.xy * 2.0 - 1.0;\n\n if (p.w > 0.0 && p.z > 1e-5) {\n vec2 dir = normalize(p.xy - p2.xy);\n vec2 norm = vec2(dir.y / vp.z, -dir.x / vp.w) * sign(position.z) * size;\n if (abs(position.z) == 2.0) {\n gl_Position = vec4(p.xy + norm, 0.0, 1.0);\n v_Uv = p.xy;\n v_Mag = p.z;\n }\n else {\n gl_Position = vec4(p2.xy + norm, 0.0, 1.0);\n v_Mag = p2.z;\n v_Uv = p2.xy;\n }\n gl_Position = worldViewProjection * gl_Position;\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n #ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n"},function(e,t,r){"use strict";var n=r(0),i=r.n(n);i.a.extendSeriesModel({type:"series.flowGL",dependencies:["geo","grid","bmap"],visualColorAccessPath:"itemStyle.color",getInitialData:function(e,t){var r=i.a.getCoordinateSystemDimensions(this.get("coordinateSystem"))||["x","y"];r.push("vx","vy");var n=i.a.helper.completeDimensions(r,this.getSource(),{encodeDef:this.get("encode"),dimsDef:this.get("dimensions")}),a=new i.a.List(n,this);return a.initData(this.getSource()),a},defaultOption:{coordinateSystem:"cartesian2d",zlevel:10,supersampling:1,particleType:"point",particleDensity:128,particleSize:1,particleSpeed:1,particleTrail:2,colorTexture:null,gridWidth:"auto",gridHeight:"auto",itemStyle:{color:"#fff",opacity:.8}}})},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=(r(282),r(283),r(17));i.a.registerVisual(Object(a.a)("linesGL"))},function(e,t,r){"use strict";var n=r(0),i=r.n(n),a=r(13),o=(r.n(a),i.a.extendSeriesModel({type:"series.linesGL",dependencies:["grid","geo"],visualColorAccessPath:"lineStyle.color",streamEnabled:!0,init:function(e){var t=this._processFlatCoordsArray(e.data);this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset,t.flatCoords&&(e.data=new Float32Array(t.count)),o.superApply(this,"init",arguments)},mergeOption:function(e){var t=this._processFlatCoordsArray(e.data);this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset,t.flatCoords&&(e.data=new Float32Array(t.count)),o.superApply(this,"mergeOption",arguments)},appendData:function(e){var t=this._processFlatCoordsArray(e.data);t.flatCoords&&(this._flatCoords?(this._flatCoords=Object(a.concatArray)(this._flatCoords,t.flatCoords),this._flatCoordsOffset=Object(a.concatArray)(this._flatCoordsOffset,t.flatCoordsOffset)):(this._flatCoords=t.flatCoords,this._flatCoordsOffset=t.flatCoordsOffset),e.data=new Float32Array(t.count)),this.getRawData().appendData(e.data)},_getCoordsFromItemModel:function(e){var t=this.getData().getItemModel(e),r=t.option instanceof Array?t.option:t.getShallow("coords");return r},getLineCoordsCount:function(e){return this._flatCoordsOffset?this._flatCoordsOffset[2*e+1]:this._getCoordsFromItemModel(e).length},getLineCoords:function(e,t){if(this._flatCoordsOffset){for(var r=this._flatCoordsOffset[2*e],n=this._flatCoordsOffset[2*e+1],i=0;i1?(t.material.shader!==this._meshLinesShader&&t.material.attachShader(this._meshLinesShader),t.mode=a.a.Mesh.TRIANGLES):(t.material.shader!==this._nativeLinesShader&&t.material.attachShader(this._nativeLinesShader),t.mode=a.a.Mesh.LINES),r=r||0,n=n||o.count(),h.resetOffset();var f=0,p=0,m=[],g=[],_=[],v=[],y=[],x=.3,T=.7;if(u||0!==s)for(var b=r;b