diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..4cd3d52 --- /dev/null +++ b/.npmignore @@ -0,0 +1,3 @@ +/editor +/examples +/screenshots \ No newline at end of file diff --git a/dist/QMV.js b/dist/QMV.js index 332af79..4305ba1 100644 --- a/dist/QMV.js +++ b/dist/QMV.js @@ -264,7 +264,7 @@ var notifier = { }, /** - * Alias of on('success') + * Remove event listener * @param {Function} action * @param {Object} [context] * @chainable @@ -580,7 +580,7 @@ function GLInfo(_gl) { * @memberOf qtek.core.glinfo */ this.getExtension = function (name) { - if (typeof(extensions[name]) == 'undefined') { + if (!(name in extensions)) { createExtension(name); } return extensions[name]; @@ -1106,8 +1106,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ (function(_global) { - "use strict"; - var shim = {}; { // gl-matrix lives in commonjs, define its namespaces in exports @@ -7616,19 +7614,19 @@ var SHADER_STATE_KEEP_ENABLE = 2; var SHADER_STATE_PENDING = 3; /** - * @constructor qtek.Shader + * @constructor * @extends qtek.core.Base - * + * @alias qtek.Shader * @example - * // Create a phong shader - * var shader = new qtek.Shader({ - * vertex: qtek.Shader.source('qtek.phong.vertex'), - * fragment: qtek.Shader.source('qtek.phong.fragment') - * }); - * // Enable diffuse texture - * shader.enableTexture('diffuseMap'); - * // Use alpha channel in diffuse texture - * shader.define('fragment', 'DIFFUSEMAP_ALPHA_ALPHA'); + * // Create a phong shader + * var shader = new qtek.Shader({ + * vertex: qtek.Shader.source('qtek.phong.vertex'), + * fragment: qtek.Shader.source('qtek.phong.fragment') + * }); + * // Enable diffuse texture + * shader.enableTexture('diffuseMap'); + * // Use alpha channel in diffuse texture + * shader.define('fragment', 'DIFFUSEMAP_ALPHA_ALPHA'); */ var Shader = Base.extend(function () { return /** @lends qtek.Shader# */ { @@ -7718,6 +7716,11 @@ var Shader = Base.extend(function () { }, /** @lends qtek.Shader.prototype */ { + /** + * If code is equal with given shader. + * @param {qtek.Shader} + * @return {boolean} + */ isEqual: function (otherShader) { if (!otherShader) { return false; @@ -7758,7 +7761,7 @@ var Shader = Base.extend(function () { /** * Bind shader program * Return true or error msg if error happened - * @param {WebGLRenderingContext} _gl + * @param {qtek.Renderer} renderer */ bind: function (renderer) { var cache = this._cache; @@ -7839,7 +7842,7 @@ var Shader = Base.extend(function () { }, /** - * Add a #define micro in shader code + * Add a #define macro in shader code * @param {string} shaderType Can be vertex, fragment or both * @param {string} symbol * @param {number} [val] @@ -7874,6 +7877,7 @@ var Shader = Base.extend(function () { }, /** + * Remove a #define macro in shader code * @param {string} shaderType Can be vertex, fragment or both * @param {string} symbol */ @@ -7903,6 +7907,7 @@ var Shader = Base.extend(function () { }, /** + * If macro is defined in shader. * @param {string} shaderType Can be vertex, fragment or both * @param {string} symbol */ @@ -7915,6 +7920,7 @@ var Shader = Base.extend(function () { } }, /** + * Get macro value defined in shader. * @param {string} shaderType Can be vertex, fragment or both * @param {string} symbol */ @@ -7927,7 +7933,7 @@ var Shader = Base.extend(function () { } }, /** - * Enable a texture, actually it will add a #define micro in the shader code + * 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 */ @@ -7960,7 +7966,7 @@ var Shader = Base.extend(function () { this.dirty(); }, /** - * Disable a texture, it remove a #define micro in the shader + * Disable a texture, it remove a #define macro in the shader * @param {string} symbol */ disableTexture: function (symbol) { @@ -7992,6 +7998,7 @@ var Shader = Base.extend(function () { this.dirty(); }, /** + * If texture of given type is enabled. * @param {string} symbol * @return {boolean} */ @@ -8001,6 +8008,10 @@ var Shader = Base.extend(function () { && textureStatus[symbol].enabled; }, + /** + * Get all enabled textures + * @return {string[]} + */ getEnabledTextures: function () { var enabledTextures = []; var textureStatus = this._textureStatus; @@ -8746,7 +8757,6 @@ Shader.codes = {}; * Get shader source * @param {string} name * @return {string} - * @memberOf qtek.Shader */ Shader.source = function (name) { var parts = name.split('.'); @@ -8794,9 +8804,9 @@ function ShaderLibrary () { * @return {qtek.Shader} * * @example - * qtek.shader.library.get('qtek.phong', 'diffuseMap', 'normalMap'); - * qtek.shader.library.get('qtek.phong', ['diffuseMap', 'normalMap']); - * qtek.shader.library.get('qtek.phong', { + * qtek.shader.library.get('qtek.standard', 'diffuseMap', 'normalMap'); + * qtek.shader.library.get('qtek.standard', ['diffuseMap', 'normalMap']); + * qtek.shader.library.get('qtek.standard', { * textures: ['diffuseMap'], * vertexDefines: {}, * fragmentDefines: {} @@ -8897,7 +8907,13 @@ function template(name, vertex, fragment) { var defaultLibrary = new ShaderLibrary(); +/** + * @alias qtek.shader.library + */ var library = { + /** + * Create a new shader library. + */ createLibrary: function () { return new ShaderLibrary(); }, @@ -8915,49 +8931,81 @@ var library = { * TODO mapping */ /** - * @constructor qtek.Texture + * @constructor + * @alias qtek.Texture * @extends qtek.core.Base */ var Texture = Base.extend( /** @lends qtek.Texture# */ { /** - * Texture width, only needed when the texture is used as a render target + * Texture width, readonly when the texture source is image * @type {number} */ width: 512, /** - * Texture height, only needed when the texture is used as a render target + * Texture height, readonly when the texture source is image * @type {number} */ height: 512, /** - * Texel data type + * Texel data type. + * Possible values: + * + {@link qtek.Texture.UNSIGNED_BYTE} + * + {@link qtek.Texture.HALF_FLOAT} + * + {@link qtek.Texture.FLOAT} + * + {@link qtek.Texture.UNSIGNED_INT_24_8_WEBGL} + * + {@link qtek.Texture.UNSIGNED_INT} * @type {number} */ type: glenum.UNSIGNED_BYTE, /** * Format of texel data + * Possible values: + * + {@link qtek.Texture.RGBA} + * + {@link qtek.Texture.DEPTH_COMPONENT} + * + {@link qtek.Texture.DEPTH_STENCIL} * @type {number} */ format: glenum.RGBA, /** + * Texture wrap. Default to be REPEAT. + * Possible values: + * + {@link qtek.Texture.CLAMP_TO_EDGE} + * + {@link qtek.Texture.REPEAT} + * + {@link qtek.Texture.MIRRORED_REPEAT} * @type {number} */ wrapS: glenum.REPEAT, /** + * Texture wrap. Default to be REPEAT. + * Possible values: + * + {@link qtek.Texture.CLAMP_TO_EDGE} + * + {@link qtek.Texture.REPEAT} + * + {@link qtek.Texture.MIRRORED_REPEAT} * @type {number} */ wrapT: glenum.REPEAT, /** + * Possible values: + * + {@link qtek.Texture.NEAREST} + * + {@link qtek.Texture.LINEAR} + * + {@link qtek.Texture.NEAREST_MIPMAP_NEAREST} + * + {@link qtek.Texture.LINEAR_MIPMAP_NEAREST} + * + {@link qtek.Texture.NEAREST_MIPMAP_LINEAR} + * + {@link qtek.Texture.LINEAR_MIPMAP_LINEAR} * @type {number} */ minFilter: glenum.LINEAR_MIPMAP_LINEAR, /** + * Possible values: + * + {@link qtek.Texture.NEAREST} + * + {@link qtek.Texture.LINEAR} * @type {number} */ magFilter: glenum.LINEAR, /** + * If enable mimap. * @type {boolean} */ useMipmap: true, @@ -8971,15 +9019,19 @@ var Texture = Base.extend( // 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, /** * @type {number} + * @default 4 */ unpackAlignment: 4, /** * @type {boolean} + * @default false */ premultiplyAlpha: false, @@ -9043,7 +9095,7 @@ var Texture = Base.extend( this.useMipmap = false; } - var sRGBExt = renderer.getGLExtension( 'EXT_sRGB'); + var sRGBExt = renderer.getGLExtension('EXT_sRGB'); // Fallback if (this.format === Texture.SRGB && !sRGBExt) { this.format = Texture.RGB; @@ -9121,6 +9173,10 @@ var Texture = Base.extend( */ isRenderable: function () {}, + /** + * Test if texture size is power of two + * @return {boolean} + */ isPowerOfTwo: function () {} }); @@ -9142,29 +9198,85 @@ Object.defineProperty(Texture.prototype, 'height', { }); /* DataType */ + +/** + * @type {number} + */ Texture.BYTE = glenum.BYTE; +/** + * @type {number} + */ Texture.UNSIGNED_BYTE = glenum.UNSIGNED_BYTE; +/** + * @type {number} + */ Texture.SHORT = glenum.SHORT; +/** + * @type {number} + */ Texture.UNSIGNED_SHORT = glenum.UNSIGNED_SHORT; +/** + * @type {number} + */ Texture.INT = glenum.INT; +/** + * @type {number} + */ Texture.UNSIGNED_INT = glenum.UNSIGNED_INT; +/** + * @type {number} + */ Texture.FLOAT = glenum.FLOAT; +/** + * @type {number} + */ Texture.HALF_FLOAT = 0x8D61; -// ext.UNSIGNED_INT_24_8_WEBGL for WEBGL_depth_texture extension +/** + * UNSIGNED_INT_24_8_WEBGL for WEBGL_depth_texture extension + * @type {number} + */ Texture.UNSIGNED_INT_24_8_WEBGL = 34042; /* PixelFormat */ +/** + * @type {number} + */ Texture.DEPTH_COMPONENT = glenum.DEPTH_COMPONENT; +/** + * @type {number} + */ Texture.DEPTH_STENCIL = glenum.DEPTH_STENCIL; +/** + * @type {number} + */ Texture.ALPHA = glenum.ALPHA; +/** + * @type {number} + */ Texture.RGB = glenum.RGB; +/** + * @type {number} + */ Texture.RGBA = glenum.RGBA; +/** + * @type {number} + */ Texture.LUMINANCE = glenum.LUMINANCE; +/** + * @type {number} + */ Texture.LUMINANCE_ALPHA = glenum.LUMINANCE_ALPHA; -// https://www.khronos.org/registry/webgl/extensions/EXT_sRGB/ +/** + * @see https://www.khronos.org/registry/webgl/extensions/EXT_sRGB/ + * @type {number} + */ Texture.SRGB = 0x8C40; +/** + * @see https://www.khronos.org/registry/webgl/extensions/EXT_sRGB/ + * @type {number} + */ Texture.SRGB_ALPHA = 0x8C42; /* Compressed Texture */ @@ -9174,24 +9286,45 @@ Texture.COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2; Texture.COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3; /* TextureMagFilter */ +/** + * @type {number} + */ Texture.NEAREST = glenum.NEAREST; +/** + * @type {number} + */ Texture.LINEAR = glenum.LINEAR; /* TextureMinFilter */ -/* NEAREST */ -/* LINEAR */ +/** + * @type {number} + */ Texture.NEAREST_MIPMAP_NEAREST = glenum.NEAREST_MIPMAP_NEAREST; +/** + * @type {number} + */ Texture.LINEAR_MIPMAP_NEAREST = glenum.LINEAR_MIPMAP_NEAREST; +/** + * @type {number} + */ Texture.NEAREST_MIPMAP_LINEAR = glenum.NEAREST_MIPMAP_LINEAR; +/** + * @type {number} + */ Texture.LINEAR_MIPMAP_LINEAR = glenum.LINEAR_MIPMAP_LINEAR; -/* TextureParameterName */ -// Texture.TEXTURE_MAG_FILTER = glenum.TEXTURE_MAG_FILTER; -// Texture.TEXTURE_MIN_FILTER = glenum.TEXTURE_MIN_FILTER; - /* TextureWrapMode */ +/** + * @type {number} + */ Texture.REPEAT = glenum.REPEAT; +/** + * @type {number} + */ Texture.CLAMP_TO_EDGE = glenum.CLAMP_TO_EDGE; +/** + * @type {number} + */ Texture.MIRRORED_REPEAT = glenum.MIRRORED_REPEAT; /** @@ -9263,13 +9396,6 @@ var Material = Base.extend( /** @lends qtek.Material.prototype */ { - /** - * @param {WebGLRenderingContext} renderer - * @param {qtek.Shader} [shader] - * @param {qtek.Material} [prevMaterial] - * @param {qtek.Shader} [prevShader] - * @return {Object} - */ bind: function(renderer, shader, prevMaterial, prevShader) { var _gl = renderer.gl; // PENDING Same texture in different material take different slot? @@ -9383,6 +9509,9 @@ var Material = Base.extend( }, /** + * Set material uniform + * @example + * mat.setUniform('color', [1, 1, 1, 1]); * @param {string} symbol * @param {number|array|qtek.Texture|ArrayBufferView} value */ @@ -9406,11 +9535,11 @@ var Material = Base.extend( } }, - /** - * Enable a uniform - * It only have effect on the uniform exists in shader. - * @param {string} symbol - */ + // /** + // * Enable a uniform + // * It only have effect on the uniform exists in shader. + // * @param {string} symbol + // */ // enableUniform: function (symbol) { // if (this.uniforms[symbol] && !this.isUniformEnabled(symbol)) { // this._enabledUniforms.push(symbol); @@ -10545,6 +10674,7 @@ var Renderer = Base.extend(function () { /** * Get viewport aspect, + * @return {number} */ getViewportAspect: function () { var viewport = this.viewport; @@ -10791,6 +10921,11 @@ var Renderer = Base.extend(function () { this._currentShader = null; }, + /** + * Callback during rendering process to determine if render given renderable. + * @param {qtek.Renderable} given renderable. + * @return {boolean} + */ ifRenderObject: function (obj) { return true; }, @@ -11230,8 +11365,7 @@ var Renderer = Base.extend(function () { /** * Dispose renderer */ - dispose: function () { - }, + dispose: function () {}, /** * Convert screen coords to normalized device coordinates(NDC) @@ -11341,8 +11475,20 @@ var matrices = { WORLDVIEWPROJECTIONINVERSETRANSPOSE: mat4Create() }; +/** + * @name qtek.Renderer.COLOR_BUFFER_BIT + * @type {number} + */ Renderer.COLOR_BUFFER_BIT = glenum.COLOR_BUFFER_BIT; +/** + * @name qtek.Renderer.DEPTH_BUFFER_BIT + * @type {number} + */ Renderer.DEPTH_BUFFER_BIT = glenum.DEPTH_BUFFER_BIT; +/** + * @name qtek.Renderer.STENCIL_BUFFER_BIT + * @type {number} + */ Renderer.STENCIL_BUFFER_BIT = glenum.STENCIL_BUFFER_BIT; function get(options) { @@ -12223,9 +12369,15 @@ var Node = Base.extend( * @private */ _scene: null, - + /** + * @type {boolean} + * @private + */ _needsUpdateWorldTransform: true, - + /** + * @type {boolean} + * @private + */ _inIterating: false, // Depth for transparent queue sorting @@ -12257,21 +12409,20 @@ var Node = Base.extend( { /** - * @memberOf qtek.Node - * @type {qtek.math.Vector3} + * @type {?qtek.math.Vector3} * @instance */ target: null, /** * If node and its chilren invisible * @type {boolean} - * @memberOf qtek.Node * @instance */ invisible: false, /** - * Return if Node is a skinned mesh + * If Node is a skinned mesh + * @return {boolean} */ isSkinnedMesh: function () { return false; @@ -12406,13 +12557,18 @@ var Node = Base.extend( }, /** - * Get a new created array of all its children nodes + * Get a new created array of all children nodes * @return {qtek.Node[]} */ children: function () { return this._children.slice(); }, + /** + * Get child scene node at given index. + * @param {number} idx + * @return {qtek.Node} + */ childAt: function (idx) { return this._children[idx]; }, @@ -12455,6 +12611,8 @@ var Node = Base.extend( * Query descendant node by path * @param {string} path * @return {qtek.Node} + * @example + * node.queryNode('root/parent/child'); */ queryNode: function (path) { if (!path) { @@ -12490,6 +12648,7 @@ var Node = Base.extend( /** * Get query path, relative to rootNode(default is scene) + * @param {qtek.Node} [rootNode] * @return {string} */ getPath: function (rootNode) { @@ -12630,6 +12789,7 @@ var Node = Base.extend( /** * Update world transform, assume its parent world transform have been updated + * @private */ _updateWorldTransformTopDown: function () { var localTransform = this.localTransform._array; @@ -12646,7 +12806,9 @@ var Node = Base.extend( } }, - // Update world transform before whole scene is updated. + /** + * Update world transform before whole scene is updated. + */ updateWorldTransform: function () { // Find the root node which transform needs update; var rootNodeIsDirty = this; @@ -12654,8 +12816,7 @@ var Node = Base.extend( && rootNodeIsDirty.getParent().transformNeedsUpdate() ) { rootNodeIsDirty = rootNodeIsDirty.getParent(); - } - rootNodeIsDirty.update(); + }rootNodeIsDirty.update(); }, /** @@ -12695,14 +12856,24 @@ var Node = Base.extend( return !el.invisible && el.geometry; } var tmpBBox = new BoundingBox(); + var tmpMat4 = new Matrix4(); + var invWorldTransform = new Matrix4(); return function (filter, out) { out = out || new BoundingBox(); filter = filter || defaultFilter; + if (this._parent) { + Matrix4.invert(invWorldTransform, this._parent.worldTransform); + } + else { + Matrix4.identity(invWorldTransform); + } + this.traverse(function (mesh) { if (mesh.geometry && mesh.geometry.boundingBox) { tmpBBox.copy(mesh.geometry.boundingBox); - tmpBBox.applyTransform(mesh.worldTransform); + Matrix4.multiply(tmpMat4, invWorldTransform, mesh.worldTransform); + tmpBBox.applyTransform(tmpMat4); out.union(tmpBBox); } }, this, defaultFilter); @@ -12734,8 +12905,6 @@ var Node = Base.extend( } }, - // TODO Set world transform - /** * Clone a new node * @return {Node} @@ -12793,7 +12962,6 @@ var Node = Base.extend( * @see http://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml * @method */ - // TODO world space ? lookAt: (function () { var m = new Matrix4(); return function (target, up) { @@ -12877,7 +13045,7 @@ var Scene = Node.extend(function () { return /** @lends qtek.Scene# */ { /** * Global material of scene - * @type {Material} + * @type {qtek.Material} */ material: null, @@ -12888,14 +13056,14 @@ var Scene = Node.extend(function () { /** * Opaque renderable list, it will be updated automatically - * @type {Renderable[]} + * @type {qtek.Renderable[]} * @readonly */ opaqueQueue: [], /** * Opaque renderable list, it will be updated automatically - * @type {Renderable[]} + * @type {qtek.Renderable[]} * @readonly */ transparentQueue: [], @@ -13335,132 +13503,122 @@ function releaseShader(shader, renderer) { } } +/** + * Standard material without custom shader. + * @constructor qtek.StandardMaterial + * @extends qtek.Base + * @example + * var mat = new qtek.StandardMaterial({ + * color: [1, 1, 1], + * diffuseMap: diffuseTexture + * }); + * mat.roughness = 1; + */ var StandardMaterial = Material.extend(function () { - return { + return /** @lends qtek.StandardMaterial# */ { /** * @type {Array.} - * @name color * @default [1, 1, 1] */ color: [1, 1, 1], /** * @type {Array.} - * @name emission * @default [0, 0, 0] */ emission: [0, 0, 0], /** * @type {number} - * @name emissionIntensity * @default 0 */ emissionIntensity: 0, /** * @type {number} - * @name roughness * @default 0.5 */ roughness: 0.5, /** * @type {number} - * @name metalness * @default 0 */ metalness: 0, /** * @type {number} - * @name alpha * @default 1 */ alpha: 1, /** * @type {boolean} - * @name alphaTest */ alphaTest: false, /** * Cutoff threshold for alpha test * @type {number} - * @name alphaCutoff */ alphaCutoff: 0.9, /** * @type {boolean} - * @name doubleSided */ // TODO Must disable culling. doubleSided: false, /** * @type {qtek.Texture2D} - * @name diffuseMap */ /** * @type {qtek.Texture2D} - * @name normalMap */ /** * @type {qtek.Texture2D} - * @name roughnessMap */ /** * @type {qtek.Texture2D} - * @name metalnessMap */ /** * @type {qtek.Texture2D} - * @name emissiveMap */ /** * @type {qtek.TextureCube} - * @name environmentMap */ /** * @type {qtek.math.BoundingBox} - * @name environmentBox */ /** * BRDF Lookup is generated by qtek.util.cubemap.integrateBrdf * @type {qtek.Texture2D} - * @name brdfLookup */ /** * @type {qtek.Texture2D} - * @name ssaoMap */ /** * @type {qtek.Texture2D} - * @name aoMap */ /** * @type {Array.} - * @name uvRepeat * @default [1, 1] */ uvRepeat: [1, 1], /** * @type {Array.} - * @name uvOffset * @default [0, 0] */ uvOffset: [0, 0], @@ -13473,7 +13631,6 @@ var StandardMaterial = Material.extend(function () { /** * @type {number} - * @name jointCount * @default 0 */ // FIXME Redundant with mesh @@ -13481,36 +13638,30 @@ var StandardMaterial = Material.extend(function () { /** * @type {boolean} - * @name environmentMapPrefiltered */ environmentMapPrefiltered: false, /** * @type {boolean} - * @name linear */ linear: false, /** * @type {boolean} - * @name encodeRGBM */ encodeRGBM: false, /** * @type {boolean} - * @name decodeRGBM */ decodeRGBM: false, /** * @type {Number} - * @name {roughnessChannel} */ roughnessChannel: 0, /** * @type {Number} - * @name {metalnessChannel} */ metalnessChannel: 1 }; @@ -13684,6 +13835,10 @@ Object.defineProperty(StandardMaterial.prototype, 'environmentBox', { Object.defineProperty(StandardMaterial.prototype, 'shader', { get: function () { // FIXME updateShader needs gl context. + if (!this._shader) { + // this._shaderDirty = true; + // this.updateShader(); + } return this._shader; }, set: function () { @@ -13716,7 +13871,8 @@ function VertexArrayObject( this.vao = null; } /** - * @constructor qtek.Renderable + * @constructor + * @alias qtek.Renderable * @extends qtek.Node */ var Renderable = Node.extend( @@ -13759,20 +13915,32 @@ var Renderable = Node.extend( lineWidth: 1, /** + * If enable culling * @type {boolean} */ culling: true, /** + * Specify which side of polygon will be culled. + * Possible values: + * + {@link qtek.Renderable.BACK} + * + {@link qtek.Renderable.FRONT} + * + {@link qtek.Renderable.FRONT_AND_BACK} + * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/cullFace * @type {number} */ cullFace: glenum.BACK, /** + * Specify which side is front face. + * Possible values: + * + {@link qtek.Renderable.CW} + * + {@link qtek.Renderable.CCW} + * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/frontFace * @type {number} */ frontFace: glenum.CCW, /** - * Software frustum culling + * If enable software frustum culling * @type {boolean} */ frustumCulling: true, @@ -13810,14 +13978,12 @@ var Renderable = Node.extend( /** * Before render hook * @type {Function} - * @memberOf qtek.Renderable */ beforeRender: function (_gl) {}, /** * Before render hook * @type {Function} - * @memberOf qtek.Renderable */ afterRender: function (_gl, renderStat) {}, @@ -14040,7 +14206,9 @@ var Renderable = Node.extend( var properties = [ 'castShadow', 'receiveShadow', 'mode', 'culling', 'cullFace', 'frontFace', - 'frustumCulling' + 'frustumCulling', + 'renderOrder', 'lineWidth', + 'ignorePicking', 'ignorePreZ', 'ignoreGBuffer' ]; return function() { var renderable = Node.prototype.clone.call(this); @@ -14061,23 +14229,53 @@ var Renderable = Node.extend( })() }); -Renderable.beforeFrame = function() { - prevDrawID = 0; -}; - -// Enums +/** + * @type {number} + */ Renderable.POINTS = glenum.POINTS; +/** + * @type {number} + */ Renderable.LINES = glenum.LINES; +/** + * @type {number} + */ Renderable.LINE_LOOP = glenum.LINE_LOOP; +/** + * @type {number} + */ Renderable.LINE_STRIP = glenum.LINE_STRIP; +/** + * @type {number} + */ Renderable.TRIANGLES = glenum.TRIANGLES; +/** + * @type {number} + */ Renderable.TRIANGLE_STRIP = glenum.TRIANGLE_STRIP; +/** + * @type {number} + */ Renderable.TRIANGLE_FAN = glenum.TRIANGLE_FAN; - +/** + * @type {number} + */ Renderable.BACK = glenum.BACK; +/** + * @type {number} + */ Renderable.FRONT = glenum.FRONT; +/** + * @type {number} + */ Renderable.FRONT_AND_BACK = glenum.FRONT_AND_BACK; +/** + * @type {number} + */ Renderable.CW = glenum.CW; +/** + * @type {number} + */ Renderable.CCW = glenum.CCW; Renderable.RenderInfo = RenderInfo; @@ -14129,11 +14327,12 @@ var isPowerOfTwo = mathUtil.isPowerOfTwo; var Texture2D = Texture.extend(function () { return /** @lends qtek.Texture2D# */ { /** - * @type {HTMLImageElement|HTMLCanvasElemnet} + * @type {?HTMLImageElement|HTMLCanvasElemnet} */ image: null, /** - * @type {Uint8Array|Float32Array} + * Pixels data. Will be ignored if image is set. + * @type {?Uint8Array|Float32Array} */ pixels: null, /** @@ -14346,6 +14545,7 @@ var Mesh = Renderable.extend( /** * If store the skin matrices in vertex texture + * @type {bool} */ useSkinMatricesTexture: false @@ -15492,6 +15692,7 @@ var Camera = Node.extend(function () { /** * Set camera projection matrix + * @param {qtek.math.Matrix4} projectionMatrix */ setProjectionMatrix: function (projectionMatrix) { Matrix4.copy(this.projectionMatrix, projectionMatrix); @@ -16243,11 +16444,16 @@ Clip.prototype = { return clip; }, - + /** + * Pause the clip. + */ pause: function () { this._paused = true; }, + /** + * Resume the clip. + */ resume: function () { this._paused = false; } @@ -16258,6 +16464,8 @@ var quat$3 = glmatrix.quat; var vec3$9 = glmatrix.vec3; /** + * + * Animation clip that manage a collection of {@link qtek.animation.SamplerTrack} * @constructor * @alias qtek.animation.TrackClip * @@ -16274,6 +16482,7 @@ var vec3$9 = glmatrix.vec3; * @param {function} [opts.onframe] * @param {function} [opts.onfinish] * @param {function} [opts.onrestart] + * @param {Array.} [opts.tracks] */ var TrackClip = function (opts) { @@ -16281,6 +16490,10 @@ var TrackClip = function (opts) { Clip.call(this, opts); + /** + * + * @type {qtek.animation.SamplerTrack[]} + */ this.tracks = opts.tracks || []; }; @@ -16336,14 +16549,14 @@ TrackClip.prototype.calcLifeFromTracks = function () { }; /** - * @param {qtek.animation.TransformTrack|qtek.animation.SamplerTrack} jointClip + * @param {qtek.animation.SamplerTrack} jointClip */ TrackClip.prototype.addTrack = function (track) { this.tracks.push(track); }; /** - * @param {qtek.animation.TransformTrack|qtek.animation.SamplerTrack} jointClip + * @param {qtek.animation.SamplerTrack} jointClip */ TrackClip.prototype.removeTarck = function (track) { var idx = this.tracks.indexOf(track); @@ -16378,7 +16591,7 @@ TrackClip.prototype.getSubClip = function (startTime, endTime, isLoop) { }; /** - * 1d blending between two skinning clips + * 1d blending from two skinning clips * @param {qtek.animation.TrackClip} clip1 * @param {qtek.animation.TrackClip} clip2 * @param {number} w @@ -16394,7 +16607,7 @@ TrackClip.prototype.blend1D = function (clip1, clip2, w) { }; /** - * Additive blending between two skinning clips + * Additive blending from two skinning clips * @param {qtek.animation.TrackClip} clip1 * @param {qtek.animation.TrackClip} clip2 */ @@ -16409,7 +16622,7 @@ TrackClip.prototype.additiveBlend = function (clip1, clip2) { }; /** - * Subtractive blending between two skinning clips + * Subtractive blending from two skinning clips * @param {qtek.animation.TrackClip} clip1 * @param {qtek.animation.TrackClip} clip2 */ @@ -16424,7 +16637,7 @@ TrackClip.prototype.subtractiveBlend = function (clip1, clip2) { }; /** - * 2D blending between three skinning clips + * 2D blending from three skinning clips * @param {qtek.animation.TrackClip} clip1 * @param {qtek.animation.TrackClip} clip2 * @param {qtek.animation.TrackClip} clip3 @@ -16473,13 +16686,6 @@ function keyframeSort(a, b) { return a.time - b.time; } -/** - * @constructor - * @alias qtek.animation.TransformTrack - * @extends qtek.animation.Clip - * - * @param {object[]} [opts.keyFrames] - */ var TransformTrack = function (opts) { this.name = opts.name || ''; @@ -16786,6 +16992,14 @@ function quatSlerp(out, a, b, t, oa, ob) { return out; } +/** + * SamplerTrack manages `position`, `rotation`, `scale` tracks in animation of single scene node. + * @constructor + * @alias qtek.animation.SamplerTrack + * @param {Object} [opts] + * @param {string} [opts.name] Track name + * @param {qtek.Node} [opts.target] Target node's transform will updated automatically + */ var SamplerTrack = function (opts) { opts = opts || {}; @@ -16896,6 +17110,9 @@ SamplerTrack.prototype.setTime = function (time) { this.updateTarget(); }; +/** + * Update transform of target node manually + */ SamplerTrack.prototype.updateTarget = function () { var channels = this.channels; if (this.target) { @@ -17063,6 +17280,13 @@ SamplerTrack.prototype.clone = function () { }; +var vec3$12 = glmatrix.vec3; +var mat4$6 = glmatrix.mat4; + +var vec3Create = vec3$12.create; +var vec3Add = vec3$12.add; +var vec3Set$2 = vec3$12.set; + function getArrayCtorByType (type) { return ({ 'byte': vendor.Int8Array, @@ -17072,29 +17296,63 @@ function getArrayCtorByType (type) { })[type] || vendor.Float32Array; } +function makeAttrKey(attrName) { + return 'attr_' + attrName; +} +/** + * Geometry attribute + * @alias qtek.Geometry.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; - if (semantic) { - this.semantic = semantic; - } -} -Attribute.prototype.clone = function(copyValue) { - var ret = new this.constructor(this.name, this.type, this.size, this.semantic); - // FIXME - if (copyValue) { - console.warn('todo'); - } - return ret; -}; + /** + * 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 || ''; - -/** - * Attribute for static geometry - */ -function StaticAttribute$1 (name, type, size, semantic) { - Attribute.call(this, name, type, size, semantic); + /** + * Value of the attribute. + * @type {TypedArray} + */ this.value = null; // Init getter setter @@ -17187,16 +17445,49 @@ function StaticAttribute$1 (name, type, size, semantic) { } } -StaticAttribute$1.prototype.constructor = new Attribute(); +/** + * Set item value at give index. Second parameter val is number if size is 1 + * @method + * @name qtek.Geometry.Attribute#set + * @param {number} idx + * @param {number[]|number} val + * @example + * geometry.getAttribute('position').set(0, [1, 1, 1]); + */ + +/** + * Get item value at give index. Second parameter out is no need if size is 1 + * @method + * @name qtek.Geometry.Attribute#set + * @param {number} idx + * @param {number[]} [out] + * @example + * geometry.getAttribute('position').get(0, out); + */ -StaticAttribute$1.prototype.init = function (nVertex) { +/** + * 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); } }; -StaticAttribute$1.prototype.fromArray = function (array) { +/** + * 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 @@ -17216,6 +17507,15 @@ StaticAttribute$1.prototype.fromArray = function (array) { this.value = value; }; +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; +}; + function AttributeBuffer(name, type, buffer, size, semantic) { this.name = name; this.type = type; @@ -17236,36 +17536,63 @@ function IndicesBuffer(buffer) { this.count = 0; } -function notImplementedWarn() { - console.warn('Geometry doesn\'t implement this method, use StaticGeometry instead'); -} - /** * @constructor qtek.Geometry * @extends qtek.core.Base */ -var Geometry = Base.extend( -/** @lends qtek.Geometry# */ -{ - /** - * @type {qtek.math.BoundingBox} - */ - boundingBox : null, - - /** - * Vertex attributes - * @type {Object} - */ - attributes : {}, +var Geometry = Base.extend(function () { + return /** @lends qtek.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 {qtek.math.BoundingBox} + */ + boundingBox: null, - indices : null, + /** + * Indices of geometry. + * @type {Uint16Array|Uint32Array} + */ + indices: null, - /** - * Is vertices data dynamically updated - * @type {boolean} - */ - dynamic: false, + /** + * Is vertices data dynamically updated. + * Attributes value can't be changed after first render if dyanmic is false. + * @type {boolean} + */ + dynamic: true, + _enabledAttributes: null + }; }, function() { // Use cache this._cache = new Cache(); @@ -17274,170 +17601,35 @@ var Geometry = Base.extend( }, /** @lends qtek.Geometry.prototype */ { - /** - * User defined ray picking algorithm instead of default - * triangle ray intersection - * x, y are NDC. - * (x, y, renderer, camera, renderable, out) => boolean - * @type {Function} - */ - pickByRay: null, - - /** - * User defined picking algorithm instead of default - * triangle ray intersection - * (ray: qtek.math.Ray, renderable: qtek.Renderable, out: Array) => boolean - * @type {Function} - */ - pick: null, - /** * Main attribute will be used to count vertex number * @type {string} */ mainAttribute: 'position', /** - * Mark attributes in geometry is dirty - * @method - */ - dirty: notImplementedWarn, - /** - * Create a new attribute - * @method - * @param {string} name - * @param {string} type - * @param {number} size - * @param {string} [semantic] - */ - createAttribute: notImplementedWarn, - /** - * Remove attribute - * @method - * @param {string} name - */ - removeAttribute: notImplementedWarn, - - /** - * @method - * @param {number} idx - * @param {Array.} out - * @return {Array.} + * User defined picking algorithm instead of default + * triangle ray intersection + * x, y are NDC. + * ```typescript + * (x, y, renderer, camera, renderable, out) => boolean + * ``` + * @type {?Function} */ - getTriangleIndices: notImplementedWarn, + pick: null, /** - * @method - * @param {number} idx - * @param {Array.} face - */ - setTriangleIndices: notImplementedWarn, - /** - * @method - * @return {boolean} + * User defined ray picking algorithm instead of default + * triangle ray intersection + * ```typescript + * (ray: qtek.math.Ray, renderable: qtek.Renderable, out: Array) => boolean + * ``` + * @type {?Function} */ - isUseIndices: notImplementedWarn, - - getEnabledAttributes: notImplementedWarn, - getBufferChunks: notImplementedWarn, + pickByRay: null, /** - * @method - */ - generateVertexNormals: notImplementedWarn, - /** - * @method - */ - generateFaceNormals: notImplementedWarn, - /** - * @method - * @return {boolean} - */ - isUniqueVertex: notImplementedWarn, - /** - * @method - */ - generateUniqueVertex: notImplementedWarn, - /** - * @method - */ - generateTangents: notImplementedWarn, - /** - * @method - */ - generateBarycentric: notImplementedWarn, - /** - * @method - * @param {qtek.math.Matrix4} matrix - */ - applyTransform: notImplementedWarn, - /** - * @method - * @param {WebGLRenderingContext} [gl] + * Update boundingBox of Geometry */ - dispose: notImplementedWarn -}); - -Geometry.STATIC_DRAW = glenum.STATIC_DRAW; -Geometry.DYNAMIC_DRAW = glenum.DYNAMIC_DRAW; -Geometry.STREAM_DRAW = glenum.STREAM_DRAW; - -Geometry.AttributeBuffer = AttributeBuffer; -Geometry.IndicesBuffer = IndicesBuffer; -Geometry.Attribute = Attribute; -Geometry.StaticAttribute = StaticAttribute$1; - -/** - * StaticGeometry can not be changed once they've been setup - */ -var mat4$6 = glmatrix.mat4; -var vec3$12 = glmatrix.vec3; - -var StaticAttribute = Geometry.StaticAttribute; -var vec3Create = vec3$12.create; -var vec3Add = vec3$12.add; -var vec3Set$2 = vec3$12.set; - -function makeAttrKey(attrName) { - return 'attr_' + attrName; -} -/** - * @constructor qtek.StaticGeometry - * @extends qtek.Geometry - */ -var StaticGeometry = Geometry.extend(function () { - return /** @lends qtek.StaticGeometry# */ { - attributes: { - position: new StaticAttribute('position', 'float', 3, 'POSITION'), - texcoord0: new StaticAttribute('texcoord0', 'float', 2, 'TEXCOORD_0'), - texcoord1: new StaticAttribute('texcoord1', 'float', 2, 'TEXCOORD_1'), - normal: new StaticAttribute('normal', 'float', 3, 'NORMAL'), - tangent: new StaticAttribute('tangent', 'float', 4, 'TANGENT'), - color: new StaticAttribute('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 StaticAttribute('weight', 'float', 3, 'WEIGHT'), - joint: new StaticAttribute('joint', 'float', 4, 'JOINT'), - // For wireframe display - // http://codeflow.org/entries/2012/aug/02/easy-wireframe-display-with-barycentric-coordinates/ - barycentric: new StaticAttribute('barycentric', 'float', 3, null), - }, - - hint: glenum.STATIC_DRAW, - - /** - * @type {Uint16Array|Uint32Array} - */ - indices: null, - - _normalType: 'vertex', - - _enabledAttributes: null - }; -}, -/** @lends qtek.StaticGeometry.prototype */ -{ updateBoundingBox: function () { var bbox = this.boundingBox; if (!bbox) { @@ -17467,7 +17659,9 @@ var StaticGeometry = Geometry.extend(function () { max._dirty = true; } }, - + /** + * Mark attributes and indices in geometry needs to update. + */ dirty: function () { var enabledAttributes = this.getEnabledAttributes(); for (var i = 0; i < enabledAttributes.length; i++) { @@ -17476,16 +17670,26 @@ var StaticGeometry = Geometry.extend(function () { this.dirtyIndices(); this._enabledAttributes = null; }, - + /** + * 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) { @@ -17499,6 +17703,11 @@ var StaticGeometry = Geometry.extend(function () { } }, + /** + * 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]; @@ -17510,6 +17719,10 @@ var StaticGeometry = Geometry.extend(function () { return !!this.indices; }, + /** + * Initialize indices from an array. + * @param {Array} array + */ initIndicesFromArray: function (array) { var value; var ArrayConstructor = this.vertexCount > 0xffff @@ -17532,9 +17745,15 @@ var StaticGeometry = Geometry.extend(function () { 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 StaticAttribute(name, type, size, semantic); + var attrib = new Attribute(name, type, size, semantic); if (this.attributes[name]) { this.removeAttribute(name); } @@ -17542,7 +17761,10 @@ var StaticGeometry = Geometry.extend(function () { this._attributeList.push(name); return attrib; }, - + /** + * Remove attribute + * @param {string} name + */ removeAttribute: function (name) { var attributeList = this._attributeList; var idx = attributeList.indexOf(name); @@ -17554,6 +17776,15 @@ var StaticGeometry = Geometry.extend(function () { return false; }, + /** + * Get attribute + * @param {string} name + * @return {qtek.Geometry.Attribute} + */ + getAttribute: function (name) { + return this.attribute[name]; + }, + /** * Get enabled attributes name list * Attribute which has the same vertex number with position is treated as a enabled attribute @@ -17651,10 +17882,10 @@ var StaticGeometry = Geometry.extend(function () { // Only update when they are dirty. // TODO: Use BufferSubData? _gl.bindBuffer(_gl.ARRAY_BUFFER, buffer); - _gl.bufferData(_gl.ARRAY_BUFFER, attribute.value, this.hint); + _gl.bufferData(_gl.ARRAY_BUFFER, attribute.value, this.dynamic ? glenum.DYNAMIC_DRAW : glenum.STATIC_DRAW); } - attributeBuffers[k] = new Geometry.AttributeBuffer(name, attribute.type, buffer, attribute.size, attribute.semantic); + attributeBuffers[k] = new AttributeBuffer(name, attribute.type, buffer, attribute.size, attribute.semantic); } // Remove unused attributes buffers. // PENDING @@ -17667,15 +17898,18 @@ var StaticGeometry = Geometry.extend(function () { if (this.isUseIndices() && (isIndicesDirty || firstUpdate)) { if (!indicesBuffer) { - indicesBuffer = new Geometry.IndicesBuffer(_gl.createBuffer()); + 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.hint); + _gl.bufferData(_gl.ELEMENT_ARRAY_BUFFER, this.indices, this.dynamic ? glenum.DYNAMIC_DRAW : glenum.STATIC_DRAW); } }, + /** + * Generate normals per vertex. + */ generateVertexNormals: function () { if (!this.vertexCount) { return; @@ -17744,6 +17978,9 @@ var StaticGeometry = Geometry.extend(function () { this.dirty(); }, + /** + * Generate normals per face. + */ generateFaceNormals: function () { if (!this.vertexCount) { return; @@ -17802,6 +18039,9 @@ var StaticGeometry = Geometry.extend(function () { this.dirty(); }, + /** + * Generate tangents attributes. + */ generateTangents: function () { if (!this.vertexCount) { return; @@ -17915,7 +18155,10 @@ var StaticGeometry = Geometry.extend(function () { } this.dirty(); }, - + + /** + * If vertices are not shared by different indices. + */ isUniqueVertex: function () { if (this.isUseIndices()) { return this.vertexCount === this.indices.length; @@ -17924,7 +18167,9 @@ var StaticGeometry = Geometry.extend(function () { return true; } }, - + /** + * Create a unique vertex for each index. + */ generateUniqueVertex: function () { if (!this.vertexCount || !this.indices) { return; @@ -17965,6 +18210,9 @@ var StaticGeometry = Geometry.extend(function () { this.dirty(); }, + /** + * Generate barycentric coordinates for wireframe draw. + */ generateBarycentric: function () { if (!this.vertexCount) { return; @@ -17992,6 +18240,10 @@ var StaticGeometry = Geometry.extend(function () { this.dirty(); }, + /** + * Apply transform to geometry attributes. + * @param {qtek.math.Matrix4} matrix + */ applyTransform: function (matrix) { var attributes = this.attributes; @@ -18019,7 +18271,10 @@ var StaticGeometry = Geometry.extend(function () { this.updateBoundingBox(); } }, - + /** + * Dispose geometry data in GL context. + * @param {qtek.Renderer} renderer + */ dispose: function (renderer) { var cache = this._cache; @@ -18038,10 +18293,16 @@ var StaticGeometry = Geometry.extend(function () { } cache.deleteContext(renderer.__GUID__); } + }); if (Object.defineProperty) { - Object.defineProperty(StaticGeometry.prototype, 'vertexCount', { + /** + * @name qtek.Geometry#vertexCount + * @type {number} + * @readOnly + */ + Object.defineProperty(Geometry.prototype, 'vertexCount', { enumerable: false, @@ -18053,7 +18314,12 @@ if (Object.defineProperty) { return mainAttribute.value.length / mainAttribute.size; } }); - Object.defineProperty(StaticGeometry.prototype, 'triangleCount', { + /** + * @name qtek.Geometry#triangleCount + * @type {number} + * @readOnly + */ + Object.defineProperty(Geometry.prototype, 'triangleCount', { enumerable: false, @@ -18069,7 +18335,14 @@ if (Object.defineProperty) { }); } -StaticGeometry.Attribute = Geometry.StaticAttribute; +Geometry.STATIC_DRAW = glenum.STATIC_DRAW; +Geometry.DYNAMIC_DRAW = glenum.DYNAMIC_DRAW; +Geometry.STREAM_DRAW = glenum.STREAM_DRAW; + +Geometry.AttributeBuffer = AttributeBuffer; +Geometry.IndicesBuffer = IndicesBuffer; + +Geometry.Attribute = Attribute; var utilEssl = "\n@export qtek.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 qtek.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 qtek.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 qtek.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 qtek.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 qtek.util.float\n@import qtek.util.encode_float\n@import qtek.util.decode_float\n@end\n@export qtek.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export qtek.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 qtek.util.rgbm\n@import qtek.util.rgbm_decode\n@import qtek.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 51.5), 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, 51.5);\n#else\n return color;\n#endif\n}\n@end\n@export qtek.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 qtek.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n#ifdef USE_SKIN_MATRICES_TEXTURE\nuniform sampler2D skinMatricesTexture;\nuniform float skinMatricesTextureSize: unconfigurable;\nmat4 getSkinMatrix(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(skinMatricesTexture, vec2(x + 0.5, y) / scale),\n texture2D(skinMatricesTexture, vec2(x + 1.5, y) / scale),\n texture2D(skinMatricesTexture, vec2(x + 2.5, y) / scale),\n texture2D(skinMatricesTexture, vec2(x + 3.5, y) / scale)\n );\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 qtek.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 qtek.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 qtek.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"; @@ -18220,13 +18493,16 @@ function getAccessorData(json, lib, accessorIdx, isIndices) { /** * @typedef {Object} qtek.loader.GLTF.IResult + * @property {Object} json * @property {qtek.Scene} scene * @property {qtek.Node} rootNode - * @property {Object.} cameras - * @property {Object.} textures - * @property {Object.} materials - * @property {Object.} skeletons - * @property {Object.} meshes + * @property {qtek.Camera[]} cameras + * @property {qtek.Texture[]} textures + * @property {qtek.Material[]} materials + * @property {qtek.Skeleton[]} skeletons + * @property {qtek.Mesh[]} meshes + * @property {qtek.animation.TrackClip[]} clips + * @property {qtek.Node[]} nodes */ /** @@ -18237,48 +18513,59 @@ var GLTFLoader = Base.extend( /** @lends qtek.loader.GLTF# */ { /** + * * @type {qtek.Node} */ rootNode: null, /** + * Root path for uri parsing. * @type {string} */ rootPath: null, /** + * Root path for texture uri parsing. Defaultly use the rootPath * @type {string} */ textureRootPath: null, /** + * Root path for buffer uri parsing. Defaultly use the rootPath * @type {string} */ bufferRootPath: null, /** + * Shader used when creating the materials. * @type {string} + * @default 'qtek.standard' */ shaderName: 'qtek.standard', /** + * If use {@link qtek.StandardMaterial} * @type {string} */ useStandardMaterial: false, /** + * If loading the cameras. * @type {boolean} */ includeCamera: true, /** + * If loading the animations. * @type {boolean} */ includeAnimation: true, /** + * If loading the meshes * @type {boolean} */ includeMesh: true, /** + * If loading the textures. * @type {boolean} */ includeTexture: true, @@ -18289,9 +18576,8 @@ var GLTFLoader = Base.extend( crossOrigin: '', /** * @type {boolean} + * @see https://github.com/KhronosGroup/glTF/issues/674 */ - // PENDING - // https://github.com/KhronosGroup/glTF/issues/674 textureFlipY: false, shaderLibrary: null @@ -18304,7 +18590,7 @@ function () { /** @lends qtek.loader.GLTF.prototype */ { /** - * @param {string} url + * @param {string} url */ load: function (url) { var self = this; @@ -18337,6 +18623,7 @@ function () { /** * Parse glTF binary * @param {ArrayBuffer} buffer + * @return {qtek.loader.GLTF.IResult} */ parseBinary: function (buffer) { var header = new Uint32Array(buffer, 0, 4); @@ -18390,7 +18677,7 @@ function () { /** * @param {Object} json - * @param {Array.} [buffer] + * @param {ArrayBuffer[]} [buffer] * @return {qtek.loader.GLTF.IResult} */ parse: function (json, buffers) { @@ -18980,7 +19267,8 @@ function () { // Geometry for (var pp = 0; pp < meshInfo.primitives.length; pp++) { var primitiveInfo = meshInfo.primitives[pp]; - var geometry = new StaticGeometry({ + var geometry = new Geometry({ + dynamic: false, // PENDIGN name: meshInfo.name, boundingBox: new BoundingBox() @@ -19815,21 +20103,21 @@ var requestAnimationFrame$1 = window.requestAnimationFrame * @extends qtek.core.Base * * @example - * var animation = new qtek.animation.Animation(); - * var node = new qtek.Node(); - * animation.animate(node.position) - * .when(1000, { - * x: 500, - * y: 500 - * }) - * .when(2000, { - * x: 100, - * y: 100 - * }) - * .when(3000, { - * z: 10 - * }) - * .start('spline'); + * var animation = new qtek.animation.Animation(); + * var node = new qtek.Node(); + * animation.animate(node.position) + * .when(1000, { + * x: 500, + * y: 500 + * }) + * .when(2000, { + * x: 100, + * y: 100 + * }) + * .when(3000, { + * z: 10 + * }) + * .start('spline'); */ var Animation = Base.extend(function () { return /** @lends qtek.animation.Animation# */{ @@ -20049,7 +20337,9 @@ var meshUtil = { var templateGeo = templateMesh.geometry; var material = templateMesh.material; - var geometry = new StaticGeometry(); + var geometry = new Geometry({ + dynamic: false + }); geometry.boundingBox = new BoundingBox(); var attributeNames = templateGeo.getEnabledAttributes(); @@ -20288,7 +20578,7 @@ var meshUtil = { } subMat.name = [material.name, b].join('-'); - var subGeo = new StaticGeometry(); + var subGeo = new Geometry(); var subMesh = new Mesh({ name: [mesh.name, i].join('-'), @@ -20730,14 +21020,15 @@ TaskGroup.prototype.getTaskNumber = function (recursive) { /** * @constructor qtek.geometry.Plane - * @extends qtek.StaticGeometry + * @extends qtek.Geometry * @param {Object} [opt] * @param {number} [opt.widthSegments] * @param {number} [opt.heightSegments] */ -var Plane$2 = StaticGeometry.extend( +var Plane$2 = Geometry.extend( /** @lends qtek.geometry.Plane# */ { + dynamic: false, /** * @type {number} */ @@ -21087,12 +21378,12 @@ var TextureCube = Texture.extend(function () { return /** @lends qtek.TextureCube# */{ /** * @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 + * @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, @@ -21103,13 +21394,14 @@ var TextureCube = Texture.extend(function () { 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 + * @property {?Uint8Array} px + * @property {?Uint8Array} nx + * @property {?Uint8Array} py + * @property {?Uint8Array} ny + * @property {?Uint8Array} pz + * @property {?Uint8Array} nz */ pixels: { px: null, @@ -21496,13 +21788,12 @@ var FrameBuffer = Base.extend( } }, - /** - * 0x8CD5, 36053, FRAMEBUFFER_COMPLETE - * 0x8CD6, 36054, FRAMEBUFFER_INCOMPLETE_ATTACHMENT - * 0x8CD7, 36055, FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT - * 0x8CD9, 36057, FRAMEBUFFER_INCOMPLETE_DIMENSIONS - * 0x8CDD, 36061, FRAMEBUFFER_UNSUPPORTED - */ + + // 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); }, @@ -21833,7 +22124,7 @@ var EnvironmentMapPass = Base.extend(function() { /** * @constructor qtek.geometry.Sphere - * @extends qtek.StaticGeometry + * @extends qtek.Geometry * @param {Object} [opt] * @param {number} [widthSegments] * @param {number} [heightSegments] @@ -21843,9 +22134,10 @@ var EnvironmentMapPass = Base.extend(function() { * @param {number} [thetaLength] * @param {number} [radius] */ -var Sphere = StaticGeometry.extend( +var Sphere = Geometry.extend( /** @lends qtek.geometry.Sphere# */ { + dynamic: false, /** * @type {number} */ @@ -22352,7 +22644,7 @@ var ret$1 = { }; /** - * @namespace qtek.util.texture + * @alias qtek.util.texture */ var textureUtil = { /** @@ -22361,8 +22653,6 @@ var textureUtil = { * @param {Function} [onsuccess] * @param {Function} [onerror] * @return {qtek.Texture} - * - * @memberOf qtek.util.texture */ loadTexture: function (path, option, onsuccess, onerror) { var texture; @@ -22432,8 +22722,6 @@ var textureUtil = { * @param {number} [option.exposure] * @param {Function} [onsuccess] * @param {Function} [onerror] - * - * @memberOf qtek.util.texture */ loadPanorama: function (renderer, path, cubeMap, option, onsuccess, onerror) { var self = this; @@ -22463,8 +22751,6 @@ var textureUtil = { * @param {qtek.TextureCube} cubeMap * @param {Object} option * @param {boolean} [option.encodeRGBM] - * - * @memberOf qtek.util.texture */ panoramaToCubeMap: function (renderer, panoramaMap, cubeMap, option) { var environmentMapPass = new EnvironmentMapPass(); @@ -22599,8 +22885,6 @@ var textureUtil = { * @param {string} [color1] * @param {string} [color2] * @return {qtek.Texture2D} - * - * @memberOf qtek.util.texture */ createChessboard: function (size, unitSize, color1, color2) { size = size || 512; @@ -22639,8 +22923,6 @@ var textureUtil = { * Create a blank pure color 1x1 texture * @param {string} color * @return {qtek.Texture2D} - * - * @memberOf qtek.util.texture */ createBlank: function (color) { var canvas = document.createElement('canvas'); @@ -23191,6 +23473,8 @@ function isPowerOfTwo$2(width, height) { var shadowmapEssl = "@export qtek.sm.depth.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\n#ifdef SHADOW_TRANSPARENT\nattribute vec2 texcoord : TEXCOORD_0;\n#endif\n@import qtek.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 qtek.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 qtek.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 qtek.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 qtek.sm.debug_depth\nuniform sampler2D depthMap;\nvarying vec2 v_Texcoord;\n@import qtek.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 qtek.sm.distance.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\n@import qtek.chunk.skinning_header\nvarying vec3 v_WorldPosition;\nvoid main (){\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import qtek.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 qtek.sm.distance.fragment\nuniform vec3 lightPosition;\nuniform float range : 100;\nvarying vec3 v_WorldPosition;\n@import qtek.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 qtek.plugin.shadow_map_common\n@import qtek.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 qtek.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];\nuniform mat4 spotLightMatrices[SPOT_LIGHT_SHADOWMAP_COUNT];\nuniform float spotLightShadowMapSizes[SPOT_LIGHT_SHADOWMAP_COUNT];\n#endif\n#ifdef DIRECTIONAL_LIGHT_SHADOWMAP_COUNT\n#if defined(SHADOW_CASCADE)\nuniform sampler2D directionalLightShadowMaps[1];\nuniform mat4 directionalLightMatrices[SHADOW_CASCADE];\nuniform float directionalLightShadowMapSizes[1];\nuniform float shadowCascadeClipsNear[SHADOW_CASCADE];\nuniform float shadowCascadeClipsFar[SHADOW_CASCADE];\n#else\nuniform sampler2D directionalLightShadowMaps[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT];\nuniform mat4 directionalLightMatrices[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT];\nuniform float directionalLightShadowMapSizes[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT];\n#endif\n#endif\n#ifdef POINT_LIGHT_SHADOWMAP_COUNT\nuniform samplerCube pointLightShadowMaps[POINT_LIGHT_SHADOWMAP_COUNT];\nuniform float pointLightShadowMapSizes[POINT_LIGHT_SHADOWMAP_COUNT];\n#endif\nuniform bool shadowEnabled : true;\n#ifdef PCF_KERNEL_SIZE\nuniform vec2 pcfKernel[PCF_KERNEL_SIZE];\n#endif\n@import qtek.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"; var mat4$8 = glmatrix.mat4; +var vec3$15 = glmatrix.vec3; + var targets$1 = ['px', 'nx', 'py', 'ny', 'pz', 'nz']; Shader['import'](shadowmapEssl); @@ -23845,6 +24129,7 @@ var ShadowMapPass = Base.extend(function () { height: size, type: Texture.FLOAT }; + var _gl = renderer.gl; var tmpTexture = this._texturePool.get(parameter); this._frameBuffer.attach(tmpTexture); @@ -25916,6 +26201,16 @@ function getBeforeRenderHook2(gl, defaultDiffuseMap, defaultMetalnessMap) { }; } +/** + * GBuffer is provided for deferred rendering and SSAO, SSR pass. + * It will do two passes rendering to three target textures. See + * + {@link qtek.deferred.GBuffer#getTargetTexture1} + * + {@link qtek.deferred.GBuffer#getTargetTexture2} + * + {@link qtek.deferred.GBuffer#getTargetTexture3} + * @constructor + * @alias qtek.deferred.GBuffer + * @extends qtek.core.Base + */ var GBuffer = Base.extend(function () { return { @@ -25979,8 +26274,13 @@ var GBuffer = Base.extend(function () { fragment: Shader.source('qtek.deferred.gbuffer.debug') }) }; -}, { +}, /** @lends qtek.deferred.GBuffer# */{ + /** + * Set G Buffer size. + * @param {number} width + * @param {number} height + */ resize: function (width, height) { if (this._gBufferTex1.width === width && this._gBufferTex1.height === height @@ -26027,6 +26327,12 @@ var GBuffer = Base.extend(function () { } }, + /** + * Update G Buffer + * @param {qtek.Renderer} renderer + * @param {qtek.Scene} scene + * @param {qtek.camera.Perspective} camera + */ update: function (renderer, scene, camera) { var gl = renderer.gl; @@ -26188,14 +26494,38 @@ var GBuffer = Base.extend(function () { renderer.restoreClear(); }, + /** + * Get first target texture. + * Channel storage: + * + R: normal.x * 0.5 + 0.5 + * + G: normal.y * 0.5 + 0.5 + * + B: normal.z * 0.5 + 0.5 + * + A: glossiness + * @return {qtek.Texture2D} + */ getTargetTexture1: function () { return this._gBufferTex1; }, + /** + * Get second target texture. + * Channel storage: + * + R: depth + * @return {qtek.Texture2D} + */ getTargetTexture2: function () { return this._gBufferTex2; }, + /** + * Get third target texture. + * Channel storage: + * + R: albedo.r + * + G: albedo.g + * + B: albedo.b + * + A: metalness + * @return {qtek.Texture2D} + */ getTargetTexture3: function () { return this._gBufferTex3; }, @@ -26279,6 +26609,10 @@ var GBuffer = Base.extend(function () { } }, + + /** + * @param {qtek.Renderer} renderer + */ dispose: function (renderer) { for (var name in this._gBufferMaterials) { var matObj = this._gBufferMaterials[name]; @@ -26486,16 +26820,17 @@ var planeMatrix = new Matrix4(); /** * @constructor qtek.geometry.Cube - * @extends qtek.StaticGeometry + * @extends qtek.Geometry * @param {Object} [opt] * @param {number} [opt.widthSegments] * @param {number} [opt.heightSegments] * @param {number} [opt.depthSegments] * @param {boolean} [opt.inside] */ -var Cube = StaticGeometry.extend( +var Cube = Geometry.extend( /**@lends qtek.geometry.Cube# */ { + dynamic: false, /** * @type {number} */ @@ -26731,14 +27066,15 @@ var cubemapUtil = {}; var targets$2 = ['px', 'nx', 'py', 'ny', 'pz', 'nz']; /** + * @name qtek.util.cubemap.prefilterEnvironmentMap * @param {qtek.Renderer} renderer * @param {qtek.Texture} envMap * @param {Object} [textureOpts] - * @param {number} [textureOpts.width] - * @param {number} [textureOpts.height] + * @param {number} [textureOpts.width=64] + * @param {number} [textureOpts.height=64] * @param {number} [textureOpts.type] - * @param {boolean} [textureOpts.encodeRGBM] - * @param {boolean} [textureOpts.decodeRGBM] + * @param {boolean} [textureOpts.encodeRGBM=false] + * @param {boolean} [textureOpts.decodeRGBM=false] * @param {qtek.Texture2D} [normalDistribution] * @param {qtek.Texture2D} [brdfLookup] */ @@ -26976,6 +27312,8 @@ cubemapUtil.generateNormalDistribution = function (roughnessLevels, sampleSize) // https://docs.unrealengine.com/latest/INT/Engine/Rendering/LightingAndShadows/AmbientCubemap/ /** + * Ambient cubemap light provides specular parts of Image Based Lighting. + * Which is a basic requirement for Physically Based Rendering * @constructor qtek.light.AmbientCubemap * @extends qtek.Light */ @@ -26998,6 +27336,11 @@ var AmbientCubemapLight = Light.extend({ type: 'AMBIENT_CUBEMAP_LIGHT', + /** + * Do prefitering the cubemap + * @param {qtek.Renderer} renderer + * @param {number} [size=32] + */ prefilter: function (renderer, size) { if (!this._brdfLookup) { this._normalDistribution = cubemapUtil.generateNormalDistribution(); @@ -27105,7 +27448,7 @@ var AmbientSHLight = Light.extend({ }); // Spherical Harmonic Helpers -var vec3$17 = glmatrix.vec3; +var vec3$16 = glmatrix.vec3; var sh = {}; var targets$3 = ['px', 'nx', 'py', 'ny', 'pz', 'nz']; @@ -27156,15 +27499,15 @@ var normalTransform = { // Project on cpu. function projectEnvironmentMapCPU(renderer, cubePixels, width, height) { var coeff = new vendor.Float32Array(9 * 3); - var normal = vec3$17.create(); - var texel = vec3$17.create(); - var fetchNormal = vec3$17.create(); + var normal = vec3$16.create(); + var texel = vec3$16.create(); + var fetchNormal = vec3$16.create(); for (var m = 0; m < 9; m++) { - var result = vec3$17.create(); + var result = vec3$16.create(); for (var k = 0; k < targets$3.length; k++) { var pixels = cubePixels[targets$3[k]]; - var sideResult = vec3$17.create(); + var sideResult = vec3$16.create(); var divider = 0; var i = 0; var transform = normalTransform[targets$3[k]]; @@ -27175,7 +27518,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$17.normalize(normal, normal); + vec3$16.normalize(normal, normal); fetchNormal[0] = normal[transform[0]] * transform[3]; fetchNormal[1] = normal[transform[1]] * transform[4]; @@ -27190,12 +27533,12 @@ function projectEnvironmentMapCPU(renderer, cubePixels, width, height) { texel[1] *= scale; texel[2] *= scale; - vec3$17.scaleAndAdd(sideResult, sideResult, texel, harmonics(fetchNormal, m) * -normal[2]); + vec3$16.scaleAndAdd(sideResult, sideResult, texel, harmonics(fetchNormal, m) * -normal[2]); // -normal.z equals cos(theta) of Lambertian divider += -normal[2]; } } - vec3$17.scaleAndAdd(result, result, sideResult, 1 / divider); + vec3$16.scaleAndAdd(result, result, sideResult, 1 / divider); } coeff[m * 3] = result[0] / 6.0; @@ -27709,15 +28052,7 @@ helper.firstNotNull = function () { return arguments[i]; } } -}, -/** - * @param {string|HTMLImageElement|HTMLCanvasElement} imgValue - * @param {Viewer} app - * @param {Object} [textureOpts] - * @param {Function} cb - */ -// TODO Promise, test -helper.loadTexture = function (imgValue, app, textureOpts, cb) { +}, helper.loadTexture = function (imgValue, app, textureOpts, cb) { if (typeof textureOpts === 'function') { cb = textureOpts; textureOpts = {}; @@ -29681,39 +30016,41 @@ SceneHelper.prototype = { var self = this; // TODO Change exposure - if (!this._currentCubemapLights || textureUrl !== this._currentCubemapLights.textureUrl) { - if (this._currentCubemapLights) { - this._lightRoot.remove(this._currentCubemapLights.diffuse); - if (this._currentCubemapLights.specular) { - this._lightRoot.remove(this._currentCubemapLights.specular); - this._currentCubemapLights.specular.cubemap.dispose(renderer.gl); + if ('texture' in opts) { + if (!this._currentCubemapLights || textureUrl !== this._currentCubemapLights.textureUrl) { + if (this._currentCubemapLights) { + this._lightRoot.remove(this._currentCubemapLights.diffuse); + if (this._currentCubemapLights.specular) { + this._lightRoot.remove(this._currentCubemapLights.specular); + this._currentCubemapLights.specular.cubemap.dispose(renderer.gl); + } } - } - if (textureUrl) { - var lights = helper.createAmbientCubemap(opts, app, function () { - // Use prefitered cubemap - if (lights.specular && (self._skybox instanceof Skybox)) { - self._skybox.setEnvironmentMap(lights.specular.cubemap); + if (textureUrl) { + var lights = helper.createAmbientCubemap(opts, app, function () { + // Use prefitered cubemap + if (lights.specular && (self._skybox instanceof Skybox)) { + self._skybox.setEnvironmentMap(lights.specular.cubemap); + } + app.refresh(); + }); + if (lights.diffuse) { + this._lightRoot.add(lights.diffuse); } - app.refresh(); - }); - if (lights.diffuse) { - this._lightRoot.add(lights.diffuse); + if (lights.specular) { + this._lightRoot.add(lights.specular); + } + + this._currentCubemapLights = lights; + this._currentCubemapLights.textureUrl = textureUrl; } - if (lights.specular) { - this._lightRoot.add(lights.specular); + else if (this._currentCubemapLights) { + this._lightRoot.remove(this._currentCubemapLights.diffuse); + this._lightRoot.remove(this._currentCubemapLights.specular); + this._currentCubemapLights = null; } - - this._currentCubemapLights = lights; - this._currentCubemapLights.textureUrl = textureUrl; - } - else if (this._currentCubemapLights) { - this._lightRoot.remove(this._currentCubemapLights.diffuse); - this._lightRoot.remove(this._currentCubemapLights.specular); - this._currentCubemapLights = null; } } - + if (this._currentCubemapLights) { if (opts.specularIntensity != null && this._currentCubemapLights.specular) { this._currentCubemapLights.specular.intensity = opts.specularIntensity; @@ -30299,7 +30636,7 @@ function isPrimitive(obj) { return obj[primitiveKey]; } -var vec3$18 = glmatrix.vec3; +var vec3$17 = glmatrix.vec3; function getBoundingBoxOfSkinningMesh(mesh, out) { var pos = []; @@ -30331,16 +30668,16 @@ function getBoundingBoxOfSkinningMesh(mesh, out) { jointAttr.get(i, joint); weight[3] = 1 - weight[0] - weight[1] - weight[2]; - vec3$18.set(skinnedPos, 0, 0, 0); + vec3$17.set(skinnedPos, 0, 0, 0); for (var k = 0; k < 4; k++) { if (joint[k] >= 0 && weight[k] > 1e-6) { - vec3$18.transformMat4(tmp, pos, skinMatrices[joint[k]]); - vec3$18.scaleAndAdd(skinnedPos, skinnedPos, tmp, weight[k]); + vec3$17.transformMat4(tmp, pos, skinMatrices[joint[k]]); + vec3$17.scaleAndAdd(skinnedPos, skinnedPos, tmp, weight[k]); } } - vec3$18.min(min, min, skinnedPos); - vec3$18.max(max, max, skinnedPos); + vec3$17.min(min, min, skinnedPos); + vec3$17.max(max, max, skinnedPos); } out.min.setArray(min); out.max.setArray(max); @@ -31884,6 +32221,9 @@ Vector4.transformQuat = function(out, a, q) { return out; }; +var DEFAULT_FAR_ALPHA = 0.1; +var DEFAULT_NEAR_ALPHA = 1.0; + var HotspotManger = Base.extend(function () { return { @@ -31972,6 +32312,8 @@ var HotspotManger = Base.extend(function () { var p = hotspot.position; pos.set(p[0], p[1], p[2], 1); pos.transformMat4(this.camera.viewMatrix); + var linearDepth = pos.z; + pos.transformMat4(this.camera.projectionMatrix); pos.scale(1 / pos.w); @@ -31982,8 +32324,12 @@ var HotspotManger = Base.extend(function () { hotspot.dom.style.top = this.renderer.getHeight() - y + 'px'; // Upadte alpha + var farAlpha = hotspot.farAlpha == null ? DEFAULT_FAR_ALPHA : hotspot.farAlpha; + var nearAlpha = hotspot.nearAlpha == null ? DEFAULT_NEAR_ALPHA : hotspot.nearAlpha; + tmpBBox.copy(this._boundingBox); tmpBBox.applyTransform(this.camera.viewMatrix); + var percent = (linearDepth - tmpBBox.max.z) / (tmpBBox.min.z - tmpBBox.max.z); hotspot.dom.style.opacity = 1; hotspot.onupdate && hotspot.onupdate(x, y); @@ -33106,7 +33452,8 @@ Viewer.prototype.dispose = function () { util.extend(Viewer.prototype, notifier); var index = { - Viewer: Viewer + Viewer: Viewer, + version: '0.1.0' }; exports.Viewer = Viewer; diff --git a/dist/QMV.min.js b/dist/QMV.min.js index 97dcb8e..597fce3 100644 --- a/dist/QMV.min.js +++ b/dist/QMV.min.js @@ -1,14 +1,14 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.QMV={})}(this,function(e){"use strict";function t(e,t,i){"object"==typeof t&&(i=t,t=null);var a,o=this;if(!(e instanceof Function)){a=[];for(var s in e)e.hasOwnProperty(s)&&a.push(s)}var u=function(t){if(o.apply(this,arguments),e instanceof Function?r(this,e.call(this,t)):n(this,e,a),this.constructor===u)for(var i=u.__initializers__,s=0;sr?r:e}function s(){return{locations:{},attriblocations:{}}}function u(e,t,r){if(!e.getShaderParameter(t,e.COMPILE_STATUS))return[e.getShaderInfoLog(t),l(r)].join("\n")}function l(e){for(var t=e.split("\n"),r=0,n=t.length;r=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}function d(e,t){if(t.castShadow&&!e.castShadow)return!0}function _(e,t,r){var n=t;n+=256*r.roughnessChannel,n+=1024*r.metalnessChannel;for(var i=0;i1e-6?(o=Math.acos(s),u=Math.sin(o),l=Math.sin((1-n)*o)/u,c=Math.sin(n*o)/u):(l=1-n,c=n),e[0]=l*h+c*p,e[1]=l*f+c*m,e[2]=l*d+c*v,e[3]=l*_+c*g,e}function E(e){return{byte:at.Int8Array,ubyte:at.Uint8Array,short:at.Int16Array,ushort:at.Uint16Array}[e]||at.Float32Array}function b(e,t,r,n){this.name=e,this.type=t,this.size=r,n&&(this.semantic=n)}function S(e,t,r,n){switch(b.call(this,e,t,r,n),this.value=null,r){case 1:this.get=function(e){return this.value[e]},this.set=function(e,t){this.value[e]=t},this.copy=function(e,t){this.value[e]=this.value[e]};break;case 2:this.get=function(e,t){var r=this.value;return t[0]=r[2*e],t[1]=r[2*e+1],t},this.set=function(e,t){var r=this.value;r[2*e]=t[0],r[2*e+1]=t[1]},this.copy=function(e,t){var r=this.value;t*=2,e*=2,r[e]=r[t],r[e+1]=r[t+1]};break;case 3:this.get=function(e,t){var r=3*e,n=this.value;return t[0]=n[r],t[1]=n[r+1],t[2]=n[r+2],t},this.set=function(e,t){var r=3*e,n=this.value;n[r]=t[0],n[r+1]=t[1],n[r+2]=t[2]},this.copy=function(e,t){var r=this.value;t*=3,e*=3,r[e]=r[t],r[e+1]=r[t+1],r[e+2]=r[t+2]};break;case 4:this.get=function(e,t){var r=this.value,n=4*e;return t[0]=r[n],t[1]=r[n+1],t[2]=r[n+2],t[3]=r[n+3],t},this.set=function(e,t){var r=this.value,n=4*e;r[n]=t[0],r[n+1]=t[1],r[n+2]=t[2],r[n+3]=t[3]},this.copy=function(e,t){var r=this.value;t*=4,e*=4,r[e]=r[t],r[e+1]=r[t+1],r[e+2]=r[t+2],r[e+3]=r[t+3]}}}function A(e,t,r,n,i){this.name=e,this.type=t,this.buffer=r,this.size=n,this.semantic=i,this.symbol="",this.needsRemove=!1}function N(e){this.buffer=e,this.count=0}function w(){console.warn("Geometry doesn't implement this method, use StaticGeometry instead")}function M(e){return"attr_"+e}function R(e,t,r,n){var i=e.accessors[r],a=t.bufferViews[i.bufferView],o=i.byteOffset||0,s=On[i.componentType]||at.Float32Array,u=Fn[i.type];null==u&&n&&(u=1);var l=new s(a,o,u*i.count),c=i.extensions&&i.extensions.WEB3D_quantized_attributes;if(c){for(var h,f,d=new at.Float32Array(u*i.count),_=c.decodeMatrix,h=new Array(u),f=new Array(u),p=0;pi)e.length=i;else for(var a=n;a=0&&!(_[g]<=t);g--);g=Math.min(g,l-2)}else{for(g=w;gt);g++);g=Math.min(g-1,l-2)}w=g,M=t;var r=_[g+1]-_[g];0!==r&&(E=(t-_[g])/r,u?(S=p[g],b=p[0===g?g:g-1],A=p[g>l-2?l-1:g+1],N=p[g>l-3?l-1:g+2],a?s(e,i,a(o(e,i),b,S,A,N,E)):h?F(b,S,A,N,E,E*E,E*E*E,o(e,i),f):s(e,i,k(b,S,A,N,E,E*E,E*E*E))):a?s(e,i,a(o(e,i),p[g],p[g+1],E)):h?P(p[g],p[g+1],E,o(e,i),f):s(e,i,D(p[g],p[g+1],E)))},C=new on({target:e._target,life:d,loop:e._loop,delay:e._delay,onframe:R,onfinish:r});return t&&"spline"!==t&&C.setEasing(t),C}}}function z(e,t,r,n,i){this._tracks={},this._target=e,this._loop=t||!1,this._getter=r||C,this._setter=n||L,this._interpolater=i||null,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]}function G(e,t){var r=new Wn;return ar.get({url:e,responseType:t,onload:function(e){r.resolve(e)},onerror:function(e){r.reject(e)}}),r}function q(e){return"CANVAS"===e.nodeName||"VIDEO"===e.nodeName||e.complete}function W(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function V(e,t,r,n){if(e[3]>0){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 j(e,t,r){for(var n="",i=t;i0;)if(e[a][0]=t[r++],e[a][1]=t[r++],e[a][2]=t[r++],e[a][3]=t[r++],1===e[a][0]&&1===e[a][1]&&1===e[a][2]){for(var s=e[a][3]<>>0;s>0;s--)X(e[a-1],e[a]),a++,o--;i+=8}else a++,o--,i=0;return r}function Y(e,t,r,n){if(n_i)return K(e,t,r,n);var i=t[r++];if(2!=i)return K(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){o=(127&o)>>>0;for(var s=t[r++];o--;)e[a++][i]=s}else for(;o--;)e[a++][i]=t[r++]}return r}function Z(e){Je.defaultsWithPropList(e,Ai,Ni),Q(e);for(var t="",r=0;r0;)r+=n*(i%t),i=Math.floor(i/t),n/=t;return r}function ne(e){for(var t=new Uint8Array(e*e*4),r=0,n=new ut,i=0;i255?255:e}function me(e){return e<0?0:e>1?1:e}function ve(e){return pe(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100*255:parseInt(e,10))}function ge(e){return me(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100:parseFloat(e))}function ye(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 xe(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e}function Te(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function Ee(e,t){oa&&Te(oa,t),oa=aa.put(e,oa||t.slice())}function be(e,t){if(e){t=t||[];var r=aa.get(e);if(r)return Te(t,r);e+="";var n=e.replace(/ /g,"").toLowerCase();if(n in ia)return Te(t,ia[n]),Ee(e,t),t;if("#"!==n.charAt(0)){var i=n.indexOf("("),a=n.indexOf(")");if(-1!==i&&a+1===n.length){var o=n.substr(0,i),s=n.substr(i+1,a-(i+1)).split(","),u=1;switch(o){case"rgba":if(4!==s.length)return void xe(t,0,0,0,1);u=ge(s.pop());case"rgb":return 3!==s.length?void xe(t,0,0,0,1):(xe(t,ve(s[0]),ve(s[1]),ve(s[2]),u),Ee(e,t),t);case"hsla":return 4!==s.length?void xe(t,0,0,0,1):(s[3]=ge(s[3]),Se(s,t),Ee(e,t),t);case"hsl":return 3!==s.length?void xe(t,0,0,0,1):(Se(s,t),Ee(e,t),t);default:return}}xe(t,0,0,0,1)}else{if(4===n.length){var l=parseInt(n.substr(1),16);return l>=0&&l<=4095?(xe(t,(3840&l)>>4|(3840&l)>>8,240&l|(240&l)>>4,15&l|(15&l)<<4,1),Ee(e,t),t):void xe(t,0,0,0,1)}if(7===n.length){var l=parseInt(n.substr(1),16);return l>=0&&l<=16777215?(xe(t,(16711680&l)>>16,(65280&l)>>8,255&l,1),Ee(e,t),t):void xe(t,0,0,0,1)}}}}function Se(e,t){var r=(parseFloat(e[0])%360+360)%360/360,n=ge(e[1]),i=ge(e[2]),a=i<=.5?i*(n+1):i+n-i*n,o=2*i-a;return t=t||[],xe(t,pe(255*ye(o,a,r+1/3)),pe(255*ye(o,a,r)),pe(255*ye(o,a,r-1/3)),1),4===e.length&&(t[3]=e[3]),t}function Ae(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+")"}}function Ne(e){return!e||"none"===e}function we(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}function Me(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function Re(e){if((e.wrapS===Vt.REPEAT||e.wrapT===Vt.REPEAT)&&e.image){var t=Me(e.width),r=Me(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),n.srcImage=e.image,e.image=n,e.dirty()}}}function Ce(){this._sourceTexture=new Pr({type:Vt.HALF_FLOAT}),this._depthTexture=new Pr({format:Vt.DEPTH_COMPONENT,type:Vt.UNSIGNED_INT}),this._framebuffer=new ni,this._framebuffer.attach(this._sourceTexture),this._framebuffer.attach(this._depthTexture,ni.DEPTH_ATTACHMENT),this._gBufferPass=new zi({enableTargetTexture3:!1});var e=new Bi;this._compositor=e.parse(la);var t=this._compositor.getNodeByName("source");t.texture=this._sourceTexture;var r=this._compositor.getNodeByName("coc");this._sourceNode=t,this._cocNode=r,this._compositeNode=this._compositor.getNodeByName("composite"),this._fxaaNode=this._compositor.getNodeByName("FXAA"),this._dofBlurNodes=["dof_far_blur","dof_near_blur","dof_coc_blur"].map(function(e){return this._compositor.getNodeByName(e)},this),this._dofBlurKernel=null,this._dofBlurKernelSize=new Float32Array(0),this._finalNodesChain=ha.map(function(e){return this._compositor.getNodeByName(e)},this);var n={normalTexture:this._gBufferPass.getTargetTexture1(),depthTexture:this._gBufferPass.getTargetTexture2()};this._ssaoPass=new oe(n),this._ssrPass=new se(n)}function Le(){for(var e=[],t=0;t<30;t++)e.push([re(t,2),re(t,3)]);this._haltonSequence=e,this._frame=0,this._sourceTex=new Pr,this._sourceFb=new ni,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new Pr,this._outputTex=new Pr;var r=this._blendPass=new bi({fragment:Ut.source("qtek.compositor.blend")});r.material.shader.disableTexturesAll(),r.material.shader.enableTexture(["texture1","texture2"]),this._blendFb=new ni({depthBuffer:!1}),this._outputPass=new bi({fragment:Ut.source("qtek.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.shader.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)}}function De(e,t,r){this.renderer=e,r=r||"perspective",this.scene=new _r,this.rootNode=this.scene,this.viewport={x:0,y:0,width:0,height:0},this.preZ=!1,this.setProjection(r),this._compositor=new Ce,this._temporalSS=new Le,t&&(this._shadowMapPass=new Ri({lightFrustumBias:20}));for(var n=[],i=0,a=0;a<30;a++){for(var o=[],s=0;s<6;s++)o.push(4*re(i,2)-2),o.push(4*re(i,3)-2),i++;n.push(o)}this._pcfKernels=n,this._enableTemporalSS="auto",this.scene.on("beforerender",function(e,t,r){this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,r)},this)}function Pe(e){this.setScene(e)}function Ie(e){if(null==e||"object"!=typeof e)return e;var t=e,r=va.call(e);if("[object Array]"===r){t=[];for(var n=0,i=e.length;n=0&&i[h]>1e-6&&(ya.transformMat4(s,r,a[n[h]]),ya.scaleAndAdd(o,o,s,i[h]));ya.min(p,p,o),ya.max(m,m,o)}t.min.setArray(p),t.max.setArray(m)}function Ge(e,t){t=t||new vt;var r=new vt;return e.traverse(function(e){e.geometry&&(e.isSkinnedMesh()?(ze(e,r),e.geometry.boundingBox.copy(r)):(r.copy(e.geometry.boundingBox),r.applyTransform(e.worldTransform)),t.union(r))}),t}function qe(e){var t=e[1][0]-e[0][0],r=e[1][1]-e[0][1];return Math.sqrt(t*t+r*r)}function We(e){return[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2]}function Ve(e){return Array.isArray(e)||(e=[e,e]),e}function je(e,t){t=Ie(t),Oe(t,_a),this.init(e,t)}var Xe={extend:t,derive:t},Ke={trigger:function(e){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(e)){var t=this.__handlers__[e],r=t.length,n=-1,i=arguments;switch(i.length){case 1:for(;++n0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},o.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},o.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},o.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},o.random=function(e,t){t=t||1;var r=2*n()*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e},o.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},o.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},o.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},o.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},o.forEach=function(){var e=o.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},s.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},s.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},s.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},s.random=function(e,t){t=t||1;var r=2*n()*Math.PI,i=2*n()-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},s.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},s.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},s.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,f=l*a+o*i-s*n,d=-o*n-s*i-u*a;return e[0]=c*l+d*-o+h*-u-f*-s,e[1]=h*l+d*-s+f*-o-c*-u,e[2]=f*l+d*-u+c*-s-h*-o,e},s.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},s.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},s.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},s.forEach=function(){var e=s.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)},s.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},void 0!==e&&(e.vec3=s);var u={};u.create=function(){var e=new r(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},u.clone=function(e){var t=new r(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},u.fromValues=function(e,t,n,i){var a=new r(4);return a[0]=e,a[1]=t,a[2]=n,a[3]=i,a},u.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},u.set=function(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e},u.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},u.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},u.sub=u.subtract,u.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},u.mul=u.multiply,u.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},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[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),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[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e},u.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},u.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},u.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)},u.dist=u.distance,u.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},u.sqrDist=u.squaredDistance,u.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)},u.len=u.length,u.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},u.sqrLen=u.squaredLength,u.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},u.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},u.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},u.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},u.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},u.random=function(e,t){return t=t||1,e[0]=n(),e[1]=n(),e[2]=n(),e[3]=n(),u.normalize(e,e),u.scale(e,e,t),e},u.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},u.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,f=l*a+o*i-s*n,d=-o*n-s*i-u*a;return e[0]=c*l+d*-o+h*-u-f*-s,e[1]=h*l+d*-s+f*-o-c*-u,e[2]=f*l+d*-u+c*-s-h*-o,e},u.forEach=function(){var e=u.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):(s.cross(e,i,a),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+o,d.normalize(n,n))}}(),d.setAxes=function(){var e=h.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],d.normalize(t,d.fromMat3(t,e))}}(),d.clone=u.clone,d.fromValues=u.fromValues,d.copy=u.copy,d.set=u.set,d.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},d.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},d.add=u.add,d.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},d.mul=d.multiply,d.scale=u.scale,d.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},d.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},d.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},d.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},d.dot=u.dot,d.lerp=u.lerp,d.slerp=function(e,t,r,n){var i,a,o,s,u,l=t[0],c=t[1],h=t[2],f=t[3],d=r[0],_=r[1],p=r[2],m=r[3];return a=l*d+c*_+h*p+f*m,a<0&&(a=-a,d=-d,_=-_,p=-p,m=-m),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*d,e[1]=s*c+u*_,e[2]=s*h+u*p,e[3]=s*f+u*m,e},d.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},d.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},d.length=u.length,d.len=d.length,d.squaredLength=u.squaredLength,d.sqrLen=d.squaredLength,d.normalize=u.normalize,d.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},d.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},void 0!==e&&(e.quat=d)}(r.exports)}()})),st=ot.vec3,ut=function(e,t,r){e=e||0,t=t||0,r=r||0,this._array=st.fromValues(e,t,r),this._dirty=!0};ut.prototype={constructor:ut,add:function(e){return st.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 ut(this.x,this.y,this.z)},copy:function(e){return st.copy(this._array,e._array),this._dirty=!0,this},cross:function(e,t){return st.cross(this._array,e._array,t._array),this._dirty=!0,this},dist:function(e){return st.dist(this._array,e._array)},distance:function(e){return st.distance(this._array,e._array)},div:function(e){return st.div(this._array,this._array,e._array),this._dirty=!0,this},divide:function(e){return st.divide(this._array,this._array,e._array),this._dirty=!0,this},dot:function(e){return st.dot(this._array,e._array)},len:function(){return st.len(this._array)},length:function(){return st.length(this._array)},lerp:function(e,t,r){return st.lerp(this._array,e._array,t._array,r),this._dirty=!0,this},min:function(e){return st.min(this._array,this._array,e._array),this._dirty=!0,this},max:function(e){return st.max(this._array,this._array,e._array),this._dirty=!0,this},mul:function(e){return st.mul(this._array,this._array,e._array),this._dirty=!0,this},multiply:function(e){return st.multiply(this._array,this._array,e._array),this._dirty=!0,this},negate:function(){return st.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return st.normalize(this._array,this._array),this._dirty=!0,this},random:function(e){return st.random(this._array,e),this._dirty=!0,this},scale:function(e){return st.scale(this._array,this._array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return st.scaleAndAdd(this._array,this._array,e._array,t),this._dirty=!0,this},sqrDist:function(e){return st.sqrDist(this._array,e._array)},squaredDistance:function(e){return st.squaredDistance(this._array,e._array)},sqrLen:function(){return st.sqrLen(this._array)},squaredLength:function(){return st.squaredLength(this._array)},sub:function(e){return st.sub(this._array,this._array,e._array),this._dirty=!0,this},subtract:function(e){return st.subtract(this._array,this._array,e._array),this._dirty=!0,this},transformMat3:function(e){return st.transformMat3(this._array,this._array,e._array),this._dirty=!0,this},transformMat4:function(e){return st.transformMat4(this._array,this._array,e._array),this._dirty=!0,this},transformQuat:function(e){ -return st.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){ut.eulerFromQuat(this,e,t)},eulerFromMat3:function(e,t){ut.eulerFromMat3(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}};var lt=Object.defineProperty;if(lt){var ct=ut.prototype;lt(ct,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),lt(ct,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),lt(ct,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}})}ut.add=function(e,t,r){return st.add(e._array,t._array,r._array),e._dirty=!0,e},ut.set=function(e,t,r,n){st.set(e._array,t,r,n),e._dirty=!0},ut.copy=function(e,t){return st.copy(e._array,t._array),e._dirty=!0,e},ut.cross=function(e,t,r){return st.cross(e._array,t._array,r._array),e._dirty=!0,e},ut.dist=function(e,t){return st.distance(e._array,t._array)},ut.distance=ut.dist,ut.div=function(e,t,r){return st.divide(e._array,t._array,r._array),e._dirty=!0,e},ut.divide=ut.div,ut.dot=function(e,t){return st.dot(e._array,t._array)},ut.len=function(e){return st.length(e._array)},ut.lerp=function(e,t,r,n){return st.lerp(e._array,t._array,r._array,n),e._dirty=!0,e},ut.min=function(e,t,r){return st.min(e._array,t._array,r._array),e._dirty=!0,e},ut.max=function(e,t,r){return st.max(e._array,t._array,r._array),e._dirty=!0,e},ut.mul=function(e,t,r){return st.multiply(e._array,t._array,r._array),e._dirty=!0,e},ut.multiply=ut.mul,ut.negate=function(e,t){return st.negate(e._array,t._array),e._dirty=!0,e},ut.normalize=function(e,t){return st.normalize(e._array,t._array),e._dirty=!0,e},ut.random=function(e,t){return st.random(e._array,t),e._dirty=!0,e},ut.scale=function(e,t,r){return st.scale(e._array,t._array,r),e._dirty=!0,e},ut.scaleAndAdd=function(e,t,r,n){return st.scaleAndAdd(e._array,t._array,r._array,n),e._dirty=!0,e},ut.sqrDist=function(e,t){return st.sqrDist(e._array,t._array)},ut.squaredDistance=ut.sqrDist,ut.sqrLen=function(e){return st.sqrLen(e._array)},ut.squaredLength=ut.sqrLen,ut.sub=function(e,t,r){return st.subtract(e._array,t._array,r._array),e._dirty=!0,e},ut.subtract=ut.sub,ut.transformMat3=function(e,t,r){return st.transformMat3(e._array,t._array,r._array),e._dirty=!0,e},ut.transformMat4=function(e,t,r){return st.transformMat4(e._array,t._array,r._array),e._dirty=!0,e},ut.transformQuat=function(e,t,r){return st.transformQuat(e._array,t._array,r._array),e._dirty=!0,e};var ht=Math.atan2,ft=Math.asin,dt=Math.abs;ut.eulerFromQuat=function(e,t,r){e._dirty=!0,t=t._array;var n=e._array,i=t[0],a=t[1],s=t[2],u=t[3],l=i*i,c=a*a,h=s*s,f=u*u,r=(r||"XYZ").toUpperCase();switch(r){case"XYZ":n[0]=ht(2*(i*u-a*s),f-l-c+h),n[1]=ft(o(2*(i*s+a*u),-1,1)),n[2]=ht(2*(s*u-i*a),f+l-c-h);break;case"YXZ":n[0]=ft(o(2*(i*u-a*s),-1,1)),n[1]=ht(2*(i*s+a*u),f-l-c+h),n[2]=ht(2*(i*a+s*u),f-l+c-h);break;case"ZXY":n[0]=ft(o(2*(i*u+a*s),-1,1)),n[1]=ht(2*(a*u-s*i),f-l-c+h),n[2]=ht(2*(s*u-i*a),f-l+c-h);break;case"ZYX":n[0]=ht(2*(i*u+s*a),f-l-c+h),n[1]=ft(o(2*(a*u-i*s),-1,1)),n[2]=ht(2*(i*a+s*u),f+l-c-h);break;case"YZX":n[0]=ht(2*(i*u-s*a),f-l+c-h),n[1]=ht(2*(a*u-i*s),f+l-c-h),n[2]=ft(o(2*(i*a+s*u),-1,1));break;case"XZY":n[0]=ht(2*(i*u+a*s),f-l+c-h),n[1]=ht(2*(i*s+a*u),f+l-c-h),n[2]=ft(o(2*(s*u-i*a),-1,1));break;default:console.warn("Unkown order: "+r)}return e},ut.eulerFromMat3=function(e,t,r){var n=t._array,i=n[0],a=n[3],s=n[6],u=n[1],l=n[4],c=n[7],h=n[2],f=n[5],d=n[8],_=e._array,r=(r||"XYZ").toUpperCase();switch(r){case"XYZ":_[1]=ft(o(s,-1,1)),dt(s)<.99999?(_[0]=ht(-c,d),_[2]=ht(-a,i)):(_[0]=ht(f,l),_[2]=0);break;case"YXZ":_[0]=ft(-o(c,-1,1)),dt(c)<.99999?(_[1]=ht(s,d),_[2]=ht(u,l)):(_[1]=ht(-h,i),_[2]=0);break;case"ZXY":_[0]=ft(o(f,-1,1)),dt(f)<.99999?(_[1]=ht(-h,d),_[2]=ht(-a,l)):(_[1]=0,_[2]=ht(u,i));break;case"ZYX":_[1]=ft(-o(h,-1,1)),dt(h)<.99999?(_[0]=ht(f,d),_[2]=ht(u,i)):(_[0]=0,_[2]=ht(-a,l));break;case"YZX":_[2]=ft(o(u,-1,1)),dt(u)<.99999?(_[0]=ht(-c,l),_[1]=ht(-h,i)):(_[0]=0,_[1]=ht(s,d));break;case"XZY":_[2]=ft(-o(a,-1,1)),dt(a)<.99999?(_[0]=ht(f,l),_[1]=ht(s,i)):(_[0]=ht(-c,d),_[1]=0);break;default:console.warn("Unkown order: "+r)}return e._dirty=!0,e},ut.POSITIVE_X=new ut(1,0,0),ut.NEGATIVE_X=new ut(-1,0,0),ut.POSITIVE_Y=new ut(0,1,0),ut.NEGATIVE_Y=new ut(0,-1,0),ut.POSITIVE_Z=new ut(0,0,1),ut.NEGATIVE_Z=new ut(0,0,-1),ut.UP=new ut(0,1,0),ut.ZERO=new ut(0,0,0);var _t=ot.vec3,pt=_t.copy,mt=_t.set,vt=function(e,t){this.min=e||new ut(1/0,1/0,1/0),this.max=t||new ut(-1/0,-1/0,-1/0)};vt.prototype={constructor:vt,updateFromVertices:function(e){if(e.length>0){var t=this.min,r=this.max,n=t._array,i=r._array;pt(n,e[0]),pt(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 _t.min(t._array,t._array,e.min._array),_t.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 _t.max(t._array,t._array,e.min._array),_t.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(){var e=_t.create(),t=_t.create(),r=_t.create(),n=_t.create(),i=_t.create(),a=_t.create();return function(o){var s=this.min._array,u=this.max._array,l=o._array;return e[0]=l[0]*s[0],e[1]=l[1]*s[0],e[2]=l[2]*s[0],t[0]=l[0]*u[0],t[1]=l[1]*u[0],t[2]=l[2]*u[0],r[0]=l[4]*s[1],r[1]=l[5]*s[1],r[2]=l[6]*s[1],n[0]=l[4]*u[1],n[1]=l[5]*u[1],n[2]=l[6]*u[1],i[0]=l[8]*s[2],i[1]=l[9]*s[2],i[2]=l[10]*s[2],a[0]=l[8]*u[2],a[1]=l[9]*u[2],a[2]=l[10]*u[2],s[0]=Math.min(e[0],t[0])+Math.min(r[0],n[0])+Math.min(i[0],a[0])+l[12],s[1]=Math.min(e[1],t[1])+Math.min(r[1],n[1])+Math.min(i[1],a[1])+l[13],s[2]=Math.min(e[2],t[2])+Math.min(r[2],n[2])+Math.min(i[2],a[2])+l[14],u[0]=Math.max(e[0],t[0])+Math.max(r[0],n[0])+Math.max(i[0],a[0])+l[12],u[1]=Math.max(e[1],t[1])+Math.max(r[1],n[1])+Math.max(i[1],a[1])+l[13],u[2]=Math.max(e[2],t[2])+Math.max(r[2],n[2])+Math.max(i[2],a[2])+l[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],f=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]*f+n[14];else{var d=-1/o;t[0]=n[0]*i*d,t[1]=n[5]*a*d,r[2]=(n[10]*o+n[14])*d,d=-1/l,r[0]=n[0]*s*d,r[1]=n[5]*u*d,d=-1/f,t[2]=(n[10]*f+n[14])*d}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){for(var e=[],t=0;t<8;t++)e[t]=_t.fromValues(0,0,0);this.vertices=e}var r=this.min._array,n=this.max._array;return mt(e[0],r[0],r[1],r[2]),mt(e[1],r[0],n[1],r[2]),mt(e[2],n[0],r[1],r[2]),mt(e[3],n[0],n[1],r[2]),mt(e[4],r[0],r[1],n[2]),mt(e[5],r[0],n[1],n[2]),mt(e[6],n[0],r[1],n[2]),mt(e[7],n[0],n[1],n[2]),this},copy:function(e){var t=this.min,r=this.max;return pt(t._array,e.min._array),pt(r._array,e.max._array),t._dirty=!0,r._dirty=!0,this},clone:function(){var e=new vt;return e.copy(this),e}};var gt=ot.mat4,yt=ot.vec3,xt=ot.mat3,Tt=ot.quat,Et=function(){this._axisX=new ut,this._axisY=new ut,this._axisZ=new ut,this._array=gt.create(),this._dirty=!0};Et.prototype={constructor:Et,setArray:function(e){for(var t=0;t0&&n.push("#define "+i.toUpperCase()+"_COUNT "+a)}for(var o in r){r[o].enabled&&n.push("#define "+o.toUpperCase()+"_ENABLED")}for(var o in e){var s=e[o];null===s?n.push("#define "+o):n.push("#define "+o+" "+s.toString())}return n.join("\n")},_unrollLoop:function(e,t){function r(e,r,i,a){var o="";isNaN(r)&&(r=r in t?t[r]:n[r]),isNaN(i)&&(i=i in t?t[i]:n[i]);for(var s=parseInt(r);s=0)r.attribSemantics[u]={symbol:a,type:c},h=!1;else if(kt.indexOf(u)>=0){var f=!1,d=u;u.match(/TRANSPOSE$/)&&(f=!0,d=u.slice(0,-9)),r.matrixSemantics[u]={symbol:a,type:c,isTranspose:f,semanticNoTranspose:d},h=!1}else if(Ft.indexOf(u)>=0)r.uniformSemantics[u]={symbol:a,type:c},h=!1;else if("unconfigurable"===u)h=!1;else{if(!(l=r._parseDefaultValue(i,u)))throw new Error('Unkown semantic "'+u+'"');u=""}h&&(t[a]={type:c,value:o?It.array:l||It[i],semantic:u||null})}return["uniform",i,a,o].join(" ")+";\n"}}var t={},r=this,n="vertex";this._uniformList=[],this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(Rt,e),n="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(Rt,e),r.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=t},_parseDefaultValue:function(e,t){var r=/\[\s*(.*)\s*\]/;{if("vec2"!==e&&"vec3"!==e&&"vec4"!==e)return"bool"===e?function(){return"true"===t.toLowerCase()}:"float"===e?function(){return parseFloat(t)}:"int"===e?function(){return parseInt(t)}:void 0;var n=r.exec(t)[1];if(n){var i=n.split(/\s*,\s*/);return function(){return new at.Float32Array(i)}}}},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},attached:function(){this._attacheMaterialNumber++},detached:function(){this._attacheMaterialNumber--},isAttachedToAny:function(){return 0!==this._attacheMaterialNumber},_parseAttributes:function(){function e(e,n,i,a,o){if(n&&i){var s=1;switch(n){case"vec4":s=4;break;case"vec3":s=3;break;case"vec2":s=2;break;case"float":s=1}if(t[i]={type:"float",size:s,semantic:o||null},o){if(Ot.indexOf(o)<0)throw new Error('Unkown semantic "'+o+'"');r.attribSemantics[o]={symbol:i,type:n}}}return["attribute",n,i].join(" ")+";\n"}var t={},r=this;this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(Ct,e),this.attributeTemplates=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:parseFloat(i):null))),""}var t=this,r="vertex";this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(Lt,e),r="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(Lt,e)},_buildProgram:function(e,t,r){var n=this._cache;n.get("program")&&e.deleteProgram(n.get("program"));var i=e.createProgram(),a=e.createShader(e.VERTEX_SHADER);e.shaderSource(a,t),e.compileShader(a);var o=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(o,r),e.compileShader(o);var s=u(e,a,t);if(s)return s;if(s=u(e,o,r))return s;if(e.attachShader(i,a),e.attachShader(i,o),this.attribSemantics.POSITION)e.bindAttribLocation(i,0,this.attribSemantics.POSITION.symbol);else{var l=Object.keys(this.attributeTemplates);e.bindAttribLocation(i,0,l[0])}if(e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))return"Could not link program\nVALIDATE_STATUS: "+e.getProgramParameter(i,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]";for(var c=0;c>t;return e+1},dispose:function(e){var t=this._cache;t.use(e.__GUID__);var r=t.get("webgl_texture");r&&e.gl.deleteTexture(r),t.deleteContext(e.__GUID__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(Vt.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(Vt.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),Vt.BYTE=rt.BYTE,Vt.UNSIGNED_BYTE=rt.UNSIGNED_BYTE,Vt.SHORT=rt.SHORT,Vt.UNSIGNED_SHORT=rt.UNSIGNED_SHORT,Vt.INT=rt.INT,Vt.UNSIGNED_INT=rt.UNSIGNED_INT,Vt.FLOAT=rt.FLOAT,Vt.HALF_FLOAT=36193,Vt.UNSIGNED_INT_24_8_WEBGL=34042,Vt.DEPTH_COMPONENT=rt.DEPTH_COMPONENT,Vt.DEPTH_STENCIL=rt.DEPTH_STENCIL,Vt.ALPHA=rt.ALPHA,Vt.RGB=rt.RGB,Vt.RGBA=rt.RGBA,Vt.LUMINANCE=rt.LUMINANCE,Vt.LUMINANCE_ALPHA=rt.LUMINANCE_ALPHA,Vt.SRGB=35904,Vt.SRGB_ALPHA=35906,Vt.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,Vt.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,Vt.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,Vt.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,Vt.NEAREST=rt.NEAREST,Vt.LINEAR=rt.LINEAR,Vt.NEAREST_MIPMAP_NEAREST=rt.NEAREST_MIPMAP_NEAREST,Vt.LINEAR_MIPMAP_NEAREST=rt.LINEAR_MIPMAP_NEAREST,Vt.NEAREST_MIPMAP_LINEAR=rt.NEAREST_MIPMAP_LINEAR,Vt.LINEAR_MIPMAP_LINEAR=rt.LINEAR_MIPMAP_LINEAR, -Vt.REPEAT=rt.REPEAT,Vt.CLAMP_TO_EDGE=rt.CLAMP_TO_EDGE,Vt.MIRRORED_REPEAT=rt.MIRRORED_REPEAT;var jt=$e.extend({name:"",depthTest:!0,depthMask:!0,transparent:!1,blend:null,_enabledUniforms:null},function(){this.name||(this.name="MATERIAL_"+this.__GUID__),this.shader&&this.attachShader(this.shader),this.uniforms||(this.uniforms={})},{bind:function(e,t,r,n){for(var i=e.gl,t=t||this.shader,a=t.currentTextureSlot(),o=0;o=0},set:function(e,t){if("object"==typeof e)for(var r in e){var n=e[r];this.set(r,n)}else{var i=this.uniforms[e];i&&(void 0===t&&(console.warn('Uniform value "'+e+'" is undefined'),t=null),i.value=t)}},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){this.shader&&this.shader.detached();var r=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var n=this.uniforms;if(this._enabledUniforms=Object.keys(n),this._enabledUniforms.sort(),t)for(var i in r)n[i]&&(n[i].value=r[i].value);e.attached()},detachShader:function(){this.shader.detached(),this.shader=null,this.uniforms={}},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},dispose:function(e,t){if(t)for(var r in this.uniforms){var n=this.uniforms[r].value;if(n)if(n instanceof Vt)n.dispose(e);else if(Array.isArray(n))for(var i=0;i0&&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},beforeRenderObject:function(){},afterRenderObject:function(){},render:function(e,t,r,n){var i=this.gl;this._sceneRendering=e;var 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)}r||e.update(!1),t.getScene()||t.update(!0);for(var l=e.opaqueQueue,c=e.transparentQueue,h=e.material,f=0;f0)for(var _=tr(),p=er.create(),f=0;f0&&e.min._array[2]<0&&(e.max._array[2]=-1e-20),e.applyProjection(t);var u=e.min._array,l=e.max._array;if(l[0]<-1||u[0]>1||l[1]<-1||u[1]>1||l[2]<-1||u[2]>1)return!0}return!1}}(),disposeScene:function(e){this.disposeNode(e,!0,!0),e.dispose()},disposeNode:function(e,t,r){var n={};e.getParent()&&e.getParent().remove(e),e.traverse(function(e){e.geometry&&t&&e.geometry.dispose(this),e.material&&(n[e.material.__GUID__]=e.material),e.dispose&&e.dispose(this)},this);for(var i in n){n[i].dispose(this,r)}},disposeShader:function(e){e.dispose(this)},disposeGeometry:function(e){e.dispose(this)},disposeTexture:function(e){e.dispose(this)},disposeFrameBuffer:function(e){e.dispose(this)},dispose:function(){},screenToNDC:function(e,t,r){r||(r=new Kt),t=this._height-t;var n=this.viewport,i=r._array;return i[0]=(e-n.x)/n.width,i[0]=2*i[0]-1,i[1]=(t-n.y)/n.height,i[1]=2*i[1]-1,r}});nr.opaqueSortFunc=nr.prototype.opaqueSortFunc=function(e,t){return e.renderOrder===t.renderOrder?e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__:e.renderOrder-t.renderOrder},nr.transparentSortFunc=nr.prototype.transparentSortFunc=function(e,t){return e.renderOrder===t.renderOrder?e.__depth===t.__depth?e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__:e.__depth-t.__depth:e.renderOrder-t.renderOrder};var ir={IDENTITY:tr(),WORLD:tr(),VIEW:tr(),PROJECTION:tr(),WORLDVIEW:tr(),VIEWPROJECTION:tr(),WORLDVIEWPROJECTION:tr(),WORLDINVERSE:tr(),VIEWINVERSE:tr(),PROJECTIONINVERSE:tr(),WORLDVIEWINVERSE:tr(),VIEWPROJECTIONINVERSE:tr(),WORLDVIEWPROJECTIONINVERSE:tr(),WORLDTRANSPOSE:tr(),VIEWTRANSPOSE:tr(),PROJECTIONTRANSPOSE:tr(),WORLDVIEWTRANSPOSE:tr(),VIEWPROJECTIONTRANSPOSE:tr(),WORLDVIEWPROJECTIONTRANSPOSE:tr(),WORLDINVERSETRANSPOSE:tr(),VIEWINVERSETRANSPOSE:tr(),PROJECTIONINVERSETRANSPOSE:tr(),WORLDVIEWINVERSETRANSPOSE:tr(),VIEWPROJECTIONINVERSETRANSPOSE:tr(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:tr()};nr.COLOR_BUFFER_BIT=rt.COLOR_BUFFER_BIT,nr.DEPTH_BUFFER_BIT=rt.DEPTH_BUFFER_BIT,nr.STENCIL_BUFFER_BIT=rt.STENCIL_BUFFER_BIT;var ar={get:f},or=ot.quat,sr=function(e,t,r,n){e=e||0,t=t||0,r=r||0,n=void 0===n?1:n,this._array=or.fromValues(e,t,r,n),this._dirty=!0};sr.prototype={constructor:sr,add:function(e){return or.add(this._array,this._array,e._array),this._dirty=!0,this},calculateW:function(){return or.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 sr(this.x,this.y,this.z,this.w)},conjugate:function(){return or.conjugate(this._array,this._array),this._dirty=!0,this},copy:function(e){return or.copy(this._array,e._array),this._dirty=!0,this},dot:function(e){return or.dot(this._array,e._array)},fromMat3:function(e){return or.fromMat3(this._array,e._array),this._dirty=!0,this},fromMat4:function(){var e=ot.mat3,t=e.create();return function(r){return e.fromMat4(t,r._array),e.transpose(t,t),or.fromMat3(this._array,t),this._dirty=!0,this}}(),identity:function(){return or.identity(this._array),this._dirty=!0,this},invert:function(){return or.invert(this._array,this._array),this._dirty=!0,this},len:function(){return or.len(this._array)},length:function(){return or.length(this._array)},lerp:function(e,t,r){return or.lerp(this._array,e._array,t._array,r),this._dirty=!0,this},mul:function(e){return or.mul(this._array,this._array,e._array),this._dirty=!0,this},mulLeft:function(e){return or.multiply(this._array,e._array,this._array),this._dirty=!0,this},multiply:function(e){return or.multiply(this._array,this._array,e._array),this._dirty=!0,this},multiplyLeft:function(e){return or.multiply(this._array,e._array,this._array),this._dirty=!0,this},normalize:function(){return or.normalize(this._array,this._array),this._dirty=!0,this},rotateX:function(e){return or.rotateX(this._array,this._array,e),this._dirty=!0,this},rotateY:function(e){return or.rotateY(this._array,this._array,e),this._dirty=!0,this},rotateZ:function(e){return or.rotateZ(this._array,this._array,e),this._dirty=!0,this},rotationTo:function(e,t){return or.rotationTo(this._array,e._array,t._array),this._dirty=!0,this},setAxes:function(e,t,r){return or.setAxes(this._array,e._array,t._array,r._array),this._dirty=!0,this},setAxisAngle:function(e,t){return or.setAxisAngle(this._array,e._array,t),this._dirty=!0,this},slerp:function(e,t,r){return or.slerp(this._array,e._array,t._array,r),this._dirty=!0,this},sqrLen:function(){return or.sqrLen(this._array)},squaredLength:function(){return or.squaredLength(this._array)},fromEuler:function(e,t){return sr.fromEuler(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}};var ur=Object.defineProperty;if(ur){var lr=sr.prototype;ur(lr,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),ur(lr,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),ur(lr,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}}),ur(lr,"w",{get:function(){return this._array[3]},set:function(e){this._array[3]=e,this._dirty=!0}})}sr.add=function(e,t,r){return or.add(e._array,t._array,r._array),e._dirty=!0,e},sr.set=function(e,t,r,n,i){or.set(e._array,t,r,n,i),e._dirty=!0},sr.copy=function(e,t){return or.copy(e._array,t._array),e._dirty=!0,e},sr.calculateW=function(e,t){return or.calculateW(e._array,t._array),e._dirty=!0,e},sr.conjugate=function(e,t){return or.conjugate(e._array,t._array),e._dirty=!0,e},sr.identity=function(e){return or.identity(e._array),e._dirty=!0,e},sr.invert=function(e,t){return or.invert(e._array,t._array),e._dirty=!0,e},sr.dot=function(e,t){return or.dot(e._array,t._array)},sr.len=function(e){return or.length(e._array)},sr.lerp=function(e,t,r,n){return or.lerp(e._array,t._array,r._array,n),e._dirty=!0,e},sr.slerp=function(e,t,r,n){return or.slerp(e._array,t._array,r._array,n),e._dirty=!0,e},sr.mul=function(e,t,r){return or.multiply(e._array,t._array,r._array),e._dirty=!0,e},sr.multiply=sr.mul,sr.rotateX=function(e,t,r){return or.rotateX(e._array,t._array,r),e._dirty=!0,e},sr.rotateY=function(e,t,r){return or.rotateY(e._array,t._array,r),e._dirty=!0,e},sr.rotateZ=function(e,t,r){return or.rotateZ(e._array,t._array,r),e._dirty=!0,e},sr.setAxisAngle=function(e,t,r){return or.setAxisAngle(e._array,t._array,r),e._dirty=!0,e},sr.normalize=function(e,t){return or.normalize(e._array,t._array),e._dirty=!0,e},sr.sqrLen=function(e){return or.sqrLen(e._array)},sr.squaredLength=sr.sqrLen,sr.fromMat3=function(e,t){return or.fromMat3(e._array,t._array),e._dirty=!0,e},sr.setAxes=function(e,t,r,n){return or.setAxes(e._array,t._array,r._array,n._array),e._dirty=!0,e},sr.rotationTo=function(e,t,r){return or.rotationTo(e._array,t._array,r._array),e._dirty=!0,e},sr.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}};var cr=ot.mat4,hr=0,fr=$e.extend({name:"",position:null,rotation:null,scale:null,worldTransform:null,localTransform:null,autoUpdateLocalTransform:!0,_parent:null,_scene:null,_needsUpdateWorldTransform:!0,_inIterating:!1,__depth:0},function(){this.name||(this.name=(this.type||"NODE")+"_"+hr++),this.position||(this.position=new ut),this.rotation||(this.rotation=new sr),this.scale||(this.scale=new ut(1,1,1)),this.worldTransform=new Et,this.localTransform=new Et,this._children=[]},{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(e){var t=this._scene;if(t){var r=t._nodeRepository;delete r[this.name],r[e]=this}this.name=e},add:function(e){this._inIterating&&console.warn("Add operation can cause unpredictable error when in iterating");var t=e._parent;if(t!==this){t&&t.remove(e),e._parent=this,this._children.push(e);var r=this._scene;r&&r!==e.scene&&e.traverse(this._addSelfToScene,this),e._needsUpdateWorldTransform=!0}},remove:function(e){this._inIterating&&console.warn("Remove operation can cause unpredictable error when in iterating");var t=this._children,r=t.indexOf(e);r<0||(t.splice(r,1),e._parent=null,this._scene&&e.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var e=this._children,t=0;t0&&this._updateRenderQueue(n)}},_updateLightUniforms:function(){var e=this.lights;e.sort(d);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;i 0.0) {\n vec3 normalTexel = texture2D(normalMap, uv).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n tbn[1] = -tbn[1];\n N = normalize(tbn * N);\n }\n }\n#endif\n vec3 diffuseTerm = vec3(0.0, 0.0, 0.0);\n vec3 specularTerm = vec3(0.0, 0.0, 0.0);\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, spec);\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_];\n }}\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N) * ambientSHLightColor[_idx_];\n }}\n#endif\n#ifdef POINT_LIGHT_COUNT\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsPoint[POINT_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfPointLights(v_WorldPosition, shadowContribsPoint);\n }\n#endif\n for(int _idx_ = 0; _idx_ < POINT_LIGHT_COUNT; _idx_++)\n {{\n vec3 lightPosition = pointLightPosition[_idx_];\n vec3 lc = pointLightColor[_idx_];\n float range = pointLightRange[_idx_];\n vec3 L = lightPosition - v_WorldPosition;\n float dist = length(L);\n float attenuation = lightAttenuation(dist, range);\n L /= dist;\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, L), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n float shadowContrib = 1.0;\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\n if(shadowEnabled)\n {\n shadowContrib = shadowContribsPoint[_idx_];\n }\n#endif\n vec3 li = lc * ndl * attenuation * shadowContrib;\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\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 _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -normalize(directionalLightDirection[_idx_]);\n vec3 lc = directionalLightColor[_idx_];\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, L), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if(shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n vec3 li = lc * ndl * shadowContrib;\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n#ifdef SPOT_LIGHT_COUNT\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsSpot[SPOT_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfSpotLights(v_WorldPosition, shadowContribsSpot);\n }\n#endif\n for(int i = 0; i < SPOT_LIGHT_COUNT; i++)\n {\n vec3 lightPosition = spotLightPosition[i];\n vec3 spotLightDirection = -normalize(spotLightDirection[i]);\n vec3 lc = spotLightColor[i];\n float range = spotLightRange[i];\n float a = spotLightUmbraAngleCosine[i];\n float b = spotLightPenumbraAngleCosine[i];\n float falloffFactor = spotLightFalloffFactor[i];\n vec3 L = lightPosition - v_WorldPosition;\n float dist = length(L);\n float attenuation = lightAttenuation(dist, range);\n L /= dist;\n float c = dot(spotLightDirection, L);\n float falloff;\n falloff = clamp((c - a) /( b - a), 0.0, 1.0);\n falloff = pow(falloff, falloffFactor);\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, L), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n float shadowContrib = 1.0;\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsSpot[i];\n }\n#endif\n vec3 li = lc * attenuation * (1.0 - falloff) * shadowContrib * ndl;\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }\n#endif\n vec4 outColor = albedoColor;\n outColor.rgb *= diffuseTerm;\n outColor.rgb += specularTerm;\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\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 = spec * 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), 51.5);\n outColor.rgb += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2;\n }}\n#endif\n#ifdef ENVIRONMENTMAP_ENABLED\n vec3 envWeight = g * fresnelTerm;\n vec3 L = reflect(-V, N);\n #ifdef PARALLAX_CORRECTED\n L = parallaxCorrect(L, v_WorldPosition, environmentBoxMin, environmentBoxMax);\n #endif\n #ifdef ENVIRONMENTMAP_PREFILTER\n float rough = clamp(1.0 - g, 0.0, 1.0);\n float bias = rough * maxMipmapLevel;\n vec3 envTexel = decodeHDR(textureCubeLodEXT(environmentMap, L, bias)).rgb;\n #ifdef BRDFLOOKUP_ENABLED\n vec2 brdfParam = texture2D(brdfLookup, vec2(rough, ndv)).xy;\n envWeight = spec * brdfParam.x + brdfParam.y;\n #endif\n #else\n vec3 envTexel = textureCube(environmentMap, L).xyz;\n #endif\n outColor.rgb += envTexel * envWeight;\n#endif\n float aoFactor = 1.0;\n#ifdef SSAOMAP_ENABLED\n aoFactor = min(texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r, aoFactor);\n#endif\n#ifdef AOMAP_ENABLED\n aoFactor = min(1.0 - clamp((1.0 - texture2D(aoMap, v_Texcoord2).r) * aoIntensity, 0.0, 1.0), aoFactor);\n#endif\n outColor.rgb *= aoFactor;\n vec3 lEmission = emission;\n#ifdef EMISSIVEMAP_ENABLED\n lEmission *= texture2D(emissiveMap, uv).rgb;\n#endif\n outColor.rgb += lEmission * emissionIntensity;\n#ifdef GAMMA_ENCODE\n outColor.rgb = pow(outColor.rgb, vec3(1 / 2.2));\n#endif\n if(lineWidth > 0.)\n {\n outColor.rgb = mix(outColor.rgb, lineColor.rgb, (1.0 - edgeFactor(lineWidth)) * lineColor.a);\n }\n#ifdef ALPHA_TEST\n if (outColor.a < alphaCutoff) {\n discard;\n }\n#endif\n gl_FragColor = encodeHDR(outColor);\n}\n@end\n";Ut.import(pr);var mr={},vr={},gr=["diffuseMap","normalMap","roughnessMap","metalnessMap","emissiveMap","environmentMap","brdfLookup","ssaoMap","aoMap"],yr=["color","emission","emissionIntensity","alpha","roughness","metalness","uvRepeat","uvOffset","aoIntensity","alphaCutoff"],xr=["jointCount","linear","encodeRGBM","decodeRGBM","doubleSided","alphaTest","roughnessChannel","metalnessChannel"],Tr=["environmentMapPrefiltered","linear","encodeRGBM","decodeRGBM","doubleSided","alphaTest","parallaxCorrected"],Er=gr.concat(Tr),br=Er.reduce(function(e,t,r){return e[t]=4096<0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=fr.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},render:function(e,t){var r=e.gl,t=t||this.material.shader,n=this.geometry,i=this.mode,a=n.vertexCount,o=n.isUseIndices(),s=e.getGLExtension("OES_element_index_uint"),u=s&&a>65535,l=u?r.UNSIGNED_INT:r.UNSIGNED_SHORT,c=e.getGLExtension("OES_vertex_array_object"),h=!n.dynamic,f=this._renderInfo;f.vertexCount=a,f.triangleCount=0,f.drawCallCount=0;var d=!1;if(Ar=e.__GUID__+"-"+n.__GUID__+"-"+t.__GUID__,Ar!==Nr?d=!0:(a>65535&&!s&&o||c&&h||n._cache.isDirty())&&(d=!0),Nr=Ar,d){var _=this._drawCache[Ar];if(!_){var p=n.getBufferChunks(e);if(!p)return;_=[];for(var m=0;m>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},Lr.nearestPowerOfTwo=function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))};var Dr=Lr.isPowerOfTwo,Pr=Vt.extend(function(){return{image:null,pixels:null,mipmaps:[]}},{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;t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var i=e.getGLExtension("EXT_texture_filter_anisotropic");if(i&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_2D,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===n){e.getGLExtension("OES_texture_half_float")||(n=rt.FLOAT)}if(this.mipmaps.length)for(var a=this.width,o=this.height,s=0;s=Vt.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,r,a,n,i,0,t.pixels):e.texImage2D(e.TEXTURE_2D,r,a,n,i,0,a,o,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(){var e,t;return this.image?(e=this.image.width,t=this.image.height):(e=this.width,t=this.height),Dr(e)&&Dr(t)},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(Pr.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(Pr.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)}});var Ir=Cr.extend({skeleton:null,joints:null,useSkinMatricesTexture:!1},function(){this.joints||(this.joints=[])},{isSkinnedMesh:function(){return!(!this.skeleton||!this.material.shader.isDefined("vertex","SKINNING"))},render:function(e,t){var r=e.gl;if(t=t||this.material.shader,this.skeleton){this.skeleton.update();var n=this.skeleton.getSubSkinMatrices(this.__GUID__,this.joints);if(this.useSkinMatricesTexture){var i,a=this.joints.length;i=a>256?64:a>64?32:a>16?16:8;var o=this.getSkinMatricesTexture();o.width=i,o.height=i,o.pixels&&o.pixels.length===i*i*4||(o.pixels=new Float32Array(i*i*4)),o.pixels.set(n),o.dirty(),t.setUniform(r,"1f","skinMatricesTextureSize",i)}else t.setUniformOfSemantic(r,"SKIN_MATRIX",n)}return Cr.prototype.render.call(this,e,t)},getSkinMatricesTexture:function(){return this._skinMatricesTexture=this._skinMatricesTexture||new Pr({type:rt.FLOAT,minFilter:rt.NEAREST,magFilter:rt.NEAREST,useMipmap:!1,flipY:!1}),this._skinMatricesTexture}});Ir.POINTS=rt.POINTS,Ir.LINES=rt.LINES,Ir.LINE_LOOP=rt.LINE_LOOP,Ir.LINE_STRIP=rt.LINE_STRIP,Ir.TRIANGLES=rt.TRIANGLES,Ir.TRIANGLE_STRIP=rt.TRIANGLE_STRIP,Ir.TRIANGLE_FAN=rt.TRIANGLE_FAN,Ir.BACK=rt.BACK,Ir.FRONT=rt.FRONT,Ir.FRONT_AND_BACK=rt.FRONT_AND_BACK,Ir.CW=rt.CW,Ir.CCW=rt.CCW;var Or=$e.extend({name:"",index:-1,node:null,rootNode:null}),Fr=ot.quat,kr=ot.vec3,Br=ot.mat4,Ur=$e.extend(function(){return{relativeRootNode:null,name:"",joints:[],_clips:[],_invBindPoseMatricesArray:null,_jointMatricesSubArrays:[],_skinMatricesArray:null,_skinMatricesSubArrays:[],_subSkinMatricesArray:{}}},{addClip:function(e,t){for(var r=0;r0&&this._clips.splice(t,1)},removeClipsAll:function(){this._clips=[]},getClip:function(e){if(this._clips[e])return this._clips[e].clip},getClipNumber:function(){return this._clips.length},updateJointMatrices:function(){var e=Br.create();return function(){this._invBindPoseMatricesArray=new Float32Array(16*this.joints.length),this._skinMatricesArray=new Float32Array(16*this.joints.length);for(var t=0;tthis.distance,i=1;i<8;i++)if(Hr.dot(t[i]._array,r)>this.distance!=n)return!0},intersectLine:function(){var e=Hr.create();return function(t,r,n){var i=this.distanceToPoint(t),a=this.distanceToPoint(r);if(i>0&&a>0||i<0&&a<0)return null;var o=this.normal._array,s=this.distance,u=t._array;Hr.sub(e,r._array,t._array),Hr.normalize(e,e);var l=Hr.dot(o,e);if(0===l)return null;n||(n=new ut);var c=(Hr.dot(o,u)-s)/l;return Hr.scaleAndAdd(n._array,u,e,-c),n._dirty=!0,n}}(),applyTransform:function(){var e=zr.create(),t=Gr.create(),r=Gr.create();return r[3]=1,function(n){n=n._array,Hr.scale(r,this.normal._array,this.distance),Gr.transformMat4(r,r,n),this.distance=Hr.dot(r,this.normal._array),zr.invert(e,n),zr.transpose(e,e),t[3]=0,Hr.copy(t,this.normal._array),Gr.transformMat4(t,t,e),Hr.copy(this.normal._array,t)}}(),copy:function(e){Hr.copy(this.normal._array,e.normal._array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new qr;return e.copy(this),e}};var Wr=ot.vec3,Vr=Wr.set,jr=Wr.copy,Xr=Wr.transformMat4,Kr=Math.min,Yr=Math.max,Zr=function(){this.planes=[];for(var e=0;e<6;e++)this.planes.push(new qr);this.boundingBox=new vt,this.vertices=[];for(var e=0;e<8;e++)this.vertices[e]=Wr.fromValues(0,0,0)};Zr.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],u=r[5],l=r[6],c=r[7],h=r[8],f=r[9],d=r[10],_=r[11],p=r[12],m=r[13],v=r[14],g=r[15];Vr(t[0].normal._array,o-n,c-s,_-h),t[0].distance=-(g-p),t[0].normalize(),Vr(t[1].normal._array,o+n,c+s,_+h),t[1].distance=-(g+p),t[1].normalize(),Vr(t[2].normal._array,o+i,c+u,_+f),t[2].distance=-(g+m),t[2].normalize(),Vr(t[3].normal._array,o-i,c-u,_-f),t[3].distance=-(g-m),t[3].normalize(),Vr(t[4].normal._array,o-a,c-l,_-d),t[4].distance=-(g-v),t[4].normalize(),Vr(t[5].normal._array,o+a,c+l,_+d),t[5].distance=-(g+v),t[5].normalize();var y=this.boundingBox;if(0===g){var x=u/n,T=-v/(d-1),E=-v/(d+1),b=-E/u,S=-T/u;y.min.set(-b*x,-b,E),y.max.set(b*x,b,T);var A=this.vertices;Vr(A[0],-b*x,-b,E),Vr(A[1],-b*x,b,E),Vr(A[2],b*x,-b,E),Vr(A[3],b*x,b,E),Vr(A[4],-S*x,-S,T),Vr(A[5],-S*x,S,T),Vr(A[6],S*x,-S,T),Vr(A[7],S*x,S,T)}else{var N=(-1-p)/n,w=(1-p)/n,M=(1-m)/u,R=(-1-m)/u,C=(-1-v)/d,L=(1-v)/d;y.min.set(Math.min(N,w),Math.min(R,M),Math.min(L,C)),y.max.set(Math.max(w,N),Math.max(M,R),Math.max(C,L));var D=y.min._array,P=y.max._array,A=this.vertices;Vr(A[0],D[0],D[1],D[2]),Vr(A[1],D[0],P[1],D[2]),Vr(A[2],P[0],D[1],D[2]),Vr(A[3],P[0],P[1],D[2]),Vr(A[4],D[0],D[1],P[2]),Vr(A[5],D[0],P[1],P[2]),Vr(A[6],P[0],D[1],P[2]),Vr(A[7],P[0],P[1],P[2])}},getTransformedBoundingBox:function(){var e=Wr.create();return function(t,r){var n=this.vertices,i=r._array,a=t.min,o=t.max,s=a._array,u=o._array,l=n[0];Xr(e,l,i),jr(s,e),jr(u,e);for(var c=1;c<8;c++)l=n[c],Xr(e,l,i),s[0]=Kr(e[0],s[0]),s[1]=Kr(e[1],s[1]),s[2]=Kr(e[2],s[2]),u[0]=Yr(e[0],u[0]),u[1]=Yr(e[1],u[1]),u[2]=Yr(e[2],u[2]);return a._dirty=!0,o._dirty=!0,t}}()};var Qr=ot.vec3,Jr=function(e,t){this.origin=e||new ut,this.direction=t||new ut};Jr.prototype={constructor:Jr,intersectPlane:function(e,t){var r=e.normal._array,n=e.distance,i=this.origin._array,a=this.direction._array,o=Qr.dot(r,a);if(0===o)return null;t||(t=new ut);var s=(Qr.dot(r,i)-n)/o;return Qr.scaleAndAdd(t._array,i,a,-s),t._dirty=!0,t},mirrorAgainstPlane:function(e){var t=Qr.dot(e.normal._array,this.direction._array);Qr.scaleAndAdd(this.direction._array,this.direction._array,e.normal._array,2*-t),this.direction._dirty=!0},distanceToPoint:function(){var e=Qr.create();return function(t){Qr.sub(e,t,this.origin._array);var r=Qr.dot(e,this.direction._array);if(r<0)return Qr.distance(this.origin._array,t);var n=Qr.lenSquared(e);return Math.sqrt(n-r*r)}}(),intersectSphere:function(){var e=Qr.create();return function(t,r,n){var i=this.origin._array,a=this.direction._array;t=t._array,Qr.sub(e,t,i);var o=Qr.dot(e,a),s=Qr.squaredLength(e),u=s-o*o,l=r*r;if(!(u>l)){var c=Math.sqrt(l-u),h=o-c,f=o+c;return n||(n=new ut),h<0?f<0?null:(Qr.scaleAndAdd(n._array,i,a,f),n):(Qr.scaleAndAdd(n._array,i,a,h),n)}}}(),intersectBoundingBox:function(e,t){var r,n,i,a,o,s,u=this.direction._array,l=this.origin._array,c=e.min._array,h=e.max._array,f=1/u[0],d=1/u[1],_=1/u[2];if(f>=0?(r=(c[0]-l[0])*f,n=(h[0]-l[0])*f):(n=(c[0]-l[0])*f,r=(h[0]-l[0])*f),d>=0?(i=(c[1]-l[1])*d,a=(h[1]-l[1])*d):(a=(c[1]-l[1])*d,i=(h[1]-l[1])*d),r>a||i>n)return null;if((i>r||r!==r)&&(r=i),(a=0?(o=(c[2]-l[2])*_,s=(h[2]-l[2])*_):(s=(c[2]-l[2])*_,o=(h[2]-l[2])*_),r>s||o>n)return null;if((o>r||r!==r)&&(r=o),(s=0?r:n;return t||(t=new ut),Qr.scaleAndAdd(t._array,l,u,p),t},intersectTriangle:function(){var e=Qr.create(),t=Qr.create(),r=Qr.create(),n=Qr.create();return function(i,a,o,s,u,l){var c=this.direction._array,h=this.origin._array;i=i._array,a=a._array,o=o._array,Qr.sub(e,a,i),Qr.sub(t,o,i),Qr.cross(n,t,c);var f=Qr.dot(e,n);if(s){if(f>-1e-5)return null}else if(f>-1e-5&&f<1e-5)return null;Qr.sub(r,h,i);var d=Qr.dot(n,r)/f;if(d<0||d>1)return null;Qr.cross(n,e,r);var _=Qr.dot(c,n)/f;if(_<0||_>1||d+_>1)return null;Qr.cross(n,e,t);var p=-Qr.dot(r,n)/f;return p<0?null:(u||(u=new ut),l&&ut.set(l,1-d-_,d,_),Qr.scaleAndAdd(u._array,h,c,p),u)}}(),applyTransform:function(e){ut.add(this.direction,this.direction,this.origin),ut.transformMat4(this.origin,this.origin,e),ut.transformMat4(this.direction,this.direction,e),ut.sub(this.direction,this.direction,this.origin),ut.normalize(this.direction,this.direction)},copy:function(e){ut.copy(this.origin,e.origin),ut.copy(this.direction,e.direction)},clone:function(){var e=new Jr;return e.copy(this),e}};var $r=ot.vec3,en=ot.vec4,tn=fr.extend(function(){return{projectionMatrix:new Et,invProjectionMatrix:new Et,viewMatrix:new Et,frustum:new Zr}},function(){this.update(!0)},{update:function(e){fr.prototype.update.call(this,e),Et.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),Et.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(e){Et.copy(this.viewMatrix,e),Et.invert(this.worldTransform,e),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(e){Et.copy(this.projectionMatrix,e),Et.invert(this.invProjectionMatrix,e),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:function(){var e=en.create();return function(t,r){var n=void 0!==r?r:new Jr,i=t._array[0],a=t._array[1];return en.set(e,i,a,-1,1),en.transformMat4(e,e,this.invProjectionMatrix._array),en.transformMat4(e,e,this.worldTransform._array),$r.scale(n.origin._array,e,1/e[3]),en.set(e,i,a,1,1),en.transformMat4(e,e,this.invProjectionMatrix._array),en.transformMat4(e,e,this.worldTransform._array),$r.scale(e,e,1/e[3]),$r.sub(n.direction._array,e,n.origin._array),$r.normalize(n.direction._array,n.direction._array),n.direction._dirty=!0,n.origin._dirty=!0,n}}()}),rn=tn.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=tn.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}}),nn=tn.extend({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix._array;this.left=(-1-e[12])/e[0],this.right=(1-e[12])/e[0],this.top=(1-e[13])/e[5],this.bottom=(-1-e[13])/e[5],this.near=-(-1-e[14])/e[10],this.far=-(1-e[14])/e[10]},clone:function(){var e=tn.prototype.clone.call(this);return e.left=this.left,e.right=this.right,e.near=this.near,e.far=this.far,e.top=this.top,e.bottom=this.bottom,e}}),an={linear:function(e){return e},quadraticIn:function(e){return e*e},quadraticOut:function(e){return e*(2-e)},quadraticInOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},cubicIn:function(e){return e*e*e},cubicOut:function(e){return--e*e*e+1},cubicInOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},quarticIn:function(e){return e*e*e*e},quarticOut:function(e){return 1- --e*e*e*e},quarticInOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)},quinticIn:function(e){return e*e*e*e*e},quinticOut:function(e){return--e*e*e*e*e+1},quinticInOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)},sinusoidalIn:function(e){return 1-Math.cos(e*Math.PI/2)},sinusoidalOut:function(e){return Math.sin(e*Math.PI/2)},sinusoidalInOut:function(e){return.5*(1-Math.cos(Math.PI*e))},exponentialIn:function(e){return 0===e?0:Math.pow(1024,e-1)},exponentialOut:function(e){return 1===e?1:1-Math.pow(2,-10*e)},exponentialInOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(2-Math.pow(2,-10*(e-1)))},circularIn:function(e){return 1-Math.sqrt(1-e*e)},circularOut:function(e){return Math.sqrt(1- --e*e)},circularInOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)},elasticIn:function(e){var t,r=.1;return 0===e?0:1===e?1:(!r||r<1?(r=1,t=.1):t=.4*Math.asin(1/r)/(2*Math.PI),-r*Math.pow(2,10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/.4))},elasticOut:function(e){var t,r=.1;return 0===e?0:1===e?1:(!r||r<1?(r=1,t=.1):t=.4*Math.asin(1/r)/(2*Math.PI),r*Math.pow(2,-10*e)*Math.sin((e-t)*(2*Math.PI)/.4)+1)},elasticInOut:function(e){var t,r=.1;return 0===e?0:1===e?1:(!r||r<1?(r=1,t=.1):t=.4*Math.asin(1/r)/(2*Math.PI),(e*=2)<1?r*Math.pow(2,10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/.4)*-.5:r*Math.pow(2,-10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/.4)*.5+1)},backIn:function(e){var t=1.70158;return e*e*((t+1)*e-t)},backOut:function(e){var t=1.70158;return--e*e*((t+1)*e+t)+1},backInOut:function(e){var t=2.5949095;return(e*=2)<1?e*e*((t+1)*e-t)*.5:.5*((e-=2)*e*((t+1)*e+t)+2)},bounceIn:function(e){return 1-an.bounceOut(1-e)},bounceOut:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},bounceInOut:function(e){return e<.5?.5*an.bounceIn(2*e):.5*an.bounceOut(2*e-1)+.5}},on=function(e){e=e||{},this.name=e.name||"",this.target=e.target,this.life=e.life||1e3,this.delay=e.delay||0,this.gap=e.gap||0,this.playbackRate=e.playbackRate||1,this._initialized=!1,this._elapsedTime=0,this._loop=null!=e.loop&&e.loop,this.setLoop(this._loop),null!=e.easing&&this.setEasing(e.easing),this.onframe=e.onframe||g,this.onfinish=e.onfinish||g,this.onrestart=e.onrestart||g,this._paused=!1};on.prototype={gap:0,life:0,delay:0,setLoop:function(e){this._loop=e,e&&(this._loopRemained="number"==typeof e?e:1e8)},setEasing:function(e){"string"==typeof e&&(e=an[e]),this.easing=e},step:function(e,t,r){if(this._initialized||(this._startTime=e+this.delay,this._initialized=!0),null!=this._currentTime&&(t=e-this._currentTime),this._currentTime=e,this._paused)return"paused";if(!(e0?(this._restartInLoop(e),this._loopRemained--,"restart"):(this._needsRemove=!0,"finish"):null}}},setTime:function(e){return this.step(e+this._startTime)},restart:function(e){var t=0;e&&(this._elapse(e),t=this._elapsedTime%this.life),e=e||Date.now(),this._startTime=e-t+this.delay,this._elapsedTime=0,this._needsRemove=!1,this._paused=!1},getElapsedTime:function(){return this._elapsedTime},_restartInLoop:function(e){this._startTime=e+this.gap,this._elapsedTime=0},_elapse:function(e,t){this._elapsedTime+=t*this.playbackRate},fire:function(e,t){var r="on"+e;this[r]&&this[r](this.target,t)},clone:function(){var e=new this.constructor;return e.name=this.name,e._loop=this._loop,e._loopRemained=this._loopRemained,e.life=this.life,e.gap=this.gap,e.delay=this.delay,e},pause:function(){this._paused=!0},resume:function(){this._paused=!1}},on.prototype.constructor=on;var sn=ot.quat,un=ot.vec3,ln=function(e){e=e||{},on.call(this,e),this.tracks=e.tracks||[]};ln.prototype=Object.create(on.prototype),ln.prototype.constructor=ln,ln.prototype.step=function(e,t,r){var n=on.prototype.step.call(this,e,t,!0);if("finish"!==n){var e=this.getElapsedTime();this._range&&(e=this._range[0]+e),this.setTime(e)}return r||"paused"===n||this.fire("frame"),n},ln.prototype.setRange=function(e){this.calcLifeFromTracks(),this._range=e,e&&(e[1]=Math.min(e[1],this.life),e[0]=Math.min(e[0],this.life),this.life=e[1]-e[0])},ln.prototype.setTime=function(e){for(var t=0;t=0&&this.tracks.splice(t,1)},ln.prototype.getSubClip=function(e,t,r){for(var n=new ln({name:this.name}),i=0;i=e.time)return this.keyFrames.splice(t,0,e),t}this.life=e.time,this.keyFrames.push(e)},fn.prototype.addKeyFrames=function(e){for(var t=0;ti[i.length-1].time)){if(e=a-1?a-1:this._cacheKey+1,s=o;s>=0;s--)if(i[s].time<=e&&i[s][t])r=i[s],this._cacheKey=s,this._cacheTime=e;else if(i[s][t]){n=i[s];break}}else for(var s=this._cacheKey;s=t.time[r-1])e=t.time[r-1],n=r-2;else if(e=0;a--)if(t.time[a-1]<=e&&t.time[a]>e){n=a-1;break}}else for(var a=this._cacheKey;ae){n=a;break}if(n>-1){this._cacheKey=n,this._cacheTime=e;var o=n,s=n+1,u=t.time[o],l=t.time[s],c=l-u,h=0===c?0:(e-u)/c;t.rotation&&T(this.rotation,t.rotation,t.rotation,h,4*o,4*s),t.position&&x(this.position,t.position,t.position,h,3*o,3*s),t.scale&&x(this.scale,t.scale,t.scale,h,3*o,3*s)}n==r-2&&(this._cacheKey=0,this._cacheTime=0),this.updateTarget()}},pn.prototype.updateTarget=function(){var e=this.channels;this.target&&(e.position&&this.target.position.setArray(this.position),e.rotation&&this.target.rotation.setArray(this.rotation),e.scale&&this.target.scale.setArray(this.scale))},pn.prototype.getMaxTime=function(){return this.channels.time[this.channels.time.length-1]},pn.prototype.getSubTrack=function(e,t){var r=new pn({name:this.name}),n=this.channels.time[0];e=Math.min(Math.max(e,n),this.life),t=Math.min(Math.max(t,n),this.life);var i=this._findRange(e),a=this._findRange(t),o=a[0]-i[0]+1;0===i[1]&&0===a[1]&&(o-=1),this.channels.rotation&&(r.channels.rotation=new Float32Array(4*o)),this.channels.position&&(r.channels.position=new Float32Array(3*o)),this.channels.scale&&(r.channels.scale=new Float32Array(3*o)),this.channels.time&&(r.channels.time=new Float32Array(o)),this.setTime(e);for(var s=0;s<3;s++)r.channels.rotation[s]=this.rotation[s],r.channels.position[s]=this.position[s],r.channels.scale[s]=this.scale[s];r.channels.time[0]=0,r.channels.rotation[3]=this.rotation[3];for(var s=1;se&&(n=i);var a=0;if(n>=0)var o=t.time[n],s=t.time[n+1],a=(e-o)/(s-o);return[n,a]},pn.prototype.blend1D=fn.prototype.blend1D,pn.prototype.blend2D=fn.prototype.blend2D,pn.prototype.additiveBlend=fn.prototype.additiveBlend,pn.prototype.subtractiveBlend=fn.prototype.subtractiveBlend,pn.prototype.clone=function(){var e=pn.prototype.clone.call(this);return e.channels={time:this.channels.time||null,position:this.channels.position||null,rotation:this.channels.rotation||null,scale:this.channels.scale||null},_n.copy(e.position,this.position),dn.copy(e.rotation,this.rotation),_n.copy(e.scale,this.scale),e.target=this.target,e.updateTarget(),e},b.prototype.clone=function(e){var t=new this.constructor(this.name,this.type,this.size,this.semantic);return e&&console.warn("todo"),t},S.prototype.constructor=new b,S.prototype.init=function(e){if(!this.value||this.value.length!=e*this.size){var t=E(this.type);this.value=new t(e*this.size)}},S.prototype.fromArray=function(e){var t,r=E(this.type);if(e[0]&&e[0].length){var n=0,i=this.size;t=new r(e.length*i);for(var a=0;aa[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=xn());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?at.Uint32Array:at.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)},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 at.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,r=this.getEnabledAttributes(),n={},i=0;i 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 qtek.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 qtek.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"),Ut.import(Sn),Ut.import("\n@export qtek.lambert.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\nattribute vec3 barycentric;\n@import qtek.chunk.skinning_header\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\nvarying vec3 v_Barycentric;\nvoid main()\n{\n vec3 skinnedPosition = position;\n vec3 skinnedNormal = normal;\n#ifdef SKINNING\n @import qtek.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n skinnedNormal = (skinMatrixWS * vec4(normal, 0.0)).xyz;\n#endif\n gl_Position = worldViewProjection * vec4( skinnedPosition, 1.0 );\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_Normal = normalize( ( worldInverseTranspose * vec4(skinnedNormal, 0.0) ).xyz );\n v_WorldPosition = ( world * vec4( skinnedPosition, 1.0) ).xyz;\n v_Barycentric = barycentric;\n}\n@end\n@export qtek.lambert.fragment\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\nuniform sampler2D diffuseMap;\nuniform sampler2D alphaMap;\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform vec3 emission : [0.0, 0.0, 0.0];\nuniform float alpha : 1.0;\n#ifdef ALPHA_TEST\nuniform float alphaCutoff: 0.9;\n#endif\nuniform float lineWidth : 0.0;\nuniform vec4 lineColor : [0.0, 0.0, 0.0, 0.6];\nvarying vec3 v_Barycentric;\n#ifdef AMBIENT_LIGHT_COUNT\n@import qtek.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import qtek.header.ambient_sh_light\n#endif\n#ifdef POINT_LIGHT_COUNT\n@import qtek.header.point_light\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import qtek.header.directional_light\n#endif\n#ifdef SPOT_LIGHT_COUNT\n@import qtek.header.spot_light\n#endif\n@import qtek.util.calculate_attenuation\n@import qtek.util.edge_factor\n@import qtek.util.rgbm\n@import qtek.plugin.compute_shadow_map\nvoid main()\n{\n#ifdef RENDER_NORMAL\n gl_FragColor = vec4(v_Normal * 0.5 + 0.5, 1.0);\n return;\n#endif\n#ifdef RENDER_TEXCOORD\n gl_FragColor = vec4(v_Texcoord, 1.0, 1.0);\n return;\n#endif\n gl_FragColor = vec4(color, alpha);\n#ifdef DIFFUSEMAP_ENABLED\n vec4 tex = texture2D( diffuseMap, v_Texcoord );\n#ifdef SRGB_DECODE\n tex.rgb = pow(tex.rgb, vec3(2.2));\n#endif\n gl_FragColor.rgb *= tex.rgb;\n#ifdef DIFFUSEMAP_ALPHA_ALPHA\n gl_FragColor.a *= tex.a;\n#endif\n#endif\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {\n diffuseColor += ambientLightColor[_idx_];\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_, v_Normal) * ambientSHLightColor[_idx_];\n }}\n#endif\n#ifdef POINT_LIGHT_COUNT\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsPoint[POINT_LIGHT_COUNT];\n if( shadowEnabled )\n {\n computeShadowOfPointLights(v_WorldPosition, shadowContribsPoint);\n }\n#endif\n for(int i = 0; i < POINT_LIGHT_COUNT; i++)\n {\n vec3 lightPosition = pointLightPosition[i];\n vec3 lightColor = pointLightColor[i];\n float range = pointLightRange[i];\n vec3 lightDirection = lightPosition - v_WorldPosition;\n float dist = length(lightDirection);\n float attenuation = lightAttenuation(dist, range);\n lightDirection /= dist;\n float ndl = dot( v_Normal, lightDirection );\n float shadowContrib = 1.0;\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\n if( shadowEnabled )\n {\n shadowContrib = shadowContribsPoint[i];\n }\n#endif\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0) * attenuation * shadowContrib;\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 float ndl = dot(v_Normal, normalize(lightDirection));\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if( shadowEnabled )\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0) * shadowContrib;\n }\n#endif\n#ifdef SPOT_LIGHT_COUNT\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsSpot[SPOT_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfSpotLights(v_WorldPosition, shadowContribsSpot);\n }\n#endif\n for(int i = 0; i < SPOT_LIGHT_COUNT; i++)\n {\n vec3 lightPosition = -spotLightPosition[i];\n vec3 spotLightDirection = -normalize( spotLightDirection[i] );\n vec3 lightColor = spotLightColor[i];\n float range = spotLightRange[i];\n float a = spotLightUmbraAngleCosine[i];\n float b = spotLightPenumbraAngleCosine[i];\n float falloffFactor = spotLightFalloffFactor[i];\n vec3 lightDirection = lightPosition - v_WorldPosition;\n float dist = length(lightDirection);\n float attenuation = lightAttenuation(dist, range);\n lightDirection /= dist;\n float c = dot(spotLightDirection, lightDirection);\n float falloff;\n falloff = clamp((c - a) /( b - a), 0.0, 1.0);\n falloff = pow(falloff, falloffFactor);\n float ndl = dot(v_Normal, lightDirection);\n ndl = clamp(ndl, 0.0, 1.0);\n float shadowContrib = 1.0;\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\n if( shadowEnabled )\n {\n shadowContrib = shadowContribsSpot[i];\n }\n#endif\n diffuseColor += lightColor * ndl * attenuation * (1.0-falloff) * shadowContrib;\n }\n#endif\n gl_FragColor.rgb *= diffuseColor;\n gl_FragColor.rgb += emission;\n if(lineWidth > 0.)\n {\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor(lineWidth)) * lineColor.a);\n }\n#ifdef ALPHA_TEST\n if (gl_FragColor.a < alphaCutoff) {\n discard;\n }\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n}\n@end"),Ut.import(pr),Ut.import("@export qtek.wireframe.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\nattribute vec3 barycentric;\n@import qtek.chunk.skinning_header\nvarying vec3 v_Barycentric;\nvoid main()\n{\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import qtek.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0 );\n v_Barycentric = barycentric;\n}\n@end\n@export qtek.wireframe.fragment\nuniform vec3 color : [0.0, 0.0, 0.0];\nuniform float alpha : 1.0;\nuniform float lineWidth : 1.0;\nvarying vec3 v_Barycentric;\n@import qtek.util.edge_factor\nvoid main()\n{\n gl_FragColor.rgb = color;\n gl_FragColor.a = (1.0-edgeFactor(lineWidth)) * alpha;\n}\n@end"),Ut.import(An),Ut.import(Jt),Wt.template("qtek.basic",Ut.source("qtek.basic.vertex"),Ut.source("qtek.basic.fragment")),Wt.template("qtek.lambert",Ut.source("qtek.lambert.vertex"),Ut.source("qtek.lambert.fragment")),Wt.template("qtek.wireframe",Ut.source("qtek.wireframe.vertex"),Ut.source("qtek.wireframe.fragment")),Wt.template("qtek.skybox",Ut.source("qtek.skybox.vertex"),Ut.source("qtek.skybox.fragment")),Wt.template("qtek.prez",Ut.source("qtek.prez.vertex"),Ut.source("qtek.prez.fragment")),Wt.template("qtek.standard",Ut.source("qtek.standard.vertex"),Ut.source("qtek.standard.fragment")),Ut.import("@export qtek.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 qtek.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 qtek.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 qtek.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 qtek.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 qtek.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"),Ut.import(Nn), -Ut.import("@export qtek.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import qtek.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 qtek.compositor.hdr.lum_adaption\nvarying vec2 v_Texcoord;\nuniform sampler2D adaptedLum;\nuniform sampler2D currentLum;\nuniform float frameTime : 0.02;\n@import qtek.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 qtek.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"),Ut.import("\n@export qtek.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"),Ut.import("@export qtek.compositor.vignette\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float darkness: 1;\nuniform float offset: 1;\n@import qtek.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"),Ut.import(wn),Ut.import(Mn),Ut.import(Rn),Ut.import(Cn),Ut.import(Ln),Ut.import("@export qtek.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 qtek.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 qtek.compositor.dof.premultiply\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\n@import qtek.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 qtek.compositor.dof.min_coc\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform vec2 textureSize : [512.0, 512.0];\n@import qtek.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 qtek.compositor.dof.max_coc\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform vec2 textureSize : [512.0, 512.0];\n@import qtek.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 qtek.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 qtek.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 qtek.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 qtek.util.rgbm\n@import qtek.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 qtek.compositor.dof.downsample\nuniform sampler2D texture;\nuniform sampler2D coc;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\n@import qtek.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 qtek.compositor.dof.hexagonal_blur_frag\n@import qtek.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 qtek.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 qtek.util.rgbm\n@import qtek.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 qtek.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 qtek.util.rgbm\n@import qtek.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 qtek.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 qtek.util.rgbm\n@import qtek.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 qtek.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 qtek.util.rgbm\n@import qtek.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"),Ut.import("@export qtek.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 qtek.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"),Ut.import(Dn),Ut.import(Pn),Ut.import("@export qtek.compositor.fxaa3\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nuniform float subpixel: 0.75;\nuniform float edgeThreshold: 0.125;\nuniform float edgeThresholdMin: 0.0625;\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\nfloat FxaaLuma(vec4 rgba) { return rgba.y; }\nvec4 FxaaPixelShader(\n vec2 pos\n ,sampler2D tex\n ,vec2 fxaaQualityRcpFrame\n ,float fxaaQualitySubpix\n ,float fxaaQualityEdgeThreshold\n ,float fxaaQualityEdgeThresholdMin\n) {\n vec2 posM;\n posM.x = pos.x;\n posM.y = pos.y;\n vec4 rgbyM = decodeHDR(texture2D(texture, posM, 0.0));\n float lumaS = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2( 0.0, 1.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaE = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2( 1.0, 0.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaN = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2( 0.0,-1.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaW = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2(-1.0, 0.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float maxSM = max(lumaS, rgbyM.y);\n float minSM = min(lumaS, rgbyM.y);\n float maxESM = max(lumaE, maxSM);\n float minESM = min(lumaE, minSM);\n float maxWN = max(lumaN, lumaW);\n float minWN = min(lumaN, lumaW);\n float rangeMax = max(maxWN, maxESM);\n float rangeMin = min(minWN, minESM);\n float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\n float range = rangeMax - rangeMin;\n float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\n bool earlyExit = range < rangeMaxClamped;\n if(earlyExit) return rgbyM;\n float lumaNW = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2(-1.0,-1.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaSE = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2( 1.0, 1.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaNE = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2( 1.0,-1.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaSW = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2(-1.0, 1.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaNS = lumaN + lumaS;\n float lumaWE = lumaW + lumaE;\n float subpixRcpRange = 1.0/range;\n float subpixNSWE = lumaNS + lumaWE;\n float edgeHorz1 = (-2.0 * rgbyM.y) + lumaNS;\n float edgeVert1 = (-2.0 * rgbyM.y) + lumaWE;\n float lumaNESE = lumaNE + lumaSE;\n float lumaNWNE = lumaNW + lumaNE;\n float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\n float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\n float lumaNWSW = lumaNW + lumaSW;\n float lumaSWSE = lumaSW + lumaSE;\n float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\n float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\n float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\n float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\n float edgeHorz = abs(edgeHorz3) + edgeHorz4;\n float edgeVert = abs(edgeVert3) + edgeVert4;\n float subpixNWSWNESE = lumaNWSW + lumaNESE;\n float lengthSign = fxaaQualityRcpFrame.x;\n bool horzSpan = edgeHorz >= edgeVert;\n float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\n if(!horzSpan) lumaN = lumaW;\n if(!horzSpan) lumaS = lumaE;\n if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\n float subpixB = (subpixA * (1.0/12.0)) - rgbyM.y;\n float gradientN = lumaN - rgbyM.y;\n float gradientS = lumaS - rgbyM.y;\n float lumaNN = lumaN + rgbyM.y;\n float lumaSS = lumaS + rgbyM.y;\n bool pairN = abs(gradientN) >= abs(gradientS);\n float gradient = max(abs(gradientN), abs(gradientS));\n if(pairN) lengthSign = -lengthSign;\n float subpixC = clamp(abs(subpixB) * subpixRcpRange, 0.0, 1.0);\n vec2 posB;\n posB.x = posM.x;\n posB.y = posM.y;\n vec2 offNP;\n offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n if(!horzSpan) posB.x += lengthSign * 0.5;\n if( horzSpan) posB.y += lengthSign * 0.5;\n vec2 posN;\n posN.x = posB.x - offNP.x * 1.0;\n posN.y = posB.y - offNP.y * 1.0;\n vec2 posP;\n posP.x = posB.x + offNP.x * 1.0;\n posP.y = posB.y + offNP.y * 1.0;\n float subpixD = ((-2.0)*subpixC) + 3.0;\n float lumaEndN = FxaaLuma(decodeHDR(texture2D(texture, posN, 0.0)));\n float subpixE = subpixC * subpixC;\n float lumaEndP = FxaaLuma(decodeHDR(texture2D(texture, posP, 0.0)));\n if(!pairN) lumaNN = lumaSS;\n float gradientScaled = gradient * 1.0/4.0;\n float lumaMM = rgbyM.y - lumaNN * 0.5;\n float subpixF = subpixD * subpixE;\n bool lumaMLTZero = lumaMM < 0.0;\n lumaEndN -= lumaNN * 0.5;\n lumaEndP -= lumaNN * 0.5;\n bool doneN = abs(lumaEndN) >= gradientScaled;\n bool doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * 1.5;\n if(!doneN) posN.y -= offNP.y * 1.5;\n bool doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * 1.5;\n if(!doneP) posP.y += offNP.y * 1.5;\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(decodeHDR(texture2D(texture, posN.xy, 0.0)));\n if(!doneP) lumaEndP = FxaaLuma(decodeHDR(texture2D(texture, posP.xy, 0.0)));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * 2.0;\n if(!doneN) posN.y -= offNP.y * 2.0;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * 2.0;\n if(!doneP) posP.y += offNP.y * 2.0;\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(decodeHDR(texture2D(texture, posN.xy, 0.0)));\n if(!doneP) lumaEndP = FxaaLuma(decodeHDR(texture2D(texture, posP.xy, 0.0)));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * 4.0;\n if(!doneN) posN.y -= offNP.y * 4.0;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * 4.0;\n if(!doneP) posP.y += offNP.y * 4.0;\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(decodeHDR(texture2D(texture, posN.xy, 0.0)));\n if(!doneP) lumaEndP = FxaaLuma(decodeHDR(texture2D(texture, posP.xy, 0.0)));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * 12.0;\n if(!doneN) posN.y -= offNP.y * 12.0;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * 12.0;\n if(!doneP) posP.y += offNP.y * 12.0;\n }\n }\n }\n float dstN = posM.x - posN.x;\n float dstP = posP.x - posM.x;\n if(!horzSpan) dstN = posM.y - posN.y;\n if(!horzSpan) dstP = posP.y - posM.y;\n bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\n float spanLength = (dstP + dstN);\n bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\n float spanLengthRcp = 1.0/spanLength;\n bool directionN = dstN < dstP;\n float dst = min(dstN, dstP);\n bool goodSpan = directionN ? goodSpanN : goodSpanP;\n float subpixG = subpixF * subpixF;\n float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\n float subpixH = subpixG * fxaaQualitySubpix;\n float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\n float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n return vec4(decodeHDR(texture2D(texture, posM, 0.0)).xyz, rgbyM.y);\n}\nvoid main()\n{\n vec4 color = FxaaPixelShader(\n v_Texcoord,\n texture,\n vec2(1.0) / viewport.zw,\n subpixel,\n edgeThreshold,\n edgeThresholdMin\n );\n gl_FragColor = vec4(color.rgb, 1.0);\n}\n@end");var In={NORMAL:"normal",POSITION:"position",TEXCOORD_0:"texcoord0",TEXCOORD_1:"texcoord1",WEIGHTS_0:"weight",JOINTS_0:"joint",COLOR:"color"},On={5120:at.Int8Array,5121:at.Uint8Array,5122:at.Int16Array,5123:at.Uint16Array,5125:at.Uint32Array,5126:at.Float32Array},Fn={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},kn=$e.extend({rootNode:null,rootPath:null,textureRootPath:null,bufferRootPath:null,shaderName:"qtek.standard",useStandardMaterial:!1,includeCamera:!0,includeAnimation:!0,includeMesh:!0,includeTexture:!0,crossOrigin:"",textureFlipY:!1,shaderLibrary:null},function(){this.shaderLibrary||(this.shaderLibrary=Wt.createLibrary())},{load:function(e){var t=this,r=e.endsWith(".glb");null==this.rootPath&&(this.rootPath=e.slice(0,e.lastIndexOf("/"))),ar.get({url:e,onprogress:function(e,r,n){t.trigger("progress",e,r,n)},onerror:function(e){t.trigger("error",e)},responseType:r?"arraybuffer":"text",onload:function(e){r?t.parseBinary(e):t.parse(JSON.parse(e))}})},parseBinary:function(e){var t=new Uint32Array(e,0,4);if(1179937895!==t[0])return void this.trigger("error","Invalid glTF binary format: Invalid header");if(t[0]<2)return void this.trigger("error","Only glTF2.0 is supported.");for(var r,n=new DataView(e,12),i=[],a=0;a=0&&this._clips.splice(t,1)},removeAnimator:function(e){for(var t=e.getClips(),r=0;r=65535?new Uint32Array(3*f):new Uint16Array(3*f);for(var m=0,v=0,g=n.isUseIndices(),y=0;y0;){for(var x=[],T=[],E=[],b=0,m=0;m=0&&-1===T[R]&&(b65535?new Uint32Array(3*I.triangles.length):new Uint16Array(3*I.triangles.length);var K=0;G=0;for(var m=0;m=0?O[R]:-1}G++}H.indices[K++]=D[w]}H.updateBoundingBox(),C.add(z)}for(var $=e.children(),m=0;m<$.length;m++)C.add($[m]);if(C.position.copy(e.position),C.rotation.copy(e.rotation),C.scale.copy(e.scale),r&&e.getParent()){var ee=e.getParent();ee.remove(e),ee.add(C)}return C}}},Wn=function(){this._fullfilled=!1,this._rejected=!1};Wn.prototype.resolve=function(e){this._fullfilled=!0,this._rejected=!1,this.trigger("success",e)},Wn.prototype.reject=function(e){this._rejected=!0,this._fullfilled=!1,this.trigger("error",e)},Wn.prototype.isFullfilled=function(){return this._fullfilled},Wn.prototype.isRejected=function(){return this._rejected},Wn.prototype.isSettled=function(){return this._fullfilled||this._rejected},Je.extend(Wn.prototype,Ke),Wn.makeRequestTask=function(e,t){if("string"==typeof e)return G(e,t);if(e.url){var r=e;return G(r.url,r.responseType)}if(Array.isArray(e)){var n=e,i=[];return n.forEach(function(e){var t,r;"string"==typeof e?t=e:Object(e)===e&&(t=e.url,r=e.responseType),i.push(G(t,r))}),i}},Wn.makeTask=function(){return new Wn},Je.extend(Wn.prototype,Ke);var Vn=function(){Wn.apply(this,arguments),this._tasks=[],this._fulfilledNumber=0,this._rejectedNumber=0},jn=function(){};jn.prototype=Wn.prototype,Vn.prototype=new jn,Vn.prototype.constructor=Vn,Vn.prototype.all=function(e){var t=0,r=this,n=[];return this._tasks=e,this._fulfilledNumber=0,this._rejectedNumber=0,Je.each(e,function(e,i){e&&e.once&&(t++,e.once("success",function(a){t--,r._fulfilledNumber++,e._fulfilled=!0,e._rejected=!1,n[i]=a,0===t&&r.resolve(n)}),e.once("error",function(){r._rejectedNumber++,e._fulfilled=!1,e._rejected=!0,r.reject(e)}))}),0===t?(setTimeout(function(){r.resolve(n)}),this):this},Vn.prototype.allSettled=function(e){var t=0,r=this,n=[];return 0===e.length?(setTimeout(function(){r.trigger("success",n)}),this):(this._tasks=e,Je.each(e,function(e,i){e&&e.once&&(t++,e.once("success",function(a){t--,r._fulfilledNumber++,e._fulfilled=!0,e._rejected=!1,n[i]=a,0===t&&r.resolve(n)}),e.once("error",function(a){t--,r._rejectedNumber++,e._fulfilled=!1,e._rejected=!0,n[i]=null,0===t&&r.resolve(n)}))}),this)},Vn.prototype.getFulfilledNumber=function(e){if(e){for(var t=0,r=0;r=0&&x[g]>1e-4&&(Kn.transformMat4(b,y,m[T[g]]),Kn.scaleAndAdd(E,E,b,x[g]));S.set(v,E)}}for(var v=0;v1&&t.texParameterf(t.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===n){e.getGLExtension("OES_texture_half_float")||(n=rt.FLOAT)}if(this.mipmaps.length)for(var a=this.width,o=this.height,s=0;s65535?Uint32Array:Uint16Array,_=this.indices=new d(t*e*6),p=this.radius,m=this.phiStart,v=this.phiLength,g=this.thetaStart,y=this.thetaLength,p=this.radius,x=[],T=[],E=0,b=1/p;for(f=0;f<=e;f++)for(h=0;h<=t;h++)l=h/t,c=f/e,o=-p*Math.cos(m+l*v)*Math.sin(g+c*y),s=p*Math.cos(g+c*y),u=p*Math.sin(m+l*v)*Math.sin(g+c*y),x[0]=o,x[1]=s,x[2]=u,T[0]=l,T[1]=c,r.set(E,x),n.set(E,T),x[0]*=b,x[1]*=b,x[2]*=b,i.set(E,x),E++;var S,A,N,w,M=t+1,R=0;for(f=0;f=i)){a+=2;for(var o="";a20)return console.warn("Given image is not a height map"),e}var f,d,_,p;u%(4*n)==0?(f=o.data[u],_=o.data[u+4]):u%(4*n)==4*(n-1)?(f=o.data[u-4],_=o.data[u]):(f=o.data[u-4],_=o.data[u+4]),u<4*n?(d=o.data[u],p=o.data[u+4*n]):u>n*(i-1)*4?(d=o.data[u-4*n],p=o.data[u]):(d=o.data[u-4*n],p=o.data[u+4*n]),s.data[u]=f-_+127,s.data[u+1]=d-p+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){ar.get({url:e,responseType:"arraybuffer",onload:t,onerror:r})},createChessboard:function(e,t,r,n){e=e||512,t=t||64,r=r||"black",n=n||"white";var i=Math.ceil(e/t),a=document.createElement("canvas");a.width=e,a.height=e;var o=a.getContext("2d");o.fillStyle=n,o.fillRect(0,0,e,e),o.fillStyle=r;for(var s=0;s=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){Ti.material=this.material,e.renderQueue([Ti],Ei)},dispose:function(e){this.material.dispose(e)}}),Si=function(){this._pool={},this._allocatedTextures=[]};Si.prototype={constructor:Si,get:function(e){var t=Z(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]);var r=this._pool[t];if(!r.length){var n=new Pr(e);return this._allocatedTextures.push(n),n}return r.pop()},put:function(e){var t=Z(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]),this._pool[t].push(e)},clear:function(e){for(var t=0;t= 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");var Ri=$e.extend(function(){return{softShadow:Ri.PCF,shadowBlur:1,lightFrustumBias:"auto",kernelPCF:new Float32Array([1,0,1,1,-1,1,0,1,-1,0,-1,-1,1,-1,0,-1]),precision:"mediump",_lastRenderNotCastShadow:!1,_frameBuffer:new ni,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_meshMaterials:{},_depthMaterials:{},_depthShaders:{},_distanceMaterials:{},_opaqueCasters:[],_receivers:[],_lightsCastShadow:[],_lightCameras:{},_texturePool:new Si}},function(){this._gaussianPassH=new bi({fragment:Ut.source("qtek.compositor.gaussian_blur")}),this._gaussianPassV=new bi({fragment:Ut.source("qtek.compositor.gaussian_blur")}),this._gaussianPassH.setUniform("blurSize",this.shadowBlur),this._gaussianPassH.setUniform("blurDir",0),this._gaussianPassV.setUniform("blurSize",this.shadowBlur),this._gaussianPassV.setUniform("blurDir",1),this._outputDepthPass=new bi({fragment:Ut.source("qtek.sm.debug_depth")})},{render:function(e,t,r,n){this.trigger("beforerender",this,e,t,r),this._renderShadowPass(e,t,r,n),this.trigger("afterrender",this,e,t,r)},renderDebug:function(e,t){e.saveClear();var r=e.viewport,n=0,i=t||r.width/4,a=i;this.softShadow===Ri.VSM?this._outputDepthPass.material.shader.define("fragment","USE_VSM"):this._outputDepthPass.material.shader.undefine("fragment","USE_VSM");for(var o in this._textures){var s=this._textures[o];e.setViewport(n,0,i*s.width/s.height,a),this._outputDepthPass.setUniform("depthMap",s),this._outputDepthPass.render(e),n+=i*s.width/s.height}e.setViewport(r),e.restoreClear()},_bindDepthMaterial:function(e,t,r){for(var n=0;n0&&(h.define("vertex","SKINNING"),h.define("vertex","JOINT_COUNT",l)),s&&h.define("both","SHADOW_TRANSPARENT"),o.useSkinMatricesTexture&&h.define("vertex","USE_SKIN_MATRICES_TEXTURE"),this._depthShaders[a]=h),c||(c=new jt({shader:h}),this._depthMaterials[i]=c),o.material=c,this.softShadow===Ri.VSM?h.define("fragment","USE_VSM"):h.undefine("fragment","USE_VSM"),c.setUniform("bias",t),c.setUniform("slopeScale",r),s&&c.set("shadowTransparentMap",u))}},_bindDistanceMaterial:function(e,t){for(var r=t.getWorldPosition()._array,n=0;n0&&(o.shader.define("vertex","SKINNING"),o.shader.define("vertex","JOINT_COUNT",a)),this._distanceMaterials[a]=o),i.material=o,this.softShadow===Ri.VSM?o.shader.define("fragment","USE_VSM"):o.shader.undefine("fragment","USE_VSM")),o.set("lightPosition",r),o.set("range",t.range)}},saveMaterial:function(e){for(var t=0;t1&&(d=p,p.shadowCascade>4)){console.warn("Support at most 4 cascade");continue}this.renderDirectionalLightShadow(e,t,r,p,this._opaqueCasters,h,c,l)}else p instanceof vi?this.renderSpotLightShadow(e,p,this._opaqueCasters,u,s):p instanceof yi&&this.renderPointLightShadow(e,p,this._opaqueCasters,f);this._shadowMapNumber[p.type]++}this.restoreMaterial(this._opaqueCasters);var m=h.slice(),v=h.slice();m.pop(),v.shift(),m.reverse(),v.reverse(),c.reverse();for(var g=s.map(i),y=l.map(i),x={},_=0;_0?(b.fragmentDefines[w]=N,S=!0):b.isDefined("fragment",w)&&(b.undefine("fragment",w),S=!0))}S&&b.dirty(),d?b.define("fragment","SHADOW_CASCADE",d.shadowCascade):b.undefine("fragment","SHADOW_CASCADE"),x[b.__GUID__]=!0}s.length>0&&(E.setUniform("spotLightShadowMaps",s),E.setUniform("spotLightMatrices",u),E.setUniform("spotLightShadowMapSizes",g)),l.length>0&&(E.setUniform("directionalLightShadowMaps",l),d&&(E.setUniform("shadowCascadeClipsNear",m),E.setUniform("shadowCascadeClipsFar",v)),E.setUniform("directionalLightMatrices",c),E.setUniform("directionalLightShadowMapSizes",y)),f.length>0&&E.setUniform("pointLightShadowMaps",f)}}},renderDirectionalLightShadow:function(){var e=new Zr,t=new Et,r=new vt,n=new Et,i=new Et,a=new Et,o=new Et;return function(s,u,l,c,h,f,d,_){var p=c.shadowBias;if(this._bindDepthMaterial(h,p,c.shadowSlopeScale),h.sort(nr.opaqueSortFunc),!u.viewBoundingBoxLastFrame.isFinite()){var m=u.getBoundingBox();u.viewBoundingBoxLastFrame.copy(m).applyTransform(l.viewMatrix)}var v=Math.min(-u.viewBoundingBoxLastFrame.min.z,l.far),g=Math.max(-u.viewBoundingBoxLastFrame.max.z,l.near),y=this._getDirectionalLightCamera(c,u,l),x=a._array;o.copy(y.projectionMatrix),wi.invert(i._array,y.worldTransform._array),wi.multiply(i._array,i._array,l.worldTransform._array),wi.multiply(x,o._array,i._array);for(var T=[],E=l instanceof rn,b=(l.near+l.far)/(l.near-l.far),S=2*l.near*l.far/(l.near-l.far),A=0;A<=c.shadowCascade;A++){var N=g*Math.pow(v/g,A/c.shadowCascade),w=g+(v-g)*A/c.shadowCascade,M=N*c.cascadeSplitLogFactor+w*(1-c.cascadeSplitLogFactor);T.push(M),f.push(-(-M*b+S)/-M)}var R=this._getTexture(c,c.shadowCascade);_.push(R);var C=s.viewport,L=s.gl;this._frameBuffer.attach(R),this._frameBuffer.bind(s),L.clear(L.COLOR_BUFFER_BIT|L.DEPTH_BUFFER_BIT);for(var A=0;A0){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])}}}),Li=$e.extend(function(){return{nodes:[]}},{dirty:function(){this._dirty=!0},addNode:function(e){this.nodes.indexOf(e)>=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&&u<=t.COLOR_ATTACHMENT0+8&&c.push(u);l.drawBuffersEXT(c)}e.saveClear(),e.clearBit=rt.DEPTH_BUFFER_BIT|rt.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}}),Ii=Ci.extend(function(){return{texture:null,outputs:{color:{}}}},function(){},{getOutput:function(e,t){return this.texture},beforeFrame:function(){},afterFrame:function(){}}),Oi=Ci.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 bi({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])},setShader:function(e){var t=this.pass.material;t.shader.setFragment(e),t.attachShader(t.shader,!0)},shaderDefine:function(e,t){this.pass.material.shader.define("fragment",e,t)},shaderUndefine:function(e){this.pass.material.shader.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])}},link:function(e,t,r){this.inputLinks[e]={node:t,pin:r},t.outputLinks[r]||(t.outputLinks[r]=[]),t.outputLinks[r].push({node:this,pin:e}),this.pass.material.shader.enableTexture(e)},clear:function(){Ci.prototype.clear.call(this),this.pass.material.shader.disableTexturesAll()},updateReference:function(e){if(!this._rendering){this._rendering=!0;for(var t in this.inputLinks){var r=this.inputLinks[t];r.node.updateReference(r.pin)}this._rendering=!1}e&&this._outputReferences[e]++},beforeFrame:function(){this._rendered=!1;for(var e in this.outputLinks)this._outputReferences[e]=0},afterFrame:function(){for(var e in this.outputLinks)if(this._outputReferences[e]>0){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])}}}),Fi=/#source\((.*?)\)/,ki=/#url\((.*?)\)/,Bi=$e.extend({rootPath:"",textureRootPath:"",shaderRootPath:"",scene:null,camera:null},{load:function(e){var t=this;this.rootPath||(this.rootPath=e.slice(0,e.lastIndexOf("/"))),ar.get({url:e,onprogress:function(e,r,n){t.trigger("progress",e,r,n)},onerror:function(e){t.trigger("error",e)},responseType:"text",onload:function(e){t.parse(JSON.parse(e))}})},parse:function(e){var t=this,r=new Di,n={textures:{},shaders:{},parameters:{}},i=function(i,a){for(var o=0;o 0.99999) {\n gl_FragColor = vec4(1.0);\n return;\n }\n mat3 kernelBasis;\n#endif\n\n float z = depthTexel.r * 2.0 - 1.0;\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * projectedPos;\n\n vec3 position = p4.xyz / p4.w;\n\n float ao = ssaoEstimator(position, N, kernelBasis);\n ao = clamp(1.0 - (1.0 - ao) * intensity, 0.0, 1.0);\n gl_FragColor = vec4(vec3(ao), 1.0);\n}\n\n@end\n\n\n@export ecgl.ssao.blur\n#define SHADER_NAME SSAO_BLUR\n\nuniform sampler2D ssaoTexture;\n\n#ifdef NORMALTEX_ENABLED\nuniform sampler2D normalTex;\n#endif\n\n#ifdef DEPTHTEX_ENABLED\nuniform sampler2D depthTex;\nuniform mat4 projection;\nuniform float depthRange : 0.05;\n#endif\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\nuniform int direction: 0.0;\n\n#ifdef DEPTHTEX_ENABLED\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(depthTex, v_Texcoord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n#endif\n\nvoid main()\n{\n @import qtek.compositor.kernel.gaussian_9\n\n vec2 off = vec2(0.0);\n if (direction == 0) {\n off[0] = blurSize / textureSize.x;\n }\n else {\n off[1] = blurSize / textureSize.y;\n }\n\n vec2 coord = v_Texcoord;\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\n#ifdef NORMALTEX_ENABLED\n vec3 centerNormal = texture2D(normalTex, v_Texcoord).rgb * 2.0 - 1.0;\n#elif defined(DEPTHTEX_ENABLED)\n float centerDepth = getLinearDepth(v_Texcoord);\n#endif\n\n for (int i = 0; i < 9; i++) {\n vec2 coord = clamp(v_Texcoord + vec2(float(i) - 4.0) * off, vec2(0.0), vec2(1.0));\n\n#ifdef NORMALTEX_ENABLED\n vec3 normal = texture2D(normalTex, coord).rgb * 2.0 - 1.0;\n float w = gaussianKernel[i] * clamp(dot(normal, centerNormal), 0.0, 1.0);\n#elif defined(DEPTHTEX_ENABLED)\n float d = getLinearDepth(coord);\n float w = gaussianKernel[i] * (1.0 - clamp(abs(centerDepth - d) / depthRange, 0.0, 1.0));\n#else\n float w = gaussianKernel[i];\n#endif\n\n weightAll += w;\n sum += texture2D(ssaoTexture, coord) * w;\n }\n\n gl_FragColor = vec4(vec3(sum / weightAll), 1.0);\n}\n\n@end\n"),oe.prototype.setDepthTexture=function(e){this._depthTex=e},oe.prototype.setNormalTexture=function(e){this._normalTex=e,this._ssaoPass.material.shader[e?"enableTexture":"disableTexture"]("normalTex"),this.setKernelSize(this._kernelSize)},oe.prototype.update=function(e,t,r){var n=e.getWidth(),i=e.getHeight(),a=this._ssaoPass,o=this._blurPass;a.setUniform("kernel",this._kernels[r%this._kernels.length]),a.setUniform("depthTex",this._depthTex),null!=this._normalTex&&a.setUniform("normalTex",this._normalTex),a.setUniform("depthTexSize",[this._depthTex.width,this._depthTex.height]);var s=new Et;Et.transpose(s,t.worldTransform),a.setUniform("projection",t.projectionMatrix._array),a.setUniform("projectionInv",t.invProjectionMatrix._array),a.setUniform("viewInverseTranspose",s._array);var u=this._ssaoTexture,l=this._blurTexture;u.width=n,u.height=i,l.width=n,l.height=i,this._framebuffer.attach(u),this._framebuffer.bind(e),e.gl.clearColor(1,1,1,1),e.gl.clear(e.gl.COLOR_BUFFER_BIT),a.render(e),o.setUniform("textureSize",[n,i]),this._framebuffer.attach(l),o.setUniform("direction",0),o.setUniform("ssaoTexture",u),o.render(e),this._framebuffer.attach(u),o.setUniform("direction",1),o.setUniform("ssaoTexture",l),o.render(e),this._framebuffer.unbind(e);var c=e.clearColor;e.gl.clearColor(c[0],c[1],c[2],c[3])},oe.prototype.getTargetTexture=function(){return this._ssaoTexture},oe.prototype.setParameter=function(e,t){"noiseTexSize"===e?this.setNoiseSize(t):"kernelSize"===e?this.setKernelSize(t):"intensity"===e?this._ssaoPass.material.set("intensity",t):this._ssaoPass.setUniform(e,t)},oe.prototype.setKernelSize=function(e){this._kernelSize=e,this._ssaoPass.material.shader.define("fragment","KERNEL_SIZE",e),this._kernels=this._kernels||[];for(var t=0;t<30;t++)this._kernels[t]=ae(e,t*e,!!this._normalTex)},oe.prototype.setNoiseSize=function(e){var t=this._ssaoPass.getUniform("noiseTex");t?(t.data=ne(e),t.width=t.height=e,t.dirty()):(t=ie(e),this._ssaoPass.setUniform("noiseTex",ie(e))),this._ssaoPass.setUniform("noiseTexSize",[e,e])},oe.prototype.dispose=function(e){this._blurTexture.dispose(e),this._ssaoTexture.dispose(e)};Ut.import("@export ecgl.ssr.main\n\n#define MAX_ITERATION 20;\n\nuniform sampler2D sourceTexture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\n\nuniform mat4 projection;\nuniform mat4 projectionInv;\nuniform mat4 viewInverseTranspose;\n\nuniform float maxRayDistance: 50;\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: 10;\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 qtek.util.decode_float\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 if (intersect) {\n break;\n }\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 qtek.util.rand\n\n@import qtek.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 (g <= minGlossiness) {\n discard;\n }\n\n float reflectivity = (g - minGlossiness) / (1.0 - minGlossiness);\n\n vec3 N = normalAndGloss.rgb * 2.0 - 1.0;\n N = normalize((viewInverseTranspose * 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\n vec3 rayDir = normalize(reflect(normalize(rayOrigin), N));\n vec2 hitPixel;\n vec3 hitPoint;\n float iterationCount;\n\n vec2 uv2 = v_Texcoord * viewportSize;\n float jitter = rand(fract(v_Texcoord + jitterOffset));\n\n bool intersect = traceScreenSpaceRay(rayOrigin, rayDir, jitter, hitPixel, hitPoint, iterationCount);\n\n float dist = distance(rayOrigin, hitPoint);\n\n float alpha = calculateAlpha(iterationCount, reflectivity, hitPixel, hitPoint, dist, rayDir) * float(intersect);\n\n vec3 hitNormal = texture2D(gBufferTexture1, hitPixel).rgb * 2.0 - 1.0;\n hitNormal = normalize((viewInverseTranspose * vec4(hitNormal, 0.0)).xyz);\n\n if (dot(hitNormal, rayDir) >= 0.0) {\n discard;\n }\n\n \n if (!intersect) {\n discard;\n }\n vec4 color = decodeHDR(texture2D(sourceTexture, hitPixel));\n gl_FragColor = encodeHDR(vec4(color.rgb * alpha, color.a));\n}\n@end\n\n@export ecgl.ssr.blur\n\nuniform sampler2D texture;\nuniform sampler2D gBufferTexture1;\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 4.0;\n\n#ifdef BLEND\nuniform sampler2D sourceTexture;\n#endif\n\n@import qtek.util.rgbm\n\n\nvoid main()\n{\n @import qtek.compositor.kernel.gaussian_13\n\n vec4 centerNTexel = texture2D(gBufferTexture1, v_Texcoord);\n float g = centerNTexel.a;\n float maxBlurSize = clamp(1.0 - g + 0.1, 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 for (int i = 0; i < 13; i++) {\n vec2 coord = clamp((float(i) - 6.0) * off + v_Texcoord, vec2(0.0), vec2(1.0));\n float w = gaussianKernel[i] * clamp(dot(cN, texture2D(gBufferTexture1, coord).rgb * 2.0 - 1.0), 0.0, 1.0);\n weightAll += w;\n sum += decodeHDR(texture2D(texture, coord)) * w;\n }\n\n#ifdef BLEND\n gl_FragColor = encodeHDR(\n sum / weightAll + decodeHDR(texture2D(sourceTexture, v_Texcoord))\n );\n#else\n gl_FragColor = encodeHDR(sum / weightAll);\n#endif\n}\n\n@end"),se.prototype.update=function(e,t,r,n){var i=e.getWidth(),a=e.getHeight(),o=this._texture1,s=this._texture2;o.width=s.width=i,o.height=s.height=a;var u=this._frameBuffer,l=this._ssrPass,c=this._blurPass1,h=this._blurPass2,f=new Et;Et.transpose(f,t.worldTransform),l.setUniform("sourceTexture",r),l.setUniform("projection",t.projectionMatrix._array),l.setUniform("projectionInv",t.invProjectionMatrix._array),l.setUniform("viewInverseTranspose",f._array),l.setUniform("nearZ",t.near),l.setUniform("jitterOffset",n/30);var d=[i,a];c.setUniform("textureSize",d),h.setUniform("textureSize",d),h.setUniform("sourceTexture",r),u.attach(s),u.bind(e),l.render(e),u.attach(o),c.setUniform("texture",s),c.render(e),u.attach(s),h.setUniform("texture",o),h.render(e),u.unbind(e)},se.prototype.getTargetTexture=function(){return this._texture2},se.prototype.setParameter=function(e,t){"maxIteration"===e?this._ssrPass.material.shader.define("fragment","MAX_ITERATION",t):this._ssrPass.setUniform(e,t)},se.prototype.dispose=function(e){this._texture1.dispose(e),this._texture2.dispose(e),this._frameBuffer.dispose(e)};var Ui=[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],Hi="@export qtek.deferred.gbuffer.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\nuniform vec2 uvRepeat;\nuniform vec2 uvOffset;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n#ifdef FIRST_PASS\nattribute vec3 normal : NORMAL;\n#endif\n@import qtek.chunk.skinning_header\n#ifdef FIRST_PASS\nvarying vec3 v_Normal;\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\nvarying vec3 v_WorldPosition;\n#endif\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec3 skinnedPosition = position;\n#ifdef FIRST_PASS\n vec3 skinnedNormal = normal;\n vec3 skinnedTangent = tangent.xyz;\n bool hasTangent = dot(tangent, tangent) > 0.0;\n#endif\n#ifdef SKINNING\n @import qtek.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n #ifdef FIRST_PASS\n skinnedNormal = (skinMatrixWS * vec4(normal, 0.0)).xyz;\n if (hasTangent) {\n skinnedTangent = (skinMatrixWS * vec4(tangent.xyz, 0.0)).xyz;\n }\n #endif\n#endif\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n#ifdef FIRST_PASS\n v_Normal = normalize((worldInverseTranspose * vec4(skinnedNormal, 0.0)).xyz);\n if (hasTangent) {\n v_Tangent = normalize((worldInverseTranspose * vec4(skinnedTangent, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n v_WorldPosition = (world * vec4(skinnedPosition, 1.0)).xyz;\n#endif\n}\n@end\n@export qtek.deferred.gbuffer1.fragment\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform float glossiness;\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\nuniform sampler2D roughGlossMap;\nuniform bool useRoughGlossMap;\nuniform bool useRoughness;\nuniform bool doubleSided;\nuniform int roughGlossChannel: 0;\nfloat indexingTexel(in vec4 texel, in int idx) {\n if (idx == 3) return texel.a;\n else if (idx == 1) return texel.g;\n else if (idx == 2) return texel.b;\n else return texel.r;\n}\nvoid main()\n{\n vec3 N = v_Normal;\n if (doubleSided) {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = eyePos - v_WorldPosition;\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n }\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_Texcoord).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 gl_FragColor.rgb = (N + 1.0) * 0.5;\n float g = glossiness;\n if (useRoughGlossMap) {\n float g2 = indexingTexel(texture2D(roughGlossMap, v_Texcoord), roughGlossChannel);\n if (useRoughness) {\n g2 = 1.0 - g2;\n }\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n }\n gl_FragColor.a = g;\n}\n@end\n@export qtek.deferred.gbuffer2.fragment\nuniform sampler2D diffuseMap;\nuniform sampler2D metalnessMap;\nuniform vec3 color;\nuniform float metalness;\nuniform bool useMetalnessMap;\nuniform bool linear;\nvarying vec2 v_Texcoord;\n@import qtek.util.srgb\nvoid main ()\n{\n float m = metalness;\n if (useMetalnessMap) {\n vec4 metalnessTexel = texture2D(metalnessMap, v_Texcoord);\n m = clamp(metalnessTexel.r + (m * 2.0 - 1.0), 0.0, 1.0);\n }\n vec4 texel = texture2D(diffuseMap, v_Texcoord);\n if (linear) {\n texel = sRGBToLinear(texel);\n }\n gl_FragColor.rgb = texel.rgb * color;\n gl_FragColor.a = m;\n}\n@end\n@export qtek.deferred.gbuffer.debug\n@import qtek.deferred.chunk.light_head\nuniform int debug: 0;\nvoid main ()\n{\n @import qtek.deferred.chunk.gbuffer_read\n if (debug == 0) {\n gl_FragColor = vec4(N, 1.0);\n }\n else if (debug == 1) {\n gl_FragColor = vec4(vec3(z), 1.0);\n }\n else if (debug == 2) {\n gl_FragColor = vec4(position, 1.0);\n }\n else if (debug == 3) {\n gl_FragColor = vec4(vec3(glossiness), 1.0);\n }\n else if (debug == 4) {\n gl_FragColor = vec4(vec3(metalness), 1.0);\n }\n else {\n gl_FragColor = vec4(albedo, 1.0);\n }\n}\n@end";Ut.import(Hi),Ut.import("@export qtek.deferred.chunk.light_head\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform sampler2D gBufferTexture3;\nuniform vec2 windowSize: WINDOW_SIZE;\nuniform vec4 viewport: VIEWPORT;\nuniform mat4 viewProjectionInv;\n#ifdef DEPTH_ENCODED\n@import qtek.util.decode_float\n#endif\n@end\n@export qtek.deferred.chunk.gbuffer_read\n vec2 uv = gl_FragCoord.xy / windowSize;\n vec2 uv2 = (gl_FragCoord.xy - viewport.xy) / viewport.zw;\n vec4 texel1 = texture2D(gBufferTexture1, uv);\n vec4 texel3 = texture2D(gBufferTexture3, uv);\n if (dot(texel1.rgb, vec3(1.0)) == 0.0) {\n discard;\n }\n float glossiness = texel1.a;\n float metalness = texel3.a;\n vec3 N = texel1.rgb * 2.0 - 1.0;\n float z = texture2D(gBufferTexture2, uv).r * 2.0 - 1.0;\n vec2 xy = uv2 * 2.0 - 1.0;\n vec4 projectedPos = vec4(xy, z, 1.0);\n vec4 p4 = viewProjectionInv * projectedPos;\n vec3 position = p4.xyz / p4.w;\n vec3 albedo = texel3.rgb;\n vec3 diffuseColor = albedo * (1.0 - metalness);\n vec3 specularColor = mix(vec3(0.04), albedo, metalness);\n@end\n@export qtek.deferred.chunk.light_equation\nfloat D_Phong(in float g, in float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\nfloat D_GGX(in float g, in float ndh) {\n float r = 1.0 - g;\n float a = r * r;\n float tmp = ndh * ndh * (a - 1.0) + 1.0;\n return a / (3.1415926 * tmp * tmp);\n}\nvec3 F_Schlick(in float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\nvec3 lightEquation(\n in vec3 lightColor, in vec3 diffuseColor, in vec3 specularColor,\n in float ndl, in float ndh, in float ndv, in float g\n)\n{\n return ndl * lightColor\n * (diffuseColor + D_Phong(g, ndh) * F_Schlick(ndv, specularColor));\n}\n@end");var zi=$e.extend(function(){return{enableTargetTexture1:!0,enableTargetTexture2:!0,enableTargetTexture3:!0,_renderQueue:[],_gBufferTex1:new Pr({minFilter:Vt.NEAREST,magFilter:Vt.NEAREST,type:Vt.HALF_FLOAT}),_gBufferTex2:new Pr({minFilter:Vt.NEAREST,magFilter:Vt.NEAREST,format:Vt.DEPTH_STENCIL,type:Vt.UNSIGNED_INT_24_8_WEBGL}),_gBufferTex3:new Pr({minFilter:Vt.NEAREST,magFilter:Vt.NEAREST}),_defaultNormalMap:new Pr({image:ue("#000")}),_defaultRoughnessMap:new Pr({image:ue("#fff")}),_defaultMetalnessMap:new Pr({image:ue("#fff")}),_defaultDiffuseMap:new Pr({image:ue("#fff")}),_frameBuffer:new ni,_gBufferMaterials:{},_debugPass:new bi({fragment:Ut.source("qtek.deferred.gbuffer.debug")})}},{resize:function(e,t){this._gBufferTex1.width===e&&this._gBufferTex1.height===t||(this._gBufferTex1.width=e,this._gBufferTex1.height=t,this._gBufferTex2.width=e,this._gBufferTex2.height=t,this._gBufferTex3.width=e,this._gBufferTex3.height=t)},setViewport:function(e,t,r,n,i){var a;a="object"==typeof e?e:{x:e,y:t,width:r,height:n,devicePixelRatio:i||1},this._frameBuffer.viewport=a},getViewport:function(){return this._frameBuffer.viewport?this._frameBuffer.viewport:{x:0,y:0,width:this._gBufferTex1.width,height:this._gBufferTex1.height,devicePixelRatio:1}},update:function(e,t,r){for(var n=e.gl,i=this._frameBuffer,a=i.viewport,o=t.opaqueQueue,s=t.transparentQueue,u=e.beforeRenderObject,l=0;l0&&(n.shader.define("vertex","SKINNING"),n.shader.define("vertex","JOINT_COUNT",e),i.shader.define("vertex","SKINNING"),i.shader.define("vertex","JOINT_COUNT",e)),r={material1:n,material2:i},t[e]=r}return r.used=!0,r},_resetGBufferMaterials:function(){for(var e in this._gBufferMaterials)this._gBufferMaterials[e].used=!1},_cleanGBufferMaterials:function(e){for(var t in this._gBufferMaterials){var r=this._gBufferMaterials[t];r.used||(r.material1.dispose(e),r.material2.dispose(e))}},_replaceGBufferMat:function(e,t){for(var r=0;r=this._maxSize&&a>0){var s=r.head;r.remove(s),delete n[s.key],i=s.value,this._lastRemovedEntry=s}o?o.value=t:o=new Wi(t),o.key=e,r.insertEntry(o),n[e]=o}return i},ji.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},ji.clear=function(){this._list.clear(),this._map={}};var Xi=new Et,Ki=bn.extend({widthSegments:1,heightSegments:1,depthSegments:1,inside:!1},function(){this.build()},{build:function(){var e={px:fe("px",this.depthSegments,this.heightSegments),nx:fe("nx",this.depthSegments,this.heightSegments),py:fe("py",this.widthSegments,this.depthSegments),ny:fe("ny",this.widthSegments,this.depthSegments),pz:fe("pz",this.widthSegments,this.heightSegments),nz:fe("nz",this.widthSegments,this.heightSegments)},t=["position","texcoord0","normal"],r=0,n=0;for(var i in e)r+=e[i].vertexCount,n+=e[i].indices.length;for(var a=0;a 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"})});h.set("normalDistribution",n),r.encodeRGBM&&h.shader.define("fragment","RGBM_ENCODE"),r.decodeRGBM&&h.shader.define("fragment","RGBM_DECODE");var f,d=new _r;if(t instanceof Pr){var _=new Jn({width:a,height:o,type:s===Vt.FLOAT?Vt.HALF_FLOAT:s});mi.panoramaToCubeMap(e,t,_,{encodeRGBM:r.decodeRGBM}),t=_}f=new Yi({scene:d,material:h}),f.material.set("environmentMap",t);var p=new ai({texture:u});r.encodeRGBM&&(s=u.type=Vt.UNSIGNED_BYTE);for(var m=new Pr({width:a,height:o,type:s}),v=new ni({depthBuffer:!1}),g=at[s===Vt.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],y=0;y 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"}),i=new Pr({width:512,height:256,type:Vt.HALF_FLOAT,minFilter:Vt.NEAREST,magFilter:Vt.NEAREST,useMipmap:!1});return n.setUniform("normalDistribution",t),n.setUniform("viewportSize",[512,256]),n.attachOutput(i),n.render(e,r),r.dispose(e),i},Zi.generateNormalDistribution=function(e,t){for(var e=e||256,t=t||1024,r=new Pr({width:e,height:t,type:Vt.FLOAT,minFilter:Vt.NEAREST,magFilter:Vt.NEAREST,useMipmap:!1}),n=new Float32Array(t*e*4),i=0;i>>16)>>>0;o=((1431655765&o)<<1|(2863311530&o)>>>1)>>>0,o=((858993459&o)<<2|(3435973836&o)>>>2)>>>0,o=((252645135&o)<<4|(4042322160&o)>>>4)>>>0,o=(((16711935&o)<<8|(4278255360&o)>>>8)>>>0)/4294967296;for(var s=0;s3?t[3]=e[3]:t[3]=1,t):(t=be(e||"#000",t)||[0,0,0,0],t[0]/=255,t[1]/=255,t[2]/=255,t)},sa.stringifyColor=function(e,t){return e=e.slice(),e[0]=Math.round(255*e[0]),e[1]=Math.round(255*e[1]),e[2]=Math.round(255*e[2]),"hex"===t?"#"+((1<<24)+(e[0]<<16)+(e[1]<<8)+e[2]).toString(16).slice(1):Ae(e,t)},sa.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},sa.convertTextureToPowerOfTwo=Re;var la={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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 / 32, height * 1.0 / 32] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(qtek.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(qtek.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 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blend",shader:"#source(qtek.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(qtek.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(qtek.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 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blend",shader:"#source(qtek.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(qtek.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(qtek.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 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blend",shader:"#source(qtek.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(qtek.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(qtek.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 / 2, height * 1.0 / 2] )"}},{name:"bloom_composite",shader:"#source(qtek.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(qtek.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},defines:{}},{name:"FXAA",shader:"#source(qtek.compositor.fxaa)",inputs:{texture:"composite"}}]};Ut.import(Nn),Ut.import(wn),Ut.import(Mn),Ut.import(Rn),Ut.import(Cn),Ut.import(Ln),Ut.import(Dn),Ut.import(Pn),Ut.import(Hi),Ut.import("@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 qtek.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 qtek.util.rgbm\n@import qtek.util.float\n\nvoid main()\n{\n vec4 blurredColor = decodeHDR(texture2D(blurred, v_Texcoord));\n vec4 originalColor = decodeHDR(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 = decodeHDR(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 qtek.util.rgbm\n@import qtek.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 = decodeHDR(texel);\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\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 gl_FragColor = encodeHDR(color);\n#endif\n}\n\n@end"), -Ut.import("@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");var ca={color:{parameters:{width:function(e){return e.getWidth()},height:function(e){return e.getHeight()}}}},ha=["composite","FXAA"];Ce.prototype.resize=function(e,t,r){r=r||1,e*=r,t*=r;var n=this._sourceTexture,i=this._depthTexture;n.width=e,n.height=t,i.width=e,i.height=t,this._gBufferPass.resize(e,t)},Ce.prototype._ifRenderNormalPass=function(){return this._enableSSAO||this._enableEdge||this._enableSSR},Ce.prototype._getPrevNode=function(e){for(var t=ha.indexOf(e.name)-1,r=this._finalNodesChain[t];r&&!this._compositor.getNodeByName(r.name);)t-=1,r=this._finalNodesChain[t];return r},Ce.prototype._getNextNode=function(e){for(var t=ha.indexOf(e.name)+1,r=this._finalNodesChain[t];r&&!this._compositor.getNodeByName(r.name);)t+=1,r=this._finalNodesChain[t];return r},Ce.prototype._addChainNode=function(e){var t=this._getPrevNode(e),r=this._getNextNode(e);t&&(t.outputs=ca,e.inputs.texture=t.name,r?(e.outputs=ca,r.inputs.texture=e.name):e.outputs=null,this._compositor.addNode(e))},Ce.prototype._removeChainNode=function(e){var t=this._getPrevNode(e),r=this._getNextNode(e);t&&(r?(t.outputs=ca,r.inputs.texture=t.name):t.outputs=null,this._compositor.removeNode(e))},Ce.prototype.updateNormal=function(e,t,r,n){this._ifRenderNormalPass()&&this._gBufferPass.update(e,t,r)},Ce.prototype.updateSSAO=function(e,t,r,n){this._ssaoPass.update(e,r,n)},Ce.prototype.enableSSAO=function(){this._enableSSAO=!0},Ce.prototype.disableSSAO=function(){this._enableSSAO=!1},Ce.prototype.enableSSR=function(){this._enableSSR=!0},Ce.prototype.disableSSR=function(){this._enableSSR=!1},Ce.prototype.getSSAOTexture=function(e,t,r,n){return this._ssaoPass.getTargetTexture()},Ce.prototype.getSourceFrameBuffer=function(){return this._framebuffer},Ce.prototype.getSourceTexture=function(){return this._sourceTexture},Ce.prototype.disableFXAA=function(){this._removeChainNode(this._fxaaNode)},Ce.prototype.enableFXAA=function(){this._addChainNode(this._fxaaNode)},Ce.prototype.enableBloom=function(){this._compositeNode.inputs.bloom="bloom_composite",this._compositor.dirty()},Ce.prototype.disableBloom=function(){this._compositeNode.inputs.bloom=null,this._compositor.dirty()},Ce.prototype.enableDOF=function(){this._compositeNode.inputs.texture="dof_composite",this._compositor.dirty()},Ce.prototype.disableDOF=function(){this._compositeNode.inputs.texture="source",this._compositor.dirty()},Ce.prototype.enableColorCorrection=function(){this._compositeNode.shaderDefine("COLOR_CORRECTION"),this._enableColorCorrection=!0},Ce.prototype.disableColorCorrection=function(){this._compositeNode.shaderUndefine("COLOR_CORRECTION"),this._enableColorCorrection=!1},Ce.prototype.enableEdge=function(){this._enableEdge=!0},Ce.prototype.disableEdge=function(){this._enableEdge=!1},Ce.prototype.setBloomIntensity=function(e){null!=e&&this._compositeNode.setParameter("bloomIntensity",e)},Ce.prototype.setSSAOParameter=function(e,t){if(null!=t)switch(e){case"quality":var r={low:6,medium:12,high:32,ultra:62}[t]||12;this._ssaoPass.setParameter("kernelSize",r);break;case"radius":this._ssaoPass.setParameter(e,t),this._ssaoPass.setParameter("bias",t/50);break;case"intensity":this._ssaoPass.setParameter(e,t)}},Ce.prototype.setDOFParameter=function(e,t){if(null!=t)switch(e){case"focalDistance":case"focalRange":case"fstop":this._cocNode.setParameter(e,t);break;case"blurRadius":for(var r=0;r=this._haltonSequence.length},render:function(e){var t=this._blendPass;0===this._frame?(t.setUniform("weight1",0),t.setUniform("weight2",1)):(t.setUniform("weight1",.9),t.setUniform("weight2",.1)),t.setUniform("texture1",this._prevFrameTex),t.setUniform("texture2",this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),t.render(e),this._blendFb.unbind(e),this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e);var r=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=r,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)}},De.prototype.setProjection=function(e){var t=this.camera;t&&t.update(),"perspective"===e?this.camera instanceof rn||(this.camera=new rn,t&&this.camera.setLocalTransform(t.localTransform)):this.camera instanceof nn||(this.camera=new nn,t&&this.camera.setLocalTransform(t.localTransform)),this.camera.near=.1,this.camera.far=2e3},De.prototype.setViewport=function(e,t,r,n,i){this.camera instanceof rn&&(this.camera.aspect=r/n),i=i||1,this.viewport.x=e,this.viewport.y=t,this.viewport.width=r,this.viewport.height=n,this.viewport.devicePixelRatio=i,this._compositor.resize(r*i,n*i),this._temporalSS.resize(r*i,n*i)},De.prototype.containPoint=function(e,t){var r=this.viewport;return t=this.layer.renderer.getHeight()-t,e>=r.x&&t>=r.y&&e<=r.x+r.width&&t<=r.y+r.height};var fa=new Kt;De.prototype.castRay=function(e,t,r){var n=this.layer.renderer,i=n.viewport;return n.viewport=this.viewport,n.screenToNDC(e,t,fa),this.camera.castRay(fa,r),n.viewport=i,r},De.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this._frame=0,this._temporalSS.resetFrame()},De.prototype.render=function(e){this._doRender(e,this._frame),this._frame++},De.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively},De.prototype.needsTemporalSS=function(){var e=this._enableTemporalSS;return"auto"==e&&(e=this._enablePostEffect),e},De.prototype.hasDOF=function(){return this._enableDOF},De.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30},De.prototype._doRender=function(e,t){var r=this.scene,n=this.camera,i=this.renderer;if(t=t||0,!e&&this._shadowMapPass&&(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(i,r,n,!0)),this._updateShadowPCFKernel(t),i.gl.clearColor(0,0,0,0),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(i,n),this._compositor.updateNormal(i,r,n,this._temporalSS.getFrame())),this._updateSSAO(i,r,n,this._temporalSS.getFrame()),this._enablePostEffect){var a=this._compositor.getSourceFrameBuffer();a.bind(i),i.gl.clear(i.gl.DEPTH_BUFFER_BIT|i.gl.COLOR_BUFFER_BIT),i.render(r,n,!0,this.preZ),this.afterRenderScene(i,r,n),a.unbind(i),this.needsTemporalSS()&&e?(this._compositor.composite(i,n,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),i.setViewport(this.viewport),this._temporalSS.render(i)):(i.setViewport(this.viewport),this._compositor.composite(i,n,null,0))}else if(this.needsTemporalSS()&&e){var a=this._temporalSS.getSourceFrameBuffer();a.bind(i),i.saveClear(),i.clearBit=i.gl.DEPTH_BUFFER_BIT|i.gl.COLOR_BUFFER_BIT,i.render(r,n,!0,this.preZ),this.afterRenderScene(i,r,n),i.restoreClear(),a.unbind(i),i.setViewport(this.viewport),this._temporalSS.render(i)}else i.setViewport(this.viewport),i.render(r,n,!0,this.preZ),this.afterRenderScene(i,r,n);this.afterRenderAll(i,r,n)},De.prototype.afterRenderScene=function(e,t,r){},De.prototype.afterRenderAll=function(e,t,r){},De.prototype._updateSSAO=function(e,t,r,n){function i(e){for(var t=0;tthis.camera.far||e1&&n&&n.length>1){var a=qe(n)/qe(i);!isFinite(a)&&(a=1),t.pinchScale=a;var o=We(n);return t.pinchX=o[0],t.pinchY=o[1],{type:"pinch",target:e[0].target,event:t}}}}},Ea=$e.extend(function(){return{animation:null,domElement:null,target:null,_center:new ut,minDistance:.1,maxDistance:1e3,minAlpha:-90,maxAlpha:90,minBeta:-1/0,maxBeta:1/0,autoRotateAfterStill:0,autoRotateDirection:"cw",autoRotateSpeed:60,_mode:"rotate",damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,_needsUpdate:!1,_rotating:!1,_phi:0,_theta:0,_mouseX:0,_mouseY:0,_rotateVelocity:new Kt,_panVelocity:new Kt,_distance:20,_zoomSpeed:0,_stillTimeout:0,_animators:[],_gestureMgr:new xa}},function(){this._mouseDownHandler=this._mouseDownHandler.bind(this),this._mouseWheelHandler=this._mouseWheelHandler.bind(this),this._mouseMoveHandler=this._mouseMoveHandler.bind(this),this._mouseUpHandler=this._mouseUpHandler.bind(this),this._pinchHandler=this._pinchHandler.bind(this),this.update=this.update.bind(this),this.init()},{init:function(){var e=this.domElement;e.addEventListener("touchstart",this._mouseDownHandler),e.addEventListener("mousedown",this._mouseDownHandler),e.addEventListener("mousewheel",this._mouseWheelHandler),this.animation&&this.animation.on("frame",this.update)},dispose:function(){var e=this.domElement;e.removeEventListener("touchstart",this._mouseDownHandler),e.removeEventListener("touchmove",this._mouseMoveHandler),e.removeEventListener("touchend",this._mouseUpHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseup",this._mouseUpHandler),e.removeEventListener("mousewheel",this._mouseWheelHandler),this.animation&&this.animation.off("frame",this.update),this.stopAllAnimation()},getDistance:function(){return this._distance},setDistance:function(e){this._distance=e,this._needsUpdate=!0},getAlpha:function(){return this._theta/Math.PI*180},getBeta:function(){return-this._phi/Math.PI*180},getCenter:function(){return this._center.toArray()},setAlpha:function(e){e=Math.max(Math.min(this.maxAlpha,e),this.minAlpha),this._theta=e/180*Math.PI,this._needsUpdate=!0},setBeta:function(e){e=Math.max(Math.min(this.maxBeta,e),this.minBeta),this._phi=-e/180*Math.PI,this._needsUpdate=!0},setCenter:function(e){this._center.setArray(e)},setOption:function(e){e=e||{},["autoRotate","autoRotateAfterStill","autoRotateDirection","autoRotateSpeed","damping","minDistance","maxDistance","minAlpha","maxAlpha","minBeta","maxBeta","rotateSensitivity","zoomSensitivity","panSensitivity"].forEach(function(t){null!=e[t]&&(this[t]=e[t])},this),null!=e.distance&&this.setDistance(e.distance),null!=e.alpha&&this.setAlpha(e.alpha),null!=e.beta&&this.setBeta(e.beta),e.center&&this.setCenter(e.center)},animateTo:function(e){var t=this,r={},n={},i=this.animation;if(i)return null!=e.distance&&(r.distance=this.getDistance(),n.distance=e.distance),null!=e.alpha&&(r.alpha=this.getAlpha(),n.alpha=e.alpha),null!=e.beta&&(r.beta=this.getBeta(),n.beta=e.beta),null!=e.center&&(r.center=this.getCenter(),n.center=e.center),this._addAnimator(i.animate(r).when(e.duration||1e3,n).during(function(){null!=r.alpha&&t.setAlpha(r.alpha),null!=r.beta&&t.setBeta(r.beta),null!=r.distance&&t.setDistance(r.distance),null!=r.center&&t.setCenter(r.center),t._needsUpdate=!0}).done(e.done)).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e0},update:function(e){if(e=e||16,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)>.01||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(this._updateDistance(Math.min(e,50)),this._updatePan(Math.min(e,50)),this._updateRotate(Math.min(e,50)),this._updateTransform(),this.target.update(),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,this.damping)},_updateDistance:function(e){this._setDistance(this._distance+this._zoomSpeed*e/20),this._zoomSpeed*=this.damping},_setDistance:function(e){this._distance=Math.max(Math.min(e,this.maxDistance),this.minDistance)},_updatePan:function(e){var t=this._panVelocity,r=this._distance,n=this.target,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.target,t=new ut,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.target){var e=new ut;e.eulerFromQuat(this.target.rotation.normalize(),"ZYX"),this._theta=-e.x,this._phi=-e.y,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this._setDistance(this.target.position.dist(this._center))}},_mouseDownHandler:function(e){if(!this._isAnimating()){var t=e.clientX,r=e.clientY;if(e.targetTouches){var n=e.targetTouches[0];t=n.clientX,r=n.clientY,this._mode="rotate",this._processGesture(e,"start")}var i=this.domElement;i.addEventListener("touchmove",this._mouseMoveHandler),i.addEventListener("touchend",this._mouseUpHandler),i.addEventListener("mousemove",this._mouseMoveHandler),i.addEventListener("mouseup",this._mouseUpHandler),0===e.button?this._mode="rotate":1===e.button&&(this._mode="pan"),this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=t,this._mouseY=r}},_mouseMoveHandler:function(e){if(!this._isAnimating()){var t,r=e.clientX,n=e.clientY;if(e.targetTouches){var i=e.targetTouches[0];r=i.clientX,n=i.clientY,t=this._processGesture(e,"change")}var a=Ve(this.panSensitivity),o=Ve(this.rotateSensitivity);t||("rotate"===this._mode?(this._rotateVelocity.y=(r-this._mouseX)/this.domElement.clientHeight*2*o[0],this._rotateVelocity.x=(n-this._mouseY)/this.domElement.clientWidth*2*o[1]):"pan"===this._mode&&(this._panVelocity.x=(r-this._mouseX)/this.domElement.clientWidth*a[0]*400,this._panVelocity.y=(-n+this._mouseY)/this.domElement.clientHeight*a[1]*400)),this._mouseX=r,this._mouseY=n,e.preventDefault()}},_mouseWheelHandler:function(e){if(!this._isAnimating()){var t=e.wheelDelta||-e.detail;0!==t&&this._zoomHandler(e,t>0?-1:1)}},_pinchHandler:function(e){this._isAnimating()||this._zoomHandler(e,e.pinchScale>1?-.4:.4)},_zoomHandler:function(e,t){var r=Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance));this._zoomSpeed=t*Math.max(r/40*this.zoomSensitivity,.2),this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),e.preventDefault()},_mouseUpHandler:function(e){var t=this.domElement;t.removeEventListener("touchmove",this._mouseMoveHandler),t.removeEventListener("touchend",this._mouseUpHandler),t.removeEventListener("mousemove",this._mouseMoveHandler),t.removeEventListener("mouseup",this._mouseUpHandler),this._processGesture(e,"end")},_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},_processGesture:function(e,t){var r=this._gestureMgr;"start"===t&&r.clear();var n=r.recognize(e,null,this.domElement);if("end"===t&&r.clear(),n){var i=n.type;e.gestureEvent=i,this._pinchHandler(n.event)}return n}});Object.defineProperty(Ea.prototype,"autoRotate",{get:function(){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}}),Object.defineProperty(Ea.prototype,"target",{get:function(){return this._target},set:function(e){e&&e.target&&this.setCenter(e.target.toArray()),this._target=e,this.decomposeTransform()}});var ba=ot.vec4,Sa=function(e,t,r,n){e=e||0,t=t||0,r=r||0,n=n||0,this._array=ba.fromValues(e,t,r,n),this._dirty=!0};Sa.prototype={constructor:Sa,add:function(e){return ba.add(this._array,this._array,e._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 Sa(this.x,this.y,this.z,this.w)},copy:function(e){return ba.copy(this._array,e._array),this._dirty=!0,this},dist:function(e){return ba.dist(this._array,e._array)},distance:function(e){return ba.distance(this._array,e._array)},div:function(e){return ba.div(this._array,this._array,e._array),this._dirty=!0,this},divide:function(e){return ba.divide(this._array,this._array,e._array),this._dirty=!0,this},dot:function(e){return ba.dot(this._array,e._array)},len:function(){return ba.len(this._array)},length:function(){return ba.length(this._array)},lerp:function(e,t,r){return ba.lerp(this._array,e._array,t._array,r),this._dirty=!0,this},min:function(e){return ba.min(this._array,this._array,e._array),this._dirty=!0,this},max:function(e){return ba.max(this._array,this._array,e._array),this._dirty=!0,this},mul:function(e){return ba.mul(this._array,this._array,e._array),this._dirty=!0,this},multiply:function(e){return ba.multiply(this._array,this._array,e._array),this._dirty=!0,this},negate:function(){return ba.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return ba.normalize(this._array,this._array),this._dirty=!0,this},random:function(e){return ba.random(this._array,e),this._dirty=!0,this},scale:function(e){return ba.scale(this._array,this._array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return ba.scaleAndAdd(this._array,this._array,e._array,t),this._dirty=!0,this},sqrDist:function(e){return ba.sqrDist(this._array,e._array)},squaredDistance:function(e){return ba.squaredDistance(this._array,e._array)},sqrLen:function(){return ba.sqrLen(this._array)},squaredLength:function(){return ba.squaredLength(this._array)},sub:function(e){return ba.sub(this._array,this._array,e._array),this._dirty=!0,this},subtract:function(e){return ba.subtract(this._array,this._array,e._array),this._dirty=!0,this},transformMat4:function(e){return ba.transformMat4(this._array,this._array,e._array),this._dirty=!0,this},transformQuat:function(e){return ba.transformQuat(this._array,this._array,e._array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}};var Aa=Object.defineProperty;if(Aa){var Na=Sa.prototype;Aa(Na,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),Aa(Na,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),Aa(Na,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}}),Aa(Na,"w",{get:function(){return this._array[3]},set:function(e){this._array[3]=e,this._dirty=!0}})}Sa.add=function(e,t,r){return ba.add(e._array,t._array,r._array),e._dirty=!0,e},Sa.set=function(e,t,r,n,i){ba.set(e._array,t,r,n,i),e._dirty=!0},Sa.copy=function(e,t){return ba.copy(e._array,t._array),e._dirty=!0,e},Sa.dist=function(e,t){return ba.distance(e._array,t._array)},Sa.distance=Sa.dist,Sa.div=function(e,t,r){return ba.divide(e._array,t._array,r._array),e._dirty=!0,e},Sa.divide=Sa.div, -Sa.dot=function(e,t){return ba.dot(e._array,t._array)},Sa.len=function(e){return ba.length(e._array)},Sa.lerp=function(e,t,r,n){return ba.lerp(e._array,t._array,r._array,n),e._dirty=!0,e},Sa.min=function(e,t,r){return ba.min(e._array,t._array,r._array),e._dirty=!0,e},Sa.max=function(e,t,r){return ba.max(e._array,t._array,r._array),e._dirty=!0,e},Sa.mul=function(e,t,r){return ba.multiply(e._array,t._array,r._array),e._dirty=!0,e},Sa.multiply=Sa.mul,Sa.negate=function(e,t){return ba.negate(e._array,t._array),e._dirty=!0,e},Sa.normalize=function(e,t){return ba.normalize(e._array,t._array),e._dirty=!0,e},Sa.random=function(e,t){return ba.random(e._array,t),e._dirty=!0,e},Sa.scale=function(e,t,r){return ba.scale(e._array,t._array,r),e._dirty=!0,e},Sa.scaleAndAdd=function(e,t,r,n){return ba.scaleAndAdd(e._array,t._array,r._array,n),e._dirty=!0,e},Sa.sqrDist=function(e,t){return ba.sqrDist(e._array,t._array)},Sa.squaredDistance=Sa.sqrDist,Sa.sqrLen=function(e){return ba.sqrLen(e._array)},Sa.squaredLength=Sa.sqrLen,Sa.sub=function(e,t,r){return ba.subtract(e._array,t._array,r._array),e._dirty=!0,e},Sa.subtract=Sa.sub,Sa.transformMat4=function(e,t,r){return ba.transformMat4(e._array,t._array,r._array),e._dirty=!0,e},Sa.transformQuat=function(e,t,r){return ba.transformQuat(e._array,t._array,r._array),e._dirty=!0,e};var wa=$e.extend(function(){return{dom:null,renderer:null,camera:null,_boundingBox:new vt,_hotspotRoot:null,_hotspots:[]}},function(){if(!this.dom||!this.renderer||!this.camera)throw new Error("Tip manager needs `root`, `camera`, `renderer`");var e=this._hotspotRoot=document.createElement("div");e.style.cssText="position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;",this.dom.appendChild(e)},{setBoundingBox:function(e,t){this._boundingBox.min.setArray(e),this._boundingBox.max.setArray(t)},add:function(e,t){if("string"==typeof t){var r=document.createElement("div");r.innerHTML=t,t=r}return t.classList.add("qmv-annotation"),t.style.position="absolute",this._hotspotRoot.appendChild(t),this._hotspots.push({position:e,dom:t}),t},remove:function(e){for(var t=-1,r=0;r=0&&(this._hotspots.splice(t,1),this._hotspotRoot.removeChild(e))},update:function(){var e=new Sa,t=new vt;this._hotspots.forEach(function(r){var n=r.position;e.set(n[0],n[1],n[2],1),e.transformMat4(this.camera.viewMatrix),e.transformMat4(this.camera.projectionMatrix),e.scale(1/e.w);var i=.5*(e.x+1)*this.renderer.getWidth(),a=.5*(e.y+1)*this.renderer.getHeight();r.dom.style.left=i+"px",r.dom.style.top=this.renderer.getHeight()-a+"px",t.copy(this._boundingBox),t.applyTransform(this.camera.viewMatrix),r.dom.style.opacity=1,r.onupdate&&r.onupdate(i,a)},this)}});Ut.import("@export qmv.ground.vertex\n@import qtek.lambert.vertex\n@end\n\n\n@export qmv.ground.fragment\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float gridSize: 5;\nuniform float gridSize2: 1;\nuniform vec4 gridColor: [0, 0, 0, 1];\nuniform vec4 gridColor2: [0.3, 0.3, 0.3, 1];\n\nuniform float glossiness: 0.7;\n\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import qtek.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import qtek.header.ambient_sh_light\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import qtek.header.directional_light\n#endif\n\n@import qtek.plugin.compute_shadow_map\n\nvoid main()\n{\n gl_FragColor = color;\n\n float wx = v_WorldPosition.x;\n float wz = v_WorldPosition.z;\n float x0 = abs(fract(wx / gridSize - 0.5) - 0.5) / fwidth(wx) * gridSize / 2.0;\n float z0 = abs(fract(wz / gridSize - 0.5) - 0.5) / fwidth(wz) * gridSize / 2.0;\n\n float x1 = abs(fract(wx / gridSize2 - 0.5) - 0.5) / fwidth(wx) * gridSize2;\n float z1 = abs(fract(wz / gridSize2 - 0.5) - 0.5) / fwidth(wz) * gridSize2;\n\n float v0 = 1.0 - clamp(min(x0, z0), 0.0, 1.0);\n float v1 = 1.0 - clamp(min(x1, z1), 0.0, 1.0);\n if (v0 > 0.1) {\n gl_FragColor = mix(gl_FragColor, gridColor, v0);\n }\n else {\n gl_FragColor = mix(gl_FragColor, gridColor2, v1);\n }\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {\n diffuseColor += ambientLightColor[_idx_];\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_, v_Normal) * ambientSHLightColor[_idx_];\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 i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float ndl = dot(v_Normal, normalize(lightDirection));\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 diffuseColor += lightColor * clamp(ndl, 0.0, 1.0) * shadowContrib;\n }\n#endif\n\n#ifdef SSAOMAP_ENABLED\n diffuseColor *= texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n gl_FragColor.a *= 1.0 - clamp(length(v_WorldPosition.xz) / 30.0, 0.0, 1.0);\n\n}\n\n@end");var Ma=["diffuseMap","normalMap","emissiveMap","metalnessMap","roughnessMap","specularMap","glossinessMap"];je.prototype.init=function(e,t){t=t||{},this.root=e,this._animation=new Hn;var r=new nr({devicePixelRatio:t.devicePixelRatio||window.devicePixelRatio});e.appendChild(r.canvas),r.canvas.style.cssText="position:absolute;left:0;top:0",this._renderer=r,this._renderMain=new De(r,t.shadow,"perspective"),this._renderMain.afterRenderScene=function(e,t,r){this.trigger("renderscene",e,t,r)}.bind(this),this._renderMain.afterRenderAll=function(e,t,r){this.trigger("afterrender",e,t,r)}.bind(this),this._renderMain.preZ=t.preZ||!1;var n=this._cameraControl=new Ea({renderer:r,animation:this._animation,domElement:e});n.target=this._renderMain.camera,n.init(),this._hotspotManager=new wa({dom:e,renderer:r,camera:this._renderMain.camera}),this._skeletons=[],this._clips=[],this._takes=[],this._materialsMap={},this._sceneHelper=new Pe(this._renderMain.scene),this._sceneHelper.initLight(this._renderMain.scene),this.resize(),t.postEffect&&this.setPostEffect(t.postEffect),t.mainLight&&this.setMainLight(t.mainLight),t.secondaryLight&&this.setSecondaryLight(t.secondaryLight),t.tertiaryLight&&this.setTertiaryLight(t.tertiaryLight),t.ambientCubemapLight&&this.setAmbientCubemapLight(t.ambientCubemapLight),t.ambientLight&&this.setAmbientLight(t.ambientLight),t.environment&&this.setEnvironment(t.environment),this._createGround(),t.ground&&this.setGround(t.ground),this.setCameraControl({distance:20,minDisntance:2,maxDistance:100,center:[0,0,0]}),this._enablePicking=t.picking||!1,this._initHandlers(),n.on("update",function(){this.trigger("updatecamera",{center:n.getCenter(),alpha:n.getAlpha(),beta:n.getBeta(),distance:n.getDistance()}),this.refresh()},this),this.shaderLibrary=Wt.createLibrary()},je.prototype._createGround=function(){var e=new Ir({isGround:!0,material:new jt({shader:new Ut({vertex:Ut.source("qmv.ground.vertex"),fragment:Ut.source("qmv.ground.fragment")}),transparent:!0}),castShadow:!1,geometry:new Xn});e.material.set("color",[1,1,1,1]),e.scale.set(40,40,1),e.rotation.rotateX(-Math.PI/2),this._groundMesh=e,this._renderMain.scene.add(e)},je.prototype._addModel=function(e,t,r,n){this.removeModel(),this._renderMain.scene.add(e),this._skeletons=r.slice(),this._modelNode=e,this._setAnimationClips(n),t&&t.length&&(this._nodes=t);var i={};e.traverse(function(e){if(e.material){var t=e.material;i[t.name]=i[t.name]||[],i[t.name].push(t)}},this),this._materialsMap=i,this._updateMaterialsSRGB(),this._stopAccumulating()},je.prototype._removeAnimationClips=function(){this._clips.forEach(function(e){this._animation.removeClip(e)},this),this._clips=[],this._takes=[]},je.prototype._setAnimationClips=function(e){function t(){r.refresh()}var r=this;e.forEach(function(e){e.tracks.forEach(function(e){e.target||(e.target=this._nodes[e.targetNodeIndex])},this),e.onframe=t,this._animation.addClip(e),this._takes.push({name:e.name,range:[0,e.life],clip:e})},this),this._clips=e.slice()},je.prototype._initHandlers=function(){this._picking=new Yn({renderer:this._renderer,scene:this._renderMain.scene,camera:this._renderMain.camera}),this._clickHandler=this._clickHandler.bind(this),this._mouseDownHandler=this._mouseDownHandler.bind(this),this.root.addEventListener("mousedown",this._mouseDownHandler),this.root.addEventListener("click",this._clickHandler)},je.prototype._mouseDownHandler=function(e){this._startX=e.clientX,this._startY=e.clientY},je.prototype._clickHandler=function(e){if(this._enablePicking||this._renderMain.isDOFEnabled()){var t=e.clientX-this._startX,r=e.clientY-this._startY;if(!(Math.sqrt(t*t+r*r)>=40)){var n=this._picking.pick(e.clientX,e.clientY,!0);n&&!n.target.isGround?(this._renderMain.setDOFFocusOnPoint(n.distance),this.trigger("doffocus",n),this._selectResult=n,this.trigger("select",n),this.refresh()):(this._selectResult&&this.trigger("unselect",this._selectResult),this._selectResult=null)}}},je.prototype.enablePicking=function(){this._enablePicking=!0},je.prototype.disablePicking=function(){this._enablePicking=!1},je.prototype.setModelUpAxis=function(e){var t=this._modelNode;t&&(t.position.set(0,0,0),t.scale.set(1,1,1),t.rotation.identity(),"z"===e.toLowerCase()&&t.rotation.identity().rotateX(-Math.PI/2),this.autoFitModel())},je.prototype.setTextureFlipY=function(e){if(this._modelNode){for(var t in this._materialsMap)for(var r=0;r1||o<0){r=!0;break}}if(r)for(var n=0;n=0&&s.splice(n,1),u[e]=null}}t=t||{};var i=this._materialsMap[e],a=this,o=this._textureFlipY;if(!i||!i.length)return void console.warn("Material %s not exits",e);var s=i[0].shader.getEnabledTextures(),u={};["diffuseMap","normalMap","parallaxOcclusionMap","emissiveMap"].forEach(function(e){n(e)},this),i[0].shader.isDefined("fragment","USE_METALNESS")?["metalnessMap","roughnessMap"].forEach(function(e){n(e)},this):["specularMap","glossinessMap"].forEach(function(e){n(e)},this),(u.normalMap||u.parallaxOcclusionMap)&&this._modelNode.traverse(function(t){t.material&&t.material.name===e&&(t.geometry.attributes.tangent.value||t.geometry.generateTangents())}),i.forEach(function(e){null!=t.transparent&&(e.transparent=!!t.transparent,e.depthMask=!t.transparent),["color","emission","specularColor"].forEach(function(r){null!=t[r]&&e.set(r,sa.parseColor(t[r]))}),["alpha","alphaCutoff","metalness","roughness","glossiness","emissionIntensity","uvRepeat","parallaxOcclusionScale"].forEach(function(r){null!=t[r]&&e.set(r,t[r])});for(var r in u)e.set(r,u[r]);e.attachShader(this.shaderLibrary.get("qtek."+(this._shaderName||"standard"),{fragmentDefines:e.shader.fragmentDefines,textures:s,vertexDefines:e.shader.vertexDefines,precision:e.shader.precision}),!0)},this),this.refresh()},je.prototype.getMaterial=function(e){function t(e){var t=n.get(e);if(!t)return"";for(var r=t.image;r.srcImage;)r=r.srcImage;return r&&r.src||""}var r=this._materialsMap[e];if(!r)return void console.warn("Material %s not exits",e);var n=r[0],i={name:e};return["color","emission"].forEach(function(e){i[e]=sa.stringifyColor(n.get(e),"hex")}),["alpha","alphaCutoff","emissionIntensity","uvRepeat","parallaxOcclusionScale"].forEach(function(e){i[e]=n.get(e)}),["diffuseMap","normalMap","parallaxOcclusionMap","emissiveMap"].forEach(function(e){i[e]=t(e)}),n.shader.isDefined("fragment","USE_METALNESS")?(["metalness","roughness"].forEach(function(e){i[e]=n.get(e)}),["metalnessMap","roughnessMap"].forEach(function(e){i[e]=t(e)}),i.type="pbrMetallicRoughness"):(i.specularColor=sa.stringifyColor(n.get("specularColor"),"hex"),i.glossiness=n.get("glossiness"),["specularMap","glossinessMap"].forEach(function(e){i[e]=t(e)}),i.type="pbrSpecularGlossiness"),i},je.prototype.setGround=function(e){this._groundMesh.invisible=!e.show,this.refresh()},je.prototype.getMaterialsNames=function(){return Object.keys(this._materialsMap)},je.prototype.setPostEffect=function(e){this._renderMain.setPostEffect(e),this._updateMaterialsSRGB(),this.refresh()},je.prototype.start=function(){if(this._disposed)return void console.warn("Viewer already disposed");this._animation.start(),this._animation.on("frame",this._loop,this)},je.prototype.stop=function(){this._animation.stop(),this._animation.off("frame",this._loop)},je.prototype.addHotspot=function(e,t){return this._hotspotManager.add(e,t)},je.prototype.setPose=function(e){this._clips.forEach(function(t){t.setTime(e)}),this._skeletons.forEach(function(e){e.update()}),this.refresh()},je.prototype.getAnimationDuration=function(){var e=0;return this._clips.forEach(function(t){e=Math.max(t.life,e)}),e},je.prototype.refresh=function(){this._needsRefresh=!0},je.prototype.getRenderer=function(){return this._renderer},je.prototype._updateMaterialsSRGB=function(){var e=this._renderMain.isLinearSpace();for(var t in this._materialsMap)for(var r=this._materialsMap[t],n=0;nr?r:e}function s(){return{locations:{},attriblocations:{}}}function u(e,t,r){if(!e.getShaderParameter(t,e.COMPILE_STATUS))return[e.getShaderInfoLog(t),l(r)].join("\n")}function l(e){for(var t=e.split("\n"),r=0,n=t.length;r=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}function d(e,t){if(t.castShadow&&!e.castShadow)return!0}function _(e,t,r){var n=t;n+=256*r.roughnessChannel,n+=1024*r.metalnessChannel;for(var i=0;i1e-6?(o=Math.acos(s),u=Math.sin(o),l=Math.sin((1-n)*o)/u,c=Math.sin(n*o)/u):(l=1-n,c=n),e[0]=l*h+c*p,e[1]=l*f+c*m,e[2]=l*d+c*v,e[3]=l*_+c*g,e}function E(e){return{byte:nt.Int8Array,ubyte:nt.Uint8Array,short:nt.Int16Array,ushort:nt.Uint16Array}[e]||nt.Float32Array}function b(e){return"attr_"+e}function S(e,t,r,n){switch(this.name=e,this.type=t,this.size=r,this.semantic=n||"",this.value=null,r){case 1:this.get=function(e){return this.value[e]},this.set=function(e,t){this.value[e]=t},this.copy=function(e,t){this.value[e]=this.value[e]};break;case 2:this.get=function(e,t){var r=this.value;return t[0]=r[2*e],t[1]=r[2*e+1],t},this.set=function(e,t){var r=this.value;r[2*e]=t[0],r[2*e+1]=t[1]},this.copy=function(e,t){var r=this.value;t*=2,e*=2,r[e]=r[t],r[e+1]=r[t+1]};break;case 3:this.get=function(e,t){var r=3*e,n=this.value;return t[0]=n[r],t[1]=n[r+1],t[2]=n[r+2],t},this.set=function(e,t){var r=3*e,n=this.value;n[r]=t[0],n[r+1]=t[1],n[r+2]=t[2]},this.copy=function(e,t){var r=this.value;t*=3,e*=3,r[e]=r[t],r[e+1]=r[t+1],r[e+2]=r[t+2]};break;case 4:this.get=function(e,t){var r=this.value,n=4*e;return t[0]=r[n],t[1]=r[n+1],t[2]=r[n+2],t[3]=r[n+3],t},this.set=function(e,t){var r=this.value,n=4*e;r[n]=t[0],r[n+1]=t[1],r[n+2]=t[2],r[n+3]=t[3]},this.copy=function(e,t){var r=this.value;t*=4,e*=4,r[e]=r[t],r[e+1]=r[t+1],r[e+2]=r[t+2],r[e+3]=r[t+3]}}}function A(e,t,r,n,i){this.name=e,this.type=t,this.buffer=r,this.size=n,this.semantic=i,this.symbol="",this.needsRemove=!1}function N(e){this.buffer=e,this.count=0}function w(e,t,r,n){var i=e.accessors[r],a=t.bufferViews[i.bufferView],o=i.byteOffset||0,s=Ln[i.componentType]||nt.Float32Array,u=Dn[i.type];null==u&&n&&(u=1);var l=new s(a,o,u*i.count),c=i.extensions&&i.extensions.WEB3D_quantized_attributes;if(c){for(var h,f,d=new nt.Float32Array(u*i.count),_=c.decodeMatrix,h=new Array(u),f=new Array(u),p=0;pi)e.length=i;else for(var a=n;a=0&&!(_[g]<=t);g--);g=Math.min(g,l-2)}else{for(g=w;gt);g++);g=Math.min(g-1,l-2)}w=g,M=t;var r=_[g+1]-_[g];0!==r&&(E=(t-_[g])/r,u?(S=p[g],b=p[0===g?g:g-1],A=p[g>l-2?l-1:g+1],N=p[g>l-3?l-1:g+2],a?s(e,i,a(o(e,i),b,S,A,N,E)):h?I(b,S,A,N,E,E*E,E*E*E,o(e,i),f):s(e,i,O(b,S,A,N,E,E*E,E*E*E))):a?s(e,i,a(o(e,i),p[g],p[g+1],E)):h?L(p[g],p[g+1],E,o(e,i),f):s(e,i,C(p[g],p[g+1],E)))},P=new nn({target:e._target,life:d,loop:e._loop,delay:e._delay,onframe:R,onfinish:r});return t&&"spline"!==t&&P.setEasing(t),P}}}function U(e,t,r,n,i){this._tracks={},this._target=e,this._loop=t||!1,this._getter=r||M,this._setter=n||R,this._interpolater=i||null,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]}function H(e,t){var r=new Hn;return nr.get({url:e,responseType:t,onload:function(e){r.resolve(e)},onerror:function(e){r.reject(e)}}),r}function z(e){return"CANVAS"===e.nodeName||"VIDEO"===e.nodeName||e.complete}function G(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function W(e,t,r,n){if(e[3]>0){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 q(e,t,r){for(var n="",i=t;i0;)if(e[a][0]=t[r++],e[a][1]=t[r++],e[a][2]=t[r++],e[a][3]=t[r++],1===e[a][0]&&1===e[a][1]&&1===e[a][2]){for(var s=e[a][3]<>>0;s>0;s--)V(e[a-1],e[a]),a++,o--;i+=8}else a++,o--,i=0;return r}function X(e,t,r,n){if(nci)return j(e,t,r,n);var i=t[r++];if(2!=i)return j(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){o=(127&o)>>>0;for(var s=t[r++];o--;)e[a++][i]=s}else for(;o--;)e[a++][i]=t[r++]}return r}function K(e){Ze.defaultsWithPropList(e,Ti,Ei),Y(e);for(var t="",r=0;r0;)r+=n*(i%t),i=Math.floor(i/t),n/=t;return r}function te(e){for(var t=new Uint8Array(e*e*4),r=0,n=new ot,i=0;i255?255:e}function _e(e){return e<0?0:e>1?1:e}function pe(e){return de(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100*255:parseInt(e,10))}function me(e){return _e(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100:parseFloat(e))}function ve(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 ge(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e}function ye(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function xe(e,t){ra&&ye(ra,t),ra=ta.put(e,ra||t.slice())}function Te(e,t){if(e){t=t||[];var r=ta.get(e);if(r)return ye(t,r);e+="";var n=e.replace(/ /g,"").toLowerCase();if(n in ea)return ye(t,ea[n]),xe(e,t),t;if("#"!==n.charAt(0)){var i=n.indexOf("("),a=n.indexOf(")");if(-1!==i&&a+1===n.length){var o=n.substr(0,i),s=n.substr(i+1,a-(i+1)).split(","),u=1;switch(o){case"rgba":if(4!==s.length)return void ge(t,0,0,0,1);u=me(s.pop());case"rgb":return 3!==s.length?void ge(t,0,0,0,1):(ge(t,pe(s[0]),pe(s[1]),pe(s[2]),u),xe(e,t),t);case"hsla":return 4!==s.length?void ge(t,0,0,0,1):(s[3]=me(s[3]),Ee(s,t),xe(e,t),t);case"hsl":return 3!==s.length?void ge(t,0,0,0,1):(Ee(s,t),xe(e,t),t);default:return}}ge(t,0,0,0,1)}else{if(4===n.length){var l=parseInt(n.substr(1),16);return l>=0&&l<=4095?(ge(t,(3840&l)>>4|(3840&l)>>8,240&l|(240&l)>>4,15&l|(15&l)<<4,1),xe(e,t),t):void ge(t,0,0,0,1)}if(7===n.length){var l=parseInt(n.substr(1),16);return l>=0&&l<=16777215?(ge(t,(16711680&l)>>16,(65280&l)>>8,255&l,1),xe(e,t),t):void ge(t,0,0,0,1)}}}}function Ee(e,t){var r=(parseFloat(e[0])%360+360)%360/360,n=me(e[1]),i=me(e[2]),a=i<=.5?i*(n+1):i+n-i*n,o=2*i-a;return t=t||[],ge(t,de(255*ve(o,a,r+1/3)),de(255*ve(o,a,r)),de(255*ve(o,a,r-1/3)),1),4===e.length&&(t[3]=e[3]),t}function be(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+")"}}function Se(e){return!e||"none"===e}function Ae(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}function Ne(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function we(e){if((e.wrapS===Wt.REPEAT||e.wrapT===Wt.REPEAT)&&e.image){var t=Ne(e.width),r=Ne(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),n.srcImage=e.image,e.image=n,e.dirty()}}}function Me(){this._sourceTexture=new Lr({type:Wt.HALF_FLOAT}),this._depthTexture=new Lr({format:Wt.DEPTH_COMPONENT,type:Wt.UNSIGNED_INT}),this._framebuffer=new $n,this._framebuffer.attach(this._sourceTexture),this._framebuffer.attach(this._depthTexture,$n.DEPTH_ATTACHMENT),this._gBufferPass=new ki({enableTargetTexture3:!1});var e=new Ii;this._compositor=e.parse(aa);var t=this._compositor.getNodeByName("source");t.texture=this._sourceTexture;var r=this._compositor.getNodeByName("coc");this._sourceNode=t,this._cocNode=r,this._compositeNode=this._compositor.getNodeByName("composite"),this._fxaaNode=this._compositor.getNodeByName("FXAA"),this._dofBlurNodes=["dof_far_blur","dof_near_blur","dof_coc_blur"].map(function(e){return this._compositor.getNodeByName(e)},this),this._dofBlurKernel=null,this._dofBlurKernelSize=new Float32Array(0),this._finalNodesChain=sa.map(function(e){return this._compositor.getNodeByName(e)},this);var n={normalTexture:this._gBufferPass.getTargetTexture1(),depthTexture:this._gBufferPass.getTargetTexture2()};this._ssaoPass=new ie(n),this._ssrPass=new ae(n)}function Re(){for(var e=[],t=0;t<30;t++)e.push([ee(t,2),ee(t,3)]);this._haltonSequence=e,this._frame=0,this._sourceTex=new Lr,this._sourceFb=new $n,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new Lr,this._outputTex=new Lr;var r=this._blendPass=new yi({fragment:kt.source("qtek.compositor.blend")});r.material.shader.disableTexturesAll(),r.material.shader.enableTexture(["texture1","texture2"]),this._blendFb=new $n({depthBuffer:!1}),this._outputPass=new yi({fragment:kt.source("qtek.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.shader.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)}}function Ce(e,t,r){this.renderer=e,r=r||"perspective",this.scene=new fr,this.rootNode=this.scene,this.viewport={x:0,y:0,width:0,height:0},this.preZ=!1,this.setProjection(r),this._compositor=new Me,this._temporalSS=new Re,t&&(this._shadowMapPass=new Ai({lightFrustumBias:20}));for(var n=[],i=0,a=0;a<30;a++){for(var o=[],s=0;s<6;s++)o.push(4*ee(i,2)-2),o.push(4*ee(i,3)-2),i++;n.push(o)}this._pcfKernels=n,this._enableTemporalSS="auto",this.scene.on("beforerender",function(e,t,r){this.needsTemporalSS()&&this._temporalSS.jitterProjection(e,r)},this)}function Le(e){this.setScene(e)}function De(e){if(null==e||"object"!=typeof e)return e;var t=e,r=da.call(e);if("[object Array]"===r){t=[];for(var n=0,i=e.length;n=0&&i[h]>1e-6&&(pa.transformMat4(s,r,a[n[h]]),pa.scaleAndAdd(o,o,s,i[h]));pa.min(p,p,o),pa.max(m,m,o)}t.min.setArray(p),t.max.setArray(m)}function He(e,t){t=t||new pt;var r=new pt;return e.traverse(function(e){e.geometry&&(e.isSkinnedMesh()?(Ue(e,r),e.geometry.boundingBox.copy(r)):(r.copy(e.geometry.boundingBox),r.applyTransform(e.worldTransform)),t.union(r))}),t}function ze(e){var t=e[1][0]-e[0][0],r=e[1][1]-e[0][1];return Math.sqrt(t*t+r*r)}function Ge(e){return[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2]}function We(e){return Array.isArray(e)||(e=[e,e]),e}function qe(e,t){t=De(t),Pe(t,ca),this.init(e,t)}var Ve={extend:t,derive:t},je={trigger:function(e){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(e)){var t=this.__handlers__[e],r=t.length,n=-1,i=arguments;switch(i.length){case 1:for(;++n0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},o.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},o.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},o.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},o.random=function(e,t){t=t||1;var r=2*n()*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e},o.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},o.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},o.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},o.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},o.forEach=function(){var e=o.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},s.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},s.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},s.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},s.random=function(e,t){t=t||1;var r=2*n()*Math.PI,i=2*n()-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},s.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},s.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},s.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,f=l*a+o*i-s*n,d=-o*n-s*i-u*a;return e[0]=c*l+d*-o+h*-u-f*-s,e[1]=h*l+d*-s+f*-o-c*-u,e[2]=f*l+d*-u+c*-s-h*-o,e},s.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},s.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},s.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},s.forEach=function(){var e=s.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)},s.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},void 0!==e&&(e.vec3=s);var u={};u.create=function(){var e=new r(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},u.clone=function(e){var t=new r(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},u.fromValues=function(e,t,n,i){var a=new r(4);return a[0]=e,a[1]=t,a[2]=n,a[3]=i,a},u.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},u.set=function(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e},u.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},u.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},u.sub=u.subtract,u.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},u.mul=u.multiply,u.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},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[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),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[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e},u.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},u.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},u.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)},u.dist=u.distance,u.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},u.sqrDist=u.squaredDistance,u.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)},u.len=u.length,u.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},u.sqrLen=u.squaredLength,u.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},u.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},u.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},u.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},u.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},u.random=function(e,t){return t=t||1,e[0]=n(),e[1]=n(),e[2]=n(),e[3]=n(),u.normalize(e,e),u.scale(e,e,t),e},u.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},u.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,f=l*a+o*i-s*n,d=-o*n-s*i-u*a;return e[0]=c*l+d*-o+h*-u-f*-s,e[1]=h*l+d*-s+f*-o-c*-u,e[2]=f*l+d*-u+c*-s-h*-o,e},u.forEach=function(){var e=u.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):(s.cross(e,i,a),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+o,d.normalize(n,n))}}(),d.setAxes=function(){var e=h.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],d.normalize(t,d.fromMat3(t,e))}}(),d.clone=u.clone,d.fromValues=u.fromValues,d.copy=u.copy,d.set=u.set,d.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},d.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},d.add=u.add,d.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},d.mul=d.multiply,d.scale=u.scale,d.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},d.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},d.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},d.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},d.dot=u.dot,d.lerp=u.lerp,d.slerp=function(e,t,r,n){var i,a,o,s,u,l=t[0],c=t[1],h=t[2],f=t[3],d=r[0],_=r[1],p=r[2],m=r[3];return a=l*d+c*_+h*p+f*m,a<0&&(a=-a,d=-d,_=-_,p=-p,m=-m),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*d,e[1]=s*c+u*_,e[2]=s*h+u*p,e[3]=s*f+u*m,e},d.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},d.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},d.length=u.length,d.len=d.length,d.squaredLength=u.squaredLength,d.sqrLen=d.squaredLength,d.normalize=u.normalize,d.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},d.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},void 0!==e&&(e.quat=d)}(r.exports)}()})),at=it.vec3,ot=function(e,t,r){e=e||0,t=t||0,r=r||0,this._array=at.fromValues(e,t,r),this._dirty=!0};ot.prototype={constructor:ot,add:function(e){return at.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 ot(this.x,this.y,this.z)},copy:function(e){return at.copy(this._array,e._array),this._dirty=!0,this},cross:function(e,t){return at.cross(this._array,e._array,t._array),this._dirty=!0,this},dist:function(e){return at.dist(this._array,e._array)},distance:function(e){return at.distance(this._array,e._array)},div:function(e){return at.div(this._array,this._array,e._array),this._dirty=!0,this},divide:function(e){return at.divide(this._array,this._array,e._array),this._dirty=!0,this},dot:function(e){return at.dot(this._array,e._array)},len:function(){return at.len(this._array)},length:function(){return at.length(this._array)},lerp:function(e,t,r){return at.lerp(this._array,e._array,t._array,r),this._dirty=!0,this},min:function(e){return at.min(this._array,this._array,e._array),this._dirty=!0,this},max:function(e){return at.max(this._array,this._array,e._array),this._dirty=!0,this},mul:function(e){return at.mul(this._array,this._array,e._array),this._dirty=!0,this},multiply:function(e){return at.multiply(this._array,this._array,e._array),this._dirty=!0,this},negate:function(){return at.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return at.normalize(this._array,this._array),this._dirty=!0,this},random:function(e){return at.random(this._array,e),this._dirty=!0,this},scale:function(e){return at.scale(this._array,this._array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return at.scaleAndAdd(this._array,this._array,e._array,t),this._dirty=!0,this},sqrDist:function(e){return at.sqrDist(this._array,e._array)},squaredDistance:function(e){return at.squaredDistance(this._array,e._array)},sqrLen:function(){return at.sqrLen(this._array)},squaredLength:function(){return at.squaredLength(this._array)},sub:function(e){return at.sub(this._array,this._array,e._array),this._dirty=!0,this},subtract:function(e){return at.subtract(this._array,this._array,e._array),this._dirty=!0,this},transformMat3:function(e){return at.transformMat3(this._array,this._array,e._array),this._dirty=!0,this},transformMat4:function(e){return at.transformMat4(this._array,this._array,e._array),this._dirty=!0,this},transformQuat:function(e){return at.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){ot.eulerFromQuat(this,e,t)},eulerFromMat3:function(e,t){ot.eulerFromMat3(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}};var st=Object.defineProperty;if(st){var ut=ot.prototype;st(ut,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),st(ut,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),st(ut,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}})}ot.add=function(e,t,r){return at.add(e._array,t._array,r._array),e._dirty=!0,e},ot.set=function(e,t,r,n){at.set(e._array,t,r,n),e._dirty=!0},ot.copy=function(e,t){return at.copy(e._array,t._array),e._dirty=!0,e},ot.cross=function(e,t,r){return at.cross(e._array,t._array,r._array),e._dirty=!0,e},ot.dist=function(e,t){return at.distance(e._array,t._array)},ot.distance=ot.dist,ot.div=function(e,t,r){return at.divide(e._array,t._array,r._array),e._dirty=!0,e},ot.divide=ot.div,ot.dot=function(e,t){return at.dot(e._array,t._array)},ot.len=function(e){return at.length(e._array)},ot.lerp=function(e,t,r,n){return at.lerp(e._array,t._array,r._array,n),e._dirty=!0,e},ot.min=function(e,t,r){return at.min(e._array,t._array,r._array),e._dirty=!0,e},ot.max=function(e,t,r){return at.max(e._array,t._array,r._array),e._dirty=!0,e},ot.mul=function(e,t,r){return at.multiply(e._array,t._array,r._array),e._dirty=!0,e},ot.multiply=ot.mul,ot.negate=function(e,t){return at.negate(e._array,t._array),e._dirty=!0,e},ot.normalize=function(e,t){return at.normalize(e._array,t._array),e._dirty=!0,e},ot.random=function(e,t){return at.random(e._array,t),e._dirty=!0,e},ot.scale=function(e,t,r){return at.scale(e._array,t._array,r),e._dirty=!0,e},ot.scaleAndAdd=function(e,t,r,n){return at.scaleAndAdd(e._array,t._array,r._array,n),e._dirty=!0,e},ot.sqrDist=function(e,t){return at.sqrDist(e._array,t._array)},ot.squaredDistance=ot.sqrDist,ot.sqrLen=function(e){return at.sqrLen(e._array)},ot.squaredLength=ot.sqrLen,ot.sub=function(e,t,r){return at.subtract(e._array,t._array,r._array),e._dirty=!0,e},ot.subtract=ot.sub,ot.transformMat3=function(e,t,r){return at.transformMat3(e._array,t._array,r._array),e._dirty=!0,e},ot.transformMat4=function(e,t,r){return at.transformMat4(e._array,t._array,r._array),e._dirty=!0,e},ot.transformQuat=function(e,t,r){return at.transformQuat(e._array,t._array,r._array),e._dirty=!0,e};var lt=Math.atan2,ct=Math.asin,ht=Math.abs;ot.eulerFromQuat=function(e,t,r){e._dirty=!0,t=t._array;var n=e._array,i=t[0],a=t[1],s=t[2],u=t[3],l=i*i,c=a*a,h=s*s,f=u*u,r=(r||"XYZ").toUpperCase();switch(r){case"XYZ":n[0]=lt(2*(i*u-a*s),f-l-c+h),n[1]=ct(o(2*(i*s+a*u),-1,1)),n[2]=lt(2*(s*u-i*a),f+l-c-h);break;case"YXZ":n[0]=ct(o(2*(i*u-a*s),-1,1)),n[1]=lt(2*(i*s+a*u),f-l-c+h),n[2]=lt(2*(i*a+s*u),f-l+c-h);break;case"ZXY":n[0]=ct(o(2*(i*u+a*s),-1,1)),n[1]=lt(2*(a*u-s*i),f-l-c+h),n[2]=lt(2*(s*u-i*a),f-l+c-h);break;case"ZYX":n[0]=lt(2*(i*u+s*a),f-l-c+h),n[1]=ct(o(2*(a*u-i*s),-1,1)),n[2]=lt(2*(i*a+s*u),f+l-c-h);break;case"YZX":n[0]=lt(2*(i*u-s*a),f-l+c-h),n[1]=lt(2*(a*u-i*s),f+l-c-h),n[2]=ct(o(2*(i*a+s*u),-1,1));break;case"XZY":n[0]=lt(2*(i*u+a*s),f-l+c-h),n[1]=lt(2*(i*s+a*u),f+l-c-h),n[2]=ct(o(2*(s*u-i*a),-1,1));break;default:console.warn("Unkown order: "+r)}return e},ot.eulerFromMat3=function(e,t,r){var n=t._array,i=n[0],a=n[3],s=n[6],u=n[1],l=n[4],c=n[7],h=n[2],f=n[5],d=n[8],_=e._array,r=(r||"XYZ").toUpperCase();switch(r){case"XYZ":_[1]=ct(o(s,-1,1)),ht(s)<.99999?(_[0]=lt(-c,d),_[2]=lt(-a,i)):(_[0]=lt(f,l),_[2]=0);break;case"YXZ":_[0]=ct(-o(c,-1,1)),ht(c)<.99999?(_[1]=lt(s,d),_[2]=lt(u,l)):(_[1]=lt(-h,i),_[2]=0);break;case"ZXY":_[0]=ct(o(f,-1,1)),ht(f)<.99999?(_[1]=lt(-h,d),_[2]=lt(-a,l)):(_[1]=0,_[2]=lt(u,i));break;case"ZYX":_[1]=ct(-o(h,-1,1)),ht(h)<.99999?(_[0]=lt(f,d),_[2]=lt(u,i)):(_[0]=0,_[2]=lt(-a,l));break;case"YZX":_[2]=ct(o(u,-1,1)),ht(u)<.99999?(_[0]=lt(-c,l),_[1]=lt(-h,i)):(_[0]=0,_[1]=lt(s,d));break;case"XZY":_[2]=ct(-o(a,-1,1)),ht(a)<.99999?(_[0]=lt(f,l),_[1]=lt(s,i)):(_[0]=lt(-c,d),_[1]=0);break;default:console.warn("Unkown order: "+r)}return e._dirty=!0,e},ot.POSITIVE_X=new ot(1,0,0),ot.NEGATIVE_X=new ot(-1,0,0),ot.POSITIVE_Y=new ot(0,1,0),ot.NEGATIVE_Y=new ot(0,-1,0),ot.POSITIVE_Z=new ot(0,0,1),ot.NEGATIVE_Z=new ot(0,0,-1),ot.UP=new ot(0,1,0),ot.ZERO=new ot(0,0,0);var ft=it.vec3,dt=ft.copy,_t=ft.set,pt=function(e,t){this.min=e||new ot(1/0,1/0,1/0),this.max=t||new ot(-1/0,-1/0,-1/0)};pt.prototype={constructor:pt,updateFromVertices:function(e){if(e.length>0){var t=this.min,r=this.max,n=t._array,i=r._array;dt(n,e[0]),dt(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 ft.min(t._array,t._array,e.min._array),ft.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 ft.max(t._array,t._array,e.min._array),ft.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(){var e=ft.create(),t=ft.create(),r=ft.create(),n=ft.create(),i=ft.create(),a=ft.create();return function(o){var s=this.min._array,u=this.max._array,l=o._array;return e[0]=l[0]*s[0],e[1]=l[1]*s[0],e[2]=l[2]*s[0],t[0]=l[0]*u[0],t[1]=l[1]*u[0],t[2]=l[2]*u[0],r[0]=l[4]*s[1],r[1]=l[5]*s[1],r[2]=l[6]*s[1],n[0]=l[4]*u[1],n[1]=l[5]*u[1],n[2]=l[6]*u[1],i[0]=l[8]*s[2],i[1]=l[9]*s[2],i[2]=l[10]*s[2],a[0]=l[8]*u[2],a[1]=l[9]*u[2],a[2]=l[10]*u[2],s[0]=Math.min(e[0],t[0])+Math.min(r[0],n[0])+Math.min(i[0],a[0])+l[12],s[1]=Math.min(e[1],t[1])+Math.min(r[1],n[1])+Math.min(i[1],a[1])+l[13],s[2]=Math.min(e[2],t[2])+Math.min(r[2],n[2])+Math.min(i[2],a[2])+l[14],u[0]=Math.max(e[0],t[0])+Math.max(r[0],n[0])+Math.max(i[0],a[0])+l[12],u[1]=Math.max(e[1],t[1])+Math.max(r[1],n[1])+Math.max(i[1],a[1])+l[13],u[2]=Math.max(e[2],t[2])+Math.max(r[2],n[2])+Math.max(i[2],a[2])+l[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],f=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]*f+n[14];else{var d=-1/o;t[0]=n[0]*i*d,t[1]=n[5]*a*d,r[2]=(n[10]*o+n[14])*d,d=-1/l,r[0]=n[0]*s*d,r[1]=n[5]*u*d,d=-1/f,t[2]=(n[10]*f+n[14])*d}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){for(var e=[],t=0;t<8;t++)e[t]=ft.fromValues(0,0,0);this.vertices=e}var r=this.min._array,n=this.max._array;return _t(e[0],r[0],r[1],r[2]),_t(e[1],r[0],n[1],r[2]),_t(e[2],n[0],r[1],r[2]),_t(e[3],n[0],n[1],r[2]),_t(e[4],r[0],r[1],n[2]),_t(e[5],r[0],n[1],n[2]),_t(e[6],n[0],r[1],n[2]),_t(e[7],n[0],n[1],n[2]),this},copy:function(e){var t=this.min,r=this.max;return dt(t._array,e.min._array),dt(r._array,e.max._array),t._dirty=!0,r._dirty=!0,this},clone:function(){var e=new pt;return e.copy(this),e}};var mt=it.mat4,vt=it.vec3,gt=it.mat3,yt=it.quat,xt=function(){this._axisX=new ot,this._axisY=new ot,this._axisZ=new ot,this._array=mt.create(),this._dirty=!0};xt.prototype={constructor:xt,setArray:function(e){for(var t=0;t0&&n.push("#define "+i.toUpperCase()+"_COUNT "+a)}for(var o in r){r[o].enabled&&n.push("#define "+o.toUpperCase()+"_ENABLED")}for(var o in e){var s=e[o];null===s?n.push("#define "+o):n.push("#define "+o+" "+s.toString())}return n.join("\n")},_unrollLoop:function(e,t){function r(e,r,i,a){var o="";isNaN(r)&&(r=r in t?t[r]:n[r]),isNaN(i)&&(i=i in t?t[i]:n[i]);for(var s=parseInt(r);s=0)r.attribSemantics[u]={symbol:a,type:c},h=!1;else if(Ot.indexOf(u)>=0){var f=!1,d=u;u.match(/TRANSPOSE$/)&&(f=!0,d=u.slice(0,-9)),r.matrixSemantics[u]={symbol:a,type:c,isTranspose:f,semanticNoTranspose:d},h=!1}else if(It.indexOf(u)>=0)r.uniformSemantics[u]={symbol:a,type:c},h=!1;else if("unconfigurable"===u)h=!1;else{if(!(l=r._parseDefaultValue(i,u)))throw new Error('Unkown semantic "'+u+'"');u=""}h&&(t[a]={type:c,value:o?Dt.array:l||Dt[i],semantic:u||null})}return["uniform",i,a,o].join(" ")+";\n"}}var t={},r=this,n="vertex";this._uniformList=[],this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(wt,e),n="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(wt,e),r.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=t},_parseDefaultValue:function(e,t){var r=/\[\s*(.*)\s*\]/;{if("vec2"!==e&&"vec3"!==e&&"vec4"!==e)return"bool"===e?function(){return"true"===t.toLowerCase()}:"float"===e?function(){return parseFloat(t)}:"int"===e?function(){return parseInt(t)}:void 0;var n=r.exec(t)[1];if(n){var i=n.split(/\s*,\s*/);return function(){return new nt.Float32Array(i)}}}},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},attached:function(){this._attacheMaterialNumber++},detached:function(){this._attacheMaterialNumber--},isAttachedToAny:function(){return 0!==this._attacheMaterialNumber},_parseAttributes:function(){function e(e,n,i,a,o){if(n&&i){var s=1;switch(n){case"vec4":s=4;break;case"vec3":s=3;break;case"vec2":s=2;break;case"float":s=1}if(t[i]={type:"float",size:s,semantic:o||null},o){if(Pt.indexOf(o)<0)throw new Error('Unkown semantic "'+o+'"');r.attribSemantics[o]={symbol:i,type:n}}}return["attribute",n,i].join(" ")+";\n"}var t={},r=this;this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(Mt,e),this.attributeTemplates=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:parseFloat(i):null))),""}var t=this,r="vertex";this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(Rt,e),r="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(Rt,e)},_buildProgram:function(e,t,r){var n=this._cache;n.get("program")&&e.deleteProgram(n.get("program"));var i=e.createProgram(),a=e.createShader(e.VERTEX_SHADER);e.shaderSource(a,t),e.compileShader(a);var o=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(o,r),e.compileShader(o);var s=u(e,a,t);if(s)return s;if(s=u(e,o,r))return s;if(e.attachShader(i,a),e.attachShader(i,o),this.attribSemantics.POSITION)e.bindAttribLocation(i,0,this.attribSemantics.POSITION.symbol);else{var l=Object.keys(this.attributeTemplates);e.bindAttribLocation(i,0,l[0])}if(e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))return"Could not link program\nVALIDATE_STATUS: "+e.getProgramParameter(i,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]";for(var c=0;c>t;return e+1},dispose:function(e){var t=this._cache;t.use(e.__GUID__);var r=t.get("webgl_texture");r&&e.gl.deleteTexture(r),t.deleteContext(e.__GUID__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(Wt.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(Wt.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),Wt.BYTE=et.BYTE,Wt.UNSIGNED_BYTE=et.UNSIGNED_BYTE,Wt.SHORT=et.SHORT,Wt.UNSIGNED_SHORT=et.UNSIGNED_SHORT,Wt.INT=et.INT,Wt.UNSIGNED_INT=et.UNSIGNED_INT,Wt.FLOAT=et.FLOAT,Wt.HALF_FLOAT=36193,Wt.UNSIGNED_INT_24_8_WEBGL=34042,Wt.DEPTH_COMPONENT=et.DEPTH_COMPONENT,Wt.DEPTH_STENCIL=et.DEPTH_STENCIL,Wt.ALPHA=et.ALPHA,Wt.RGB=et.RGB,Wt.RGBA=et.RGBA,Wt.LUMINANCE=et.LUMINANCE,Wt.LUMINANCE_ALPHA=et.LUMINANCE_ALPHA,Wt.SRGB=35904,Wt.SRGB_ALPHA=35906,Wt.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,Wt.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,Wt.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,Wt.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,Wt.NEAREST=et.NEAREST,Wt.LINEAR=et.LINEAR,Wt.NEAREST_MIPMAP_NEAREST=et.NEAREST_MIPMAP_NEAREST,Wt.LINEAR_MIPMAP_NEAREST=et.LINEAR_MIPMAP_NEAREST,Wt.NEAREST_MIPMAP_LINEAR=et.NEAREST_MIPMAP_LINEAR,Wt.LINEAR_MIPMAP_LINEAR=et.LINEAR_MIPMAP_LINEAR,Wt.REPEAT=et.REPEAT,Wt.CLAMP_TO_EDGE=et.CLAMP_TO_EDGE,Wt.MIRRORED_REPEAT=et.MIRRORED_REPEAT;var qt=Qe.extend({name:"",depthTest:!0,depthMask:!0,transparent:!1,blend:null, +_enabledUniforms:null},function(){this.name||(this.name="MATERIAL_"+this.__GUID__),this.shader&&this.attachShader(this.shader),this.uniforms||(this.uniforms={})},{bind:function(e,t,r,n){for(var i=e.gl,t=t||this.shader,a=t.currentTextureSlot(),o=0;o=0},set:function(e,t){if("object"==typeof e)for(var r in e){var n=e[r];this.set(r,n)}else{var i=this.uniforms[e];i&&(void 0===t&&(console.warn('Uniform value "'+e+'" is undefined'),t=null),i.value=t)}},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){this.shader&&this.shader.detached();var r=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var n=this.uniforms;if(this._enabledUniforms=Object.keys(n),this._enabledUniforms.sort(),t)for(var i in r)n[i]&&(n[i].value=r[i].value);e.attached()},detachShader:function(){this.shader.detached(),this.shader=null,this.uniforms={}},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},dispose:function(e,t){if(t)for(var r in this.uniforms){var n=this.uniforms[r].value;if(n)if(n instanceof Wt)n.dispose(e);else if(Array.isArray(n))for(var i=0;i0&&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},beforeRenderObject:function(){},afterRenderObject:function(){},render:function(e,t,r,n){var i=this.gl;this._sceneRendering=e;var 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)}r||e.update(!1),t.getScene()||t.update(!0);for(var l=e.opaqueQueue,c=e.transparentQueue,h=e.material,f=0;f0)for(var _=$t(),p=Jt.create(),f=0;f0&&e.min._array[2]<0&&(e.max._array[2]=-1e-20),e.applyProjection(t);var u=e.min._array,l=e.max._array;if(l[0]<-1||u[0]>1||l[1]<-1||u[1]>1||l[2]<-1||u[2]>1)return!0}return!1}}(),disposeScene:function(e){this.disposeNode(e,!0,!0),e.dispose()},disposeNode:function(e,t,r){var n={};e.getParent()&&e.getParent().remove(e),e.traverse(function(e){e.geometry&&t&&e.geometry.dispose(this),e.material&&(n[e.material.__GUID__]=e.material),e.dispose&&e.dispose(this)},this);for(var i in n){n[i].dispose(this,r)}},disposeShader:function(e){e.dispose(this)},disposeGeometry:function(e){e.dispose(this)},disposeTexture:function(e){e.dispose(this)},disposeFrameBuffer:function(e){e.dispose(this)},dispose:function(){},screenToNDC:function(e,t,r){r||(r=new jt),t=this._height-t;var n=this.viewport,i=r._array;return i[0]=(e-n.x)/n.width,i[0]=2*i[0]-1,i[1]=(t-n.y)/n.height,i[1]=2*i[1]-1,r}});tr.opaqueSortFunc=tr.prototype.opaqueSortFunc=function(e,t){return e.renderOrder===t.renderOrder?e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__:e.renderOrder-t.renderOrder},tr.transparentSortFunc=tr.prototype.transparentSortFunc=function(e,t){return e.renderOrder===t.renderOrder?e.__depth===t.__depth?e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__:e.__depth-t.__depth:e.renderOrder-t.renderOrder};var rr={IDENTITY:$t(),WORLD:$t(),VIEW:$t(),PROJECTION:$t(),WORLDVIEW:$t(),VIEWPROJECTION:$t(),WORLDVIEWPROJECTION:$t(),WORLDINVERSE:$t(),VIEWINVERSE:$t(),PROJECTIONINVERSE:$t(),WORLDVIEWINVERSE:$t(),VIEWPROJECTIONINVERSE:$t(),WORLDVIEWPROJECTIONINVERSE:$t(),WORLDTRANSPOSE:$t(),VIEWTRANSPOSE:$t(),PROJECTIONTRANSPOSE:$t(),WORLDVIEWTRANSPOSE:$t(),VIEWPROJECTIONTRANSPOSE:$t(),WORLDVIEWPROJECTIONTRANSPOSE:$t(),WORLDINVERSETRANSPOSE:$t(),VIEWINVERSETRANSPOSE:$t(),PROJECTIONINVERSETRANSPOSE:$t(),WORLDVIEWINVERSETRANSPOSE:$t(),VIEWPROJECTIONINVERSETRANSPOSE:$t(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:$t()};tr.COLOR_BUFFER_BIT=et.COLOR_BUFFER_BIT,tr.DEPTH_BUFFER_BIT=et.DEPTH_BUFFER_BIT,tr.STENCIL_BUFFER_BIT=et.STENCIL_BUFFER_BIT;var nr={get:f},ir=it.quat,ar=function(e,t,r,n){e=e||0,t=t||0,r=r||0,n=void 0===n?1:n,this._array=ir.fromValues(e,t,r,n),this._dirty=!0};ar.prototype={constructor:ar,add:function(e){return ir.add(this._array,this._array,e._array),this._dirty=!0,this},calculateW:function(){return ir.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 ar(this.x,this.y,this.z,this.w)},conjugate:function(){return ir.conjugate(this._array,this._array),this._dirty=!0,this},copy:function(e){return ir.copy(this._array,e._array),this._dirty=!0,this},dot:function(e){return ir.dot(this._array,e._array)},fromMat3:function(e){return ir.fromMat3(this._array,e._array),this._dirty=!0,this},fromMat4:function(){var e=it.mat3,t=e.create();return function(r){return e.fromMat4(t,r._array),e.transpose(t,t),ir.fromMat3(this._array,t),this._dirty=!0,this}}(),identity:function(){return ir.identity(this._array),this._dirty=!0,this},invert:function(){return ir.invert(this._array,this._array),this._dirty=!0,this},len:function(){return ir.len(this._array)},length:function(){return ir.length(this._array)},lerp:function(e,t,r){return ir.lerp(this._array,e._array,t._array,r),this._dirty=!0,this},mul:function(e){return ir.mul(this._array,this._array,e._array),this._dirty=!0,this},mulLeft:function(e){return ir.multiply(this._array,e._array,this._array),this._dirty=!0,this},multiply:function(e){return ir.multiply(this._array,this._array,e._array),this._dirty=!0,this},multiplyLeft:function(e){return ir.multiply(this._array,e._array,this._array),this._dirty=!0,this},normalize:function(){return ir.normalize(this._array,this._array),this._dirty=!0,this},rotateX:function(e){return ir.rotateX(this._array,this._array,e),this._dirty=!0,this},rotateY:function(e){return ir.rotateY(this._array,this._array,e),this._dirty=!0,this},rotateZ:function(e){return ir.rotateZ(this._array,this._array,e),this._dirty=!0,this},rotationTo:function(e,t){return ir.rotationTo(this._array,e._array,t._array),this._dirty=!0,this},setAxes:function(e,t,r){return ir.setAxes(this._array,e._array,t._array,r._array),this._dirty=!0,this},setAxisAngle:function(e,t){return ir.setAxisAngle(this._array,e._array,t),this._dirty=!0,this},slerp:function(e,t,r){return ir.slerp(this._array,e._array,t._array,r),this._dirty=!0,this},sqrLen:function(){return ir.sqrLen(this._array)},squaredLength:function(){return ir.squaredLength(this._array)},fromEuler:function(e,t){return ar.fromEuler(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}};var or=Object.defineProperty;if(or){var sr=ar.prototype;or(sr,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),or(sr,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),or(sr,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}}),or(sr,"w",{get:function(){return this._array[3]},set:function(e){this._array[3]=e,this._dirty=!0}})}ar.add=function(e,t,r){return ir.add(e._array,t._array,r._array),e._dirty=!0,e},ar.set=function(e,t,r,n,i){ir.set(e._array,t,r,n,i),e._dirty=!0},ar.copy=function(e,t){return ir.copy(e._array,t._array),e._dirty=!0,e},ar.calculateW=function(e,t){return ir.calculateW(e._array,t._array),e._dirty=!0,e},ar.conjugate=function(e,t){return ir.conjugate(e._array,t._array),e._dirty=!0,e},ar.identity=function(e){return ir.identity(e._array),e._dirty=!0,e},ar.invert=function(e,t){return ir.invert(e._array,t._array),e._dirty=!0,e},ar.dot=function(e,t){return ir.dot(e._array,t._array)},ar.len=function(e){return ir.length(e._array)},ar.lerp=function(e,t,r,n){return ir.lerp(e._array,t._array,r._array,n),e._dirty=!0,e},ar.slerp=function(e,t,r,n){return ir.slerp(e._array,t._array,r._array,n),e._dirty=!0,e},ar.mul=function(e,t,r){return ir.multiply(e._array,t._array,r._array),e._dirty=!0,e},ar.multiply=ar.mul,ar.rotateX=function(e,t,r){return ir.rotateX(e._array,t._array,r),e._dirty=!0,e},ar.rotateY=function(e,t,r){return ir.rotateY(e._array,t._array,r),e._dirty=!0,e},ar.rotateZ=function(e,t,r){return ir.rotateZ(e._array,t._array,r),e._dirty=!0,e},ar.setAxisAngle=function(e,t,r){return ir.setAxisAngle(e._array,t._array,r),e._dirty=!0,e},ar.normalize=function(e,t){return ir.normalize(e._array,t._array),e._dirty=!0,e},ar.sqrLen=function(e){return ir.sqrLen(e._array)},ar.squaredLength=ar.sqrLen,ar.fromMat3=function(e,t){return ir.fromMat3(e._array,t._array),e._dirty=!0,e},ar.setAxes=function(e,t,r,n){return ir.setAxes(e._array,t._array,r._array,n._array),e._dirty=!0,e},ar.rotationTo=function(e,t,r){return ir.rotationTo(e._array,t._array,r._array),e._dirty=!0,e},ar.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}};var ur=it.mat4,lr=0,cr=Qe.extend({name:"",position:null,rotation:null,scale:null,worldTransform:null,localTransform:null,autoUpdateLocalTransform:!0,_parent:null,_scene:null,_needsUpdateWorldTransform:!0,_inIterating:!1,__depth:0},function(){this.name||(this.name=(this.type||"NODE")+"_"+lr++),this.position||(this.position=new ot),this.rotation||(this.rotation=new ar),this.scale||(this.scale=new ot(1,1,1)),this.worldTransform=new xt,this.localTransform=new xt,this._children=[]},{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(e){var t=this._scene;if(t){var r=t._nodeRepository;delete r[this.name],r[e]=this}this.name=e},add:function(e){this._inIterating&&console.warn("Add operation can cause unpredictable error when in iterating");var t=e._parent;if(t!==this){t&&t.remove(e),e._parent=this,this._children.push(e);var r=this._scene;r&&r!==e.scene&&e.traverse(this._addSelfToScene,this),e._needsUpdateWorldTransform=!0}},remove:function(e){this._inIterating&&console.warn("Remove operation can cause unpredictable error when in iterating");var t=this._children,r=t.indexOf(e);r<0||(t.splice(r,1),e._parent=null,this._scene&&e.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var e=this._children,t=0;t0&&this._updateRenderQueue(n)}},_updateLightUniforms:function(){var e=this.lights;e.sort(d);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;i 0.0) {\n vec3 normalTexel = texture2D(normalMap, uv).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n tbn[1] = -tbn[1];\n N = normalize(tbn * N);\n }\n }\n#endif\n vec3 diffuseTerm = vec3(0.0, 0.0, 0.0);\n vec3 specularTerm = vec3(0.0, 0.0, 0.0);\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, spec);\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_];\n }}\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N) * ambientSHLightColor[_idx_];\n }}\n#endif\n#ifdef POINT_LIGHT_COUNT\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsPoint[POINT_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfPointLights(v_WorldPosition, shadowContribsPoint);\n }\n#endif\n for(int _idx_ = 0; _idx_ < POINT_LIGHT_COUNT; _idx_++)\n {{\n vec3 lightPosition = pointLightPosition[_idx_];\n vec3 lc = pointLightColor[_idx_];\n float range = pointLightRange[_idx_];\n vec3 L = lightPosition - v_WorldPosition;\n float dist = length(L);\n float attenuation = lightAttenuation(dist, range);\n L /= dist;\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, L), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n float shadowContrib = 1.0;\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\n if(shadowEnabled)\n {\n shadowContrib = shadowContribsPoint[_idx_];\n }\n#endif\n vec3 li = lc * ndl * attenuation * shadowContrib;\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\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 _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -normalize(directionalLightDirection[_idx_]);\n vec3 lc = directionalLightColor[_idx_];\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, L), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if(shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n vec3 li = lc * ndl * shadowContrib;\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n#ifdef SPOT_LIGHT_COUNT\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsSpot[SPOT_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfSpotLights(v_WorldPosition, shadowContribsSpot);\n }\n#endif\n for(int i = 0; i < SPOT_LIGHT_COUNT; i++)\n {\n vec3 lightPosition = spotLightPosition[i];\n vec3 spotLightDirection = -normalize(spotLightDirection[i]);\n vec3 lc = spotLightColor[i];\n float range = spotLightRange[i];\n float a = spotLightUmbraAngleCosine[i];\n float b = spotLightPenumbraAngleCosine[i];\n float falloffFactor = spotLightFalloffFactor[i];\n vec3 L = lightPosition - v_WorldPosition;\n float dist = length(L);\n float attenuation = lightAttenuation(dist, range);\n L /= dist;\n float c = dot(spotLightDirection, L);\n float falloff;\n falloff = clamp((c - a) /( b - a), 0.0, 1.0);\n falloff = pow(falloff, falloffFactor);\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, L), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n float shadowContrib = 1.0;\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsSpot[i];\n }\n#endif\n vec3 li = lc * attenuation * (1.0 - falloff) * shadowContrib * ndl;\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }\n#endif\n vec4 outColor = albedoColor;\n outColor.rgb *= diffuseTerm;\n outColor.rgb += specularTerm;\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\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 = spec * 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), 51.5);\n outColor.rgb += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2;\n }}\n#endif\n#ifdef ENVIRONMENTMAP_ENABLED\n vec3 envWeight = g * fresnelTerm;\n vec3 L = reflect(-V, N);\n #ifdef PARALLAX_CORRECTED\n L = parallaxCorrect(L, v_WorldPosition, environmentBoxMin, environmentBoxMax);\n #endif\n #ifdef ENVIRONMENTMAP_PREFILTER\n float rough = clamp(1.0 - g, 0.0, 1.0);\n float bias = rough * maxMipmapLevel;\n vec3 envTexel = decodeHDR(textureCubeLodEXT(environmentMap, L, bias)).rgb;\n #ifdef BRDFLOOKUP_ENABLED\n vec2 brdfParam = texture2D(brdfLookup, vec2(rough, ndv)).xy;\n envWeight = spec * brdfParam.x + brdfParam.y;\n #endif\n #else\n vec3 envTexel = textureCube(environmentMap, L).xyz;\n #endif\n outColor.rgb += envTexel * envWeight;\n#endif\n float aoFactor = 1.0;\n#ifdef SSAOMAP_ENABLED\n aoFactor = min(texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r, aoFactor);\n#endif\n#ifdef AOMAP_ENABLED\n aoFactor = min(1.0 - clamp((1.0 - texture2D(aoMap, v_Texcoord2).r) * aoIntensity, 0.0, 1.0), aoFactor);\n#endif\n outColor.rgb *= aoFactor;\n vec3 lEmission = emission;\n#ifdef EMISSIVEMAP_ENABLED\n lEmission *= texture2D(emissiveMap, uv).rgb;\n#endif\n outColor.rgb += lEmission * emissionIntensity;\n#ifdef GAMMA_ENCODE\n outColor.rgb = pow(outColor.rgb, vec3(1 / 2.2));\n#endif\n if(lineWidth > 0.)\n {\n outColor.rgb = mix(outColor.rgb, lineColor.rgb, (1.0 - edgeFactor(lineWidth)) * lineColor.a);\n }\n#ifdef ALPHA_TEST\n if (outColor.a < alphaCutoff) {\n discard;\n }\n#endif\n gl_FragColor = encodeHDR(outColor);\n}\n@end\n";kt.import(dr);var _r={},pr={},mr=["diffuseMap","normalMap","roughnessMap","metalnessMap","emissiveMap","environmentMap","brdfLookup","ssaoMap","aoMap"],vr=["color","emission","emissionIntensity","alpha","roughness","metalness","uvRepeat","uvOffset","aoIntensity","alphaCutoff"],gr=["jointCount","linear","encodeRGBM","decodeRGBM","doubleSided","alphaTest","roughnessChannel","metalnessChannel"],yr=["environmentMapPrefiltered","linear","encodeRGBM","decodeRGBM","doubleSided","alphaTest","parallaxCorrected"],xr=mr.concat(yr),Tr=xr.reduce(function(e,t,r){return e[t]=4096<0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=cr.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},render:function(e,t){var r=e.gl,t=t||this.material.shader,n=this.geometry,i=this.mode,a=n.vertexCount,o=n.isUseIndices(),s=e.getGLExtension("OES_element_index_uint"),u=s&&a>65535,l=u?r.UNSIGNED_INT:r.UNSIGNED_SHORT,c=e.getGLExtension("OES_vertex_array_object"),h=!n.dynamic,f=this._renderInfo;f.vertexCount=a,f.triangleCount=0,f.drawCallCount=0;var d=!1;if(br=e.__GUID__+"-"+n.__GUID__+"-"+t.__GUID__,br!==Sr?d=!0:(a>65535&&!s&&o||c&&h||n._cache.isDirty())&&(d=!0),Sr=br,d){var _=this._drawCache[br];if(!_){var p=n.getBufferChunks(e);if(!p)return;_=[];for(var m=0;m>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},Rr.nearestPowerOfTwo=function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))};var Cr=Rr.isPowerOfTwo,Lr=Wt.extend(function(){return{image:null,pixels:null,mipmaps:[]}},{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;t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var i=e.getGLExtension("EXT_texture_filter_anisotropic");if(i&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_2D,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===n){e.getGLExtension("OES_texture_half_float")||(n=et.FLOAT)}if(this.mipmaps.length)for(var a=this.width,o=this.height,s=0;s=Wt.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,r,a,n,i,0,t.pixels):e.texImage2D(e.TEXTURE_2D,r,a,n,i,0,a,o,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(){var e,t;return this.image?(e=this.image.width,t=this.image.height):(e=this.width,t=this.height),Cr(e)&&Cr(t)},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(Lr.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(Lr.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)}});var Dr=Mr.extend({skeleton:null,joints:null,useSkinMatricesTexture:!1},function(){this.joints||(this.joints=[])},{isSkinnedMesh:function(){return!(!this.skeleton||!this.material.shader.isDefined("vertex","SKINNING"))},render:function(e,t){var r=e.gl;if(t=t||this.material.shader,this.skeleton){this.skeleton.update();var n=this.skeleton.getSubSkinMatrices(this.__GUID__,this.joints);if(this.useSkinMatricesTexture){var i,a=this.joints.length;i=a>256?64:a>64?32:a>16?16:8;var o=this.getSkinMatricesTexture();o.width=i,o.height=i,o.pixels&&o.pixels.length===i*i*4||(o.pixels=new Float32Array(i*i*4)),o.pixels.set(n),o.dirty(),t.setUniform(r,"1f","skinMatricesTextureSize",i)}else t.setUniformOfSemantic(r,"SKIN_MATRIX",n)}return Mr.prototype.render.call(this,e,t)},getSkinMatricesTexture:function(){return this._skinMatricesTexture=this._skinMatricesTexture||new Lr({type:et.FLOAT,minFilter:et.NEAREST,magFilter:et.NEAREST,useMipmap:!1,flipY:!1}),this._skinMatricesTexture}});Dr.POINTS=et.POINTS,Dr.LINES=et.LINES,Dr.LINE_LOOP=et.LINE_LOOP,Dr.LINE_STRIP=et.LINE_STRIP,Dr.TRIANGLES=et.TRIANGLES,Dr.TRIANGLE_STRIP=et.TRIANGLE_STRIP,Dr.TRIANGLE_FAN=et.TRIANGLE_FAN,Dr.BACK=et.BACK,Dr.FRONT=et.FRONT,Dr.FRONT_AND_BACK=et.FRONT_AND_BACK,Dr.CW=et.CW,Dr.CCW=et.CCW;var Pr=Qe.extend({name:"",index:-1,node:null,rootNode:null}),Ir=it.quat,Or=it.vec3,Fr=it.mat4,kr=Qe.extend(function(){return{relativeRootNode:null,name:"",joints:[],_clips:[],_invBindPoseMatricesArray:null,_jointMatricesSubArrays:[],_skinMatricesArray:null,_skinMatricesSubArrays:[],_subSkinMatricesArray:{}}},{addClip:function(e,t){for(var r=0;r0&&this._clips.splice(t,1)},removeClipsAll:function(){this._clips=[]},getClip:function(e){if(this._clips[e])return this._clips[e].clip},getClipNumber:function(){return this._clips.length},updateJointMatrices:function(){var e=Fr.create();return function(){this._invBindPoseMatricesArray=new Float32Array(16*this.joints.length),this._skinMatricesArray=new Float32Array(16*this.joints.length);for(var t=0;tthis.distance,i=1;i<8;i++)if(Br.dot(t[i]._array,r)>this.distance!=n)return!0},intersectLine:function(){var e=Br.create();return function(t,r,n){var i=this.distanceToPoint(t),a=this.distanceToPoint(r);if(i>0&&a>0||i<0&&a<0)return null;var o=this.normal._array,s=this.distance,u=t._array;Br.sub(e,r._array,t._array),Br.normalize(e,e);var l=Br.dot(o,e);if(0===l)return null;n||(n=new ot);var c=(Br.dot(o,u)-s)/l;return Br.scaleAndAdd(n._array,u,e,-c),n._dirty=!0,n}}(),applyTransform:function(){var e=Ur.create(),t=Hr.create(),r=Hr.create();return r[3]=1,function(n){n=n._array,Br.scale(r,this.normal._array,this.distance),Hr.transformMat4(r,r,n),this.distance=Br.dot(r,this.normal._array),Ur.invert(e,n),Ur.transpose(e,e),t[3]=0,Br.copy(t,this.normal._array),Hr.transformMat4(t,t,e),Br.copy(this.normal._array,t)}}(),copy:function(e){Br.copy(this.normal._array,e.normal._array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new zr;return e.copy(this),e}};var Gr=it.vec3,Wr=Gr.set,qr=Gr.copy,Vr=Gr.transformMat4,jr=Math.min,Xr=Math.max,Kr=function(){this.planes=[];for(var e=0;e<6;e++)this.planes.push(new zr);this.boundingBox=new pt,this.vertices=[];for(var e=0;e<8;e++)this.vertices[e]=Gr.fromValues(0,0,0)};Kr.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],u=r[5],l=r[6],c=r[7],h=r[8],f=r[9],d=r[10],_=r[11],p=r[12],m=r[13],v=r[14],g=r[15];Wr(t[0].normal._array,o-n,c-s,_-h),t[0].distance=-(g-p),t[0].normalize(),Wr(t[1].normal._array,o+n,c+s,_+h),t[1].distance=-(g+p),t[1].normalize(),Wr(t[2].normal._array,o+i,c+u,_+f),t[2].distance=-(g+m),t[2].normalize(),Wr(t[3].normal._array,o-i,c-u,_-f),t[3].distance=-(g-m),t[3].normalize(),Wr(t[4].normal._array,o-a,c-l,_-d),t[4].distance=-(g-v),t[4].normalize(),Wr(t[5].normal._array,o+a,c+l,_+d),t[5].distance=-(g+v),t[5].normalize();var y=this.boundingBox;if(0===g){var x=u/n,T=-v/(d-1),E=-v/(d+1),b=-E/u,S=-T/u;y.min.set(-b*x,-b,E),y.max.set(b*x,b,T);var A=this.vertices;Wr(A[0],-b*x,-b,E),Wr(A[1],-b*x,b,E),Wr(A[2],b*x,-b,E),Wr(A[3],b*x,b,E),Wr(A[4],-S*x,-S,T),Wr(A[5],-S*x,S,T),Wr(A[6],S*x,-S,T),Wr(A[7],S*x,S,T)}else{var N=(-1-p)/n,w=(1-p)/n,M=(1-m)/u,R=(-1-m)/u,C=(-1-v)/d,L=(1-v)/d;y.min.set(Math.min(N,w),Math.min(R,M),Math.min(L,C)),y.max.set(Math.max(w,N),Math.max(M,R),Math.max(C,L));var D=y.min._array,P=y.max._array,A=this.vertices;Wr(A[0],D[0],D[1],D[2]),Wr(A[1],D[0],P[1],D[2]),Wr(A[2],P[0],D[1],D[2]),Wr(A[3],P[0],P[1],D[2]),Wr(A[4],D[0],D[1],P[2]),Wr(A[5],D[0],P[1],P[2]),Wr(A[6],P[0],D[1],P[2]),Wr(A[7],P[0],P[1],P[2])}},getTransformedBoundingBox:function(){var e=Gr.create();return function(t,r){var n=this.vertices,i=r._array,a=t.min,o=t.max,s=a._array,u=o._array,l=n[0];Vr(e,l,i),qr(s,e),qr(u,e);for(var c=1;c<8;c++)l=n[c],Vr(e,l,i),s[0]=jr(e[0],s[0]),s[1]=jr(e[1],s[1]),s[2]=jr(e[2],s[2]),u[0]=Xr(e[0],u[0]),u[1]=Xr(e[1],u[1]),u[2]=Xr(e[2],u[2]);return a._dirty=!0,o._dirty=!0,t}}()};var Yr=it.vec3,Zr=function(e,t){this.origin=e||new ot,this.direction=t||new ot};Zr.prototype={constructor:Zr,intersectPlane:function(e,t){var r=e.normal._array,n=e.distance,i=this.origin._array,a=this.direction._array,o=Yr.dot(r,a);if(0===o)return null;t||(t=new ot);var s=(Yr.dot(r,i)-n)/o;return Yr.scaleAndAdd(t._array,i,a,-s),t._dirty=!0,t},mirrorAgainstPlane:function(e){var t=Yr.dot(e.normal._array,this.direction._array);Yr.scaleAndAdd(this.direction._array,this.direction._array,e.normal._array,2*-t),this.direction._dirty=!0},distanceToPoint:function(){var e=Yr.create();return function(t){Yr.sub(e,t,this.origin._array);var r=Yr.dot(e,this.direction._array);if(r<0)return Yr.distance(this.origin._array,t);var n=Yr.lenSquared(e);return Math.sqrt(n-r*r)}}(),intersectSphere:function(){var e=Yr.create();return function(t,r,n){var i=this.origin._array,a=this.direction._array;t=t._array,Yr.sub(e,t,i);var o=Yr.dot(e,a),s=Yr.squaredLength(e),u=s-o*o,l=r*r;if(!(u>l)){var c=Math.sqrt(l-u),h=o-c,f=o+c;return n||(n=new ot),h<0?f<0?null:(Yr.scaleAndAdd(n._array,i,a,f),n):(Yr.scaleAndAdd(n._array,i,a,h),n)}}}(),intersectBoundingBox:function(e,t){var r,n,i,a,o,s,u=this.direction._array,l=this.origin._array,c=e.min._array,h=e.max._array,f=1/u[0],d=1/u[1],_=1/u[2];if(f>=0?(r=(c[0]-l[0])*f,n=(h[0]-l[0])*f):(n=(c[0]-l[0])*f,r=(h[0]-l[0])*f),d>=0?(i=(c[1]-l[1])*d,a=(h[1]-l[1])*d):(a=(c[1]-l[1])*d,i=(h[1]-l[1])*d),r>a||i>n)return null;if((i>r||r!==r)&&(r=i),(a=0?(o=(c[2]-l[2])*_,s=(h[2]-l[2])*_):(s=(c[2]-l[2])*_,o=(h[2]-l[2])*_),r>s||o>n)return null;if((o>r||r!==r)&&(r=o),(s=0?r:n;return t||(t=new ot),Yr.scaleAndAdd(t._array,l,u,p),t},intersectTriangle:function(){var e=Yr.create(),t=Yr.create(),r=Yr.create(),n=Yr.create();return function(i,a,o,s,u,l){var c=this.direction._array,h=this.origin._array;i=i._array,a=a._array,o=o._array,Yr.sub(e,a,i),Yr.sub(t,o,i),Yr.cross(n,t,c);var f=Yr.dot(e,n);if(s){if(f>-1e-5)return null}else if(f>-1e-5&&f<1e-5)return null;Yr.sub(r,h,i);var d=Yr.dot(n,r)/f;if(d<0||d>1)return null;Yr.cross(n,e,r);var _=Yr.dot(c,n)/f;if(_<0||_>1||d+_>1)return null;Yr.cross(n,e,t);var p=-Yr.dot(r,n)/f;return p<0?null:(u||(u=new ot),l&&ot.set(l,1-d-_,d,_),Yr.scaleAndAdd(u._array,h,c,p),u)}}(),applyTransform:function(e){ot.add(this.direction,this.direction,this.origin),ot.transformMat4(this.origin,this.origin,e),ot.transformMat4(this.direction,this.direction,e),ot.sub(this.direction,this.direction,this.origin),ot.normalize(this.direction,this.direction)},copy:function(e){ot.copy(this.origin,e.origin),ot.copy(this.direction,e.direction)},clone:function(){var e=new Zr;return e.copy(this),e}};var Qr=it.vec3,Jr=it.vec4,$r=cr.extend(function(){return{projectionMatrix:new xt,invProjectionMatrix:new xt,viewMatrix:new xt,frustum:new Kr}},function(){this.update(!0)},{update:function(e){cr.prototype.update.call(this,e),xt.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),xt.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(e){xt.copy(this.viewMatrix,e),xt.invert(this.worldTransform,e),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(e){xt.copy(this.projectionMatrix,e),xt.invert(this.invProjectionMatrix,e),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:function(){var e=Jr.create();return function(t,r){var n=void 0!==r?r:new Zr,i=t._array[0],a=t._array[1];return Jr.set(e,i,a,-1,1),Jr.transformMat4(e,e,this.invProjectionMatrix._array),Jr.transformMat4(e,e,this.worldTransform._array),Qr.scale(n.origin._array,e,1/e[3]),Jr.set(e,i,a,1,1),Jr.transformMat4(e,e,this.invProjectionMatrix._array),Jr.transformMat4(e,e,this.worldTransform._array),Qr.scale(e,e,1/e[3]),Qr.sub(n.direction._array,e,n.origin._array),Qr.normalize(n.direction._array,n.direction._array),n.direction._dirty=!0,n.origin._dirty=!0,n}}()}),en=$r.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=$r.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}}),tn=$r.extend({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix._array;this.left=(-1-e[12])/e[0],this.right=(1-e[12])/e[0],this.top=(1-e[13])/e[5],this.bottom=(-1-e[13])/e[5],this.near=-(-1-e[14])/e[10],this.far=-(1-e[14])/e[10]},clone:function(){var e=$r.prototype.clone.call(this);return e.left=this.left,e.right=this.right,e.near=this.near,e.far=this.far,e.top=this.top,e.bottom=this.bottom,e}}),rn={linear:function(e){return e},quadraticIn:function(e){return e*e},quadraticOut:function(e){return e*(2-e)},quadraticInOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},cubicIn:function(e){return e*e*e},cubicOut:function(e){return--e*e*e+1},cubicInOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},quarticIn:function(e){return e*e*e*e},quarticOut:function(e){return 1- --e*e*e*e},quarticInOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)},quinticIn:function(e){return e*e*e*e*e},quinticOut:function(e){return--e*e*e*e*e+1},quinticInOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)},sinusoidalIn:function(e){return 1-Math.cos(e*Math.PI/2)},sinusoidalOut:function(e){return Math.sin(e*Math.PI/2)},sinusoidalInOut:function(e){return.5*(1-Math.cos(Math.PI*e))},exponentialIn:function(e){return 0===e?0:Math.pow(1024,e-1)},exponentialOut:function(e){return 1===e?1:1-Math.pow(2,-10*e)},exponentialInOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(2-Math.pow(2,-10*(e-1)))},circularIn:function(e){return 1-Math.sqrt(1-e*e)},circularOut:function(e){return Math.sqrt(1- --e*e)},circularInOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)},elasticIn:function(e){var t,r=.1;return 0===e?0:1===e?1:(!r||r<1?(r=1,t=.1):t=.4*Math.asin(1/r)/(2*Math.PI),-r*Math.pow(2,10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/.4))},elasticOut:function(e){var t,r=.1;return 0===e?0:1===e?1:(!r||r<1?(r=1,t=.1):t=.4*Math.asin(1/r)/(2*Math.PI),r*Math.pow(2,-10*e)*Math.sin((e-t)*(2*Math.PI)/.4)+1)},elasticInOut:function(e){var t,r=.1;return 0===e?0:1===e?1:(!r||r<1?(r=1,t=.1):t=.4*Math.asin(1/r)/(2*Math.PI),(e*=2)<1?r*Math.pow(2,10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/.4)*-.5:r*Math.pow(2,-10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/.4)*.5+1)},backIn:function(e){var t=1.70158;return e*e*((t+1)*e-t)},backOut:function(e){var t=1.70158;return--e*e*((t+1)*e+t)+1},backInOut:function(e){var t=2.5949095;return(e*=2)<1?e*e*((t+1)*e-t)*.5:.5*((e-=2)*e*((t+1)*e+t)+2)},bounceIn:function(e){return 1-rn.bounceOut(1-e)},bounceOut:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},bounceInOut:function(e){return e<.5?.5*rn.bounceIn(2*e):.5*rn.bounceOut(2*e-1)+.5}},nn=function(e){e=e||{},this.name=e.name||"",this.target=e.target,this.life=e.life||1e3,this.delay=e.delay||0,this.gap=e.gap||0,this.playbackRate=e.playbackRate||1,this._initialized=!1,this._elapsedTime=0,this._loop=null!=e.loop&&e.loop,this.setLoop(this._loop),null!=e.easing&&this.setEasing(e.easing),this.onframe=e.onframe||g,this.onfinish=e.onfinish||g,this.onrestart=e.onrestart||g,this._paused=!1};nn.prototype={gap:0,life:0,delay:0,setLoop:function(e){this._loop=e,e&&(this._loopRemained="number"==typeof e?e:1e8)},setEasing:function(e){"string"==typeof e&&(e=rn[e]),this.easing=e},step:function(e,t,r){if(this._initialized||(this._startTime=e+this.delay,this._initialized=!0),null!=this._currentTime&&(t=e-this._currentTime),this._currentTime=e,this._paused)return"paused";if(!(e0?(this._restartInLoop(e),this._loopRemained--,"restart"):(this._needsRemove=!0,"finish"):null}}},setTime:function(e){return this.step(e+this._startTime)},restart:function(e){var t=0;e&&(this._elapse(e),t=this._elapsedTime%this.life),e=e||Date.now(),this._startTime=e-t+this.delay,this._elapsedTime=0,this._needsRemove=!1,this._paused=!1},getElapsedTime:function(){return this._elapsedTime},_restartInLoop:function(e){this._startTime=e+this.gap,this._elapsedTime=0},_elapse:function(e,t){this._elapsedTime+=t*this.playbackRate},fire:function(e,t){var r="on"+e;this[r]&&this[r](this.target,t)},clone:function(){var e=new this.constructor;return e.name=this.name,e._loop=this._loop,e._loopRemained=this._loopRemained,e.life=this.life,e.gap=this.gap,e.delay=this.delay,e},pause:function(){this._paused=!0},resume:function(){this._paused=!1}},nn.prototype.constructor=nn;var an=it.quat,on=it.vec3,sn=function(e){e=e||{},nn.call(this,e),this.tracks=e.tracks||[]};sn.prototype=Object.create(nn.prototype),sn.prototype.constructor=sn,sn.prototype.step=function(e,t,r){var n=nn.prototype.step.call(this,e,t,!0);if("finish"!==n){var e=this.getElapsedTime();this._range&&(e=this._range[0]+e),this.setTime(e)}return r||"paused"===n||this.fire("frame"),n},sn.prototype.setRange=function(e){this.calcLifeFromTracks(),this._range=e,e&&(e[1]=Math.min(e[1],this.life),e[0]=Math.min(e[0],this.life),this.life=e[1]-e[0])},sn.prototype.setTime=function(e){for(var t=0;t=0&&this.tracks.splice(t,1)},sn.prototype.getSubClip=function(e,t,r){for(var n=new sn({name:this.name}),i=0;i=e.time)return this.keyFrames.splice(t,0,e),t}this.life=e.time,this.keyFrames.push(e)},cn.prototype.addKeyFrames=function(e){for(var t=0;ti[i.length-1].time)){if(e=a-1?a-1:this._cacheKey+1,s=o;s>=0;s--)if(i[s].time<=e&&i[s][t])r=i[s],this._cacheKey=s,this._cacheTime=e;else if(i[s][t]){n=i[s];break}}else for(var s=this._cacheKey;s=t.time[r-1])e=t.time[r-1],n=r-2;else if(e=0;a--)if(t.time[a-1]<=e&&t.time[a]>e){n=a-1;break}}else for(var a=this._cacheKey;ae){n=a;break}if(n>-1){this._cacheKey=n,this._cacheTime=e;var o=n,s=n+1,u=t.time[o],l=t.time[s],c=l-u,h=0===c?0:(e-u)/c;t.rotation&&T(this.rotation,t.rotation,t.rotation,h,4*o,4*s),t.position&&x(this.position,t.position,t.position,h,3*o,3*s),t.scale&&x(this.scale,t.scale,t.scale,h,3*o,3*s)}n==r-2&&(this._cacheKey=0,this._cacheTime=0),this.updateTarget()}},dn.prototype.updateTarget=function(){var e=this.channels;this.target&&(e.position&&this.target.position.setArray(this.position),e.rotation&&this.target.rotation.setArray(this.rotation),e.scale&&this.target.scale.setArray(this.scale))},dn.prototype.getMaxTime=function(){return this.channels.time[this.channels.time.length-1]},dn.prototype.getSubTrack=function(e,t){var r=new dn({name:this.name}),n=this.channels.time[0];e=Math.min(Math.max(e,n),this.life),t=Math.min(Math.max(t,n),this.life);var i=this._findRange(e),a=this._findRange(t),o=a[0]-i[0]+1;0===i[1]&&0===a[1]&&(o-=1),this.channels.rotation&&(r.channels.rotation=new Float32Array(4*o)),this.channels.position&&(r.channels.position=new Float32Array(3*o)),this.channels.scale&&(r.channels.scale=new Float32Array(3*o)),this.channels.time&&(r.channels.time=new Float32Array(o)),this.setTime(e);for(var s=0;s<3;s++)r.channels.rotation[s]=this.rotation[s],r.channels.position[s]=this.position[s],r.channels.scale[s]=this.scale[s];r.channels.time[0]=0,r.channels.rotation[3]=this.rotation[3];for(var s=1;se&&(n=i);var a=0;if(n>=0)var o=t.time[n],s=t.time[n+1],a=(e-o)/(s-o);return[n,a]},dn.prototype.blend1D=cn.prototype.blend1D,dn.prototype.blend2D=cn.prototype.blend2D,dn.prototype.additiveBlend=cn.prototype.additiveBlend,dn.prototype.subtractiveBlend=cn.prototype.subtractiveBlend,dn.prototype.clone=function(){var e=dn.prototype.clone.call(this);return e.channels={time:this.channels.time||null,position:this.channels.position||null,rotation:this.channels.rotation||null,scale:this.channels.scale||null},fn.copy(e.position,this.position),hn.copy(e.rotation,this.rotation),fn.copy(e.scale,this.scale),e.target=this.target,e.updateTarget(),e};var _n=it.vec3,pn=it.mat4,mn=_n.create,vn=_n.add,gn=_n.set;S.prototype.init=function(e){if(!this.value||this.value.length!=e*this.size){var t=E(this.type);this.value=new t(e*this.size)}},S.prototype.fromArray=function(e){var t,r=E(this.type);if(e[0]&&e[0].length){var n=0,i=this.size;t=new r(e.length*i);for(var a=0;aa[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=mn());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?nt.Uint32Array:nt.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.attribute[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 nt.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,r=this.getEnabledAttributes(),n={},i=0;i 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 qtek.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 qtek.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"),kt.import(xn),kt.import("\n@export qtek.lambert.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\nattribute vec3 barycentric;\n@import qtek.chunk.skinning_header\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\nvarying vec3 v_Barycentric;\nvoid main()\n{\n vec3 skinnedPosition = position;\n vec3 skinnedNormal = normal;\n#ifdef SKINNING\n @import qtek.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n skinnedNormal = (skinMatrixWS * vec4(normal, 0.0)).xyz;\n#endif\n gl_Position = worldViewProjection * vec4( skinnedPosition, 1.0 );\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_Normal = normalize( ( worldInverseTranspose * vec4(skinnedNormal, 0.0) ).xyz );\n v_WorldPosition = ( world * vec4( skinnedPosition, 1.0) ).xyz;\n v_Barycentric = barycentric;\n}\n@end\n@export qtek.lambert.fragment\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\nuniform sampler2D diffuseMap;\nuniform sampler2D alphaMap;\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform vec3 emission : [0.0, 0.0, 0.0];\nuniform float alpha : 1.0;\n#ifdef ALPHA_TEST\nuniform float alphaCutoff: 0.9;\n#endif\nuniform float lineWidth : 0.0;\nuniform vec4 lineColor : [0.0, 0.0, 0.0, 0.6];\nvarying vec3 v_Barycentric;\n#ifdef AMBIENT_LIGHT_COUNT\n@import qtek.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import qtek.header.ambient_sh_light\n#endif\n#ifdef POINT_LIGHT_COUNT\n@import qtek.header.point_light\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import qtek.header.directional_light\n#endif\n#ifdef SPOT_LIGHT_COUNT\n@import qtek.header.spot_light\n#endif\n@import qtek.util.calculate_attenuation\n@import qtek.util.edge_factor\n@import qtek.util.rgbm\n@import qtek.plugin.compute_shadow_map\nvoid main()\n{\n#ifdef RENDER_NORMAL\n gl_FragColor = vec4(v_Normal * 0.5 + 0.5, 1.0);\n return;\n#endif\n#ifdef RENDER_TEXCOORD\n gl_FragColor = vec4(v_Texcoord, 1.0, 1.0);\n return;\n#endif\n gl_FragColor = vec4(color, alpha);\n#ifdef DIFFUSEMAP_ENABLED\n vec4 tex = texture2D( diffuseMap, v_Texcoord );\n#ifdef SRGB_DECODE\n tex.rgb = pow(tex.rgb, vec3(2.2));\n#endif\n gl_FragColor.rgb *= tex.rgb;\n#ifdef DIFFUSEMAP_ALPHA_ALPHA\n gl_FragColor.a *= tex.a;\n#endif\n#endif\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {\n diffuseColor += ambientLightColor[_idx_];\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_, v_Normal) * ambientSHLightColor[_idx_];\n }}\n#endif\n#ifdef POINT_LIGHT_COUNT\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsPoint[POINT_LIGHT_COUNT];\n if( shadowEnabled )\n {\n computeShadowOfPointLights(v_WorldPosition, shadowContribsPoint);\n }\n#endif\n for(int i = 0; i < POINT_LIGHT_COUNT; i++)\n {\n vec3 lightPosition = pointLightPosition[i];\n vec3 lightColor = pointLightColor[i];\n float range = pointLightRange[i];\n vec3 lightDirection = lightPosition - v_WorldPosition;\n float dist = length(lightDirection);\n float attenuation = lightAttenuation(dist, range);\n lightDirection /= dist;\n float ndl = dot( v_Normal, lightDirection );\n float shadowContrib = 1.0;\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\n if( shadowEnabled )\n {\n shadowContrib = shadowContribsPoint[i];\n }\n#endif\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0) * attenuation * shadowContrib;\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 float ndl = dot(v_Normal, normalize(lightDirection));\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if( shadowEnabled )\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0) * shadowContrib;\n }\n#endif\n#ifdef SPOT_LIGHT_COUNT\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsSpot[SPOT_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfSpotLights(v_WorldPosition, shadowContribsSpot);\n }\n#endif\n for(int i = 0; i < SPOT_LIGHT_COUNT; i++)\n {\n vec3 lightPosition = -spotLightPosition[i];\n vec3 spotLightDirection = -normalize( spotLightDirection[i] );\n vec3 lightColor = spotLightColor[i];\n float range = spotLightRange[i];\n float a = spotLightUmbraAngleCosine[i];\n float b = spotLightPenumbraAngleCosine[i];\n float falloffFactor = spotLightFalloffFactor[i];\n vec3 lightDirection = lightPosition - v_WorldPosition;\n float dist = length(lightDirection);\n float attenuation = lightAttenuation(dist, range);\n lightDirection /= dist;\n float c = dot(spotLightDirection, lightDirection);\n float falloff;\n falloff = clamp((c - a) /( b - a), 0.0, 1.0);\n falloff = pow(falloff, falloffFactor);\n float ndl = dot(v_Normal, lightDirection);\n ndl = clamp(ndl, 0.0, 1.0);\n float shadowContrib = 1.0;\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\n if( shadowEnabled )\n {\n shadowContrib = shadowContribsSpot[i];\n }\n#endif\n diffuseColor += lightColor * ndl * attenuation * (1.0-falloff) * shadowContrib;\n }\n#endif\n gl_FragColor.rgb *= diffuseColor;\n gl_FragColor.rgb += emission;\n if(lineWidth > 0.)\n {\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor(lineWidth)) * lineColor.a);\n }\n#ifdef ALPHA_TEST\n if (gl_FragColor.a < alphaCutoff) {\n discard;\n }\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n}\n@end"),kt.import(dr),kt.import("@export qtek.wireframe.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\nattribute vec3 barycentric;\n@import qtek.chunk.skinning_header\nvarying vec3 v_Barycentric;\nvoid main()\n{\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import qtek.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0 );\n v_Barycentric = barycentric;\n}\n@end\n@export qtek.wireframe.fragment\nuniform vec3 color : [0.0, 0.0, 0.0];\nuniform float alpha : 1.0;\nuniform float lineWidth : 1.0;\nvarying vec3 v_Barycentric;\n@import qtek.util.edge_factor\nvoid main()\n{\n gl_FragColor.rgb = color;\n gl_FragColor.a = (1.0-edgeFactor(lineWidth)) * alpha;\n}\n@end"),kt.import(Tn),kt.import(Zt),Gt.template("qtek.basic",kt.source("qtek.basic.vertex"),kt.source("qtek.basic.fragment")),Gt.template("qtek.lambert",kt.source("qtek.lambert.vertex"),kt.source("qtek.lambert.fragment")),Gt.template("qtek.wireframe",kt.source("qtek.wireframe.vertex"),kt.source("qtek.wireframe.fragment")),Gt.template("qtek.skybox",kt.source("qtek.skybox.vertex"),kt.source("qtek.skybox.fragment")),Gt.template("qtek.prez",kt.source("qtek.prez.vertex"),kt.source("qtek.prez.fragment")),Gt.template("qtek.standard",kt.source("qtek.standard.vertex"),kt.source("qtek.standard.fragment")),kt.import("@export qtek.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 qtek.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 qtek.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 qtek.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 qtek.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 qtek.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"),kt.import(En), +kt.import("@export qtek.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import qtek.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 qtek.compositor.hdr.lum_adaption\nvarying vec2 v_Texcoord;\nuniform sampler2D adaptedLum;\nuniform sampler2D currentLum;\nuniform float frameTime : 0.02;\n@import qtek.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 qtek.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"),kt.import("\n@export qtek.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"),kt.import("@export qtek.compositor.vignette\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float darkness: 1;\nuniform float offset: 1;\n@import qtek.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"),kt.import(bn),kt.import(Sn),kt.import(An),kt.import(Nn),kt.import(wn),kt.import("@export qtek.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 qtek.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 qtek.compositor.dof.premultiply\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\n@import qtek.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 qtek.compositor.dof.min_coc\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform vec2 textureSize : [512.0, 512.0];\n@import qtek.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 qtek.compositor.dof.max_coc\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\nuniform vec2 textureSize : [512.0, 512.0];\n@import qtek.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 qtek.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 qtek.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 qtek.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 qtek.util.rgbm\n@import qtek.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 qtek.compositor.dof.downsample\nuniform sampler2D texture;\nuniform sampler2D coc;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\n@import qtek.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 qtek.compositor.dof.hexagonal_blur_frag\n@import qtek.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 qtek.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 qtek.util.rgbm\n@import qtek.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 qtek.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 qtek.util.rgbm\n@import qtek.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 qtek.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 qtek.util.rgbm\n@import qtek.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 qtek.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 qtek.util.rgbm\n@import qtek.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"),kt.import("@export qtek.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 qtek.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"),kt.import(Mn),kt.import(Rn),kt.import("@export qtek.compositor.fxaa3\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nuniform float subpixel: 0.75;\nuniform float edgeThreshold: 0.125;\nuniform float edgeThresholdMin: 0.0625;\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\nfloat FxaaLuma(vec4 rgba) { return rgba.y; }\nvec4 FxaaPixelShader(\n vec2 pos\n ,sampler2D tex\n ,vec2 fxaaQualityRcpFrame\n ,float fxaaQualitySubpix\n ,float fxaaQualityEdgeThreshold\n ,float fxaaQualityEdgeThresholdMin\n) {\n vec2 posM;\n posM.x = pos.x;\n posM.y = pos.y;\n vec4 rgbyM = decodeHDR(texture2D(texture, posM, 0.0));\n float lumaS = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2( 0.0, 1.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaE = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2( 1.0, 0.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaN = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2( 0.0,-1.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaW = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2(-1.0, 0.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float maxSM = max(lumaS, rgbyM.y);\n float minSM = min(lumaS, rgbyM.y);\n float maxESM = max(lumaE, maxSM);\n float minESM = min(lumaE, minSM);\n float maxWN = max(lumaN, lumaW);\n float minWN = min(lumaN, lumaW);\n float rangeMax = max(maxWN, maxESM);\n float rangeMin = min(minWN, minESM);\n float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\n float range = rangeMax - rangeMin;\n float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\n bool earlyExit = range < rangeMaxClamped;\n if(earlyExit) return rgbyM;\n float lumaNW = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2(-1.0,-1.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaSE = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2( 1.0, 1.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaNE = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2( 1.0,-1.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaSW = FxaaLuma(decodeHDR(texture2D(texture, posM + (vec2(-1.0, 1.0) * fxaaQualityRcpFrame.xy), 0.0)));\n float lumaNS = lumaN + lumaS;\n float lumaWE = lumaW + lumaE;\n float subpixRcpRange = 1.0/range;\n float subpixNSWE = lumaNS + lumaWE;\n float edgeHorz1 = (-2.0 * rgbyM.y) + lumaNS;\n float edgeVert1 = (-2.0 * rgbyM.y) + lumaWE;\n float lumaNESE = lumaNE + lumaSE;\n float lumaNWNE = lumaNW + lumaNE;\n float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\n float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\n float lumaNWSW = lumaNW + lumaSW;\n float lumaSWSE = lumaSW + lumaSE;\n float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\n float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\n float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\n float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\n float edgeHorz = abs(edgeHorz3) + edgeHorz4;\n float edgeVert = abs(edgeVert3) + edgeVert4;\n float subpixNWSWNESE = lumaNWSW + lumaNESE;\n float lengthSign = fxaaQualityRcpFrame.x;\n bool horzSpan = edgeHorz >= edgeVert;\n float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\n if(!horzSpan) lumaN = lumaW;\n if(!horzSpan) lumaS = lumaE;\n if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\n float subpixB = (subpixA * (1.0/12.0)) - rgbyM.y;\n float gradientN = lumaN - rgbyM.y;\n float gradientS = lumaS - rgbyM.y;\n float lumaNN = lumaN + rgbyM.y;\n float lumaSS = lumaS + rgbyM.y;\n bool pairN = abs(gradientN) >= abs(gradientS);\n float gradient = max(abs(gradientN), abs(gradientS));\n if(pairN) lengthSign = -lengthSign;\n float subpixC = clamp(abs(subpixB) * subpixRcpRange, 0.0, 1.0);\n vec2 posB;\n posB.x = posM.x;\n posB.y = posM.y;\n vec2 offNP;\n offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n if(!horzSpan) posB.x += lengthSign * 0.5;\n if( horzSpan) posB.y += lengthSign * 0.5;\n vec2 posN;\n posN.x = posB.x - offNP.x * 1.0;\n posN.y = posB.y - offNP.y * 1.0;\n vec2 posP;\n posP.x = posB.x + offNP.x * 1.0;\n posP.y = posB.y + offNP.y * 1.0;\n float subpixD = ((-2.0)*subpixC) + 3.0;\n float lumaEndN = FxaaLuma(decodeHDR(texture2D(texture, posN, 0.0)));\n float subpixE = subpixC * subpixC;\n float lumaEndP = FxaaLuma(decodeHDR(texture2D(texture, posP, 0.0)));\n if(!pairN) lumaNN = lumaSS;\n float gradientScaled = gradient * 1.0/4.0;\n float lumaMM = rgbyM.y - lumaNN * 0.5;\n float subpixF = subpixD * subpixE;\n bool lumaMLTZero = lumaMM < 0.0;\n lumaEndN -= lumaNN * 0.5;\n lumaEndP -= lumaNN * 0.5;\n bool doneN = abs(lumaEndN) >= gradientScaled;\n bool doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * 1.5;\n if(!doneN) posN.y -= offNP.y * 1.5;\n bool doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * 1.5;\n if(!doneP) posP.y += offNP.y * 1.5;\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(decodeHDR(texture2D(texture, posN.xy, 0.0)));\n if(!doneP) lumaEndP = FxaaLuma(decodeHDR(texture2D(texture, posP.xy, 0.0)));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * 2.0;\n if(!doneN) posN.y -= offNP.y * 2.0;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * 2.0;\n if(!doneP) posP.y += offNP.y * 2.0;\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(decodeHDR(texture2D(texture, posN.xy, 0.0)));\n if(!doneP) lumaEndP = FxaaLuma(decodeHDR(texture2D(texture, posP.xy, 0.0)));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * 4.0;\n if(!doneN) posN.y -= offNP.y * 4.0;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * 4.0;\n if(!doneP) posP.y += offNP.y * 4.0;\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma(decodeHDR(texture2D(texture, posN.xy, 0.0)));\n if(!doneP) lumaEndP = FxaaLuma(decodeHDR(texture2D(texture, posP.xy, 0.0)));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * 12.0;\n if(!doneN) posN.y -= offNP.y * 12.0;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * 12.0;\n if(!doneP) posP.y += offNP.y * 12.0;\n }\n }\n }\n float dstN = posM.x - posN.x;\n float dstP = posP.x - posM.x;\n if(!horzSpan) dstN = posM.y - posN.y;\n if(!horzSpan) dstP = posP.y - posM.y;\n bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\n float spanLength = (dstP + dstN);\n bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\n float spanLengthRcp = 1.0/spanLength;\n bool directionN = dstN < dstP;\n float dst = min(dstN, dstP);\n bool goodSpan = directionN ? goodSpanN : goodSpanP;\n float subpixG = subpixF * subpixF;\n float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\n float subpixH = subpixG * fxaaQualitySubpix;\n float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\n float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n return vec4(decodeHDR(texture2D(texture, posM, 0.0)).xyz, rgbyM.y);\n}\nvoid main()\n{\n vec4 color = FxaaPixelShader(\n v_Texcoord,\n texture,\n vec2(1.0) / viewport.zw,\n subpixel,\n edgeThreshold,\n edgeThresholdMin\n );\n gl_FragColor = vec4(color.rgb, 1.0);\n}\n@end");var Cn={NORMAL:"normal",POSITION:"position",TEXCOORD_0:"texcoord0",TEXCOORD_1:"texcoord1",WEIGHTS_0:"weight",JOINTS_0:"joint",COLOR:"color"},Ln={5120:nt.Int8Array,5121:nt.Uint8Array,5122:nt.Int16Array,5123:nt.Uint16Array,5125:nt.Uint32Array,5126:nt.Float32Array},Dn={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Pn=Qe.extend({rootNode:null,rootPath:null,textureRootPath:null,bufferRootPath:null,shaderName:"qtek.standard",useStandardMaterial:!1,includeCamera:!0,includeAnimation:!0,includeMesh:!0,includeTexture:!0,crossOrigin:"",textureFlipY:!1,shaderLibrary:null},function(){this.shaderLibrary||(this.shaderLibrary=Gt.createLibrary())},{load:function(e){var t=this,r=e.endsWith(".glb");null==this.rootPath&&(this.rootPath=e.slice(0,e.lastIndexOf("/"))),nr.get({url:e,onprogress:function(e,r,n){t.trigger("progress",e,r,n)},onerror:function(e){t.trigger("error",e)},responseType:r?"arraybuffer":"text",onload:function(e){r?t.parseBinary(e):t.parse(JSON.parse(e))}})},parseBinary:function(e){var t=new Uint32Array(e,0,4);if(1179937895!==t[0])return void this.trigger("error","Invalid glTF binary format: Invalid header");if(t[0]<2)return void this.trigger("error","Only glTF2.0 is supported.");for(var r,n=new DataView(e,12),i=[],a=0;a=0&&this._clips.splice(t,1)},removeAnimator:function(e){for(var t=e.getClips(),r=0;r=65535?new Uint32Array(3*f):new Uint16Array(3*f);for(var m=0,v=0,g=n.isUseIndices(),y=0;y0;){for(var x=[],T=[],E=[],b=0,m=0;m=0&&-1===T[R]&&(b65535?new Uint32Array(3*I.triangles.length):new Uint16Array(3*I.triangles.length);var K=0;G=0;for(var m=0;m=0?O[R]:-1}G++}H.indices[K++]=D[w]}H.updateBoundingBox(),C.add(z)}for(var $=e.children(),m=0;m<$.length;m++)C.add($[m]);if(C.position.copy(e.position),C.rotation.copy(e.rotation),C.scale.copy(e.scale),r&&e.getParent()){var ee=e.getParent();ee.remove(e),ee.add(C)}return C}}},Hn=function(){this._fullfilled=!1,this._rejected=!1};Hn.prototype.resolve=function(e){this._fullfilled=!0,this._rejected=!1,this.trigger("success",e)},Hn.prototype.reject=function(e){this._rejected=!0,this._fullfilled=!1,this.trigger("error",e)},Hn.prototype.isFullfilled=function(){return this._fullfilled},Hn.prototype.isRejected=function(){return this._rejected},Hn.prototype.isSettled=function(){return this._fullfilled||this._rejected},Ze.extend(Hn.prototype,je),Hn.makeRequestTask=function(e,t){if("string"==typeof e)return H(e,t);if(e.url){var r=e;return H(r.url,r.responseType)}if(Array.isArray(e)){var n=e,i=[];return n.forEach(function(e){var t,r;"string"==typeof e?t=e:Object(e)===e&&(t=e.url,r=e.responseType),i.push(H(t,r))}),i}},Hn.makeTask=function(){return new Hn},Ze.extend(Hn.prototype,je);var zn=function(){Hn.apply(this,arguments),this._tasks=[],this._fulfilledNumber=0,this._rejectedNumber=0},Gn=function(){};Gn.prototype=Hn.prototype,zn.prototype=new Gn,zn.prototype.constructor=zn,zn.prototype.all=function(e){var t=0,r=this,n=[];return this._tasks=e,this._fulfilledNumber=0,this._rejectedNumber=0,Ze.each(e,function(e,i){e&&e.once&&(t++,e.once("success",function(a){t--,r._fulfilledNumber++,e._fulfilled=!0,e._rejected=!1,n[i]=a,0===t&&r.resolve(n)}),e.once("error",function(){r._rejectedNumber++,e._fulfilled=!1,e._rejected=!0,r.reject(e)}))}),0===t?(setTimeout(function(){r.resolve(n)}),this):this},zn.prototype.allSettled=function(e){var t=0,r=this,n=[];return 0===e.length?(setTimeout(function(){r.trigger("success",n)}),this):(this._tasks=e,Ze.each(e,function(e,i){e&&e.once&&(t++,e.once("success",function(a){t--,r._fulfilledNumber++,e._fulfilled=!0,e._rejected=!1,n[i]=a,0===t&&r.resolve(n)}),e.once("error",function(a){t--,r._rejectedNumber++,e._fulfilled=!1,e._rejected=!0,n[i]=null,0===t&&r.resolve(n)}))}),this)},zn.prototype.getFulfilledNumber=function(e){if(e){for(var t=0,r=0;r=0&&x[g]>1e-4&&(qn.transformMat4(b,y,m[T[g]]),qn.scaleAndAdd(E,E,b,x[g]));S.set(v,E)}}for(var v=0;v1&&t.texParameterf(t.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===n){e.getGLExtension("OES_texture_half_float")||(n=et.FLOAT)}if(this.mipmaps.length)for(var a=this.width,o=this.height,s=0;s65535?Uint32Array:Uint16Array,_=this.indices=new d(t*e*6),p=this.radius,m=this.phiStart,v=this.phiLength,g=this.thetaStart,y=this.thetaLength,p=this.radius,x=[],T=[],E=0,b=1/p;for(f=0;f<=e;f++)for(h=0;h<=t;h++)l=h/t,c=f/e,o=-p*Math.cos(m+l*v)*Math.sin(g+c*y),s=p*Math.cos(g+c*y),u=p*Math.sin(m+l*v)*Math.sin(g+c*y),x[0]=o,x[1]=s,x[2]=u,T[0]=l,T[1]=c,r.set(E,x),n.set(E,T),x[0]*=b,x[1]*=b,x[2]*=b,i.set(E,x),E++;var S,A,N,w,M=t+1,R=0;for(f=0;f=i)){a+=2;for(var o="";a20)return console.warn("Given image is not a height map"),e}var f,d,_,p;u%(4*n)==0?(f=o.data[u],_=o.data[u+4]):u%(4*n)==4*(n-1)?(f=o.data[u-4],_=o.data[u]):(f=o.data[u-4],_=o.data[u+4]),u<4*n?(d=o.data[u],p=o.data[u+4*n]):u>n*(i-1)*4?(d=o.data[u-4*n],p=o.data[u]):(d=o.data[u-4*n],p=o.data[u+4*n]),s.data[u]=f-_+127,s.data[u+1]=d-p+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){nr.get({url:e,responseType:"arraybuffer",onload:t,onerror:r})},createChessboard:function(e,t,r,n){e=e||512,t=t||64,r=r||"black",n=n||"white";var i=Math.ceil(e/t),a=document.createElement("canvas");a.width=e,a.height=e;var o=a.getContext("2d");o.fillStyle=n,o.fillRect(0,0,e,e),o.fillStyle=r;for(var s=0;s=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){vi.material=this.material,e.renderQueue([vi],gi)},dispose:function(e){this.material.dispose(e)}}),xi=function(){this._pool={},this._allocatedTextures=[]};xi.prototype={constructor:xi,get:function(e){var t=K(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]);var r=this._pool[t];if(!r.length){var n=new Lr(e);return this._allocatedTextures.push(n),n}return r.pop()},put:function(e){var t=K(e);this._pool.hasOwnProperty(t)||(this._pool[t]=[]),this._pool[t].push(e)},clear:function(e){for(var t=0;t= 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");var Ai=Qe.extend(function(){return{softShadow:Ai.PCF,shadowBlur:1,lightFrustumBias:"auto",kernelPCF:new Float32Array([1,0,1,1,-1,1,0,1,-1,0,-1,-1,1,-1,0,-1]),precision:"mediump",_lastRenderNotCastShadow:!1,_frameBuffer:new $n,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_meshMaterials:{},_depthMaterials:{},_depthShaders:{},_distanceMaterials:{},_opaqueCasters:[],_receivers:[],_lightsCastShadow:[],_lightCameras:{},_texturePool:new xi}},function(){this._gaussianPassH=new yi({fragment:kt.source("qtek.compositor.gaussian_blur")}),this._gaussianPassV=new yi({fragment:kt.source("qtek.compositor.gaussian_blur")}),this._gaussianPassH.setUniform("blurSize",this.shadowBlur),this._gaussianPassH.setUniform("blurDir",0),this._gaussianPassV.setUniform("blurSize",this.shadowBlur),this._gaussianPassV.setUniform("blurDir",1),this._outputDepthPass=new yi({fragment:kt.source("qtek.sm.debug_depth")})},{render:function(e,t,r,n){this.trigger("beforerender",this,e,t,r),this._renderShadowPass(e,t,r,n),this.trigger("afterrender",this,e,t,r)},renderDebug:function(e,t){e.saveClear();var r=e.viewport,n=0,i=t||r.width/4,a=i;this.softShadow===Ai.VSM?this._outputDepthPass.material.shader.define("fragment","USE_VSM"):this._outputDepthPass.material.shader.undefine("fragment","USE_VSM");for(var o in this._textures){var s=this._textures[o];e.setViewport(n,0,i*s.width/s.height,a),this._outputDepthPass.setUniform("depthMap",s),this._outputDepthPass.render(e),n+=i*s.width/s.height}e.setViewport(r),e.restoreClear()},_bindDepthMaterial:function(e,t,r){for(var n=0;n0&&(h.define("vertex","SKINNING"),h.define("vertex","JOINT_COUNT",l)),s&&h.define("both","SHADOW_TRANSPARENT"),o.useSkinMatricesTexture&&h.define("vertex","USE_SKIN_MATRICES_TEXTURE"),this._depthShaders[a]=h),c||(c=new qt({shader:h}),this._depthMaterials[i]=c),o.material=c,this.softShadow===Ai.VSM?h.define("fragment","USE_VSM"):h.undefine("fragment","USE_VSM"),c.setUniform("bias",t),c.setUniform("slopeScale",r),s&&c.set("shadowTransparentMap",u))}},_bindDistanceMaterial:function(e,t){for(var r=t.getWorldPosition()._array,n=0;n0&&(o.shader.define("vertex","SKINNING"),o.shader.define("vertex","JOINT_COUNT",a)),this._distanceMaterials[a]=o),i.material=o,this.softShadow===Ai.VSM?o.shader.define("fragment","USE_VSM"):o.shader.undefine("fragment","USE_VSM")),o.set("lightPosition",r),o.set("range",t.range)}},saveMaterial:function(e){for(var t=0;t1&&(d=p,p.shadowCascade>4)){console.warn("Support at most 4 cascade");continue}this.renderDirectionalLightShadow(e,t,r,p,this._opaqueCasters,h,c,l)}else p instanceof di?this.renderSpotLightShadow(e,p,this._opaqueCasters,u,s):p instanceof pi&&this.renderPointLightShadow(e,p,this._opaqueCasters,f);this._shadowMapNumber[p.type]++}this.restoreMaterial(this._opaqueCasters);var m=h.slice(),v=h.slice();m.pop(),v.shift(),m.reverse(),v.reverse(),c.reverse();for(var g=s.map(i),y=l.map(i),x={},_=0;_0?(b.fragmentDefines[w]=N,S=!0):b.isDefined("fragment",w)&&(b.undefine("fragment",w),S=!0))}S&&b.dirty(),d?b.define("fragment","SHADOW_CASCADE",d.shadowCascade):b.undefine("fragment","SHADOW_CASCADE"),x[b.__GUID__]=!0}s.length>0&&(E.setUniform("spotLightShadowMaps",s),E.setUniform("spotLightMatrices",u),E.setUniform("spotLightShadowMapSizes",g)),l.length>0&&(E.setUniform("directionalLightShadowMaps",l),d&&(E.setUniform("shadowCascadeClipsNear",m),E.setUniform("shadowCascadeClipsFar",v)),E.setUniform("directionalLightMatrices",c),E.setUniform("directionalLightShadowMapSizes",y)),f.length>0&&E.setUniform("pointLightShadowMaps",f)}}},renderDirectionalLightShadow:function(){var e=new Kr,t=new xt,r=new pt,n=new xt,i=new xt,a=new xt,o=new xt;return function(s,u,l,c,h,f,d,_){var p=c.shadowBias;if(this._bindDepthMaterial(h,p,c.shadowSlopeScale),h.sort(tr.opaqueSortFunc),!u.viewBoundingBoxLastFrame.isFinite()){var m=u.getBoundingBox();u.viewBoundingBoxLastFrame.copy(m).applyTransform(l.viewMatrix)}var v=Math.min(-u.viewBoundingBoxLastFrame.min.z,l.far),g=Math.max(-u.viewBoundingBoxLastFrame.max.z,l.near),y=this._getDirectionalLightCamera(c,u,l),x=a._array;o.copy(y.projectionMatrix),bi.invert(i._array,y.worldTransform._array),bi.multiply(i._array,i._array,l.worldTransform._array),bi.multiply(x,o._array,i._array);for(var T=[],E=l instanceof en,b=(l.near+l.far)/(l.near-l.far),S=2*l.near*l.far/(l.near-l.far),A=0;A<=c.shadowCascade;A++){var N=g*Math.pow(v/g,A/c.shadowCascade),w=g+(v-g)*A/c.shadowCascade,M=N*c.cascadeSplitLogFactor+w*(1-c.cascadeSplitLogFactor);T.push(M),f.push(-(-M*b+S)/-M)}var R=this._getTexture(c,c.shadowCascade);_.push(R);var C=s.viewport,L=s.gl;this._frameBuffer.attach(R),this._frameBuffer.bind(s),L.clear(L.COLOR_BUFFER_BIT|L.DEPTH_BUFFER_BIT);for(var A=0;A0){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])}}}),wi=Qe.extend(function(){return{nodes:[]}},{dirty:function(){this._dirty=!0},addNode:function(e){this.nodes.indexOf(e)>=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&&u<=t.COLOR_ATTACHMENT0+8&&c.push(u);l.drawBuffersEXT(c)}e.saveClear(),e.clearBit=et.DEPTH_BUFFER_BIT|et.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}}),Ci=Ni.extend(function(){return{texture:null,outputs:{color:{}}}},function(){},{getOutput:function(e,t){return this.texture},beforeFrame:function(){},afterFrame:function(){}}),Li=Ni.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 yi({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])},setShader:function(e){var t=this.pass.material;t.shader.setFragment(e),t.attachShader(t.shader,!0)},shaderDefine:function(e,t){this.pass.material.shader.define("fragment",e,t)},shaderUndefine:function(e){this.pass.material.shader.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])}},link:function(e,t,r){this.inputLinks[e]={node:t,pin:r},t.outputLinks[r]||(t.outputLinks[r]=[]),t.outputLinks[r].push({node:this,pin:e}),this.pass.material.shader.enableTexture(e)},clear:function(){Ni.prototype.clear.call(this),this.pass.material.shader.disableTexturesAll()},updateReference:function(e){if(!this._rendering){this._rendering=!0;for(var t in this.inputLinks){var r=this.inputLinks[t];r.node.updateReference(r.pin)}this._rendering=!1}e&&this._outputReferences[e]++},beforeFrame:function(){this._rendered=!1;for(var e in this.outputLinks)this._outputReferences[e]=0},afterFrame:function(){for(var e in this.outputLinks)if(this._outputReferences[e]>0){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])}}}),Di=/#source\((.*?)\)/,Pi=/#url\((.*?)\)/,Ii=Qe.extend({rootPath:"",textureRootPath:"",shaderRootPath:"",scene:null,camera:null},{load:function(e){var t=this;this.rootPath||(this.rootPath=e.slice(0,e.lastIndexOf("/"))),nr.get({url:e,onprogress:function(e,r,n){t.trigger("progress",e,r,n)},onerror:function(e){t.trigger("error",e)},responseType:"text",onload:function(e){t.parse(JSON.parse(e))}})},parse:function(e){var t=this,r=new Mi,n={textures:{},shaders:{},parameters:{}},i=function(i,a){for(var o=0;o 0.99999) {\n gl_FragColor = vec4(1.0);\n return;\n }\n mat3 kernelBasis;\n#endif\n\n float z = depthTexel.r * 2.0 - 1.0;\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * projectedPos;\n\n vec3 position = p4.xyz / p4.w;\n\n float ao = ssaoEstimator(position, N, kernelBasis);\n ao = clamp(1.0 - (1.0 - ao) * intensity, 0.0, 1.0);\n gl_FragColor = vec4(vec3(ao), 1.0);\n}\n\n@end\n\n\n@export ecgl.ssao.blur\n#define SHADER_NAME SSAO_BLUR\n\nuniform sampler2D ssaoTexture;\n\n#ifdef NORMALTEX_ENABLED\nuniform sampler2D normalTex;\n#endif\n\n#ifdef DEPTHTEX_ENABLED\nuniform sampler2D depthTex;\nuniform mat4 projection;\nuniform float depthRange : 0.05;\n#endif\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\nuniform int direction: 0.0;\n\n#ifdef DEPTHTEX_ENABLED\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(depthTex, v_Texcoord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n#endif\n\nvoid main()\n{\n @import qtek.compositor.kernel.gaussian_9\n\n vec2 off = vec2(0.0);\n if (direction == 0) {\n off[0] = blurSize / textureSize.x;\n }\n else {\n off[1] = blurSize / textureSize.y;\n }\n\n vec2 coord = v_Texcoord;\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\n#ifdef NORMALTEX_ENABLED\n vec3 centerNormal = texture2D(normalTex, v_Texcoord).rgb * 2.0 - 1.0;\n#elif defined(DEPTHTEX_ENABLED)\n float centerDepth = getLinearDepth(v_Texcoord);\n#endif\n\n for (int i = 0; i < 9; i++) {\n vec2 coord = clamp(v_Texcoord + vec2(float(i) - 4.0) * off, vec2(0.0), vec2(1.0));\n\n#ifdef NORMALTEX_ENABLED\n vec3 normal = texture2D(normalTex, coord).rgb * 2.0 - 1.0;\n float w = gaussianKernel[i] * clamp(dot(normal, centerNormal), 0.0, 1.0);\n#elif defined(DEPTHTEX_ENABLED)\n float d = getLinearDepth(coord);\n float w = gaussianKernel[i] * (1.0 - clamp(abs(centerDepth - d) / depthRange, 0.0, 1.0));\n#else\n float w = gaussianKernel[i];\n#endif\n\n weightAll += w;\n sum += texture2D(ssaoTexture, coord) * w;\n }\n\n gl_FragColor = vec4(vec3(sum / weightAll), 1.0);\n}\n\n@end\n"),ie.prototype.setDepthTexture=function(e){this._depthTex=e},ie.prototype.setNormalTexture=function(e){this._normalTex=e,this._ssaoPass.material.shader[e?"enableTexture":"disableTexture"]("normalTex"),this.setKernelSize(this._kernelSize)},ie.prototype.update=function(e,t,r){var n=e.getWidth(),i=e.getHeight(),a=this._ssaoPass,o=this._blurPass;a.setUniform("kernel",this._kernels[r%this._kernels.length]),a.setUniform("depthTex",this._depthTex),null!=this._normalTex&&a.setUniform("normalTex",this._normalTex),a.setUniform("depthTexSize",[this._depthTex.width,this._depthTex.height]);var s=new xt;xt.transpose(s,t.worldTransform),a.setUniform("projection",t.projectionMatrix._array),a.setUniform("projectionInv",t.invProjectionMatrix._array),a.setUniform("viewInverseTranspose",s._array);var u=this._ssaoTexture,l=this._blurTexture;u.width=n,u.height=i,l.width=n,l.height=i,this._framebuffer.attach(u),this._framebuffer.bind(e),e.gl.clearColor(1,1,1,1),e.gl.clear(e.gl.COLOR_BUFFER_BIT),a.render(e),o.setUniform("textureSize",[n,i]),this._framebuffer.attach(l),o.setUniform("direction",0),o.setUniform("ssaoTexture",u),o.render(e),this._framebuffer.attach(u),o.setUniform("direction",1),o.setUniform("ssaoTexture",l),o.render(e),this._framebuffer.unbind(e);var c=e.clearColor;e.gl.clearColor(c[0],c[1],c[2],c[3])},ie.prototype.getTargetTexture=function(){return this._ssaoTexture},ie.prototype.setParameter=function(e,t){"noiseTexSize"===e?this.setNoiseSize(t):"kernelSize"===e?this.setKernelSize(t):"intensity"===e?this._ssaoPass.material.set("intensity",t):this._ssaoPass.setUniform(e,t)},ie.prototype.setKernelSize=function(e){this._kernelSize=e,this._ssaoPass.material.shader.define("fragment","KERNEL_SIZE",e),this._kernels=this._kernels||[];for(var t=0;t<30;t++)this._kernels[t]=ne(e,t*e,!!this._normalTex)},ie.prototype.setNoiseSize=function(e){var t=this._ssaoPass.getUniform("noiseTex");t?(t.data=te(e),t.width=t.height=e,t.dirty()):(t=re(e),this._ssaoPass.setUniform("noiseTex",re(e))),this._ssaoPass.setUniform("noiseTexSize",[e,e])},ie.prototype.dispose=function(e){this._blurTexture.dispose(e),this._ssaoTexture.dispose(e)};kt.import("@export ecgl.ssr.main\n\n#define MAX_ITERATION 20;\n\nuniform sampler2D sourceTexture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\n\nuniform mat4 projection;\nuniform mat4 projectionInv;\nuniform mat4 viewInverseTranspose;\n\nuniform float maxRayDistance: 50;\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: 10;\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 qtek.util.decode_float\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 if (intersect) {\n break;\n }\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 qtek.util.rand\n\n@import qtek.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 (g <= minGlossiness) {\n discard;\n }\n\n float reflectivity = (g - minGlossiness) / (1.0 - minGlossiness);\n\n vec3 N = normalAndGloss.rgb * 2.0 - 1.0;\n N = normalize((viewInverseTranspose * 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\n vec3 rayDir = normalize(reflect(normalize(rayOrigin), N));\n vec2 hitPixel;\n vec3 hitPoint;\n float iterationCount;\n\n vec2 uv2 = v_Texcoord * viewportSize;\n float jitter = rand(fract(v_Texcoord + jitterOffset));\n\n bool intersect = traceScreenSpaceRay(rayOrigin, rayDir, jitter, hitPixel, hitPoint, iterationCount);\n\n float dist = distance(rayOrigin, hitPoint);\n\n float alpha = calculateAlpha(iterationCount, reflectivity, hitPixel, hitPoint, dist, rayDir) * float(intersect);\n\n vec3 hitNormal = texture2D(gBufferTexture1, hitPixel).rgb * 2.0 - 1.0;\n hitNormal = normalize((viewInverseTranspose * vec4(hitNormal, 0.0)).xyz);\n\n if (dot(hitNormal, rayDir) >= 0.0) {\n discard;\n }\n\n \n if (!intersect) {\n discard;\n }\n vec4 color = decodeHDR(texture2D(sourceTexture, hitPixel));\n gl_FragColor = encodeHDR(vec4(color.rgb * alpha, color.a));\n}\n@end\n\n@export ecgl.ssr.blur\n\nuniform sampler2D texture;\nuniform sampler2D gBufferTexture1;\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 4.0;\n\n#ifdef BLEND\nuniform sampler2D sourceTexture;\n#endif\n\n@import qtek.util.rgbm\n\n\nvoid main()\n{\n @import qtek.compositor.kernel.gaussian_13\n\n vec4 centerNTexel = texture2D(gBufferTexture1, v_Texcoord);\n float g = centerNTexel.a;\n float maxBlurSize = clamp(1.0 - g + 0.1, 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 for (int i = 0; i < 13; i++) {\n vec2 coord = clamp((float(i) - 6.0) * off + v_Texcoord, vec2(0.0), vec2(1.0));\n float w = gaussianKernel[i] * clamp(dot(cN, texture2D(gBufferTexture1, coord).rgb * 2.0 - 1.0), 0.0, 1.0);\n weightAll += w;\n sum += decodeHDR(texture2D(texture, coord)) * w;\n }\n\n#ifdef BLEND\n gl_FragColor = encodeHDR(\n sum / weightAll + decodeHDR(texture2D(sourceTexture, v_Texcoord))\n );\n#else\n gl_FragColor = encodeHDR(sum / weightAll);\n#endif\n}\n\n@end"),ae.prototype.update=function(e,t,r,n){var i=e.getWidth(),a=e.getHeight(),o=this._texture1,s=this._texture2;o.width=s.width=i,o.height=s.height=a;var u=this._frameBuffer,l=this._ssrPass,c=this._blurPass1,h=this._blurPass2,f=new xt;xt.transpose(f,t.worldTransform),l.setUniform("sourceTexture",r),l.setUniform("projection",t.projectionMatrix._array),l.setUniform("projectionInv",t.invProjectionMatrix._array),l.setUniform("viewInverseTranspose",f._array),l.setUniform("nearZ",t.near),l.setUniform("jitterOffset",n/30);var d=[i,a];c.setUniform("textureSize",d),h.setUniform("textureSize",d),h.setUniform("sourceTexture",r),u.attach(s),u.bind(e),l.render(e),u.attach(o),c.setUniform("texture",s),c.render(e),u.attach(s),h.setUniform("texture",o),h.render(e),u.unbind(e)},ae.prototype.getTargetTexture=function(){return this._texture2},ae.prototype.setParameter=function(e,t){"maxIteration"===e?this._ssrPass.material.shader.define("fragment","MAX_ITERATION",t):this._ssrPass.setUniform(e,t)},ae.prototype.dispose=function(e){this._texture1.dispose(e),this._texture2.dispose(e),this._frameBuffer.dispose(e)};var Oi=[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],Fi="@export qtek.deferred.gbuffer.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\nuniform vec2 uvRepeat;\nuniform vec2 uvOffset;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n#ifdef FIRST_PASS\nattribute vec3 normal : NORMAL;\n#endif\n@import qtek.chunk.skinning_header\n#ifdef FIRST_PASS\nvarying vec3 v_Normal;\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\nvarying vec3 v_WorldPosition;\n#endif\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec3 skinnedPosition = position;\n#ifdef FIRST_PASS\n vec3 skinnedNormal = normal;\n vec3 skinnedTangent = tangent.xyz;\n bool hasTangent = dot(tangent, tangent) > 0.0;\n#endif\n#ifdef SKINNING\n @import qtek.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n #ifdef FIRST_PASS\n skinnedNormal = (skinMatrixWS * vec4(normal, 0.0)).xyz;\n if (hasTangent) {\n skinnedTangent = (skinMatrixWS * vec4(tangent.xyz, 0.0)).xyz;\n }\n #endif\n#endif\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n#ifdef FIRST_PASS\n v_Normal = normalize((worldInverseTranspose * vec4(skinnedNormal, 0.0)).xyz);\n if (hasTangent) {\n v_Tangent = normalize((worldInverseTranspose * vec4(skinnedTangent, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n v_WorldPosition = (world * vec4(skinnedPosition, 1.0)).xyz;\n#endif\n}\n@end\n@export qtek.deferred.gbuffer1.fragment\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform float glossiness;\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\nuniform sampler2D roughGlossMap;\nuniform bool useRoughGlossMap;\nuniform bool useRoughness;\nuniform bool doubleSided;\nuniform int roughGlossChannel: 0;\nfloat indexingTexel(in vec4 texel, in int idx) {\n if (idx == 3) return texel.a;\n else if (idx == 1) return texel.g;\n else if (idx == 2) return texel.b;\n else return texel.r;\n}\nvoid main()\n{\n vec3 N = v_Normal;\n if (doubleSided) {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = eyePos - v_WorldPosition;\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n }\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_Texcoord).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 gl_FragColor.rgb = (N + 1.0) * 0.5;\n float g = glossiness;\n if (useRoughGlossMap) {\n float g2 = indexingTexel(texture2D(roughGlossMap, v_Texcoord), roughGlossChannel);\n if (useRoughness) {\n g2 = 1.0 - g2;\n }\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n }\n gl_FragColor.a = g;\n}\n@end\n@export qtek.deferred.gbuffer2.fragment\nuniform sampler2D diffuseMap;\nuniform sampler2D metalnessMap;\nuniform vec3 color;\nuniform float metalness;\nuniform bool useMetalnessMap;\nuniform bool linear;\nvarying vec2 v_Texcoord;\n@import qtek.util.srgb\nvoid main ()\n{\n float m = metalness;\n if (useMetalnessMap) {\n vec4 metalnessTexel = texture2D(metalnessMap, v_Texcoord);\n m = clamp(metalnessTexel.r + (m * 2.0 - 1.0), 0.0, 1.0);\n }\n vec4 texel = texture2D(diffuseMap, v_Texcoord);\n if (linear) {\n texel = sRGBToLinear(texel);\n }\n gl_FragColor.rgb = texel.rgb * color;\n gl_FragColor.a = m;\n}\n@end\n@export qtek.deferred.gbuffer.debug\n@import qtek.deferred.chunk.light_head\nuniform int debug: 0;\nvoid main ()\n{\n @import qtek.deferred.chunk.gbuffer_read\n if (debug == 0) {\n gl_FragColor = vec4(N, 1.0);\n }\n else if (debug == 1) {\n gl_FragColor = vec4(vec3(z), 1.0);\n }\n else if (debug == 2) {\n gl_FragColor = vec4(position, 1.0);\n }\n else if (debug == 3) {\n gl_FragColor = vec4(vec3(glossiness), 1.0);\n }\n else if (debug == 4) {\n gl_FragColor = vec4(vec3(metalness), 1.0);\n }\n else {\n gl_FragColor = vec4(albedo, 1.0);\n }\n}\n@end";kt.import(Fi),kt.import("@export qtek.deferred.chunk.light_head\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform sampler2D gBufferTexture3;\nuniform vec2 windowSize: WINDOW_SIZE;\nuniform vec4 viewport: VIEWPORT;\nuniform mat4 viewProjectionInv;\n#ifdef DEPTH_ENCODED\n@import qtek.util.decode_float\n#endif\n@end\n@export qtek.deferred.chunk.gbuffer_read\n vec2 uv = gl_FragCoord.xy / windowSize;\n vec2 uv2 = (gl_FragCoord.xy - viewport.xy) / viewport.zw;\n vec4 texel1 = texture2D(gBufferTexture1, uv);\n vec4 texel3 = texture2D(gBufferTexture3, uv);\n if (dot(texel1.rgb, vec3(1.0)) == 0.0) {\n discard;\n }\n float glossiness = texel1.a;\n float metalness = texel3.a;\n vec3 N = texel1.rgb * 2.0 - 1.0;\n float z = texture2D(gBufferTexture2, uv).r * 2.0 - 1.0;\n vec2 xy = uv2 * 2.0 - 1.0;\n vec4 projectedPos = vec4(xy, z, 1.0);\n vec4 p4 = viewProjectionInv * projectedPos;\n vec3 position = p4.xyz / p4.w;\n vec3 albedo = texel3.rgb;\n vec3 diffuseColor = albedo * (1.0 - metalness);\n vec3 specularColor = mix(vec3(0.04), albedo, metalness);\n@end\n@export qtek.deferred.chunk.light_equation\nfloat D_Phong(in float g, in float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\nfloat D_GGX(in float g, in float ndh) {\n float r = 1.0 - g;\n float a = r * r;\n float tmp = ndh * ndh * (a - 1.0) + 1.0;\n return a / (3.1415926 * tmp * tmp);\n}\nvec3 F_Schlick(in float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\nvec3 lightEquation(\n in vec3 lightColor, in vec3 diffuseColor, in vec3 specularColor,\n in float ndl, in float ndh, in float ndv, in float g\n)\n{\n return ndl * lightColor\n * (diffuseColor + D_Phong(g, ndh) * F_Schlick(ndv, specularColor));\n}\n@end");var ki=Qe.extend(function(){return{enableTargetTexture1:!0,enableTargetTexture2:!0,enableTargetTexture3:!0,_renderQueue:[],_gBufferTex1:new Lr({minFilter:Wt.NEAREST,magFilter:Wt.NEAREST,type:Wt.HALF_FLOAT}),_gBufferTex2:new Lr({minFilter:Wt.NEAREST,magFilter:Wt.NEAREST,format:Wt.DEPTH_STENCIL,type:Wt.UNSIGNED_INT_24_8_WEBGL}),_gBufferTex3:new Lr({minFilter:Wt.NEAREST,magFilter:Wt.NEAREST}),_defaultNormalMap:new Lr({image:oe("#000")}),_defaultRoughnessMap:new Lr({image:oe("#fff")}),_defaultMetalnessMap:new Lr({image:oe("#fff")}),_defaultDiffuseMap:new Lr({image:oe("#fff")}),_frameBuffer:new $n,_gBufferMaterials:{},_debugPass:new yi({fragment:kt.source("qtek.deferred.gbuffer.debug")})}},{resize:function(e,t){this._gBufferTex1.width===e&&this._gBufferTex1.height===t||(this._gBufferTex1.width=e,this._gBufferTex1.height=t,this._gBufferTex2.width=e,this._gBufferTex2.height=t,this._gBufferTex3.width=e,this._gBufferTex3.height=t)},setViewport:function(e,t,r,n,i){var a;a="object"==typeof e?e:{x:e,y:t,width:r,height:n,devicePixelRatio:i||1},this._frameBuffer.viewport=a},getViewport:function(){return this._frameBuffer.viewport?this._frameBuffer.viewport:{x:0,y:0,width:this._gBufferTex1.width,height:this._gBufferTex1.height,devicePixelRatio:1}},update:function(e,t,r){for(var n=e.gl,i=this._frameBuffer,a=i.viewport,o=t.opaqueQueue,s=t.transparentQueue,u=e.beforeRenderObject,l=0;l0&&(n.shader.define("vertex","SKINNING"),n.shader.define("vertex","JOINT_COUNT",e),i.shader.define("vertex","SKINNING"),i.shader.define("vertex","JOINT_COUNT",e)),r={material1:n,material2:i},t[e]=r}return r.used=!0,r},_resetGBufferMaterials:function(){for(var e in this._gBufferMaterials)this._gBufferMaterials[e].used=!1},_cleanGBufferMaterials:function(e){for(var t in this._gBufferMaterials){var r=this._gBufferMaterials[t];r.used||(r.material1.dispose(e),r.material2.dispose(e))}},_replaceGBufferMat:function(e,t){for(var r=0;r=this._maxSize&&a>0){var s=r.head;r.remove(s),delete n[s.key],i=s.value,this._lastRemovedEntry=s}o?o.value=t:o=new Hi(t),o.key=e,r.insertEntry(o),n[e]=o}return i},Gi.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},Gi.clear=function(){this._list.clear(),this._map={}};var Wi=new xt,qi=yn.extend({dynamic:!1,widthSegments:1,heightSegments:1,depthSegments:1,inside:!1},function(){this.build()},{build:function(){var e={px:ce("px",this.depthSegments,this.heightSegments),nx:ce("nx",this.depthSegments,this.heightSegments),py:ce("py",this.widthSegments,this.depthSegments),ny:ce("ny",this.widthSegments,this.depthSegments),pz:ce("pz",this.widthSegments,this.heightSegments),nz:ce("nz",this.widthSegments,this.heightSegments)},t=["position","texcoord0","normal"],r=0,n=0;for(var i in e)r+=e[i].vertexCount,n+=e[i].indices.length;for(var a=0;a 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"})});h.set("normalDistribution",n),r.encodeRGBM&&h.shader.define("fragment","RGBM_ENCODE"),r.decodeRGBM&&h.shader.define("fragment","RGBM_DECODE");var f,d=new fr;if(t instanceof Lr){var _=new Kn({width:a,height:o,type:s===Wt.FLOAT?Wt.HALF_FLOAT:s});fi.panoramaToCubeMap(e,t,_,{encodeRGBM:r.decodeRGBM}),t=_}f=new Vi({scene:d,material:h}),f.material.set("environmentMap",t);var p=new ti({texture:u});r.encodeRGBM&&(s=u.type=Wt.UNSIGNED_BYTE);for(var m=new Lr({width:a,height:o,type:s}),v=new $n({depthBuffer:!1}),g=nt[s===Wt.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],y=0;y 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"}),i=new Lr({width:512,height:256,type:Wt.HALF_FLOAT,minFilter:Wt.NEAREST,magFilter:Wt.NEAREST,useMipmap:!1});return n.setUniform("normalDistribution",t),n.setUniform("viewportSize",[512,256]),n.attachOutput(i),n.render(e,r),r.dispose(e),i},ji.generateNormalDistribution=function(e,t){for(var e=e||256,t=t||1024,r=new Lr({width:e,height:t,type:Wt.FLOAT,minFilter:Wt.NEAREST,magFilter:Wt.NEAREST,useMipmap:!1}),n=new Float32Array(t*e*4),i=0;i>>16)>>>0;o=((1431655765&o)<<1|(2863311530&o)>>>1)>>>0,o=((858993459&o)<<2|(3435973836&o)>>>2)>>>0,o=((252645135&o)<<4|(4042322160&o)>>>4)>>>0,o=(((16711935&o)<<8|(4278255360&o)>>>8)>>>0)/4294967296;for(var s=0;s3?t[3]=e[3]:t[3]=1,t):(t=Te(e||"#000",t)||[0,0,0,0],t[0]/=255,t[1]/=255,t[2]/=255,t)},na.stringifyColor=function(e,t){return e=e.slice(),e[0]=Math.round(255*e[0]),e[1]=Math.round(255*e[1]),e[2]=Math.round(255*e[2]),"hex"===t?"#"+((1<<24)+(e[0]<<16)+(e[1]<<8)+e[2]).toString(16).slice(1):be(e,t)},na.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},na.convertTextureToPowerOfTwo=we;var aa={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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 / 32, height * 1.0 / 32] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(qtek.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(qtek.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 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blend",shader:"#source(qtek.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(qtek.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(qtek.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 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blend",shader:"#source(qtek.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(qtek.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(qtek.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 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blend",shader:"#source(qtek.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(qtek.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(qtek.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 / 2, height * 1.0 / 2] )"}},{name:"bloom_composite",shader:"#source(qtek.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(qtek.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},defines:{}},{name:"FXAA",shader:"#source(qtek.compositor.fxaa)",inputs:{texture:"composite"}}]};kt.import(En),kt.import(bn),kt.import(Sn),kt.import(An),kt.import(Nn),kt.import(wn),kt.import(Mn),kt.import(Rn),kt.import(Fi), +kt.import("@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 qtek.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 qtek.util.rgbm\n@import qtek.util.float\n\nvoid main()\n{\n vec4 blurredColor = decodeHDR(texture2D(blurred, v_Texcoord));\n vec4 originalColor = decodeHDR(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 = decodeHDR(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 qtek.util.rgbm\n@import qtek.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 = decodeHDR(texel);\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\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 gl_FragColor = encodeHDR(color);\n#endif\n}\n\n@end"),kt.import("@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");var oa={color:{parameters:{width:function(e){return e.getWidth()},height:function(e){return e.getHeight()}}}},sa=["composite","FXAA"];Me.prototype.resize=function(e,t,r){r=r||1,e*=r,t*=r;var n=this._sourceTexture,i=this._depthTexture;n.width=e,n.height=t,i.width=e,i.height=t,this._gBufferPass.resize(e,t)},Me.prototype._ifRenderNormalPass=function(){return this._enableSSAO||this._enableEdge||this._enableSSR},Me.prototype._getPrevNode=function(e){for(var t=sa.indexOf(e.name)-1,r=this._finalNodesChain[t];r&&!this._compositor.getNodeByName(r.name);)t-=1,r=this._finalNodesChain[t];return r},Me.prototype._getNextNode=function(e){for(var t=sa.indexOf(e.name)+1,r=this._finalNodesChain[t];r&&!this._compositor.getNodeByName(r.name);)t+=1,r=this._finalNodesChain[t];return r},Me.prototype._addChainNode=function(e){var t=this._getPrevNode(e),r=this._getNextNode(e);t&&(t.outputs=oa,e.inputs.texture=t.name,r?(e.outputs=oa,r.inputs.texture=e.name):e.outputs=null,this._compositor.addNode(e))},Me.prototype._removeChainNode=function(e){var t=this._getPrevNode(e),r=this._getNextNode(e);t&&(r?(t.outputs=oa,r.inputs.texture=t.name):t.outputs=null,this._compositor.removeNode(e))},Me.prototype.updateNormal=function(e,t,r,n){this._ifRenderNormalPass()&&this._gBufferPass.update(e,t,r)},Me.prototype.updateSSAO=function(e,t,r,n){this._ssaoPass.update(e,r,n)},Me.prototype.enableSSAO=function(){this._enableSSAO=!0},Me.prototype.disableSSAO=function(){this._enableSSAO=!1},Me.prototype.enableSSR=function(){this._enableSSR=!0},Me.prototype.disableSSR=function(){this._enableSSR=!1},Me.prototype.getSSAOTexture=function(e,t,r,n){return this._ssaoPass.getTargetTexture()},Me.prototype.getSourceFrameBuffer=function(){return this._framebuffer},Me.prototype.getSourceTexture=function(){return this._sourceTexture},Me.prototype.disableFXAA=function(){this._removeChainNode(this._fxaaNode)},Me.prototype.enableFXAA=function(){this._addChainNode(this._fxaaNode)},Me.prototype.enableBloom=function(){this._compositeNode.inputs.bloom="bloom_composite",this._compositor.dirty()},Me.prototype.disableBloom=function(){this._compositeNode.inputs.bloom=null,this._compositor.dirty()},Me.prototype.enableDOF=function(){this._compositeNode.inputs.texture="dof_composite",this._compositor.dirty()},Me.prototype.disableDOF=function(){this._compositeNode.inputs.texture="source",this._compositor.dirty()},Me.prototype.enableColorCorrection=function(){this._compositeNode.shaderDefine("COLOR_CORRECTION"),this._enableColorCorrection=!0},Me.prototype.disableColorCorrection=function(){this._compositeNode.shaderUndefine("COLOR_CORRECTION"),this._enableColorCorrection=!1},Me.prototype.enableEdge=function(){this._enableEdge=!0},Me.prototype.disableEdge=function(){this._enableEdge=!1},Me.prototype.setBloomIntensity=function(e){null!=e&&this._compositeNode.setParameter("bloomIntensity",e)},Me.prototype.setSSAOParameter=function(e,t){if(null!=t)switch(e){case"quality":var r={low:6,medium:12,high:32,ultra:62}[t]||12;this._ssaoPass.setParameter("kernelSize",r);break;case"radius":this._ssaoPass.setParameter(e,t),this._ssaoPass.setParameter("bias",t/50);break;case"intensity":this._ssaoPass.setParameter(e,t)}},Me.prototype.setDOFParameter=function(e,t){if(null!=t)switch(e){case"focalDistance":case"focalRange":case"fstop":this._cocNode.setParameter(e,t);break;case"blurRadius":for(var r=0;r=this._haltonSequence.length},render:function(e){var t=this._blendPass;0===this._frame?(t.setUniform("weight1",0),t.setUniform("weight2",1)):(t.setUniform("weight1",.9),t.setUniform("weight2",.1)),t.setUniform("texture1",this._prevFrameTex),t.setUniform("texture2",this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),t.render(e),this._blendFb.unbind(e),this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e);var r=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=r,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)}},Ce.prototype.setProjection=function(e){var t=this.camera;t&&t.update(),"perspective"===e?this.camera instanceof en||(this.camera=new en,t&&this.camera.setLocalTransform(t.localTransform)):this.camera instanceof tn||(this.camera=new tn,t&&this.camera.setLocalTransform(t.localTransform)),this.camera.near=.1,this.camera.far=2e3},Ce.prototype.setViewport=function(e,t,r,n,i){this.camera instanceof en&&(this.camera.aspect=r/n),i=i||1,this.viewport.x=e,this.viewport.y=t,this.viewport.width=r,this.viewport.height=n,this.viewport.devicePixelRatio=i,this._compositor.resize(r*i,n*i),this._temporalSS.resize(r*i,n*i)},Ce.prototype.containPoint=function(e,t){var r=this.viewport;return t=this.layer.renderer.getHeight()-t,e>=r.x&&t>=r.y&&e<=r.x+r.width&&t<=r.y+r.height};var ua=new jt;Ce.prototype.castRay=function(e,t,r){var n=this.layer.renderer,i=n.viewport;return n.viewport=this.viewport,n.screenToNDC(e,t,ua),this.camera.castRay(ua,r),n.viewport=i,r},Ce.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this._frame=0,this._temporalSS.resetFrame()},Ce.prototype.render=function(e){this._doRender(e,this._frame),this._frame++},Ce.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively},Ce.prototype.needsTemporalSS=function(){var e=this._enableTemporalSS;return"auto"==e&&(e=this._enablePostEffect),e},Ce.prototype.hasDOF=function(){return this._enableDOF},Ce.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30},Ce.prototype._doRender=function(e,t){var r=this.scene,n=this.camera,i=this.renderer;if(t=t||0,!e&&this._shadowMapPass&&(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(i,r,n,!0)),this._updateShadowPCFKernel(t),i.gl.clearColor(0,0,0,0),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(i,n),this._compositor.updateNormal(i,r,n,this._temporalSS.getFrame())),this._updateSSAO(i,r,n,this._temporalSS.getFrame()),this._enablePostEffect){var a=this._compositor.getSourceFrameBuffer();a.bind(i),i.gl.clear(i.gl.DEPTH_BUFFER_BIT|i.gl.COLOR_BUFFER_BIT),i.render(r,n,!0,this.preZ),this.afterRenderScene(i,r,n),a.unbind(i),this.needsTemporalSS()&&e?(this._compositor.composite(i,n,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),i.setViewport(this.viewport),this._temporalSS.render(i)):(i.setViewport(this.viewport),this._compositor.composite(i,n,null,0))}else if(this.needsTemporalSS()&&e){var a=this._temporalSS.getSourceFrameBuffer();a.bind(i),i.saveClear(),i.clearBit=i.gl.DEPTH_BUFFER_BIT|i.gl.COLOR_BUFFER_BIT,i.render(r,n,!0,this.preZ),this.afterRenderScene(i,r,n),i.restoreClear(),a.unbind(i),i.setViewport(this.viewport),this._temporalSS.render(i)}else i.setViewport(this.viewport),i.render(r,n,!0,this.preZ),this.afterRenderScene(i,r,n);this.afterRenderAll(i,r,n)},Ce.prototype.afterRenderScene=function(e,t,r){},Ce.prototype.afterRenderAll=function(e,t,r){},Ce.prototype._updateSSAO=function(e,t,r,n){function i(e){for(var t=0;tthis.camera.far||e1&&n&&n.length>1){var a=ze(n)/ze(i);!isFinite(a)&&(a=1),t.pinchScale=a;var o=Ge(n);return t.pinchX=o[0],t.pinchY=o[1],{type:"pinch",target:e[0].target,event:t}}}}},ga=Qe.extend(function(){return{animation:null,domElement:null,target:null,_center:new ot,minDistance:.1,maxDistance:1e3,minAlpha:-90,maxAlpha:90,minBeta:-1/0,maxBeta:1/0,autoRotateAfterStill:0,autoRotateDirection:"cw",autoRotateSpeed:60,_mode:"rotate",damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,_needsUpdate:!1,_rotating:!1,_phi:0,_theta:0,_mouseX:0,_mouseY:0,_rotateVelocity:new jt,_panVelocity:new jt,_distance:20,_zoomSpeed:0,_stillTimeout:0,_animators:[],_gestureMgr:new ma}},function(){this._mouseDownHandler=this._mouseDownHandler.bind(this),this._mouseWheelHandler=this._mouseWheelHandler.bind(this),this._mouseMoveHandler=this._mouseMoveHandler.bind(this),this._mouseUpHandler=this._mouseUpHandler.bind(this),this._pinchHandler=this._pinchHandler.bind(this),this.update=this.update.bind(this),this.init()},{init:function(){var e=this.domElement;e.addEventListener("touchstart",this._mouseDownHandler),e.addEventListener("mousedown",this._mouseDownHandler),e.addEventListener("mousewheel",this._mouseWheelHandler),this.animation&&this.animation.on("frame",this.update)},dispose:function(){var e=this.domElement;e.removeEventListener("touchstart",this._mouseDownHandler),e.removeEventListener("touchmove",this._mouseMoveHandler),e.removeEventListener("touchend",this._mouseUpHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseup",this._mouseUpHandler),e.removeEventListener("mousewheel",this._mouseWheelHandler),this.animation&&this.animation.off("frame",this.update),this.stopAllAnimation()},getDistance:function(){return this._distance},setDistance:function(e){this._distance=e,this._needsUpdate=!0},getAlpha:function(){return this._theta/Math.PI*180},getBeta:function(){return-this._phi/Math.PI*180},getCenter:function(){return this._center.toArray()},setAlpha:function(e){e=Math.max(Math.min(this.maxAlpha,e),this.minAlpha),this._theta=e/180*Math.PI,this._needsUpdate=!0},setBeta:function(e){e=Math.max(Math.min(this.maxBeta,e),this.minBeta),this._phi=-e/180*Math.PI,this._needsUpdate=!0},setCenter:function(e){this._center.setArray(e)},setOption:function(e){e=e||{},["autoRotate","autoRotateAfterStill","autoRotateDirection","autoRotateSpeed","damping","minDistance","maxDistance","minAlpha","maxAlpha","minBeta","maxBeta","rotateSensitivity","zoomSensitivity","panSensitivity"].forEach(function(t){null!=e[t]&&(this[t]=e[t])},this),null!=e.distance&&this.setDistance(e.distance),null!=e.alpha&&this.setAlpha(e.alpha),null!=e.beta&&this.setBeta(e.beta),e.center&&this.setCenter(e.center)},animateTo:function(e){var t=this,r={},n={},i=this.animation;if(i)return null!=e.distance&&(r.distance=this.getDistance(),n.distance=e.distance),null!=e.alpha&&(r.alpha=this.getAlpha(),n.alpha=e.alpha),null!=e.beta&&(r.beta=this.getBeta(),n.beta=e.beta),null!=e.center&&(r.center=this.getCenter(),n.center=e.center),this._addAnimator(i.animate(r).when(e.duration||1e3,n).during(function(){null!=r.alpha&&t.setAlpha(r.alpha),null!=r.beta&&t.setBeta(r.beta),null!=r.distance&&t.setDistance(r.distance),null!=r.center&&t.setCenter(r.center),t._needsUpdate=!0}).done(e.done)).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e0},update:function(e){if(e=e||16,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)>.01||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(this._updateDistance(Math.min(e,50)),this._updatePan(Math.min(e,50)),this._updateRotate(Math.min(e,50)),this._updateTransform(),this.target.update(),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,this.damping)},_updateDistance:function(e){this._setDistance(this._distance+this._zoomSpeed*e/20),this._zoomSpeed*=this.damping},_setDistance:function(e){this._distance=Math.max(Math.min(e,this.maxDistance),this.minDistance)},_updatePan:function(e){var t=this._panVelocity,r=this._distance,n=this.target,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.target,t=new ot,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.target){var e=new ot;e.eulerFromQuat(this.target.rotation.normalize(),"ZYX"),this._theta=-e.x,this._phi=-e.y,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this._setDistance(this.target.position.dist(this._center))}},_mouseDownHandler:function(e){if(!this._isAnimating()){var t=e.clientX,r=e.clientY;if(e.targetTouches){var n=e.targetTouches[0];t=n.clientX,r=n.clientY,this._mode="rotate",this._processGesture(e,"start")}var i=this.domElement;i.addEventListener("touchmove",this._mouseMoveHandler),i.addEventListener("touchend",this._mouseUpHandler),i.addEventListener("mousemove",this._mouseMoveHandler),i.addEventListener("mouseup",this._mouseUpHandler),0===e.button?this._mode="rotate":1===e.button&&(this._mode="pan"),this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=t,this._mouseY=r}},_mouseMoveHandler:function(e){if(!this._isAnimating()){var t,r=e.clientX,n=e.clientY;if(e.targetTouches){var i=e.targetTouches[0];r=i.clientX,n=i.clientY,t=this._processGesture(e,"change")}var a=We(this.panSensitivity),o=We(this.rotateSensitivity);t||("rotate"===this._mode?(this._rotateVelocity.y=(r-this._mouseX)/this.domElement.clientHeight*2*o[0],this._rotateVelocity.x=(n-this._mouseY)/this.domElement.clientWidth*2*o[1]):"pan"===this._mode&&(this._panVelocity.x=(r-this._mouseX)/this.domElement.clientWidth*a[0]*400,this._panVelocity.y=(-n+this._mouseY)/this.domElement.clientHeight*a[1]*400)),this._mouseX=r,this._mouseY=n,e.preventDefault()}},_mouseWheelHandler:function(e){if(!this._isAnimating()){var t=e.wheelDelta||-e.detail;0!==t&&this._zoomHandler(e,t>0?-1:1)}},_pinchHandler:function(e){this._isAnimating()||this._zoomHandler(e,e.pinchScale>1?-.4:.4)},_zoomHandler:function(e,t){var r=Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance));this._zoomSpeed=t*Math.max(r/40*this.zoomSensitivity,.2),this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),e.preventDefault()},_mouseUpHandler:function(e){var t=this.domElement;t.removeEventListener("touchmove",this._mouseMoveHandler),t.removeEventListener("touchend",this._mouseUpHandler),t.removeEventListener("mousemove",this._mouseMoveHandler),t.removeEventListener("mouseup",this._mouseUpHandler),this._processGesture(e,"end")},_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},_processGesture:function(e,t){var r=this._gestureMgr;"start"===t&&r.clear();var n=r.recognize(e,null,this.domElement);if("end"===t&&r.clear(),n){var i=n.type;e.gestureEvent=i,this._pinchHandler(n.event)}return n}});Object.defineProperty(ga.prototype,"autoRotate",{get:function(){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}}),Object.defineProperty(ga.prototype,"target",{get:function(){return this._target},set:function(e){ +e&&e.target&&this.setCenter(e.target.toArray()),this._target=e,this.decomposeTransform()}});var ya=it.vec4,xa=function(e,t,r,n){e=e||0,t=t||0,r=r||0,n=n||0,this._array=ya.fromValues(e,t,r,n),this._dirty=!0};xa.prototype={constructor:xa,add:function(e){return ya.add(this._array,this._array,e._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 xa(this.x,this.y,this.z,this.w)},copy:function(e){return ya.copy(this._array,e._array),this._dirty=!0,this},dist:function(e){return ya.dist(this._array,e._array)},distance:function(e){return ya.distance(this._array,e._array)},div:function(e){return ya.div(this._array,this._array,e._array),this._dirty=!0,this},divide:function(e){return ya.divide(this._array,this._array,e._array),this._dirty=!0,this},dot:function(e){return ya.dot(this._array,e._array)},len:function(){return ya.len(this._array)},length:function(){return ya.length(this._array)},lerp:function(e,t,r){return ya.lerp(this._array,e._array,t._array,r),this._dirty=!0,this},min:function(e){return ya.min(this._array,this._array,e._array),this._dirty=!0,this},max:function(e){return ya.max(this._array,this._array,e._array),this._dirty=!0,this},mul:function(e){return ya.mul(this._array,this._array,e._array),this._dirty=!0,this},multiply:function(e){return ya.multiply(this._array,this._array,e._array),this._dirty=!0,this},negate:function(){return ya.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return ya.normalize(this._array,this._array),this._dirty=!0,this},random:function(e){return ya.random(this._array,e),this._dirty=!0,this},scale:function(e){return ya.scale(this._array,this._array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return ya.scaleAndAdd(this._array,this._array,e._array,t),this._dirty=!0,this},sqrDist:function(e){return ya.sqrDist(this._array,e._array)},squaredDistance:function(e){return ya.squaredDistance(this._array,e._array)},sqrLen:function(){return ya.sqrLen(this._array)},squaredLength:function(){return ya.squaredLength(this._array)},sub:function(e){return ya.sub(this._array,this._array,e._array),this._dirty=!0,this},subtract:function(e){return ya.subtract(this._array,this._array,e._array),this._dirty=!0,this},transformMat4:function(e){return ya.transformMat4(this._array,this._array,e._array),this._dirty=!0,this},transformQuat:function(e){return ya.transformQuat(this._array,this._array,e._array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}};var Ta=Object.defineProperty;if(Ta){var Ea=xa.prototype;Ta(Ea,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),Ta(Ea,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),Ta(Ea,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}}),Ta(Ea,"w",{get:function(){return this._array[3]},set:function(e){this._array[3]=e,this._dirty=!0}})}xa.add=function(e,t,r){return ya.add(e._array,t._array,r._array),e._dirty=!0,e},xa.set=function(e,t,r,n,i){ya.set(e._array,t,r,n,i),e._dirty=!0},xa.copy=function(e,t){return ya.copy(e._array,t._array),e._dirty=!0,e},xa.dist=function(e,t){return ya.distance(e._array,t._array)},xa.distance=xa.dist,xa.div=function(e,t,r){return ya.divide(e._array,t._array,r._array),e._dirty=!0,e},xa.divide=xa.div,xa.dot=function(e,t){return ya.dot(e._array,t._array)},xa.len=function(e){return ya.length(e._array)},xa.lerp=function(e,t,r,n){return ya.lerp(e._array,t._array,r._array,n),e._dirty=!0,e},xa.min=function(e,t,r){return ya.min(e._array,t._array,r._array),e._dirty=!0,e},xa.max=function(e,t,r){return ya.max(e._array,t._array,r._array),e._dirty=!0,e},xa.mul=function(e,t,r){return ya.multiply(e._array,t._array,r._array),e._dirty=!0,e},xa.multiply=xa.mul,xa.negate=function(e,t){return ya.negate(e._array,t._array),e._dirty=!0,e},xa.normalize=function(e,t){return ya.normalize(e._array,t._array),e._dirty=!0,e},xa.random=function(e,t){return ya.random(e._array,t),e._dirty=!0,e},xa.scale=function(e,t,r){return ya.scale(e._array,t._array,r),e._dirty=!0,e},xa.scaleAndAdd=function(e,t,r,n){return ya.scaleAndAdd(e._array,t._array,r._array,n),e._dirty=!0,e},xa.sqrDist=function(e,t){return ya.sqrDist(e._array,t._array)},xa.squaredDistance=xa.sqrDist,xa.sqrLen=function(e){return ya.sqrLen(e._array)},xa.squaredLength=xa.sqrLen,xa.sub=function(e,t,r){return ya.subtract(e._array,t._array,r._array),e._dirty=!0,e},xa.subtract=xa.sub,xa.transformMat4=function(e,t,r){return ya.transformMat4(e._array,t._array,r._array),e._dirty=!0,e},xa.transformQuat=function(e,t,r){return ya.transformQuat(e._array,t._array,r._array),e._dirty=!0,e};var ba=Qe.extend(function(){return{dom:null,renderer:null,camera:null,_boundingBox:new pt,_hotspotRoot:null,_hotspots:[]}},function(){if(!this.dom||!this.renderer||!this.camera)throw new Error("Tip manager needs `root`, `camera`, `renderer`");var e=this._hotspotRoot=document.createElement("div");e.style.cssText="position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;",this.dom.appendChild(e)},{setBoundingBox:function(e,t){this._boundingBox.min.setArray(e),this._boundingBox.max.setArray(t)},add:function(e,t){if("string"==typeof t){var r=document.createElement("div");r.innerHTML=t,t=r}return t.classList.add("qmv-annotation"),t.style.position="absolute",this._hotspotRoot.appendChild(t),this._hotspots.push({position:e,dom:t}),t},remove:function(e){for(var t=-1,r=0;r=0&&(this._hotspots.splice(t,1),this._hotspotRoot.removeChild(e))},update:function(){var e=new xa,t=new pt;this._hotspots.forEach(function(r){var n=r.position;e.set(n[0],n[1],n[2],1),e.transformMat4(this.camera.viewMatrix);var i=e.z;e.transformMat4(this.camera.projectionMatrix),e.scale(1/e.w);var a=.5*(e.x+1)*this.renderer.getWidth(),o=.5*(e.y+1)*this.renderer.getHeight();r.dom.style.left=a+"px",r.dom.style.top=this.renderer.getHeight()-o+"px";null==r.farAlpha||r.farAlpha,null==r.nearAlpha||r.nearAlpha;t.copy(this._boundingBox),t.applyTransform(this.camera.viewMatrix);t.max.z,t.min.z,t.max.z;r.dom.style.opacity=1,r.onupdate&&r.onupdate(a,o)},this)}});kt.import("@export qmv.ground.vertex\n@import qtek.lambert.vertex\n@end\n\n\n@export qmv.ground.fragment\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float gridSize: 5;\nuniform float gridSize2: 1;\nuniform vec4 gridColor: [0, 0, 0, 1];\nuniform vec4 gridColor2: [0.3, 0.3, 0.3, 1];\n\nuniform float glossiness: 0.7;\n\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import qtek.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import qtek.header.ambient_sh_light\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import qtek.header.directional_light\n#endif\n\n@import qtek.plugin.compute_shadow_map\n\nvoid main()\n{\n gl_FragColor = color;\n\n float wx = v_WorldPosition.x;\n float wz = v_WorldPosition.z;\n float x0 = abs(fract(wx / gridSize - 0.5) - 0.5) / fwidth(wx) * gridSize / 2.0;\n float z0 = abs(fract(wz / gridSize - 0.5) - 0.5) / fwidth(wz) * gridSize / 2.0;\n\n float x1 = abs(fract(wx / gridSize2 - 0.5) - 0.5) / fwidth(wx) * gridSize2;\n float z1 = abs(fract(wz / gridSize2 - 0.5) - 0.5) / fwidth(wz) * gridSize2;\n\n float v0 = 1.0 - clamp(min(x0, z0), 0.0, 1.0);\n float v1 = 1.0 - clamp(min(x1, z1), 0.0, 1.0);\n if (v0 > 0.1) {\n gl_FragColor = mix(gl_FragColor, gridColor, v0);\n }\n else {\n gl_FragColor = mix(gl_FragColor, gridColor2, v1);\n }\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {\n diffuseColor += ambientLightColor[_idx_];\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_, v_Normal) * ambientSHLightColor[_idx_];\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 i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float ndl = dot(v_Normal, normalize(lightDirection));\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 diffuseColor += lightColor * clamp(ndl, 0.0, 1.0) * shadowContrib;\n }\n#endif\n\n#ifdef SSAOMAP_ENABLED\n diffuseColor *= texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n gl_FragColor.a *= 1.0 - clamp(length(v_WorldPosition.xz) / 30.0, 0.0, 1.0);\n\n}\n\n@end");var Sa=["diffuseMap","normalMap","emissiveMap","metalnessMap","roughnessMap","specularMap","glossinessMap"];qe.prototype.init=function(e,t){t=t||{},this.root=e,this._animation=new Fn;var r=new tr({devicePixelRatio:t.devicePixelRatio||window.devicePixelRatio});e.appendChild(r.canvas),r.canvas.style.cssText="position:absolute;left:0;top:0",this._renderer=r,this._renderMain=new Ce(r,t.shadow,"perspective"),this._renderMain.afterRenderScene=function(e,t,r){this.trigger("renderscene",e,t,r)}.bind(this),this._renderMain.afterRenderAll=function(e,t,r){this.trigger("afterrender",e,t,r)}.bind(this),this._renderMain.preZ=t.preZ||!1;var n=this._cameraControl=new ga({renderer:r,animation:this._animation,domElement:e});n.target=this._renderMain.camera,n.init(),this._hotspotManager=new ba({dom:e,renderer:r,camera:this._renderMain.camera}),this._skeletons=[],this._clips=[],this._takes=[],this._materialsMap={},this._sceneHelper=new Le(this._renderMain.scene),this._sceneHelper.initLight(this._renderMain.scene),this.resize(),t.postEffect&&this.setPostEffect(t.postEffect),t.mainLight&&this.setMainLight(t.mainLight),t.secondaryLight&&this.setSecondaryLight(t.secondaryLight),t.tertiaryLight&&this.setTertiaryLight(t.tertiaryLight),t.ambientCubemapLight&&this.setAmbientCubemapLight(t.ambientCubemapLight),t.ambientLight&&this.setAmbientLight(t.ambientLight),t.environment&&this.setEnvironment(t.environment),this._createGround(),t.ground&&this.setGround(t.ground),this.setCameraControl({distance:20,minDisntance:2,maxDistance:100,center:[0,0,0]}),this._enablePicking=t.picking||!1,this._initHandlers(),n.on("update",function(){this.trigger("updatecamera",{center:n.getCenter(),alpha:n.getAlpha(),beta:n.getBeta(),distance:n.getDistance()}),this.refresh()},this),this.shaderLibrary=Gt.createLibrary()},qe.prototype._createGround=function(){var e=new Dr({isGround:!0,material:new qt({shader:new kt({vertex:kt.source("qmv.ground.vertex"),fragment:kt.source("qmv.ground.fragment")}),transparent:!0}),castShadow:!1,geometry:new Wn});e.material.set("color",[1,1,1,1]),e.scale.set(40,40,1),e.rotation.rotateX(-Math.PI/2),this._groundMesh=e,this._renderMain.scene.add(e)},qe.prototype._addModel=function(e,t,r,n){this.removeModel(),this._renderMain.scene.add(e),this._skeletons=r.slice(),this._modelNode=e,this._setAnimationClips(n),t&&t.length&&(this._nodes=t);var i={};e.traverse(function(e){if(e.material){var t=e.material;i[t.name]=i[t.name]||[],i[t.name].push(t)}},this),this._materialsMap=i,this._updateMaterialsSRGB(),this._stopAccumulating()},qe.prototype._removeAnimationClips=function(){this._clips.forEach(function(e){this._animation.removeClip(e)},this),this._clips=[],this._takes=[]},qe.prototype._setAnimationClips=function(e){function t(){r.refresh()}var r=this;e.forEach(function(e){e.tracks.forEach(function(e){e.target||(e.target=this._nodes[e.targetNodeIndex])},this),e.onframe=t,this._animation.addClip(e),this._takes.push({name:e.name,range:[0,e.life],clip:e})},this),this._clips=e.slice()},qe.prototype._initHandlers=function(){this._picking=new Vn({renderer:this._renderer,scene:this._renderMain.scene,camera:this._renderMain.camera}),this._clickHandler=this._clickHandler.bind(this),this._mouseDownHandler=this._mouseDownHandler.bind(this),this.root.addEventListener("mousedown",this._mouseDownHandler),this.root.addEventListener("click",this._clickHandler)},qe.prototype._mouseDownHandler=function(e){this._startX=e.clientX,this._startY=e.clientY},qe.prototype._clickHandler=function(e){if(this._enablePicking||this._renderMain.isDOFEnabled()){var t=e.clientX-this._startX,r=e.clientY-this._startY;if(!(Math.sqrt(t*t+r*r)>=40)){var n=this._picking.pick(e.clientX,e.clientY,!0);n&&!n.target.isGround?(this._renderMain.setDOFFocusOnPoint(n.distance),this.trigger("doffocus",n),this._selectResult=n,this.trigger("select",n),this.refresh()):(this._selectResult&&this.trigger("unselect",this._selectResult),this._selectResult=null)}}},qe.prototype.enablePicking=function(){this._enablePicking=!0},qe.prototype.disablePicking=function(){this._enablePicking=!1},qe.prototype.setModelUpAxis=function(e){var t=this._modelNode;t&&(t.position.set(0,0,0),t.scale.set(1,1,1),t.rotation.identity(),"z"===e.toLowerCase()&&t.rotation.identity().rotateX(-Math.PI/2),this.autoFitModel())},qe.prototype.setTextureFlipY=function(e){if(this._modelNode){for(var t in this._materialsMap)for(var r=0;r1||o<0){r=!0;break}}if(r)for(var n=0;n=0&&s.splice(n,1),u[e]=null}}t=t||{};var i=this._materialsMap[e],a=this,o=this._textureFlipY;if(!i||!i.length)return void console.warn("Material %s not exits",e);var s=i[0].shader.getEnabledTextures(),u={};["diffuseMap","normalMap","parallaxOcclusionMap","emissiveMap"].forEach(function(e){n(e)},this),i[0].shader.isDefined("fragment","USE_METALNESS")?["metalnessMap","roughnessMap"].forEach(function(e){n(e)},this):["specularMap","glossinessMap"].forEach(function(e){n(e)},this),(u.normalMap||u.parallaxOcclusionMap)&&this._modelNode.traverse(function(t){t.material&&t.material.name===e&&(t.geometry.attributes.tangent.value||t.geometry.generateTangents())}),i.forEach(function(e){null!=t.transparent&&(e.transparent=!!t.transparent,e.depthMask=!t.transparent),["color","emission","specularColor"].forEach(function(r){null!=t[r]&&e.set(r,na.parseColor(t[r]))}),["alpha","alphaCutoff","metalness","roughness","glossiness","emissionIntensity","uvRepeat","parallaxOcclusionScale"].forEach(function(r){null!=t[r]&&e.set(r,t[r])});for(var r in u)e.set(r,u[r]);e.attachShader(this.shaderLibrary.get("qtek."+(this._shaderName||"standard"),{fragmentDefines:e.shader.fragmentDefines,textures:s,vertexDefines:e.shader.vertexDefines,precision:e.shader.precision}),!0)},this),this.refresh()},qe.prototype.getMaterial=function(e){function t(e){var t=n.get(e);if(!t)return"";for(var r=t.image;r.srcImage;)r=r.srcImage;return r&&r.src||""}var r=this._materialsMap[e];if(!r)return void console.warn("Material %s not exits",e);var n=r[0],i={name:e};return["color","emission"].forEach(function(e){i[e]=na.stringifyColor(n.get(e),"hex")}),["alpha","alphaCutoff","emissionIntensity","uvRepeat","parallaxOcclusionScale"].forEach(function(e){i[e]=n.get(e)}),["diffuseMap","normalMap","parallaxOcclusionMap","emissiveMap"].forEach(function(e){i[e]=t(e)}),n.shader.isDefined("fragment","USE_METALNESS")?(["metalness","roughness"].forEach(function(e){i[e]=n.get(e)}),["metalnessMap","roughnessMap"].forEach(function(e){i[e]=t(e)}),i.type="pbrMetallicRoughness"):(i.specularColor=na.stringifyColor(n.get("specularColor"),"hex"),i.glossiness=n.get("glossiness"),["specularMap","glossinessMap"].forEach(function(e){i[e]=t(e)}),i.type="pbrSpecularGlossiness"),i},qe.prototype.setGround=function(e){this._groundMesh.invisible=!e.show,this.refresh()},qe.prototype.getMaterialsNames=function(){return Object.keys(this._materialsMap)},qe.prototype.setPostEffect=function(e){this._renderMain.setPostEffect(e),this._updateMaterialsSRGB(),this.refresh()},qe.prototype.start=function(){if(this._disposed)return void console.warn("Viewer already disposed");this._animation.start(),this._animation.on("frame",this._loop,this)},qe.prototype.stop=function(){this._animation.stop(),this._animation.off("frame",this._loop)},qe.prototype.addHotspot=function(e,t){return this._hotspotManager.add(e,t)},qe.prototype.setPose=function(e){this._clips.forEach(function(t){t.setTime(e)}),this._skeletons.forEach(function(e){e.update()}),this.refresh()},qe.prototype.getAnimationDuration=function(){var e=0;return this._clips.forEach(function(t){e=Math.max(t.life,e)}),e},qe.prototype.refresh=function(){this._needsRefresh=!0},qe.prototype.getRenderer=function(){return this._renderer},qe.prototype._updateMaterialsSRGB=function(){var e=this._renderMain.isLinearSpace();for(var t in this._materialsMap)for(var r=this._materialsMap[t],n=0;n0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},o.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},o.cross=function(e,t,n){var a=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=a,e},o.lerp=function(e,t,n,a){var i=t[0],r=t[1];return e[0]=i+a*(n[0]-i),e[1]=r+a*(n[1]-r),e},o.random=function(e,t){t=t||1;var n=2*a()*Math.PI;return e[0]=Math.cos(n)*t,e[1]=Math.sin(n)*t,e},o.transformMat2=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[2]*i,e[1]=n[1]*a+n[3]*i,e},o.transformMat2d=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[2]*i+n[4],e[1]=n[1]*a+n[3]*i+n[5],e},o.transformMat3=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[3]*i+n[6],e[1]=n[1]*a+n[4]*i+n[7],e},o.transformMat4=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[4]*i+n[12],e[1]=n[1]*a+n[5]*i+n[13],e},o.forEach=function(){var e=o.create();return function(t,n,a,i,r,o){var s,c;for(n||(n=2),a||(a=0),c=i?Math.min(i*n+a,t.length):t.length,s=a;s0&&(r=1/Math.sqrt(r),e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r),e},s.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},s.cross=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[0],s=n[1],c=n[2];return e[0]=i*c-r*s,e[1]=r*o-a*c,e[2]=a*s-i*o,e},s.lerp=function(e,t,n,a){var i=t[0],r=t[1],o=t[2];return e[0]=i+a*(n[0]-i),e[1]=r+a*(n[1]-r),e[2]=o+a*(n[2]-o),e},s.random=function(e,t){t=t||1;var n=2*a()*Math.PI,i=2*a()-1,r=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(n)*r,e[1]=Math.sin(n)*r,e[2]=i*t,e},s.transformMat4=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[3]*a+n[7]*i+n[11]*r+n[15];return o=o||1,e[0]=(n[0]*a+n[4]*i+n[8]*r+n[12])/o,e[1]=(n[1]*a+n[5]*i+n[9]*r+n[13])/o,e[2]=(n[2]*a+n[6]*i+n[10]*r+n[14])/o,e},s.transformMat3=function(e,t,n){var a=t[0],i=t[1],r=t[2];return e[0]=a*n[0]+i*n[3]+r*n[6],e[1]=a*n[1]+i*n[4]+r*n[7],e[2]=a*n[2]+i*n[5]+r*n[8],e},s.transformQuat=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[0],s=n[1],c=n[2],l=n[3],u=l*a+s*r-c*i,p=l*i+c*a-o*r,d=l*r+o*i-s*a,f=-o*a-s*i-c*r;return e[0]=u*l+f*-o+p*-c-d*-s,e[1]=p*l+f*-s+d*-o-u*-c,e[2]=d*l+f*-c+u*-s-p*-o,e},s.rotateX=function(e,t,n,a){var i=[],r=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],r[0]=i[0],r[1]=i[1]*Math.cos(a)-i[2]*Math.sin(a),r[2]=i[1]*Math.sin(a)+i[2]*Math.cos(a),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e},s.rotateY=function(e,t,n,a){var i=[],r=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],r[0]=i[2]*Math.sin(a)+i[0]*Math.cos(a),r[1]=i[1],r[2]=i[2]*Math.cos(a)-i[0]*Math.sin(a),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e},s.rotateZ=function(e,t,n,a){var i=[],r=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],r[0]=i[0]*Math.cos(a)-i[1]*Math.sin(a),r[1]=i[0]*Math.sin(a)+i[1]*Math.cos(a),r[2]=i[2],e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e},s.forEach=function(){var e=s.create();return function(t,n,a,i,r,o){var s,c;for(n||(n=3),a||(a=0),c=i?Math.min(i*n+a,t.length):t.length,s=a;s1?0:Math.acos(i)},s.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},void 0!==e&&(e.vec3=s);var c={};c.create=function(){var e=new n(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},c.clone=function(e){var t=new n(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},c.fromValues=function(e,t,a,i){var r=new n(4);return r[0]=e,r[1]=t,r[2]=a,r[3]=i,r},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,n,a,i){return e[0]=t,e[1]=n,e[2]=a,e[3]=i,e},c.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e},c.subtract=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e},c.sub=c.subtract,c.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e},c.mul=c.multiply,c.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e[3]=t[3]/n[3],e},c.div=c.divide,c.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e[3]=Math.min(t[3],n[3]),e},c.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e[3]=Math.max(t[3],n[3]),e},c.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},c.scaleAndAdd=function(e,t,n,a){return e[0]=t[0]+n[0]*a,e[1]=t[1]+n[1]*a,e[2]=t[2]+n[2]*a,e[3]=t[3]+n[3]*a,e},c.distance=function(e,t){var n=t[0]-e[0],a=t[1]-e[1],i=t[2]-e[2],r=t[3]-e[3];return Math.sqrt(n*n+a*a+i*i+r*r)},c.dist=c.distance,c.squaredDistance=function(e,t){var n=t[0]-e[0],a=t[1]-e[1],i=t[2]-e[2],r=t[3]-e[3];return n*n+a*a+i*i+r*r},c.sqrDist=c.squaredDistance,c.length=function(e){var t=e[0],n=e[1],a=e[2],i=e[3];return Math.sqrt(t*t+n*n+a*a+i*i)},c.len=c.length,c.squaredLength=function(e){var t=e[0],n=e[1],a=e[2],i=e[3];return t*t+n*n+a*a+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 n=t[0],a=t[1],i=t[2],r=t[3],o=n*n+a*a+i*i+r*r;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,n,a){var i=t[0],r=t[1],o=t[2],s=t[3];return e[0]=i+a*(n[0]-i),e[1]=r+a*(n[1]-r),e[2]=o+a*(n[2]-o),e[3]=s+a*(n[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,n){var a=t[0],i=t[1],r=t[2],o=t[3];return e[0]=n[0]*a+n[4]*i+n[8]*r+n[12]*o,e[1]=n[1]*a+n[5]*i+n[9]*r+n[13]*o,e[2]=n[2]*a+n[6]*i+n[10]*r+n[14]*o,e[3]=n[3]*a+n[7]*i+n[11]*r+n[15]*o,e},c.transformQuat=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[0],s=n[1],c=n[2],l=n[3],u=l*a+s*r-c*i,p=l*i+c*a-o*r,d=l*r+o*i-s*a,f=-o*a-s*i-c*r;return e[0]=u*l+f*-o+p*-c-d*-s,e[1]=p*l+f*-s+d*-o-u*-c,e[2]=d*l+f*-c+u*-s-p*-o,e},c.forEach=function(){var e=c.create();return function(t,n,a,i,r,o){var s,c;for(n||(n=4),a||(a=0),c=i?Math.min(i*n+a,t.length):t.length,s=a;s.999999?(a[0]=0,a[1]=0,a[2]=0,a[3]=1,a):(s.cross(e,i,r),a[0]=e[0],a[1]=e[1],a[2]=e[2],a[3]=1+o,f.normalize(a,a))}}(),f.setAxes=function(){var e=p.create();return function(t,n,a,i){return e[0]=a[0],e[3]=a[1],e[6]=a[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],f.normalize(t,f.fromMat3(t,e))}}(),f.clone=c.clone,f.fromValues=c.fromValues,f.copy=c.copy,f.set=c.set,f.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},f.setAxisAngle=function(e,t,n){n*=.5;var a=Math.sin(n);return e[0]=a*t[0],e[1]=a*t[1],e[2]=a*t[2],e[3]=Math.cos(n),e},f.add=c.add,f.multiply=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=t[3],s=n[0],c=n[1],l=n[2],u=n[3];return e[0]=a*u+o*s+i*l-r*c,e[1]=i*u+o*c+r*s-a*l,e[2]=r*u+o*l+a*c-i*s,e[3]=o*u-a*s-i*c-r*l,e},f.mul=f.multiply,f.scale=c.scale,f.rotateX=function(e,t,n){n*=.5;var a=t[0],i=t[1],r=t[2],o=t[3],s=Math.sin(n),c=Math.cos(n);return e[0]=a*c+o*s,e[1]=i*c+r*s,e[2]=r*c-i*s,e[3]=o*c-a*s,e},f.rotateY=function(e,t,n){n*=.5;var a=t[0],i=t[1],r=t[2],o=t[3],s=Math.sin(n),c=Math.cos(n);return e[0]=a*c-r*s,e[1]=i*c+o*s,e[2]=r*c+a*s,e[3]=o*c-i*s,e},f.rotateZ=function(e,t,n){n*=.5;var a=t[0],i=t[1],r=t[2],o=t[3],s=Math.sin(n),c=Math.cos(n);return e[0]=a*c+i*s,e[1]=i*c-a*s,e[2]=r*c+o*s,e[3]=o*c-r*s,e},f.calculateW=function(e,t){var n=t[0],a=t[1],i=t[2];return e[0]=n,e[1]=a,e[2]=i,e[3]=Math.sqrt(Math.abs(1-n*n-a*a-i*i)),e},f.dot=c.dot,f.lerp=c.lerp,f.slerp=function(e,t,n,a){var i,r,o,s,c,l=t[0],u=t[1],p=t[2],d=t[3],f=n[0],h=n[1],m=n[2],v=n[3];return r=l*f+u*h+p*m+d*v,r<0&&(r=-r,f=-f,h=-h,m=-m,v=-v),1-r>1e-6?(i=Math.acos(r),o=Math.sin(i),s=Math.sin((1-a)*i)/o,c=Math.sin(a*i)/o):(s=1-a,c=a),e[0]=s*l+c*f,e[1]=s*u+c*h,e[2]=s*p+c*m,e[3]=s*d+c*v,e},f.invert=function(e,t){var n=t[0],a=t[1],i=t[2],r=t[3],o=n*n+a*a+i*i+r*r,s=o?1/o:0;return e[0]=-n*s,e[1]=-a*s,e[2]=-i*s,e[3]=r*s,e},f.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},f.length=c.length,f.len=f.length,f.squaredLength=c.squaredLength,f.sqrLen=f.squaredLength,f.normalize=c.normalize,f.fromMat3=function(e,t){var n,a=t[0]+t[4]+t[8];if(a>0)n=Math.sqrt(a+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var r=(i+1)%3,o=(i+2)%3;n=Math.sqrt(t[3*i+i]-t[3*r+r]-t[3*o+o]+1),e[i]=.5*n,n=.5/n,e[3]=(t[3*r+o]-t[3*o+r])*n,e[r]=(t[3*r+i]+t[3*i+r])*n,e[o]=(t[3*o+i]+t[3*i+o])*n}return e},f.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},void 0!==e&&(e.quat=f)}(n.exports)}()},function(e,t,n){"use strict";var a=n(68),i=n(22),r=n(11),o=function(){this.__GUID__=r.a.genGUID()};o.__initializers__=[function(e){r.a.extend(this,e)}],r.a.extend(o,a.a),r.a.extend(o.prototype,i.a),t.a=o},function(e,t,n){"use strict";function a(e,t,n){return en?n:e}var i=n(0),r=n.n(i),o=r.a.vec3,s=function(e,t,n){e=e||0,t=t||0,n=n||0,this._array=o.fromValues(e,t,n),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,n){return this._array[0]=e,this._array[1]=t,this._array[2]=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._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,n){return o.lerp(this._array,e._array,t._array,n),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 n=-1/t[2];t[0]=e[0]*t[0]*n,t[1]=e[5]*t[1]*n,t[2]=(e[10]*t[2]+e[14])*n}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 c=Object.defineProperty;if(c){var l=s.prototype;c(l,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),c(l,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),c(l,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}})}s.add=function(e,t,n){return o.add(e._array,t._array,n._array),e._dirty=!0,e},s.set=function(e,t,n,a){o.set(e._array,t,n,a),e._dirty=!0},s.copy=function(e,t){return o.copy(e._array,t._array),e._dirty=!0,e},s.cross=function(e,t,n){return o.cross(e._array,t._array,n._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,n){return o.divide(e._array,t._array,n._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,n,a){return o.lerp(e._array,t._array,n._array,a),e._dirty=!0,e},s.min=function(e,t,n){return o.min(e._array,t._array,n._array),e._dirty=!0,e},s.max=function(e,t,n){return o.max(e._array,t._array,n._array),e._dirty=!0,e},s.mul=function(e,t,n){return o.multiply(e._array,t._array,n._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,n){return o.scale(e._array,t._array,n),e._dirty=!0,e},s.scaleAndAdd=function(e,t,n,a){return o.scaleAndAdd(e._array,t._array,n._array,a),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,n){return o.subtract(e._array,t._array,n._array),e._dirty=!0,e},s.subtract=s.sub,s.transformMat3=function(e,t,n){return o.transformMat3(e._array,t._array,n._array),e._dirty=!0,e},s.transformMat4=function(e,t,n){return o.transformMat4(e._array,t._array,n._array),e._dirty=!0,e},s.transformQuat=function(e,t,n){return o.transformQuat(e._array,t._array,n._array),e._dirty=!0,e};var u=Math.atan2,p=Math.asin,d=Math.abs;s.eulerFromQuat=function(e,t,n){e._dirty=!0,t=t._array;var i=e._array,r=t[0],o=t[1],s=t[2],c=t[3],l=r*r,d=o*o,f=s*s,h=c*c,n=(n||"XYZ").toUpperCase();switch(n){case"XYZ":i[0]=u(2*(r*c-o*s),h-l-d+f),i[1]=p(a(2*(r*s+o*c),-1,1)),i[2]=u(2*(s*c-r*o),h+l-d-f);break;case"YXZ":i[0]=p(a(2*(r*c-o*s),-1,1)),i[1]=u(2*(r*s+o*c),h-l-d+f),i[2]=u(2*(r*o+s*c),h-l+d-f);break;case"ZXY":i[0]=p(a(2*(r*c+o*s),-1,1)),i[1]=u(2*(o*c-s*r),h-l-d+f),i[2]=u(2*(s*c-r*o),h-l+d-f);break;case"ZYX":i[0]=u(2*(r*c+s*o),h-l-d+f),i[1]=p(a(2*(o*c-r*s),-1,1)),i[2]=u(2*(r*o+s*c),h+l-d-f);break;case"YZX":i[0]=u(2*(r*c-s*o),h-l+d-f),i[1]=u(2*(o*c-r*s),h+l-d-f),i[2]=p(a(2*(r*o+s*c),-1,1));break;case"XZY":i[0]=u(2*(r*c+o*s),h-l+d-f),i[1]=u(2*(r*s+o*c),h+l-d-f),i[2]=p(a(2*(s*c-r*o),-1,1));break;default:console.warn("Unkown order: "+n)}return e},s.eulerFromMat3=function(e,t,n){var i=t._array,r=i[0],o=i[3],s=i[6],c=i[1],l=i[4],f=i[7],h=i[2],m=i[5],v=i[8],_=e._array,n=(n||"XYZ").toUpperCase();switch(n){case"XYZ":_[1]=p(a(s,-1,1)),d(s)<.99999?(_[0]=u(-f,v),_[2]=u(-o,r)):(_[0]=u(m,l),_[2]=0);break;case"YXZ":_[0]=p(-a(f,-1,1)),d(f)<.99999?(_[1]=u(s,v),_[2]=u(c,l)):(_[1]=u(-h,r),_[2]=0);break;case"ZXY":_[0]=p(a(m,-1,1)),d(m)<.99999?(_[1]=u(-h,v),_[2]=u(-o,l)):(_[1]=0,_[2]=u(c,r));break;case"ZYX":_[1]=p(-a(h,-1,1)),d(h)<.99999?(_[0]=u(m,v),_[2]=u(c,r)):(_[0]=0,_[2]=u(-o,l));break;case"YZX":_[2]=p(a(c,-1,1)),d(c)<.99999?(_[0]=u(-f,l),_[1]=u(-h,r)):(_[0]=0,_[1]=u(s,v));break;case"XZY":_[2]=p(-a(o,-1,1)),d(o)<.99999?(_[0]=u(m,l),_[1]=u(s,r)):(_[0]=u(-f,v),_[1]=0);break;default:console.warn("Unkown order: "+n)}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,n){"use strict";var a=n(1),i=n(6),r=n(23),o=a.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,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1},function(){this._cache=new r.a},{getWebGLTexture:function(e){var t=e.gl,n=this._cache;return n.use(e.__GUID__),n.miss("webgl_texture")&&n.put("webgl_texture",t.createTexture()),this.dynamic?this.update(e):n.isDirty()&&(this.update(e),n.fresh()),n.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 n=e.getGLExtension("EXT_sRGB");this.format!==o.SRGB||n||(this.format=o.RGB),this.format!==o.SRGB_ALPHA||n||(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.__GUID__);var n=t.get("webgl_texture");n&&e.gl.deleteTexture(n),t.deleteContext(e.__GUID__)},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,n){"use strict";function a(){return{locations:{},attriblocations:{}}}function i(e,t,n){if(!e.getShaderParameter(t,e.COMPILE_STATUS))return[e.getShaderInfoLog(t),r(n)].join("\n")}function r(e){for(var t=e.split("\n"),n=0,a=t.length;n0&&a.push("#define "+i.toUpperCase()+"_COUNT "+r)}for(var o in n){n[o].enabled&&a.push("#define "+o.toUpperCase()+"_ENABLED")}for(var o in e){var s=e[o];null===s?a.push("#define "+o):a.push("#define "+o+" "+s.toString())}return a.join("\n")},_unrollLoop:function(e,t){function n(e,n,i,r){var o="";isNaN(n)&&(n=n in t?t[n]:a[n]),isNaN(i)&&(i=i in t?t[i]:a[i]);for(var s=parseInt(n);s=0)n.attribSemantics[c]={symbol:r,type:u},p=!1;else if(E.indexOf(c)>=0){var d=!1,f=c;c.match(/TRANSPOSE$/)&&(d=!0,f=c.slice(0,-9)),n.matrixSemantics[c]={symbol:r,type:u,isTranspose:d,semanticNoTranspose:f},p=!1}else if(T.indexOf(c)>=0)n.uniformSemantics[c]={symbol:r,type:u},p=!1;else if("unconfigurable"===c)p=!1;else{if(!(l=n._parseDefaultValue(i,c)))throw new Error('Unkown semantic "'+c+'"');c=""}p&&(t[r]={type:u,value:o?y.array:l||y[i],semantic:c||null})}return["uniform",i,r,o].join(" ")+";\n"}}var t={},n=this,a="vertex";this._uniformList=[],this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(m,e),a="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(m,e),n.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=t},_parseDefaultValue:function(e,t){var n=/\[\s*(.*)\s*\]/;{if("vec2"!==e&&"vec3"!==e&&"vec4"!==e)return"bool"===e?function(){return"true"===t.toLowerCase()}:"float"===e?function(){return parseFloat(t)}:"int"===e?function(){return parseInt(t)}:void 0;var a=n.exec(t)[1];if(a){var i=a.split(/\s*,\s*/);return function(){return new l.a.Float32Array(i)}}}},createUniforms:function(){var e={};for(var t in this.uniformTemplates){var n=this.uniformTemplates[t];e[t]={type:n.type,value:n.value()}}return e},attached:function(){this._attacheMaterialNumber++},detached:function(){this._attacheMaterialNumber--},isAttachedToAny:function(){return 0!==this._attacheMaterialNumber},_parseAttributes:function(){function e(e,a,i,r,o){if(a&&i){var s=1;switch(a){case"vec4":s=4;break;case"vec3":s=3;break;case"vec2":s=2;break;case"float":s=1}if(t[i]={type:"float",size:s,semantic:o||null},o){if(b.indexOf(o)<0)throw new Error('Unkown semantic "'+o+'"');n.attribSemantics[o]={symbol:i,type:a}}}return["attribute",a,i].join(" ")+";\n"}var t={},n=this;this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(v,e),this.attributeTemplates=t},_parseDefines:function(){function e(e,a,i){var r="vertex"===n?t.vertexDefines:t.fragmentDefines;return r[a]||(r[a]="false"!=i&&("true"==i||(i?isNaN(parseFloat(i))?i:parseFloat(i):null))),""}var t=this,n="vertex";this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(_,e),n="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(_,e)},_buildProgram:function(e,t,n){var a=this._cache;a.get("program")&&e.deleteProgram(a.get("program"));var r=e.createProgram(),o=e.createShader(e.VERTEX_SHADER);e.shaderSource(o,t),e.compileShader(o);var s=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(s,n),e.compileShader(s);var c=i(e,o,t);if(c)return c;if(c=i(e,s,n))return c;if(e.attachShader(r,o),e.attachShader(r,s),this.attribSemantics.POSITION)e.bindAttribLocation(r,0,this.attribSemantics.POSITION.symbol);else{var l=Object.keys(this.attributeTemplates);e.bindAttribLocation(r,0,l[0])}if(e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS))return"Could not link program\nVALIDATE_STATUS: "+e.getProgramParameter(r,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]";for(var u=0;u1&&t.texParameterf(t.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===a){e.getGLExtension("OES_texture_half_float")||(a=i.a.FLOAT)}if(this.mipmaps.length)for(var o=this.width,s=this.height,c=0;c=a.a.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,n,o,i,r,0,t.pixels):e.texImage2D(e.TEXTURE_2D,n,o,i,r,0,o,s,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(){var e,t;return this.image?(e=this.image.width,t=this.image.height):(e=this.width,t=this.height),o(e)&&o(t)},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 n=new Image;t&&(n.crossOrigin=t);var a=this;return n.onload=function(){a.dirty(),a.trigger("success",a),n.onload=null},n.onerror=function(){a.trigger("error",a),n.onerror=null},n.src=e,this.image=n,this}});Object.defineProperty(s.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(s.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=s},function(e,t,n){"use strict";t.a={DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:33995,TEXTURE12:33996,TEXTURE13:33997,TEXTURE14:33998,TEXTURE15:33999,TEXTURE16:34e3,TEXTURE17:34001,TEXTURE18:34002,TEXTURE19:34003,TEXTURE20:34004,TEXTURE21:34005,TEXTURE22:34006,TEXTURE23:34007,TEXTURE24:34008,TEXTURE25:34009,TEXTURE26:34010,TEXTURE27:34011,TEXTURE28:34012,TEXTURE29:34013,TEXTURE30:34014,TEXTURE31:34015,ACTIVE_TEXTURE:34016,REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,INT_VEC2:35667,INT_VEC3:35668,INT_VEC4:35669,BOOL:35670,BOOL_VEC2:35671,BOOL_VEC3:35672,BOOL_VEC4:35673,FLOAT_MAT2:35674,FLOAT_MAT3:35675,FLOAT_MAT4:35676,SAMPLER_2D:35678,SAMPLER_CUBE:35680,VERTEX_ATTRIB_ARRAY_ENABLED:34338,VERTEX_ATTRIB_ARRAY_SIZE:34339,VERTEX_ATTRIB_ARRAY_STRIDE:34340,VERTEX_ATTRIB_ARRAY_TYPE:34341,VERTEX_ATTRIB_ARRAY_NORMALIZED:34922,VERTEX_ATTRIB_ARRAY_POINTER:34373,VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:34975,COMPILE_STATUS:35713,LOW_FLOAT:36336,MEDIUM_FLOAT:36337,HIGH_FLOAT:36338,LOW_INT:36339,MEDIUM_INT:36340,HIGH_INT:36341,FRAMEBUFFER:36160,RENDERBUFFER:36161,RGBA4:32854,RGB5_A1:32855,RGB565:36194,DEPTH_COMPONENT16:33189,STENCIL_INDEX:6401,STENCIL_INDEX8:36168,DEPTH_STENCIL:34041,RENDERBUFFER_WIDTH:36162,RENDERBUFFER_HEIGHT:36163,RENDERBUFFER_INTERNAL_FORMAT:36164,RENDERBUFFER_RED_SIZE:36176,RENDERBUFFER_GREEN_SIZE:36177,RENDERBUFFER_BLUE_SIZE:36178,RENDERBUFFER_ALPHA_SIZE:36179,RENDERBUFFER_DEPTH_SIZE:36180,RENDERBUFFER_STENCIL_SIZE:36181,FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:36048,FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:36049,FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:36050,FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:36051,COLOR_ATTACHMENT0:36064,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306,NONE:0,FRAMEBUFFER_COMPLETE:36053,FRAMEBUFFER_INCOMPLETE_ATTACHMENT:36054,FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:36055,FRAMEBUFFER_INCOMPLETE_DIMENSIONS:36057,FRAMEBUFFER_UNSUPPORTED:36061,FRAMEBUFFER_BINDING:36006,RENDERBUFFER_BINDING:36007,MAX_RENDERBUFFER_SIZE:34024,INVALID_FRAMEBUFFER_OPERATION:1286,UNPACK_FLIP_Y_WEBGL:37440,UNPACK_PREMULTIPLY_ALPHA_WEBGL:37441,CONTEXT_LOST_WEBGL:37442,UNPACK_COLORSPACE_CONVERSION_WEBGL:37443,BROWSER_DEFAULT_WEBGL:37444}},function(e,t,n){"use strict";var a=n(2),i=n(0),r=n.n(i),o=r.a.vec3,s=o.copy,c=o.set,l=function(e,t){this.min=e||new a.a(1/0,1/0,1/0),this.max=t||new a.a(-1/0,-1/0,-1/0)};l.prototype={constructor:l,updateFromVertices:function(e){if(e.length>0){var t=this.min,n=this.max,a=t._array,i=n._array;s(a,e[0]),s(i,e[0]);for(var r=1;ri[0]&&(i[0]=o[0]),o[1]>i[1]&&(i[1]=o[1]),o[2]>i[2]&&(i[2]=o[2])}t._dirty=!0,n._dirty=!0}},union:function(e){var t=this.min,n=this.max;return o.min(t._array,t._array,e.min._array),o.max(n._array,n._array,e.max._array),t._dirty=!0,n._dirty=!0,this},intersection:function(e){var t=this.min,n=this.max;return o.max(t._array,t._array,e.min._array),o.min(n._array,n._array,e.max._array),t._dirty=!0,n._dirty=!0,this},intersectBoundingBox:function(e){var t=this.min._array,n=this.max._array,a=e.min._array,i=e.max._array;return!(t[0]>i[0]||t[1]>i[1]||t[2]>i[2]||n[0]=i[0]&&n[1]>=i[1]&&n[2]>=i[2]},containPoint:function(e){var t=this.min._array,n=this.max._array,a=e._array;return t[0]<=a[0]&&t[1]<=a[1]&&t[2]<=a[2]&&n[0]>=a[0]&&n[1]>=a[1]&&n[2]>=a[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(){var e=o.create(),t=o.create(),n=o.create(),a=o.create(),i=o.create(),r=o.create();return function(o){var s=this.min._array,c=this.max._array,l=o._array;return e[0]=l[0]*s[0],e[1]=l[1]*s[0],e[2]=l[2]*s[0],t[0]=l[0]*c[0],t[1]=l[1]*c[0],t[2]=l[2]*c[0],n[0]=l[4]*s[1],n[1]=l[5]*s[1],n[2]=l[6]*s[1],a[0]=l[4]*c[1],a[1]=l[5]*c[1],a[2]=l[6]*c[1],i[0]=l[8]*s[2],i[1]=l[9]*s[2],i[2]=l[10]*s[2],r[0]=l[8]*c[2],r[1]=l[9]*c[2],r[2]=l[10]*c[2],s[0]=Math.min(e[0],t[0])+Math.min(n[0],a[0])+Math.min(i[0],r[0])+l[12],s[1]=Math.min(e[1],t[1])+Math.min(n[1],a[1])+Math.min(i[1],r[1])+l[13],s[2]=Math.min(e[2],t[2])+Math.min(n[2],a[2])+Math.min(i[2],r[2])+l[14],c[0]=Math.max(e[0],t[0])+Math.max(n[0],a[0])+Math.max(i[0],r[0])+l[12],c[1]=Math.max(e[1],t[1])+Math.max(n[1],a[1])+Math.max(i[1],r[1])+l[13],c[2]=Math.max(e[2],t[2])+Math.max(n[2],a[2])+Math.max(i[2],r[2])+l[14],this.min._dirty=!0,this.max._dirty=!0,this}}(),applyProjection:function(e){var t=this.min._array,n=this.max._array,a=e._array,i=t[0],r=t[1],o=t[2],s=n[0],c=n[1],l=t[2],u=n[0],p=n[1],d=n[2];if(1===a[15])t[0]=a[0]*i+a[12],t[1]=a[5]*r+a[13],n[2]=a[10]*o+a[14],n[0]=a[0]*u+a[12],n[1]=a[5]*p+a[13],t[2]=a[10]*d+a[14];else{var f=-1/o;t[0]=a[0]*i*f,t[1]=a[5]*r*f,n[2]=(a[10]*o+a[14])*f,f=-1/l,n[0]=a[0]*s*f,n[1]=a[5]*c*f,f=-1/d,t[2]=(a[10]*d+a[14])*f}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){for(var e=[],t=0;t<8;t++)e[t]=o.fromValues(0,0,0);this.vertices=e}var n=this.min._array,a=this.max._array;return c(e[0],n[0],n[1],n[2]),c(e[1],n[0],a[1],n[2]),c(e[2],a[0],n[1],n[2]),c(e[3],a[0],a[1],n[2]),c(e[4],n[0],n[1],a[2]),c(e[5],n[0],a[1],a[2]),c(e[6],a[0],n[1],a[2]),c(e[7],a[0],a[1],a[2]),this},copy:function(e){var t=this.min,n=this.max;return s(t._array,e.min._array),s(n._array,e.max._array),t._dirty=!0,n._dirty=!0,this},clone:function(){var e=new l;return e.copy(this),e}},t.a=l},function(e,t,n){"use strict";var a=n(0),i=n.n(a),r=n(2),o=i.a.mat4,s=i.a.vec3,c=i.a.mat3,l=i.a.quat,u=function(){this._axisX=new r.a,this._axisY=new r.a,this._axisZ=new r.a,this._array=o.create(),this._dirty=!0};u.prototype={constructor:u,setArray:function(e){for(var t=0;t=0},set:function(e,t){if("object"==typeof e)for(var n in e){var a=e[n];this.set(n,a)}else{var i=this.uniforms[e];i&&(void 0===t&&(console.warn('Uniform value "'+e+'" is undefined'),t=null),i.value=t)}},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){this.shader&&this.shader.detached();var n=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var a=this.uniforms;if(this._enabledUniforms=Object.keys(a),this._enabledUniforms.sort(),t)for(var i in n)a[i]&&(a[i].value=n[i].value);e.attached()},detachShader:function(){this.shader.detached(),this.shader=null,this.uniforms={}},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},dispose:function(e,t){if(t)for(var n in this.uniforms){var a=this.uniforms[n].value;if(a)if(a instanceof i.a)a.dispose(e);else if(Array.isArray(a))for(var r=0;r=n.COLOR_ATTACHMENT0&&r<=n.COLOR_ATTACHMENT0+8&&i.push(r);a.drawBuffersEXT(i)}}this.trigger("beforerender",this,e);var o=this.clearDepth?n.DEPTH_BUFFER_BIT:0;if(n.depthMask(!0),this.clearColor){o|=n.COLOR_BUFFER_BIT,n.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&n.clearColor(s[0],s[1],s[2],s[3])}n.clear(o),this.blendWithPrevious?(n.enable(n.BLEND),this.material.transparent=!0):(n.disable(n.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.renderQueue([d],f)},dispose:function(e){this.material.dispose(e)}});t.a=h},function(e,t,n){"use strict";var a=n(15),i=a.a.extend(function(){return{color:[1,1,1],intensity:1,castShadow:!0,shadowResolution:512,group:0}},{type:"",clone:function(){var e=a.a.prototype.clone.call(this);return e.color=Array.prototype.slice.call(this.color),e.intensity=this.intensity,e.castShadow=this.castShadow,e.shadowResolution=this.shadowResolution,e}});t.a=i},function(e,t,n){"use strict";var a=n(1),i=n(2),r=n(71),o=n(8),s=n(0),c=n.n(s),l=n(7),u=c.a.mat4,p=0,d=a.a.extend({name:"",position:null,rotation:null,scale:null,worldTransform:null,localTransform:null,autoUpdateLocalTransform:!0,_parent:null,_scene:null,_needsUpdateWorldTransform:!0,_inIterating:!1,__depth:0},function(){this.name||(this.name=(this.type||"NODE")+"_"+p++),this.position||(this.position=new i.a),this.rotation||(this.rotation=new r.a),this.scale||(this.scale=new i.a(1,1,1)),this.worldTransform=new o.a,this.localTransform=new o.a,this._children=[]},{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(e){var t=this._scene;if(t){var n=t._nodeRepository;delete n[this.name],n[e]=this}this.name=e},add:function(e){this._inIterating&&console.warn("Add operation can cause unpredictable error when in iterating");var t=e._parent;if(t!==this){t&&t.remove(e),e._parent=this,this._children.push(e);var n=this._scene;n&&n!==e.scene&&e.traverse(this._addSelfToScene,this),e._needsUpdateWorldTransform=!0}},remove:function(e){this._inIterating&&console.warn("Remove operation can cause unpredictable error when in iterating");var t=this._children,n=t.indexOf(e);n<0||(t.splice(n,1),e._parent=null,this._scene&&e.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var e=this._children,t=0;t256?64:o>64?32:o>16?16:8;var s=this.getSkinMatricesTexture();s.width=r,s.height=r,s.pixels&&s.pixels.length===r*r*4||(s.pixels=new Float32Array(r*r*4)),s.pixels.set(i),s.dirty(),t.setUniform(n,"1f","skinMatricesTextureSize",r)}else t.setUniformOfSemantic(n,"SKIN_MATRIX",i)}return a.a.prototype.render.call(this,e,t)},getSkinMatricesTexture:function(){return this._skinMatricesTexture=this._skinMatricesTexture||new r.a({type:i.a.FLOAT,minFilter:i.a.NEAREST,magFilter:i.a.NEAREST,useMipmap:!1,flipY:!1}),this._skinMatricesTexture}});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,n){"use strict";function a(e){return"CANVAS"===e.nodeName||"VIDEO"===e.nodeName||e.complete}var i=n(3),r=n(6),o=n(11),s=n(44),c=s.a.isPowerOfTwo,l=["px","nx","py","ny","pz","nz"],u=i.a.extend(function(){return{image:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},pixels:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},mipmaps:[]}},{update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),this.updateCommon(e);var n=this.format,a=this.type;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var i=e.getGLExtension("EXT_texture_filter_anisotropic");if(i&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===a){e.getGLExtension("OES_texture_half_float")||(a=r.a.FLOAT)}if(this.mipmaps.length)for(var o=this.width,s=this.height,c=0;c0&&this._updateRenderQueue(a)}},_updateLightUniforms:function(){var e=this.lights;e.sort(a);var t=this._lightUniforms;for(var n in t)for(var i in t[n])t[n][i].value.length=0;for(var r=0;ro[0]&&(o[0]=c),l>o[1]&&(o[1]=l),u>o[2]&&(o[2]=u)}n._dirty=!0,a._dirty=!0}},dirty:function(){for(var e=this.getEnabledAttributes(),t=0;t=0){t||(t=f());var n=this.indices;return t[0]=n[3*e],t[1]=n[3*e+1],t[2]=n[3*e+2],t}},setTriangleIndices:function(e,t){var n=this.indices;n[3*e]=t[0],n[3*e+1]=t[1],n[3*e+2]=t[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(e){var t,n=this.vertexCount>65535?c.a.Uint32Array:c.a.Uint16Array;if(e[0]&&e[0].length){var a=0;t=new n(3*e.length);for(var i=0;i=0&&(t.splice(n,1),delete this.attributes[e],!0)},getEnabledAttributes:function(){var e=this._enabledAttributes,t=this._attributeList;if(e)return e;for(var n=[],a=this.vertexCount,i=0;i65535&&(this.indices=new c.a.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,n=this.getEnabledAttributes(),a={},i=0;i0){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,n){"use strict";function a(e,t){this.action=e,this.context=t}var i={trigger:function(e){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(e)){var t=this.__handlers__[e],n=t.length,a=-1,i=arguments;switch(i.length){case 1:for(;++a=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}t.a={get:a}},function(e,t,n){"use strict";var a=n(46),i=a.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=a.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,n){"use strict";var a=n(46),i=a.a.extend({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix._array;this.left=(-1-e[12])/e[0],this.right=(1-e[12])/e[0],this.top=(1-e[13])/e[5],this.bottom=(-1-e[13])/e[5],this.near=-(-1-e[14])/e[10],this.far=-(1-e[14])/e[10]},clone:function(){var e=a.a.prototype.clone.call(this);return e.left=this.left,e.right=this.right,e.near=this.near,e.far=this.far,e.top=this.top,e.bottom=this.bottom,e}});t.a=i},function(e,t,n){"use strict";function a(e,t){for(var n=0,a=1/t,i=e;i>0;)n+=a*(i%t),i=Math.floor(i/t),a/=t;return n}t.a=a},function(e,t,n){"use strict";function a(e){return!e||"none"===e}function i(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}function r(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function o(e){if((e.wrapS===s.a.REPEAT||e.wrapT===s.a.REPEAT)&&e.image){var t=r(e.width),n=r(e.height);if(t!==e.width||n!==e.height){var a=document.createElement("canvas");a.width=t,a.height=n;a.getContext("2d").drawImage(e.image,0,0,t,n),a.srcImage=e.image,e.image=a,e.dirty()}}}var s=n(3),c=n(9),l=n(63),u=n(33),p=n(118),d=n(123),f=n(124),h=n(126),m=n(5);c.a.prototype.setTextureImage=function(e,t,n,i){if(this.shader){var r,o=this;return o.shader.disableTexture(e),a(t)||(r=v.loadTexture(t,n,i,function(t){o.shader.enableTexture(e),n.refresh()}),o.set(e,r)),r}};var v={},_=u.a.createBlank("rgba(255,255,255,0)").image;v.firstNotNull=function(){for(var e=0,t=arguments.length;e3?t[3]=e[3]:t[3]=1,t):(t=h.a(e||"#000",t)||[0,0,0,0],t[0]/=255,t[1]/=255,t[2]/=255,t)},v.stringifyColor=function(e,t){return e=e.slice(),e[0]=Math.round(255*e[0]),e[1]=Math.round(255*e[1]),e[2]=Math.round(255*e[2]),"hex"===t?"#"+((1<<24)+(e[0]<<16)+(e[1]<<8)+e[2]).toString(16).slice(1):h.b(e,t)},v.directionFromAlphaBeta=function(e,t){var n=e/180*Math.PI+Math.PI/2,a=-t/180*Math.PI+Math.PI/2,i=[],r=Math.sin(n);return i[0]=r*Math.cos(a),i[1]=-Math.cos(n),i[2]=r*Math.sin(a),i},v.convertTextureToPowerOfTwo=o,t.a=v},function(e,t,n){"use strict";var a=n(1),i=n(69),r=n(6),o=(n(12),n(7)),s=n(8),c=(n(18),n(9)),l=n(24),u=n(4),p=n(38),d=n(39),f=n(0),h=n.n(f);u.a.import(p.a),u.a.import(d.a);var m=h.a.mat4,v=h.a.vec3,_=m.create,x={},g=a.a.extend(function(){return{canvas:null,_width:100,_height:100,devicePixelRatio: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 i.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}},{resize:function(e,t){var n=this.canvas,a=this.devicePixelRatio;null!=e?(n.style.width=e+"px",n.style.height=t+"px",n.width=e*a,n.height=t*a,this._width=e,this._height=t):(this._width=n.width/a,this._height=n.height/a),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,n,a,i){if("object"==typeof e){var r=e;e=r.x,t=r.y,n=r.width,a=r.height,i=r.devicePixelRatio}i=i||this.devicePixelRatio,this.gl.viewport(e*i,t*i,n*i,a*i),this.viewport={x:e,y:t,width:n,height:a,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},beforeRenderObject:function(){},afterRenderObject:function(){},render:function(e,t,n,a){var i=this.gl;this._sceneRendering=e;var r=this.clearColor;if(this.clearBit){i.colorMask(!0,!0,!0,!0),i.depthMask(!0);var o=this.viewport,s=!1,c=o.devicePixelRatio;(o.width!==this._width||o.height!==this._height||c&&c!==this.devicePixelRatio||o.x||o.y)&&(s=!0,i.enable(i.SCISSOR_TEST),i.scissor(o.x*c,o.y*c,o.width*c,o.height*c)),i.clearColor(r[0],r[1],r[2],r[3]),i.clear(this.clearBit),s&&i.disable(i.SCISSOR_TEST)}n||e.update(!1),t.getScene()||t.update(!0);for(var l=e.opaqueQueue,u=e.transparentQueue,p=e.material,d=0;d0)for(var h=_(),x=v.create(),d=0;d0&&e.min._array[2]<0&&(e.max._array[2]=-1e-20),e.applyProjection(t);var c=e.min._array,l=e.max._array;if(l[0]<-1||c[0]>1||l[1]<-1||c[1]>1||l[2]<-1||c[2]>1)return!0}return!1}}(),disposeScene:function(e){this.disposeNode(e,!0,!0),e.dispose()},disposeNode:function(e,t,n){var a={};e.getParent()&&e.getParent().remove(e),e.traverse(function(e){e.geometry&&t&&e.geometry.dispose(this),e.material&&(a[e.material.__GUID__]=e.material),e.dispose&&e.dispose(this)},this);for(var i in a){a[i].dispose(this,n)}},disposeShader:function(e){e.dispose(this)},disposeGeometry:function(e){e.dispose(this)},disposeTexture:function(e){e.dispose(this)},disposeFrameBuffer:function(e){e.dispose(this)},dispose:function(){},screenToNDC:function(e,t,n){n||(n=new l.a),t=this._height-t;var a=this.viewport,i=n._array;return i[0]=(e-a.x)/a.width,i[0]=2*i[0]-1,i[1]=(t-a.y)/a.height,i[1]=2*i[1]-1,n}});g.opaqueSortFunc=g.prototype.opaqueSortFunc=function(e,t){return e.renderOrder===t.renderOrder?e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__:e.renderOrder-t.renderOrder},g.transparentSortFunc=g.prototype.transparentSortFunc=function(e,t){return e.renderOrder===t.renderOrder?e.__depth===t.__depth?e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__:e.__depth-t.__depth:e.renderOrder-t.renderOrder};var y={IDENTITY:_(),WORLD:_(),VIEW:_(),PROJECTION:_(),WORLDVIEW:_(),VIEWPROJECTION:_(),WORLDVIEWPROJECTION:_(),WORLDINVERSE:_(),VIEWINVERSE:_(),PROJECTIONINVERSE:_(),WORLDVIEWINVERSE:_(),VIEWPROJECTIONINVERSE:_(),WORLDVIEWPROJECTIONINVERSE:_(),WORLDTRANSPOSE:_(),VIEWTRANSPOSE:_(),PROJECTIONTRANSPOSE:_(),WORLDVIEWTRANSPOSE:_(),VIEWPROJECTIONTRANSPOSE:_(),WORLDVIEWPROJECTIONTRANSPOSE:_(),WORLDINVERSETRANSPOSE:_(),VIEWINVERSETRANSPOSE:_(),PROJECTIONINVERSETRANSPOSE:_(),WORLDVIEWINVERSETRANSPOSE:_(),VIEWPROJECTIONINVERSETRANSPOSE:_(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:_()};g.COLOR_BUFFER_BIT=r.a.COLOR_BUFFER_BIT,g.DEPTH_BUFFER_BIT=r.a.DEPTH_BUFFER_BIT,g.STENCIL_BUFFER_BIT=r.a.STENCIL_BUFFER_BIT,t.a=g},function(e,t,n){"use strict";function a(){}var i=n(75),r=function(e){e=e||{},this.name=e.name||"",this.target=e.target,this.life=e.life||1e3,this.delay=e.delay||0,this.gap=e.gap||0,this.playbackRate=e.playbackRate||1,this._initialized=!1,this._elapsedTime=0,this._loop=null!=e.loop&&e.loop,this.setLoop(this._loop),null!=e.easing&&this.setEasing(e.easing),this.onframe=e.onframe||a,this.onfinish=e.onfinish||a,this.onrestart=e.onrestart||a,this._paused=!1};r.prototype={gap:0,life:0,delay:0,setLoop:function(e){this._loop=e,e&&(this._loopRemained="number"==typeof e?e:1e8)},setEasing:function(e){"string"==typeof e&&(e=i.a[e]),this.easing=e},step:function(e,t,n){if(this._initialized||(this._startTime=e+this.delay,this._initialized=!0),null!=this._currentTime&&(t=e-this._currentTime),this._currentTime=e,this._paused)return"paused";if(!(e0?(this._restartInLoop(e),this._loopRemained--,"restart"):(this._needsRemove=!0,"finish"):null}}},setTime:function(e){return this.step(e+this._startTime)},restart:function(e){var t=0;e&&(this._elapse(e),t=this._elapsedTime%this.life),e=e||Date.now(),this._startTime=e-t+this.delay,this._elapsedTime=0,this._needsRemove=!1,this._paused=!1},getElapsedTime:function(){return this._elapsedTime},_restartInLoop:function(e){this._startTime=e+this.gap,this._elapsedTime=0},_elapse:function(e,t){this._elapsedTime+=t*this.playbackRate},fire:function(e,t){var n="on"+e;this[n]&&this[n](this.target,t)},clone:function(){var e=new this.constructor;return e.name=this.name,e._loop=this._loop,e._loopRemained=this._loopRemained,e.life=this.life,e.gap=this.gap,e.delay=this.delay,e},pause:function(){this._paused=!0},resume:function(){this._paused=!1}},r.prototype.constructor=r,t.a=r},function(e,t,n){"use strict";var a=n(20),i=n(7),r=a.a.extend({widthSegments:1,heightSegments:1},function(){this.build()},{build:function(){for(var e=this.heightSegments,t=this.widthSegments,n=this.attributes,a=[],r=[],o=[],s=[],c=0;c<=e;c++)for(var l=c/e,u=0;u<=t;u++){var p=u/t;if(a.push([2*p-1,2*l-1,0]),r&&r.push([p,l]),o&&o.push([0,0,1]),u20)return console.warn("Given image is not a height map"),e}var d,f,h,m;c%(4*a)==0?(d=o.data[c],h=o.data[c+4]):c%(4*a)==4*(a-1)?(d=o.data[c-4],h=o.data[c]):(d=o.data[c-4],h=o.data[c+4]),c<4*a?(f=o.data[c],m=o.data[c+4*a]):c>a*(i-1)*4?(f=o.data[c-4*a],m=o.data[c]):(f=o.data[c-4*a],m=o.data[c+4*a]),s.data[c]=d-h+127,s.data[c+1]=f-m+127,s.data[c+2]=255,s.data[c+3]=255}return r.putImageData(s,0,0),n},isHeightImage:function(e,t,n){if(!e||!e.width||!e.height)return!1;var a=document.createElement("canvas"),i=a.getContext("2d"),r=t||32;n=n||20,a.width=a.height=r,i.drawImage(e,0,0,r,r);for(var o=i.getImageData(0,0,r,r),s=0;sn)return!1}return!0},_fetchTexture:function(e,t,n){r.a.get({url:e,responseType:"arraybuffer",onload:t,onerror:n})},createChessboard:function(e,t,n,i){e=e||512,t=t||64,n=n||"black",i=i||"white";var r=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=n;for(var c=0;c0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=r.a.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},render:function(e,t){var n=e.gl,t=t||this.material.shader,r=this.geometry,u=this.mode,p=r.vertexCount,d=r.isUseIndices(),f=e.getGLExtension("OES_element_index_uint"),h=f&&p>65535,m=h?n.UNSIGNED_INT:n.UNSIGNED_SHORT,v=e.getGLExtension("OES_vertex_array_object"),_=!r.dynamic,x=this._renderInfo;x.vertexCount=p,x.triangleCount=0,x.drawCallCount=0;var g=!1;if(i=e.__GUID__+"-"+r.__GUID__+"-"+t.__GUID__,i!==s?g=!0:(p>65535&&!f&&d||v&&_||r._cache.isDirty())&&(g=!0),s=i,g){var y=this._drawCache[i];if(!y){var b=r.getBufferChunks(e);if(!b)return;y=[];for(var T=0;T>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},a.nearestPowerOfTwo=function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))},t.a=a},function(e,t,n){"use strict";var a=n(1),i=a.a.extend({name:"",index:-1,node:null,rootNode:null});t.a=i},function(e,t,n){"use strict";var a=n(15),i=n(8),r=n(47),o=n(48),s=n(0),c=n.n(s),l=c.a.vec3,u=c.a.vec4,p=a.a.extend(function(){return{projectionMatrix:new i.a,invProjectionMatrix:new i.a,viewMatrix:new i.a,frustum:new r.a}},function(){this.update(!0)},{update:function(e){a.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=u.create();return function(t,n){var a=void 0!==n?n:new o.a,i=t._array[0],r=t._array[1];return u.set(e,i,r,-1,1),u.transformMat4(e,e,this.invProjectionMatrix._array),u.transformMat4(e,e,this.worldTransform._array),l.scale(a.origin._array,e,1/e[3]),u.set(e,i,r,1,1),u.transformMat4(e,e,this.invProjectionMatrix._array),u.transformMat4(e,e,this.worldTransform._array),l.scale(e,e,1/e[3]),l.sub(a.direction._array,e,a.origin._array),l.normalize(a.direction._array,a.direction._array),a.direction._dirty=!0,a.origin._dirty=!0,a}}()});t.a=p},function(e,t,n){"use strict";var a=(n(2),n(7)),i=n(73),r=n(0),o=n.n(r),s=o.a.vec3,c=s.set,l=s.copy,u=s.transformMat4,p=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 a.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,n=e._array,a=n[0],i=n[1],r=n[2],o=n[3],s=n[4],l=n[5],u=n[6],p=n[7],d=n[8],f=n[9],h=n[10],m=n[11],v=n[12],_=n[13],x=n[14],g=n[15];c(t[0].normal._array,o-a,p-s,m-d),t[0].distance=-(g-v),t[0].normalize(),c(t[1].normal._array,o+a,p+s,m+d),t[1].distance=-(g+v),t[1].normalize(),c(t[2].normal._array,o+i,p+l,m+f),t[2].distance=-(g+_),t[2].normalize(),c(t[3].normal._array,o-i,p-l,m-f),t[3].distance=-(g-_),t[3].normalize(),c(t[4].normal._array,o-r,p-u,m-h),t[4].distance=-(g-x),t[4].normalize(),c(t[5].normal._array,o+r,p+u,m+h),t[5].distance=-(g+x),t[5].normalize();var y=this.boundingBox;if(0===g){var b=l/a,T=-x/(h-1),E=-x/(h+1),w=-E/l,S=-T/l;y.min.set(-w*b,-w,E),y.max.set(w*b,w,T);var A=this.vertices;c(A[0],-w*b,-w,E),c(A[1],-w*b,w,E),c(A[2],w*b,-w,E),c(A[3],w*b,w,E),c(A[4],-S*b,-S,T),c(A[5],-S*b,S,T),c(A[6],S*b,-S,T),c(A[7],S*b,S,T)}else{var N=(-1-v)/a,C=(1-v)/a,M=(1-_)/l,R=(-1-_)/l,L=(-1-x)/h,D=(1-x)/h;y.min.set(Math.min(N,C),Math.min(R,M),Math.min(D,L)),y.max.set(Math.max(C,N),Math.max(M,R),Math.max(L,D));var P=y.min._array,I=y.max._array,A=this.vertices;c(A[0],P[0],P[1],P[2]),c(A[1],P[0],I[1],P[2]),c(A[2],I[0],P[1],P[2]),c(A[3],I[0],I[1],P[2]),c(A[4],P[0],P[1],I[2]),c(A[5],P[0],I[1],I[2]),c(A[6],I[0],P[1],I[2]),c(A[7],I[0],I[1],I[2])}},getTransformedBoundingBox:function(){var e=s.create();return function(t,n){var a=this.vertices,i=n._array,r=t.min,o=t.max,s=r._array,c=o._array,f=a[0];u(e,f,i),l(s,e),l(c,e);for(var h=1;h<8;h++)f=a[h],u(e,f,i),s[0]=p(e[0],s[0]),s[1]=p(e[1],s[1]),s[2]=p(e[2],s[2]),c[0]=d(e[0],c[0]),c[1]=d(e[1],c[1]),c[2]=d(e[2],c[2]);return r._dirty=!0,o._dirty=!0,t}}()},t.a=f},function(e,t,n){"use strict";var a=n(2),i=n(0),r=n.n(i),o=r.a.vec3,s=function(e,t){this.origin=e||new a.a,this.direction=t||new a.a};s.prototype={constructor:s,intersectPlane:function(e,t){var n=e.normal._array,i=e.distance,r=this.origin._array,s=this.direction._array,c=o.dot(n,s);if(0===c)return null;t||(t=new a.a);var l=(o.dot(n,r)-i)/c;return o.scaleAndAdd(t._array,r,s,-l),t._dirty=!0,t},mirrorAgainstPlane:function(e){var t=o.dot(e.normal._array,this.direction._array);o.scaleAndAdd(this.direction._array,this.direction._array,e.normal._array,2*-t),this.direction._dirty=!0},distanceToPoint:function(){var e=o.create();return function(t){o.sub(e,t,this.origin._array);var n=o.dot(e,this.direction._array);if(n<0)return o.distance(this.origin._array,t);var a=o.lenSquared(e);return Math.sqrt(a-n*n)}}(),intersectSphere:function(){var e=o.create();return function(t,n,i){var r=this.origin._array,s=this.direction._array;t=t._array,o.sub(e,t,r);var c=o.dot(e,s),l=o.squaredLength(e),u=l-c*c,p=n*n;if(!(u>p)){var d=Math.sqrt(p-u),f=c-d,h=c+d;return i||(i=new a.a),f<0?h<0?null:(o.scaleAndAdd(i._array,r,s,h),i):(o.scaleAndAdd(i._array,r,s,f),i)}}}(),intersectBoundingBox:function(e,t){var n,i,r,s,c,l,u=this.direction._array,p=this.origin._array,d=e.min._array,f=e.max._array,h=1/u[0],m=1/u[1],v=1/u[2];if(h>=0?(n=(d[0]-p[0])*h,i=(f[0]-p[0])*h):(i=(d[0]-p[0])*h,n=(f[0]-p[0])*h),m>=0?(r=(d[1]-p[1])*m,s=(f[1]-p[1])*m):(s=(d[1]-p[1])*m,r=(f[1]-p[1])*m),n>s||r>i)return null;if((r>n||n!==n)&&(n=r),(s=0?(c=(d[2]-p[2])*v,l=(f[2]-p[2])*v):(l=(d[2]-p[2])*v,c=(f[2]-p[2])*v),n>l||c>i)return null;if((c>n||n!==n)&&(n=c),(l=0?n:i;return t||(t=new a.a),o.scaleAndAdd(t._array,p,u,_),t},intersectTriangle:function(){var e=o.create(),t=o.create(),n=o.create(),i=o.create();return function(r,s,c,l,u,p){var d=this.direction._array,f=this.origin._array;r=r._array,s=s._array,c=c._array,o.sub(e,s,r),o.sub(t,c,r),o.cross(i,t,d);var h=o.dot(e,i);if(l){if(h>-1e-5)return null}else if(h>-1e-5&&h<1e-5)return null;o.sub(n,f,r);var m=o.dot(i,n)/h;if(m<0||m>1)return null;o.cross(i,e,n);var v=o.dot(d,i)/h;if(v<0||v>1||m+v>1)return null;o.cross(i,e,t);var _=-o.dot(n,i)/h;return _<0?null:(u||(u=new a.a),p&&a.a.set(p,1-m-v,m,v),o.scaleAndAdd(u._array,f,d,_),u)}}(),applyTransform:function(e){a.a.add(this.direction,this.direction,this.origin),a.a.transformMat4(this.origin,this.origin,e),a.a.transformMat4(this.direction,this.direction,e),a.a.sub(this.direction,this.direction,this.origin),a.a.normalize(this.direction,this.direction)},copy:function(e){a.a.copy(this.origin,e.origin),a.a.copy(this.direction,e.direction)},clone:function(){var e=new s;return e.copy(this),e}},t.a=s},function(e,t,n){"use strict";t.a="@export qtek.basic.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position : POSITION;\nattribute vec3 barycentric;\n@import qtek.chunk.skinning_header\nvarying vec2 v_Texcoord;\nvarying vec3 v_Barycentric;\nvoid main()\n{\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import qtek.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_Barycentric = barycentric;\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n}\n@end\n@export qtek.basic.fragment\nvarying vec2 v_Texcoord;\nuniform sampler2D diffuseMap;\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform vec3 emission : [0.0, 0.0, 0.0];\nuniform float alpha : 1.0;\n#ifdef ALPHA_TEST\nuniform float alphaCutoff: 0.9;\n#endif\nuniform float lineWidth : 0.0;\nuniform vec4 lineColor : [0.0, 0.0, 0.0, 0.6];\nvarying vec3 v_Barycentric;\n@import qtek.util.edge_factor\n@import qtek.util.rgbm\n@import qtek.util.srgb\nvoid main()\n{\n#ifdef RENDER_TEXCOORD\n gl_FragColor = vec4(v_Texcoord, 1.0, 1.0);\n return;\n#endif\n gl_FragColor = vec4(color, alpha);\n#ifdef DIFFUSEMAP_ENABLED\n vec4 tex = decodeHDR(texture2D(diffuseMap, v_Texcoord));\n#ifdef SRGB_DECODE\n tex = sRGBToLinear(tex);\n#endif\n#if defined(DIFFUSEMAP_ALPHA_ALPHA)\n gl_FragColor.a = tex.a;\n#endif\n gl_FragColor.rgb *= tex.rgb;\n#endif\n gl_FragColor.rgb += emission;\n if( lineWidth > 0.)\n {\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor(lineWidth)) * lineColor.a);\n }\n#ifdef GAMMA_ENCODE\n gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(1 / 2.2));\n#endif\n#ifdef ALPHA_TEST\n if (gl_FragColor.a < alphaCutoff) {\n discard;\n }\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.skybox.vertex\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 qtek.skybox.fragment\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import qtek.util.rgbm\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 viewDirection = normalize(v_WorldPosition - eyePos);\n vec3 tex = decodeHDR(textureCubeLodEXT(environmentMap, viewDirection, lod)).rgb;\n#ifdef SRGB_DECODE\n tex.rgb = pow(tex.rgb, vec3(2.2));\n#endif\n gl_FragColor = encodeHDR(vec4(tex, 1.0));\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.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 qtek.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 qtek.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 qtek.util.rgbm\n@import qtek.util.clamp_sample\nvoid main (void)\n{\n @import qtek.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"},function(e,t,n){"use strict";t.a="@export qtek.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import qtek.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(e,t,n){"use strict";t.a="@export qtek.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 qtek.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(e,t,n){"use strict";t.a="@export qtek.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import qtek.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"},function(e,t,n){"use strict";t.a="\n@export qtek.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 qtek.util.rgbm\n@import qtek.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(e,t,n){"use strict";t.a="@export qtek.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 qtek.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 qtek.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) {\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(e,t,n){"use strict";t.a="@export qtek.compositor.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 qtek.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(e,t,n){"use strict";t.a="@export qtek.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 qtek.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(e,t,n){"use strict";function a(e,t){var n=new s;return r.a.get({url:e,responseType:t,onload:function(e){n.resolve(e)},onerror:function(e){n.reject(e)}}),n}var i=n(22),r=n(25),o=n(11),s=function(){this._fullfilled=!1,this._rejected=!1};s.prototype.resolve=function(e){this._fullfilled=!0,this._rejected=!1,this.trigger("success",e)},s.prototype.reject=function(e){this._rejected=!0,this._fullfilled=!1,this.trigger("error",e)},s.prototype.isFullfilled=function(){return this._fullfilled},s.prototype.isRejected=function(){return this._rejected},s.prototype.isSettled=function(){return this._fullfilled||this._rejected},o.a.extend(s.prototype,i.a),s.makeRequestTask=function(e,t){if("string"==typeof e)return a(e,t);if(e.url){var n=e;return a(n.url,n.responseType)}if(Array.isArray(e)){var i=e,r=[];return i.forEach(function(e){var t,n;"string"==typeof e?t=e:Object(e)===e&&(t=e.url,n=e.responseType),r.push(a(t,n))}),r}},s.makeTask=function(){return new s},o.a.extend(s.prototype,i.a),t.a=s},function(e,t,n){"use strict";var a=n(14),i=n(2),r=a.a.extend({shadowBias:.001,shadowSlopeScale:2,shadowCascade:1,cascadeSplitLogFactor:.2},{type:"DIRECTIONAL_LIGHT",uniformTemplates:{directionalLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new i.a,e.__dir.copy(e.worldTransform.z).normalize().negate()._array}},directionalLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=a.a.prototype.clone.call(this);return e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}});t.a=r},function(e,t,n){"use strict";function a(e){c.a.defaultsWithPropList(e,u,p),i(e);for(var t="",n=0;n=this._maxSize&&o>0){var c=n.head;n.remove(c),delete a[c.key],i=c.value,this._lastRemovedEntry=c}s?s.value=t:s=new r(t),s.key=e,n.insertEntry(s),a[e]=s}return i},s.get=function(e){var t=this._map[e],n=this._list;if(null!=t)return t!==n.tail&&(n.remove(t),n.insertEntry(t)),t.value},s.clear=function(){this._list.clear(),this._map={}},t.a=o},function(e,t,n){"use strict";function a(){document.getElementById("timeline").style.display="block"}function i(){document.getElementById("timeline").style.display="none",c()}function r(e){if(u=e,l=Math.floor(e.getAnimationDuration()),l>0?a():i(),!(l<=0)){var t=document.getElementById("timeline-pause-resume");t.removeEventListener("click",d),t.addEventListener("click",d=function(){f?c():s(n)}),m=0,h=0,o();var n=Math.random();p=n,l>0?s(n):c();var r=null;if(!$("#timeline-progress input").data("ionRangeSlider")){$("#timeline-progress input").ionRangeSlider({from_shadow:!0,force_edges:!0,onChange:function(e){h=e.from,u.setPose(h),null==r&&(r=f),c()},onFinish:function(){r&&s(n),r=null}}),$("#timeline-range input").ionRangeSlider({from_shadow:!0,force_edges:!0,type:"double",drag_interval:!0,grid:!0,grid_num:10,onChange:function(e){l=e.to-e.from,m=e.from,h=Math.min(Math.max(e.from,h),e.to),u.setPose(h),v.update({from_min:e.from,from_max:e.to})}});var v=$("#timeline-progress input").data("ionRangeSlider"),_=$("#timeline-range input").data("ionRangeSlider");v.update({min:0,max:l,from:h,from_min:0,from_max:l}),_.update({min:0,max:l,from:0,to:l})}}}function o(){var e=$("#timeline-progress input").data("ionRangeSlider");e&&e.update({from:h})}function s(e){function t(){if(f&&e===p){u.setPose(h);var a=Math.min(Date.now()-n,20);n=Date.now(),o(),h+=a,h>m+l&&(h=m),requestAnimationFrame(t)}}if(!f){f=!0;var n=Date.now(),a=document.getElementById("timeline-pause-resume");a.classList.remove("icon-resume"),a.classList.add("icon-pause"),requestAnimationFrame(t)}}function c(){if(f){f=!1;var e=document.getElementById("timeline-pause-resume");e.classList.remove("icon-pause"),e.classList.add("icon-resume")}}n.d(t,"b",function(){return r}),n.d(t,"a",function(){return i});var l,u,p,d,f=!1,h=0,m=0},function(e,t,n){"use strict";function a(){["mainLight","secondaryLight","tertiaryLight"].forEach(function(e){z[e].alpha=90*z[e].$padAngle[1],z[e].beta=180*z[e].$padAngle[0]}),S.setMainLight(z.mainLight),S.setSecondaryLight(z.secondaryLight),S.setTertiaryLight(z.tertiaryLight),S.setAmbientLight(z.ambientLight)}function i(){S.setPostEffect(z.postEffect)}function r(){z.ambientCubemapLight.texture=O.a.ENV_TEXTURE_ROOT+z.ambientCubemapLight.$texture+".hdr",z.ambientCubemapLight.diffuseIntensity=z.ambientCubemapLight.specularIntensity=z.ambientCubemapLight.$intensity,S.setAmbientCubemapLight(z.ambientCubemapLight)}function o(){S.setGround(z.ground)}function s(){a(),i(),r(),o()}function c(){var e=Math.max(j.$textureTiling,.01);j.uvRepeat=[e,e],j.transparent=j.alpha<1,S.setMaterial(j.name,j)}function l(e){j.name=e.name;var t=S.getMaterial(e.name);t.$textureTiling=t.uvRepeat[0],k.a.extend(j,t),null==t.specularColor?(N.enable(),C.disable()):(C.enable(),N.disable()),q.update()}function u(e){return e&&"none"!==e}function p(e,t,n){var a=!1;u(n)&&([["diffuseMap","color","#fff"],["metalnessMap","metalness",.5],["roughnessMap","roughness",.5],["glossinessMap","glossiness",.5],["specularMap","specularColor","#fff"],["emissiveMap","emission","#fff"]].forEach(function(t){e===t[0]&&(console.warn("Force %s to be %s after set %s",t[1],t[2],t[0]),j[t[1]]=t[2],a=!0)},this),_(),O.a.AUTO_SAVE&&I.g(t).then(g).catch(g),R[n]=t.name,a&&q.update()),c()}function d(){document.getElementById("tip").style.display="block"}function f(){document.getElementById("tip").style.display="none"}function h(){S=new L.a.Viewer(document.getElementById("viewport"),z),S.enablePicking(),S.setCameraControl(z.viewControl),S.start(),S.on("select",function(e){S.refresh(),l(e.target.material),M=e.target}),S.on("doffocus",function(e){z.postEffect.depthOfField.enable&&(z.postEffect.depthOfField.focalDistance=e.distance,q.update())}),S.on("unselect",function(){S.refresh(),N.disable(),C.disable(),M=null}),S.on("afterrender",function(e,t,n){M&&Object(H.a)(S,[M],n)}),S.on("updatecamera",function(e){z.viewControl={center:e.center,alpha:e.alpha,beta:e.beta,distance:e.distance}})}function m(e){document.body.appendChild(G),G.querySelector("#loading-text").innerHTML=e||"LOADING"}function v(){G.parentNode.removeChild(G)}function _(){W.style.display="block",W.querySelector("#background-progress-text").innerHTML="Saving...DONT close the page."}function x(){W.style.display="block",W.querySelector("#background-progress-text").innerHTML="Preparing for download...DONT close the page."}function g(){W.style.display="none"}function y(){v(),document.getElementById("toolbar").style.display="block",document.getElementById("reset").addEventListener("click",T),document.getElementById("download").addEventListener("click",E),h(),FileAPI.event.dnd(document.getElementById("main"),function(e){},function(e){m("Loading model"),U.a(),I.a(e).then(function(e){var t=e.glTF,n=e.filesMap,a=e.buffers,i=e.allFiles;R={};for(var r in n)R[n[r]]=r;var o=!(!t.extras||!t.extras.qtekModelViewerConfig);o&&(F.merge(z,t.extras.qtekModelViewerConfig,!0),S.setCameraControl(z.viewControl),s(),q.update()),S.loadModel(t,{files:n,buffers:a,textureFlipY:z.textureFlipY,doubleSided:!0,upAxis:z.zUpToYUp?"z":"y",includeTexture:!o}).on("ready",function(){f(),v(),o&&(t.extras.qtekModelViewerConfig.materials||[]).forEach(function(e){for(var t in e)n[e[t]]&&(e[t]=n[e[t]]);S.setMaterial(e.name,e)}),setTimeout(function(){_(),O.a.AUTO_SAVE&&I.e(i).then(g).catch(g)},200)}).on("loadmodel",w).on("error",function(){v(),swal("Model load error")}),N.disable(),C.disable()}).catch(function(e){v(),S.getModelRoot()||d(),Object(U.b)(S),console.log(e),swal(e.toString())})}),b(),V=!0}function b(){function e(e){return R&&R[e]}function t(t){t.addStringOutput(j,"name",{label:"Name"}).addColor(j,"color",{label:"Base Color",onChange:c}).addSlider(j,"alpha","$alphaRange",{label:"Alpha",onChange:c}).addSlider(j,"alphaCutoff","$alphaCutoffRange",{label:"Alpha Cutoff",onChange:c}).addNumberInput(j,"$textureTiling",{label:"Tiling",onChange:c,step:.5}).addCustomComponent(B.a,j,"diffuseMap",{label:"Base Map",onChange:p.bind(null,"diffuseMap"),getFileName:e}).addCustomComponent(B.a,j,"normalMap",{label:"Normal/Bump Map",onChange:p.bind(null,"normalMap"),getFileName:e})}function n(t){t.addCustomComponent(B.a,j,"parallaxOcclusionMap",{label:"Parallax Occlusion Map",onChange:p.bind(null,"parallaxOcclusionMap"),getFileName:e}).addSlider(j,"parallaxOcclusionScale","$parallaxOcclusionScaleRange",{label:"Scale",onChange:c}).addColor(j,"emission",{label:"Emission",onChange:c}).addNumberInput(j,"emissionIntensity",{label:"Emission Intensity",onChange:c}).addCustomComponent(B.a,j,"emissiveMap",{label:"Emissive Map",onChange:p.bind(null,"emissiveMap"),getFileName:e})}A=q.addPanel({label:"Settings",width:250}),A.addGroup({label:"Global"}).addSubGroup({label:"Load Option"}).addCheckbox(z,"textureFlipY",{label:"Flip Texture",onChange:function(){S.setTextureFlipY(z.textureFlipY)}}).addCheckbox(z,"zUpToYUp",{label:"Z Up",onChange:function(){S.setModelUpAxis(z.zUpToYUp?"Z":"Y")}}).addSubGroup({label:"Ground"}).addCheckbox(z.ground,"show",{label:"Show",onChange:o}),A.addGroup({label:"Environment",enable:!1}).addSelect(z.ambientCubemapLight,"$textureOptions",{label:"HDR Texture",onChange:r,target:"$texture"}).addNumberInput(z.ambientCubemapLight,"$intensity",{label:"Intensity",onChange:r,step:.1}),A.addGroup({label:"Light",enable:!1}).addSubGroup({label:"Main",enable:!1}).addCheckbox(z.mainLight,"shadow",{label:"Cast Shadow",onChange:a}).addNumberInput(z.mainLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(z.mainLight,"color",{label:"Color",onChange:a}).addPad(z.mainLight,"$padAngle",{label:"Direction",onChange:a}).addSubGroup({label:"Secondary",enable:!1}).addNumberInput(z.secondaryLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(z.secondaryLight,"color",{label:"Color",onChange:a}).addPad(z.secondaryLight,"$padAngle",{label:"Direction",onChange:a}).addSubGroup({label:"Tertiary",enable:!1}).addNumberInput(z.tertiaryLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(z.tertiaryLight,"color",{label:"Color",onChange:a}).addPad(z.tertiaryLight,"$padAngle",{label:"Direction",onChange:a}).addSubGroup({label:"Ambient",enable:!1}).addNumberInput(z.ambientLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(z.ambientLight,"color",{label:"Color",onChange:a}),A.addGroup({label:"Post Effect",enable:!1}).addCheckbox(z.postEffect,"enable",{label:"Enable",onChange:i}).addSubGroup({label:"Bloom",enable:!1}).addCheckbox(z.postEffect.bloom,"enable",{label:"Enable",onChange:i}).addNumberInput(z.postEffect.bloom,"intensity",{label:"Intensity",step:.1,onChange:i}).addSubGroup({label:"Screen Space Ambient Occulusion",enable:!1}).addCheckbox(z.postEffect.screenSpaceAmbientOcclusion,"enable",{label:"Enable",onChange:i}).addNumberInput(z.postEffect.screenSpaceAmbientOcclusion,"radius",{label:"Radius",step:.1,onChange:i}).addNumberInput(z.postEffect.screenSpaceAmbientOcclusion,"intensity",{label:"Intensity",step:.1,onChange:i}).addSelect(z.postEffect.screenSpaceAmbientOcclusion,"$qualityOptions",{label:"Quality",onChange:i,target:"quality"}).addSubGroup({label:"Screen Space Reflection",enable:!1}).addCheckbox(z.postEffect.screenSpaceReflection,"enable",{label:"Enable",onChange:i}).addNumberInput(z.postEffect.screenSpaceReflection,"maxRoughness",{label:"Max Roughness",step:.01,onChange:i}).addSelect(z.postEffect.screenSpaceReflection,"$qualityOptions",{label:"Quality",onChange:i,target:"quality"}).addSubGroup({label:"Depth of Field",enable:!1}).addCheckbox(z.postEffect.depthOfField,"enable",{label:"Enable",onChange:i}).addNumberInput(z.postEffect.depthOfField,"fstop",{label:"f-stop",step:.1,onChange:i}).addNumberInput(z.postEffect.depthOfField,"focalDistance",{label:"Focal Distance",step:.1,onChange:i}).addNumberInput(z.postEffect.depthOfField,"focalRange",{label:"Focal Range",step:.1,onChange:i}).addNumberInput(z.postEffect.depthOfField,"blurRadius",{label:"Blur Radius",step:.1,onChange:i}).addSelect(z.postEffect.depthOfField,"$qualityOptions",{label:"Quality",onChange:i,target:"quality"}).addSubGroup({label:"Color Correction",enable:!1}).addNumberInput(z.postEffect.colorCorrection,"exposure",{label:"Exposure",step:.1,onChange:i}).addNumberInput(z.postEffect.colorCorrection,"brightness",{label:"Brightness",step:.1,onChange:i}).addNumberInput(z.postEffect.colorCorrection,"contrast",{label:"Contrast",step:.1,onChange:i}).addNumberInput(z.postEffect.colorCorrection,"saturation",{label:"Saturation",step:.1,onChange:i}),N=q.addPanel({label:"Material - Metalllic Roughness",width:240,fixed:!1,align:"left",position:[10,10]}),t(N),N.addCustomComponent(B.a,j,"metalnessMap",{label:"Metalness Map",onChange:p.bind(null,"metalnessMap"),getFileName:e}).addSlider(j,"metalness","$metalnessRange",{label:"Metalness",onChange:c}).addCustomComponent(B.a,j,"roughnessMap",{label:"Roughness Map",onChange:p.bind(null,"roughnessMap"),getFileName:e}).addSlider(j,"roughness","$roughnessRange",{label:"Roughness",onChange:c}),n(N),N.disable(),C=q.addPanel({label:"Material - Specular Glossiness",width:240,fixed:!1,align:"left",position:[10,10]}),t(C),C.addCustomComponent(B.a,j,"specularMap",{label:"Specular Map",onChange:p.bind(null,"specularMap"),getFileName:e}).addColor(j,"specularColor",{label:"Specular Factor",onChange:c}).addCustomComponent(B.a,j,"glossinessMap",{label:"Glossiness Map",onChange:p.bind(null,"glossinessMap"),getFileName:e}).addSlider(j,"glossiness","$glossinessRange",{label:"Glossiness",onChange:c}),n(C),C.disable()}function T(){swal({title:"Reset?",text:"Reset the viewer",type:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"Yes!"}).then(function(){F.merge(z,Object(D.a)(),!0),F.merge(j,Object(P.a)(),!0),q.update(),N.disable(),C.disable(),M=null,S.dispose(),h(),I.d(),d(),U.b(S),g()}).catch(function(){})}function E(){swal({title:"Select download format.",input:"radio",inputOptions:{glb:"GLB",zip:"ZIP"}}).then(function(e){x(),I.b(e,g,g)})}function w(){M=null,S.stopAnimation(),U.b(S)}Object.defineProperty(t,"__esModule",{value:!0});var S,A,N,C,M,R,L=n(66),D=n(141),P=n(142),I=n(143),O=n(37),k=n(11),F=n(151),B=(n.n(F),n(152)),U=n(64),H=n(153),z=Object(D.a)(),j=Object(P.a)(),q=new ControlKit({loadAndSave:!0,useExternalStyle:!0}),G=document.getElementById("loading"),W=document.getElementById("background-progress"),V=!1;I.c(function(e,t,n){if(n&&F.merge(z,n,!0),!V)if(y(),e){R={};for(var a in t)R[t[a]]=a;S.loadModel(e,{files:t,textureFlipY:z.textureFlipY,upAxis:z.zUpToYUp?"z":"y",doubleSided:!0,includeTexture:!1}).on("ready",function(){n&&n.materials&&n.materials.forEach(function(e){for(var n in e)t[e[n]]&&(e[n]=t[e[n]]);S.setMaterial(e.name,e)})}).on("loadmodel",w).on("error",function(){d(),swal("Model load error")})}else d()}),setTimeout(function(){V||(console.warn("Init time out"),y())},5e3),setInterval(function(){if(S&&!document.hidden){var e={};z.materials=S.getMaterialsNames().map(function(t){var n=S.getMaterial(t);for(var a in n)R[n[a]]&&(n[a]=R[n[a]]);return n.targetMeshes=[],e[t]=n,n}),S.getModelRoot()&&S.getModelRoot().traverse(function(t){t.material&&e[t.material.name]&&e[t.material.name].targetMeshes.push(t.originalMeshName||t.name)}),_(),O.a.AUTO_SAVE&&I.f(z).then(function(){g(),console.log("Saved")}).catch(g)}},5e3),window.addEventListener("resize",function(){S.resize()}),window.addEventListener("dragover",function(e){e.preventDefault()}),window.addEventListener("drop",function(e){e.preventDefault()})},function(e,t,n){"use strict";var a=n(67);t.a={Viewer:a.a}},function(e,t,n){"use strict";function a(e,t){t=S.a(t),S.b(t,w.a),this.init(e,t)}var i=n(30),r=n(40),o=n(2),s=n(90),c=n(92),l=n(59),u=n(93),p=n(11),d=n(15),f=n(16),h=n(9),m=n(32),v=n(4),_=n(94),x=n(22),g=n(18),y=n(33),b=n(98),T=n(29),E=n(131),w=n(133),S=n(134),A=n(135),N=n(136),C=n(138),M=n(140);v.a.import(M.a);var R=["diffuseMap","normalMap","emissiveMap","metalnessMap","roughnessMap","specularMap","glossinessMap"];a.prototype.init=function(e,t){t=t||{},this.root=e,this._animation=new s.a;var n=new i.a({devicePixelRatio:t.devicePixelRatio||window.devicePixelRatio});e.appendChild(n.canvas),n.canvas.style.cssText="position:absolute;left:0;top:0",this._renderer=n,this._renderMain=new b.a(n,t.shadow,"perspective"),this._renderMain.afterRenderScene=function(e,t,n){this.trigger("renderscene",e,t,n)}.bind(this),this._renderMain.afterRenderAll=function(e,t,n){this.trigger("afterrender",e,t,n)}.bind(this),this._renderMain.preZ=t.preZ||!1;var a=this._cameraControl=new N.a({renderer:n,animation:this._animation,domElement:e});a.target=this._renderMain.camera,a.init(),this._hotspotManager=new C.a({dom:e,renderer:n,camera:this._renderMain.camera}),this._skeletons=[],this._clips=[],this._takes=[],this._materialsMap={},this._sceneHelper=new E.a(this._renderMain.scene),this._sceneHelper.initLight(this._renderMain.scene),this.resize(),t.postEffect&&this.setPostEffect(t.postEffect),t.mainLight&&this.setMainLight(t.mainLight),t.secondaryLight&&this.setSecondaryLight(t.secondaryLight),t.tertiaryLight&&this.setTertiaryLight(t.tertiaryLight),t.ambientCubemapLight&&this.setAmbientCubemapLight(t.ambientCubemapLight),t.ambientLight&&this.setAmbientLight(t.ambientLight),t.environment&&this.setEnvironment(t.environment),this._createGround(),t.ground&&this.setGround(t.ground),this.setCameraControl({distance:20,minDisntance:2,maxDistance:100,center:[0,0,0]}),this._enablePicking=t.picking||!1,this._initHandlers(),a.on("update",function(){this.trigger("updatecamera",{center:a.getCenter(),alpha:a.getAlpha(),beta:a.getBeta(),distance:a.getDistance()}),this.refresh()},this),this.shaderLibrary=g.a.createLibrary()},a.prototype._createGround=function(){var e=new f.a({isGround:!0,material:new h.a({shader:new v.a({vertex:v.a.source("qmv.ground.vertex"),fragment:v.a.source("qmv.ground.fragment")}),transparent:!0}),castShadow:!1,geometry:new m.a});e.material.set("color",[1,1,1,1]),e.scale.set(40,40,1),e.rotation.rotateX(-Math.PI/2),this._groundMesh=e,this._renderMain.scene.add(e)},a.prototype._addModel=function(e,t,n,a){this.removeModel(),this._renderMain.scene.add(e),this._skeletons=n.slice(),this._modelNode=e,this._setAnimationClips(a),t&&t.length&&(this._nodes=t);var i={};e.traverse(function(e){if(e.material){var t=e.material;i[t.name]=i[t.name]||[],i[t.name].push(t)}},this),this._materialsMap=i,this._updateMaterialsSRGB(),this._stopAccumulating()},a.prototype._removeAnimationClips=function(){this._clips.forEach(function(e){this._animation.removeClip(e)},this),this._clips=[],this._takes=[]},a.prototype._setAnimationClips=function(e){function t(){n.refresh()}var n=this;e.forEach(function(e){e.tracks.forEach(function(e){e.target||(e.target=this._nodes[e.targetNodeIndex])},this),e.onframe=t,this._animation.addClip(e),this._takes.push({name:e.name,range:[0,e.life],clip:e})},this),this._clips=e.slice()},a.prototype._initHandlers=function(){this._picking=new _.a({renderer:this._renderer,scene:this._renderMain.scene,camera:this._renderMain.camera}),this._clickHandler=this._clickHandler.bind(this),this._mouseDownHandler=this._mouseDownHandler.bind(this),this.root.addEventListener("mousedown",this._mouseDownHandler),this.root.addEventListener("click",this._clickHandler)},a.prototype._mouseDownHandler=function(e){this._startX=e.clientX,this._startY=e.clientY},a.prototype._clickHandler=function(e){if(this._enablePicking||this._renderMain.isDOFEnabled()){var t=e.clientX-this._startX,n=e.clientY-this._startY;if(!(Math.sqrt(t*t+n*n)>=40)){var a=this._picking.pick(e.clientX,e.clientY,!0);a&&!a.target.isGround?(this._renderMain.setDOFFocusOnPoint(a.distance),this.trigger("doffocus",a),this._selectResult=a,this.trigger("select",a),this.refresh()):(this._selectResult&&this.trigger("unselect",this._selectResult),this._selectResult=null)}}},a.prototype.enablePicking=function(){this._enablePicking=!0},a.prototype.disablePicking=function(){this._enablePicking=!1},a.prototype.setModelUpAxis=function(e){var t=this._modelNode;t&&(t.position.set(0,0,0),t.scale.set(1,1,1),t.rotation.identity(),"z"===e.toLowerCase()&&t.rotation.identity().rotateX(-Math.PI/2),this.autoFitModel())},a.prototype.setTextureFlipY=function(e){if(this._modelNode){for(var t in this._materialsMap)for(var n=0;n1||o<0){n=!0;break}}if(n)for(var a=0;a=0&&s.splice(a,1),c[e]=null}}t=t||{};var i=this._materialsMap[e],r=this,o=this._textureFlipY;if(!i||!i.length)return void console.warn("Material %s not exits",e);var s=i[0].shader.getEnabledTextures(),c={};["diffuseMap","normalMap","parallaxOcclusionMap","emissiveMap"].forEach(function(e){a(e)},this),i[0].shader.isDefined("fragment","USE_METALNESS")?["metalnessMap","roughnessMap"].forEach(function(e){a(e)},this):["specularMap","glossinessMap"].forEach(function(e){a(e)},this),(c.normalMap||c.parallaxOcclusionMap)&&this._modelNode.traverse(function(t){t.material&&t.material.name===e&&(t.geometry.attributes.tangent.value||t.geometry.generateTangents())}),i.forEach(function(e){null!=t.transparent&&(e.transparent=!!t.transparent,e.depthMask=!t.transparent),["color","emission","specularColor"].forEach(function(n){null!=t[n]&&e.set(n,T.a.parseColor(t[n]))}),["alpha","alphaCutoff","metalness","roughness","glossiness","emissionIntensity","uvRepeat","parallaxOcclusionScale"].forEach(function(n){null!=t[n]&&e.set(n,t[n])});for(var n in c)e.set(n,c[n]);e.attachShader(this.shaderLibrary.get("qtek."+(this._shaderName||"standard"),{fragmentDefines:e.shader.fragmentDefines,textures:s,vertexDefines:e.shader.vertexDefines,precision:e.shader.precision}),!0)},this),this.refresh()},a.prototype.getMaterial=function(e){function t(e){var t=a.get(e);if(!t)return"";for(var n=t.image;n.srcImage;)n=n.srcImage;return n&&n.src||""}var n=this._materialsMap[e];if(!n)return void console.warn("Material %s not exits",e);var a=n[0],i={name:e};return["color","emission"].forEach(function(e){i[e]=T.a.stringifyColor(a.get(e),"hex")}),["alpha","alphaCutoff","emissionIntensity","uvRepeat","parallaxOcclusionScale"].forEach(function(e){i[e]=a.get(e)}),["diffuseMap","normalMap","parallaxOcclusionMap","emissiveMap"].forEach(function(e){i[e]=t(e)}),a.shader.isDefined("fragment","USE_METALNESS")?(["metalness","roughness"].forEach(function(e){i[e]=a.get(e)}),["metalnessMap","roughnessMap"].forEach(function(e){i[e]=t(e)}),i.type="pbrMetallicRoughness"):(i.specularColor=T.a.stringifyColor(a.get("specularColor"),"hex"),i.glossiness=a.get("glossiness"),["specularMap","glossinessMap"].forEach(function(e){i[e]=t(e)}),i.type="pbrSpecularGlossiness"),i},a.prototype.setGround=function(e){this._groundMesh.invisible=!e.show,this.refresh()},a.prototype.getMaterialsNames=function(){return Object.keys(this._materialsMap)},a.prototype.setPostEffect=function(e){this._renderMain.setPostEffect(e),this._updateMaterialsSRGB(),this.refresh()},a.prototype.start=function(){if(this._disposed)return void console.warn("Viewer already disposed");this._animation.start(),this._animation.on("frame",this._loop,this)},a.prototype.stop=function(){this._animation.stop(),this._animation.off("frame",this._loop)},a.prototype.addHotspot=function(e,t){return this._hotspotManager.add(e,t)},a.prototype.setPose=function(e){this._clips.forEach(function(t){t.setTime(e)}),this._skeletons.forEach(function(e){e.update()}),this.refresh()},a.prototype.getAnimationDuration=function(){var e=0;return this._clips.forEach(function(t){e=Math.max(t.life,e)}),e},a.prototype.refresh=function(){this._needsRefresh=!0},a.prototype.getRenderer=function(){return this._renderer},a.prototype._updateMaterialsSRGB=function(){var e=this._renderMain.isLinearSpace();for(var t in this._materialsMap)for(var n=this._materialsMap[t],a=0;a0&&this._clips.splice(t,1)},removeClipsAll:function(){this._clips=[]},getClip:function(e){if(this._clips[e])return this._clips[e].clip},getClipNumber:function(){return this._clips.length},updateJointMatrices:function(){var e=l.create();return function(){this._invBindPoseMatricesArray=new Float32Array(16*this.joints.length),this._skinMatricesArray=new Float32Array(16*this.joints.length);for(var t=0;tthis.distance,i=1;i<8;i++)if(o.dot(t[i]._array,n)>this.distance!=a)return!0},intersectLine:function(){var e=o.create();return function(t,n,i){var r=this.distanceToPoint(t),s=this.distanceToPoint(n);if(r>0&&s>0||r<0&&s<0)return null;var c=this.normal._array,l=this.distance,u=t._array;o.sub(e,n._array,t._array),o.normalize(e,e);var p=o.dot(c,e);if(0===p)return null;i||(i=new a.a);var d=(o.dot(c,u)-l)/p;return o.scaleAndAdd(i._array,u,e,-d),i._dirty=!0,i}}(),applyTransform:function(){var e=s.create(),t=c.create(),n=c.create();return n[3]=1,function(a){a=a._array,o.scale(n,this.normal._array,this.distance),c.transformMat4(n,n,a),this.distance=o.dot(n,this.normal._array),s.invert(e,a),s.transpose(e,e),t[3]=0,o.copy(t,this.normal._array),c.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,n){"use strict";var a=n(31),i=n(0),r=n.n(i),o=r.a.quat,s=r.a.vec3,c=function(e){e=e||{},a.a.call(this,e),this.tracks=e.tracks||[]};c.prototype=Object.create(a.a.prototype),c.prototype.constructor=c,c.prototype.step=function(e,t,n){var i=a.a.prototype.step.call(this,e,t,!0);if("finish"!==i){var e=this.getElapsedTime();this._range&&(e=this._range[0]+e),this.setTime(e)}return n||"paused"===i||this.fire("frame"),i},c.prototype.setRange=function(e){this.calcLifeFromTracks(),this._range=e,e&&(e[1]=Math.min(e[1],this.life),e[0]=Math.min(e[0],this.life),this.life=e[1]-e[0])},c.prototype.setTime=function(e){for(var t=0;t=0&&this.tracks.splice(t,1)},c.prototype.getSubClip=function(e,t,n){for(var a=new c({name:this.name}),i=0;i1e-6?(o=Math.acos(s),c=Math.sin(o),l=Math.sin((1-a)*o)/c,u=Math.sin(a*o)/c):(l=1-a,u=a),e[0]=l*p+u*m,e[1]=l*d+u*v,e[2]=l*f+u*_,e[3]=l*h+u*x,e}var r=n(77),o=n(0),s=n.n(o),c=s.a.quat,l=s.a.vec3,u=function(e){e=e||{},this.name=e.name||"",this.target=e.target||null,this.position=l.create(),this.rotation=c.create(),this.scale=l.fromValues(1,1,1),this.channels={time:null,position:null,rotation:null,scale:null},this._cacheKey=0,this._cacheTime=0};u.prototype.setTime=function(e){if(this.channels.time){var t=this.channels,n=t.time.length,r=-1;if(1===n)return t.rotation&&c.copy(this.rotation,t.rotation),t.position&&l.copy(this.position,t.position),void(t.scale&&l.copy(this.scale,t.scale));if(e<=t.time[0])e=t.time[0],r=0;else if(e>=t.time[n-1])e=t.time[n-1],r=n-2;else if(e=0;s--)if(t.time[s-1]<=e&&t.time[s]>e){r=s-1;break}}else for(var s=this._cacheKey;se){r=s;break}if(r>-1){this._cacheKey=r,this._cacheTime=e;var u=r,p=r+1,d=t.time[u],f=t.time[p],h=f-d,m=0===h?0:(e-d)/h;t.rotation&&i(this.rotation,t.rotation,t.rotation,m,4*u,4*p),t.position&&a(this.position,t.position,t.position,m,3*u,3*p),t.scale&&a(this.scale,t.scale,t.scale,m,3*u,3*p)}r==n-2&&(this._cacheKey=0,this._cacheTime=0),this.updateTarget()}},u.prototype.updateTarget=function(){var e=this.channels;this.target&&(e.position&&this.target.position.setArray(this.position),e.rotation&&this.target.rotation.setArray(this.rotation),e.scale&&this.target.scale.setArray(this.scale))},u.prototype.getMaxTime=function(){return this.channels.time[this.channels.time.length-1]},u.prototype.getSubTrack=function(e,t){var n=new u({name:this.name}),a=this.channels.time[0];e=Math.min(Math.max(e,a),this.life),t=Math.min(Math.max(t,a),this.life);var i=this._findRange(e),r=this._findRange(t),o=r[0]-i[0]+1;0===i[1]&&0===r[1]&&(o-=1),this.channels.rotation&&(n.channels.rotation=new Float32Array(4*o)),this.channels.position&&(n.channels.position=new Float32Array(3*o)),this.channels.scale&&(n.channels.scale=new Float32Array(3*o)),this.channels.time&&(n.channels.time=new Float32Array(o)),this.setTime(e);for(var s=0;s<3;s++)n.channels.rotation[s]=this.rotation[s],n.channels.position[s]=this.position[s],n.channels.scale[s]=this.scale[s];n.channels.time[0]=0,n.channels.rotation[3]=this.rotation[3];for(var s=1;se&&(a=i);var r=0;if(a>=0)var o=t.time[a],s=t.time[a+1],r=(e-o)/(s-o);return[a,r]},u.prototype.blend1D=r.a.prototype.blend1D,u.prototype.blend2D=r.a.prototype.blend2D,u.prototype.additiveBlend=r.a.prototype.additiveBlend,u.prototype.subtractiveBlend=r.a.prototype.subtractiveBlend,u.prototype.clone=function(){var e=u.prototype.clone.call(this);return e.channels={time:this.channels.time||null,position:this.channels.position||null,rotation:this.channels.rotation||null,scale:this.channels.scale||null},l.copy(e.position,this.position),c.copy(e.rotation,this.rotation),l.copy(e.scale,this.scale),e.target=this.target,e.updateTarget(),e},t.a=u},function(e,t,n){"use strict";function a(e,t){return e.time-t.time}var i=n(31),r=n(0),o=n.n(r),s=o.a.quat,c=o.a.vec3,l=function(e){this.name=e.name||"",this.keyFrames=[],e.keyFrames&&this.addKeyFrames(e.keyFrames),this.position=c.create(),this.rotation=s.create(),this.scale=c.fromValues(1,1,1),this._cacheKey=0,this._cacheTime=0};l.prototype=Object.create(i.a.prototype),l.prototype.constructor=l,l.prototype.step=function(e,t,n){var a=i.a.prototype.step.call(this,e,t,!0);return"finish"!==a&&this.setTime(this.getElapsedTime()),n||"paused"===a||this.fire("frame"),a},l.prototype.setTime=function(e){this._interpolateField(e,"position"),this._interpolateField(e,"rotation"),this._interpolateField(e,"scale")},l.prototype.getMaxTime=function(){var e=this.keyFrames[this.keyFrames.length-1];return e?e.time:0},l.prototype.addKeyFrame=function(e){for(var t=0;t=e.time)return this.keyFrames.splice(t,0,e),t}this.life=e.time,this.keyFrames.push(e)},l.prototype.addKeyFrames=function(e){for(var t=0;ti[i.length-1].time)){if(e=r-1?r-1:this._cacheKey+1,l=o;l>=0;l--)if(i[l].time<=e&&i[l][t])n=i[l],this._cacheKey=l,this._cacheTime=e;else if(i[l][t]){a=i[l];break}}else for(var l=this._cacheKey;l=0&&this._clips.splice(t,1)},removeAnimator:function(e){for(var t=e.getClips(),n=0;ni)e.length=i;else for(var r=a;r=0&&!(T[A]<=t);A--);A=Math.min(A,_-2)}else{for(A=O;A<_&&!(T[A]>t);A++);A=Math.min(A-1,_-2)}O=A,k=t;var n=T[A+1]-T[A];0!==n&&(R=(t-T[A])/n,v?(D=E[A],L=E[0===A?A:A-1],P=E[A>_-2?_-1:A+1],I=E[A>_-3?_-1:A+2],c?h(e,i,c(f(e,i),L,D,P,I,R)):g?l(L,D,P,I,R,R*R,R*R*R,f(e,i),y):h(e,i,u(L,D,P,I,R,R*R,R*R*R))):c?h(e,i,c(f(e,i),E[A],E[A+1],R)):g?o(E[A],E[A+1],R,f(e,i),y):h(e,i,r(E[A],E[A+1],R)))},B=new m.a({target:e._target,life:b,loop:e._loop,delay:e._delay,onframe:F,onfinish:n});return t&&"spline"!==t&&B.setEasing(t),B}}}function h(e,t,n,r,o){this._tracks={},this._target=e,this._loop=t||!1,this._getter=n||a,this._setter=r||i,this._interpolater=o||null,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]}var m=n(31),v=Array.prototype.slice;h.prototype={constructor:h,when:function(e,t){for(var n in t)this._tracks[n]||(this._tracks[n]=[],0!==e&&this._tracks[n].push({time:0,value:c(this._getter(this._target,n))})),this._tracks[n].push({time:parseInt(e),value:t[n]});return this},during:function(e){return this._onframeList.push(e),this},_doneCallback:function(){this._tracks={},this._clipList.length=0;for(var e=this._doneList,t=e.length,n=0;n=65535?new Uint32Array(3*_):new Uint16Array(3*_);for(var b=0,T=0,E=r.isUseIndices(),w=0;w0;){for(var w=[],S=[],A=[],N=0,y=0;y=0&&-1===S[P]&&(N65535?new Uint32Array(3*B.triangles.length):new Uint16Array(3*B.triangles.length);var J=0;V=0;for(var y=0;y=0?U[P]:-1}V++}G.indices[J++]=k[L]}G.updateBoundingBox(),I.add(W)}for(var ae=e.children(),y=0;y=0&&S[E]>1e-4&&(d.transformMat4(C,w,b[A[E]]),d.scaleAndAdd(N,N,C,S[E]));M.set(T,N)}}for(var T=0;T<_.length;T+=3){var R=_[T],L=_[T+1],D=_[T+2],P=u?p.attributes.skinnedPosition:x;if(P.get(R,e._array),P.get(L,t._array),P.get(D,n._array),h=v?a.intersectTriangle(e,t,n,i.culling):a.intersectTriangle(e,n,t,i.culling)){var I=new o.a;u?o.a.copy(I,h):o.a.transformMat4(I,h,i.worldTransform),c.push(new f.Intersection(h,I,i,[R,L,D],T/3,o.a.dist(I,this._ray.origin)))}}}}}}(),_intersectionCompareFunc:function(e,t){return e.distance-t.distance}});f.Intersection=function(e,t,n,a,i,r){this.point=e,this.pointWorld=t,this.target=n,this.triangle=a,this.triangleIndex=i,this.distance=r},t.a=f},function(e,t,n){"use strict";var a=n(20),i=n(0),r=n.n(i),o=n(7),s=(r.a.vec3,r.a.vec2,a.a.extend({widthSegments:20,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,n=this.attributes.position,a=this.attributes.texcoord0,i=this.attributes.normal,r=(t+1)*(e+1);n.init(r),a.init(r),i.init(r);var s,c,l,u,p,d,f,h=r>65535?Uint32Array:Uint16Array,m=this.indices=new h(t*e*6),v=this.radius,_=this.phiStart,x=this.phiLength,g=this.thetaStart,y=this.thetaLength,v=this.radius,b=[],T=[],E=0,w=1/v;for(f=0;f<=e;f++)for(d=0;d<=t;d++)u=d/t,p=f/e,s=-v*Math.cos(_+u*x)*Math.sin(g+p*y),c=v*Math.cos(g+p*y),l=v*Math.sin(_+u*x)*Math.sin(g+p*y),b[0]=s,b[1]=c,b[2]=l,T[0]=u,T[1]=p,n.set(E,b),a.set(E,T),b[0]*=w,b[1]*=w,b[2]*=w,i.set(E,b),E++;var S,A,N,C,M=t+1,R=0;for(f=0;f0){var i=Math.pow(2,e[3]-128-8+a);t[n+0]=e[0]*i,t[n+1]=e[1]*i,t[n+2]=e[2]*i}else t[n+0]=0,t[n+1]=0,t[n+2]=0;return t[n+3]=1,t}function i(e,t,n){for(var a="",i=t;i0;)if(e[o][0]=t[n++],e[o][1]=t[n++],e[o][2]=t[n++],e[o][3]=t[n++],1===e[o][0]&&1===e[o][1]&&1===e[o][2]){for(var c=e[o][3]<>>0;c>0;c--)r(e[o-1],e[o]),o++,s--;i+=8}else o++,s--,i=0;return n}function s(e,t,n,a){if(ad)return o(e,t,n,a);var i=t[n++];if(2!=i)return o(e,t,n-1,a);if(e[0][1]=t[n++],e[0][2]=t[n++],i=t[n++],(e[0][2]<<8>>>0|i)>>>0!==a)return null;for(var i=0;i<4;i++)for(var r=0;r128){s=(127&s)>>>0;for(var c=t[n++];s--;)e[r++][i]=c}else for(;s--;)e[r++][i]=t[n++]}return n}var c=n(3),l=n(5),u=String.fromCharCode,p=8,d=32767,f={parseRGBE:function(e,t,n){null==n&&(n=0);var r=new Uint8Array(e),o=r.length;if("#?"===i(r,0,2)){for(var p=2;p=o)){p+=2;for(var d="";p=n.x&&t>=n.y&&e<=n.x+n.width&&t<=n.y+n.height};var d=new c.a;a.prototype.castRay=function(e,t,n){var a=this.layer.renderer,i=a.viewport;return a.viewport=this.viewport,a.screenToNDC(e,t,d),this.camera.castRay(d,n),a.viewport=i,n},a.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this._frame=0,this._temporalSS.resetFrame()},a.prototype.render=function(e){this._doRender(e,this._frame),this._frame++},a.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively},a.prototype.needsTemporalSS=function(){var e=this._enableTemporalSS;return"auto"==e&&(e=this._enablePostEffect),e},a.prototype.hasDOF=function(){return this._enableDOF},a.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30},a.prototype._doRender=function(e,t){var n=this.scene,a=this.camera,i=this.renderer;if(t=t||0,!e&&this._shadowMapPass&&(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(i,n,a,!0)),this._updateShadowPCFKernel(t),i.gl.clearColor(0,0,0,0),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(i,a),this._compositor.updateNormal(i,n,a,this._temporalSS.getFrame())),this._updateSSAO(i,n,a,this._temporalSS.getFrame()),this._enablePostEffect){var r=this._compositor.getSourceFrameBuffer();r.bind(i),i.gl.clear(i.gl.DEPTH_BUFFER_BIT|i.gl.COLOR_BUFFER_BIT),i.render(n,a,!0,this.preZ),this.afterRenderScene(i,n,a),r.unbind(i),this.needsTemporalSS()&&e?(this._compositor.composite(i,a,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),i.setViewport(this.viewport),this._temporalSS.render(i)):(i.setViewport(this.viewport),this._compositor.composite(i,a,null,0))}else if(this.needsTemporalSS()&&e){var r=this._temporalSS.getSourceFrameBuffer();r.bind(i),i.saveClear(),i.clearBit=i.gl.DEPTH_BUFFER_BIT|i.gl.COLOR_BUFFER_BIT,i.render(n,a,!0,this.preZ),this.afterRenderScene(i,n,a),i.restoreClear(),r.unbind(i),i.setViewport(this.viewport),this._temporalSS.render(i)}else i.setViewport(this.viewport),i.render(n,a,!0,this.preZ),this.afterRenderScene(i,n,a);this.afterRenderAll(i,n,a)},a.prototype.afterRenderScene=function(e,t,n){},a.prototype.afterRenderAll=function(e,t,n){},a.prototype._updateSSAO=function(e,t,n,a){function i(e){for(var t=0;tthis.camera.far||e0&&(d.define("vertex","SKINNING"),d.define("vertex","JOINT_COUNT",l)),s&&d.define("both","SHADOW_TRANSPARENT"),o.useSkinMatricesTexture&&d.define("vertex","USE_SKIN_MATRICES_TEXTURE"),this._depthShaders[r]=d),p||(p=new h.a({shader:d}),this._depthMaterials[i]=p),o.material=p,this.softShadow===C.VSM?d.define("fragment","USE_VSM"):d.undefine("fragment","USE_VSM"),p.setUniform("bias",t),p.setUniform("slopeScale",n),s&&p.set("shadowTransparentMap",c))}},_bindDistanceMaterial:function(e,t){for(var n=t.getWorldPosition()._array,a=0;a0&&(o.shader.define("vertex","SKINNING"),o.shader.define("vertex","JOINT_COUNT",r)),this._distanceMaterials[r]=o),i.material=o,this.softShadow===C.VSM?o.shader.define("fragment","USE_VSM"):o.shader.undefine("fragment","USE_VSM")),o.set("lightPosition",n),o.set("range",t.range)}},saveMaterial:function(e){for(var t=0;t1&&(v=x,x.shadowCascade>4)){console.warn("Support at most 4 cascade");continue}this.renderDirectionalLightShadow(e,t,n,x,this._opaqueCasters,h,u,l)}else x instanceof p.a?this.renderSpotLightShadow(e,x,this._opaqueCasters,c,s):x instanceof f.a&&this.renderPointLightShadow(e,x,this._opaqueCasters,m);this._shadowMapNumber[x.type]++}this.restoreMaterial(this._opaqueCasters);var g=h.slice(),y=h.slice();g.pop(),y.shift(),g.reverse(),y.reverse(),u.reverse();for(var b=s.map(i),T=l.map(i),E={},_=0;_0?(A.fragmentDefines[R]=M,N=!0):A.isDefined("fragment",R)&&(A.undefine("fragment",R),N=!0))}N&&A.dirty(),v?A.define("fragment","SHADOW_CASCADE",v.shadowCascade):A.undefine("fragment","SHADOW_CASCADE"),E[A.__GUID__]=!0}s.length>0&&(S.setUniform("spotLightShadowMaps",s),S.setUniform("spotLightMatrices",c),S.setUniform("spotLightShadowMapSizes",b)),l.length>0&&(S.setUniform("directionalLightShadowMaps",l),v&&(S.setUniform("shadowCascadeClipsNear",g),S.setUniform("shadowCascadeClipsFar",y)),S.setUniform("directionalLightMatrices",u),S.setUniform("directionalLightShadowMapSizes",T)),m.length>0&&S.setUniform("pointLightShadowMaps",m)}}},renderDirectionalLightShadow:function(){var e=new s.a,t=new c.a,n=new o.a,a=new c.a,i=new c.a,r=new c.a,u=new c.a;return function(o,s,p,d,f,h,m,v){var _=d.shadowBias;if(this._bindDepthMaterial(f,_,d.shadowSlopeScale),f.sort(l.a.opaqueSortFunc),!s.viewBoundingBoxLastFrame.isFinite()){var x=s.getBoundingBox();s.viewBoundingBoxLastFrame.copy(x).applyTransform(p.viewMatrix)}var y=Math.min(-s.viewBoundingBoxLastFrame.min.z,p.far),b=Math.max(-s.viewBoundingBoxLastFrame.max.z,p.near),T=this._getDirectionalLightCamera(d,s,p),E=r._array;u.copy(T.projectionMatrix),A.invert(i._array,T.worldTransform._array),A.multiply(i._array,i._array,p.worldTransform._array),A.multiply(E,u._array,i._array);for(var w=[],S=p instanceof g.a,N=(p.near+p.far)/(p.near-p.far),M=2*p.near*p.far/(p.near-p.far),R=0;R<=d.shadowCascade;R++){var L=b*Math.pow(y/b,R/d.shadowCascade),D=b+(y-b)*R/d.shadowCascade,P=L*d.cascadeSplitLogFactor+D*(1-d.cascadeSplitLogFactor);w.push(P),h.push(-(-P*N+M)/-P)}var I=this._getTexture(d,d.shadowCascade);v.push(I);var O=o.viewport,k=o.gl;this._frameBuffer.attach(I),this._frameBuffer.bind(o),k.clear(k.COLOR_BUFFER_BIT|k.DEPTH_BUFFER_BIT);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&&p.push(l);u.drawBuffersEXT(p)}e.saveClear(),e.clearBit=i.a.DEPTH_BUFFER_BIT|i.a.COLOR_BUFFER_BIT,n=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),e.restoreClear(),a.unbind(e)}else n=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",n),this._rendering=!1,this._rendered=!0}});t.a=o},function(e,t,n){"use strict";var a=n(21),i=a.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,n){"use strict";var a=n(13),i=n(21),r=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 a.a({fragment:this.shader});this.pass=e},{render:function(e,t){this.trigger("beforerender",e),this._rendering=!0;var n=e.gl;for(var a in this.inputLinks){var i=this.inputLinks[a],r=i.node.getOutput(e,i.pin);this.pass.setUniform(a,r)}if(this.outputs){this.pass.outputs={};var o={};for(var s in this.outputs){var c=this.updateParameter(s,e);isNaN(c.width)&&this.updateParameter(s,e);var l=this.outputs[s],u=this._compositor.allocateTexture(c);this._outputTextures[s]=u;var p=l.attachment||n.COLOR_ATTACHMENT0;"string"==typeof p&&(p=n[p]),o[p]=u}this._compositor.getFrameBuffer().bind(e);for(var p in o)this._compositor.getFrameBuffer().attach(o[p],p);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 a in this.inputLinks){var i=this.inputLinks[a];i.node.removeReference(i.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",e)},updateParameter:function(e,t){var n=this.outputs[e],a=n.parameters,i=n._parametersCopy;if(i||(i=n._parametersCopy={}),a)for(var r in a)"width"!==r&&"height"!==r&&(i[r]=a[r]);var o,s;return o=a.width instanceof Function?a.width.call(this,t):a.width,s=a.height instanceof Function?a.height.call(this,t):a.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])},setShader:function(e){var t=this.pass.material;t.shader.setFragment(e),t.attachShader(t.shader,!0)},shaderDefine:function(e,t){this.pass.material.shader.define("fragment",e,t)},shaderUndefine:function(e){this.pass.material.shader.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])}},link:function(e,t,n){this.inputLinks[e]={node:t,pin:n},t.outputLinks[n]||(t.outputLinks[n]=[]),t.outputLinks[n].push({node:this,pin:e}),this.pass.material.shader.enableTexture(e)},clear:function(){i.a.prototype.clear.call(this),this.pass.material.shader.disableTexturesAll()},updateReference:function(e){if(!this._rendering){this._rendering=!0;for(var t in this.inputLinks){var n=this.inputLinks[t];n.node.updateReference(n.pin)}this._rendering=!1}e&&this._outputReferences[e]++},beforeFrame:function(){this._rendered=!1;for(var e in this.outputLinks)this._outputReferences[e]=0},afterFrame:function(){for(var e in this.outputLinks)if(this._outputReferences[e]>0){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=r},function(e,t,n){"use strict";function a(e){for(var t=new Uint8Array(e*e*4),n=0,a=new c.a,i=0;i0&&(a.shader.define("vertex","SKINNING"),a.shader.define("vertex","JOINT_COUNT",e),i.shader.define("vertex","SKINNING"),i.shader.define("vertex","JOINT_COUNT",e)),n={material1:a,material2:i},t[e]=n}return n.used=!0,n},_resetGBufferMaterials:function(){for(var e in this._gBufferMaterials)this._gBufferMaterials[e].used=!1},_cleanGBufferMaterials:function(e){for(var t in this._gBufferMaterials){var n=this._gBufferMaterials[t];n.used||(n.material1.dispose(e),n.material2.dispose(e))}},_replaceGBufferMat:function(e,t){for(var n=0;n>>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;for(var l=0;l255?255:e}function i(e){return e<0?0:e>1?1:e}function r(e){return a(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100*255:parseInt(e,10))}function o(e){return i(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100:parseFloat(e))}function s(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}function c(e,t,n,a,i){return e[0]=t,e[1]=n,e[2]=a,e[3]=i,e}function l(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function u(e,t){_&&l(_,t),_=v.put(e,_||t.slice())}function p(e,t){if(e){t=t||[];var n=v.get(e);if(n)return l(t,n);e+="";var a=e.replace(/ /g,"").toLowerCase();if(a in m)return l(t,m[a]),u(e,t),t;if("#"!==a.charAt(0)){var i=a.indexOf("("),s=a.indexOf(")");if(-1!==i&&s+1===a.length){var p=a.substr(0,i),f=a.substr(i+1,s-(i+1)).split(","),h=1;switch(p){case"rgba":if(4!==f.length)return void c(t,0,0,0,1);h=o(f.pop());case"rgb":return 3!==f.length?void c(t,0,0,0,1):(c(t,r(f[0]),r(f[1]),r(f[2]),h),u(e,t),t);case"hsla":return 4!==f.length?void c(t,0,0,0,1):(f[3]=o(f[3]),d(f,t),u(e,t),t);case"hsl":return 3!==f.length?void c(t,0,0,0,1):(d(f,t),u(e,t),t);default:return}}c(t,0,0,0,1)}else{if(4===a.length){var _=parseInt(a.substr(1),16);return _>=0&&_<=4095?(c(t,(3840&_)>>4|(3840&_)>>8,240&_|(240&_)>>4,15&_|(15&_)<<4,1),u(e,t),t):void c(t,0,0,0,1)}if(7===a.length){var _=parseInt(a.substr(1),16);return _>=0&&_<=16777215?(c(t,(16711680&_)>>16,(65280&_)>>8,255&_,1),u(e,t),t):void c(t,0,0,0,1)}}}}function d(e,t){var n=(parseFloat(e[0])%360+360)%360/360,i=o(e[1]),r=o(e[2]),l=r<=.5?r*(i+1):r+i-r*i,u=2*r-l;return t=t||[],c(t,a(255*s(u,l,n+1/3)),a(255*s(u,l,n)),a(255*s(u,l,n-1/3)),1),4===e.length&&(t[3]=e[3]),t}function f(e,t){if(e&&e.length){var n=e[0]+","+e[1]+","+e[2];return"rgba"!==t&&"hsva"!==t&&"hsla"!==t||(n+=","+e[3]),t+"("+n+")"}}t.a=p,t.b=f;var h=n(63),m={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 h.a(20),_=null},function(e,t,n){"use strict";t.a={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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 / 32, height * 1.0 / 32] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(qtek.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(qtek.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 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blend",shader:"#source(qtek.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(qtek.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(qtek.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 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blend",shader:"#source(qtek.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(qtek.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(qtek.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 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blend",shader:"#source(qtek.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(qtek.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(qtek.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 / 2, height * 1.0 / 2] )"}},{name:"bloom_composite",shader:"#source(qtek.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(qtek.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},defines:{}},{name:"FXAA",shader:"#source(qtek.compositor.fxaa)",inputs:{texture:"composite"}}]}},function(e,t,n){"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 qtek.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 qtek.util.rgbm\n@import qtek.util.float\n\nvoid main()\n{\n vec4 blurredColor = decodeHDR(texture2D(blurred, v_Texcoord));\n vec4 originalColor = decodeHDR(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 = decodeHDR(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 qtek.util.rgbm\n@import qtek.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 = decodeHDR(texel);\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\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 gl_FragColor = encodeHDR(color);\n#endif\n}\n\n@end"},function(e,t,n){"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,n){"use strict";function a(){for(var e=[],t=0;t<30;t++)e.push([Object(i.a)(t,2),Object(i.a)(t,3)]);this._haltonSequence=e,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 r.a({fragment:c.a.source("qtek.compositor.blend")});n.material.shader.disableTexturesAll(),n.material.shader.enableTexture(["texture1","texture2"]),this._blendFb=new o.a({depthBuffer:!1}),this._outputPass=new r.a({fragment:c.a.source("qtek.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.shader.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=n(28),r=n(13),o=n(10),s=n(5),c=n(4),l=n(8);a.prototype={constructor:a,jitterProjection:function(e,t){var n=e.viewport,a=n.devicePixelRatio||e.getDevicePixelRatio(),i=n.width*a,r=n.height*a,o=this._haltonSequence[this._frame],s=new l.a;s._array[12]=(2*o[0]-1)/i,s._array[13]=(2*o[1]-1)/r,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},resize:function(e,t){this._sourceTex.width===e&&this._sourceTex.height===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){var t=this._blendPass;0===this._frame?(t.setUniform("weight1",0),t.setUniform("weight2",1)):(t.setUniform("weight1",.9),t.setUniform("weight2",.1)),t.setUniform("texture1",this._prevFrameTex),t.setUniform("texture2",this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),t.render(e),this._blendFb.unbind(e),this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e);var n=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=n,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=a},function(e,t,n){"use strict";function a(e){this.setScene(e)}var i=n(29),r=n(36),o=n(35),s=n(2),c=n(60),l=n(132);a.prototype={constructor:a,setScene:function(e){this._scene=e,this._skybox&&this._skybox.attachScene(this._scene)},initLight:function(e){this._lightRoot=e,this.mainLight=new c.a({shadowBias:.005}),this.secondaryLight=new c.a({shadowBias:.005}),this.tertiaryLight=new c.a({shadowBias:.005}),this.ambientLight=new l.a},dispose:function(e){this._lightRoot&&(this._lightRoot.remove(this.mainLight),this._lightRoot.remove(this.ambientLight)),this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._currentCubemapLights.specular&&(this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights.specular.cubemap.dispose(e)))},updateMainLight:function(e,t){this._updateDirectionalLight(this.mainLight,e,t)},updateSecondaryLight:function(e,t){this._updateDirectionalLight(this.secondaryLight,e,t)},updateTertiaryLight:function(e,t){this._updateDirectionalLight(this.tertiaryLight,e,t)},_updateDirectionalLight:function(e,t,n){t=t||{},null!=t.intensity&&(e.intensity=t.intensity,this._lightRoot[t.intensity?"add":"remove"](e)),null!=t.color&&(e.color=i.a.parseColor(t.color).slice(0,3));var a=i.a.firstNotNull(t.alpha,45),r=i.a.firstNotNull(t.beta,45);e.position.setArray(i.a.directionFromAlphaBeta(a,r)),e.lookAt(s.a.ZERO);var o={low:512,medium:1024,high:2048,ultra:4096}[t.quality]||1024;e.castShadow=i.a.firstNotNull(t.shadow,!0),e.shadowResolution=o},updateAmbientLight:function(e,t){e=e||{},null!=e.intensity&&(this.ambientLight.intensity=e.intensity,this._lightRoot[e.intensity?"add":"remove"](this.ambientLight)),null!=e.color&&(this.ambientLight.color=i.a.parseColor(e.color).slice(0,3))},updateAmbientCubemapLight:function(e,t){e=e||{};var n=t.getRenderer(),a=e.texture,o=this;if(!this._currentCubemapLights||a!==this._currentCubemapLights.textureUrl)if(this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._currentCubemapLights.specular&&(this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights.specular.cubemap.dispose(n.gl))),a){var s=i.a.createAmbientCubemap(e,t,function(){s.specular&&o._skybox instanceof r.a&&o._skybox.setEnvironmentMap(s.specular.cubemap),t.refresh()});s.diffuse&&this._lightRoot.add(s.diffuse),s.specular&&this._lightRoot.add(s.specular),this._currentCubemapLights=s,this._currentCubemapLights.textureUrl=a}else this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights=null);this._currentCubemapLights&&(null!=e.specularIntensity&&this._currentCubemapLights.specular&&(this._currentCubemapLights.specular.intensity=e.specularIntensity),null!=e.diffuseIntensity&&this._currentCubemapLights.diffuse&&(this._currentCubemapLights.diffuse.intensity=e.diffuseIntensity))},updateSkybox:function(e,t,n){var a=n.getRenderer(),s=this;if(e&&"none"!==e)if("auto"===e)if(this._currentCubemapLights){var c=function(){return s._skybox instanceof r.a||(s._skybox&&s._skybox.dispose(a),s._skybox=new r.a),s._skybox}();if(this._currentCubemapLights.specular){var l=this._currentCubemapLights.specular.cubemap;c.setEnvironmentMap(l)}this._scene&&c.attachScene(this._scene),c.material.set("lod",2)}else this._skybox&&this._skybox.detachScene();else{var u=function(){return s._skybox instanceof o.a||(s._skybox&&s._skybox.dispose(a),s._skybox=new o.a),s._skybox}(),p=i.a.loadTexture(e,n,{flipY:!1},function(){n.refresh()});u.setEnvironmentMap(p),u.attachScene(this._scene)}else this._skybox&&this._skybox.detachScene(this._scene),this._skybox=null;if(this._skybox)if("auto"===e||e.match&&e.match(/.hdr$/))this._skybox.material.shader.undefine("fragment","SRGB_DECODE");else{var d=t?"define":"undefine";this._skybox.material.shader[d]("fragment","SRGB_DECODE")}}},t.a=a},function(e,t,n){"use strict";var a=n(14),i=a.a.extend({castShadow:!1},{type:"AMBIENT_LIGHT",uniformTemplates:{ambientLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}}});t.a=i},function(e,t,n){"use strict";t.a={devicePixelRatio:null,preZ:!1,picking:!1,shadow:!0,environment:"",ground:{show:!1},mainLight:{shadow:!0,shadowQuality:"medium",intensity:.8,color:"#fff",alpha:45,beta:45},secondaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:60,beta:-50},tertiaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:89,beta:0},ambientLight:{intensity:.3,color:"#fff"},ambientCubemapLight:{texture:"",exposure:3,diffuseIntensity:.5,specularIntensity:.5},postEffect:{enable:!1,bloom:{enable:!1,intensity:.1},depthOfField:{enable:!1,focalDistance:5,focalRange:1,blurRadius:5,fstop:2.8,quality:"medium"},screenSpaceAmbientOcculusion:{enable:!1,radius:.5,quality:"medium",intensity:1},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},FXAA:{enable:!1}}}},function(e,t,n){"use strict";function a(e){if(null==e||"object"!=typeof e)return e;var t=e,n=m.call(e);if("[object Array]"===n){t=[];for(var i=0,r=e.length;i=0&&i[d]>1e-6&&(c.transformMat4(s,n,r[a[d]]),c.scaleAndAdd(o,o,s,i[d]));c.min(v,v,o),c.max(_,_,o)}t.min.setArray(v),t.max.setArray(_)}function i(e,t){t=t||new r.a;var n=new r.a;return e.traverse(function(e){e.geometry&&(e.isSkinnedMesh()?(a(e,n),e.geometry.boundingBox.copy(n)):(n.copy(e.geometry.boundingBox),n.applyTransform(e.worldTransform)),t.union(n))}),t}var r=n(7),o=n(0),s=n.n(o),c=s.a.vec3;t.a=i},function(e,t,n){"use strict";function a(e){return Array.isArray(e)||(e=[e,e]),e}var i=n(1),r=n(24),o=n(2),s=n(137),c=i.a.extend(function(){return{animation:null,domElement:null,target:null,_center:new o.a,minDistance:.1,maxDistance:1e3,minAlpha:-90,maxAlpha:90,minBeta:-1/0,maxBeta:1/0,autoRotateAfterStill:0,autoRotateDirection:"cw",autoRotateSpeed:60,_mode:"rotate",damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,_needsUpdate:!1,_rotating:!1,_phi:0,_theta:0,_mouseX:0,_mouseY:0,_rotateVelocity:new r.a,_panVelocity:new r.a,_distance:20,_zoomSpeed:0,_stillTimeout:0,_animators:[],_gestureMgr:new s.a}},function(){this._mouseDownHandler=this._mouseDownHandler.bind(this),this._mouseWheelHandler=this._mouseWheelHandler.bind(this),this._mouseMoveHandler=this._mouseMoveHandler.bind(this),this._mouseUpHandler=this._mouseUpHandler.bind(this),this._pinchHandler=this._pinchHandler.bind(this),this.update=this.update.bind(this),this.init()},{init:function(){var e=this.domElement;e.addEventListener("touchstart",this._mouseDownHandler),e.addEventListener("mousedown",this._mouseDownHandler),e.addEventListener("mousewheel",this._mouseWheelHandler),this.animation&&this.animation.on("frame",this.update)},dispose:function(){var e=this.domElement;e.removeEventListener("touchstart",this._mouseDownHandler),e.removeEventListener("touchmove",this._mouseMoveHandler),e.removeEventListener("touchend",this._mouseUpHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseup",this._mouseUpHandler),e.removeEventListener("mousewheel",this._mouseWheelHandler),this.animation&&this.animation.off("frame",this.update),this.stopAllAnimation()},getDistance:function(){return this._distance},setDistance:function(e){this._distance=e,this._needsUpdate=!0},getAlpha:function(){return this._theta/Math.PI*180},getBeta:function(){return-this._phi/Math.PI*180},getCenter:function(){return this._center.toArray()},setAlpha:function(e){e=Math.max(Math.min(this.maxAlpha,e),this.minAlpha),this._theta=e/180*Math.PI,this._needsUpdate=!0},setBeta:function(e){e=Math.max(Math.min(this.maxBeta,e),this.minBeta),this._phi=-e/180*Math.PI,this._needsUpdate=!0},setCenter:function(e){this._center.setArray(e)},setOption:function(e){e=e||{},["autoRotate","autoRotateAfterStill","autoRotateDirection","autoRotateSpeed","damping","minDistance","maxDistance","minAlpha","maxAlpha","minBeta","maxBeta","rotateSensitivity","zoomSensitivity","panSensitivity"].forEach(function(t){null!=e[t]&&(this[t]=e[t])},this),null!=e.distance&&this.setDistance(e.distance),null!=e.alpha&&this.setAlpha(e.alpha),null!=e.beta&&this.setBeta(e.beta),e.center&&this.setCenter(e.center)},animateTo:function(e){var t=this,n={},a={},i=this.animation;if(i)return null!=e.distance&&(n.distance=this.getDistance(),a.distance=e.distance),null!=e.alpha&&(n.alpha=this.getAlpha(),a.alpha=e.alpha),null!=e.beta&&(n.beta=this.getBeta(),a.beta=e.beta),null!=e.center&&(n.center=this.getCenter(),a.center=e.center),this._addAnimator(i.animate(n).when(e.duration||1e3,a).during(function(){null!=n.alpha&&t.setAlpha(n.alpha),null!=n.beta&&t.setBeta(n.beta),null!=n.distance&&t.setDistance(n.distance),null!=n.center&&t.setCenter(n.center),t._needsUpdate=!0}).done(e.done)).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e0},update:function(e){if(e=e||16,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)>.01||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(this._updateDistance(Math.min(e,50)),this._updatePan(Math.min(e,50)),this._updateRotate(Math.min(e,50)),this._updateTransform(),this.target.update(),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,this.damping)},_updateDistance:function(e){this._setDistance(this._distance+this._zoomSpeed*e/20),this._zoomSpeed*=this.damping},_setDistance:function(e){this._distance=Math.max(Math.min(e,this.maxDistance),this.minDistance)},_updatePan:function(e){var t=this._panVelocity,n=this._distance,a=this.target,i=a.worldTransform.y,r=a.worldTransform.x;this._center.scaleAndAdd(r,-t.x*n/200).scaleAndAdd(i,-t.y*n/200),this._vectorDamping(t,0)},_updateTransform:function(){var e=this.target,t=new o.a,n=this._theta+Math.PI/2,a=this._phi+Math.PI/2,i=Math.sin(n);t.x=i*Math.cos(a),t.y=-Math.cos(n),t.z=i*Math.sin(a),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 n=e.len();n*=t,n<1e-4&&(n=0),e.normalize().scale(n)},decomposeTransform:function(){if(this.target){var e=new o.a;e.eulerFromQuat(this.target.rotation.normalize(),"ZYX"),this._theta=-e.x,this._phi=-e.y,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this._setDistance(this.target.position.dist(this._center))}},_mouseDownHandler:function(e){if(!this._isAnimating()){var t=e.clientX,n=e.clientY;if(e.targetTouches){var a=e.targetTouches[0];t=a.clientX,n=a.clientY,this._mode="rotate",this._processGesture(e,"start")}var i=this.domElement;i.addEventListener("touchmove",this._mouseMoveHandler),i.addEventListener("touchend",this._mouseUpHandler),i.addEventListener("mousemove",this._mouseMoveHandler),i.addEventListener("mouseup",this._mouseUpHandler),0===e.button?this._mode="rotate":1===e.button&&(this._mode="pan"),this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=t,this._mouseY=n}},_mouseMoveHandler:function(e){if(!this._isAnimating()){var t,n=e.clientX,i=e.clientY;if(e.targetTouches){var r=e.targetTouches[0];n=r.clientX,i=r.clientY,t=this._processGesture(e,"change")}var o=a(this.panSensitivity),s=a(this.rotateSensitivity);t||("rotate"===this._mode?(this._rotateVelocity.y=(n-this._mouseX)/this.domElement.clientHeight*2*s[0],this._rotateVelocity.x=(i-this._mouseY)/this.domElement.clientWidth*2*s[1]):"pan"===this._mode&&(this._panVelocity.x=(n-this._mouseX)/this.domElement.clientWidth*o[0]*400,this._panVelocity.y=(-i+this._mouseY)/this.domElement.clientHeight*o[1]*400)),this._mouseX=n,this._mouseY=i,e.preventDefault()}},_mouseWheelHandler:function(e){if(!this._isAnimating()){var t=e.wheelDelta||-e.detail;0!==t&&this._zoomHandler(e,t>0?-1:1)}},_pinchHandler:function(e){this._isAnimating()||this._zoomHandler(e,e.pinchScale>1?-.4:.4)},_zoomHandler:function(e,t){var n=Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance));this._zoomSpeed=t*Math.max(n/40*this.zoomSensitivity,.2),this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),e.preventDefault()},_mouseUpHandler:function(e){var t=this.domElement;t.removeEventListener("touchmove",this._mouseMoveHandler),t.removeEventListener("touchend",this._mouseUpHandler),t.removeEventListener("mousemove",this._mouseMoveHandler),t.removeEventListener("mouseup",this._mouseUpHandler),this._processGesture(e,"end")},_addAnimator:function(e){var t=this._animators;return t.push(e),e.done(function(){var n=t.indexOf(e);n>=0&&t.splice(n,1)}),e},_processGesture:function(e,t){var n=this._gestureMgr;"start"===t&&n.clear();var a=n.recognize(e,null,this.domElement);if("end"===t&&n.clear(),a){var i=a.type;e.gestureEvent=i,this._pinchHandler(a.event)}return a}});Object.defineProperty(c.prototype,"autoRotate",{get:function(){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}}),Object.defineProperty(c.prototype,"target",{get:function(){return this._target},set:function(e){e&&e.target&&this.setCenter(e.target.toArray()),this._target=e,this.decomposeTransform()}}),t.a=c},function(e,t,n){"use strict";function a(e){var t=e[1][0]-e[0][0],n=e[1][1]-e[0][1];return Math.sqrt(t*t+n*n)}function i(e){return[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2]}var r=function(){this._track=[]};r.prototype={constructor:r,recognize:function(e,t,n){return this._doTrack(e,t,n),this._recognize(e)},clear:function(){return this._track.length=0,this},_doTrack:function(e,t,n){var a=e.targetTouches;if(a){for(var i={points:[],touches:[],target:t,event:e},r=0,o=a.length;r1&&r&&r.length>1){var s=a(r)/a(o);!isFinite(s)&&(s=1),t.pinchScale=s;var c=i(r);return t.pinchX=c[0],t.pinchY=c[1],{type:"pinch",target:e[0].target,event:t}}}}};t.a=r},function(e,t,n){"use strict";var a=n(1),i=n(139),r=n(7),o=a.a.extend(function(){return{dom:null,renderer:null,camera:null,_boundingBox:new r.a,_hotspotRoot:null,_hotspots:[]}},function(){if(!this.dom||!this.renderer||!this.camera)throw new Error("Tip manager needs `root`, `camera`, `renderer`");var e=this._hotspotRoot=document.createElement("div");e.style.cssText="position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;",this.dom.appendChild(e)},{setBoundingBox:function(e,t){this._boundingBox.min.setArray(e),this._boundingBox.max.setArray(t)},add:function(e,t){if("string"==typeof t){var n=document.createElement("div");n.innerHTML=t,t=n}return t.classList.add("qmv-annotation"),t.style.position="absolute",this._hotspotRoot.appendChild(t),this._hotspots.push({position:e,dom:t}),t},remove:function(e){for(var t=-1,n=0;n=0&&(this._hotspots.splice(t,1),this._hotspotRoot.removeChild(e))},update:function(){var e=new i.a,t=new r.a;this._hotspots.forEach(function(n){var a=n.position;e.set(a[0],a[1],a[2],1),e.transformMat4(this.camera.viewMatrix);var i=e.z;e.transformMat4(this.camera.projectionMatrix),e.scale(1/e.w);var r=.5*(e.x+1)*this.renderer.getWidth(),o=.5*(e.y+1)*this.renderer.getHeight();n.dom.style.left=r+"px",n.dom.style.top=this.renderer.getHeight()-o+"px";var s=null==n.farAlpha?.1:n.farAlpha,c=null==n.nearAlpha?1:n.nearAlpha;t.copy(this._boundingBox),t.applyTransform(this.camera.viewMatrix);var l=(i-t.max.z)/(t.min.z-t.max.z);Math.max(Math.min(l,1),0);n.dom.style.opacity=1,n.onupdate&&n.onupdate(r,o)},this)}});t.a=o},function(e,t,n){"use strict";var a=n(0),i=n.n(a),r=i.a.vec4,o=function(e,t,n,a){e=e||0,t=t||0,n=n||0,a=a||0,this._array=r.fromValues(e,t,n,a),this._dirty=!0};o.prototype={constructor:o,add:function(e){return r.add(this._array,this._array,e._array),this._dirty=!0,this},set:function(e,t,n,a){return this._array[0]=e,this._array[1]=t,this._array[2]=n,this._array[3]=a,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)},copy:function(e){return r.copy(this._array,e._array),this._dirty=!0,this},dist:function(e){return r.dist(this._array,e._array)},distance:function(e){return r.distance(this._array,e._array)},div:function(e){return r.div(this._array,this._array,e._array),this._dirty=!0,this},divide:function(e){return r.divide(this._array,this._array,e._array),this._dirty=!0,this},dot:function(e){return r.dot(this._array,e._array)},len:function(){return r.len(this._array)},length:function(){return r.length(this._array)},lerp:function(e,t,n){return r.lerp(this._array,e._array,t._array,n),this._dirty=!0,this},min:function(e){return r.min(this._array,this._array,e._array),this._dirty=!0,this},max:function(e){return r.max(this._array,this._array,e._array),this._dirty=!0,this},mul:function(e){return r.mul(this._array,this._array,e._array),this._dirty=!0,this},multiply:function(e){return r.multiply(this._array,this._array,e._array),this._dirty=!0,this},negate:function(){return r.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return r.normalize(this._array,this._array),this._dirty=!0,this},random:function(e){return r.random(this._array,e),this._dirty=!0,this},scale:function(e){return r.scale(this._array,this._array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return r.scaleAndAdd(this._array,this._array,e._array,t),this._dirty=!0,this},sqrDist:function(e){return r.sqrDist(this._array,e._array)},squaredDistance:function(e){return r.squaredDistance(this._array,e._array)},sqrLen:function(){return r.sqrLen(this._array)},squaredLength:function(){return r.squaredLength(this._array)},sub:function(e){return r.sub(this._array,this._array,e._array),this._dirty=!0,this},subtract:function(e){return r.subtract(this._array,this._array,e._array),this._dirty=!0,this},transformMat4:function(e){return r.transformMat4(this._array,this._array,e._array),this._dirty=!0,this},transformQuat:function(e){return r.transformQuat(this._array,this._array,e._array),this._dirty=!0,this},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 c=o.prototype;s(c,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),s(c,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),s(c,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}}),s(c,"w",{get:function(){return this._array[3]},set:function(e){this._array[3]=e,this._dirty=!0}})}o.add=function(e,t,n){return r.add(e._array,t._array,n._array),e._dirty=!0,e},o.set=function(e,t,n,a,i){r.set(e._array,t,n,a,i),e._dirty=!0},o.copy=function(e,t){return r.copy(e._array,t._array),e._dirty=!0,e},o.dist=function(e,t){return r.distance(e._array,t._array)},o.distance=o.dist,o.div=function(e,t,n){return r.divide(e._array,t._array,n._array),e._dirty=!0,e},o.divide=o.div,o.dot=function(e,t){return r.dot(e._array,t._array)},o.len=function(e){return r.length(e._array)},o.lerp=function(e,t,n,a){return r.lerp(e._array,t._array,n._array,a),e._dirty=!0,e},o.min=function(e,t,n){return r.min(e._array,t._array,n._array),e._dirty=!0,e},o.max=function(e,t,n){return r.max(e._array,t._array,n._array),e._dirty=!0,e},o.mul=function(e,t,n){return r.multiply(e._array,t._array,n._array),e._dirty=!0,e},o.multiply=o.mul,o.negate=function(e,t){return r.negate(e._array,t._array),e._dirty=!0,e},o.normalize=function(e,t){return r.normalize(e._array,t._array),e._dirty=!0,e},o.random=function(e,t){return r.random(e._array,t),e._dirty=!0,e},o.scale=function(e,t,n){return r.scale(e._array,t._array,n),e._dirty=!0,e},o.scaleAndAdd=function(e,t,n,a){return r.scaleAndAdd(e._array,t._array,n._array,a),e._dirty=!0,e},o.sqrDist=function(e,t){return r.sqrDist(e._array,t._array)},o.squaredDistance=o.sqrDist,o.sqrLen=function(e){return r.sqrLen(e._array)},o.squaredLength=o.sqrLen,o.sub=function(e,t,n){return r.subtract(e._array,t._array,n._array),e._dirty=!0,e},o.subtract=o.sub,o.transformMat4=function(e,t,n){return r.transformMat4(e._array,t._array,n._array),e._dirty=!0,e},o.transformQuat=function(e,t,n){return r.transformQuat(e._array,t._array,n._array),e._dirty=!0,e},t.a=o},function(e,t,n){"use strict";t.a="@export qmv.ground.vertex\n@import qtek.lambert.vertex\n@end\n\n\n@export qmv.ground.fragment\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float gridSize: 5;\nuniform float gridSize2: 1;\nuniform vec4 gridColor: [0, 0, 0, 1];\nuniform vec4 gridColor2: [0.3, 0.3, 0.3, 1];\n\nuniform float glossiness: 0.7;\n\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import qtek.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import qtek.header.ambient_sh_light\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import qtek.header.directional_light\n#endif\n\n@import qtek.plugin.compute_shadow_map\n\nvoid main()\n{\n gl_FragColor = color;\n\n float wx = v_WorldPosition.x;\n float wz = v_WorldPosition.z;\n float x0 = abs(fract(wx / gridSize - 0.5) - 0.5) / fwidth(wx) * gridSize / 2.0;\n float z0 = abs(fract(wz / gridSize - 0.5) - 0.5) / fwidth(wz) * gridSize / 2.0;\n\n float x1 = abs(fract(wx / gridSize2 - 0.5) - 0.5) / fwidth(wx) * gridSize2;\n float z1 = abs(fract(wz / gridSize2 - 0.5) - 0.5) / fwidth(wz) * gridSize2;\n\n float v0 = 1.0 - clamp(min(x0, z0), 0.0, 1.0);\n float v1 = 1.0 - clamp(min(x1, z1), 0.0, 1.0);\n if (v0 > 0.1) {\n gl_FragColor = mix(gl_FragColor, gridColor, v0);\n }\n else {\n gl_FragColor = mix(gl_FragColor, gridColor2, v1);\n }\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {\n diffuseColor += ambientLightColor[_idx_];\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_, v_Normal) * ambientSHLightColor[_idx_];\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 i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float ndl = dot(v_Normal, normalize(lightDirection));\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 diffuseColor += lightColor * clamp(ndl, 0.0, 1.0) * shadowContrib;\n }\n#endif\n\n#ifdef SSAOMAP_ENABLED\n diffuseColor *= texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n gl_FragColor.a *= 1.0 - clamp(length(v_WorldPosition.xz) / 30.0, 0.0, 1.0);\n\n}\n\n@end"},function(e,t,n){"use strict";var a=n(37);t.a=function(){return{preZ:!0,materials:[],takes:[],textureFlipY:!1,zUpToYUp:!1,shadow:!0,environment:"auto",viewControl:{alpha:20,beta:30,distance:18},ground:{show:!0},mainLight:{shadow:!0,shadowQuality:"medium",intensity:.8,color:"#fff",alpha:45,beta:45,$padAngle:[.25,.5]},secondaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:60,beta:-50,$padAngle:[-50/180,60/90]},tertiaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:89,beta:0,$padAngle:[0,89/90]},ambientLight:{intensity:0,color:"#fff"},ambientCubemapLight:{texture:a.a.ENV_TEXTURE_ROOT+"pisa.hdr",$texture:"pisa",$textureOptions:["pisa","Barce_Rooftop_C","Factory_Catwalk","Grand_Canyon_C","Ice_Lake","Hall","Old_Industrial_Hall"],exposure:3,diffuseIntensity:.5,specularIntensity:.5,$intensity:.5},postEffect:{enable:!0,bloom:{enable:!0,intensity:.1},depthOfField:{enable:!1,focalDistance:4,focalRange:1,blurRadius:5,fstop:10,quality:"medium",$qualityOptions:["low","medium","high","ultra"]},screenSpaceAmbientOcclusion:{enable:!1,radius:1.5,quality:"medium",intensity:1,$qualityOptions:["low","medium","high","ultra"]},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8,$qualityOptions:["low","medium","high","ultra"]},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},FXAA:{enable:!1}}}}},function(e,t,n){"use strict";t.a=function(){return{name:"",type:"pbrMetallicRoughness",color:"#fff",transparent:!1,alpha:1,alphaCutoff:0,diffuseMap:"",normalMap:"",parallaxOcclusionScale:.01,parallaxOcclusionMap:"",emission:"#fff",emissionIntensity:0,emissiveMap:"",uvRepeat:[1,1],metalness:0,roughness:.5,metalnessMap:"",roughnessMap:"",glossiness:.5,specularColor:"#111",glossinessMap:"",specularMap:"",$alphaRange:[0,1],$alphaCutoffRange:[0,1],$metalnessRange:[0,1],$roughnessRange:[0,1],$glossinessRange:[0,1],$parallaxOcclusionScaleRange:[0,.1],$textureTiling:1}}},function(e,t,n){"use strict";function a(e){var t=e.lastIndexOf(".");return t>=0?e.substr(t+1).toLowerCase():""}function i(e,t){var n=e.split("/");return t=t||"",0===e.indexOf("/")&&n.shift(),n=n.filter(function(e){return!!e}),new Promise(function(e,a){if(!x)return void a(E);var r=n.shift(),o=t+"/"+r;x.mkdir(o,function(t){t&&"EEXIST"!==t.code?a(t.toString()):n.length?i(n.join("/"),o).then(e).catch(a):e()})})}function r(e){return new Promise(function(t,n){if(!x)return void n(E);s(e).then(function(t){return Promise.all(t.map(function(t){return new Promise(function(n,a){var i=e+"/"+t;x.lstat(i,function(e,t){e?a(e.toString()):t.isDirectory()?r(i).then(n,a):x.unlink(i,function(e){e?a(e.toString()):n()})})})}))},n).then(function(){x.rmdir(e,function(e){e?n(e.toString()):t()})},n)})}function o(e,t){return new Promise(function(n,a){x||a(E),FileAPI.readAsArrayBuffer(t,function(i){"load"===i.type&&x.writeFile(e,T.from(i.result),function(e){e&&"EEXIST"!==e.code?a(e):(console.log("Writed file "+t.name+" "+i.result.byteLength),n())})})})}function s(e){return new Promise(function(t,n){x.readdir(e,function(e,a){e?n(e):t(a)})})}function c(e){BrowserFS.install(window),BrowserFS.configure({fs:"IndexedDB",options:{}},function(t){if(t)throw t;x=BrowserFS.BFSRequire("fs"),i("/project").then(function(){Promise.all([d(),p()]).then(function(t){t[0]?e&&e(t[0].glTF,t[0].filesMap,t[1]):e()}).catch(function(t){e()})},function(t){e()})})}function l(e){function t(){return i("/project/model").then(function(){return Promise.all(e.map(function(e){return o("/project/model/"+e.name,e)}))})}return r("/project/model").then(function(){return t()},function(e){return t()})}function u(e){return i("/project").then(function(){return o("/project/scene.json",new File([JSON.stringify(e)],"scene.json",{type:"application/json"}))})}function p(){return new Promise(function(e,t){if(!x)return void t(E);x.readFile("/project/scene.json","utf-8",function(t,n){if(t)e(null);else{var a=null;try{a=JSON.parse(n)}catch(e){console.error(e)}e(a)}})})}function d(){return m().then(function(e){return v(e)})}function f(e){return i("/project/model").then(function(){return o("/project/model/"+e.name,e)})}function h(){return r("/project")}function m(){return s("/project/model").then(function(e){return Promise.all(e.map(function(e){return new Promise(function(t,n){x.readFile("/project/model/"+e,function(i,r){i?n(i):t(new File([r],e,{type:b.a.lookup(a(e))}))})})}))})}function v(e){return new Promise(function(t,n){function a(n,a,o){function s(t){var n=0;e.forEach(function(e){e!==i&&(n++,l[e.name]=URL.createObjectURL(e))}),t&&t(l)}e=e.filter(function(e){return e.name.match(/.(gltf|bin|glb)$/)||e.type.match(/image/)});for(var c in w)URL.revokeObjectURL(w[c]);var l={};w=l,a?s(function(i){e.push(new File([a],n+".gltf",{type:"application/json"}),new File([o],n+".bin",{type:"application/octet-stream"})),t({glTF:JSON.parse(a),filesMap:i,buffers:[o],allFiles:e})}):r?FileAPI.readAsArrayBuffer(r,function(n){"load"===n.type&&s(function(a){t({glTF:n.result,filesMap:a,allFiles:e})})}):i&&FileAPI.readAsText(i,"utf-8",function(n){if("load"===n.type){var a;try{a=JSON.parse(n.result)}catch(e){return void t(null)}s(function(n){t({glTF:a,filesMap:n,allFiles:e})})}})}var i=e.find(function(e){return e.name.endsWith(".gltf")}),r=e.find(function(e){return e.name.endsWith(".glb")});if(i||r)a();else{n("No glTF file found")}})}function _(e,t,n){Promise.all([m(),p()]).then(function(a){var i,r=a[0],o=a[1],s=new JSZip,c={};if(r=(r||[]).filter(function(e){if(!e.name.endsWith(".gltf"))return c[e.name]=e,!0;i=e}),!i)return swal("No glTF file in project!"),void(n&&n());Promise.all(o.materials.map(function(e,t){if(e.metalnessMap||e.roughnessMap){var n=c[e.metalnessMap],a=c[e.roughnessMap];return new Promise(function(i){Object(g.b)(n,a,e.metalness,e.roughness).then(function(n){var a=e.name+"$"+t+"_metallicRoughness.png",r=n.toDataURL();r=r.slice("data:image/png;base64,".length),s.file(a,r,{base64:!0}),e.metalnessMap=e.roughnessMap=a,console.log("Merged %s, %s to %s",e.metalnessMap,e.roughnessMap,a),i()})})}if(e.specularMap||e.glossinessMap){var i=c[e.specularMap],r=c[e.glossinessMap];return new Promise(function(n){Object(g.c)(i,r,e.specularColor,e.glossiness).then(function(a){var i=e.name+"$"+t+"_specularGlossiness.png",r=a.toDataURL();r=r.slice("data:image/png;base64,".length),s.file(i,r,{base64:!0}),e.specularMap=e.glossinessMap=i,console.log("Merged %s, %s to %s",e.specularMap,e.glossinessMap,i),n()})})}return null}).filter(function(e){return null!=e})).then(function(){FileAPI.readAsText(i,"utf-8",function(a){if("load"==a.type){var c=Object(g.d)(JSON.parse(a.result),o);if(c.extensionsUsed=c.extensionsUsed||[],c.extensionsUsed.indexOf("KHR_materials_pbrSpecularGlossiness")<0&&c.extensionsUsed.push("KHR_materials_pbrSpecularGlossiness"),["extensionsUsed","images","textures","samplers","animations"].forEach(function(e){c[e]&&!c[e].length&&delete c[e]}),c.textures||delete c.samplers,r=r.filter(function(e){return e.type.match(/image/)?c.images&&c.images.some(function(t){return t.uri===e.name}):!!e.name.endsWith(".bin")||void 0}),r.forEach(function(e){s.file(e.name,e)}),"glb"===e){var l=[],u=[];s.forEach(function(e,t){(e.endsWith(".bin")?l:u).push({reader:s.file(e).async("arraybuffer"),name:e})}),Promise.all([Promise.all(l.map(function(e){return e.reader})),Promise.all(u.map(function(e){return e.reader}))]).then(function(e){var n=Object(g.a)(c,e[0],e[1].reduce(function(e,t,n){return e[u[n].name]=t,e},{}));saveAs(new Blob([n],{type:"model/json-binary"}),"model.glb"),t&&t()}).catch(n)}else s.file(i.name,JSON.stringify(c,null,2)),s.generateAsync({type:"blob"}).then(function(e){saveAs(e,"model.zip"),t&&t()}).catch(n)}})})}).catch(function(e){swal(e.toString()),n&&n()})}n.d(t,"c",function(){return c}),n.d(t,"e",function(){return l}),n.d(t,"a",function(){return v}),n.d(t,"f",function(){return u}),n.d(t,"g",function(){return f}),n.d(t,"d",function(){return h}),n.d(t,"b",function(){return _});var x,g=(n(37),n(144)),y=(n(145),n(146)),b=n.n(y),T=BrowserFS.BFSRequire("buffer").Buffer,E="File system not prepared yet.",w={}},function(e,t,n){"use strict";function a(e,t){return new Promise(function(t,n){Promise.all(e.map(function(e){var t=e&&URL.createObjectURL(e);return new Promise(function(e,n){if(t){var a=new Image;a.src=t,a.onload=function(){e(a)}}else e(null)})})).then(function(e){var n=e.find(function(e){return null!=e});n||t(null);var a=document.createElement("canvas"),i=a.getContext("2d"),r=a.width=n.width,o=a.height=n.height,s=e.map(function(e){return e?(i.drawImage(e,0,0,r,o),i.getImageData(0,0,r,o).data):null});t({canvas:a,imageDataList:s})})})}function i(e,t,n,i){return new Promise(function(r,o){a([e,t]).then(function(e){for(var t=e.canvas,a=t.getContext("2d"),o=e.imageDataList[0],s=e.imageDataList[1],c=a.createImageData(t.width,t.height),l=0;l<(o||s).length;l+=4){var u=n;if(o){var p=o[l+2]/255;u=Math.min(Math.max(p+2*(u-.5),0),1)}var d=i;if(s){var f=s[l+1]/255;d=Math.min(Math.max(f+2*(d-.5),0),1)}c.data[l]=c.data[l+3]=0,c.data[l+1]=Math.round(255*d),c.data[l+2]=Math.round(255*u)}a.putImageData(c,0,0),r(t)})})}function r(e,t,n,i){return n=d.a.parseColor(n).slice(0,3),new Promise(function(r,o){a([e,t]).then(function(e){for(var t=e.canvas,a=t.getContext("2d"),o=e.imageDataList[0],s=e.imageDataList[1],c=a.createImageData(t.width,t.height),l=0;l<(o||s).length;l+=4){var u=n.slice();o&&(u[0]*=o[l]/255,u[1]*=o[l+1]/255,u[2]*=o[l+2]/255);var p=i;if(s){var d=s[l+3]/255;p=Math.min(Math.max(d+2*(p-.5),0),1)}for(var f=0;f<3;f++)c.data[l+f]=Math.round(255*u[f]);c.data[l+3]=Math.round(255*p)}a.putImageData(c,0,0),r(t)})})}function o(e,t){var n={},a=0;return e.images=[],e.textures=[],e.samplers=[{minFilter:h.a.LINEAR_MIPMAP_LINEAR,magFilter:h.a.LINEAR,wrapS:h.a.REPEAT,wrapT:h.a.REPEAT}],t.materials.forEach(function(t,i){m.forEach(function(i){t[i]&&!n.hasOwnProperty(i)&&(e.images.push({uri:t[i]}),e.textures.push({sampler:0,source:a}),n[t[i]]=a++)})}),n}function s(e,t){var n={baseColorFactor:d.a.parseColor(e.color),metallicFactor:e.metalness,roughnessFactor:e.roughness};return n.baseColorFactor[3]=e.alpha,e.diffuseMap&&(n.baseColorTexture={index:t[e.diffuseMap],texCoord:0}),e.metalnessMap&&(n.metallicRoughnessTexture={index:t[e.metalnessMap],texCoord:0},n.metallicFactor=1,n.roughnessFactor=1),n}function c(e,t){var n={diffuseFactor:d.a.parseColor(e.color),specularFactor:d.a.parseColor(e.specularColor).slice(0,3),glossinessFactor:e.glossiness};return n.diffuseFactor[3]=e.alpha,e.diffuseMap&&(n.diffuseTexture={index:t[e.diffuseMap],texCoord:0}),e.specularMap&&(n.specularGlossinessTexture={index:t[e.specularMap],texCoord:0},n.specularFactor=[1,1,1],n.glossinessFactor=1),n}function l(e,t){if(e.materials){var n=o(e,t),a={};return e.materials=[],e.nodes.forEach(function(t,n){if(null!=t.mesh){var i=e.meshes[t.mesh];1===i.primitives.length?a[t.name]=i.primitives[0]:i.primitives.forEach(function(n,i){a[f.a.generateMeshName(e.meshes,t.mesh,i)]=n})}}),t.materials.forEach(function(t,i){var r={name:t.name,emissiveFactor:d.a.parseColor(t.emission).slice(0,3).map(function(e){return e*t.emissionIntensity})};t.normalMap&&(r.normalTexture={texCoord:0,scale:1,index:n[t.normalMap]}),t.emissiveMap&&(r.emissiveTexture={texCoord:0,index:n[t.emissiveMap]}),"pbrMetallicRoughness"===t.type?r.pbrMetallicRoughness=s(t,n):r.extensions={KHR_materials_pbrSpecularGlossiness:c(t,n)},t.targetMeshes.forEach(function(e){a[e].material=i}),e.materials[i]=r}),e.extras=e.extras||{},e.extras.qtekModelViewerConfig=t,e}}function u(e,t,n){function a(e){return 4*Math.ceil(e/4)}var i=0,r=[],o=t.slice();e.buffers.forEach(function(e){r.push(i),i+=a(e.byteLength),delete e.uri}),e.bufferViews.forEach(function(e){null==e.byteOffset?e.byteOffset=0:e.byteOffset=e.byteOffset+r[e.buffer]}),(e.images||[]).forEach(function(t,s){var c=t.uri,l=n[c];if(delete t.uri,l){var u={buffer:0,byteOffset:i,byteLength:l.byteLength};r.push(i),i+=a(l.byteLength),t.bufferView=e.bufferViews.length,t.mimeType=p(c),e.bufferViews.push(u),o.push(l)}});var s=i;e.buffers=[{byteLength:s}];var c,l=new TextEncoder,u=l.encode(JSON.stringify(e)),d=a(u.length);d!==u.length&&(c=d-u.length);var f=20+d+8+s,h=new ArrayBuffer(f),m=new DataView(h),v=0;m.setUint32(v,1179937895,!0),v+=4,m.setUint32(v,2,!0),v+=4,m.setUint32(v,f,!0),v+=4,m.setUint32(v,d,!0),v+=4,m.setUint32(v,1313821514,!0),v+=4;for(var _=0;_0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},o.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},o.cross=function(e,t,n){var a=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=a,e},o.lerp=function(e,t,n,a){var i=t[0],r=t[1];return e[0]=i+a*(n[0]-i),e[1]=r+a*(n[1]-r),e},o.random=function(e,t){t=t||1;var n=2*a()*Math.PI;return e[0]=Math.cos(n)*t,e[1]=Math.sin(n)*t,e},o.transformMat2=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[2]*i,e[1]=n[1]*a+n[3]*i,e},o.transformMat2d=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[2]*i+n[4],e[1]=n[1]*a+n[3]*i+n[5],e},o.transformMat3=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[3]*i+n[6],e[1]=n[1]*a+n[4]*i+n[7],e},o.transformMat4=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[4]*i+n[12],e[1]=n[1]*a+n[5]*i+n[13],e},o.forEach=function(){var e=o.create();return function(t,n,a,i,r,o){var s,c;for(n||(n=2),a||(a=0),c=i?Math.min(i*n+a,t.length):t.length,s=a;s0&&(r=1/Math.sqrt(r),e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r),e},s.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},s.cross=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[0],s=n[1],c=n[2];return e[0]=i*c-r*s,e[1]=r*o-a*c,e[2]=a*s-i*o,e},s.lerp=function(e,t,n,a){var i=t[0],r=t[1],o=t[2];return e[0]=i+a*(n[0]-i),e[1]=r+a*(n[1]-r),e[2]=o+a*(n[2]-o),e},s.random=function(e,t){t=t||1;var n=2*a()*Math.PI,i=2*a()-1,r=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(n)*r,e[1]=Math.sin(n)*r,e[2]=i*t,e},s.transformMat4=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[3]*a+n[7]*i+n[11]*r+n[15];return o=o||1,e[0]=(n[0]*a+n[4]*i+n[8]*r+n[12])/o,e[1]=(n[1]*a+n[5]*i+n[9]*r+n[13])/o,e[2]=(n[2]*a+n[6]*i+n[10]*r+n[14])/o,e},s.transformMat3=function(e,t,n){var a=t[0],i=t[1],r=t[2];return e[0]=a*n[0]+i*n[3]+r*n[6],e[1]=a*n[1]+i*n[4]+r*n[7],e[2]=a*n[2]+i*n[5]+r*n[8],e},s.transformQuat=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[0],s=n[1],c=n[2],l=n[3],u=l*a+s*r-c*i,p=l*i+c*a-o*r,d=l*r+o*i-s*a,f=-o*a-s*i-c*r;return e[0]=u*l+f*-o+p*-c-d*-s,e[1]=p*l+f*-s+d*-o-u*-c,e[2]=d*l+f*-c+u*-s-p*-o,e},s.rotateX=function(e,t,n,a){var i=[],r=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],r[0]=i[0],r[1]=i[1]*Math.cos(a)-i[2]*Math.sin(a),r[2]=i[1]*Math.sin(a)+i[2]*Math.cos(a),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e},s.rotateY=function(e,t,n,a){var i=[],r=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],r[0]=i[2]*Math.sin(a)+i[0]*Math.cos(a),r[1]=i[1],r[2]=i[2]*Math.cos(a)-i[0]*Math.sin(a),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e},s.rotateZ=function(e,t,n,a){var i=[],r=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],r[0]=i[0]*Math.cos(a)-i[1]*Math.sin(a),r[1]=i[0]*Math.sin(a)+i[1]*Math.cos(a),r[2]=i[2],e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e},s.forEach=function(){var e=s.create();return function(t,n,a,i,r,o){var s,c;for(n||(n=3),a||(a=0),c=i?Math.min(i*n+a,t.length):t.length,s=a;s1?0:Math.acos(i)},s.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},void 0!==e&&(e.vec3=s);var c={};c.create=function(){var e=new n(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},c.clone=function(e){var t=new n(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},c.fromValues=function(e,t,a,i){var r=new n(4);return r[0]=e,r[1]=t,r[2]=a,r[3]=i,r},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,n,a,i){return e[0]=t,e[1]=n,e[2]=a,e[3]=i,e},c.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e},c.subtract=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e},c.sub=c.subtract,c.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e},c.mul=c.multiply,c.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e[3]=t[3]/n[3],e},c.div=c.divide,c.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e[3]=Math.min(t[3],n[3]),e},c.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e[3]=Math.max(t[3],n[3]),e},c.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},c.scaleAndAdd=function(e,t,n,a){return e[0]=t[0]+n[0]*a,e[1]=t[1]+n[1]*a,e[2]=t[2]+n[2]*a,e[3]=t[3]+n[3]*a,e},c.distance=function(e,t){var n=t[0]-e[0],a=t[1]-e[1],i=t[2]-e[2],r=t[3]-e[3];return Math.sqrt(n*n+a*a+i*i+r*r)},c.dist=c.distance,c.squaredDistance=function(e,t){var n=t[0]-e[0],a=t[1]-e[1],i=t[2]-e[2],r=t[3]-e[3];return n*n+a*a+i*i+r*r},c.sqrDist=c.squaredDistance,c.length=function(e){var t=e[0],n=e[1],a=e[2],i=e[3];return Math.sqrt(t*t+n*n+a*a+i*i)},c.len=c.length,c.squaredLength=function(e){var t=e[0],n=e[1],a=e[2],i=e[3];return t*t+n*n+a*a+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 n=t[0],a=t[1],i=t[2],r=t[3],o=n*n+a*a+i*i+r*r;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,n,a){var i=t[0],r=t[1],o=t[2],s=t[3];return e[0]=i+a*(n[0]-i),e[1]=r+a*(n[1]-r),e[2]=o+a*(n[2]-o),e[3]=s+a*(n[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,n){var a=t[0],i=t[1],r=t[2],o=t[3];return e[0]=n[0]*a+n[4]*i+n[8]*r+n[12]*o,e[1]=n[1]*a+n[5]*i+n[9]*r+n[13]*o,e[2]=n[2]*a+n[6]*i+n[10]*r+n[14]*o,e[3]=n[3]*a+n[7]*i+n[11]*r+n[15]*o,e},c.transformQuat=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[0],s=n[1],c=n[2],l=n[3],u=l*a+s*r-c*i,p=l*i+c*a-o*r,d=l*r+o*i-s*a,f=-o*a-s*i-c*r;return e[0]=u*l+f*-o+p*-c-d*-s,e[1]=p*l+f*-s+d*-o-u*-c,e[2]=d*l+f*-c+u*-s-p*-o,e},c.forEach=function(){var e=c.create();return function(t,n,a,i,r,o){var s,c;for(n||(n=4),a||(a=0),c=i?Math.min(i*n+a,t.length):t.length,s=a;s.999999?(a[0]=0,a[1]=0,a[2]=0,a[3]=1,a):(s.cross(e,i,r),a[0]=e[0],a[1]=e[1],a[2]=e[2],a[3]=1+o,f.normalize(a,a))}}(),f.setAxes=function(){var e=p.create();return function(t,n,a,i){return e[0]=a[0],e[3]=a[1],e[6]=a[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],f.normalize(t,f.fromMat3(t,e))}}(),f.clone=c.clone,f.fromValues=c.fromValues,f.copy=c.copy,f.set=c.set,f.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},f.setAxisAngle=function(e,t,n){n*=.5;var a=Math.sin(n);return e[0]=a*t[0],e[1]=a*t[1],e[2]=a*t[2],e[3]=Math.cos(n),e},f.add=c.add,f.multiply=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=t[3],s=n[0],c=n[1],l=n[2],u=n[3];return e[0]=a*u+o*s+i*l-r*c,e[1]=i*u+o*c+r*s-a*l,e[2]=r*u+o*l+a*c-i*s,e[3]=o*u-a*s-i*c-r*l,e},f.mul=f.multiply,f.scale=c.scale,f.rotateX=function(e,t,n){n*=.5;var a=t[0],i=t[1],r=t[2],o=t[3],s=Math.sin(n),c=Math.cos(n);return e[0]=a*c+o*s,e[1]=i*c+r*s,e[2]=r*c-i*s,e[3]=o*c-a*s,e},f.rotateY=function(e,t,n){n*=.5;var a=t[0],i=t[1],r=t[2],o=t[3],s=Math.sin(n),c=Math.cos(n);return e[0]=a*c-r*s,e[1]=i*c+o*s,e[2]=r*c+a*s,e[3]=o*c-i*s,e},f.rotateZ=function(e,t,n){n*=.5;var a=t[0],i=t[1],r=t[2],o=t[3],s=Math.sin(n),c=Math.cos(n);return e[0]=a*c+i*s,e[1]=i*c-a*s,e[2]=r*c+o*s,e[3]=o*c-r*s,e},f.calculateW=function(e,t){var n=t[0],a=t[1],i=t[2];return e[0]=n,e[1]=a,e[2]=i,e[3]=Math.sqrt(Math.abs(1-n*n-a*a-i*i)),e},f.dot=c.dot,f.lerp=c.lerp,f.slerp=function(e,t,n,a){var i,r,o,s,c,l=t[0],u=t[1],p=t[2],d=t[3],f=n[0],h=n[1],m=n[2],v=n[3];return r=l*f+u*h+p*m+d*v,r<0&&(r=-r,f=-f,h=-h,m=-m,v=-v),1-r>1e-6?(i=Math.acos(r),o=Math.sin(i),s=Math.sin((1-a)*i)/o,c=Math.sin(a*i)/o):(s=1-a,c=a),e[0]=s*l+c*f,e[1]=s*u+c*h,e[2]=s*p+c*m,e[3]=s*d+c*v,e},f.invert=function(e,t){var n=t[0],a=t[1],i=t[2],r=t[3],o=n*n+a*a+i*i+r*r,s=o?1/o:0;return e[0]=-n*s,e[1]=-a*s,e[2]=-i*s,e[3]=r*s,e},f.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},f.length=c.length,f.len=f.length,f.squaredLength=c.squaredLength,f.sqrLen=f.squaredLength,f.normalize=c.normalize,f.fromMat3=function(e,t){var n,a=t[0]+t[4]+t[8];if(a>0)n=Math.sqrt(a+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var r=(i+1)%3,o=(i+2)%3;n=Math.sqrt(t[3*i+i]-t[3*r+r]-t[3*o+o]+1),e[i]=.5*n,n=.5/n,e[3]=(t[3*r+o]-t[3*o+r])*n,e[r]=(t[3*r+i]+t[3*i+r])*n,e[o]=(t[3*o+i]+t[3*i+o])*n}return e},f.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},void 0!==e&&(e.quat=f)}(n.exports)}()},function(e,t,n){"use strict";var a=n(68),i=n(22),r=n(11),o=function(){this.__GUID__=r.a.genGUID()};o.__initializers__=[function(e){r.a.extend(this,e)}],r.a.extend(o,a.a),r.a.extend(o.prototype,i.a),t.a=o},function(e,t,n){"use strict";function a(e,t,n){return en?n:e}var i=n(0),r=n.n(i),o=r.a.vec3,s=function(e,t,n){e=e||0,t=t||0,n=n||0,this._array=o.fromValues(e,t,n),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,n){return this._array[0]=e,this._array[1]=t,this._array[2]=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._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,n){return o.lerp(this._array,e._array,t._array,n),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 n=-1/t[2];t[0]=e[0]*t[0]*n,t[1]=e[5]*t[1]*n,t[2]=(e[10]*t[2]+e[14])*n}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 c=Object.defineProperty;if(c){var l=s.prototype;c(l,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),c(l,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),c(l,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}})}s.add=function(e,t,n){return o.add(e._array,t._array,n._array),e._dirty=!0,e},s.set=function(e,t,n,a){o.set(e._array,t,n,a),e._dirty=!0},s.copy=function(e,t){return o.copy(e._array,t._array),e._dirty=!0,e},s.cross=function(e,t,n){return o.cross(e._array,t._array,n._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,n){return o.divide(e._array,t._array,n._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,n,a){return o.lerp(e._array,t._array,n._array,a),e._dirty=!0,e},s.min=function(e,t,n){return o.min(e._array,t._array,n._array),e._dirty=!0,e},s.max=function(e,t,n){return o.max(e._array,t._array,n._array),e._dirty=!0,e},s.mul=function(e,t,n){return o.multiply(e._array,t._array,n._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,n){return o.scale(e._array,t._array,n),e._dirty=!0,e},s.scaleAndAdd=function(e,t,n,a){return o.scaleAndAdd(e._array,t._array,n._array,a),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,n){return o.subtract(e._array,t._array,n._array),e._dirty=!0,e},s.subtract=s.sub,s.transformMat3=function(e,t,n){return o.transformMat3(e._array,t._array,n._array),e._dirty=!0,e},s.transformMat4=function(e,t,n){return o.transformMat4(e._array,t._array,n._array),e._dirty=!0,e},s.transformQuat=function(e,t,n){return o.transformQuat(e._array,t._array,n._array),e._dirty=!0,e};var u=Math.atan2,p=Math.asin,d=Math.abs;s.eulerFromQuat=function(e,t,n){e._dirty=!0,t=t._array;var i=e._array,r=t[0],o=t[1],s=t[2],c=t[3],l=r*r,d=o*o,f=s*s,h=c*c,n=(n||"XYZ").toUpperCase();switch(n){case"XYZ":i[0]=u(2*(r*c-o*s),h-l-d+f),i[1]=p(a(2*(r*s+o*c),-1,1)),i[2]=u(2*(s*c-r*o),h+l-d-f);break;case"YXZ":i[0]=p(a(2*(r*c-o*s),-1,1)),i[1]=u(2*(r*s+o*c),h-l-d+f),i[2]=u(2*(r*o+s*c),h-l+d-f);break;case"ZXY":i[0]=p(a(2*(r*c+o*s),-1,1)),i[1]=u(2*(o*c-s*r),h-l-d+f),i[2]=u(2*(s*c-r*o),h-l+d-f);break;case"ZYX":i[0]=u(2*(r*c+s*o),h-l-d+f),i[1]=p(a(2*(o*c-r*s),-1,1)),i[2]=u(2*(r*o+s*c),h+l-d-f);break;case"YZX":i[0]=u(2*(r*c-s*o),h-l+d-f),i[1]=u(2*(o*c-r*s),h+l-d-f),i[2]=p(a(2*(r*o+s*c),-1,1));break;case"XZY":i[0]=u(2*(r*c+o*s),h-l+d-f),i[1]=u(2*(r*s+o*c),h+l-d-f),i[2]=p(a(2*(s*c-r*o),-1,1));break;default:console.warn("Unkown order: "+n)}return e},s.eulerFromMat3=function(e,t,n){var i=t._array,r=i[0],o=i[3],s=i[6],c=i[1],l=i[4],f=i[7],h=i[2],m=i[5],v=i[8],_=e._array,n=(n||"XYZ").toUpperCase();switch(n){case"XYZ":_[1]=p(a(s,-1,1)),d(s)<.99999?(_[0]=u(-f,v),_[2]=u(-o,r)):(_[0]=u(m,l),_[2]=0);break;case"YXZ":_[0]=p(-a(f,-1,1)),d(f)<.99999?(_[1]=u(s,v),_[2]=u(c,l)):(_[1]=u(-h,r),_[2]=0);break;case"ZXY":_[0]=p(a(m,-1,1)),d(m)<.99999?(_[1]=u(-h,v),_[2]=u(-o,l)):(_[1]=0,_[2]=u(c,r));break;case"ZYX":_[1]=p(-a(h,-1,1)),d(h)<.99999?(_[0]=u(m,v),_[2]=u(c,r)):(_[0]=0,_[2]=u(-o,l));break;case"YZX":_[2]=p(a(c,-1,1)),d(c)<.99999?(_[0]=u(-f,l),_[1]=u(-h,r)):(_[0]=0,_[1]=u(s,v));break;case"XZY":_[2]=p(-a(o,-1,1)),d(o)<.99999?(_[0]=u(m,l),_[1]=u(s,r)):(_[0]=u(-f,v),_[1]=0);break;default:console.warn("Unkown order: "+n)}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,n){"use strict";var a=n(1),i=n(6),r=n(23),o=a.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,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1},function(){this._cache=new r.a},{getWebGLTexture:function(e){var t=e.gl,n=this._cache;return n.use(e.__GUID__),n.miss("webgl_texture")&&n.put("webgl_texture",t.createTexture()),this.dynamic?this.update(e):n.isDirty()&&(this.update(e),n.fresh()),n.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 n=e.getGLExtension("EXT_sRGB");this.format!==o.SRGB||n||(this.format=o.RGB),this.format!==o.SRGB_ALPHA||n||(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.__GUID__);var n=t.get("webgl_texture");n&&e.gl.deleteTexture(n),t.deleteContext(e.__GUID__)},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,n){"use strict";function a(){return{locations:{},attriblocations:{}}}function i(e,t,n){if(!e.getShaderParameter(t,e.COMPILE_STATUS))return[e.getShaderInfoLog(t),r(n)].join("\n")}function r(e){for(var t=e.split("\n"),n=0,a=t.length;n0&&a.push("#define "+i.toUpperCase()+"_COUNT "+r)}for(var o in n){n[o].enabled&&a.push("#define "+o.toUpperCase()+"_ENABLED")}for(var o in e){var s=e[o];null===s?a.push("#define "+o):a.push("#define "+o+" "+s.toString())}return a.join("\n")},_unrollLoop:function(e,t){function n(e,n,i,r){var o="";isNaN(n)&&(n=n in t?t[n]:a[n]),isNaN(i)&&(i=i in t?t[i]:a[i]);for(var s=parseInt(n);s=0)n.attribSemantics[c]={symbol:r,type:u},p=!1;else if(E.indexOf(c)>=0){var d=!1,f=c;c.match(/TRANSPOSE$/)&&(d=!0,f=c.slice(0,-9)),n.matrixSemantics[c]={symbol:r,type:u,isTranspose:d,semanticNoTranspose:f},p=!1}else if(T.indexOf(c)>=0)n.uniformSemantics[c]={symbol:r,type:u},p=!1;else if("unconfigurable"===c)p=!1;else{if(!(l=n._parseDefaultValue(i,c)))throw new Error('Unkown semantic "'+c+'"');c=""}p&&(t[r]={type:u,value:o?y.array:l||y[i],semantic:c||null})}return["uniform",i,r,o].join(" ")+";\n"}}var t={},n=this,a="vertex";this._uniformList=[],this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(m,e),a="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(m,e),n.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=t},_parseDefaultValue:function(e,t){var n=/\[\s*(.*)\s*\]/;{if("vec2"!==e&&"vec3"!==e&&"vec4"!==e)return"bool"===e?function(){return"true"===t.toLowerCase()}:"float"===e?function(){return parseFloat(t)}:"int"===e?function(){return parseInt(t)}:void 0;var a=n.exec(t)[1];if(a){var i=a.split(/\s*,\s*/);return function(){return new l.a.Float32Array(i)}}}},createUniforms:function(){var e={};for(var t in this.uniformTemplates){var n=this.uniformTemplates[t];e[t]={type:n.type,value:n.value()}}return e},attached:function(){this._attacheMaterialNumber++},detached:function(){this._attacheMaterialNumber--},isAttachedToAny:function(){return 0!==this._attacheMaterialNumber},_parseAttributes:function(){function e(e,a,i,r,o){if(a&&i){var s=1;switch(a){case"vec4":s=4;break;case"vec3":s=3;break;case"vec2":s=2;break;case"float":s=1}if(t[i]={type:"float",size:s,semantic:o||null},o){if(b.indexOf(o)<0)throw new Error('Unkown semantic "'+o+'"');n.attribSemantics[o]={symbol:i,type:a}}}return["attribute",a,i].join(" ")+";\n"}var t={},n=this;this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(v,e),this.attributeTemplates=t},_parseDefines:function(){function e(e,a,i){var r="vertex"===n?t.vertexDefines:t.fragmentDefines;return r[a]||(r[a]="false"!=i&&("true"==i||(i?isNaN(parseFloat(i))?i:parseFloat(i):null))),""}var t=this,n="vertex";this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(_,e),n="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(_,e)},_buildProgram:function(e,t,n){var a=this._cache;a.get("program")&&e.deleteProgram(a.get("program"));var r=e.createProgram(),o=e.createShader(e.VERTEX_SHADER);e.shaderSource(o,t),e.compileShader(o);var s=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(s,n),e.compileShader(s);var c=i(e,o,t);if(c)return c;if(c=i(e,s,n))return c;if(e.attachShader(r,o),e.attachShader(r,s),this.attribSemantics.POSITION)e.bindAttribLocation(r,0,this.attribSemantics.POSITION.symbol);else{var l=Object.keys(this.attributeTemplates);e.bindAttribLocation(r,0,l[0])}if(e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS))return"Could not link program\nVALIDATE_STATUS: "+e.getProgramParameter(r,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]";for(var u=0;u1&&t.texParameterf(t.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===a){e.getGLExtension("OES_texture_half_float")||(a=i.a.FLOAT)}if(this.mipmaps.length)for(var o=this.width,s=this.height,c=0;c=a.a.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,n,o,i,r,0,t.pixels):e.texImage2D(e.TEXTURE_2D,n,o,i,r,0,o,s,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(){var e,t;return this.image?(e=this.image.width,t=this.image.height):(e=this.width,t=this.height),o(e)&&o(t)},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 n=new Image;t&&(n.crossOrigin=t);var a=this;return n.onload=function(){a.dirty(),a.trigger("success",a),n.onload=null},n.onerror=function(){a.trigger("error",a),n.onerror=null},n.src=e,this.image=n,this}});Object.defineProperty(s.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(s.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=s},function(e,t,n){"use strict";t.a={DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:33995,TEXTURE12:33996,TEXTURE13:33997,TEXTURE14:33998,TEXTURE15:33999,TEXTURE16:34e3,TEXTURE17:34001,TEXTURE18:34002,TEXTURE19:34003,TEXTURE20:34004,TEXTURE21:34005,TEXTURE22:34006,TEXTURE23:34007,TEXTURE24:34008,TEXTURE25:34009,TEXTURE26:34010,TEXTURE27:34011,TEXTURE28:34012,TEXTURE29:34013,TEXTURE30:34014,TEXTURE31:34015,ACTIVE_TEXTURE:34016,REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,INT_VEC2:35667,INT_VEC3:35668,INT_VEC4:35669,BOOL:35670,BOOL_VEC2:35671,BOOL_VEC3:35672,BOOL_VEC4:35673,FLOAT_MAT2:35674,FLOAT_MAT3:35675,FLOAT_MAT4:35676,SAMPLER_2D:35678,SAMPLER_CUBE:35680,VERTEX_ATTRIB_ARRAY_ENABLED:34338,VERTEX_ATTRIB_ARRAY_SIZE:34339,VERTEX_ATTRIB_ARRAY_STRIDE:34340,VERTEX_ATTRIB_ARRAY_TYPE:34341,VERTEX_ATTRIB_ARRAY_NORMALIZED:34922,VERTEX_ATTRIB_ARRAY_POINTER:34373,VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:34975,COMPILE_STATUS:35713,LOW_FLOAT:36336,MEDIUM_FLOAT:36337,HIGH_FLOAT:36338,LOW_INT:36339,MEDIUM_INT:36340,HIGH_INT:36341,FRAMEBUFFER:36160,RENDERBUFFER:36161,RGBA4:32854,RGB5_A1:32855,RGB565:36194,DEPTH_COMPONENT16:33189,STENCIL_INDEX:6401,STENCIL_INDEX8:36168,DEPTH_STENCIL:34041,RENDERBUFFER_WIDTH:36162,RENDERBUFFER_HEIGHT:36163,RENDERBUFFER_INTERNAL_FORMAT:36164,RENDERBUFFER_RED_SIZE:36176,RENDERBUFFER_GREEN_SIZE:36177,RENDERBUFFER_BLUE_SIZE:36178,RENDERBUFFER_ALPHA_SIZE:36179,RENDERBUFFER_DEPTH_SIZE:36180,RENDERBUFFER_STENCIL_SIZE:36181,FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:36048,FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:36049,FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:36050,FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:36051,COLOR_ATTACHMENT0:36064,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306,NONE:0,FRAMEBUFFER_COMPLETE:36053,FRAMEBUFFER_INCOMPLETE_ATTACHMENT:36054,FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:36055,FRAMEBUFFER_INCOMPLETE_DIMENSIONS:36057,FRAMEBUFFER_UNSUPPORTED:36061,FRAMEBUFFER_BINDING:36006,RENDERBUFFER_BINDING:36007,MAX_RENDERBUFFER_SIZE:34024,INVALID_FRAMEBUFFER_OPERATION:1286,UNPACK_FLIP_Y_WEBGL:37440,UNPACK_PREMULTIPLY_ALPHA_WEBGL:37441,CONTEXT_LOST_WEBGL:37442,UNPACK_COLORSPACE_CONVERSION_WEBGL:37443,BROWSER_DEFAULT_WEBGL:37444}},function(e,t,n){"use strict";var a=n(2),i=n(0),r=n.n(i),o=r.a.vec3,s=o.copy,c=o.set,l=function(e,t){this.min=e||new a.a(1/0,1/0,1/0),this.max=t||new a.a(-1/0,-1/0,-1/0)};l.prototype={constructor:l,updateFromVertices:function(e){if(e.length>0){var t=this.min,n=this.max,a=t._array,i=n._array;s(a,e[0]),s(i,e[0]);for(var r=1;ri[0]&&(i[0]=o[0]),o[1]>i[1]&&(i[1]=o[1]),o[2]>i[2]&&(i[2]=o[2])}t._dirty=!0,n._dirty=!0}},union:function(e){var t=this.min,n=this.max;return o.min(t._array,t._array,e.min._array),o.max(n._array,n._array,e.max._array),t._dirty=!0,n._dirty=!0,this},intersection:function(e){var t=this.min,n=this.max;return o.max(t._array,t._array,e.min._array),o.min(n._array,n._array,e.max._array),t._dirty=!0,n._dirty=!0,this},intersectBoundingBox:function(e){var t=this.min._array,n=this.max._array,a=e.min._array,i=e.max._array;return!(t[0]>i[0]||t[1]>i[1]||t[2]>i[2]||n[0]=i[0]&&n[1]>=i[1]&&n[2]>=i[2]},containPoint:function(e){var t=this.min._array,n=this.max._array,a=e._array;return t[0]<=a[0]&&t[1]<=a[1]&&t[2]<=a[2]&&n[0]>=a[0]&&n[1]>=a[1]&&n[2]>=a[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(){var e=o.create(),t=o.create(),n=o.create(),a=o.create(),i=o.create(),r=o.create();return function(o){var s=this.min._array,c=this.max._array,l=o._array;return e[0]=l[0]*s[0],e[1]=l[1]*s[0],e[2]=l[2]*s[0],t[0]=l[0]*c[0],t[1]=l[1]*c[0],t[2]=l[2]*c[0],n[0]=l[4]*s[1],n[1]=l[5]*s[1],n[2]=l[6]*s[1],a[0]=l[4]*c[1],a[1]=l[5]*c[1],a[2]=l[6]*c[1],i[0]=l[8]*s[2],i[1]=l[9]*s[2],i[2]=l[10]*s[2],r[0]=l[8]*c[2],r[1]=l[9]*c[2],r[2]=l[10]*c[2],s[0]=Math.min(e[0],t[0])+Math.min(n[0],a[0])+Math.min(i[0],r[0])+l[12],s[1]=Math.min(e[1],t[1])+Math.min(n[1],a[1])+Math.min(i[1],r[1])+l[13],s[2]=Math.min(e[2],t[2])+Math.min(n[2],a[2])+Math.min(i[2],r[2])+l[14],c[0]=Math.max(e[0],t[0])+Math.max(n[0],a[0])+Math.max(i[0],r[0])+l[12],c[1]=Math.max(e[1],t[1])+Math.max(n[1],a[1])+Math.max(i[1],r[1])+l[13],c[2]=Math.max(e[2],t[2])+Math.max(n[2],a[2])+Math.max(i[2],r[2])+l[14],this.min._dirty=!0,this.max._dirty=!0,this}}(),applyProjection:function(e){var t=this.min._array,n=this.max._array,a=e._array,i=t[0],r=t[1],o=t[2],s=n[0],c=n[1],l=t[2],u=n[0],p=n[1],d=n[2];if(1===a[15])t[0]=a[0]*i+a[12],t[1]=a[5]*r+a[13],n[2]=a[10]*o+a[14],n[0]=a[0]*u+a[12],n[1]=a[5]*p+a[13],t[2]=a[10]*d+a[14];else{var f=-1/o;t[0]=a[0]*i*f,t[1]=a[5]*r*f,n[2]=(a[10]*o+a[14])*f,f=-1/l,n[0]=a[0]*s*f,n[1]=a[5]*c*f,f=-1/d,t[2]=(a[10]*d+a[14])*f}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){for(var e=[],t=0;t<8;t++)e[t]=o.fromValues(0,0,0);this.vertices=e}var n=this.min._array,a=this.max._array;return c(e[0],n[0],n[1],n[2]),c(e[1],n[0],a[1],n[2]),c(e[2],a[0],n[1],n[2]),c(e[3],a[0],a[1],n[2]),c(e[4],n[0],n[1],a[2]),c(e[5],n[0],a[1],a[2]),c(e[6],a[0],n[1],a[2]),c(e[7],a[0],a[1],a[2]),this},copy:function(e){var t=this.min,n=this.max;return s(t._array,e.min._array),s(n._array,e.max._array),t._dirty=!0,n._dirty=!0,this},clone:function(){var e=new l;return e.copy(this),e}},t.a=l},function(e,t,n){"use strict";var a=n(0),i=n.n(a),r=n(2),o=i.a.mat4,s=i.a.vec3,c=i.a.mat3,l=i.a.quat,u=function(){this._axisX=new r.a,this._axisY=new r.a,this._axisZ=new r.a,this._array=o.create(),this._dirty=!0};u.prototype={constructor:u,setArray:function(e){for(var t=0;t=0},set:function(e,t){if("object"==typeof e)for(var n in e){var a=e[n];this.set(n,a)}else{var i=this.uniforms[e];i&&(void 0===t&&(console.warn('Uniform value "'+e+'" is undefined'),t=null),i.value=t)}},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){this.shader&&this.shader.detached();var n=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var a=this.uniforms;if(this._enabledUniforms=Object.keys(a),this._enabledUniforms.sort(),t)for(var i in n)a[i]&&(a[i].value=n[i].value);e.attached()},detachShader:function(){this.shader.detached(),this.shader=null,this.uniforms={}},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},dispose:function(e,t){if(t)for(var n in this.uniforms){var a=this.uniforms[n].value;if(a)if(a instanceof i.a)a.dispose(e);else if(Array.isArray(a))for(var r=0;r=n.COLOR_ATTACHMENT0&&r<=n.COLOR_ATTACHMENT0+8&&i.push(r);a.drawBuffersEXT(i)}}this.trigger("beforerender",this,e);var o=this.clearDepth?n.DEPTH_BUFFER_BIT:0;if(n.depthMask(!0),this.clearColor){o|=n.COLOR_BUFFER_BIT,n.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&n.clearColor(s[0],s[1],s[2],s[3])}n.clear(o),this.blendWithPrevious?(n.enable(n.BLEND),this.material.transparent=!0):(n.disable(n.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.renderQueue([d],f)},dispose:function(e){this.material.dispose(e)}});t.a=h},function(e,t,n){"use strict";var a=!0;try{var i=document.createElement("canvas");if(!(i.getContext("webgl")||i.getContext("experimental-webgl")))throw new Error}catch(e){a=!1}var r={};r.supportWebGL=function(){return a},r.Int8Array="undefined"==typeof Int8Array?Array:Int8Array,r.Uint8Array="undefined"==typeof Uint8Array?Array:Uint8Array,r.Uint16Array="undefined"==typeof Uint16Array?Array:Uint16Array,r.Uint32Array="undefined"==typeof Uint32Array?Array:Uint32Array,r.Int16Array="undefined"==typeof Int16Array?Array:Int16Array,r.Float32Array="undefined"==typeof Float32Array?Array:Float32Array,r.Float64Array="undefined"==typeof Float64Array?Array:Float64Array,t.a=r},function(e,t,n){"use strict";var a=n(15),i=a.a.extend(function(){return{color:[1,1,1],intensity:1,castShadow:!0,shadowResolution:512,group:0}},{type:"",clone:function(){var e=a.a.prototype.clone.call(this);return e.color=Array.prototype.slice.call(this.color),e.intensity=this.intensity,e.castShadow=this.castShadow,e.shadowResolution=this.shadowResolution,e}});t.a=i},function(e,t,n){"use strict";var a=n(1),i=n(2),r=n(71),o=n(8),s=n(0),c=n.n(s),l=n(7),u=c.a.mat4,p=0,d=a.a.extend({name:"",position:null,rotation:null,scale:null,worldTransform:null,localTransform:null,autoUpdateLocalTransform:!0,_parent:null,_scene:null,_needsUpdateWorldTransform:!0,_inIterating:!1,__depth:0},function(){this.name||(this.name=(this.type||"NODE")+"_"+p++),this.position||(this.position=new i.a),this.rotation||(this.rotation=new r.a),this.scale||(this.scale=new i.a(1,1,1)),this.worldTransform=new o.a,this.localTransform=new o.a,this._children=[]},{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(e){var t=this._scene;if(t){var n=t._nodeRepository;delete n[this.name],n[e]=this}this.name=e},add:function(e){this._inIterating&&console.warn("Add operation can cause unpredictable error when in iterating");var t=e._parent;if(t!==this){t&&t.remove(e),e._parent=this,this._children.push(e);var n=this._scene;n&&n!==e.scene&&e.traverse(this._addSelfToScene,this),e._needsUpdateWorldTransform=!0}},remove:function(e){this._inIterating&&console.warn("Remove operation can cause unpredictable error when in iterating");var t=this._children,n=t.indexOf(e);n<0||(t.splice(n,1),e._parent=null,this._scene&&e.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var e=this._children,t=0;t256?64:o>64?32:o>16?16:8;var s=this.getSkinMatricesTexture();s.width=r,s.height=r,s.pixels&&s.pixels.length===r*r*4||(s.pixels=new Float32Array(r*r*4)),s.pixels.set(i),s.dirty(),t.setUniform(n,"1f","skinMatricesTextureSize",r)}else t.setUniformOfSemantic(n,"SKIN_MATRIX",i)}return a.a.prototype.render.call(this,e,t)},getSkinMatricesTexture:function(){return this._skinMatricesTexture=this._skinMatricesTexture||new r.a({type:i.a.FLOAT,minFilter:i.a.NEAREST,magFilter:i.a.NEAREST,useMipmap:!1,flipY:!1}),this._skinMatricesTexture}});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,n){"use strict";function a(e){return"CANVAS"===e.nodeName||"VIDEO"===e.nodeName||e.complete}var i=n(3),r=n(6),o=n(11),s=n(44),c=s.a.isPowerOfTwo,l=["px","nx","py","ny","pz","nz"],u=i.a.extend(function(){return{image:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},pixels:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},mipmaps:[]}},{update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),this.updateCommon(e);var n=this.format,a=this.type;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var i=e.getGLExtension("EXT_texture_filter_anisotropic");if(i&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===a){e.getGLExtension("OES_texture_half_float")||(a=r.a.FLOAT)}if(this.mipmaps.length)for(var o=this.width,s=this.height,c=0;c0&&this._updateRenderQueue(a)}},_updateLightUniforms:function(){var e=this.lights;e.sort(a);var t=this._lightUniforms;for(var n in t)for(var i in t[n])t[n][i].value.length=0;for(var r=0;rr[0]&&(r[0]=s),c>r[1]&&(r[1]=c),l>r[2]&&(r[2]=l)}n._dirty=!0,a._dirty=!0}},dirty:function(){for(var e=this.getEnabledAttributes(),t=0;t=0){t||(t=_());var n=this.indices;return t[0]=n[3*e],t[1]=n[3*e+1],t[2]=n[3*e+2],t}},setTriangleIndices:function(e,t){var n=this.indices;n[3*e]=t[0],n[3*e+1]=t[1],n[3*e+2]=t[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(e){var t,n=this.vertexCount>65535?p.a.Uint32Array:p.a.Uint16Array;if(e[0]&&e[0].length){var a=0;t=new n(3*e.length);for(var i=0;i=0&&(t.splice(n,1),delete this.attributes[e],!0)},getAttribute:function(e){return this.attribute[e]},getEnabledAttributes:function(){var e=this._enabledAttributes,t=this._attributeList;if(e)return e;for(var n=[],a=this.vertexCount,i=0;i65535&&(this.indices=new p.a.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,n=this.getEnabledAttributes(),a={},i=0;i0){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,n){"use strict";function a(e,t){this.action=e,this.context=t}var i={trigger:function(e){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(e)){var t=this.__handlers__[e],n=t.length,a=-1,i=arguments;switch(i.length){case 1:for(;++a=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}t.a={get:a}},function(e,t,n){"use strict";var a=n(46),i=a.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=a.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,n){"use strict";var a=n(46),i=a.a.extend({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix._array;this.left=(-1-e[12])/e[0],this.right=(1-e[12])/e[0],this.top=(1-e[13])/e[5],this.bottom=(-1-e[13])/e[5],this.near=-(-1-e[14])/e[10],this.far=-(1-e[14])/e[10]},clone:function(){var e=a.a.prototype.clone.call(this);return e.left=this.left,e.right=this.right,e.near=this.near,e.far=this.far,e.top=this.top,e.bottom=this.bottom,e}});t.a=i},function(e,t,n){"use strict";function a(e,t){for(var n=0,a=1/t,i=e;i>0;)n+=a*(i%t),i=Math.floor(i/t),a/=t;return n}t.a=a},function(e,t,n){"use strict";function a(e){return!e||"none"===e}function i(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}function r(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function o(e){if((e.wrapS===s.a.REPEAT||e.wrapT===s.a.REPEAT)&&e.image){var t=r(e.width),n=r(e.height);if(t!==e.width||n!==e.height){var a=document.createElement("canvas");a.width=t,a.height=n;a.getContext("2d").drawImage(e.image,0,0,t,n),a.srcImage=e.image,e.image=a,e.dirty()}}}var s=n(3),c=n(9),l=n(63),u=n(33),p=n(117),d=n(122),f=n(123),h=n(125),m=n(5);c.a.prototype.setTextureImage=function(e,t,n,i){if(this.shader){var r,o=this;return o.shader.disableTexture(e),a(t)||(r=v.loadTexture(t,n,i,function(t){o.shader.enableTexture(e),n.refresh()}),o.set(e,r)),r}};var v={},_=u.a.createBlank("rgba(255,255,255,0)").image;v.firstNotNull=function(){for(var e=0,t=arguments.length;e3?t[3]=e[3]:t[3]=1,t):(t=h.a(e||"#000",t)||[0,0,0,0],t[0]/=255,t[1]/=255,t[2]/=255,t)},v.stringifyColor=function(e,t){return e=e.slice(),e[0]=Math.round(255*e[0]),e[1]=Math.round(255*e[1]),e[2]=Math.round(255*e[2]),"hex"===t?"#"+((1<<24)+(e[0]<<16)+(e[1]<<8)+e[2]).toString(16).slice(1):h.b(e,t)},v.directionFromAlphaBeta=function(e,t){var n=e/180*Math.PI+Math.PI/2,a=-t/180*Math.PI+Math.PI/2,i=[],r=Math.sin(n);return i[0]=r*Math.cos(a),i[1]=-Math.cos(n),i[2]=r*Math.sin(a),i},v.convertTextureToPowerOfTwo=o,t.a=v},function(e,t,n){"use strict";var a=n(1),i=n(69),r=n(6),o=(n(13),n(7)),s=n(8),c=(n(18),n(9)),l=n(24),u=n(4),p=n(38),d=n(39),f=n(0),h=n.n(f);u.a.import(p.a),u.a.import(d.a);var m=h.a.mat4,v=h.a.vec3,_=m.create,x={},g=a.a.extend(function(){return{canvas:null,_width:100,_height:100,devicePixelRatio: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 i.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}},{resize:function(e,t){var n=this.canvas,a=this.devicePixelRatio;null!=e?(n.style.width=e+"px",n.style.height=t+"px",n.width=e*a,n.height=t*a,this._width=e,this._height=t):(this._width=n.width/a,this._height=n.height/a),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,n,a,i){if("object"==typeof e){var r=e;e=r.x,t=r.y,n=r.width,a=r.height,i=r.devicePixelRatio}i=i||this.devicePixelRatio,this.gl.viewport(e*i,t*i,n*i,a*i),this.viewport={x:e,y:t,width:n,height:a,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},beforeRenderObject:function(){},afterRenderObject:function(){},render:function(e,t,n,a){var i=this.gl;this._sceneRendering=e;var r=this.clearColor;if(this.clearBit){i.colorMask(!0,!0,!0,!0),i.depthMask(!0);var o=this.viewport,s=!1,c=o.devicePixelRatio;(o.width!==this._width||o.height!==this._height||c&&c!==this.devicePixelRatio||o.x||o.y)&&(s=!0,i.enable(i.SCISSOR_TEST),i.scissor(o.x*c,o.y*c,o.width*c,o.height*c)),i.clearColor(r[0],r[1],r[2],r[3]),i.clear(this.clearBit),s&&i.disable(i.SCISSOR_TEST)}n||e.update(!1),t.getScene()||t.update(!0);for(var l=e.opaqueQueue,u=e.transparentQueue,p=e.material,d=0;d0)for(var h=_(),x=v.create(),d=0;d0&&e.min._array[2]<0&&(e.max._array[2]=-1e-20),e.applyProjection(t);var c=e.min._array,l=e.max._array;if(l[0]<-1||c[0]>1||l[1]<-1||c[1]>1||l[2]<-1||c[2]>1)return!0}return!1}}(),disposeScene:function(e){this.disposeNode(e,!0,!0),e.dispose()},disposeNode:function(e,t,n){var a={};e.getParent()&&e.getParent().remove(e),e.traverse(function(e){e.geometry&&t&&e.geometry.dispose(this),e.material&&(a[e.material.__GUID__]=e.material),e.dispose&&e.dispose(this)},this);for(var i in a){a[i].dispose(this,n)}},disposeShader:function(e){e.dispose(this)},disposeGeometry:function(e){e.dispose(this)},disposeTexture:function(e){e.dispose(this)},disposeFrameBuffer:function(e){e.dispose(this)},dispose:function(){},screenToNDC:function(e,t,n){n||(n=new l.a),t=this._height-t;var a=this.viewport,i=n._array;return i[0]=(e-a.x)/a.width,i[0]=2*i[0]-1,i[1]=(t-a.y)/a.height,i[1]=2*i[1]-1,n}});g.opaqueSortFunc=g.prototype.opaqueSortFunc=function(e,t){return e.renderOrder===t.renderOrder?e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__:e.renderOrder-t.renderOrder},g.transparentSortFunc=g.prototype.transparentSortFunc=function(e,t){return e.renderOrder===t.renderOrder?e.__depth===t.__depth?e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__:e.__depth-t.__depth:e.renderOrder-t.renderOrder};var y={IDENTITY:_(),WORLD:_(),VIEW:_(),PROJECTION:_(),WORLDVIEW:_(),VIEWPROJECTION:_(),WORLDVIEWPROJECTION:_(),WORLDINVERSE:_(),VIEWINVERSE:_(),PROJECTIONINVERSE:_(),WORLDVIEWINVERSE:_(),VIEWPROJECTIONINVERSE:_(),WORLDVIEWPROJECTIONINVERSE:_(),WORLDTRANSPOSE:_(),VIEWTRANSPOSE:_(),PROJECTIONTRANSPOSE:_(),WORLDVIEWTRANSPOSE:_(),VIEWPROJECTIONTRANSPOSE:_(),WORLDVIEWPROJECTIONTRANSPOSE:_(),WORLDINVERSETRANSPOSE:_(),VIEWINVERSETRANSPOSE:_(),PROJECTIONINVERSETRANSPOSE:_(),WORLDVIEWINVERSETRANSPOSE:_(),VIEWPROJECTIONINVERSETRANSPOSE:_(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:_()};g.COLOR_BUFFER_BIT=r.a.COLOR_BUFFER_BIT,g.DEPTH_BUFFER_BIT=r.a.DEPTH_BUFFER_BIT,g.STENCIL_BUFFER_BIT=r.a.STENCIL_BUFFER_BIT,t.a=g},function(e,t,n){"use strict";function a(){}var i=n(75),r=function(e){e=e||{},this.name=e.name||"",this.target=e.target,this.life=e.life||1e3,this.delay=e.delay||0,this.gap=e.gap||0,this.playbackRate=e.playbackRate||1,this._initialized=!1,this._elapsedTime=0,this._loop=null!=e.loop&&e.loop,this.setLoop(this._loop),null!=e.easing&&this.setEasing(e.easing),this.onframe=e.onframe||a,this.onfinish=e.onfinish||a,this.onrestart=e.onrestart||a,this._paused=!1};r.prototype={gap:0,life:0,delay:0,setLoop:function(e){this._loop=e,e&&(this._loopRemained="number"==typeof e?e:1e8)},setEasing:function(e){"string"==typeof e&&(e=i.a[e]),this.easing=e},step:function(e,t,n){if(this._initialized||(this._startTime=e+this.delay,this._initialized=!0),null!=this._currentTime&&(t=e-this._currentTime),this._currentTime=e,this._paused)return"paused";if(!(e0?(this._restartInLoop(e),this._loopRemained--,"restart"):(this._needsRemove=!0,"finish"):null}}},setTime:function(e){return this.step(e+this._startTime)},restart:function(e){var t=0;e&&(this._elapse(e),t=this._elapsedTime%this.life),e=e||Date.now(),this._startTime=e-t+this.delay,this._elapsedTime=0,this._needsRemove=!1,this._paused=!1},getElapsedTime:function(){return this._elapsedTime},_restartInLoop:function(e){this._startTime=e+this.gap,this._elapsedTime=0},_elapse:function(e,t){this._elapsedTime+=t*this.playbackRate},fire:function(e,t){var n="on"+e;this[n]&&this[n](this.target,t)},clone:function(){var e=new this.constructor;return e.name=this.name,e._loop=this._loop,e._loopRemained=this._loopRemained,e.life=this.life,e.gap=this.gap,e.delay=this.delay,e},pause:function(){this._paused=!0},resume:function(){this._paused=!1}},r.prototype.constructor=r,t.a=r},function(e,t,n){"use strict";var a=n(20),i=n(7),r=a.a.extend({dynamic:!1,widthSegments:1,heightSegments:1},function(){this.build()},{build:function(){for(var e=this.heightSegments,t=this.widthSegments,n=this.attributes,a=[],r=[],o=[],s=[],c=0;c<=e;c++)for(var l=c/e,u=0;u<=t;u++){var p=u/t;if(a.push([2*p-1,2*l-1,0]),r&&r.push([p,l]),o&&o.push([0,0,1]),u20)return console.warn("Given image is not a height map"),e}var d,f,h,m;c%(4*a)==0?(d=o.data[c],h=o.data[c+4]):c%(4*a)==4*(a-1)?(d=o.data[c-4],h=o.data[c]):(d=o.data[c-4],h=o.data[c+4]),c<4*a?(f=o.data[c],m=o.data[c+4*a]):c>a*(i-1)*4?(f=o.data[c-4*a],m=o.data[c]):(f=o.data[c-4*a],m=o.data[c+4*a]),s.data[c]=d-h+127,s.data[c+1]=f-m+127,s.data[c+2]=255,s.data[c+3]=255}return r.putImageData(s,0,0),n},isHeightImage:function(e,t,n){if(!e||!e.width||!e.height)return!1;var a=document.createElement("canvas"),i=a.getContext("2d"),r=t||32;n=n||20,a.width=a.height=r,i.drawImage(e,0,0,r,r);for(var o=i.getImageData(0,0,r,r),s=0;sn)return!1}return!0},_fetchTexture:function(e,t,n){r.a.get({url:e,responseType:"arraybuffer",onload:t,onerror:n})},createChessboard:function(e,t,n,i){e=e||512,t=t||64,n=n||"black",i=i||"white";var r=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=n;for(var c=0;c0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=r.a.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},render:function(e,t){var n=e.gl,t=t||this.material.shader,r=this.geometry,u=this.mode,p=r.vertexCount,d=r.isUseIndices(),f=e.getGLExtension("OES_element_index_uint"),h=f&&p>65535,m=h?n.UNSIGNED_INT:n.UNSIGNED_SHORT,v=e.getGLExtension("OES_vertex_array_object"),_=!r.dynamic,x=this._renderInfo;x.vertexCount=p,x.triangleCount=0,x.drawCallCount=0;var g=!1;if(i=e.__GUID__+"-"+r.__GUID__+"-"+t.__GUID__,i!==s?g=!0:(p>65535&&!f&&d||v&&_||r._cache.isDirty())&&(g=!0),s=i,g){var y=this._drawCache[i];if(!y){var b=r.getBufferChunks(e);if(!b)return;y=[];for(var T=0;T>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},a.nearestPowerOfTwo=function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))},t.a=a},function(e,t,n){"use strict";var a=n(1),i=a.a.extend({name:"",index:-1,node:null,rootNode:null});t.a=i},function(e,t,n){"use strict";var a=n(15),i=n(8),r=n(47),o=n(48),s=n(0),c=n.n(s),l=c.a.vec3,u=c.a.vec4,p=a.a.extend(function(){return{projectionMatrix:new i.a,invProjectionMatrix:new i.a,viewMatrix:new i.a,frustum:new r.a}},function(){this.update(!0)},{update:function(e){a.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=u.create();return function(t,n){var a=void 0!==n?n:new o.a,i=t._array[0],r=t._array[1];return u.set(e,i,r,-1,1),u.transformMat4(e,e,this.invProjectionMatrix._array),u.transformMat4(e,e,this.worldTransform._array),l.scale(a.origin._array,e,1/e[3]),u.set(e,i,r,1,1),u.transformMat4(e,e,this.invProjectionMatrix._array),u.transformMat4(e,e,this.worldTransform._array),l.scale(e,e,1/e[3]),l.sub(a.direction._array,e,a.origin._array),l.normalize(a.direction._array,a.direction._array),a.direction._dirty=!0,a.origin._dirty=!0,a}}()});t.a=p},function(e,t,n){"use strict";var a=(n(2),n(7)),i=n(73),r=n(0),o=n.n(r),s=o.a.vec3,c=s.set,l=s.copy,u=s.transformMat4,p=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 a.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,n=e._array,a=n[0],i=n[1],r=n[2],o=n[3],s=n[4],l=n[5],u=n[6],p=n[7],d=n[8],f=n[9],h=n[10],m=n[11],v=n[12],_=n[13],x=n[14],g=n[15];c(t[0].normal._array,o-a,p-s,m-d),t[0].distance=-(g-v),t[0].normalize(),c(t[1].normal._array,o+a,p+s,m+d),t[1].distance=-(g+v),t[1].normalize(),c(t[2].normal._array,o+i,p+l,m+f),t[2].distance=-(g+_),t[2].normalize(),c(t[3].normal._array,o-i,p-l,m-f),t[3].distance=-(g-_),t[3].normalize(),c(t[4].normal._array,o-r,p-u,m-h),t[4].distance=-(g-x),t[4].normalize(),c(t[5].normal._array,o+r,p+u,m+h),t[5].distance=-(g+x),t[5].normalize();var y=this.boundingBox;if(0===g){var b=l/a,T=-x/(h-1),E=-x/(h+1),w=-E/l,S=-T/l;y.min.set(-w*b,-w,E),y.max.set(w*b,w,T);var A=this.vertices;c(A[0],-w*b,-w,E),c(A[1],-w*b,w,E),c(A[2],w*b,-w,E),c(A[3],w*b,w,E),c(A[4],-S*b,-S,T),c(A[5],-S*b,S,T),c(A[6],S*b,-S,T),c(A[7],S*b,S,T)}else{var N=(-1-v)/a,C=(1-v)/a,M=(1-_)/l,R=(-1-_)/l,L=(-1-x)/h,D=(1-x)/h;y.min.set(Math.min(N,C),Math.min(R,M),Math.min(D,L)),y.max.set(Math.max(C,N),Math.max(M,R),Math.max(L,D));var P=y.min._array,I=y.max._array,A=this.vertices;c(A[0],P[0],P[1],P[2]),c(A[1],P[0],I[1],P[2]),c(A[2],I[0],P[1],P[2]),c(A[3],I[0],I[1],P[2]),c(A[4],P[0],P[1],I[2]),c(A[5],P[0],I[1],I[2]),c(A[6],I[0],P[1],I[2]),c(A[7],I[0],I[1],I[2])}},getTransformedBoundingBox:function(){var e=s.create();return function(t,n){var a=this.vertices,i=n._array,r=t.min,o=t.max,s=r._array,c=o._array,f=a[0];u(e,f,i),l(s,e),l(c,e);for(var h=1;h<8;h++)f=a[h],u(e,f,i),s[0]=p(e[0],s[0]),s[1]=p(e[1],s[1]),s[2]=p(e[2],s[2]),c[0]=d(e[0],c[0]),c[1]=d(e[1],c[1]),c[2]=d(e[2],c[2]);return r._dirty=!0,o._dirty=!0,t}}()},t.a=f},function(e,t,n){"use strict";var a=n(2),i=n(0),r=n.n(i),o=r.a.vec3,s=function(e,t){this.origin=e||new a.a,this.direction=t||new a.a};s.prototype={constructor:s,intersectPlane:function(e,t){var n=e.normal._array,i=e.distance,r=this.origin._array,s=this.direction._array,c=o.dot(n,s);if(0===c)return null;t||(t=new a.a);var l=(o.dot(n,r)-i)/c;return o.scaleAndAdd(t._array,r,s,-l),t._dirty=!0,t},mirrorAgainstPlane:function(e){var t=o.dot(e.normal._array,this.direction._array);o.scaleAndAdd(this.direction._array,this.direction._array,e.normal._array,2*-t),this.direction._dirty=!0},distanceToPoint:function(){var e=o.create();return function(t){o.sub(e,t,this.origin._array);var n=o.dot(e,this.direction._array);if(n<0)return o.distance(this.origin._array,t);var a=o.lenSquared(e);return Math.sqrt(a-n*n)}}(),intersectSphere:function(){var e=o.create();return function(t,n,i){var r=this.origin._array,s=this.direction._array;t=t._array,o.sub(e,t,r);var c=o.dot(e,s),l=o.squaredLength(e),u=l-c*c,p=n*n;if(!(u>p)){var d=Math.sqrt(p-u),f=c-d,h=c+d;return i||(i=new a.a),f<0?h<0?null:(o.scaleAndAdd(i._array,r,s,h),i):(o.scaleAndAdd(i._array,r,s,f),i)}}}(),intersectBoundingBox:function(e,t){var n,i,r,s,c,l,u=this.direction._array,p=this.origin._array,d=e.min._array,f=e.max._array,h=1/u[0],m=1/u[1],v=1/u[2];if(h>=0?(n=(d[0]-p[0])*h,i=(f[0]-p[0])*h):(i=(d[0]-p[0])*h,n=(f[0]-p[0])*h),m>=0?(r=(d[1]-p[1])*m,s=(f[1]-p[1])*m):(s=(d[1]-p[1])*m,r=(f[1]-p[1])*m),n>s||r>i)return null;if((r>n||n!==n)&&(n=r),(s=0?(c=(d[2]-p[2])*v,l=(f[2]-p[2])*v):(l=(d[2]-p[2])*v,c=(f[2]-p[2])*v),n>l||c>i)return null;if((c>n||n!==n)&&(n=c),(l=0?n:i;return t||(t=new a.a),o.scaleAndAdd(t._array,p,u,_),t},intersectTriangle:function(){var e=o.create(),t=o.create(),n=o.create(),i=o.create();return function(r,s,c,l,u,p){var d=this.direction._array,f=this.origin._array;r=r._array,s=s._array,c=c._array,o.sub(e,s,r),o.sub(t,c,r),o.cross(i,t,d);var h=o.dot(e,i);if(l){if(h>-1e-5)return null}else if(h>-1e-5&&h<1e-5)return null;o.sub(n,f,r);var m=o.dot(i,n)/h;if(m<0||m>1)return null;o.cross(i,e,n);var v=o.dot(d,i)/h;if(v<0||v>1||m+v>1)return null;o.cross(i,e,t);var _=-o.dot(n,i)/h;return _<0?null:(u||(u=new a.a),p&&a.a.set(p,1-m-v,m,v),o.scaleAndAdd(u._array,f,d,_),u)}}(),applyTransform:function(e){a.a.add(this.direction,this.direction,this.origin),a.a.transformMat4(this.origin,this.origin,e),a.a.transformMat4(this.direction,this.direction,e),a.a.sub(this.direction,this.direction,this.origin),a.a.normalize(this.direction,this.direction)},copy:function(e){a.a.copy(this.origin,e.origin),a.a.copy(this.direction,e.direction)},clone:function(){var e=new s;return e.copy(this),e}},t.a=s},function(e,t,n){"use strict";t.a="@export qtek.basic.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position : POSITION;\nattribute vec3 barycentric;\n@import qtek.chunk.skinning_header\nvarying vec2 v_Texcoord;\nvarying vec3 v_Barycentric;\nvoid main()\n{\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import qtek.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_Barycentric = barycentric;\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n}\n@end\n@export qtek.basic.fragment\nvarying vec2 v_Texcoord;\nuniform sampler2D diffuseMap;\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform vec3 emission : [0.0, 0.0, 0.0];\nuniform float alpha : 1.0;\n#ifdef ALPHA_TEST\nuniform float alphaCutoff: 0.9;\n#endif\nuniform float lineWidth : 0.0;\nuniform vec4 lineColor : [0.0, 0.0, 0.0, 0.6];\nvarying vec3 v_Barycentric;\n@import qtek.util.edge_factor\n@import qtek.util.rgbm\n@import qtek.util.srgb\nvoid main()\n{\n#ifdef RENDER_TEXCOORD\n gl_FragColor = vec4(v_Texcoord, 1.0, 1.0);\n return;\n#endif\n gl_FragColor = vec4(color, alpha);\n#ifdef DIFFUSEMAP_ENABLED\n vec4 tex = decodeHDR(texture2D(diffuseMap, v_Texcoord));\n#ifdef SRGB_DECODE\n tex = sRGBToLinear(tex);\n#endif\n#if defined(DIFFUSEMAP_ALPHA_ALPHA)\n gl_FragColor.a = tex.a;\n#endif\n gl_FragColor.rgb *= tex.rgb;\n#endif\n gl_FragColor.rgb += emission;\n if( lineWidth > 0.)\n {\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor(lineWidth)) * lineColor.a);\n }\n#ifdef GAMMA_ENCODE\n gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(1 / 2.2));\n#endif\n#ifdef ALPHA_TEST\n if (gl_FragColor.a < alphaCutoff) {\n discard;\n }\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.skybox.vertex\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 qtek.skybox.fragment\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import qtek.util.rgbm\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 viewDirection = normalize(v_WorldPosition - eyePos);\n vec3 tex = decodeHDR(textureCubeLodEXT(environmentMap, viewDirection, lod)).rgb;\n#ifdef SRGB_DECODE\n tex.rgb = pow(tex.rgb, vec3(2.2));\n#endif\n gl_FragColor = encodeHDR(vec4(tex, 1.0));\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.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 qtek.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 qtek.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 qtek.util.rgbm\n@import qtek.util.clamp_sample\nvoid main (void)\n{\n @import qtek.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"},function(e,t,n){"use strict";t.a="@export qtek.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import qtek.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(e,t,n){"use strict";t.a="@export qtek.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 qtek.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(e,t,n){"use strict";t.a="@export qtek.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import qtek.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"},function(e,t,n){"use strict";t.a="\n@export qtek.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 qtek.util.rgbm\n@import qtek.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(e,t,n){"use strict";t.a="@export qtek.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 qtek.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 qtek.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) {\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(e,t,n){"use strict";t.a="@export qtek.compositor.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 qtek.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(e,t,n){"use strict";t.a="@export qtek.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 qtek.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(e,t,n){"use strict";function a(e,t){var n=new s;return r.a.get({url:e,responseType:t,onload:function(e){n.resolve(e)},onerror:function(e){n.reject(e)}}),n}var i=n(22),r=n(25),o=n(11),s=function(){this._fullfilled=!1,this._rejected=!1};s.prototype.resolve=function(e){this._fullfilled=!0,this._rejected=!1,this.trigger("success",e)},s.prototype.reject=function(e){this._rejected=!0,this._fullfilled=!1,this.trigger("error",e)},s.prototype.isFullfilled=function(){return this._fullfilled},s.prototype.isRejected=function(){return this._rejected},s.prototype.isSettled=function(){return this._fullfilled||this._rejected},o.a.extend(s.prototype,i.a),s.makeRequestTask=function(e,t){if("string"==typeof e)return a(e,t);if(e.url){var n=e;return a(n.url,n.responseType)}if(Array.isArray(e)){var i=e,r=[];return i.forEach(function(e){var t,n;"string"==typeof e?t=e:Object(e)===e&&(t=e.url,n=e.responseType),r.push(a(t,n))}),r}},s.makeTask=function(){return new s},o.a.extend(s.prototype,i.a),t.a=s},function(e,t,n){"use strict";var a=n(14),i=n(2),r=a.a.extend({shadowBias:.001,shadowSlopeScale:2,shadowCascade:1,cascadeSplitLogFactor:.2},{type:"DIRECTIONAL_LIGHT",uniformTemplates:{directionalLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new i.a,e.__dir.copy(e.worldTransform.z).normalize().negate()._array}},directionalLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=a.a.prototype.clone.call(this);return e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}});t.a=r},function(e,t,n){"use strict";function a(e){c.a.defaultsWithPropList(e,u,p),i(e);for(var t="",n=0;n=this._maxSize&&o>0){var c=n.head;n.remove(c),delete a[c.key],i=c.value,this._lastRemovedEntry=c}s?s.value=t:s=new r(t),s.key=e,n.insertEntry(s),a[e]=s}return i},s.get=function(e){var t=this._map[e],n=this._list;if(null!=t)return t!==n.tail&&(n.remove(t),n.insertEntry(t)),t.value},s.clear=function(){this._list.clear(),this._map={}},t.a=o},function(e,t,n){"use strict";function a(){document.getElementById("timeline").style.display="block"}function i(){document.getElementById("timeline").style.display="none",c()}function r(e){if(u=e,l=Math.floor(e.getAnimationDuration()),l>0?a():i(),!(l<=0)){var t=document.getElementById("timeline-pause-resume");t.removeEventListener("click",d),t.addEventListener("click",d=function(){f?c():s(n)}),m=0,h=0,o();var n=Math.random();p=n,l>0?s(n):c();var r=null;if(!$("#timeline-progress input").data("ionRangeSlider")){$("#timeline-progress input").ionRangeSlider({from_shadow:!0,force_edges:!0,onChange:function(e){h=e.from,u.setPose(h),null==r&&(r=f),c()},onFinish:function(){r&&s(n),r=null}}),$("#timeline-range input").ionRangeSlider({from_shadow:!0,force_edges:!0,type:"double",drag_interval:!0,grid:!0,grid_num:10,onChange:function(e){l=e.to-e.from,m=e.from,h=Math.min(Math.max(e.from,h),e.to),u.setPose(h),v.update({from_min:e.from,from_max:e.to})}});var v=$("#timeline-progress input").data("ionRangeSlider"),_=$("#timeline-range input").data("ionRangeSlider");v.update({min:0,max:l,from:h,from_min:0,from_max:l}),_.update({min:0,max:l,from:0,to:l})}}}function o(){var e=$("#timeline-progress input").data("ionRangeSlider");e&&e.update({from:h})}function s(e){function t(){if(f&&e===p){u.setPose(h);var a=Math.min(Date.now()-n,20);n=Date.now(),o(),h+=a,h>m+l&&(h=m),requestAnimationFrame(t)}}if(!f){f=!0;var n=Date.now(),a=document.getElementById("timeline-pause-resume");a.classList.remove("icon-resume"),a.classList.add("icon-pause"),requestAnimationFrame(t)}}function c(){if(f){f=!1;var e=document.getElementById("timeline-pause-resume");e.classList.remove("icon-pause"),e.classList.add("icon-resume")}}n.d(t,"b",function(){return r}),n.d(t,"a",function(){return i});var l,u,p,d,f=!1,h=0,m=0},function(e,t,n){"use strict";function a(){["mainLight","secondaryLight","tertiaryLight"].forEach(function(e){z[e].alpha=90*z[e].$padAngle[1],z[e].beta=180*z[e].$padAngle[0]}),S.setMainLight(z.mainLight),S.setSecondaryLight(z.secondaryLight),S.setTertiaryLight(z.tertiaryLight),S.setAmbientLight(z.ambientLight)}function i(){S.setPostEffect(z.postEffect)}function r(){z.ambientCubemapLight.texture=O.a.ENV_TEXTURE_ROOT+z.ambientCubemapLight.$texture+".hdr",z.ambientCubemapLight.diffuseIntensity=z.ambientCubemapLight.specularIntensity=z.ambientCubemapLight.$intensity,S.setAmbientCubemapLight(z.ambientCubemapLight)}function o(){S.setGround(z.ground)}function s(){a(),i(),r(),o()}function c(){var e=Math.max(j.$textureTiling,.01);j.uvRepeat=[e,e],j.transparent=j.alpha<1,S.setMaterial(j.name,j)}function l(e){j.name=e.name;var t=S.getMaterial(e.name);t.$textureTiling=t.uvRepeat[0],k.a.extend(j,t),null==t.specularColor?(N.enable(),C.disable()):(C.enable(),N.disable()),q.update()}function u(e){return e&&"none"!==e}function p(e,t,n){var a=!1;u(n)&&([["diffuseMap","color","#fff"],["metalnessMap","metalness",.5],["roughnessMap","roughness",.5],["glossinessMap","glossiness",.5],["specularMap","specularColor","#fff"],["emissiveMap","emission","#fff"]].forEach(function(t){e===t[0]&&(console.warn("Force %s to be %s after set %s",t[1],t[2],t[0]),j[t[1]]=t[2],a=!0)},this),_(),O.a.AUTO_SAVE&&I.g(t).then(g).catch(g),R[n]=t.name,a&&q.update()),c()}function d(){document.getElementById("tip").style.display="block"}function f(){document.getElementById("tip").style.display="none"}function h(){S=new L.a.Viewer(document.getElementById("viewport"),z),S.enablePicking(),S.setCameraControl(z.viewControl),S.start(),S.on("select",function(e){S.refresh(),l(e.target.material),M=e.target}),S.on("doffocus",function(e){z.postEffect.depthOfField.enable&&(z.postEffect.depthOfField.focalDistance=e.distance,q.update())}),S.on("unselect",function(){S.refresh(),N.disable(),C.disable(),M=null}),S.on("afterrender",function(e,t,n){M&&Object(H.a)(S,[M],n)}),S.on("updatecamera",function(e){z.viewControl={center:e.center,alpha:e.alpha,beta:e.beta,distance:e.distance}})}function m(e){document.body.appendChild(G),G.querySelector("#loading-text").innerHTML=e||"LOADING"}function v(){G.parentNode.removeChild(G)}function _(){W.style.display="block",W.querySelector("#background-progress-text").innerHTML="Saving...DONT close the page."}function x(){W.style.display="block",W.querySelector("#background-progress-text").innerHTML="Preparing for download...DONT close the page."}function g(){W.style.display="none"}function y(){v(),document.getElementById("toolbar").style.display="block",document.getElementById("reset").addEventListener("click",T),document.getElementById("download").addEventListener("click",E),h(),FileAPI.event.dnd(document.getElementById("main"),function(e){},function(e){m("Loading model"),U.a(),I.a(e).then(function(e){var t=e.glTF,n=e.filesMap,a=e.buffers,i=e.allFiles;R={};for(var r in n)R[n[r]]=r;var o=!(!t.extras||!t.extras.qtekModelViewerConfig);o&&(F.merge(z,t.extras.qtekModelViewerConfig,!0),S.setCameraControl(z.viewControl),s(),q.update()),S.loadModel(t,{files:n,buffers:a,textureFlipY:z.textureFlipY,doubleSided:!0,upAxis:z.zUpToYUp?"z":"y",includeTexture:!o}).on("ready",function(){f(),v(),o&&(t.extras.qtekModelViewerConfig.materials||[]).forEach(function(e){for(var t in e)n[e[t]]&&(e[t]=n[e[t]]);S.setMaterial(e.name,e)}),setTimeout(function(){_(),O.a.AUTO_SAVE&&I.e(i).then(g).catch(g)},200)}).on("loadmodel",w).on("error",function(){v(),swal("Model load error")}),N.disable(),C.disable()}).catch(function(e){v(),S.getModelRoot()||d(),Object(U.b)(S),console.log(e),swal(e.toString())})}),b(),V=!0}function b(){function e(e){return R&&R[e]}function t(t){t.addStringOutput(j,"name",{label:"Name"}).addColor(j,"color",{label:"Base Color",onChange:c}).addSlider(j,"alpha","$alphaRange",{label:"Alpha",onChange:c}).addSlider(j,"alphaCutoff","$alphaCutoffRange",{label:"Alpha Cutoff",onChange:c}).addNumberInput(j,"$textureTiling",{label:"Tiling",onChange:c,step:.5}).addCustomComponent(B.a,j,"diffuseMap",{label:"Base Map",onChange:p.bind(null,"diffuseMap"),getFileName:e}).addCustomComponent(B.a,j,"normalMap",{label:"Normal/Bump Map",onChange:p.bind(null,"normalMap"),getFileName:e})}function n(t){t.addCustomComponent(B.a,j,"parallaxOcclusionMap",{label:"Parallax Occlusion Map",onChange:p.bind(null,"parallaxOcclusionMap"),getFileName:e}).addSlider(j,"parallaxOcclusionScale","$parallaxOcclusionScaleRange",{label:"Scale",onChange:c}).addColor(j,"emission",{label:"Emission",onChange:c}).addNumberInput(j,"emissionIntensity",{label:"Emission Intensity",onChange:c}).addCustomComponent(B.a,j,"emissiveMap",{label:"Emissive Map",onChange:p.bind(null,"emissiveMap"),getFileName:e})}A=q.addPanel({label:"Settings",width:250}),A.addGroup({label:"Global"}).addSubGroup({label:"Load Option"}).addCheckbox(z,"textureFlipY",{label:"Flip Texture",onChange:function(){S.setTextureFlipY(z.textureFlipY)}}).addCheckbox(z,"zUpToYUp",{label:"Z Up",onChange:function(){S.setModelUpAxis(z.zUpToYUp?"Z":"Y")}}).addSubGroup({label:"Ground"}).addCheckbox(z.ground,"show",{label:"Show",onChange:o}),A.addGroup({label:"Environment",enable:!1}).addSelect(z.ambientCubemapLight,"$textureOptions",{label:"HDR Texture",onChange:r,target:"$texture"}).addNumberInput(z.ambientCubemapLight,"$intensity",{label:"Intensity",onChange:r,step:.1}),A.addGroup({label:"Light",enable:!1}).addSubGroup({label:"Main",enable:!1}).addCheckbox(z.mainLight,"shadow",{label:"Cast Shadow",onChange:a}).addNumberInput(z.mainLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(z.mainLight,"color",{label:"Color",onChange:a}).addPad(z.mainLight,"$padAngle",{label:"Direction",onChange:a}).addSubGroup({label:"Secondary",enable:!1}).addNumberInput(z.secondaryLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(z.secondaryLight,"color",{label:"Color",onChange:a}).addPad(z.secondaryLight,"$padAngle",{label:"Direction",onChange:a}).addSubGroup({label:"Tertiary",enable:!1}).addNumberInput(z.tertiaryLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(z.tertiaryLight,"color",{label:"Color",onChange:a}).addPad(z.tertiaryLight,"$padAngle",{label:"Direction",onChange:a}).addSubGroup({label:"Ambient",enable:!1}).addNumberInput(z.ambientLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(z.ambientLight,"color",{label:"Color",onChange:a}),A.addGroup({label:"Post Effect",enable:!1}).addCheckbox(z.postEffect,"enable",{label:"Enable",onChange:i}).addSubGroup({label:"Bloom",enable:!1}).addCheckbox(z.postEffect.bloom,"enable",{label:"Enable",onChange:i}).addNumberInput(z.postEffect.bloom,"intensity",{label:"Intensity",step:.1,onChange:i}).addSubGroup({label:"Screen Space Ambient Occulusion",enable:!1}).addCheckbox(z.postEffect.screenSpaceAmbientOcclusion,"enable",{label:"Enable",onChange:i}).addNumberInput(z.postEffect.screenSpaceAmbientOcclusion,"radius",{label:"Radius",step:.1,onChange:i}).addNumberInput(z.postEffect.screenSpaceAmbientOcclusion,"intensity",{label:"Intensity",step:.1,onChange:i}).addSelect(z.postEffect.screenSpaceAmbientOcclusion,"$qualityOptions",{label:"Quality",onChange:i,target:"quality"}).addSubGroup({label:"Screen Space Reflection",enable:!1}).addCheckbox(z.postEffect.screenSpaceReflection,"enable",{label:"Enable",onChange:i}).addNumberInput(z.postEffect.screenSpaceReflection,"maxRoughness",{label:"Max Roughness",step:.01,onChange:i}).addSelect(z.postEffect.screenSpaceReflection,"$qualityOptions",{label:"Quality",onChange:i,target:"quality"}).addSubGroup({label:"Depth of Field",enable:!1}).addCheckbox(z.postEffect.depthOfField,"enable",{label:"Enable",onChange:i}).addNumberInput(z.postEffect.depthOfField,"fstop",{label:"f-stop",step:.1,onChange:i}).addNumberInput(z.postEffect.depthOfField,"focalDistance",{label:"Focal Distance",step:.1,onChange:i}).addNumberInput(z.postEffect.depthOfField,"focalRange",{label:"Focal Range",step:.1,onChange:i}).addNumberInput(z.postEffect.depthOfField,"blurRadius",{label:"Blur Radius",step:.1,onChange:i}).addSelect(z.postEffect.depthOfField,"$qualityOptions",{label:"Quality",onChange:i,target:"quality"}).addSubGroup({label:"Color Correction",enable:!1}).addNumberInput(z.postEffect.colorCorrection,"exposure",{label:"Exposure",step:.1,onChange:i}).addNumberInput(z.postEffect.colorCorrection,"brightness",{label:"Brightness",step:.1,onChange:i}).addNumberInput(z.postEffect.colorCorrection,"contrast",{label:"Contrast",step:.1,onChange:i}).addNumberInput(z.postEffect.colorCorrection,"saturation",{label:"Saturation",step:.1,onChange:i}),N=q.addPanel({label:"Material - Metalllic Roughness",width:240,fixed:!1,align:"left",position:[10,10]}),t(N),N.addCustomComponent(B.a,j,"metalnessMap",{label:"Metalness Map",onChange:p.bind(null,"metalnessMap"),getFileName:e}).addSlider(j,"metalness","$metalnessRange",{label:"Metalness",onChange:c}).addCustomComponent(B.a,j,"roughnessMap",{label:"Roughness Map",onChange:p.bind(null,"roughnessMap"),getFileName:e}).addSlider(j,"roughness","$roughnessRange",{label:"Roughness",onChange:c}),n(N),N.disable(),C=q.addPanel({label:"Material - Specular Glossiness",width:240,fixed:!1,align:"left",position:[10,10]}),t(C),C.addCustomComponent(B.a,j,"specularMap",{label:"Specular Map",onChange:p.bind(null,"specularMap"),getFileName:e}).addColor(j,"specularColor",{label:"Specular Factor",onChange:c}).addCustomComponent(B.a,j,"glossinessMap",{label:"Glossiness Map",onChange:p.bind(null,"glossinessMap"),getFileName:e}).addSlider(j,"glossiness","$glossinessRange",{label:"Glossiness",onChange:c}),n(C),C.disable()}function T(){swal({title:"Reset?",text:"Reset the viewer",type:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"Yes!"}).then(function(){F.merge(z,Object(D.a)(),!0),F.merge(j,Object(P.a)(),!0),q.update(),N.disable(),C.disable(),M=null,S.dispose(),h(),I.d(),d(),U.b(S),g()}).catch(function(){})}function E(){swal({title:"Select download format.",input:"radio",inputOptions:{glb:"GLB",zip:"ZIP"}}).then(function(e){x(),I.b(e,g,g)})}function w(){M=null,S.stopAnimation(),U.b(S)}Object.defineProperty(t,"__esModule",{value:!0});var S,A,N,C,M,R,L=n(66),D=n(140),P=n(141),I=n(142),O=n(37),k=n(11),F=n(150),B=(n.n(F),n(151)),U=n(64),H=n(152),z=Object(D.a)(),j=Object(P.a)(),q=new ControlKit({loadAndSave:!0,useExternalStyle:!0}),G=document.getElementById("loading"),W=document.getElementById("background-progress"),V=!1;I.c(function(e,t,n){if(n&&F.merge(z,n,!0),!V)if(y(),e){R={};for(var a in t)R[t[a]]=a;S.loadModel(e,{files:t,textureFlipY:z.textureFlipY,upAxis:z.zUpToYUp?"z":"y",doubleSided:!0,includeTexture:!1}).on("ready",function(){n&&n.materials&&n.materials.forEach(function(e){for(var n in e)t[e[n]]&&(e[n]=t[e[n]]);S.setMaterial(e.name,e)})}).on("loadmodel",w).on("error",function(){d(),swal("Model load error")})}else d()}),setTimeout(function(){V||(console.warn("Init time out"),y())},5e3),setInterval(function(){if(S&&!document.hidden){var e={};z.materials=S.getMaterialsNames().map(function(t){var n=S.getMaterial(t);for(var a in n)R[n[a]]&&(n[a]=R[n[a]]);return n.targetMeshes=[],e[t]=n,n}),S.getModelRoot()&&S.getModelRoot().traverse(function(t){t.material&&e[t.material.name]&&e[t.material.name].targetMeshes.push(t.originalMeshName||t.name)}),_(),O.a.AUTO_SAVE&&I.f(z).then(function(){g(),console.log("Saved")}).catch(g)}},5e3),window.addEventListener("resize",function(){S.resize()}),window.addEventListener("dragover",function(e){e.preventDefault()}),window.addEventListener("drop",function(e){e.preventDefault()})},function(e,t,n){"use strict";var a=n(67);t.a={Viewer:a.a,version:"0.1.0"}},function(e,t,n){"use strict";function a(e,t){t=S.a(t),S.b(t,w.a),this.init(e,t)}var i=n(30),r=n(40),o=n(2),s=n(89),c=n(91),l=n(59),u=n(92),p=n(11),d=n(15),f=n(16),h=n(9),m=n(32),v=n(4),_=n(93),x=n(22),g=n(18),y=n(33),b=n(97),T=n(29),E=n(130),w=n(132),S=n(133),A=n(134),N=n(135),C=n(137),M=n(139);v.a.import(M.a);var R=["diffuseMap","normalMap","emissiveMap","metalnessMap","roughnessMap","specularMap","glossinessMap"];a.prototype.init=function(e,t){t=t||{},this.root=e,this._animation=new s.a;var n=new i.a({devicePixelRatio:t.devicePixelRatio||window.devicePixelRatio});e.appendChild(n.canvas),n.canvas.style.cssText="position:absolute;left:0;top:0",this._renderer=n,this._renderMain=new b.a(n,t.shadow,"perspective"),this._renderMain.afterRenderScene=function(e,t,n){this.trigger("renderscene",e,t,n)}.bind(this),this._renderMain.afterRenderAll=function(e,t,n){this.trigger("afterrender",e,t,n)}.bind(this),this._renderMain.preZ=t.preZ||!1;var a=this._cameraControl=new N.a({renderer:n,animation:this._animation,domElement:e});a.target=this._renderMain.camera,a.init(),this._hotspotManager=new C.a({dom:e,renderer:n,camera:this._renderMain.camera}),this._skeletons=[],this._clips=[],this._takes=[],this._materialsMap={},this._sceneHelper=new E.a(this._renderMain.scene),this._sceneHelper.initLight(this._renderMain.scene),this.resize(),t.postEffect&&this.setPostEffect(t.postEffect),t.mainLight&&this.setMainLight(t.mainLight),t.secondaryLight&&this.setSecondaryLight(t.secondaryLight),t.tertiaryLight&&this.setTertiaryLight(t.tertiaryLight),t.ambientCubemapLight&&this.setAmbientCubemapLight(t.ambientCubemapLight),t.ambientLight&&this.setAmbientLight(t.ambientLight),t.environment&&this.setEnvironment(t.environment),this._createGround(),t.ground&&this.setGround(t.ground),this.setCameraControl({distance:20,minDisntance:2,maxDistance:100,center:[0,0,0]}),this._enablePicking=t.picking||!1,this._initHandlers(),a.on("update",function(){this.trigger("updatecamera",{center:a.getCenter(),alpha:a.getAlpha(),beta:a.getBeta(),distance:a.getDistance()}),this.refresh()},this),this.shaderLibrary=g.a.createLibrary()},a.prototype._createGround=function(){var e=new f.a({isGround:!0,material:new h.a({shader:new v.a({vertex:v.a.source("qmv.ground.vertex"),fragment:v.a.source("qmv.ground.fragment")}),transparent:!0}),castShadow:!1,geometry:new m.a});e.material.set("color",[1,1,1,1]),e.scale.set(40,40,1),e.rotation.rotateX(-Math.PI/2),this._groundMesh=e,this._renderMain.scene.add(e)},a.prototype._addModel=function(e,t,n,a){this.removeModel(),this._renderMain.scene.add(e),this._skeletons=n.slice(),this._modelNode=e,this._setAnimationClips(a),t&&t.length&&(this._nodes=t);var i={};e.traverse(function(e){if(e.material){var t=e.material;i[t.name]=i[t.name]||[],i[t.name].push(t)}},this),this._materialsMap=i,this._updateMaterialsSRGB(),this._stopAccumulating()},a.prototype._removeAnimationClips=function(){this._clips.forEach(function(e){this._animation.removeClip(e)},this),this._clips=[],this._takes=[]},a.prototype._setAnimationClips=function(e){function t(){n.refresh()}var n=this;e.forEach(function(e){e.tracks.forEach(function(e){e.target||(e.target=this._nodes[e.targetNodeIndex])},this),e.onframe=t,this._animation.addClip(e),this._takes.push({name:e.name,range:[0,e.life],clip:e})},this),this._clips=e.slice()},a.prototype._initHandlers=function(){this._picking=new _.a({renderer:this._renderer,scene:this._renderMain.scene,camera:this._renderMain.camera}),this._clickHandler=this._clickHandler.bind(this),this._mouseDownHandler=this._mouseDownHandler.bind(this),this.root.addEventListener("mousedown",this._mouseDownHandler),this.root.addEventListener("click",this._clickHandler)},a.prototype._mouseDownHandler=function(e){this._startX=e.clientX,this._startY=e.clientY},a.prototype._clickHandler=function(e){if(this._enablePicking||this._renderMain.isDOFEnabled()){var t=e.clientX-this._startX,n=e.clientY-this._startY;if(!(Math.sqrt(t*t+n*n)>=40)){var a=this._picking.pick(e.clientX,e.clientY,!0);a&&!a.target.isGround?(this._renderMain.setDOFFocusOnPoint(a.distance),this.trigger("doffocus",a),this._selectResult=a,this.trigger("select",a),this.refresh()):(this._selectResult&&this.trigger("unselect",this._selectResult),this._selectResult=null)}}},a.prototype.enablePicking=function(){this._enablePicking=!0},a.prototype.disablePicking=function(){this._enablePicking=!1},a.prototype.setModelUpAxis=function(e){var t=this._modelNode;t&&(t.position.set(0,0,0),t.scale.set(1,1,1),t.rotation.identity(),"z"===e.toLowerCase()&&t.rotation.identity().rotateX(-Math.PI/2),this.autoFitModel())},a.prototype.setTextureFlipY=function(e){if(this._modelNode){for(var t in this._materialsMap)for(var n=0;n1||o<0){n=!0;break}}if(n)for(var a=0;a=0&&s.splice(a,1),c[e]=null}}t=t||{};var i=this._materialsMap[e],r=this,o=this._textureFlipY;if(!i||!i.length)return void console.warn("Material %s not exits",e);var s=i[0].shader.getEnabledTextures(),c={};["diffuseMap","normalMap","parallaxOcclusionMap","emissiveMap"].forEach(function(e){a(e)},this),i[0].shader.isDefined("fragment","USE_METALNESS")?["metalnessMap","roughnessMap"].forEach(function(e){a(e)},this):["specularMap","glossinessMap"].forEach(function(e){a(e)},this),(c.normalMap||c.parallaxOcclusionMap)&&this._modelNode.traverse(function(t){t.material&&t.material.name===e&&(t.geometry.attributes.tangent.value||t.geometry.generateTangents())}),i.forEach(function(e){null!=t.transparent&&(e.transparent=!!t.transparent,e.depthMask=!t.transparent),["color","emission","specularColor"].forEach(function(n){null!=t[n]&&e.set(n,T.a.parseColor(t[n]))}),["alpha","alphaCutoff","metalness","roughness","glossiness","emissionIntensity","uvRepeat","parallaxOcclusionScale"].forEach(function(n){null!=t[n]&&e.set(n,t[n])});for(var n in c)e.set(n,c[n]);e.attachShader(this.shaderLibrary.get("qtek."+(this._shaderName||"standard"),{fragmentDefines:e.shader.fragmentDefines,textures:s,vertexDefines:e.shader.vertexDefines,precision:e.shader.precision}),!0)},this),this.refresh()},a.prototype.getMaterial=function(e){function t(e){var t=a.get(e);if(!t)return"";for(var n=t.image;n.srcImage;)n=n.srcImage;return n&&n.src||""}var n=this._materialsMap[e];if(!n)return void console.warn("Material %s not exits",e);var a=n[0],i={name:e};return["color","emission"].forEach(function(e){i[e]=T.a.stringifyColor(a.get(e),"hex")}),["alpha","alphaCutoff","emissionIntensity","uvRepeat","parallaxOcclusionScale"].forEach(function(e){i[e]=a.get(e)}),["diffuseMap","normalMap","parallaxOcclusionMap","emissiveMap"].forEach(function(e){i[e]=t(e)}),a.shader.isDefined("fragment","USE_METALNESS")?(["metalness","roughness"].forEach(function(e){i[e]=a.get(e)}),["metalnessMap","roughnessMap"].forEach(function(e){i[e]=t(e)}),i.type="pbrMetallicRoughness"):(i.specularColor=T.a.stringifyColor(a.get("specularColor"),"hex"),i.glossiness=a.get("glossiness"),["specularMap","glossinessMap"].forEach(function(e){i[e]=t(e)}),i.type="pbrSpecularGlossiness"),i},a.prototype.setGround=function(e){this._groundMesh.invisible=!e.show,this.refresh()},a.prototype.getMaterialsNames=function(){return Object.keys(this._materialsMap)},a.prototype.setPostEffect=function(e){this._renderMain.setPostEffect(e),this._updateMaterialsSRGB(),this.refresh()},a.prototype.start=function(){if(this._disposed)return void console.warn("Viewer already disposed");this._animation.start(),this._animation.on("frame",this._loop,this)},a.prototype.stop=function(){this._animation.stop(),this._animation.off("frame",this._loop)},a.prototype.addHotspot=function(e,t){return this._hotspotManager.add(e,t)},a.prototype.setPose=function(e){this._clips.forEach(function(t){t.setTime(e)}),this._skeletons.forEach(function(e){e.update()}),this.refresh()},a.prototype.getAnimationDuration=function(){var e=0;return this._clips.forEach(function(t){e=Math.max(t.life,e)}),e},a.prototype.refresh=function(){this._needsRefresh=!0},a.prototype.getRenderer=function(){return this._renderer},a.prototype._updateMaterialsSRGB=function(){var e=this._renderMain.isLinearSpace();for(var t in this._materialsMap)for(var n=this._materialsMap[t],a=0;a0&&this._clips.splice(t,1)},removeClipsAll:function(){this._clips=[]},getClip:function(e){if(this._clips[e])return this._clips[e].clip},getClipNumber:function(){return this._clips.length},updateJointMatrices:function(){var e=l.create();return function(){this._invBindPoseMatricesArray=new Float32Array(16*this.joints.length),this._skinMatricesArray=new Float32Array(16*this.joints.length);for(var t=0;tthis.distance,i=1;i<8;i++)if(o.dot(t[i]._array,n)>this.distance!=a)return!0},intersectLine:function(){var e=o.create();return function(t,n,i){var r=this.distanceToPoint(t),s=this.distanceToPoint(n);if(r>0&&s>0||r<0&&s<0)return null;var c=this.normal._array,l=this.distance,u=t._array;o.sub(e,n._array,t._array),o.normalize(e,e);var p=o.dot(c,e);if(0===p)return null;i||(i=new a.a);var d=(o.dot(c,u)-l)/p;return o.scaleAndAdd(i._array,u,e,-d),i._dirty=!0,i}}(),applyTransform:function(){var e=s.create(),t=c.create(),n=c.create();return n[3]=1,function(a){a=a._array,o.scale(n,this.normal._array,this.distance),c.transformMat4(n,n,a),this.distance=o.dot(n,this.normal._array),s.invert(e,a),s.transpose(e,e),t[3]=0,o.copy(t,this.normal._array),c.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,n){"use strict";var a=n(31),i=n(0),r=n.n(i),o=r.a.quat,s=r.a.vec3,c=function(e){e=e||{},a.a.call(this,e),this.tracks=e.tracks||[]};c.prototype=Object.create(a.a.prototype),c.prototype.constructor=c,c.prototype.step=function(e,t,n){var i=a.a.prototype.step.call(this,e,t,!0);if("finish"!==i){var e=this.getElapsedTime();this._range&&(e=this._range[0]+e),this.setTime(e)}return n||"paused"===i||this.fire("frame"),i},c.prototype.setRange=function(e){this.calcLifeFromTracks(),this._range=e,e&&(e[1]=Math.min(e[1],this.life),e[0]=Math.min(e[0],this.life),this.life=e[1]-e[0])},c.prototype.setTime=function(e){for(var t=0;t=0&&this.tracks.splice(t,1)},c.prototype.getSubClip=function(e,t,n){for(var a=new c({name:this.name}),i=0;i1e-6?(o=Math.acos(s),c=Math.sin(o),l=Math.sin((1-a)*o)/c,u=Math.sin(a*o)/c):(l=1-a,u=a),e[0]=l*p+u*m,e[1]=l*d+u*v,e[2]=l*f+u*_,e[3]=l*h+u*x,e}var r=n(77),o=n(0),s=n.n(o),c=s.a.quat,l=s.a.vec3,u=function(e){e=e||{},this.name=e.name||"",this.target=e.target||null,this.position=l.create(),this.rotation=c.create(),this.scale=l.fromValues(1,1,1),this.channels={time:null,position:null,rotation:null,scale:null},this._cacheKey=0,this._cacheTime=0};u.prototype.setTime=function(e){if(this.channels.time){var t=this.channels,n=t.time.length,r=-1;if(1===n)return t.rotation&&c.copy(this.rotation,t.rotation),t.position&&l.copy(this.position,t.position),void(t.scale&&l.copy(this.scale,t.scale));if(e<=t.time[0])e=t.time[0],r=0;else if(e>=t.time[n-1])e=t.time[n-1],r=n-2;else if(e=0;s--)if(t.time[s-1]<=e&&t.time[s]>e){r=s-1;break}}else for(var s=this._cacheKey;se){r=s;break}if(r>-1){this._cacheKey=r,this._cacheTime=e;var u=r,p=r+1,d=t.time[u],f=t.time[p],h=f-d,m=0===h?0:(e-d)/h;t.rotation&&i(this.rotation,t.rotation,t.rotation,m,4*u,4*p),t.position&&a(this.position,t.position,t.position,m,3*u,3*p),t.scale&&a(this.scale,t.scale,t.scale,m,3*u,3*p)}r==n-2&&(this._cacheKey=0,this._cacheTime=0),this.updateTarget()}},u.prototype.updateTarget=function(){var e=this.channels;this.target&&(e.position&&this.target.position.setArray(this.position),e.rotation&&this.target.rotation.setArray(this.rotation),e.scale&&this.target.scale.setArray(this.scale))},u.prototype.getMaxTime=function(){return this.channels.time[this.channels.time.length-1]},u.prototype.getSubTrack=function(e,t){var n=new u({name:this.name}),a=this.channels.time[0];e=Math.min(Math.max(e,a),this.life),t=Math.min(Math.max(t,a),this.life);var i=this._findRange(e),r=this._findRange(t),o=r[0]-i[0]+1;0===i[1]&&0===r[1]&&(o-=1),this.channels.rotation&&(n.channels.rotation=new Float32Array(4*o)),this.channels.position&&(n.channels.position=new Float32Array(3*o)),this.channels.scale&&(n.channels.scale=new Float32Array(3*o)),this.channels.time&&(n.channels.time=new Float32Array(o)),this.setTime(e);for(var s=0;s<3;s++)n.channels.rotation[s]=this.rotation[s],n.channels.position[s]=this.position[s],n.channels.scale[s]=this.scale[s];n.channels.time[0]=0,n.channels.rotation[3]=this.rotation[3];for(var s=1;se&&(a=i);var r=0;if(a>=0)var o=t.time[a],s=t.time[a+1],r=(e-o)/(s-o);return[a,r]},u.prototype.blend1D=r.a.prototype.blend1D,u.prototype.blend2D=r.a.prototype.blend2D,u.prototype.additiveBlend=r.a.prototype.additiveBlend,u.prototype.subtractiveBlend=r.a.prototype.subtractiveBlend,u.prototype.clone=function(){var e=u.prototype.clone.call(this);return e.channels={time:this.channels.time||null,position:this.channels.position||null,rotation:this.channels.rotation||null,scale:this.channels.scale||null},l.copy(e.position,this.position),c.copy(e.rotation,this.rotation),l.copy(e.scale,this.scale),e.target=this.target,e.updateTarget(),e},t.a=u},function(e,t,n){"use strict";function a(e,t){return e.time-t.time}var i=n(31),r=n(0),o=n.n(r),s=o.a.quat,c=o.a.vec3,l=function(e){this.name=e.name||"",this.keyFrames=[],e.keyFrames&&this.addKeyFrames(e.keyFrames),this.position=c.create(),this.rotation=s.create(),this.scale=c.fromValues(1,1,1),this._cacheKey=0,this._cacheTime=0};l.prototype=Object.create(i.a.prototype),l.prototype.constructor=l,l.prototype.step=function(e,t,n){var a=i.a.prototype.step.call(this,e,t,!0);return"finish"!==a&&this.setTime(this.getElapsedTime()),n||"paused"===a||this.fire("frame"),a},l.prototype.setTime=function(e){this._interpolateField(e,"position"),this._interpolateField(e,"rotation"),this._interpolateField(e,"scale")},l.prototype.getMaxTime=function(){var e=this.keyFrames[this.keyFrames.length-1];return e?e.time:0},l.prototype.addKeyFrame=function(e){for(var t=0;t=e.time)return this.keyFrames.splice(t,0,e),t}this.life=e.time,this.keyFrames.push(e)},l.prototype.addKeyFrames=function(e){for(var t=0;ti[i.length-1].time)){if(e=r-1?r-1:this._cacheKey+1,l=o;l>=0;l--)if(i[l].time<=e&&i[l][t])n=i[l],this._cacheKey=l,this._cacheTime=e;else if(i[l][t]){a=i[l];break}}else for(var l=this._cacheKey;l=0&&this._clips.splice(t,1)},removeAnimator:function(e){for(var t=e.getClips(),n=0;ni)e.length=i;else for(var r=a;r=0&&!(T[A]<=t);A--);A=Math.min(A,_-2)}else{for(A=O;A<_&&!(T[A]>t);A++);A=Math.min(A-1,_-2)}O=A,k=t;var n=T[A+1]-T[A];0!==n&&(R=(t-T[A])/n,v?(D=E[A],L=E[0===A?A:A-1],P=E[A>_-2?_-1:A+1],I=E[A>_-3?_-1:A+2],c?h(e,i,c(f(e,i),L,D,P,I,R)):g?l(L,D,P,I,R,R*R,R*R*R,f(e,i),y):h(e,i,u(L,D,P,I,R,R*R,R*R*R))):c?h(e,i,c(f(e,i),E[A],E[A+1],R)):g?o(E[A],E[A+1],R,f(e,i),y):h(e,i,r(E[A],E[A+1],R)))},B=new m.a({target:e._target,life:b,loop:e._loop,delay:e._delay,onframe:F,onfinish:n});return t&&"spline"!==t&&B.setEasing(t),B}}}function h(e,t,n,r,o){this._tracks={},this._target=e,this._loop=t||!1,this._getter=n||a,this._setter=r||i,this._interpolater=o||null,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]}var m=n(31),v=Array.prototype.slice;h.prototype={constructor:h,when:function(e,t){for(var n in t)this._tracks[n]||(this._tracks[n]=[],0!==e&&this._tracks[n].push({time:0,value:c(this._getter(this._target,n))})),this._tracks[n].push({time:parseInt(e),value:t[n]});return this},during:function(e){return this._onframeList.push(e),this},_doneCallback:function(){this._tracks={},this._clipList.length=0;for(var e=this._doneList,t=e.length,n=0;n=65535?new Uint32Array(3*_):new Uint16Array(3*_);for(var b=0,T=0,E=r.isUseIndices(),w=0;w0;){for(var w=[],S=[],A=[],N=0,y=0;y=0&&-1===S[P]&&(N65535?new Uint32Array(3*B.triangles.length):new Uint16Array(3*B.triangles.length);var J=0;V=0;for(var y=0;y=0?U[P]:-1}V++}G.indices[J++]=k[L]}G.updateBoundingBox(),I.add(W)}for(var ae=e.children(),y=0;y=0&&S[E]>1e-4&&(d.transformMat4(C,w,b[A[E]]),d.scaleAndAdd(N,N,C,S[E]));M.set(T,N)}}for(var T=0;T<_.length;T+=3){var R=_[T],L=_[T+1],D=_[T+2],P=u?p.attributes.skinnedPosition:x;if(P.get(R,e._array),P.get(L,t._array),P.get(D,n._array),h=v?a.intersectTriangle(e,t,n,i.culling):a.intersectTriangle(e,n,t,i.culling)){var I=new o.a;u?o.a.copy(I,h):o.a.transformMat4(I,h,i.worldTransform),c.push(new f.Intersection(h,I,i,[R,L,D],T/3,o.a.dist(I,this._ray.origin)))}}}}}}(),_intersectionCompareFunc:function(e,t){return e.distance-t.distance}});f.Intersection=function(e,t,n,a,i,r){this.point=e,this.pointWorld=t,this.target=n,this.triangle=a,this.triangleIndex=i,this.distance=r},t.a=f},function(e,t,n){"use strict";var a=n(20),i=n(7),r=a.a.extend({dynamic:!1,widthSegments:20,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,n=this.attributes.position,a=this.attributes.texcoord0,r=this.attributes.normal,o=(t+1)*(e+1);n.init(o),a.init(o),r.init(o);var s,c,l,u,p,d,f,h=o>65535?Uint32Array:Uint16Array,m=this.indices=new h(t*e*6),v=this.radius,_=this.phiStart,x=this.phiLength,g=this.thetaStart,y=this.thetaLength,v=this.radius,b=[],T=[],E=0,w=1/v;for(f=0;f<=e;f++)for(d=0;d<=t;d++)u=d/t,p=f/e,s=-v*Math.cos(_+u*x)*Math.sin(g+p*y),c=v*Math.cos(g+p*y),l=v*Math.sin(_+u*x)*Math.sin(g+p*y),b[0]=s,b[1]=c,b[2]=l,T[0]=u,T[1]=p,n.set(E,b),a.set(E,T),b[0]*=w,b[1]*=w,b[2]*=w,r.set(E,b),E++;var S,A,N,C,M=t+1,R=0;for(f=0;f0){var i=Math.pow(2,e[3]-128-8+a);t[n+0]=e[0]*i,t[n+1]=e[1]*i,t[n+2]=e[2]*i}else t[n+0]=0,t[n+1]=0,t[n+2]=0;return t[n+3]=1,t}function i(e,t,n){for(var a="",i=t;i0;)if(e[o][0]=t[n++],e[o][1]=t[n++],e[o][2]=t[n++],e[o][3]=t[n++],1===e[o][0]&&1===e[o][1]&&1===e[o][2]){for(var c=e[o][3]<>>0;c>0;c--)r(e[o-1],e[o]),o++,s--;i+=8}else o++,s--,i=0;return n}function s(e,t,n,a){if(ad)return o(e,t,n,a);var i=t[n++];if(2!=i)return o(e,t,n-1,a);if(e[0][1]=t[n++],e[0][2]=t[n++],i=t[n++],(e[0][2]<<8>>>0|i)>>>0!==a)return null;for(var i=0;i<4;i++)for(var r=0;r128){s=(127&s)>>>0;for(var c=t[n++];s--;)e[r++][i]=c}else for(;s--;)e[r++][i]=t[n++]}return n}var c=n(3),l=n(5),u=String.fromCharCode,p=8,d=32767,f={parseRGBE:function(e,t,n){null==n&&(n=0);var r=new Uint8Array(e),o=r.length;if("#?"===i(r,0,2)){for(var p=2;p=o)){p+=2;for(var d="";p=n.x&&t>=n.y&&e<=n.x+n.width&&t<=n.y+n.height};var d=new c.a;a.prototype.castRay=function(e,t,n){var a=this.layer.renderer,i=a.viewport;return a.viewport=this.viewport,a.screenToNDC(e,t,d),this.camera.castRay(d,n),a.viewport=i,n},a.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this._frame=0,this._temporalSS.resetFrame()},a.prototype.render=function(e){this._doRender(e,this._frame),this._frame++},a.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively},a.prototype.needsTemporalSS=function(){var e=this._enableTemporalSS;return"auto"==e&&(e=this._enablePostEffect),e},a.prototype.hasDOF=function(){return this._enableDOF},a.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30},a.prototype._doRender=function(e,t){var n=this.scene,a=this.camera,i=this.renderer;if(t=t||0,!e&&this._shadowMapPass&&(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(i,n,a,!0)),this._updateShadowPCFKernel(t),i.gl.clearColor(0,0,0,0),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(i,a),this._compositor.updateNormal(i,n,a,this._temporalSS.getFrame())),this._updateSSAO(i,n,a,this._temporalSS.getFrame()),this._enablePostEffect){var r=this._compositor.getSourceFrameBuffer();r.bind(i),i.gl.clear(i.gl.DEPTH_BUFFER_BIT|i.gl.COLOR_BUFFER_BIT),i.render(n,a,!0,this.preZ),this.afterRenderScene(i,n,a),r.unbind(i),this.needsTemporalSS()&&e?(this._compositor.composite(i,a,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),i.setViewport(this.viewport),this._temporalSS.render(i)):(i.setViewport(this.viewport),this._compositor.composite(i,a,null,0))}else if(this.needsTemporalSS()&&e){var r=this._temporalSS.getSourceFrameBuffer();r.bind(i),i.saveClear(),i.clearBit=i.gl.DEPTH_BUFFER_BIT|i.gl.COLOR_BUFFER_BIT,i.render(n,a,!0,this.preZ),this.afterRenderScene(i,n,a),i.restoreClear(),r.unbind(i),i.setViewport(this.viewport),this._temporalSS.render(i)}else i.setViewport(this.viewport),i.render(n,a,!0,this.preZ),this.afterRenderScene(i,n,a);this.afterRenderAll(i,n,a)},a.prototype.afterRenderScene=function(e,t,n){},a.prototype.afterRenderAll=function(e,t,n){},a.prototype._updateSSAO=function(e,t,n,a){function i(e){for(var t=0;tthis.camera.far||e0&&(d.define("vertex","SKINNING"),d.define("vertex","JOINT_COUNT",l)),s&&d.define("both","SHADOW_TRANSPARENT"),o.useSkinMatricesTexture&&d.define("vertex","USE_SKIN_MATRICES_TEXTURE"),this._depthShaders[r]=d),p||(p=new h.a({shader:d}),this._depthMaterials[i]=p),o.material=p,this.softShadow===C.VSM?d.define("fragment","USE_VSM"):d.undefine("fragment","USE_VSM"),p.setUniform("bias",t),p.setUniform("slopeScale",n),s&&p.set("shadowTransparentMap",c))}},_bindDistanceMaterial:function(e,t){for(var n=t.getWorldPosition()._array,a=0;a0&&(o.shader.define("vertex","SKINNING"),o.shader.define("vertex","JOINT_COUNT",r)),this._distanceMaterials[r]=o),i.material=o,this.softShadow===C.VSM?o.shader.define("fragment","USE_VSM"):o.shader.undefine("fragment","USE_VSM")),o.set("lightPosition",n),o.set("range",t.range)}},saveMaterial:function(e){for(var t=0;t1&&(v=x,x.shadowCascade>4)){console.warn("Support at most 4 cascade");continue}this.renderDirectionalLightShadow(e,t,n,x,this._opaqueCasters,h,u,l)}else x instanceof p.a?this.renderSpotLightShadow(e,x,this._opaqueCasters,c,s):x instanceof f.a&&this.renderPointLightShadow(e,x,this._opaqueCasters,m);this._shadowMapNumber[x.type]++}this.restoreMaterial(this._opaqueCasters);var g=h.slice(),y=h.slice();g.pop(),y.shift(),g.reverse(),y.reverse(),u.reverse();for(var b=s.map(i),T=l.map(i),E={},_=0;_0?(A.fragmentDefines[R]=M,N=!0):A.isDefined("fragment",R)&&(A.undefine("fragment",R),N=!0))}N&&A.dirty(),v?A.define("fragment","SHADOW_CASCADE",v.shadowCascade):A.undefine("fragment","SHADOW_CASCADE"),E[A.__GUID__]=!0}s.length>0&&(S.setUniform("spotLightShadowMaps",s),S.setUniform("spotLightMatrices",c),S.setUniform("spotLightShadowMapSizes",b)),l.length>0&&(S.setUniform("directionalLightShadowMaps",l),v&&(S.setUniform("shadowCascadeClipsNear",g),S.setUniform("shadowCascadeClipsFar",y)),S.setUniform("directionalLightMatrices",u),S.setUniform("directionalLightShadowMapSizes",T)),m.length>0&&S.setUniform("pointLightShadowMaps",m)}}},renderDirectionalLightShadow:function(){var e=new s.a,t=new c.a,n=new o.a,a=new c.a,i=new c.a,r=new c.a,u=new c.a;return function(o,s,p,d,f,h,m,v){var _=d.shadowBias;if(this._bindDepthMaterial(f,_,d.shadowSlopeScale),f.sort(l.a.opaqueSortFunc),!s.viewBoundingBoxLastFrame.isFinite()){var x=s.getBoundingBox();s.viewBoundingBoxLastFrame.copy(x).applyTransform(p.viewMatrix)}var y=Math.min(-s.viewBoundingBoxLastFrame.min.z,p.far),b=Math.max(-s.viewBoundingBoxLastFrame.max.z,p.near),T=this._getDirectionalLightCamera(d,s,p),E=r._array;u.copy(T.projectionMatrix),A.invert(i._array,T.worldTransform._array),A.multiply(i._array,i._array,p.worldTransform._array),A.multiply(E,u._array,i._array);for(var w=[],S=p instanceof g.a,N=(p.near+p.far)/(p.near-p.far),M=2*p.near*p.far/(p.near-p.far),R=0;R<=d.shadowCascade;R++){var L=b*Math.pow(y/b,R/d.shadowCascade),D=b+(y-b)*R/d.shadowCascade,P=L*d.cascadeSplitLogFactor+D*(1-d.cascadeSplitLogFactor);w.push(P),h.push(-(-P*N+M)/-P)}var I=this._getTexture(d,d.shadowCascade);v.push(I);var O=o.viewport,k=o.gl;this._frameBuffer.attach(I),this._frameBuffer.bind(o),k.clear(k.COLOR_BUFFER_BIT|k.DEPTH_BUFFER_BIT);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&&p.push(l);u.drawBuffersEXT(p)}e.saveClear(),e.clearBit=i.a.DEPTH_BUFFER_BIT|i.a.COLOR_BUFFER_BIT,n=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),e.restoreClear(),a.unbind(e)}else n=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",n),this._rendering=!1,this._rendered=!0}});t.a=o},function(e,t,n){"use strict";var a=n(21),i=a.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,n){"use strict";var a=n(12),i=n(21),r=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 a.a({fragment:this.shader});this.pass=e},{render:function(e,t){this.trigger("beforerender",e),this._rendering=!0;var n=e.gl;for(var a in this.inputLinks){var i=this.inputLinks[a],r=i.node.getOutput(e,i.pin);this.pass.setUniform(a,r)}if(this.outputs){this.pass.outputs={};var o={};for(var s in this.outputs){var c=this.updateParameter(s,e);isNaN(c.width)&&this.updateParameter(s,e);var l=this.outputs[s],u=this._compositor.allocateTexture(c);this._outputTextures[s]=u;var p=l.attachment||n.COLOR_ATTACHMENT0;"string"==typeof p&&(p=n[p]),o[p]=u}this._compositor.getFrameBuffer().bind(e);for(var p in o)this._compositor.getFrameBuffer().attach(o[p],p);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 a in this.inputLinks){var i=this.inputLinks[a];i.node.removeReference(i.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",e)},updateParameter:function(e,t){var n=this.outputs[e],a=n.parameters,i=n._parametersCopy;if(i||(i=n._parametersCopy={}),a)for(var r in a)"width"!==r&&"height"!==r&&(i[r]=a[r]);var o,s;return o=a.width instanceof Function?a.width.call(this,t):a.width,s=a.height instanceof Function?a.height.call(this,t):a.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])},setShader:function(e){var t=this.pass.material;t.shader.setFragment(e),t.attachShader(t.shader,!0)},shaderDefine:function(e,t){this.pass.material.shader.define("fragment",e,t)},shaderUndefine:function(e){this.pass.material.shader.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])}},link:function(e,t,n){this.inputLinks[e]={node:t,pin:n},t.outputLinks[n]||(t.outputLinks[n]=[]),t.outputLinks[n].push({node:this,pin:e}),this.pass.material.shader.enableTexture(e)},clear:function(){i.a.prototype.clear.call(this),this.pass.material.shader.disableTexturesAll()},updateReference:function(e){if(!this._rendering){this._rendering=!0;for(var t in this.inputLinks){var n=this.inputLinks[t];n.node.updateReference(n.pin)}this._rendering=!1}e&&this._outputReferences[e]++},beforeFrame:function(){this._rendered=!1;for(var e in this.outputLinks)this._outputReferences[e]=0},afterFrame:function(){for(var e in this.outputLinks)if(this._outputReferences[e]>0){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=r},function(e,t,n){"use strict";function a(e){for(var t=new Uint8Array(e*e*4),n=0,a=new c.a,i=0;i0&&(a.shader.define("vertex","SKINNING"),a.shader.define("vertex","JOINT_COUNT",e),i.shader.define("vertex","SKINNING"),i.shader.define("vertex","JOINT_COUNT",e)),n={material1:a,material2:i},t[e]=n}return n.used=!0,n},_resetGBufferMaterials:function(){for(var e in this._gBufferMaterials)this._gBufferMaterials[e].used=!1},_cleanGBufferMaterials:function(e){for(var t in this._gBufferMaterials){var n=this._gBufferMaterials[t];n.used||(n.material1.dispose(e),n.material2.dispose(e))}},_replaceGBufferMat:function(e,t){for(var n=0;n>>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;for(var l=0;l255?255:e}function i(e){return e<0?0:e>1?1:e}function r(e){return a(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100*255:parseInt(e,10))}function o(e){return i(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100:parseFloat(e))}function s(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}function c(e,t,n,a,i){return e[0]=t,e[1]=n,e[2]=a,e[3]=i,e}function l(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function u(e,t){_&&l(_,t),_=v.put(e,_||t.slice())}function p(e,t){if(e){t=t||[];var n=v.get(e);if(n)return l(t,n);e+="";var a=e.replace(/ /g,"").toLowerCase();if(a in m)return l(t,m[a]),u(e,t),t;if("#"!==a.charAt(0)){var i=a.indexOf("("),s=a.indexOf(")");if(-1!==i&&s+1===a.length){var p=a.substr(0,i),f=a.substr(i+1,s-(i+1)).split(","),h=1;switch(p){case"rgba":if(4!==f.length)return void c(t,0,0,0,1);h=o(f.pop());case"rgb":return 3!==f.length?void c(t,0,0,0,1):(c(t,r(f[0]),r(f[1]),r(f[2]),h),u(e,t),t);case"hsla":return 4!==f.length?void c(t,0,0,0,1):(f[3]=o(f[3]),d(f,t),u(e,t),t);case"hsl":return 3!==f.length?void c(t,0,0,0,1):(d(f,t),u(e,t),t);default:return}}c(t,0,0,0,1)}else{if(4===a.length){var _=parseInt(a.substr(1),16);return _>=0&&_<=4095?(c(t,(3840&_)>>4|(3840&_)>>8,240&_|(240&_)>>4,15&_|(15&_)<<4,1),u(e,t),t):void c(t,0,0,0,1)}if(7===a.length){var _=parseInt(a.substr(1),16);return _>=0&&_<=16777215?(c(t,(16711680&_)>>16,(65280&_)>>8,255&_,1),u(e,t),t):void c(t,0,0,0,1)}}}}function d(e,t){var n=(parseFloat(e[0])%360+360)%360/360,i=o(e[1]),r=o(e[2]),l=r<=.5?r*(i+1):r+i-r*i,u=2*r-l;return t=t||[],c(t,a(255*s(u,l,n+1/3)),a(255*s(u,l,n)),a(255*s(u,l,n-1/3)),1),4===e.length&&(t[3]=e[3]),t}function f(e,t){if(e&&e.length){var n=e[0]+","+e[1]+","+e[2];return"rgba"!==t&&"hsva"!==t&&"hsla"!==t||(n+=","+e[3]),t+"("+n+")"}}t.a=p,t.b=f;var h=n(63),m={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 h.a(20),_=null},function(e,t,n){"use strict";t.a={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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(qtek.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 / 32, height * 1.0 / 32] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(qtek.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(qtek.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 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blend",shader:"#source(qtek.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(qtek.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(qtek.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 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blend",shader:"#source(qtek.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(qtek.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(qtek.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 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blend",shader:"#source(qtek.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(qtek.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(qtek.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 / 2, height * 1.0 / 2] )"}},{name:"bloom_composite",shader:"#source(qtek.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(qtek.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},defines:{}},{name:"FXAA",shader:"#source(qtek.compositor.fxaa)",inputs:{texture:"composite"}}]}},function(e,t,n){"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 qtek.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 qtek.util.rgbm\n@import qtek.util.float\n\nvoid main()\n{\n vec4 blurredColor = decodeHDR(texture2D(blurred, v_Texcoord));\n vec4 originalColor = decodeHDR(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 = decodeHDR(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 qtek.util.rgbm\n@import qtek.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 = decodeHDR(texel);\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\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 gl_FragColor = encodeHDR(color);\n#endif\n}\n\n@end"},function(e,t,n){"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,n){"use strict";function a(){for(var e=[],t=0;t<30;t++)e.push([Object(i.a)(t,2),Object(i.a)(t,3)]);this._haltonSequence=e,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 r.a({fragment:c.a.source("qtek.compositor.blend")});n.material.shader.disableTexturesAll(),n.material.shader.enableTexture(["texture1","texture2"]),this._blendFb=new o.a({depthBuffer:!1}),this._outputPass=new r.a({fragment:c.a.source("qtek.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.shader.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=n(28),r=n(12),o=n(10),s=n(5),c=n(4),l=n(8);a.prototype={constructor:a,jitterProjection:function(e,t){var n=e.viewport,a=n.devicePixelRatio||e.getDevicePixelRatio(),i=n.width*a,r=n.height*a,o=this._haltonSequence[this._frame],s=new l.a;s._array[12]=(2*o[0]-1)/i,s._array[13]=(2*o[1]-1)/r,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},resize:function(e,t){this._sourceTex.width===e&&this._sourceTex.height===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){var t=this._blendPass;0===this._frame?(t.setUniform("weight1",0),t.setUniform("weight2",1)):(t.setUniform("weight1",.9),t.setUniform("weight2",.1)),t.setUniform("texture1",this._prevFrameTex),t.setUniform("texture2",this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),t.render(e),this._blendFb.unbind(e),this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e);var n=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=n,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=a},function(e,t,n){"use strict";function a(e){this.setScene(e)}var i=n(29),r=n(36),o=n(35),s=n(2),c=n(60),l=n(131);a.prototype={constructor:a,setScene:function(e){this._scene=e,this._skybox&&this._skybox.attachScene(this._scene)},initLight:function(e){this._lightRoot=e,this.mainLight=new c.a({shadowBias:.005}),this.secondaryLight=new c.a({shadowBias:.005}),this.tertiaryLight=new c.a({shadowBias:.005}),this.ambientLight=new l.a},dispose:function(e){this._lightRoot&&(this._lightRoot.remove(this.mainLight),this._lightRoot.remove(this.ambientLight)),this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._currentCubemapLights.specular&&(this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights.specular.cubemap.dispose(e)))},updateMainLight:function(e,t){this._updateDirectionalLight(this.mainLight,e,t)},updateSecondaryLight:function(e,t){this._updateDirectionalLight(this.secondaryLight,e,t)},updateTertiaryLight:function(e,t){this._updateDirectionalLight(this.tertiaryLight,e,t)},_updateDirectionalLight:function(e,t,n){t=t||{},null!=t.intensity&&(e.intensity=t.intensity,this._lightRoot[t.intensity?"add":"remove"](e)),null!=t.color&&(e.color=i.a.parseColor(t.color).slice(0,3));var a=i.a.firstNotNull(t.alpha,45),r=i.a.firstNotNull(t.beta,45);e.position.setArray(i.a.directionFromAlphaBeta(a,r)),e.lookAt(s.a.ZERO);var o={low:512,medium:1024,high:2048,ultra:4096}[t.quality]||1024;e.castShadow=i.a.firstNotNull(t.shadow,!0),e.shadowResolution=o},updateAmbientLight:function(e,t){e=e||{},null!=e.intensity&&(this.ambientLight.intensity=e.intensity,this._lightRoot[e.intensity?"add":"remove"](this.ambientLight)),null!=e.color&&(this.ambientLight.color=i.a.parseColor(e.color).slice(0,3))},updateAmbientCubemapLight:function(e,t){e=e||{};var n=t.getRenderer(),a=e.texture,o=this;if("texture"in e&&(!this._currentCubemapLights||a!==this._currentCubemapLights.textureUrl))if(this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._currentCubemapLights.specular&&(this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights.specular.cubemap.dispose(n.gl))),a){var s=i.a.createAmbientCubemap(e,t,function(){s.specular&&o._skybox instanceof r.a&&o._skybox.setEnvironmentMap(s.specular.cubemap),t.refresh()});s.diffuse&&this._lightRoot.add(s.diffuse),s.specular&&this._lightRoot.add(s.specular),this._currentCubemapLights=s,this._currentCubemapLights.textureUrl=a}else this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights=null);this._currentCubemapLights&&(null!=e.specularIntensity&&this._currentCubemapLights.specular&&(this._currentCubemapLights.specular.intensity=e.specularIntensity),null!=e.diffuseIntensity&&this._currentCubemapLights.diffuse&&(this._currentCubemapLights.diffuse.intensity=e.diffuseIntensity))},updateSkybox:function(e,t,n){var a=n.getRenderer(),s=this;if(e&&"none"!==e)if("auto"===e)if(this._currentCubemapLights){var c=function(){return s._skybox instanceof r.a||(s._skybox&&s._skybox.dispose(a),s._skybox=new r.a),s._skybox}();if(this._currentCubemapLights.specular){var l=this._currentCubemapLights.specular.cubemap;c.setEnvironmentMap(l)}this._scene&&c.attachScene(this._scene),c.material.set("lod",2)}else this._skybox&&this._skybox.detachScene();else{var u=function(){return s._skybox instanceof o.a||(s._skybox&&s._skybox.dispose(a),s._skybox=new o.a),s._skybox}(),p=i.a.loadTexture(e,n,{flipY:!1},function(){n.refresh()});u.setEnvironmentMap(p),u.attachScene(this._scene)}else this._skybox&&this._skybox.detachScene(this._scene),this._skybox=null;if(this._skybox)if("auto"===e||e.match&&e.match(/.hdr$/))this._skybox.material.shader.undefine("fragment","SRGB_DECODE");else{var d=t?"define":"undefine";this._skybox.material.shader[d]("fragment","SRGB_DECODE")}}},t.a=a},function(e,t,n){"use strict";var a=n(14),i=a.a.extend({castShadow:!1},{type:"AMBIENT_LIGHT",uniformTemplates:{ambientLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}}});t.a=i},function(e,t,n){"use strict";t.a={devicePixelRatio:null,preZ:!1,picking:!1,shadow:!0,environment:"",ground:{show:!1},mainLight:{shadow:!0,shadowQuality:"medium",intensity:.8,color:"#fff",alpha:45,beta:45},secondaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:60,beta:-50},tertiaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:89,beta:0},ambientLight:{intensity:.3,color:"#fff"},ambientCubemapLight:{texture:"",exposure:3,diffuseIntensity:.5,specularIntensity:.5},postEffect:{enable:!1,bloom:{enable:!1,intensity:.1},depthOfField:{enable:!1,focalDistance:5,focalRange:1,blurRadius:5,fstop:2.8,quality:"medium"},screenSpaceAmbientOcculusion:{enable:!1,radius:.5,quality:"medium",intensity:1},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},FXAA:{enable:!1}}}},function(e,t,n){"use strict";function a(e){if(null==e||"object"!=typeof e)return e;var t=e,n=m.call(e);if("[object Array]"===n){t=[];for(var i=0,r=e.length;i=0&&i[d]>1e-6&&(c.transformMat4(s,n,r[a[d]]),c.scaleAndAdd(o,o,s,i[d]));c.min(v,v,o),c.max(_,_,o)}t.min.setArray(v),t.max.setArray(_)}function i(e,t){t=t||new r.a;var n=new r.a;return e.traverse(function(e){e.geometry&&(e.isSkinnedMesh()?(a(e,n),e.geometry.boundingBox.copy(n)):(n.copy(e.geometry.boundingBox),n.applyTransform(e.worldTransform)),t.union(n))}),t}var r=n(7),o=n(0),s=n.n(o),c=s.a.vec3;t.a=i},function(e,t,n){"use strict";function a(e){return Array.isArray(e)||(e=[e,e]),e}var i=n(1),r=n(24),o=n(2),s=n(136),c=i.a.extend(function(){return{animation:null,domElement:null,target:null,_center:new o.a,minDistance:.1,maxDistance:1e3,minAlpha:-90,maxAlpha:90,minBeta:-1/0,maxBeta:1/0,autoRotateAfterStill:0,autoRotateDirection:"cw",autoRotateSpeed:60,_mode:"rotate",damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,_needsUpdate:!1,_rotating:!1,_phi:0,_theta:0,_mouseX:0,_mouseY:0,_rotateVelocity:new r.a,_panVelocity:new r.a,_distance:20,_zoomSpeed:0,_stillTimeout:0,_animators:[],_gestureMgr:new s.a}},function(){this._mouseDownHandler=this._mouseDownHandler.bind(this),this._mouseWheelHandler=this._mouseWheelHandler.bind(this),this._mouseMoveHandler=this._mouseMoveHandler.bind(this),this._mouseUpHandler=this._mouseUpHandler.bind(this),this._pinchHandler=this._pinchHandler.bind(this),this.update=this.update.bind(this),this.init()},{init:function(){var e=this.domElement;e.addEventListener("touchstart",this._mouseDownHandler),e.addEventListener("mousedown",this._mouseDownHandler),e.addEventListener("mousewheel",this._mouseWheelHandler),this.animation&&this.animation.on("frame",this.update)},dispose:function(){var e=this.domElement;e.removeEventListener("touchstart",this._mouseDownHandler),e.removeEventListener("touchmove",this._mouseMoveHandler),e.removeEventListener("touchend",this._mouseUpHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseup",this._mouseUpHandler),e.removeEventListener("mousewheel",this._mouseWheelHandler),this.animation&&this.animation.off("frame",this.update),this.stopAllAnimation()},getDistance:function(){return this._distance},setDistance:function(e){this._distance=e,this._needsUpdate=!0},getAlpha:function(){return this._theta/Math.PI*180},getBeta:function(){return-this._phi/Math.PI*180},getCenter:function(){return this._center.toArray()},setAlpha:function(e){e=Math.max(Math.min(this.maxAlpha,e),this.minAlpha),this._theta=e/180*Math.PI,this._needsUpdate=!0},setBeta:function(e){e=Math.max(Math.min(this.maxBeta,e),this.minBeta),this._phi=-e/180*Math.PI,this._needsUpdate=!0},setCenter:function(e){this._center.setArray(e)},setOption:function(e){e=e||{},["autoRotate","autoRotateAfterStill","autoRotateDirection","autoRotateSpeed","damping","minDistance","maxDistance","minAlpha","maxAlpha","minBeta","maxBeta","rotateSensitivity","zoomSensitivity","panSensitivity"].forEach(function(t){null!=e[t]&&(this[t]=e[t])},this),null!=e.distance&&this.setDistance(e.distance),null!=e.alpha&&this.setAlpha(e.alpha),null!=e.beta&&this.setBeta(e.beta),e.center&&this.setCenter(e.center)},animateTo:function(e){var t=this,n={},a={},i=this.animation;if(i)return null!=e.distance&&(n.distance=this.getDistance(),a.distance=e.distance),null!=e.alpha&&(n.alpha=this.getAlpha(),a.alpha=e.alpha),null!=e.beta&&(n.beta=this.getBeta(),a.beta=e.beta),null!=e.center&&(n.center=this.getCenter(),a.center=e.center),this._addAnimator(i.animate(n).when(e.duration||1e3,a).during(function(){null!=n.alpha&&t.setAlpha(n.alpha),null!=n.beta&&t.setBeta(n.beta),null!=n.distance&&t.setDistance(n.distance),null!=n.center&&t.setCenter(n.center),t._needsUpdate=!0}).done(e.done)).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e0},update:function(e){if(e=e||16,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)>.01||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(this._updateDistance(Math.min(e,50)),this._updatePan(Math.min(e,50)),this._updateRotate(Math.min(e,50)),this._updateTransform(),this.target.update(),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,this.damping)},_updateDistance:function(e){this._setDistance(this._distance+this._zoomSpeed*e/20),this._zoomSpeed*=this.damping},_setDistance:function(e){this._distance=Math.max(Math.min(e,this.maxDistance),this.minDistance)},_updatePan:function(e){var t=this._panVelocity,n=this._distance,a=this.target,i=a.worldTransform.y,r=a.worldTransform.x;this._center.scaleAndAdd(r,-t.x*n/200).scaleAndAdd(i,-t.y*n/200),this._vectorDamping(t,0)},_updateTransform:function(){var e=this.target,t=new o.a,n=this._theta+Math.PI/2,a=this._phi+Math.PI/2,i=Math.sin(n);t.x=i*Math.cos(a),t.y=-Math.cos(n),t.z=i*Math.sin(a),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 n=e.len();n*=t,n<1e-4&&(n=0),e.normalize().scale(n)},decomposeTransform:function(){if(this.target){var e=new o.a;e.eulerFromQuat(this.target.rotation.normalize(),"ZYX"),this._theta=-e.x,this._phi=-e.y,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this._setDistance(this.target.position.dist(this._center))}},_mouseDownHandler:function(e){if(!this._isAnimating()){var t=e.clientX,n=e.clientY;if(e.targetTouches){var a=e.targetTouches[0];t=a.clientX,n=a.clientY,this._mode="rotate",this._processGesture(e,"start")}var i=this.domElement;i.addEventListener("touchmove",this._mouseMoveHandler),i.addEventListener("touchend",this._mouseUpHandler),i.addEventListener("mousemove",this._mouseMoveHandler),i.addEventListener("mouseup",this._mouseUpHandler),0===e.button?this._mode="rotate":1===e.button&&(this._mode="pan"),this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=t,this._mouseY=n}},_mouseMoveHandler:function(e){if(!this._isAnimating()){var t,n=e.clientX,i=e.clientY;if(e.targetTouches){var r=e.targetTouches[0];n=r.clientX,i=r.clientY,t=this._processGesture(e,"change")}var o=a(this.panSensitivity),s=a(this.rotateSensitivity);t||("rotate"===this._mode?(this._rotateVelocity.y=(n-this._mouseX)/this.domElement.clientHeight*2*s[0],this._rotateVelocity.x=(i-this._mouseY)/this.domElement.clientWidth*2*s[1]):"pan"===this._mode&&(this._panVelocity.x=(n-this._mouseX)/this.domElement.clientWidth*o[0]*400,this._panVelocity.y=(-i+this._mouseY)/this.domElement.clientHeight*o[1]*400)),this._mouseX=n,this._mouseY=i,e.preventDefault()}},_mouseWheelHandler:function(e){if(!this._isAnimating()){var t=e.wheelDelta||-e.detail;0!==t&&this._zoomHandler(e,t>0?-1:1)}},_pinchHandler:function(e){this._isAnimating()||this._zoomHandler(e,e.pinchScale>1?-.4:.4)},_zoomHandler:function(e,t){var n=Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance));this._zoomSpeed=t*Math.max(n/40*this.zoomSensitivity,.2),this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),e.preventDefault()},_mouseUpHandler:function(e){var t=this.domElement;t.removeEventListener("touchmove",this._mouseMoveHandler),t.removeEventListener("touchend",this._mouseUpHandler),t.removeEventListener("mousemove",this._mouseMoveHandler),t.removeEventListener("mouseup",this._mouseUpHandler),this._processGesture(e,"end")},_addAnimator:function(e){var t=this._animators;return t.push(e),e.done(function(){var n=t.indexOf(e);n>=0&&t.splice(n,1)}),e},_processGesture:function(e,t){var n=this._gestureMgr;"start"===t&&n.clear();var a=n.recognize(e,null,this.domElement);if("end"===t&&n.clear(),a){var i=a.type;e.gestureEvent=i,this._pinchHandler(a.event)}return a}});Object.defineProperty(c.prototype,"autoRotate",{get:function(){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}}),Object.defineProperty(c.prototype,"target",{get:function(){return this._target},set:function(e){e&&e.target&&this.setCenter(e.target.toArray()),this._target=e,this.decomposeTransform()}}),t.a=c},function(e,t,n){"use strict";function a(e){var t=e[1][0]-e[0][0],n=e[1][1]-e[0][1];return Math.sqrt(t*t+n*n)}function i(e){return[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2]}var r=function(){this._track=[]};r.prototype={constructor:r,recognize:function(e,t,n){return this._doTrack(e,t,n),this._recognize(e)},clear:function(){return this._track.length=0,this},_doTrack:function(e,t,n){var a=e.targetTouches;if(a){for(var i={points:[],touches:[],target:t,event:e},r=0,o=a.length;r1&&r&&r.length>1){var s=a(r)/a(o);!isFinite(s)&&(s=1),t.pinchScale=s;var c=i(r);return t.pinchX=c[0],t.pinchY=c[1],{type:"pinch",target:e[0].target,event:t}}}}};t.a=r},function(e,t,n){"use strict";var a=n(1),i=n(138),r=n(7),o=a.a.extend(function(){return{dom:null,renderer:null,camera:null,_boundingBox:new r.a,_hotspotRoot:null,_hotspots:[]}},function(){if(!this.dom||!this.renderer||!this.camera)throw new Error("Tip manager needs `root`, `camera`, `renderer`");var e=this._hotspotRoot=document.createElement("div");e.style.cssText="position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;",this.dom.appendChild(e)},{setBoundingBox:function(e,t){this._boundingBox.min.setArray(e),this._boundingBox.max.setArray(t)},add:function(e,t){if("string"==typeof t){var n=document.createElement("div");n.innerHTML=t,t=n}return t.classList.add("qmv-annotation"),t.style.position="absolute",this._hotspotRoot.appendChild(t),this._hotspots.push({position:e,dom:t}),t},remove:function(e){for(var t=-1,n=0;n=0&&(this._hotspots.splice(t,1),this._hotspotRoot.removeChild(e))},update:function(){var e=new i.a,t=new r.a;this._hotspots.forEach(function(n){var a=n.position;e.set(a[0],a[1],a[2],1),e.transformMat4(this.camera.viewMatrix);var i=e.z;e.transformMat4(this.camera.projectionMatrix),e.scale(1/e.w);var r=.5*(e.x+1)*this.renderer.getWidth(),o=.5*(e.y+1)*this.renderer.getHeight();n.dom.style.left=r+"px",n.dom.style.top=this.renderer.getHeight()-o+"px";var s=null==n.farAlpha?.1:n.farAlpha,c=null==n.nearAlpha?1:n.nearAlpha;t.copy(this._boundingBox),t.applyTransform(this.camera.viewMatrix);var l=(i-t.max.z)/(t.min.z-t.max.z);Math.max(Math.min(l,1),0);n.dom.style.opacity=1,n.onupdate&&n.onupdate(r,o)},this)}});t.a=o},function(e,t,n){"use strict";var a=n(0),i=n.n(a),r=i.a.vec4,o=function(e,t,n,a){e=e||0,t=t||0,n=n||0,a=a||0,this._array=r.fromValues(e,t,n,a),this._dirty=!0};o.prototype={constructor:o,add:function(e){return r.add(this._array,this._array,e._array),this._dirty=!0,this},set:function(e,t,n,a){return this._array[0]=e,this._array[1]=t,this._array[2]=n,this._array[3]=a,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)},copy:function(e){return r.copy(this._array,e._array),this._dirty=!0,this},dist:function(e){return r.dist(this._array,e._array)},distance:function(e){return r.distance(this._array,e._array)},div:function(e){return r.div(this._array,this._array,e._array),this._dirty=!0,this},divide:function(e){return r.divide(this._array,this._array,e._array),this._dirty=!0,this},dot:function(e){return r.dot(this._array,e._array)},len:function(){return r.len(this._array)},length:function(){return r.length(this._array)},lerp:function(e,t,n){return r.lerp(this._array,e._array,t._array,n),this._dirty=!0,this},min:function(e){return r.min(this._array,this._array,e._array),this._dirty=!0,this},max:function(e){return r.max(this._array,this._array,e._array),this._dirty=!0,this},mul:function(e){return r.mul(this._array,this._array,e._array),this._dirty=!0,this},multiply:function(e){return r.multiply(this._array,this._array,e._array),this._dirty=!0,this},negate:function(){return r.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return r.normalize(this._array,this._array),this._dirty=!0,this},random:function(e){return r.random(this._array,e),this._dirty=!0,this},scale:function(e){return r.scale(this._array,this._array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return r.scaleAndAdd(this._array,this._array,e._array,t),this._dirty=!0,this},sqrDist:function(e){return r.sqrDist(this._array,e._array)},squaredDistance:function(e){return r.squaredDistance(this._array,e._array)},sqrLen:function(){return r.sqrLen(this._array)},squaredLength:function(){return r.squaredLength(this._array)},sub:function(e){return r.sub(this._array,this._array,e._array),this._dirty=!0,this},subtract:function(e){return r.subtract(this._array,this._array,e._array),this._dirty=!0,this},transformMat4:function(e){return r.transformMat4(this._array,this._array,e._array),this._dirty=!0,this},transformQuat:function(e){return r.transformQuat(this._array,this._array,e._array),this._dirty=!0,this},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 c=o.prototype;s(c,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),s(c,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),s(c,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}}),s(c,"w",{get:function(){return this._array[3]},set:function(e){this._array[3]=e,this._dirty=!0}})}o.add=function(e,t,n){return r.add(e._array,t._array,n._array),e._dirty=!0,e},o.set=function(e,t,n,a,i){r.set(e._array,t,n,a,i),e._dirty=!0},o.copy=function(e,t){return r.copy(e._array,t._array),e._dirty=!0,e},o.dist=function(e,t){return r.distance(e._array,t._array)},o.distance=o.dist,o.div=function(e,t,n){return r.divide(e._array,t._array,n._array),e._dirty=!0,e},o.divide=o.div,o.dot=function(e,t){return r.dot(e._array,t._array)},o.len=function(e){return r.length(e._array)},o.lerp=function(e,t,n,a){return r.lerp(e._array,t._array,n._array,a),e._dirty=!0,e},o.min=function(e,t,n){return r.min(e._array,t._array,n._array),e._dirty=!0,e},o.max=function(e,t,n){return r.max(e._array,t._array,n._array),e._dirty=!0,e},o.mul=function(e,t,n){return r.multiply(e._array,t._array,n._array),e._dirty=!0,e},o.multiply=o.mul,o.negate=function(e,t){return r.negate(e._array,t._array),e._dirty=!0,e},o.normalize=function(e,t){return r.normalize(e._array,t._array),e._dirty=!0,e},o.random=function(e,t){return r.random(e._array,t),e._dirty=!0,e},o.scale=function(e,t,n){return r.scale(e._array,t._array,n),e._dirty=!0,e},o.scaleAndAdd=function(e,t,n,a){return r.scaleAndAdd(e._array,t._array,n._array,a),e._dirty=!0,e},o.sqrDist=function(e,t){return r.sqrDist(e._array,t._array)},o.squaredDistance=o.sqrDist,o.sqrLen=function(e){return r.sqrLen(e._array)},o.squaredLength=o.sqrLen,o.sub=function(e,t,n){return r.subtract(e._array,t._array,n._array),e._dirty=!0,e},o.subtract=o.sub,o.transformMat4=function(e,t,n){return r.transformMat4(e._array,t._array,n._array),e._dirty=!0,e},o.transformQuat=function(e,t,n){return r.transformQuat(e._array,t._array,n._array),e._dirty=!0,e},t.a=o},function(e,t,n){"use strict";t.a="@export qmv.ground.vertex\n@import qtek.lambert.vertex\n@end\n\n\n@export qmv.ground.fragment\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float gridSize: 5;\nuniform float gridSize2: 1;\nuniform vec4 gridColor: [0, 0, 0, 1];\nuniform vec4 gridColor2: [0.3, 0.3, 0.3, 1];\n\nuniform float glossiness: 0.7;\n\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import qtek.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import qtek.header.ambient_sh_light\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import qtek.header.directional_light\n#endif\n\n@import qtek.plugin.compute_shadow_map\n\nvoid main()\n{\n gl_FragColor = color;\n\n float wx = v_WorldPosition.x;\n float wz = v_WorldPosition.z;\n float x0 = abs(fract(wx / gridSize - 0.5) - 0.5) / fwidth(wx) * gridSize / 2.0;\n float z0 = abs(fract(wz / gridSize - 0.5) - 0.5) / fwidth(wz) * gridSize / 2.0;\n\n float x1 = abs(fract(wx / gridSize2 - 0.5) - 0.5) / fwidth(wx) * gridSize2;\n float z1 = abs(fract(wz / gridSize2 - 0.5) - 0.5) / fwidth(wz) * gridSize2;\n\n float v0 = 1.0 - clamp(min(x0, z0), 0.0, 1.0);\n float v1 = 1.0 - clamp(min(x1, z1), 0.0, 1.0);\n if (v0 > 0.1) {\n gl_FragColor = mix(gl_FragColor, gridColor, v0);\n }\n else {\n gl_FragColor = mix(gl_FragColor, gridColor2, v1);\n }\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {\n diffuseColor += ambientLightColor[_idx_];\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_, v_Normal) * ambientSHLightColor[_idx_];\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 i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float ndl = dot(v_Normal, normalize(lightDirection));\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 diffuseColor += lightColor * clamp(ndl, 0.0, 1.0) * shadowContrib;\n }\n#endif\n\n#ifdef SSAOMAP_ENABLED\n diffuseColor *= texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n gl_FragColor.a *= 1.0 - clamp(length(v_WorldPosition.xz) / 30.0, 0.0, 1.0);\n\n}\n\n@end"},function(e,t,n){"use strict";var a=n(37);t.a=function(){return{preZ:!0,materials:[],takes:[],textureFlipY:!1,zUpToYUp:!1,shadow:!0,environment:"auto",viewControl:{alpha:20,beta:30,distance:18},ground:{show:!0},mainLight:{shadow:!0,shadowQuality:"medium",intensity:.8,color:"#fff",alpha:45,beta:45,$padAngle:[.25,.5]},secondaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:60,beta:-50,$padAngle:[-50/180,60/90]},tertiaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:89,beta:0,$padAngle:[0,89/90]},ambientLight:{intensity:0,color:"#fff"},ambientCubemapLight:{texture:a.a.ENV_TEXTURE_ROOT+"pisa.hdr",$texture:"pisa",$textureOptions:["pisa","Barce_Rooftop_C","Factory_Catwalk","Grand_Canyon_C","Ice_Lake","Hall","Old_Industrial_Hall"],exposure:3,diffuseIntensity:.5,specularIntensity:.5,$intensity:.5},postEffect:{enable:!0,bloom:{enable:!0,intensity:.1},depthOfField:{enable:!1,focalDistance:4,focalRange:1,blurRadius:5,fstop:10,quality:"medium",$qualityOptions:["low","medium","high","ultra"]},screenSpaceAmbientOcclusion:{enable:!1,radius:1.5,quality:"medium",intensity:1,$qualityOptions:["low","medium","high","ultra"]},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8,$qualityOptions:["low","medium","high","ultra"]},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},FXAA:{enable:!1}}}}},function(e,t,n){"use strict";t.a=function(){return{name:"",type:"pbrMetallicRoughness",color:"#fff",transparent:!1,alpha:1,alphaCutoff:0,diffuseMap:"",normalMap:"",parallaxOcclusionScale:.01,parallaxOcclusionMap:"",emission:"#fff",emissionIntensity:0,emissiveMap:"",uvRepeat:[1,1],metalness:0,roughness:.5,metalnessMap:"",roughnessMap:"",glossiness:.5,specularColor:"#111",glossinessMap:"",specularMap:"",$alphaRange:[0,1],$alphaCutoffRange:[0,1],$metalnessRange:[0,1],$roughnessRange:[0,1],$glossinessRange:[0,1],$parallaxOcclusionScaleRange:[0,.1],$textureTiling:1}}},function(e,t,n){"use strict";function a(e){var t=e.lastIndexOf(".");return t>=0?e.substr(t+1).toLowerCase():""}function i(e,t){var n=e.split("/");return t=t||"",0===e.indexOf("/")&&n.shift(),n=n.filter(function(e){return!!e}),new Promise(function(e,a){if(!x)return void a(E);var r=n.shift(),o=t+"/"+r;x.mkdir(o,function(t){t&&"EEXIST"!==t.code?a(t.toString()):n.length?i(n.join("/"),o).then(e).catch(a):e()})})}function r(e){return new Promise(function(t,n){if(!x)return void n(E);s(e).then(function(t){return Promise.all(t.map(function(t){return new Promise(function(n,a){var i=e+"/"+t;x.lstat(i,function(e,t){e?a(e.toString()):t.isDirectory()?r(i).then(n,a):x.unlink(i,function(e){e?a(e.toString()):n()})})})}))},n).then(function(){x.rmdir(e,function(e){e?n(e.toString()):t()})},n)})}function o(e,t){return new Promise(function(n,a){x||a(E),FileAPI.readAsArrayBuffer(t,function(i){"load"===i.type&&x.writeFile(e,T.from(i.result),function(e){e&&"EEXIST"!==e.code?a(e):(console.log("Writed file "+t.name+" "+i.result.byteLength),n())})})})}function s(e){return new Promise(function(t,n){x.readdir(e,function(e,a){e?n(e):t(a)})})}function c(e){BrowserFS.install(window),BrowserFS.configure({fs:"IndexedDB",options:{}},function(t){if(t)throw t;x=BrowserFS.BFSRequire("fs"),i("/project").then(function(){Promise.all([d(),p()]).then(function(t){t[0]?e&&e(t[0].glTF,t[0].filesMap,t[1]):e()}).catch(function(t){e()})},function(t){e()})})}function l(e){function t(){return i("/project/model").then(function(){return Promise.all(e.map(function(e){return o("/project/model/"+e.name,e)}))})}return r("/project/model").then(function(){return t()},function(e){return t()})}function u(e){return i("/project").then(function(){return o("/project/scene.json",new File([JSON.stringify(e)],"scene.json",{type:"application/json"}))})}function p(){return new Promise(function(e,t){if(!x)return void t(E);x.readFile("/project/scene.json","utf-8",function(t,n){if(t)e(null);else{var a=null;try{a=JSON.parse(n)}catch(e){console.error(e)}e(a)}})})}function d(){return m().then(function(e){return v(e)})}function f(e){return i("/project/model").then(function(){return o("/project/model/"+e.name,e)})}function h(){return r("/project")}function m(){return s("/project/model").then(function(e){return Promise.all(e.map(function(e){return new Promise(function(t,n){x.readFile("/project/model/"+e,function(i,r){i?n(i):t(new File([r],e,{type:b.a.lookup(a(e))}))})})}))})}function v(e){return new Promise(function(t,n){function a(n,a,o){function s(t){var n=0;e.forEach(function(e){e!==i&&(n++,l[e.name]=URL.createObjectURL(e))}),t&&t(l)}e=e.filter(function(e){return e.name.match(/.(gltf|bin|glb)$/)||e.type.match(/image/)});for(var c in w)URL.revokeObjectURL(w[c]);var l={};w=l,a?s(function(i){e.push(new File([a],n+".gltf",{type:"application/json"}),new File([o],n+".bin",{type:"application/octet-stream"})),t({glTF:JSON.parse(a),filesMap:i,buffers:[o],allFiles:e})}):r?FileAPI.readAsArrayBuffer(r,function(n){"load"===n.type&&s(function(a){t({glTF:n.result,filesMap:a,allFiles:e})})}):i&&FileAPI.readAsText(i,"utf-8",function(n){if("load"===n.type){var a;try{a=JSON.parse(n.result)}catch(e){return void t(null)}s(function(n){t({glTF:a,filesMap:n,allFiles:e})})}})}var i=e.find(function(e){return e.name.endsWith(".gltf")}),r=e.find(function(e){return e.name.endsWith(".glb")});if(i||r)a();else{n("No glTF file found")}})}function _(e,t,n){Promise.all([m(),p()]).then(function(a){var i,r=a[0],o=a[1],s=new JSZip,c={};if(r=(r||[]).filter(function(e){if(!e.name.endsWith(".gltf"))return c[e.name]=e,!0;i=e}),!i)return swal("No glTF file in project!"),void(n&&n());Promise.all(o.materials.map(function(e,t){if(e.metalnessMap||e.roughnessMap){var n=c[e.metalnessMap],a=c[e.roughnessMap];return new Promise(function(i){Object(g.b)(n,a,e.metalness,e.roughness).then(function(n){var a=e.name+"$"+t+"_metallicRoughness.png",r=n.toDataURL();r=r.slice("data:image/png;base64,".length),s.file(a,r,{base64:!0}),e.metalnessMap=e.roughnessMap=a,console.log("Merged %s, %s to %s",e.metalnessMap,e.roughnessMap,a),i()})})}if(e.specularMap||e.glossinessMap){var i=c[e.specularMap],r=c[e.glossinessMap];return new Promise(function(n){Object(g.c)(i,r,e.specularColor,e.glossiness).then(function(a){var i=e.name+"$"+t+"_specularGlossiness.png",r=a.toDataURL();r=r.slice("data:image/png;base64,".length),s.file(i,r,{base64:!0}),e.specularMap=e.glossinessMap=i,console.log("Merged %s, %s to %s",e.specularMap,e.glossinessMap,i),n()})})}return null}).filter(function(e){return null!=e})).then(function(){FileAPI.readAsText(i,"utf-8",function(a){if("load"==a.type){var c=Object(g.d)(JSON.parse(a.result),o);if(c.extensionsUsed=c.extensionsUsed||[],c.extensionsUsed.indexOf("KHR_materials_pbrSpecularGlossiness")<0&&c.extensionsUsed.push("KHR_materials_pbrSpecularGlossiness"),["extensionsUsed","images","textures","samplers","animations"].forEach(function(e){c[e]&&!c[e].length&&delete c[e]}),c.textures||delete c.samplers,r=r.filter(function(e){return e.type.match(/image/)?c.images&&c.images.some(function(t){return t.uri===e.name}):!!e.name.endsWith(".bin")||void 0}),r.forEach(function(e){s.file(e.name,e)}),"glb"===e){var l=[],u=[];s.forEach(function(e,t){(e.endsWith(".bin")?l:u).push({reader:s.file(e).async("arraybuffer"),name:e})}),Promise.all([Promise.all(l.map(function(e){return e.reader})),Promise.all(u.map(function(e){return e.reader}))]).then(function(e){var n=Object(g.a)(c,e[0],e[1].reduce(function(e,t,n){return e[u[n].name]=t,e},{}));saveAs(new Blob([n],{type:"model/json-binary"}),"model.glb"),t&&t()}).catch(n)}else s.file(i.name,JSON.stringify(c,null,2)),s.generateAsync({type:"blob"}).then(function(e){saveAs(e,"model.zip"),t&&t()}).catch(n)}})})}).catch(function(e){swal(e.toString()),n&&n()})}n.d(t,"c",function(){return c}),n.d(t,"e",function(){return l}),n.d(t,"a",function(){return v}),n.d(t,"f",function(){return u}),n.d(t,"g",function(){return f}),n.d(t,"d",function(){return h}),n.d(t,"b",function(){return _});var x,g=(n(37),n(143)),y=(n(144),n(145)),b=n.n(y),T=BrowserFS.BFSRequire("buffer").Buffer,E="File system not prepared yet.",w={}},function(e,t,n){"use strict";function a(e,t){return new Promise(function(t,n){Promise.all(e.map(function(e){var t=e&&URL.createObjectURL(e);return new Promise(function(e,n){if(t){var a=new Image;a.src=t,a.onload=function(){e(a)}}else e(null)})})).then(function(e){var n=e.find(function(e){return null!=e});n||t(null);var a=document.createElement("canvas"),i=a.getContext("2d"),r=a.width=n.width,o=a.height=n.height,s=e.map(function(e){return e?(i.drawImage(e,0,0,r,o),i.getImageData(0,0,r,o).data):null});t({canvas:a,imageDataList:s})})})}function i(e,t,n,i){return new Promise(function(r,o){a([e,t]).then(function(e){for(var t=e.canvas,a=t.getContext("2d"),o=e.imageDataList[0],s=e.imageDataList[1],c=a.createImageData(t.width,t.height),l=0;l<(o||s).length;l+=4){var u=n;if(o){var p=o[l+2]/255;u=Math.min(Math.max(p+2*(u-.5),0),1)}var d=i;if(s){var f=s[l+1]/255;d=Math.min(Math.max(f+2*(d-.5),0),1)}c.data[l]=c.data[l+3]=0,c.data[l+1]=Math.round(255*d),c.data[l+2]=Math.round(255*u)}a.putImageData(c,0,0),r(t)})})}function r(e,t,n,i){return n=d.a.parseColor(n).slice(0,3),new Promise(function(r,o){a([e,t]).then(function(e){for(var t=e.canvas,a=t.getContext("2d"),o=e.imageDataList[0],s=e.imageDataList[1],c=a.createImageData(t.width,t.height),l=0;l<(o||s).length;l+=4){var u=n.slice();o&&(u[0]*=o[l]/255,u[1]*=o[l+1]/255,u[2]*=o[l+2]/255);var p=i;if(s){var d=s[l+3]/255;p=Math.min(Math.max(d+2*(p-.5),0),1)}for(var f=0;f<3;f++)c.data[l+f]=Math.round(255*u[f]);c.data[l+3]=Math.round(255*p)}a.putImageData(c,0,0),r(t)})})}function o(e,t){var n={},a=0;return e.images=[],e.textures=[],e.samplers=[{minFilter:h.a.LINEAR_MIPMAP_LINEAR,magFilter:h.a.LINEAR,wrapS:h.a.REPEAT,wrapT:h.a.REPEAT}],t.materials.forEach(function(t,i){m.forEach(function(i){t[i]&&!n.hasOwnProperty(i)&&(e.images.push({uri:t[i]}),e.textures.push({sampler:0,source:a}),n[t[i]]=a++)})}),n}function s(e,t){var n={baseColorFactor:d.a.parseColor(e.color),metallicFactor:e.metalness,roughnessFactor:e.roughness};return n.baseColorFactor[3]=e.alpha,e.diffuseMap&&(n.baseColorTexture={index:t[e.diffuseMap],texCoord:0}),e.metalnessMap&&(n.metallicRoughnessTexture={index:t[e.metalnessMap],texCoord:0},n.metallicFactor=1,n.roughnessFactor=1),n}function c(e,t){var n={diffuseFactor:d.a.parseColor(e.color),specularFactor:d.a.parseColor(e.specularColor).slice(0,3),glossinessFactor:e.glossiness};return n.diffuseFactor[3]=e.alpha,e.diffuseMap&&(n.diffuseTexture={index:t[e.diffuseMap],texCoord:0}),e.specularMap&&(n.specularGlossinessTexture={index:t[e.specularMap],texCoord:0},n.specularFactor=[1,1,1],n.glossinessFactor=1),n}function l(e,t){if(e.materials){var n=o(e,t),a={};return e.materials=[],e.nodes.forEach(function(t,n){if(null!=t.mesh){var i=e.meshes[t.mesh];1===i.primitives.length?a[t.name]=i.primitives[0]:i.primitives.forEach(function(n,i){a[f.a.generateMeshName(e.meshes,t.mesh,i)]=n})}}),t.materials.forEach(function(t,i){var r={name:t.name,emissiveFactor:d.a.parseColor(t.emission).slice(0,3).map(function(e){return e*t.emissionIntensity})};t.normalMap&&(r.normalTexture={texCoord:0,scale:1,index:n[t.normalMap]}),t.emissiveMap&&(r.emissiveTexture={texCoord:0,index:n[t.emissiveMap]}),"pbrMetallicRoughness"===t.type?r.pbrMetallicRoughness=s(t,n):r.extensions={KHR_materials_pbrSpecularGlossiness:c(t,n)},t.targetMeshes.forEach(function(e){a[e].material=i}),e.materials[i]=r}),e.extras=e.extras||{},e.extras.qtekModelViewerConfig=t,e}}function u(e,t,n){function a(e){return 4*Math.ceil(e/4)}var i=0,r=[],o=t.slice();e.buffers.forEach(function(e){r.push(i),i+=a(e.byteLength),delete e.uri}),e.bufferViews.forEach(function(e){null==e.byteOffset?e.byteOffset=0:e.byteOffset=e.byteOffset+r[e.buffer]}),(e.images||[]).forEach(function(t,s){var c=t.uri,l=n[c];if(delete t.uri,l){var u={buffer:0,byteOffset:i,byteLength:l.byteLength};r.push(i),i+=a(l.byteLength),t.bufferView=e.bufferViews.length,t.mimeType=p(c),e.bufferViews.push(u),o.push(l)}});var s=i;e.buffers=[{byteLength:s}];var c,l=new TextEncoder,u=l.encode(JSON.stringify(e)),d=a(u.length);d!==u.length&&(c=d-u.length);var f=20+d+8+s,h=new ArrayBuffer(f),m=new DataView(h),v=0;m.setUint32(v,1179937895,!0),v+=4,m.setUint32(v,2,!0),v+=4,m.setUint32(v,f,!0),v+=4,m.setUint32(v,d,!0),v+=4,m.setUint32(v,1313821514,!0),v+=4;for(var _=0;_u||l===u&&"application/"===t[c].substr(0,12)))continue}t[c]=a}}})}(t.extensions,t.types)},function(e,t,n){/*! +var s=n(146),c=n(148).extname,l=/^\s*([^;\s]*)(?:;|\s|$)/,u=/^text\//i;t.charset=a,t.charsets={lookup:a},t.contentType=i,t.extension=r,t.extensions=Object.create(null),t.lookup=o,t.types=Object.create(null),function(e,t){var n=["nginx","apache",void 0,"iana"];Object.keys(s).forEach(function(a){var i=s[a],r=i.extensions;if(r&&r.length){e[a]=r;for(var o=0;ou||l===u&&"application/"===t[c].substr(0,12)))continue}t[c]=a}}})}(t.extensions,t.types)},function(e,t,n){/*! * mime-db * Copyright(c) 2014 Jonathan Ong * MIT Licensed */ -e.exports=n(148)},function(e,t){e.exports={"application/1d-interleaved-parityfec":{source:"iana"},"application/3gpdash-qoe-report+xml":{source:"iana"},"application/3gpp-ims+xml":{source:"iana"},"application/a2l":{source:"iana"},"application/activemessage":{source:"iana"},"application/alto-costmap+json":{source:"iana",compressible:!0},"application/alto-costmapfilter+json":{source:"iana",compressible:!0},"application/alto-directory+json":{source:"iana",compressible:!0},"application/alto-endpointcost+json":{source:"iana",compressible:!0},"application/alto-endpointcostparams+json":{source:"iana",compressible:!0},"application/alto-endpointprop+json":{source:"iana",compressible:!0},"application/alto-endpointpropparams+json":{source:"iana",compressible:!0},"application/alto-error+json":{source:"iana",compressible:!0},"application/alto-networkmap+json":{source:"iana",compressible:!0},"application/alto-networkmapfilter+json":{source:"iana",compressible:!0},"application/aml":{source:"iana"},"application/andrew-inset":{source:"iana",extensions:["ez"]},"application/applefile":{source:"iana"},"application/applixware":{source:"apache",extensions:["aw"]},"application/atf":{source:"iana"},"application/atfx":{source:"iana"},"application/atom+xml":{source:"iana",compressible:!0,extensions:["atom"]},"application/atomcat+xml":{source:"iana",extensions:["atomcat"]},"application/atomdeleted+xml":{source:"iana"},"application/atomicmail":{source:"iana"},"application/atomsvc+xml":{source:"iana",extensions:["atomsvc"]},"application/atxml":{source:"iana"},"application/auth-policy+xml":{source:"iana"},"application/bacnet-xdd+zip":{source:"iana"},"application/batch-smtp":{source:"iana"},"application/bdoc":{compressible:!1,extensions:["bdoc"]},"application/beep+xml":{source:"iana"},"application/calendar+json":{source:"iana",compressible:!0},"application/calendar+xml":{source:"iana"},"application/call-completion":{source:"iana"},"application/cals-1840":{source:"iana"},"application/cbor":{source:"iana"},"application/cccex":{source:"iana"},"application/ccmp+xml":{source:"iana"},"application/ccxml+xml":{source:"iana",extensions:["ccxml"]},"application/cdfx+xml":{source:"iana"},"application/cdmi-capability":{source:"iana",extensions:["cdmia"]},"application/cdmi-container":{source:"iana",extensions:["cdmic"]},"application/cdmi-domain":{source:"iana",extensions:["cdmid"]},"application/cdmi-object":{source:"iana",extensions:["cdmio"]},"application/cdmi-queue":{source:"iana",extensions:["cdmiq"]},"application/cdni":{source:"iana"},"application/cea":{source:"iana"},"application/cea-2018+xml":{source:"iana"},"application/cellml+xml":{source:"iana"},"application/cfw":{source:"iana"},"application/clue_info+xml":{source:"iana"},"application/cms":{source:"iana"},"application/cnrp+xml":{source:"iana"},"application/coap-group+json":{source:"iana",compressible:!0},"application/coap-payload":{source:"iana"},"application/commonground":{source:"iana"},"application/conference-info+xml":{source:"iana"},"application/cose":{source:"iana"},"application/cose-key":{source:"iana"},"application/cose-key-set":{source:"iana"},"application/cpl+xml":{source:"iana"},"application/csrattrs":{source:"iana"},"application/csta+xml":{source:"iana"},"application/cstadata+xml":{source:"iana"},"application/csvm+json":{source:"iana",compressible:!0},"application/cu-seeme":{source:"apache",extensions:["cu"]},"application/cybercash":{source:"iana"},"application/dart":{compressible:!0},"application/dash+xml":{source:"iana",extensions:["mpd"]},"application/dashdelta":{source:"iana"},"application/davmount+xml":{source:"iana",extensions:["davmount"]},"application/dca-rft":{source:"iana"},"application/dcd":{source:"iana"},"application/dec-dx":{source:"iana"},"application/dialog-info+xml":{source:"iana"},"application/dicom":{source:"iana"},"application/dicom+json":{source:"iana",compressible:!0},"application/dicom+xml":{source:"iana"},"application/dii":{source:"iana"},"application/dit":{source:"iana"},"application/dns":{source:"iana"},"application/docbook+xml":{source:"apache",extensions:["dbk"]},"application/dskpp+xml":{source:"iana"},"application/dssc+der":{source:"iana",extensions:["dssc"]},"application/dssc+xml":{source:"iana",extensions:["xdssc"]},"application/dvcs":{source:"iana"},"application/ecmascript":{source:"iana",compressible:!0,extensions:["ecma"]},"application/edi-consent":{source:"iana"},"application/edi-x12":{source:"iana",compressible:!1},"application/edifact":{source:"iana",compressible:!1},"application/efi":{source:"iana"},"application/emergencycalldata.comment+xml":{source:"iana"},"application/emergencycalldata.control+xml":{source:"iana"},"application/emergencycalldata.deviceinfo+xml":{source:"iana"},"application/emergencycalldata.ecall.msd":{source:"iana"},"application/emergencycalldata.providerinfo+xml":{source:"iana"},"application/emergencycalldata.serviceinfo+xml":{source:"iana"},"application/emergencycalldata.subscriberinfo+xml":{source:"iana"},"application/emergencycalldata.veds+xml":{source:"iana"},"application/emma+xml":{source:"iana",extensions:["emma"]},"application/emotionml+xml":{source:"iana"},"application/encaprtp":{source:"iana"},"application/epp+xml":{source:"iana"},"application/epub+zip":{source:"iana",extensions:["epub"]},"application/eshop":{source:"iana"},"application/exi":{source:"iana",extensions:["exi"]},"application/fastinfoset":{source:"iana"},"application/fastsoap":{source:"iana"},"application/fdt+xml":{source:"iana"},"application/fido.trusted-apps+json":{compressible:!0},"application/fits":{source:"iana"},"application/font-sfnt":{source:"iana"},"application/font-tdpfr":{source:"iana",extensions:["pfr"]},"application/font-woff":{source:"iana",compressible:!1,extensions:["woff"]},"application/font-woff2":{compressible:!1,extensions:["woff2"]},"application/framework-attributes+xml":{source:"iana"},"application/geo+json":{source:"iana",compressible:!0,extensions:["geojson"]},"application/geo+json-seq":{source:"iana"},"application/geoxacml+xml":{source:"iana"},"application/gml+xml":{source:"iana",extensions:["gml"]},"application/gpx+xml":{source:"apache",extensions:["gpx"]},"application/gxf":{source:"apache",extensions:["gxf"]},"application/gzip":{source:"iana",compressible:!1,extensions:["gz"]},"application/h224":{source:"iana"},"application/held+xml":{source:"iana"},"application/http":{source:"iana"},"application/hyperstudio":{source:"iana",extensions:["stk"]},"application/ibe-key-request+xml":{source:"iana"},"application/ibe-pkg-reply+xml":{source:"iana"},"application/ibe-pp-data":{source:"iana"},"application/iges":{source:"iana"},"application/im-iscomposing+xml":{source:"iana"},"application/index":{source:"iana"},"application/index.cmd":{source:"iana"},"application/index.obj":{source:"iana"},"application/index.response":{source:"iana"},"application/index.vnd":{source:"iana"},"application/inkml+xml":{source:"iana",extensions:["ink","inkml"]},"application/iotp":{source:"iana"},"application/ipfix":{source:"iana",extensions:["ipfix"]},"application/ipp":{source:"iana"},"application/isup":{source:"iana"},"application/its+xml":{source:"iana"},"application/java-archive":{source:"apache",compressible:!1,extensions:["jar","war","ear"]},"application/java-serialized-object":{source:"apache",compressible:!1,extensions:["ser"]},"application/java-vm":{source:"apache",compressible:!1,extensions:["class"]},"application/javascript":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["js","mjs"]},"application/jf2feed+json":{source:"iana",compressible:!0},"application/jose":{source:"iana"},"application/jose+json":{source:"iana",compressible:!0},"application/jrd+json":{source:"iana",compressible:!0},"application/json":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["json","map"]},"application/json-patch+json":{source:"iana",compressible:!0},"application/json-seq":{source:"iana"},"application/json5":{extensions:["json5"]},"application/jsonml+json":{source:"apache",compressible:!0,extensions:["jsonml"]},"application/jwk+json":{source:"iana",compressible:!0},"application/jwk-set+json":{source:"iana",compressible:!0},"application/jwt":{source:"iana"},"application/kpml-request+xml":{source:"iana"},"application/kpml-response+xml":{source:"iana"},"application/ld+json":{source:"iana",compressible:!0,extensions:["jsonld"]},"application/lgr+xml":{source:"iana"},"application/link-format":{source:"iana"},"application/load-control+xml":{source:"iana"},"application/lost+xml":{source:"iana",extensions:["lostxml"]},"application/lostsync+xml":{source:"iana"},"application/lxf":{source:"iana"},"application/mac-binhex40":{source:"iana",extensions:["hqx"]},"application/mac-compactpro":{source:"apache",extensions:["cpt"]},"application/macwriteii":{source:"iana"},"application/mads+xml":{source:"iana",extensions:["mads"]},"application/manifest+json":{charset:"UTF-8",compressible:!0,extensions:["webmanifest"]},"application/marc":{source:"iana",extensions:["mrc"]},"application/marcxml+xml":{source:"iana",extensions:["mrcx"]},"application/mathematica":{source:"iana",extensions:["ma","nb","mb"]},"application/mathml+xml":{source:"iana",extensions:["mathml"]},"application/mathml-content+xml":{source:"iana"},"application/mathml-presentation+xml":{source:"iana"},"application/mbms-associated-procedure-description+xml":{source:"iana"},"application/mbms-deregister+xml":{source:"iana"},"application/mbms-envelope+xml":{source:"iana"},"application/mbms-msk+xml":{source:"iana"},"application/mbms-msk-response+xml":{source:"iana"},"application/mbms-protection-description+xml":{source:"iana"},"application/mbms-reception-report+xml":{source:"iana"},"application/mbms-register+xml":{source:"iana"},"application/mbms-register-response+xml":{source:"iana"},"application/mbms-schedule+xml":{source:"iana"},"application/mbms-user-service-description+xml":{source:"iana"},"application/mbox":{source:"iana",extensions:["mbox"]},"application/media-policy-dataset+xml":{source:"iana"},"application/media_control+xml":{source:"iana"},"application/mediaservercontrol+xml":{source:"iana",extensions:["mscml"]},"application/merge-patch+json":{source:"iana",compressible:!0},"application/metalink+xml":{source:"apache",extensions:["metalink"]},"application/metalink4+xml":{source:"iana",extensions:["meta4"]},"application/mets+xml":{source:"iana",extensions:["mets"]},"application/mf4":{source:"iana"},"application/mikey":{source:"iana"},"application/mmt-usd+xml":{source:"iana"},"application/mods+xml":{source:"iana",extensions:["mods"]},"application/moss-keys":{source:"iana"},"application/moss-signature":{source:"iana"},"application/mosskey-data":{source:"iana"},"application/mosskey-request":{source:"iana"},"application/mp21":{source:"iana",extensions:["m21","mp21"]},"application/mp4":{source:"iana",extensions:["mp4s","m4p"]},"application/mpeg4-generic":{source:"iana"},"application/mpeg4-iod":{source:"iana"},"application/mpeg4-iod-xmt":{source:"iana"},"application/mrb-consumer+xml":{source:"iana"},"application/mrb-publish+xml":{source:"iana"},"application/msc-ivr+xml":{source:"iana"},"application/msc-mixer+xml":{source:"iana"},"application/msword":{source:"iana",compressible:!1,extensions:["doc","dot"]},"application/mud+json":{source:"iana",compressible:!0},"application/mxf":{source:"iana",extensions:["mxf"]},"application/n-quads":{source:"iana"},"application/n-triples":{source:"iana"},"application/nasdata":{source:"iana"},"application/news-checkgroups":{source:"iana"},"application/news-groupinfo":{source:"iana"},"application/news-transmission":{source:"iana"},"application/nlsml+xml":{source:"iana"},"application/nss":{source:"iana"},"application/ocsp-request":{source:"iana"},"application/ocsp-response":{source:"iana"},"application/octet-stream":{source:"iana",compressible:!1,extensions:["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"]},"application/oda":{source:"iana",extensions:["oda"]},"application/odx":{source:"iana"},"application/oebps-package+xml":{source:"iana",extensions:["opf"]},"application/ogg":{source:"iana",compressible:!1,extensions:["ogx"]},"application/omdoc+xml":{source:"apache",extensions:["omdoc"]},"application/onenote":{source:"apache",extensions:["onetoc","onetoc2","onetmp","onepkg"]},"application/oxps":{source:"iana",extensions:["oxps"]},"application/p2p-overlay+xml":{source:"iana"},"application/parityfec":{source:"iana"},"application/passport":{source:"iana"},"application/patch-ops-error+xml":{source:"iana",extensions:["xer"]},"application/pdf":{source:"iana",compressible:!1,extensions:["pdf"]},"application/pdx":{source:"iana"},"application/pgp-encrypted":{source:"iana",compressible:!1,extensions:["pgp"]},"application/pgp-keys":{source:"iana"},"application/pgp-signature":{source:"iana",extensions:["asc","sig"]},"application/pics-rules":{source:"apache",extensions:["prf"]},"application/pidf+xml":{source:"iana"},"application/pidf-diff+xml":{source:"iana"},"application/pkcs10":{source:"iana",extensions:["p10"]},"application/pkcs12":{source:"iana"},"application/pkcs7-mime":{source:"iana",extensions:["p7m","p7c"]},"application/pkcs7-signature":{source:"iana",extensions:["p7s"]},"application/pkcs8":{source:"iana",extensions:["p8"]},"application/pkix-attr-cert":{source:"iana",extensions:["ac"]},"application/pkix-cert":{source:"iana",extensions:["cer"]},"application/pkix-crl":{source:"iana",extensions:["crl"]},"application/pkix-pkipath":{source:"iana",extensions:["pkipath"]},"application/pkixcmp":{source:"iana",extensions:["pki"]},"application/pls+xml":{source:"iana",extensions:["pls"]},"application/poc-settings+xml":{source:"iana"},"application/postscript":{source:"iana",compressible:!0,extensions:["ai","eps","ps"]},"application/ppsp-tracker+json":{source:"iana",compressible:!0},"application/problem+json":{source:"iana",compressible:!0},"application/problem+xml":{source:"iana"},"application/provenance+xml":{source:"iana"},"application/prs.alvestrand.titrax-sheet":{source:"iana"},"application/prs.cww":{source:"iana",extensions:["cww"]},"application/prs.hpub+zip":{source:"iana"},"application/prs.nprend":{source:"iana"},"application/prs.plucker":{source:"iana"},"application/prs.rdf-xml-crypt":{source:"iana"},"application/prs.xsf+xml":{source:"iana"},"application/pskc+xml":{source:"iana",extensions:["pskcxml"]},"application/qsig":{source:"iana"},"application/raptorfec":{source:"iana"},"application/rdap+json":{source:"iana",compressible:!0},"application/rdf+xml":{source:"iana",compressible:!0,extensions:["rdf"]},"application/reginfo+xml":{source:"iana",extensions:["rif"]},"application/relax-ng-compact-syntax":{source:"iana",extensions:["rnc"]},"application/remote-printing":{source:"iana"},"application/reputon+json":{source:"iana",compressible:!0},"application/resource-lists+xml":{source:"iana",extensions:["rl"]},"application/resource-lists-diff+xml":{source:"iana",extensions:["rld"]},"application/rfc+xml":{source:"iana"},"application/riscos":{source:"iana"},"application/rlmi+xml":{source:"iana"},"application/rls-services+xml":{source:"iana",extensions:["rs"]},"application/route-apd+xml":{source:"iana"},"application/route-s-tsid+xml":{source:"iana"},"application/route-usd+xml":{source:"iana"},"application/rpki-ghostbusters":{source:"iana",extensions:["gbr"]},"application/rpki-manifest":{source:"iana",extensions:["mft"]},"application/rpki-publication":{source:"iana"},"application/rpki-roa":{source:"iana",extensions:["roa"]},"application/rpki-updown":{source:"iana"},"application/rsd+xml":{source:"apache",extensions:["rsd"]},"application/rss+xml":{source:"apache",compressible:!0,extensions:["rss"]},"application/rtf":{source:"iana",compressible:!0,extensions:["rtf"]},"application/rtploopback":{source:"iana"},"application/rtx":{source:"iana"},"application/samlassertion+xml":{source:"iana"},"application/samlmetadata+xml":{source:"iana"},"application/sbml+xml":{source:"iana",extensions:["sbml"]},"application/scaip+xml":{source:"iana"},"application/scim+json":{source:"iana",compressible:!0},"application/scvp-cv-request":{source:"iana",extensions:["scq"]},"application/scvp-cv-response":{source:"iana",extensions:["scs"]},"application/scvp-vp-request":{source:"iana",extensions:["spq"]},"application/scvp-vp-response":{source:"iana",extensions:["spp"]},"application/sdp":{source:"iana",extensions:["sdp"]},"application/sep+xml":{source:"iana"},"application/sep-exi":{source:"iana"},"application/session-info":{source:"iana"},"application/set-payment":{source:"iana"},"application/set-payment-initiation":{source:"iana",extensions:["setpay"]},"application/set-registration":{source:"iana"},"application/set-registration-initiation":{source:"iana",extensions:["setreg"]},"application/sgml":{source:"iana"},"application/sgml-open-catalog":{source:"iana"},"application/shf+xml":{source:"iana",extensions:["shf"]},"application/sieve":{source:"iana"},"application/simple-filter+xml":{source:"iana"},"application/simple-message-summary":{source:"iana"},"application/simplesymbolcontainer":{source:"iana"},"application/slate":{source:"iana"},"application/smil":{source:"iana"},"application/smil+xml":{source:"iana",extensions:["smi","smil"]},"application/smpte336m":{source:"iana"},"application/soap+fastinfoset":{source:"iana"},"application/soap+xml":{source:"iana",compressible:!0},"application/sparql-query":{source:"iana",extensions:["rq"]},"application/sparql-results+xml":{source:"iana",extensions:["srx"]},"application/spirits-event+xml":{source:"iana"},"application/sql":{source:"iana"},"application/srgs":{source:"iana",extensions:["gram"]},"application/srgs+xml":{source:"iana",extensions:["grxml"]},"application/sru+xml":{source:"iana",extensions:["sru"]},"application/ssdl+xml":{source:"apache",extensions:["ssdl"]},"application/ssml+xml":{source:"iana",extensions:["ssml"]},"application/tamp-apex-update":{source:"iana"},"application/tamp-apex-update-confirm":{source:"iana"},"application/tamp-community-update":{source:"iana"},"application/tamp-community-update-confirm":{source:"iana"},"application/tamp-error":{source:"iana"},"application/tamp-sequence-adjust":{source:"iana"},"application/tamp-sequence-adjust-confirm":{source:"iana"},"application/tamp-status-query":{source:"iana"},"application/tamp-status-response":{source:"iana"},"application/tamp-update":{source:"iana"},"application/tamp-update-confirm":{source:"iana"},"application/tar":{compressible:!0},"application/tei+xml":{source:"iana",extensions:["tei","teicorpus"]},"application/thraud+xml":{source:"iana",extensions:["tfi"]},"application/timestamp-query":{source:"iana"},"application/timestamp-reply":{source:"iana"},"application/timestamped-data":{source:"iana",extensions:["tsd"]},"application/trig":{source:"iana"},"application/ttml+xml":{source:"iana"},"application/tve-trigger":{source:"iana"},"application/ulpfec":{source:"iana"},"application/urc-grpsheet+xml":{source:"iana"},"application/urc-ressheet+xml":{source:"iana"},"application/urc-targetdesc+xml":{source:"iana"},"application/urc-uisocketdesc+xml":{source:"iana"},"application/vcard+json":{source:"iana",compressible:!0},"application/vcard+xml":{source:"iana"},"application/vemmi":{source:"iana"},"application/vividence.scriptfile":{source:"apache"},"application/vnd.1000minds.decision-model+xml":{source:"iana"},"application/vnd.3gpp-prose+xml":{source:"iana"},"application/vnd.3gpp-prose-pc3ch+xml":{source:"iana"},"application/vnd.3gpp.access-transfer-events+xml":{source:"iana"},"application/vnd.3gpp.bsf+xml":{source:"iana"},"application/vnd.3gpp.gmop+xml":{source:"iana"},"application/vnd.3gpp.mcptt-info+xml":{source:"iana"},"application/vnd.3gpp.mcptt-mbms-usage-info+xml":{source:"iana"},"application/vnd.3gpp.mid-call+xml":{source:"iana"},"application/vnd.3gpp.pic-bw-large":{source:"iana",extensions:["plb"]},"application/vnd.3gpp.pic-bw-small":{source:"iana",extensions:["psb"]},"application/vnd.3gpp.pic-bw-var":{source:"iana",extensions:["pvb"]},"application/vnd.3gpp.sms":{source:"iana"},"application/vnd.3gpp.sms+xml":{source:"iana"},"application/vnd.3gpp.srvcc-ext+xml":{source:"iana"},"application/vnd.3gpp.srvcc-info+xml":{source:"iana"},"application/vnd.3gpp.state-and-event-info+xml":{source:"iana"},"application/vnd.3gpp.ussd+xml":{source:"iana"},"application/vnd.3gpp2.bcmcsinfo+xml":{source:"iana"},"application/vnd.3gpp2.sms":{source:"iana"},"application/vnd.3gpp2.tcap":{source:"iana",extensions:["tcap"]},"application/vnd.3lightssoftware.imagescal":{source:"iana"},"application/vnd.3m.post-it-notes":{source:"iana",extensions:["pwn"]},"application/vnd.accpac.simply.aso":{source:"iana",extensions:["aso"]},"application/vnd.accpac.simply.imp":{source:"iana",extensions:["imp"]},"application/vnd.acucobol":{source:"iana",extensions:["acu"]},"application/vnd.acucorp":{source:"iana",extensions:["atc","acutc"]},"application/vnd.adobe.air-application-installer-package+zip":{source:"apache",extensions:["air"]},"application/vnd.adobe.flash.movie":{source:"iana"},"application/vnd.adobe.formscentral.fcdt":{source:"iana",extensions:["fcdt"]},"application/vnd.adobe.fxp":{source:"iana",extensions:["fxp","fxpl"]},"application/vnd.adobe.partial-upload":{source:"iana"},"application/vnd.adobe.xdp+xml":{source:"iana",extensions:["xdp"]},"application/vnd.adobe.xfdf":{source:"iana",extensions:["xfdf"]},"application/vnd.aether.imp":{source:"iana"},"application/vnd.ah-barcode":{source:"iana"},"application/vnd.ahead.space":{source:"iana",extensions:["ahead"]},"application/vnd.airzip.filesecure.azf":{source:"iana",extensions:["azf"]},"application/vnd.airzip.filesecure.azs":{source:"iana",extensions:["azs"]},"application/vnd.amazon.ebook":{source:"apache",extensions:["azw"]},"application/vnd.amazon.mobi8-ebook":{source:"iana"},"application/vnd.americandynamics.acc":{source:"iana",extensions:["acc"]},"application/vnd.amiga.ami":{source:"iana",extensions:["ami"]},"application/vnd.amundsen.maze+xml":{source:"iana"},"application/vnd.android.package-archive":{source:"apache",compressible:!1,extensions:["apk"]},"application/vnd.anki":{source:"iana"},"application/vnd.anser-web-certificate-issue-initiation":{source:"iana",extensions:["cii"]},"application/vnd.anser-web-funds-transfer-initiation":{source:"apache",extensions:["fti"]},"application/vnd.antix.game-component":{source:"iana",extensions:["atx"]},"application/vnd.apache.thrift.binary":{source:"iana"},"application/vnd.apache.thrift.compact":{source:"iana"},"application/vnd.apache.thrift.json":{source:"iana"},"application/vnd.api+json":{source:"iana",compressible:!0},"application/vnd.apothekende.reservation+json":{source:"iana",compressible:!0},"application/vnd.apple.installer+xml":{source:"iana",extensions:["mpkg"]},"application/vnd.apple.mpegurl":{source:"iana",extensions:["m3u8"]},"application/vnd.apple.pkpass":{compressible:!1,extensions:["pkpass"]},"application/vnd.arastra.swi":{source:"iana"},"application/vnd.aristanetworks.swi":{source:"iana",extensions:["swi"]},"application/vnd.artsquare":{source:"iana"},"application/vnd.astraea-software.iota":{source:"iana",extensions:["iota"]},"application/vnd.audiograph":{source:"iana",extensions:["aep"]},"application/vnd.autopackage":{source:"iana"},"application/vnd.avistar+xml":{source:"iana"},"application/vnd.balsamiq.bmml+xml":{source:"iana"},"application/vnd.balsamiq.bmpr":{source:"iana"},"application/vnd.bekitzur-stech+json":{source:"iana",compressible:!0},"application/vnd.bint.med-content":{source:"iana"},"application/vnd.biopax.rdf+xml":{source:"iana"},"application/vnd.blink-idb-value-wrapper":{source:"iana"},"application/vnd.blueice.multipass":{source:"iana",extensions:["mpm"]},"application/vnd.bluetooth.ep.oob":{source:"iana"},"application/vnd.bluetooth.le.oob":{source:"iana"},"application/vnd.bmi":{source:"iana",extensions:["bmi"]},"application/vnd.businessobjects":{source:"iana",extensions:["rep"]},"application/vnd.cab-jscript":{source:"iana"},"application/vnd.canon-cpdl":{source:"iana"},"application/vnd.canon-lips":{source:"iana"},"application/vnd.capasystems-pg+json":{source:"iana",compressible:!0},"application/vnd.cendio.thinlinc.clientconf":{source:"iana"},"application/vnd.century-systems.tcp_stream":{source:"iana"},"application/vnd.chemdraw+xml":{source:"iana",extensions:["cdxml"]},"application/vnd.chess-pgn":{source:"iana"},"application/vnd.chipnuts.karaoke-mmd":{source:"iana",extensions:["mmd"]},"application/vnd.cinderella":{source:"iana",extensions:["cdy"]},"application/vnd.cirpack.isdn-ext":{source:"iana"},"application/vnd.citationstyles.style+xml":{source:"iana"},"application/vnd.claymore":{source:"iana",extensions:["cla"]},"application/vnd.cloanto.rp9":{source:"iana",extensions:["rp9"]},"application/vnd.clonk.c4group":{source:"iana",extensions:["c4g","c4d","c4f","c4p","c4u"]},"application/vnd.cluetrust.cartomobile-config":{source:"iana",extensions:["c11amc"]},"application/vnd.cluetrust.cartomobile-config-pkg":{source:"iana",extensions:["c11amz"]},"application/vnd.coffeescript":{source:"iana"},"application/vnd.collection+json":{source:"iana",compressible:!0},"application/vnd.collection.doc+json":{source:"iana",compressible:!0},"application/vnd.collection.next+json":{source:"iana",compressible:!0},"application/vnd.comicbook+zip":{source:"iana"},"application/vnd.commerce-battelle":{source:"iana"},"application/vnd.commonspace":{source:"iana",extensions:["csp"]},"application/vnd.contact.cmsg":{source:"iana",extensions:["cdbcmsg"]},"application/vnd.coreos.ignition+json":{source:"iana",compressible:!0},"application/vnd.cosmocaller":{source:"iana",extensions:["cmc"]},"application/vnd.crick.clicker":{source:"iana",extensions:["clkx"]},"application/vnd.crick.clicker.keyboard":{source:"iana",extensions:["clkk"]},"application/vnd.crick.clicker.palette":{source:"iana",extensions:["clkp"]},"application/vnd.crick.clicker.template":{source:"iana",extensions:["clkt"]},"application/vnd.crick.clicker.wordbank":{source:"iana",extensions:["clkw"]},"application/vnd.criticaltools.wbs+xml":{source:"iana",extensions:["wbs"]},"application/vnd.ctc-posml":{source:"iana",extensions:["pml"]},"application/vnd.ctct.ws+xml":{source:"iana"},"application/vnd.cups-pdf":{source:"iana"},"application/vnd.cups-postscript":{source:"iana"},"application/vnd.cups-ppd":{source:"iana",extensions:["ppd"]},"application/vnd.cups-raster":{source:"iana"},"application/vnd.cups-raw":{source:"iana"},"application/vnd.curl":{source:"iana"},"application/vnd.curl.car":{source:"apache",extensions:["car"]},"application/vnd.curl.pcurl":{source:"apache",extensions:["pcurl"]},"application/vnd.cyan.dean.root+xml":{source:"iana"},"application/vnd.cybank":{source:"iana"},"application/vnd.d2l.coursepackage1p0+zip":{source:"iana"},"application/vnd.dart":{source:"iana",compressible:!0,extensions:["dart"]},"application/vnd.data-vision.rdz":{source:"iana",extensions:["rdz"]},"application/vnd.datapackage+json":{source:"iana",compressible:!0},"application/vnd.dataresource+json":{source:"iana",compressible:!0},"application/vnd.debian.binary-package":{source:"iana"},"application/vnd.dece.data":{source:"iana",extensions:["uvf","uvvf","uvd","uvvd"]},"application/vnd.dece.ttml+xml":{source:"iana",extensions:["uvt","uvvt"]},"application/vnd.dece.unspecified":{source:"iana",extensions:["uvx","uvvx"]},"application/vnd.dece.zip":{source:"iana",extensions:["uvz","uvvz"]},"application/vnd.denovo.fcselayout-link":{source:"iana",extensions:["fe_launch"]},"application/vnd.desmume-movie":{source:"iana"},"application/vnd.desmume.movie":{source:"apache"},"application/vnd.dir-bi.plate-dl-nosuffix":{source:"iana"},"application/vnd.dm.delegation+xml":{source:"iana"},"application/vnd.dna":{source:"iana",extensions:["dna"]},"application/vnd.document+json":{source:"iana",compressible:!0},"application/vnd.dolby.mlp":{source:"apache",extensions:["mlp"]},"application/vnd.dolby.mobile.1":{source:"iana"},"application/vnd.dolby.mobile.2":{source:"iana"},"application/vnd.doremir.scorecloud-binary-document":{source:"iana"},"application/vnd.dpgraph":{source:"iana",extensions:["dpg"]},"application/vnd.dreamfactory":{source:"iana",extensions:["dfac"]},"application/vnd.drive+json":{source:"iana",compressible:!0},"application/vnd.ds-keypoint":{source:"apache",extensions:["kpxx"]},"application/vnd.dtg.local":{source:"iana"},"application/vnd.dtg.local.flash":{source:"iana"},"application/vnd.dtg.local.html":{source:"iana"},"application/vnd.dvb.ait":{source:"iana",extensions:["ait"]},"application/vnd.dvb.dvbj":{source:"iana"},"application/vnd.dvb.esgcontainer":{source:"iana"},"application/vnd.dvb.ipdcdftnotifaccess":{source:"iana"},"application/vnd.dvb.ipdcesgaccess":{source:"iana"},"application/vnd.dvb.ipdcesgaccess2":{source:"iana"},"application/vnd.dvb.ipdcesgpdd":{source:"iana"},"application/vnd.dvb.ipdcroaming":{source:"iana"},"application/vnd.dvb.iptv.alfec-base":{source:"iana"},"application/vnd.dvb.iptv.alfec-enhancement":{source:"iana"},"application/vnd.dvb.notif-aggregate-root+xml":{source:"iana"},"application/vnd.dvb.notif-container+xml":{source:"iana"},"application/vnd.dvb.notif-generic+xml":{source:"iana"},"application/vnd.dvb.notif-ia-msglist+xml":{source:"iana"},"application/vnd.dvb.notif-ia-registration-request+xml":{source:"iana"},"application/vnd.dvb.notif-ia-registration-response+xml":{source:"iana"},"application/vnd.dvb.notif-init+xml":{source:"iana"},"application/vnd.dvb.pfr":{source:"iana"},"application/vnd.dvb.service":{source:"iana",extensions:["svc"]},"application/vnd.dxr":{source:"iana"},"application/vnd.dynageo":{source:"iana",extensions:["geo"]},"application/vnd.dzr":{source:"iana"},"application/vnd.easykaraoke.cdgdownload":{source:"iana"},"application/vnd.ecdis-update":{source:"iana"},"application/vnd.ecowin.chart":{source:"iana",extensions:["mag"]},"application/vnd.ecowin.filerequest":{source:"iana"},"application/vnd.ecowin.fileupdate":{source:"iana"},"application/vnd.ecowin.series":{source:"iana"},"application/vnd.ecowin.seriesrequest":{source:"iana"},"application/vnd.ecowin.seriesupdate":{source:"iana"},"application/vnd.efi.img":{source:"iana"},"application/vnd.efi.iso":{source:"iana"},"application/vnd.emclient.accessrequest+xml":{source:"iana"},"application/vnd.enliven":{source:"iana",extensions:["nml"]},"application/vnd.enphase.envoy":{source:"iana"},"application/vnd.eprints.data+xml":{source:"iana"},"application/vnd.epson.esf":{source:"iana",extensions:["esf"]},"application/vnd.epson.msf":{source:"iana",extensions:["msf"]},"application/vnd.epson.quickanime":{source:"iana",extensions:["qam"]},"application/vnd.epson.salt":{source:"iana",extensions:["slt"]},"application/vnd.epson.ssf":{source:"iana",extensions:["ssf"]},"application/vnd.ericsson.quickcall":{source:"iana"},"application/vnd.espass-espass+zip":{source:"iana"},"application/vnd.eszigno3+xml":{source:"iana",extensions:["es3","et3"]},"application/vnd.etsi.aoc+xml":{source:"iana"},"application/vnd.etsi.asic-e+zip":{source:"iana"},"application/vnd.etsi.asic-s+zip":{source:"iana"},"application/vnd.etsi.cug+xml":{source:"iana"},"application/vnd.etsi.iptvcommand+xml":{source:"iana"},"application/vnd.etsi.iptvdiscovery+xml":{source:"iana"},"application/vnd.etsi.iptvprofile+xml":{source:"iana"},"application/vnd.etsi.iptvsad-bc+xml":{source:"iana"},"application/vnd.etsi.iptvsad-cod+xml":{source:"iana"},"application/vnd.etsi.iptvsad-npvr+xml":{source:"iana"},"application/vnd.etsi.iptvservice+xml":{source:"iana"},"application/vnd.etsi.iptvsync+xml":{source:"iana"},"application/vnd.etsi.iptvueprofile+xml":{source:"iana"},"application/vnd.etsi.mcid+xml":{source:"iana"},"application/vnd.etsi.mheg5":{source:"iana"},"application/vnd.etsi.overload-control-policy-dataset+xml":{source:"iana"},"application/vnd.etsi.pstn+xml":{source:"iana"},"application/vnd.etsi.sci+xml":{source:"iana"},"application/vnd.etsi.simservs+xml":{source:"iana"},"application/vnd.etsi.timestamp-token":{source:"iana"},"application/vnd.etsi.tsl+xml":{source:"iana"},"application/vnd.etsi.tsl.der":{source:"iana"},"application/vnd.eudora.data":{source:"iana"},"application/vnd.evolv.ecig.profile":{source:"iana"},"application/vnd.evolv.ecig.settings":{source:"iana"},"application/vnd.evolv.ecig.theme":{source:"iana"},"application/vnd.ezpix-album":{source:"iana",extensions:["ez2"]},"application/vnd.ezpix-package":{source:"iana",extensions:["ez3"]},"application/vnd.f-secure.mobile":{source:"iana"},"application/vnd.fastcopy-disk-image":{source:"iana"},"application/vnd.fdf":{source:"iana",extensions:["fdf"]},"application/vnd.fdsn.mseed":{source:"iana",extensions:["mseed"]},"application/vnd.fdsn.seed":{source:"iana",extensions:["seed","dataless"]},"application/vnd.ffsns":{source:"iana"},"application/vnd.filmit.zfc":{source:"iana"},"application/vnd.fints":{source:"iana"},"application/vnd.firemonkeys.cloudcell":{source:"iana"},"application/vnd.flographit":{source:"iana",extensions:["gph"]},"application/vnd.fluxtime.clip":{source:"iana",extensions:["ftc"]},"application/vnd.font-fontforge-sfd":{source:"iana"},"application/vnd.framemaker":{source:"iana",extensions:["fm","frame","maker","book"]},"application/vnd.frogans.fnc":{source:"iana",extensions:["fnc"]},"application/vnd.frogans.ltf":{source:"iana",extensions:["ltf"]},"application/vnd.fsc.weblaunch":{source:"iana",extensions:["fsc"]},"application/vnd.fujitsu.oasys":{source:"iana",extensions:["oas"]},"application/vnd.fujitsu.oasys2":{source:"iana",extensions:["oa2"]},"application/vnd.fujitsu.oasys3":{source:"iana",extensions:["oa3"]},"application/vnd.fujitsu.oasysgp":{source:"iana",extensions:["fg5"]},"application/vnd.fujitsu.oasysprs":{source:"iana",extensions:["bh2"]},"application/vnd.fujixerox.art-ex":{source:"iana"},"application/vnd.fujixerox.art4":{source:"iana"},"application/vnd.fujixerox.ddd":{source:"iana",extensions:["ddd"]},"application/vnd.fujixerox.docuworks":{source:"iana",extensions:["xdw"]},"application/vnd.fujixerox.docuworks.binder":{source:"iana",extensions:["xbd"]},"application/vnd.fujixerox.docuworks.container":{source:"iana"},"application/vnd.fujixerox.hbpl":{source:"iana"},"application/vnd.fut-misnet":{source:"iana"},"application/vnd.fuzzysheet":{source:"iana",extensions:["fzs"]},"application/vnd.genomatix.tuxedo":{source:"iana",extensions:["txd"]},"application/vnd.geo+json":{source:"iana",compressible:!0},"application/vnd.geocube+xml":{source:"iana"},"application/vnd.geogebra.file":{source:"iana",extensions:["ggb"]},"application/vnd.geogebra.tool":{source:"iana",extensions:["ggt"]},"application/vnd.geometry-explorer":{source:"iana",extensions:["gex","gre"]},"application/vnd.geonext":{source:"iana",extensions:["gxt"]},"application/vnd.geoplan":{source:"iana",extensions:["g2w"]},"application/vnd.geospace":{source:"iana",extensions:["g3w"]},"application/vnd.gerber":{source:"iana"},"application/vnd.globalplatform.card-content-mgt":{source:"iana"},"application/vnd.globalplatform.card-content-mgt-response":{source:"iana"},"application/vnd.gmx":{source:"iana",extensions:["gmx"]},"application/vnd.google-apps.document":{compressible:!1,extensions:["gdoc"]},"application/vnd.google-apps.presentation":{compressible:!1,extensions:["gslides"]},"application/vnd.google-apps.spreadsheet":{compressible:!1,extensions:["gsheet"]},"application/vnd.google-earth.kml+xml":{source:"iana",compressible:!0,extensions:["kml"]},"application/vnd.google-earth.kmz":{source:"iana",compressible:!1,extensions:["kmz"]},"application/vnd.gov.sk.e-form+xml":{source:"iana"},"application/vnd.gov.sk.e-form+zip":{source:"iana"},"application/vnd.gov.sk.xmldatacontainer+xml":{source:"iana"},"application/vnd.grafeq":{source:"iana",extensions:["gqf","gqs"]},"application/vnd.gridmp":{source:"iana"},"application/vnd.groove-account":{source:"iana",extensions:["gac"]},"application/vnd.groove-help":{source:"iana",extensions:["ghf"]},"application/vnd.groove-identity-message":{source:"iana",extensions:["gim"]},"application/vnd.groove-injector":{source:"iana",extensions:["grv"]},"application/vnd.groove-tool-message":{source:"iana",extensions:["gtm"]},"application/vnd.groove-tool-template":{source:"iana",extensions:["tpl"]},"application/vnd.groove-vcard":{source:"iana",extensions:["vcg"]},"application/vnd.hal+json":{source:"iana",compressible:!0},"application/vnd.hal+xml":{source:"iana",extensions:["hal"]},"application/vnd.handheld-entertainment+xml":{source:"iana",extensions:["zmm"]},"application/vnd.hbci":{source:"iana",extensions:["hbci"]},"application/vnd.hc+json":{source:"iana",compressible:!0},"application/vnd.hcl-bireports":{source:"iana"},"application/vnd.hdt":{source:"iana"},"application/vnd.heroku+json":{source:"iana",compressible:!0},"application/vnd.hhe.lesson-player":{source:"iana",extensions:["les"]},"application/vnd.hp-hpgl":{source:"iana",extensions:["hpgl"]},"application/vnd.hp-hpid":{source:"iana",extensions:["hpid"]},"application/vnd.hp-hps":{source:"iana",extensions:["hps"]},"application/vnd.hp-jlyt":{source:"iana",extensions:["jlt"]},"application/vnd.hp-pcl":{source:"iana",extensions:["pcl"]},"application/vnd.hp-pclxl":{source:"iana",extensions:["pclxl"]},"application/vnd.httphone":{source:"iana"},"application/vnd.hydrostatix.sof-data":{source:"iana",extensions:["sfd-hdstx"]},"application/vnd.hyper-item+json":{source:"iana",compressible:!0},"application/vnd.hyperdrive+json":{source:"iana",compressible:!0},"application/vnd.hzn-3d-crossword":{source:"iana"},"application/vnd.ibm.afplinedata":{source:"iana"},"application/vnd.ibm.electronic-media":{source:"iana"},"application/vnd.ibm.minipay":{source:"iana",extensions:["mpy"]},"application/vnd.ibm.modcap":{source:"iana",extensions:["afp","listafp","list3820"]},"application/vnd.ibm.rights-management":{source:"iana",extensions:["irm"]},"application/vnd.ibm.secure-container":{source:"iana",extensions:["sc"]},"application/vnd.iccprofile":{source:"iana",extensions:["icc","icm"]},"application/vnd.ieee.1905":{source:"iana"},"application/vnd.igloader":{source:"iana",extensions:["igl"]},"application/vnd.imagemeter.folder+zip":{source:"iana"},"application/vnd.imagemeter.image+zip":{source:"iana"},"application/vnd.immervision-ivp":{source:"iana",extensions:["ivp"]},"application/vnd.immervision-ivu":{source:"iana",extensions:["ivu"]},"application/vnd.ims.imsccv1p1":{source:"iana"},"application/vnd.ims.imsccv1p2":{source:"iana"},"application/vnd.ims.imsccv1p3":{source:"iana"},"application/vnd.ims.lis.v2.result+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolconsumerprofile+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolproxy+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolproxy.id+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolsettings+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolsettings.simple+json":{source:"iana",compressible:!0},"application/vnd.informedcontrol.rms+xml":{source:"iana"},"application/vnd.informix-visionary":{source:"iana"},"application/vnd.infotech.project":{source:"iana"},"application/vnd.infotech.project+xml":{source:"iana"},"application/vnd.innopath.wamp.notification":{source:"iana"},"application/vnd.insors.igm":{source:"iana",extensions:["igm"]},"application/vnd.intercon.formnet":{source:"iana",extensions:["xpw","xpx"]},"application/vnd.intergeo":{source:"iana",extensions:["i2g"]},"application/vnd.intertrust.digibox":{source:"iana"},"application/vnd.intertrust.nncp":{source:"iana"},"application/vnd.intu.qbo":{source:"iana",extensions:["qbo"]},"application/vnd.intu.qfx":{source:"iana",extensions:["qfx"]},"application/vnd.iptc.g2.catalogitem+xml":{source:"iana"},"application/vnd.iptc.g2.conceptitem+xml":{source:"iana"},"application/vnd.iptc.g2.knowledgeitem+xml":{source:"iana"},"application/vnd.iptc.g2.newsitem+xml":{source:"iana"},"application/vnd.iptc.g2.newsmessage+xml":{source:"iana"},"application/vnd.iptc.g2.packageitem+xml":{source:"iana"},"application/vnd.iptc.g2.planningitem+xml":{source:"iana"},"application/vnd.ipunplugged.rcprofile":{source:"iana",extensions:["rcprofile"]},"application/vnd.irepository.package+xml":{source:"iana",extensions:["irp"]},"application/vnd.is-xpr":{source:"iana",extensions:["xpr"]},"application/vnd.isac.fcs":{source:"iana",extensions:["fcs"]},"application/vnd.jam":{source:"iana",extensions:["jam"]},"application/vnd.japannet-directory-service":{source:"iana"},"application/vnd.japannet-jpnstore-wakeup":{source:"iana"},"application/vnd.japannet-payment-wakeup":{source:"iana"},"application/vnd.japannet-registration":{source:"iana"},"application/vnd.japannet-registration-wakeup":{source:"iana"},"application/vnd.japannet-setstore-wakeup":{source:"iana"},"application/vnd.japannet-verification":{source:"iana"},"application/vnd.japannet-verification-wakeup":{source:"iana"},"application/vnd.jcp.javame.midlet-rms":{source:"iana",extensions:["rms"]},"application/vnd.jisp":{source:"iana",extensions:["jisp"]},"application/vnd.joost.joda-archive":{source:"iana",extensions:["joda"]},"application/vnd.jsk.isdn-ngn":{source:"iana"},"application/vnd.kahootz":{source:"iana",extensions:["ktz","ktr"]},"application/vnd.kde.karbon":{source:"iana",extensions:["karbon"]},"application/vnd.kde.kchart":{source:"iana",extensions:["chrt"]},"application/vnd.kde.kformula":{source:"iana",extensions:["kfo"]},"application/vnd.kde.kivio":{source:"iana",extensions:["flw"]},"application/vnd.kde.kontour":{source:"iana",extensions:["kon"]},"application/vnd.kde.kpresenter":{source:"iana",extensions:["kpr","kpt"]},"application/vnd.kde.kspread":{source:"iana",extensions:["ksp"]},"application/vnd.kde.kword":{source:"iana",extensions:["kwd","kwt"]},"application/vnd.kenameaapp":{source:"iana",extensions:["htke"]},"application/vnd.kidspiration":{source:"iana",extensions:["kia"]},"application/vnd.kinar":{source:"iana",extensions:["kne","knp"]},"application/vnd.koan":{source:"iana",extensions:["skp","skd","skt","skm"]},"application/vnd.kodak-descriptor":{source:"iana",extensions:["sse"]},"application/vnd.las.las+json":{source:"iana",compressible:!0},"application/vnd.las.las+xml":{source:"iana",extensions:["lasxml"]},"application/vnd.liberty-request+xml":{source:"iana"},"application/vnd.llamagraphics.life-balance.desktop":{source:"iana",extensions:["lbd"]},"application/vnd.llamagraphics.life-balance.exchange+xml":{source:"iana",extensions:["lbe"]},"application/vnd.lotus-1-2-3":{source:"iana",extensions:["123"]},"application/vnd.lotus-approach":{source:"iana",extensions:["apr"]},"application/vnd.lotus-freelance":{source:"iana",extensions:["pre"]},"application/vnd.lotus-notes":{source:"iana",extensions:["nsf"]},"application/vnd.lotus-organizer":{source:"iana",extensions:["org"]},"application/vnd.lotus-screencam":{source:"iana",extensions:["scm"]},"application/vnd.lotus-wordpro":{source:"iana",extensions:["lwp"]},"application/vnd.macports.portpkg":{source:"iana",extensions:["portpkg"]},"application/vnd.mapbox-vector-tile":{source:"iana"},"application/vnd.marlin.drm.actiontoken+xml":{source:"iana"},"application/vnd.marlin.drm.conftoken+xml":{source:"iana"},"application/vnd.marlin.drm.license+xml":{source:"iana"},"application/vnd.marlin.drm.mdcf":{source:"iana"},"application/vnd.mason+json":{source:"iana",compressible:!0},"application/vnd.maxmind.maxmind-db":{source:"iana"},"application/vnd.mcd":{source:"iana",extensions:["mcd"]},"application/vnd.medcalcdata":{source:"iana",extensions:["mc1"]},"application/vnd.mediastation.cdkey":{source:"iana",extensions:["cdkey"]},"application/vnd.meridian-slingshot":{source:"iana"},"application/vnd.mfer":{source:"iana",extensions:["mwf"]},"application/vnd.mfmp":{source:"iana",extensions:["mfm"]},"application/vnd.micro+json":{source:"iana",compressible:!0},"application/vnd.micrografx.flo":{source:"iana",extensions:["flo"]},"application/vnd.micrografx.igx":{source:"iana",extensions:["igx"]},"application/vnd.microsoft.portable-executable":{source:"iana"},"application/vnd.microsoft.windows.thumbnail-cache":{source:"iana"},"application/vnd.miele+json":{source:"iana",compressible:!0},"application/vnd.mif":{source:"iana",extensions:["mif"]},"application/vnd.minisoft-hp3000-save":{source:"iana"},"application/vnd.mitsubishi.misty-guard.trustweb":{source:"iana"},"application/vnd.mobius.daf":{source:"iana",extensions:["daf"]},"application/vnd.mobius.dis":{source:"iana",extensions:["dis"]},"application/vnd.mobius.mbk":{source:"iana",extensions:["mbk"]},"application/vnd.mobius.mqy":{source:"iana",extensions:["mqy"]},"application/vnd.mobius.msl":{source:"iana",extensions:["msl"]},"application/vnd.mobius.plc":{source:"iana",extensions:["plc"]},"application/vnd.mobius.txf":{source:"iana",extensions:["txf"]},"application/vnd.mophun.application":{source:"iana",extensions:["mpn"]},"application/vnd.mophun.certificate":{source:"iana",extensions:["mpc"]},"application/vnd.motorola.flexsuite":{source:"iana"},"application/vnd.motorola.flexsuite.adsi":{source:"iana"},"application/vnd.motorola.flexsuite.fis":{source:"iana"},"application/vnd.motorola.flexsuite.gotap":{source:"iana"},"application/vnd.motorola.flexsuite.kmr":{source:"iana"},"application/vnd.motorola.flexsuite.ttc":{source:"iana"},"application/vnd.motorola.flexsuite.wem":{source:"iana"},"application/vnd.motorola.iprm":{source:"iana"},"application/vnd.mozilla.xul+xml":{source:"iana",compressible:!0,extensions:["xul"]},"application/vnd.ms-3mfdocument":{source:"iana"},"application/vnd.ms-artgalry":{source:"iana",extensions:["cil"]},"application/vnd.ms-asf":{source:"iana"},"application/vnd.ms-cab-compressed":{source:"iana",extensions:["cab"]},"application/vnd.ms-color.iccprofile":{source:"apache"},"application/vnd.ms-excel":{source:"iana",compressible:!1,extensions:["xls","xlm","xla","xlc","xlt","xlw"]},"application/vnd.ms-excel.addin.macroenabled.12":{source:"iana",extensions:["xlam"]},"application/vnd.ms-excel.sheet.binary.macroenabled.12":{source:"iana",extensions:["xlsb"]},"application/vnd.ms-excel.sheet.macroenabled.12":{source:"iana",extensions:["xlsm"]},"application/vnd.ms-excel.template.macroenabled.12":{source:"iana",extensions:["xltm"]},"application/vnd.ms-fontobject":{source:"iana",compressible:!0,extensions:["eot"]},"application/vnd.ms-htmlhelp":{source:"iana",extensions:["chm"]},"application/vnd.ms-ims":{source:"iana",extensions:["ims"]},"application/vnd.ms-lrm":{source:"iana",extensions:["lrm"]},"application/vnd.ms-office.activex+xml":{source:"iana"},"application/vnd.ms-officetheme":{source:"iana",extensions:["thmx"]},"application/vnd.ms-opentype":{source:"apache",compressible:!0},"application/vnd.ms-outlook":{compressible:!1,extensions:["msg"]},"application/vnd.ms-package.obfuscated-opentype":{source:"apache"},"application/vnd.ms-pki.seccat":{source:"apache",extensions:["cat"]},"application/vnd.ms-pki.stl":{source:"apache",extensions:["stl"]},"application/vnd.ms-playready.initiator+xml":{source:"iana"},"application/vnd.ms-powerpoint":{source:"iana",compressible:!1,extensions:["ppt","pps","pot"]},"application/vnd.ms-powerpoint.addin.macroenabled.12":{source:"iana",extensions:["ppam"]},"application/vnd.ms-powerpoint.presentation.macroenabled.12":{source:"iana",extensions:["pptm"]},"application/vnd.ms-powerpoint.slide.macroenabled.12":{source:"iana",extensions:["sldm"]},"application/vnd.ms-powerpoint.slideshow.macroenabled.12":{source:"iana",extensions:["ppsm"]},"application/vnd.ms-powerpoint.template.macroenabled.12":{source:"iana",extensions:["potm"]},"application/vnd.ms-printdevicecapabilities+xml":{source:"iana"},"application/vnd.ms-printing.printticket+xml":{source:"apache"},"application/vnd.ms-printschematicket+xml":{source:"iana"},"application/vnd.ms-project":{source:"iana",extensions:["mpp","mpt"]},"application/vnd.ms-tnef":{source:"iana"},"application/vnd.ms-windows.devicepairing":{source:"iana"},"application/vnd.ms-windows.nwprinting.oob":{source:"iana"},"application/vnd.ms-windows.printerpairing":{source:"iana"},"application/vnd.ms-windows.wsd.oob":{source:"iana"},"application/vnd.ms-wmdrm.lic-chlg-req":{source:"iana"},"application/vnd.ms-wmdrm.lic-resp":{source:"iana"},"application/vnd.ms-wmdrm.meter-chlg-req":{source:"iana"},"application/vnd.ms-wmdrm.meter-resp":{source:"iana"},"application/vnd.ms-word.document.macroenabled.12":{source:"iana",extensions:["docm"]},"application/vnd.ms-word.template.macroenabled.12":{source:"iana",extensions:["dotm"]},"application/vnd.ms-works":{source:"iana",extensions:["wps","wks","wcm","wdb"]},"application/vnd.ms-wpl":{source:"iana",extensions:["wpl"]},"application/vnd.ms-xpsdocument":{source:"iana",compressible:!1,extensions:["xps"]},"application/vnd.msa-disk-image":{source:"iana"},"application/vnd.mseq":{source:"iana",extensions:["mseq"]},"application/vnd.msign":{source:"iana"},"application/vnd.multiad.creator":{source:"iana"},"application/vnd.multiad.creator.cif":{source:"iana"},"application/vnd.music-niff":{source:"iana"},"application/vnd.musician":{source:"iana",extensions:["mus"]},"application/vnd.muvee.style":{source:"iana",extensions:["msty"]},"application/vnd.mynfc":{source:"iana",extensions:["taglet"]},"application/vnd.ncd.control":{source:"iana"},"application/vnd.ncd.reference":{source:"iana"},"application/vnd.nearst.inv+json":{source:"iana",compressible:!0},"application/vnd.nervana":{source:"iana"},"application/vnd.netfpx":{source:"iana"},"application/vnd.neurolanguage.nlu":{source:"iana",extensions:["nlu"]},"application/vnd.nintendo.nitro.rom":{source:"iana"},"application/vnd.nintendo.snes.rom":{source:"iana"},"application/vnd.nitf":{source:"iana",extensions:["ntf","nitf"]},"application/vnd.noblenet-directory":{source:"iana",extensions:["nnd"]},"application/vnd.noblenet-sealer":{source:"iana",extensions:["nns"]},"application/vnd.noblenet-web":{source:"iana",extensions:["nnw"]},"application/vnd.nokia.catalogs":{source:"iana"},"application/vnd.nokia.conml+wbxml":{source:"iana"},"application/vnd.nokia.conml+xml":{source:"iana"},"application/vnd.nokia.iptv.config+xml":{source:"iana"},"application/vnd.nokia.isds-radio-presets":{source:"iana"},"application/vnd.nokia.landmark+wbxml":{source:"iana"},"application/vnd.nokia.landmark+xml":{source:"iana"},"application/vnd.nokia.landmarkcollection+xml":{source:"iana"},"application/vnd.nokia.n-gage.ac+xml":{source:"iana"},"application/vnd.nokia.n-gage.data":{source:"iana",extensions:["ngdat"]},"application/vnd.nokia.n-gage.symbian.install":{source:"iana",extensions:["n-gage"]},"application/vnd.nokia.ncd":{source:"iana"},"application/vnd.nokia.pcd+wbxml":{source:"iana"},"application/vnd.nokia.pcd+xml":{source:"iana"},"application/vnd.nokia.radio-preset":{source:"iana",extensions:["rpst"]},"application/vnd.nokia.radio-presets":{source:"iana",extensions:["rpss"]},"application/vnd.novadigm.edm":{source:"iana",extensions:["edm"]},"application/vnd.novadigm.edx":{source:"iana",extensions:["edx"]},"application/vnd.novadigm.ext":{source:"iana",extensions:["ext"]},"application/vnd.ntt-local.content-share":{source:"iana"},"application/vnd.ntt-local.file-transfer":{source:"iana"},"application/vnd.ntt-local.ogw_remote-access":{source:"iana"},"application/vnd.ntt-local.sip-ta_remote":{source:"iana"},"application/vnd.ntt-local.sip-ta_tcp_stream":{source:"iana"},"application/vnd.oasis.opendocument.chart":{source:"iana",extensions:["odc"]},"application/vnd.oasis.opendocument.chart-template":{source:"iana",extensions:["otc"]},"application/vnd.oasis.opendocument.database":{source:"iana",extensions:["odb"]},"application/vnd.oasis.opendocument.formula":{source:"iana",extensions:["odf"]},"application/vnd.oasis.opendocument.formula-template":{source:"iana",extensions:["odft"]},"application/vnd.oasis.opendocument.graphics":{source:"iana",compressible:!1,extensions:["odg"]},"application/vnd.oasis.opendocument.graphics-template":{source:"iana",extensions:["otg"]},"application/vnd.oasis.opendocument.image":{source:"iana",extensions:["odi"]},"application/vnd.oasis.opendocument.image-template":{source:"iana",extensions:["oti"]},"application/vnd.oasis.opendocument.presentation":{source:"iana",compressible:!1,extensions:["odp"]},"application/vnd.oasis.opendocument.presentation-template":{source:"iana",extensions:["otp"]},"application/vnd.oasis.opendocument.spreadsheet":{source:"iana",compressible:!1,extensions:["ods"]},"application/vnd.oasis.opendocument.spreadsheet-template":{source:"iana",extensions:["ots"]},"application/vnd.oasis.opendocument.text":{source:"iana",compressible:!1,extensions:["odt"]},"application/vnd.oasis.opendocument.text-master":{source:"iana",extensions:["odm"]},"application/vnd.oasis.opendocument.text-template":{source:"iana",extensions:["ott"]},"application/vnd.oasis.opendocument.text-web":{source:"iana",extensions:["oth"]},"application/vnd.obn":{source:"iana"},"application/vnd.ocf+cbor":{source:"iana"},"application/vnd.oftn.l10n+json":{source:"iana",compressible:!0},"application/vnd.oipf.contentaccessdownload+xml":{source:"iana"},"application/vnd.oipf.contentaccessstreaming+xml":{source:"iana"},"application/vnd.oipf.cspg-hexbinary":{source:"iana"},"application/vnd.oipf.dae.svg+xml":{source:"iana"},"application/vnd.oipf.dae.xhtml+xml":{source:"iana"},"application/vnd.oipf.mippvcontrolmessage+xml":{source:"iana"},"application/vnd.oipf.pae.gem":{source:"iana"},"application/vnd.oipf.spdiscovery+xml":{source:"iana"},"application/vnd.oipf.spdlist+xml":{source:"iana"},"application/vnd.oipf.ueprofile+xml":{source:"iana"},"application/vnd.oipf.userprofile+xml":{source:"iana"},"application/vnd.olpc-sugar":{source:"iana",extensions:["xo"]},"application/vnd.oma-scws-config":{source:"iana"},"application/vnd.oma-scws-http-request":{source:"iana"},"application/vnd.oma-scws-http-response":{source:"iana"},"application/vnd.oma.bcast.associated-procedure-parameter+xml":{source:"iana"},"application/vnd.oma.bcast.drm-trigger+xml":{source:"iana"},"application/vnd.oma.bcast.imd+xml":{source:"iana"},"application/vnd.oma.bcast.ltkm":{source:"iana"},"application/vnd.oma.bcast.notification+xml":{source:"iana"},"application/vnd.oma.bcast.provisioningtrigger":{source:"iana"},"application/vnd.oma.bcast.sgboot":{source:"iana"},"application/vnd.oma.bcast.sgdd+xml":{source:"iana"},"application/vnd.oma.bcast.sgdu":{source:"iana"},"application/vnd.oma.bcast.simple-symbol-container":{source:"iana"},"application/vnd.oma.bcast.smartcard-trigger+xml":{source:"iana"},"application/vnd.oma.bcast.sprov+xml":{source:"iana"},"application/vnd.oma.bcast.stkm":{source:"iana"},"application/vnd.oma.cab-address-book+xml":{source:"iana"},"application/vnd.oma.cab-feature-handler+xml":{source:"iana"},"application/vnd.oma.cab-pcc+xml":{source:"iana"},"application/vnd.oma.cab-subs-invite+xml":{source:"iana"},"application/vnd.oma.cab-user-prefs+xml":{source:"iana"},"application/vnd.oma.dcd":{source:"iana"},"application/vnd.oma.dcdc":{source:"iana"},"application/vnd.oma.dd2+xml":{source:"iana",extensions:["dd2"]},"application/vnd.oma.drm.risd+xml":{source:"iana"},"application/vnd.oma.group-usage-list+xml":{source:"iana"},"application/vnd.oma.lwm2m+json":{source:"iana",compressible:!0},"application/vnd.oma.lwm2m+tlv":{source:"iana"},"application/vnd.oma.pal+xml":{source:"iana"},"application/vnd.oma.poc.detailed-progress-report+xml":{source:"iana"},"application/vnd.oma.poc.final-report+xml":{source:"iana"},"application/vnd.oma.poc.groups+xml":{source:"iana"},"application/vnd.oma.poc.invocation-descriptor+xml":{source:"iana"},"application/vnd.oma.poc.optimized-progress-report+xml":{source:"iana"},"application/vnd.oma.push":{source:"iana"},"application/vnd.oma.scidm.messages+xml":{source:"iana"},"application/vnd.oma.xcap-directory+xml":{source:"iana"},"application/vnd.omads-email+xml":{source:"iana"},"application/vnd.omads-file+xml":{source:"iana"},"application/vnd.omads-folder+xml":{source:"iana"},"application/vnd.omaloc-supl-init":{source:"iana"},"application/vnd.onepager":{source:"iana"},"application/vnd.onepagertamp":{source:"iana"},"application/vnd.onepagertamx":{source:"iana"},"application/vnd.onepagertat":{source:"iana"},"application/vnd.onepagertatp":{source:"iana"},"application/vnd.onepagertatx":{source:"iana"},"application/vnd.openblox.game+xml":{source:"iana"},"application/vnd.openblox.game-binary":{source:"iana"},"application/vnd.openeye.oeb":{source:"iana"},"application/vnd.openofficeorg.extension":{source:"apache",extensions:["oxt"]},"application/vnd.openstreetmap.data+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.custom-properties+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.customxmlproperties+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.drawing+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.drawingml.chart+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.extended-properties+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml-template":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.comments+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{source:"iana",compressible:!1,extensions:["pptx"]},"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.presprops+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.slide":{source:"iana",extensions:["sldx"]},"application/vnd.openxmlformats-officedocument.presentationml.slide+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.slideshow":{source:"iana",extensions:["ppsx"]},"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.tags+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.template":{source:"apache",extensions:["potx"]},"application/vnd.openxmlformats-officedocument.presentationml.template.main+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml-template":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{source:"iana",compressible:!1,extensions:["xlsx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.template":{source:"apache",extensions:["xltx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.theme+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.themeoverride+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.vmldrawing":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml-template":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{source:"iana",compressible:!1,extensions:["docx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.template":{source:"apache",extensions:["dotx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml":{source:"iana"},"application/vnd.openxmlformats-package.core-properties+xml":{source:"iana"},"application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml":{source:"iana"},"application/vnd.openxmlformats-package.relationships+xml":{source:"iana"},"application/vnd.oracle.resource+json":{source:"iana",compressible:!0},"application/vnd.orange.indata":{source:"iana"},"application/vnd.osa.netdeploy":{source:"iana"},"application/vnd.osgeo.mapguide.package":{source:"iana",extensions:["mgp"]},"application/vnd.osgi.bundle":{source:"iana"},"application/vnd.osgi.dp":{source:"iana",extensions:["dp"]},"application/vnd.osgi.subsystem":{source:"iana",extensions:["esa"]},"application/vnd.otps.ct-kip+xml":{source:"iana"},"application/vnd.oxli.countgraph":{source:"iana"},"application/vnd.pagerduty+json":{source:"iana",compressible:!0},"application/vnd.palm":{source:"iana",extensions:["pdb","pqa","oprc"]},"application/vnd.panoply":{source:"iana"},"application/vnd.paos+xml":{source:"iana"},"application/vnd.paos.xml":{source:"apache"},"application/vnd.pawaafile":{source:"iana",extensions:["paw"]},"application/vnd.pcos":{source:"iana"},"application/vnd.pg.format":{source:"iana",extensions:["str"]},"application/vnd.pg.osasli":{source:"iana",extensions:["ei6"]},"application/vnd.piaccess.application-licence":{source:"iana"},"application/vnd.picsel":{source:"iana",extensions:["efif"]},"application/vnd.pmi.widget":{source:"iana",extensions:["wg"]},"application/vnd.poc.group-advertisement+xml":{source:"iana"},"application/vnd.pocketlearn":{source:"iana",extensions:["plf"]},"application/vnd.powerbuilder6":{source:"iana",extensions:["pbd"]},"application/vnd.powerbuilder6-s":{source:"iana"},"application/vnd.powerbuilder7":{source:"iana"},"application/vnd.powerbuilder7-s":{source:"iana"},"application/vnd.powerbuilder75":{source:"iana"},"application/vnd.powerbuilder75-s":{source:"iana"},"application/vnd.preminet":{source:"iana"},"application/vnd.previewsystems.box":{source:"iana",extensions:["box"]},"application/vnd.proteus.magazine":{source:"iana",extensions:["mgz"]},"application/vnd.publishare-delta-tree":{source:"iana",extensions:["qps"]},"application/vnd.pvi.ptid1":{source:"iana",extensions:["ptid"]},"application/vnd.pwg-multiplexed":{source:"iana"},"application/vnd.pwg-xhtml-print+xml":{source:"iana"},"application/vnd.qualcomm.brew-app-res":{source:"iana"},"application/vnd.quarantainenet":{source:"iana"},"application/vnd.quark.quarkxpress":{source:"iana",extensions:["qxd","qxt","qwd","qwt","qxl","qxb"]},"application/vnd.quobject-quoxdocument":{source:"iana"},"application/vnd.radisys.moml+xml":{source:"iana"},"application/vnd.radisys.msml+xml":{source:"iana"},"application/vnd.radisys.msml-audit+xml":{source:"iana"},"application/vnd.radisys.msml-audit-conf+xml":{source:"iana"},"application/vnd.radisys.msml-audit-conn+xml":{source:"iana"},"application/vnd.radisys.msml-audit-dialog+xml":{source:"iana"},"application/vnd.radisys.msml-audit-stream+xml":{source:"iana"},"application/vnd.radisys.msml-conf+xml":{source:"iana"},"application/vnd.radisys.msml-dialog+xml":{source:"iana"},"application/vnd.radisys.msml-dialog-base+xml":{source:"iana"},"application/vnd.radisys.msml-dialog-fax-detect+xml":{source:"iana"},"application/vnd.radisys.msml-dialog-fax-sendrecv+xml":{source:"iana"},"application/vnd.radisys.msml-dialog-group+xml":{source:"iana"},"application/vnd.radisys.msml-dialog-speech+xml":{source:"iana"},"application/vnd.radisys.msml-dialog-transform+xml":{source:"iana"},"application/vnd.rainstor.data":{source:"iana"},"application/vnd.rapid":{source:"iana"},"application/vnd.rar":{source:"iana"},"application/vnd.realvnc.bed":{source:"iana",extensions:["bed"]},"application/vnd.recordare.musicxml":{source:"iana",extensions:["mxl"]},"application/vnd.recordare.musicxml+xml":{source:"iana",extensions:["musicxml"]},"application/vnd.renlearn.rlprint":{source:"iana"},"application/vnd.rig.cryptonote":{source:"iana",extensions:["cryptonote"]},"application/vnd.rim.cod":{source:"apache",extensions:["cod"]},"application/vnd.rn-realmedia":{source:"apache",extensions:["rm"]},"application/vnd.rn-realmedia-vbr":{source:"apache",extensions:["rmvb"]},"application/vnd.route66.link66+xml":{source:"iana",extensions:["link66"]},"application/vnd.rs-274x":{source:"iana"},"application/vnd.ruckus.download":{source:"iana"},"application/vnd.s3sms":{source:"iana"},"application/vnd.sailingtracker.track":{source:"iana",extensions:["st"]},"application/vnd.sbm.cid":{source:"iana"},"application/vnd.sbm.mid2":{source:"iana"},"application/vnd.scribus":{source:"iana"},"application/vnd.sealed.3df":{source:"iana"},"application/vnd.sealed.csf":{source:"iana"},"application/vnd.sealed.doc":{source:"iana"},"application/vnd.sealed.eml":{source:"iana"},"application/vnd.sealed.mht":{source:"iana"},"application/vnd.sealed.net":{source:"iana"},"application/vnd.sealed.ppt":{source:"iana"},"application/vnd.sealed.tiff":{source:"iana"},"application/vnd.sealed.xls":{source:"iana"},"application/vnd.sealedmedia.softseal.html":{source:"iana"},"application/vnd.sealedmedia.softseal.pdf":{source:"iana"},"application/vnd.seemail":{source:"iana",extensions:["see"]},"application/vnd.sema":{source:"iana",extensions:["sema"]},"application/vnd.semd":{source:"iana",extensions:["semd"]},"application/vnd.semf":{source:"iana",extensions:["semf"]},"application/vnd.shana.informed.formdata":{source:"iana",extensions:["ifm"]},"application/vnd.shana.informed.formtemplate":{source:"iana",extensions:["itp"]},"application/vnd.shana.informed.interchange":{source:"iana",extensions:["iif"]},"application/vnd.shana.informed.package":{source:"iana",extensions:["ipk"]},"application/vnd.sigrok.session":{source:"iana"},"application/vnd.simtech-mindmapper":{source:"iana",extensions:["twd","twds"]},"application/vnd.siren+json":{source:"iana",compressible:!0},"application/vnd.smaf":{source:"iana",extensions:["mmf"]},"application/vnd.smart.notebook":{source:"iana"},"application/vnd.smart.teacher":{source:"iana",extensions:["teacher"]},"application/vnd.software602.filler.form+xml":{source:"iana"},"application/vnd.software602.filler.form-xml-zip":{source:"iana"},"application/vnd.solent.sdkm+xml":{source:"iana",extensions:["sdkm","sdkd"]},"application/vnd.spotfire.dxp":{source:"iana",extensions:["dxp"]},"application/vnd.spotfire.sfs":{source:"iana",extensions:["sfs"]},"application/vnd.sss-cod":{source:"iana"},"application/vnd.sss-dtf":{source:"iana"},"application/vnd.sss-ntf":{source:"iana"},"application/vnd.stardivision.calc":{source:"apache",extensions:["sdc"]},"application/vnd.stardivision.draw":{source:"apache",extensions:["sda"]},"application/vnd.stardivision.impress":{source:"apache",extensions:["sdd"]},"application/vnd.stardivision.math":{source:"apache",extensions:["smf"]},"application/vnd.stardivision.writer":{source:"apache",extensions:["sdw","vor"]},"application/vnd.stardivision.writer-global":{source:"apache",extensions:["sgl"]},"application/vnd.stepmania.package":{source:"iana",extensions:["smzip"]},"application/vnd.stepmania.stepchart":{source:"iana",extensions:["sm"]},"application/vnd.street-stream":{source:"iana"},"application/vnd.sun.wadl+xml":{source:"iana",compressible:!0,extensions:["wadl"]},"application/vnd.sun.xml.calc":{source:"apache",extensions:["sxc"]},"application/vnd.sun.xml.calc.template":{source:"apache",extensions:["stc"]},"application/vnd.sun.xml.draw":{source:"apache",extensions:["sxd"]},"application/vnd.sun.xml.draw.template":{source:"apache",extensions:["std"]},"application/vnd.sun.xml.impress":{source:"apache",extensions:["sxi"]},"application/vnd.sun.xml.impress.template":{source:"apache",extensions:["sti"]},"application/vnd.sun.xml.math":{source:"apache",extensions:["sxm"]},"application/vnd.sun.xml.writer":{source:"apache",extensions:["sxw"]},"application/vnd.sun.xml.writer.global":{source:"apache",extensions:["sxg"]},"application/vnd.sun.xml.writer.template":{source:"apache",extensions:["stw"]},"application/vnd.sus-calendar":{source:"iana",extensions:["sus","susp"]},"application/vnd.svd":{source:"iana",extensions:["svd"]},"application/vnd.swiftview-ics":{source:"iana"},"application/vnd.symbian.install":{source:"apache",extensions:["sis","sisx"]},"application/vnd.syncml+xml":{source:"iana",extensions:["xsm"]},"application/vnd.syncml.dm+wbxml":{source:"iana",extensions:["bdm"]},"application/vnd.syncml.dm+xml":{source:"iana",extensions:["xdm"]},"application/vnd.syncml.dm.notification":{source:"iana"},"application/vnd.syncml.dmddf+wbxml":{source:"iana"},"application/vnd.syncml.dmddf+xml":{source:"iana"},"application/vnd.syncml.dmtnds+wbxml":{source:"iana"},"application/vnd.syncml.dmtnds+xml":{source:"iana"},"application/vnd.syncml.ds.notification":{source:"iana"},"application/vnd.tableschema+json":{source:"iana",compressible:!0},"application/vnd.tao.intent-module-archive":{source:"iana",extensions:["tao"]},"application/vnd.tcpdump.pcap":{source:"iana",extensions:["pcap","cap","dmp"]},"application/vnd.tmd.mediaflex.api+xml":{source:"iana"},"application/vnd.tml":{source:"iana"},"application/vnd.tmobile-livetv":{source:"iana",extensions:["tmo"]},"application/vnd.tri.onesource":{source:"iana"},"application/vnd.trid.tpt":{source:"iana",extensions:["tpt"]},"application/vnd.triscape.mxs":{source:"iana",extensions:["mxs"]},"application/vnd.trueapp":{source:"iana",extensions:["tra"]},"application/vnd.truedoc":{source:"iana"},"application/vnd.ubisoft.webplayer":{source:"iana"},"application/vnd.ufdl":{source:"iana",extensions:["ufd","ufdl"]},"application/vnd.uiq.theme":{source:"iana",extensions:["utz"]},"application/vnd.umajin":{source:"iana",extensions:["umj"]},"application/vnd.unity":{source:"iana",extensions:["unityweb"]},"application/vnd.uoml+xml":{source:"iana",extensions:["uoml"]},"application/vnd.uplanet.alert":{source:"iana"},"application/vnd.uplanet.alert-wbxml":{source:"iana"},"application/vnd.uplanet.bearer-choice":{source:"iana"},"application/vnd.uplanet.bearer-choice-wbxml":{source:"iana"},"application/vnd.uplanet.cacheop":{source:"iana"},"application/vnd.uplanet.cacheop-wbxml":{source:"iana"},"application/vnd.uplanet.channel":{source:"iana"},"application/vnd.uplanet.channel-wbxml":{source:"iana"},"application/vnd.uplanet.list":{source:"iana"},"application/vnd.uplanet.list-wbxml":{source:"iana"},"application/vnd.uplanet.listcmd":{source:"iana"},"application/vnd.uplanet.listcmd-wbxml":{source:"iana"},"application/vnd.uplanet.signal":{source:"iana"},"application/vnd.uri-map":{source:"iana"},"application/vnd.valve.source.material":{source:"iana"},"application/vnd.vcx":{source:"iana",extensions:["vcx"]},"application/vnd.vd-study":{source:"iana"},"application/vnd.vectorworks":{source:"iana"},"application/vnd.vel+json":{source:"iana",compressible:!0},"application/vnd.verimatrix.vcas":{source:"iana"},"application/vnd.vidsoft.vidconference":{source:"iana"},"application/vnd.visio":{source:"iana",extensions:["vsd","vst","vss","vsw"]},"application/vnd.visionary":{source:"iana",extensions:["vis"]},"application/vnd.vividence.scriptfile":{source:"iana"},"application/vnd.vsf":{source:"iana",extensions:["vsf"]},"application/vnd.wap.sic":{source:"iana"},"application/vnd.wap.slc":{source:"iana"},"application/vnd.wap.wbxml":{source:"iana",extensions:["wbxml"]},"application/vnd.wap.wmlc":{source:"iana",extensions:["wmlc"]},"application/vnd.wap.wmlscriptc":{source:"iana",extensions:["wmlsc"]},"application/vnd.webturbo":{source:"iana",extensions:["wtb"]},"application/vnd.wfa.p2p":{source:"iana"},"application/vnd.wfa.wsc":{source:"iana"},"application/vnd.windows.devicepairing":{source:"iana"},"application/vnd.wmc":{source:"iana"},"application/vnd.wmf.bootstrap":{source:"iana"},"application/vnd.wolfram.mathematica":{source:"iana"},"application/vnd.wolfram.mathematica.package":{source:"iana"},"application/vnd.wolfram.player":{source:"iana",extensions:["nbp"]},"application/vnd.wordperfect":{source:"iana",extensions:["wpd"]},"application/vnd.wqd":{source:"iana",extensions:["wqd"]},"application/vnd.wrq-hp3000-labelled":{source:"iana"},"application/vnd.wt.stf":{source:"iana",extensions:["stf"]},"application/vnd.wv.csp+wbxml":{source:"iana"},"application/vnd.wv.csp+xml":{source:"iana"},"application/vnd.wv.ssp+xml":{source:"iana"},"application/vnd.xacml+json":{source:"iana",compressible:!0},"application/vnd.xara":{source:"iana",extensions:["xar"]},"application/vnd.xfdl":{source:"iana",extensions:["xfdl"]},"application/vnd.xfdl.webform":{source:"iana"},"application/vnd.xmi+xml":{source:"iana"},"application/vnd.xmpie.cpkg":{source:"iana"},"application/vnd.xmpie.dpkg":{source:"iana"},"application/vnd.xmpie.plan":{source:"iana"},"application/vnd.xmpie.ppkg":{source:"iana"},"application/vnd.xmpie.xlim":{source:"iana"},"application/vnd.yamaha.hv-dic":{source:"iana",extensions:["hvd"]},"application/vnd.yamaha.hv-script":{source:"iana",extensions:["hvs"]},"application/vnd.yamaha.hv-voice":{source:"iana",extensions:["hvp"]},"application/vnd.yamaha.openscoreformat":{source:"iana",extensions:["osf"]},"application/vnd.yamaha.openscoreformat.osfpvg+xml":{source:"iana",extensions:["osfpvg"]},"application/vnd.yamaha.remote-setup":{source:"iana"},"application/vnd.yamaha.smaf-audio":{source:"iana",extensions:["saf"]},"application/vnd.yamaha.smaf-phrase":{source:"iana",extensions:["spf"]},"application/vnd.yamaha.through-ngn":{source:"iana"},"application/vnd.yamaha.tunnel-udpencap":{source:"iana"},"application/vnd.yaoweme":{source:"iana"},"application/vnd.yellowriver-custom-menu":{source:"iana",extensions:["cmp"]},"application/vnd.zul":{source:"iana",extensions:["zir","zirz"]},"application/vnd.zzazz.deck+xml":{source:"iana",extensions:["zaz"]},"application/voicexml+xml":{source:"iana",extensions:["vxml"]},"application/vq-rtcpxr":{source:"iana"},"application/watcherinfo+xml":{source:"iana"},"application/whoispp-query":{source:"iana"},"application/whoispp-response":{source:"iana"},"application/widget":{source:"iana",extensions:["wgt"]},"application/winhlp":{source:"apache",extensions:["hlp"]},"application/wita":{source:"iana"},"application/wordperfect5.1":{source:"iana"},"application/wsdl+xml":{source:"iana",extensions:["wsdl"]},"application/wspolicy+xml":{source:"iana",extensions:["wspolicy"]},"application/x-7z-compressed":{source:"apache",compressible:!1,extensions:["7z"]},"application/x-abiword":{source:"apache",extensions:["abw"]},"application/x-ace-compressed":{source:"apache",extensions:["ace"]},"application/x-amf":{source:"apache"},"application/x-apple-diskimage":{source:"apache",extensions:["dmg"]},"application/x-arj":{compressible:!1,extensions:["arj"]},"application/x-authorware-bin":{source:"apache",extensions:["aab","x32","u32","vox"]},"application/x-authorware-map":{source:"apache",extensions:["aam"]},"application/x-authorware-seg":{source:"apache",extensions:["aas"]},"application/x-bcpio":{source:"apache",extensions:["bcpio"]},"application/x-bdoc":{compressible:!1,extensions:["bdoc"]},"application/x-bittorrent":{source:"apache",extensions:["torrent"]},"application/x-blorb":{source:"apache",extensions:["blb","blorb"]},"application/x-bzip":{source:"apache",compressible:!1,extensions:["bz"]},"application/x-bzip2":{source:"apache",compressible:!1,extensions:["bz2","boz"]},"application/x-cbr":{source:"apache",extensions:["cbr","cba","cbt","cbz","cb7"]},"application/x-cdlink":{source:"apache",extensions:["vcd"]},"application/x-cfs-compressed":{source:"apache",extensions:["cfs"]},"application/x-chat":{source:"apache",extensions:["chat"]},"application/x-chess-pgn":{source:"apache",extensions:["pgn"]},"application/x-chrome-extension":{extensions:["crx"]},"application/x-cocoa":{source:"nginx",extensions:["cco"]},"application/x-compress":{source:"apache"},"application/x-conference":{source:"apache",extensions:["nsc"]},"application/x-cpio":{source:"apache",extensions:["cpio"]},"application/x-csh":{source:"apache",extensions:["csh"]},"application/x-deb":{compressible:!1},"application/x-debian-package":{source:"apache",extensions:["deb","udeb"]},"application/x-dgc-compressed":{source:"apache",extensions:["dgc"]},"application/x-director":{source:"apache",extensions:["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"]},"application/x-doom":{source:"apache",extensions:["wad"]},"application/x-dtbncx+xml":{source:"apache",extensions:["ncx"]},"application/x-dtbook+xml":{source:"apache",extensions:["dtb"]},"application/x-dtbresource+xml":{source:"apache",extensions:["res"]},"application/x-dvi":{source:"apache",compressible:!1,extensions:["dvi"]},"application/x-envoy":{source:"apache",extensions:["evy"]},"application/x-eva":{source:"apache",extensions:["eva"]},"application/x-font-bdf":{source:"apache",extensions:["bdf"]},"application/x-font-dos":{source:"apache"},"application/x-font-framemaker":{source:"apache"},"application/x-font-ghostscript":{source:"apache",extensions:["gsf"]},"application/x-font-libgrx":{source:"apache"},"application/x-font-linux-psf":{source:"apache",extensions:["psf"]},"application/x-font-otf":{source:"apache",compressible:!0,extensions:["otf"]},"application/x-font-pcf":{source:"apache",extensions:["pcf"]},"application/x-font-snf":{source:"apache",extensions:["snf"]},"application/x-font-speedo":{source:"apache"},"application/x-font-sunos-news":{source:"apache"},"application/x-font-ttf":{source:"apache",compressible:!0,extensions:["ttf","ttc"]},"application/x-font-type1":{source:"apache",extensions:["pfa","pfb","pfm","afm"]},"application/x-font-vfont":{source:"apache"},"application/x-freearc":{source:"apache",extensions:["arc"]},"application/x-futuresplash":{source:"apache",extensions:["spl"]},"application/x-gca-compressed":{source:"apache",extensions:["gca"]},"application/x-glulx":{source:"apache",extensions:["ulx"]},"application/x-gnumeric":{source:"apache",extensions:["gnumeric"]},"application/x-gramps-xml":{source:"apache",extensions:["gramps"]},"application/x-gtar":{source:"apache",extensions:["gtar"]},"application/x-gzip":{source:"apache"},"application/x-hdf":{source:"apache",extensions:["hdf"]},"application/x-httpd-php":{compressible:!0,extensions:["php"]},"application/x-install-instructions":{source:"apache",extensions:["install"]},"application/x-iso9660-image":{source:"apache",extensions:["iso"]},"application/x-java-archive-diff":{source:"nginx",extensions:["jardiff"]},"application/x-java-jnlp-file":{source:"apache",compressible:!1,extensions:["jnlp"]},"application/x-javascript":{compressible:!0},"application/x-latex":{source:"apache",compressible:!1,extensions:["latex"]},"application/x-lua-bytecode":{extensions:["luac"]},"application/x-lzh-compressed":{source:"apache",extensions:["lzh","lha"]},"application/x-makeself":{source:"nginx",extensions:["run"]},"application/x-mie":{source:"apache",extensions:["mie"]},"application/x-mobipocket-ebook":{source:"apache",extensions:["prc","mobi"]},"application/x-mpegurl":{compressible:!1},"application/x-ms-application":{source:"apache",extensions:["application"]},"application/x-ms-shortcut":{source:"apache",extensions:["lnk"]},"application/x-ms-wmd":{source:"apache",extensions:["wmd"]},"application/x-ms-wmz":{source:"apache",extensions:["wmz"]},"application/x-ms-xbap":{source:"apache",extensions:["xbap"]},"application/x-msaccess":{source:"apache",extensions:["mdb"]},"application/x-msbinder":{source:"apache",extensions:["obd"]},"application/x-mscardfile":{source:"apache",extensions:["crd"]},"application/x-msclip":{source:"apache",extensions:["clp"]},"application/x-msdos-program":{extensions:["exe"]},"application/x-msdownload":{source:"apache",extensions:["exe","dll","com","bat","msi"]},"application/x-msmediaview":{source:"apache",extensions:["mvb","m13","m14"]},"application/x-msmetafile":{source:"apache",extensions:["wmf","wmz","emf","emz"]},"application/x-msmoney":{source:"apache",extensions:["mny"]},"application/x-mspublisher":{source:"apache",extensions:["pub"]},"application/x-msschedule":{source:"apache",extensions:["scd"]},"application/x-msterminal":{source:"apache",extensions:["trm"]},"application/x-mswrite":{source:"apache",extensions:["wri"]},"application/x-netcdf":{source:"apache",extensions:["nc","cdf"]},"application/x-ns-proxy-autoconfig":{compressible:!0,extensions:["pac"]},"application/x-nzb":{source:"apache",extensions:["nzb"]},"application/x-perl":{source:"nginx",extensions:["pl","pm"]},"application/x-pilot":{source:"nginx",extensions:["prc","pdb"]},"application/x-pkcs12":{source:"apache",compressible:!1,extensions:["p12","pfx"]},"application/x-pkcs7-certificates":{source:"apache",extensions:["p7b","spc"]},"application/x-pkcs7-certreqresp":{source:"apache",extensions:["p7r"]},"application/x-rar-compressed":{source:"apache",compressible:!1,extensions:["rar"]},"application/x-redhat-package-manager":{source:"nginx",extensions:["rpm"]},"application/x-research-info-systems":{source:"apache",extensions:["ris"]},"application/x-sea":{source:"nginx",extensions:["sea"]},"application/x-sh":{source:"apache",compressible:!0,extensions:["sh"]},"application/x-shar":{source:"apache",extensions:["shar"]},"application/x-shockwave-flash":{source:"apache",compressible:!1,extensions:["swf"]},"application/x-silverlight-app":{source:"apache",extensions:["xap"]},"application/x-sql":{source:"apache",extensions:["sql"]},"application/x-stuffit":{source:"apache",compressible:!1,extensions:["sit"]},"application/x-stuffitx":{source:"apache",extensions:["sitx"]},"application/x-subrip":{source:"apache",extensions:["srt"]},"application/x-sv4cpio":{source:"apache",extensions:["sv4cpio"]},"application/x-sv4crc":{source:"apache",extensions:["sv4crc"]},"application/x-t3vm-image":{source:"apache",extensions:["t3"]},"application/x-tads":{source:"apache",extensions:["gam"]},"application/x-tar":{source:"apache",compressible:!0,extensions:["tar"]},"application/x-tcl":{source:"apache",extensions:["tcl","tk"]},"application/x-tex":{source:"apache",extensions:["tex"]},"application/x-tex-tfm":{source:"apache",extensions:["tfm"]},"application/x-texinfo":{source:"apache",extensions:["texinfo","texi"]},"application/x-tgif":{source:"apache",extensions:["obj"]},"application/x-ustar":{source:"apache",extensions:["ustar"]},"application/x-virtualbox-hdd":{compressible:!0,extensions:["hdd"]},"application/x-virtualbox-ova":{compressible:!0,extensions:["ova"]},"application/x-virtualbox-ovf":{compressible:!0,extensions:["ovf"]},"application/x-virtualbox-vbox":{compressible:!0,extensions:["vbox"]},"application/x-virtualbox-vbox-extpack":{compressible:!1,extensions:["vbox-extpack"]},"application/x-virtualbox-vdi":{compressible:!0,extensions:["vdi"]},"application/x-virtualbox-vhd":{compressible:!0,extensions:["vhd"]},"application/x-virtualbox-vmdk":{compressible:!0,extensions:["vmdk"]},"application/x-wais-source":{source:"apache",extensions:["src"]},"application/x-web-app-manifest+json":{compressible:!0,extensions:["webapp"]},"application/x-www-form-urlencoded":{source:"iana",compressible:!0},"application/x-x509-ca-cert":{source:"apache",extensions:["der","crt","pem"]},"application/x-xfig":{source:"apache",extensions:["fig"]},"application/x-xliff+xml":{source:"apache",extensions:["xlf"]},"application/x-xpinstall":{source:"apache",compressible:!1,extensions:["xpi"]},"application/x-xz":{source:"apache",extensions:["xz"]},"application/x-zmachine":{source:"apache",extensions:["z1","z2","z3","z4","z5","z6","z7","z8"]},"application/x400-bp":{source:"iana"},"application/xacml+xml":{source:"iana"},"application/xaml+xml":{source:"apache",extensions:["xaml"]},"application/xcap-att+xml":{source:"iana"},"application/xcap-caps+xml":{source:"iana"},"application/xcap-diff+xml":{source:"iana",extensions:["xdf"]},"application/xcap-el+xml":{source:"iana"},"application/xcap-error+xml":{source:"iana"},"application/xcap-ns+xml":{source:"iana"},"application/xcon-conference-info+xml":{source:"iana"},"application/xcon-conference-info-diff+xml":{source:"iana"},"application/xenc+xml":{source:"iana",extensions:["xenc"]},"application/xhtml+xml":{source:"iana",compressible:!0,extensions:["xhtml","xht"]},"application/xhtml-voice+xml":{source:"apache"},"application/xml":{source:"iana",compressible:!0,extensions:["xml","xsl","xsd","rng"]},"application/xml-dtd":{source:"iana",compressible:!0,extensions:["dtd"]},"application/xml-external-parsed-entity":{source:"iana"},"application/xml-patch+xml":{source:"iana"},"application/xmpp+xml":{source:"iana"},"application/xop+xml":{source:"iana",compressible:!0,extensions:["xop"]},"application/xproc+xml":{source:"apache",extensions:["xpl"]},"application/xslt+xml":{source:"iana",extensions:["xslt"]},"application/xspf+xml":{source:"apache",extensions:["xspf"]},"application/xv+xml":{source:"iana",extensions:["mxml","xhvml","xvml","xvm"]},"application/yang":{source:"iana",extensions:["yang"]},"application/yang-data+json":{source:"iana",compressible:!0},"application/yang-data+xml":{source:"iana"},"application/yang-patch+json":{source:"iana",compressible:!0},"application/yang-patch+xml":{source:"iana"},"application/yin+xml":{source:"iana",extensions:["yin"]},"application/zip":{source:"iana",compressible:!1,extensions:["zip"]},"application/zlib":{source:"iana"},"audio/1d-interleaved-parityfec":{source:"iana"},"audio/32kadpcm":{source:"iana"},"audio/3gpp":{source:"iana",compressible:!1,extensions:["3gpp"]},"audio/3gpp2":{source:"iana"},"audio/ac3":{source:"iana"},"audio/adpcm":{source:"apache",extensions:["adp"]},"audio/amr":{source:"iana"},"audio/amr-wb":{source:"iana"},"audio/amr-wb+":{source:"iana"},"audio/aptx":{source:"iana"},"audio/asc":{source:"iana"},"audio/atrac-advanced-lossless":{source:"iana"},"audio/atrac-x":{source:"iana"},"audio/atrac3":{source:"iana"},"audio/basic":{source:"iana",compressible:!1,extensions:["au","snd"]},"audio/bv16":{source:"iana"},"audio/bv32":{source:"iana"},"audio/clearmode":{source:"iana"},"audio/cn":{source:"iana"},"audio/dat12":{source:"iana"},"audio/dls":{source:"iana"},"audio/dsr-es201108":{source:"iana"},"audio/dsr-es202050":{source:"iana"},"audio/dsr-es202211":{source:"iana"},"audio/dsr-es202212":{source:"iana"},"audio/dv":{source:"iana"},"audio/dvi4":{source:"iana"},"audio/eac3":{source:"iana"},"audio/encaprtp":{source:"iana"},"audio/evrc":{source:"iana"},"audio/evrc-qcp":{source:"iana"},"audio/evrc0":{source:"iana"},"audio/evrc1":{source:"iana"},"audio/evrcb":{source:"iana"},"audio/evrcb0":{source:"iana"},"audio/evrcb1":{source:"iana"},"audio/evrcnw":{source:"iana"},"audio/evrcnw0":{source:"iana"},"audio/evrcnw1":{source:"iana"},"audio/evrcwb":{source:"iana"},"audio/evrcwb0":{source:"iana"},"audio/evrcwb1":{source:"iana"},"audio/evs":{source:"iana"},"audio/fwdred":{source:"iana"},"audio/g711-0":{source:"iana"},"audio/g719":{source:"iana"},"audio/g722":{source:"iana"},"audio/g7221":{source:"iana"},"audio/g723":{source:"iana"},"audio/g726-16":{source:"iana"},"audio/g726-24":{source:"iana"},"audio/g726-32":{source:"iana"},"audio/g726-40":{source:"iana"},"audio/g728":{source:"iana"},"audio/g729":{source:"iana"},"audio/g7291":{source:"iana"},"audio/g729d":{source:"iana"},"audio/g729e":{source:"iana"},"audio/gsm":{source:"iana"},"audio/gsm-efr":{source:"iana"},"audio/gsm-hr-08":{source:"iana"},"audio/ilbc":{source:"iana"},"audio/ip-mr_v2.5":{source:"iana"},"audio/isac":{source:"apache"},"audio/l16":{source:"iana"},"audio/l20":{source:"iana"},"audio/l24":{source:"iana",compressible:!1},"audio/l8":{source:"iana"},"audio/lpc":{source:"iana"},"audio/melp":{source:"iana"},"audio/melp1200":{source:"iana"},"audio/melp2400":{source:"iana"},"audio/melp600":{source:"iana"},"audio/midi":{source:"apache",extensions:["mid","midi","kar","rmi"]},"audio/mobile-xmf":{source:"iana"},"audio/mp3":{compressible:!1,extensions:["mp3"]},"audio/mp4":{source:"iana",compressible:!1,extensions:["m4a","mp4a"]},"audio/mp4a-latm":{source:"iana"},"audio/mpa":{source:"iana"},"audio/mpa-robust":{source:"iana"},"audio/mpeg":{source:"iana",compressible:!1,extensions:["mpga","mp2","mp2a","mp3","m2a","m3a"]},"audio/mpeg4-generic":{source:"iana"},"audio/musepack":{source:"apache"},"audio/ogg":{source:"iana",compressible:!1,extensions:["oga","ogg","spx"]},"audio/opus":{source:"iana"},"audio/parityfec":{source:"iana"},"audio/pcma":{source:"iana"},"audio/pcma-wb":{source:"iana"},"audio/pcmu":{source:"iana"},"audio/pcmu-wb":{source:"iana"},"audio/prs.sid":{source:"iana"},"audio/qcelp":{source:"iana"},"audio/raptorfec":{source:"iana"},"audio/red":{source:"iana"},"audio/rtp-enc-aescm128":{source:"iana"},"audio/rtp-midi":{source:"iana"},"audio/rtploopback":{source:"iana"},"audio/rtx":{source:"iana"},"audio/s3m":{source:"apache",extensions:["s3m"]},"audio/silk":{source:"apache",extensions:["sil"]},"audio/smv":{source:"iana"},"audio/smv-qcp":{source:"iana"},"audio/smv0":{source:"iana"},"audio/sp-midi":{source:"iana"},"audio/speex":{source:"iana"},"audio/t140c":{source:"iana"},"audio/t38":{source:"iana"},"audio/telephone-event":{source:"iana"},"audio/tone":{source:"iana"},"audio/uemclip":{source:"iana"},"audio/ulpfec":{source:"iana"},"audio/vdvi":{source:"iana"},"audio/vmr-wb":{source:"iana"},"audio/vnd.3gpp.iufp":{source:"iana"},"audio/vnd.4sb":{source:"iana"},"audio/vnd.audiokoz":{source:"iana"},"audio/vnd.celp":{source:"iana"},"audio/vnd.cisco.nse":{source:"iana"},"audio/vnd.cmles.radio-events":{source:"iana"},"audio/vnd.cns.anp1":{source:"iana"},"audio/vnd.cns.inf1":{source:"iana"},"audio/vnd.dece.audio":{source:"iana",extensions:["uva","uvva"]},"audio/vnd.digital-winds":{source:"iana",extensions:["eol"]},"audio/vnd.dlna.adts":{source:"iana"},"audio/vnd.dolby.heaac.1":{source:"iana"},"audio/vnd.dolby.heaac.2":{source:"iana"},"audio/vnd.dolby.mlp":{source:"iana"},"audio/vnd.dolby.mps":{source:"iana"},"audio/vnd.dolby.pl2":{source:"iana"},"audio/vnd.dolby.pl2x":{source:"iana"},"audio/vnd.dolby.pl2z":{source:"iana"},"audio/vnd.dolby.pulse.1":{source:"iana"},"audio/vnd.dra":{source:"iana",extensions:["dra"]},"audio/vnd.dts":{source:"iana",extensions:["dts"]},"audio/vnd.dts.hd":{source:"iana",extensions:["dtshd"]},"audio/vnd.dvb.file":{source:"iana"},"audio/vnd.everad.plj":{source:"iana"},"audio/vnd.hns.audio":{source:"iana"},"audio/vnd.lucent.voice":{source:"iana",extensions:["lvp"]},"audio/vnd.ms-playready.media.pya":{source:"iana",extensions:["pya"]},"audio/vnd.nokia.mobile-xmf":{source:"iana"},"audio/vnd.nortel.vbk":{source:"iana"},"audio/vnd.nuera.ecelp4800":{source:"iana",extensions:["ecelp4800"]},"audio/vnd.nuera.ecelp7470":{source:"iana",extensions:["ecelp7470"]},"audio/vnd.nuera.ecelp9600":{source:"iana",extensions:["ecelp9600"]},"audio/vnd.octel.sbc":{source:"iana"},"audio/vnd.presonus.multitrack":{source:"iana"},"audio/vnd.qcelp":{source:"iana"},"audio/vnd.rhetorex.32kadpcm":{source:"iana"},"audio/vnd.rip":{source:"iana",extensions:["rip"]},"audio/vnd.rn-realaudio":{compressible:!1},"audio/vnd.sealedmedia.softseal.mpeg":{source:"iana"},"audio/vnd.vmx.cvsd":{source:"iana"},"audio/vnd.wave":{compressible:!1},"audio/vorbis":{source:"iana",compressible:!1},"audio/vorbis-config":{source:"iana"},"audio/wav":{compressible:!1,extensions:["wav"]},"audio/wave":{compressible:!1,extensions:["wav"]},"audio/webm":{source:"apache",compressible:!1,extensions:["weba"]},"audio/x-aac":{source:"apache",compressible:!1,extensions:["aac"]},"audio/x-aiff":{source:"apache",extensions:["aif","aiff","aifc"]},"audio/x-caf":{source:"apache",compressible:!1,extensions:["caf"]},"audio/x-flac":{source:"apache",extensions:["flac"]},"audio/x-m4a":{source:"nginx",extensions:["m4a"]},"audio/x-matroska":{source:"apache",extensions:["mka"]},"audio/x-mpegurl":{source:"apache",extensions:["m3u"]},"audio/x-ms-wax":{source:"apache",extensions:["wax"]},"audio/x-ms-wma":{source:"apache",extensions:["wma"]},"audio/x-pn-realaudio":{source:"apache",extensions:["ram","ra"]},"audio/x-pn-realaudio-plugin":{source:"apache",extensions:["rmp"]},"audio/x-realaudio":{source:"nginx",extensions:["ra"]},"audio/x-tta":{source:"apache"},"audio/x-wav":{source:"apache",extensions:["wav"]},"audio/xm":{source:"apache",extensions:["xm"]},"chemical/x-cdx":{source:"apache",extensions:["cdx"]},"chemical/x-cif":{source:"apache",extensions:["cif"]},"chemical/x-cmdf":{source:"apache",extensions:["cmdf"]},"chemical/x-cml":{source:"apache",extensions:["cml"]},"chemical/x-csml":{source:"apache",extensions:["csml"]},"chemical/x-pdb":{source:"apache"},"chemical/x-xyz":{source:"apache",extensions:["xyz"]},"font/otf":{compressible:!0,extensions:["otf"]},"image/apng":{compressible:!1,extensions:["apng"]},"image/bmp":{source:"iana",compressible:!0,extensions:["bmp"]},"image/cgm":{source:"iana",extensions:["cgm"]},"image/dicom-rle":{source:"iana"},"image/emf":{source:"iana"},"image/fits":{source:"iana"},"image/g3fax":{source:"iana",extensions:["g3"]},"image/gif":{source:"iana",compressible:!1,extensions:["gif"]},"image/ief":{source:"iana",extensions:["ief"]},"image/jls":{source:"iana"},"image/jp2":{source:"iana"},"image/jpeg":{source:"iana",compressible:!1,extensions:["jpeg","jpg","jpe"]},"image/jpm":{source:"iana"},"image/jpx":{source:"iana"},"image/ktx":{source:"iana",extensions:["ktx"]},"image/naplps":{source:"iana"},"image/pjpeg":{compressible:!1},"image/png":{source:"iana",compressible:!1,extensions:["png"]},"image/prs.btif":{source:"iana",extensions:["btif"]},"image/prs.pti":{source:"iana"},"image/pwg-raster":{source:"iana"},"image/sgi":{source:"apache",extensions:["sgi"]},"image/svg+xml":{source:"iana",compressible:!0,extensions:["svg","svgz"]},"image/t38":{source:"iana"},"image/tiff":{source:"iana",compressible:!1,extensions:["tiff","tif"]},"image/tiff-fx":{source:"iana"},"image/vnd.adobe.photoshop":{source:"iana",compressible:!0,extensions:["psd"]},"image/vnd.airzip.accelerator.azv":{source:"iana"},"image/vnd.cns.inf2":{source:"iana"},"image/vnd.dece.graphic":{source:"iana",extensions:["uvi","uvvi","uvg","uvvg"]},"image/vnd.djvu":{source:"iana",extensions:["djvu","djv"]},"image/vnd.dvb.subtitle":{source:"iana",extensions:["sub"]},"image/vnd.dwg":{source:"iana",extensions:["dwg"]},"image/vnd.dxf":{source:"iana",extensions:["dxf"]},"image/vnd.fastbidsheet":{source:"iana",extensions:["fbs"]},"image/vnd.fpx":{source:"iana",extensions:["fpx"]},"image/vnd.fst":{source:"iana",extensions:["fst"]},"image/vnd.fujixerox.edmics-mmr":{source:"iana",extensions:["mmr"]},"image/vnd.fujixerox.edmics-rlc":{source:"iana",extensions:["rlc"]},"image/vnd.globalgraphics.pgb":{source:"iana"},"image/vnd.microsoft.icon":{source:"iana"},"image/vnd.mix":{source:"iana"},"image/vnd.mozilla.apng":{source:"iana"},"image/vnd.ms-modi":{source:"iana",extensions:["mdi"]},"image/vnd.ms-photo":{source:"apache",extensions:["wdp"]},"image/vnd.net-fpx":{source:"iana",extensions:["npx"]},"image/vnd.radiance":{source:"iana"},"image/vnd.sealed.png":{source:"iana"},"image/vnd.sealedmedia.softseal.gif":{source:"iana"},"image/vnd.sealedmedia.softseal.jpg":{source:"iana"},"image/vnd.svf":{source:"iana"},"image/vnd.tencent.tap":{source:"iana"},"image/vnd.valve.source.texture":{source:"iana"},"image/vnd.wap.wbmp":{source:"iana",extensions:["wbmp"]},"image/vnd.xiff":{source:"iana",extensions:["xif"]},"image/vnd.zbrush.pcx":{source:"iana"},"image/webp":{source:"apache",extensions:["webp"]},"image/wmf":{source:"iana"},"image/x-3ds":{source:"apache",extensions:["3ds"]},"image/x-cmu-raster":{source:"apache",extensions:["ras"]},"image/x-cmx":{source:"apache",extensions:["cmx"]},"image/x-freehand":{source:"apache",extensions:["fh","fhc","fh4","fh5","fh7"]},"image/x-icon":{source:"apache",compressible:!0,extensions:["ico"]},"image/x-jng":{source:"nginx",extensions:["jng"]},"image/x-mrsid-image":{source:"apache",extensions:["sid"]},"image/x-ms-bmp":{source:"nginx",compressible:!0,extensions:["bmp"]},"image/x-pcx":{source:"apache",extensions:["pcx"]},"image/x-pict":{source:"apache",extensions:["pic","pct"]},"image/x-portable-anymap":{source:"apache",extensions:["pnm"]},"image/x-portable-bitmap":{source:"apache",extensions:["pbm"]},"image/x-portable-graymap":{source:"apache",extensions:["pgm"]},"image/x-portable-pixmap":{source:"apache",extensions:["ppm"]},"image/x-rgb":{source:"apache",extensions:["rgb"]},"image/x-tga":{source:"apache",extensions:["tga"]},"image/x-xbitmap":{source:"apache",extensions:["xbm"]},"image/x-xcf":{compressible:!1},"image/x-xpixmap":{source:"apache",extensions:["xpm"]},"image/x-xwindowdump":{source:"apache",extensions:["xwd"]},"message/cpim":{source:"iana"},"message/delivery-status":{source:"iana"},"message/disposition-notification":{source:"iana"},"message/external-body":{source:"iana"},"message/feedback-report":{source:"iana"},"message/global":{source:"iana"},"message/global-delivery-status":{source:"iana"},"message/global-disposition-notification":{source:"iana"},"message/global-headers":{source:"iana"},"message/http":{source:"iana",compressible:!1},"message/imdn+xml":{source:"iana",compressible:!0},"message/news":{source:"iana"},"message/partial":{source:"iana",compressible:!1},"message/rfc822":{source:"iana",compressible:!0,extensions:["eml","mime"]},"message/s-http":{source:"iana"},"message/sip":{source:"iana"},"message/sipfrag":{source:"iana"},"message/tracking-status":{source:"iana"},"message/vnd.si.simp":{source:"iana"},"message/vnd.wfa.wsc":{source:"iana"},"model/3mf":{source:"iana"},"model/gltf+json":{source:"iana",compressible:!0,extensions:["gltf"]},"model/gltf-binary":{compressible:!0,extensions:["glb"]},"model/iges":{source:"iana",compressible:!1,extensions:["igs","iges"]},"model/mesh":{source:"iana",compressible:!1,extensions:["msh","mesh","silo"]},"model/vnd.collada+xml":{source:"iana",extensions:["dae"]},"model/vnd.dwf":{source:"iana",extensions:["dwf"]},"model/vnd.flatland.3dml":{source:"iana"},"model/vnd.gdl":{source:"iana",extensions:["gdl"]},"model/vnd.gs-gdl":{source:"apache"},"model/vnd.gs.gdl":{source:"iana"},"model/vnd.gtw":{source:"iana",extensions:["gtw"]},"model/vnd.moml+xml":{source:"iana"},"model/vnd.mts":{source:"iana",extensions:["mts"]},"model/vnd.opengex":{source:"iana"},"model/vnd.parasolid.transmit.binary":{source:"iana"},"model/vnd.parasolid.transmit.text":{source:"iana"},"model/vnd.rosette.annotated-data-model":{source:"iana"},"model/vnd.valve.source.compiled-map":{source:"iana"},"model/vnd.vtu":{source:"iana",extensions:["vtu"]},"model/vrml":{source:"iana",compressible:!1,extensions:["wrl","vrml"]},"model/x3d+binary":{source:"apache",compressible:!1,extensions:["x3db","x3dbz"]},"model/x3d+fastinfoset":{source:"iana"},"model/x3d+vrml":{source:"apache",compressible:!1,extensions:["x3dv","x3dvz"]},"model/x3d+xml":{source:"iana",compressible:!0,extensions:["x3d","x3dz"]},"model/x3d-vrml":{source:"iana"},"multipart/alternative":{source:"iana",compressible:!1},"multipart/appledouble":{source:"iana"},"multipart/byteranges":{source:"iana"},"multipart/digest":{source:"iana"},"multipart/encrypted":{source:"iana",compressible:!1},"multipart/form-data":{source:"iana",compressible:!1},"multipart/header-set":{source:"iana"},"multipart/mixed":{source:"iana",compressible:!1},"multipart/parallel":{source:"iana"},"multipart/related":{source:"iana",compressible:!1},"multipart/report":{source:"iana"},"multipart/signed":{source:"iana",compressible:!1},"multipart/vnd.bint.med-plus":{source:"iana"},"multipart/voice-message":{source:"iana"},"multipart/x-mixed-replace":{source:"iana"},"text/1d-interleaved-parityfec":{source:"iana"},"text/cache-manifest":{source:"iana",compressible:!0,extensions:["appcache","manifest"]},"text/calendar":{source:"iana",extensions:["ics","ifb"]},"text/calender":{compressible:!0},"text/cmd":{compressible:!0},"text/coffeescript":{extensions:["coffee","litcoffee"]},"text/css":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["css"]},"text/csv":{source:"iana",compressible:!0,extensions:["csv"]},"text/csv-schema":{source:"iana"},"text/directory":{source:"iana"},"text/dns":{source:"iana"},"text/ecmascript":{source:"iana"},"text/encaprtp":{source:"iana"},"text/enriched":{source:"iana"},"text/fwdred":{source:"iana"},"text/grammar-ref-list":{source:"iana"},"text/hjson":{extensions:["hjson"]},"text/html":{source:"iana",compressible:!0,extensions:["html","htm","shtml"]},"text/jade":{extensions:["jade"]},"text/javascript":{source:"iana",compressible:!0},"text/jcr-cnd":{source:"iana"},"text/jsx":{compressible:!0,extensions:["jsx"]},"text/less":{extensions:["less"]},"text/markdown":{source:"iana",compressible:!0,extensions:["markdown","md"]},"text/mathml":{source:"nginx",extensions:["mml"]},"text/mizar":{source:"iana"},"text/n3":{source:"iana",compressible:!0,extensions:["n3"]},"text/parameters":{source:"iana"},"text/parityfec":{source:"iana"},"text/plain":{source:"iana",compressible:!0,extensions:["txt","text","conf","def","list","log","in","ini"]},"text/provenance-notation":{source:"iana"},"text/prs.fallenstein.rst":{source:"iana"},"text/prs.lines.tag":{source:"iana",extensions:["dsc"]},"text/prs.prop.logic":{source:"iana"},"text/raptorfec":{source:"iana"},"text/red":{source:"iana"},"text/rfc822-headers":{source:"iana"},"text/richtext":{source:"iana",compressible:!0,extensions:["rtx"]},"text/rtf":{source:"iana",compressible:!0,extensions:["rtf"]},"text/rtp-enc-aescm128":{source:"iana"},"text/rtploopback":{source:"iana"},"text/rtx":{source:"iana"},"text/sgml":{source:"iana",extensions:["sgml","sgm"]},"text/slim":{extensions:["slim","slm"]},"text/strings":{source:"iana"},"text/stylus":{extensions:["stylus","styl"]},"text/t140":{source:"iana"},"text/tab-separated-values":{source:"iana",compressible:!0,extensions:["tsv"]},"text/troff":{source:"iana",extensions:["t","tr","roff","man","me","ms"]},"text/turtle":{source:"iana",extensions:["ttl"]},"text/ulpfec":{source:"iana"},"text/uri-list":{source:"iana",compressible:!0,extensions:["uri","uris","urls"]},"text/vcard":{source:"iana",compressible:!0,extensions:["vcard"]},"text/vnd.a":{source:"iana"},"text/vnd.abc":{source:"iana"},"text/vnd.ascii-art":{source:"iana"},"text/vnd.curl":{source:"iana",extensions:["curl"]},"text/vnd.curl.dcurl":{source:"apache",extensions:["dcurl"]},"text/vnd.curl.mcurl":{source:"apache",extensions:["mcurl"]},"text/vnd.curl.scurl":{source:"apache",extensions:["scurl"]},"text/vnd.debian.copyright":{source:"iana"},"text/vnd.dmclientscript":{source:"iana"},"text/vnd.dvb.subtitle":{source:"iana",extensions:["sub"]},"text/vnd.esmertec.theme-descriptor":{source:"iana"},"text/vnd.fly":{source:"iana",extensions:["fly"]},"text/vnd.fmi.flexstor":{source:"iana",extensions:["flx"]},"text/vnd.graphviz":{source:"iana",extensions:["gv"]},"text/vnd.in3d.3dml":{source:"iana",extensions:["3dml"]},"text/vnd.in3d.spot":{source:"iana",extensions:["spot"]},"text/vnd.iptc.newsml":{source:"iana"},"text/vnd.iptc.nitf":{source:"iana"},"text/vnd.latex-z":{source:"iana"},"text/vnd.motorola.reflex":{source:"iana"},"text/vnd.ms-mediapackage":{source:"iana"},"text/vnd.net2phone.commcenter.command":{source:"iana"},"text/vnd.radisys.msml-basic-layout":{source:"iana"},"text/vnd.si.uricatalogue":{source:"iana"},"text/vnd.sun.j2me.app-descriptor":{source:"iana",extensions:["jad"]},"text/vnd.trolltech.linguist":{source:"iana"},"text/vnd.wap.si":{source:"iana"},"text/vnd.wap.sl":{source:"iana"},"text/vnd.wap.wml":{source:"iana",extensions:["wml"]},"text/vnd.wap.wmlscript":{source:"iana",extensions:["wmls"]},"text/vtt":{charset:"UTF-8",compressible:!0,extensions:["vtt"]},"text/x-asm":{source:"apache",extensions:["s","asm"]},"text/x-c":{source:"apache",extensions:["c","cc","cxx","cpp","h","hh","dic"]},"text/x-component":{source:"nginx",extensions:["htc"]},"text/x-fortran":{source:"apache",extensions:["f","for","f77","f90"]},"text/x-gwt-rpc":{compressible:!0},"text/x-handlebars-template":{extensions:["hbs"]},"text/x-java-source":{source:"apache",extensions:["java"]},"text/x-jquery-tmpl":{compressible:!0},"text/x-lua":{extensions:["lua"]},"text/x-markdown":{compressible:!0,extensions:["mkd"]},"text/x-nfo":{source:"apache",extensions:["nfo"]},"text/x-opml":{source:"apache",extensions:["opml"]},"text/x-org":{compressible:!0,extensions:["org"]},"text/x-pascal":{source:"apache",extensions:["p","pas"]},"text/x-processing":{compressible:!0,extensions:["pde"]},"text/x-sass":{extensions:["sass"]},"text/x-scss":{extensions:["scss"]},"text/x-setext":{source:"apache",extensions:["etx"]},"text/x-sfv":{source:"apache",extensions:["sfv"]},"text/x-suse-ymp":{compressible:!0,extensions:["ymp"]},"text/x-uuencode":{source:"apache",extensions:["uu"]},"text/x-vcalendar":{source:"apache",extensions:["vcs"]},"text/x-vcard":{source:"apache",extensions:["vcf"]},"text/xml":{source:"iana",compressible:!0,extensions:["xml"]},"text/xml-external-parsed-entity":{source:"iana"},"text/yaml":{extensions:["yaml","yml"]},"video/1d-interleaved-parityfec":{source:"iana"},"video/3gpp":{source:"iana",extensions:["3gp","3gpp"]},"video/3gpp-tt":{source:"iana"},"video/3gpp2":{source:"iana",extensions:["3g2"]},"video/bmpeg":{source:"iana"},"video/bt656":{source:"iana"},"video/celb":{source:"iana"},"video/dv":{source:"iana"},"video/encaprtp":{source:"iana"},"video/h261":{source:"iana",extensions:["h261"]},"video/h263":{source:"iana",extensions:["h263"]},"video/h263-1998":{source:"iana"},"video/h263-2000":{source:"iana"},"video/h264":{source:"iana",extensions:["h264"]},"video/h264-rcdo":{source:"iana"},"video/h264-svc":{source:"iana"},"video/h265":{source:"iana"},"video/iso.segment":{source:"iana"},"video/jpeg":{source:"iana",extensions:["jpgv"]},"video/jpeg2000":{source:"iana"},"video/jpm":{source:"apache",extensions:["jpm","jpgm"]},"video/mj2":{source:"iana",extensions:["mj2","mjp2"]},"video/mp1s":{source:"iana"},"video/mp2p":{source:"iana"},"video/mp2t":{source:"iana",extensions:["ts"]},"video/mp4":{source:"iana",compressible:!1,extensions:["mp4","mp4v","mpg4"]},"video/mp4v-es":{source:"iana"},"video/mpeg":{source:"iana",compressible:!1,extensions:["mpeg","mpg","mpe","m1v","m2v"]},"video/mpeg4-generic":{source:"iana"},"video/mpv":{source:"iana"},"video/nv":{source:"iana"},"video/ogg":{source:"iana",compressible:!1,extensions:["ogv"]},"video/parityfec":{source:"iana"},"video/pointer":{source:"iana"},"video/quicktime":{source:"iana",compressible:!1,extensions:["qt","mov"]},"video/raptorfec":{source:"iana"},"video/raw":{source:"iana"},"video/rtp-enc-aescm128":{source:"iana"},"video/rtploopback":{source:"iana"},"video/rtx":{source:"iana"},"video/smpte292m":{source:"iana"},"video/ulpfec":{source:"iana"},"video/vc1":{source:"iana"},"video/vnd.cctv":{source:"iana"},"video/vnd.dece.hd":{source:"iana",extensions:["uvh","uvvh"]},"video/vnd.dece.mobile":{source:"iana",extensions:["uvm","uvvm"]},"video/vnd.dece.mp4":{source:"iana"},"video/vnd.dece.pd":{source:"iana",extensions:["uvp","uvvp"]},"video/vnd.dece.sd":{source:"iana",extensions:["uvs","uvvs"]},"video/vnd.dece.video":{source:"iana",extensions:["uvv","uvvv"]},"video/vnd.directv.mpeg":{source:"iana"},"video/vnd.directv.mpeg-tts":{source:"iana"},"video/vnd.dlna.mpeg-tts":{source:"iana"},"video/vnd.dvb.file":{source:"iana",extensions:["dvb"]},"video/vnd.fvt":{source:"iana",extensions:["fvt"]},"video/vnd.hns.video":{source:"iana"},"video/vnd.iptvforum.1dparityfec-1010":{source:"iana"},"video/vnd.iptvforum.1dparityfec-2005":{source:"iana"},"video/vnd.iptvforum.2dparityfec-1010":{source:"iana"},"video/vnd.iptvforum.2dparityfec-2005":{source:"iana"},"video/vnd.iptvforum.ttsavc":{source:"iana"},"video/vnd.iptvforum.ttsmpeg2":{source:"iana"},"video/vnd.motorola.video":{source:"iana"},"video/vnd.motorola.videop":{source:"iana"},"video/vnd.mpegurl":{source:"iana",extensions:["mxu","m4u"]},"video/vnd.ms-playready.media.pyv":{source:"iana",extensions:["pyv"]},"video/vnd.nokia.interleaved-multimedia":{source:"iana"},"video/vnd.nokia.videovoip":{source:"iana"},"video/vnd.objectvideo":{source:"iana"},"video/vnd.radgamettools.bink":{source:"iana"},"video/vnd.radgamettools.smacker":{source:"iana"},"video/vnd.sealed.mpeg1":{source:"iana"},"video/vnd.sealed.mpeg4":{source:"iana"},"video/vnd.sealed.swf":{source:"iana"},"video/vnd.sealedmedia.softseal.mov":{source:"iana"},"video/vnd.uvvu.mp4":{source:"iana",extensions:["uvu","uvvu"]},"video/vnd.vivo":{source:"iana",extensions:["viv"]},"video/vp8":{source:"iana"},"video/webm":{source:"apache",compressible:!1,extensions:["webm"]},"video/x-f4v":{source:"apache",extensions:["f4v"]},"video/x-fli":{source:"apache",extensions:["fli"]},"video/x-flv":{source:"apache",compressible:!1,extensions:["flv"]},"video/x-m4v":{source:"apache",extensions:["m4v"]},"video/x-matroska":{source:"apache",compressible:!1,extensions:["mkv","mk3d","mks"]},"video/x-mng":{source:"apache",extensions:["mng"]},"video/x-ms-asf":{source:"apache",extensions:["asf","asx"]},"video/x-ms-vob":{source:"apache",extensions:["vob"]},"video/x-ms-wm":{source:"apache",extensions:["wm"]},"video/x-ms-wmv":{source:"apache",compressible:!1,extensions:["wmv"]},"video/x-ms-wmx":{source:"apache",extensions:["wmx"]},"video/x-ms-wvx":{source:"apache",extensions:["wvx"]},"video/x-msvideo":{source:"apache",extensions:["avi"]},"video/x-sgi-movie":{source:"apache",extensions:["movie"]},"video/x-smv":{source:"apache",extensions:["smv"]},"x-conference/x-cooltalk":{source:"apache",extensions:["ice"]},"x-shader/x-fragment":{compressible:!0},"x-shader/x-vertex":{compressible:!0}}},function(e,t,n){(function(e){function n(e,t){for(var n=0,a=e.length-1;a>=0;a--){var i=e[a];"."===i?e.splice(a,1):".."===i?(e.splice(a,1),n++):n&&(e.splice(a,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function a(e,t){if(e.filter)return e.filter(t);for(var n=[],a=0;a=-1&&!i;r--){var o=r>=0?arguments[r]:e.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(t=o+"/"+t,i="/"===o.charAt(0))}return t=n(a(t.split("/"),function(e){return!!e}),!i).join("/"),(i?"/":"")+t||"."},t.normalize=function(e){var i=t.isAbsolute(e),r="/"===o(e,-1);return e=n(a(e.split("/"),function(e){return!!e}),!i).join("/"),e||i||(e="."),e&&r&&(e+="/"),(i?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(a(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},t.relative=function(e,n){function a(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=t.resolve(e).substr(1),n=t.resolve(n).substr(1);for(var i=a(e.split("/")),r=a(n.split("/")),o=Math.min(i.length,r.length),s=o,c=0;c1)for(var n=1;n=0;a--){var i=e[a];"."===i?e.splice(a,1):".."===i?(e.splice(a,1),n++):n&&(e.splice(a,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function a(e,t){if(e.filter)return e.filter(t);for(var n=[],a=0;a=-1&&!i;r--){var o=r>=0?arguments[r]:e.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(t=o+"/"+t,i="/"===o.charAt(0))}return t=n(a(t.split("/"),function(e){return!!e}),!i).join("/"),(i?"/":"")+t||"."},t.normalize=function(e){var i=t.isAbsolute(e),r="/"===o(e,-1);return e=n(a(e.split("/"),function(e){return!!e}),!i).join("/"),e||i||(e="."),e&&r&&(e+="/"),(i?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(a(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},t.relative=function(e,n){function a(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=t.resolve(e).substr(1),n=t.resolve(n).substr(1);for(var i=a(e.split("/")),r=a(n.split("/")),o=Math.min(i.length,r.length),s=o,c=0;c1)for(var n=1;n var viewer = new QMV.Viewer(document.getElementById('main'), { - shadow: false, + shadow: true, + ambientCubemapLight: { + intensity: 1, + texture: './asset/texture/pisa.hdr' + }, postEffect: { enable: true } - // renderDebugSkeleton: true }); var modelUrl = location.search.slice(1); - viewer.loadModel((modelUrl || 'baidu_asset/dragon/dragon') + '.gltf', { - textureFlipY: true - // shader: 'basic' - }) + viewer.loadModel('./asset/DamagedHelmet/DamagedHelmet.gltf') .on('loadmodel', function (modelStat) { viewer.setCameraControl({ alpha: 20, @@ -84,7 +84,7 @@ lightColor: '#fff', lightAlpha: 45, lightBeta: 45, - ambientIntensity: 0.3 + ambientIntensity: 1 } var gui = new dat.GUI(); @@ -95,15 +95,16 @@ alpha: config.lightAlpha, beta: config.lightBeta }); - viewer.setAmbientLight({ - intensity: config.ambientIntensity + viewer.setAmbientCubemapLight({ + specularIntensity: config.ambientIntensity, + diffuseIntensity: config.ambientIntensity }); } gui.add(config, 'lightIntensity', 0, 4).onChange(updateLight); gui.addColor(config, 'lightColor').onChange(updateLight); gui.add(config, 'lightAlpha', 0, 180).onChange(updateLight); gui.add(config, 'lightBeta', -180, 180).onChange(updateLight); - gui.add(config, 'ambientIntensity', 0, 1).onChange(updateLight); + gui.add(config, 'ambientIntensity', 0, 2).onChange(updateLight); updateLight(); diff --git a/index.js b/index.js index 6b22621..10d9348 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ import Viewer from './src/Viewer'; export { Viewer }; export default { - Viewer: Viewer + Viewer: Viewer, + version: '0.1.0' }; \ No newline at end of file diff --git a/package.json b/package.json index 369008f..8cf7cfb 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,9 @@ "name": "qtek-model-viewer", "version": "0.1.0", "description": "QTEK Model Viewer built on top of WebGL, Supported FBX, DAE, OBJ, glTF2.0 model formats.", - "main": "index.js", + "main": "dist/QMV.js", "dependencies": { - "qtek": "^0.5.0", - "normalize-path": "^2.1.1", + "qtek": "^0.6.0", "zrender": "^3.7.2" }, "devDependencies": { diff --git a/src/graphic/SceneHelper.js b/src/graphic/SceneHelper.js index 7a4746d..87da7a1 100644 --- a/src/graphic/SceneHelper.js +++ b/src/graphic/SceneHelper.js @@ -118,39 +118,41 @@ SceneHelper.prototype = { var self = this; // TODO Change exposure - if (!this._currentCubemapLights || textureUrl !== this._currentCubemapLights.textureUrl) { - if (this._currentCubemapLights) { - this._lightRoot.remove(this._currentCubemapLights.diffuse); - if (this._currentCubemapLights.specular) { - this._lightRoot.remove(this._currentCubemapLights.specular); - this._currentCubemapLights.specular.cubemap.dispose(renderer.gl); + if ('texture' in opts) { + if (!this._currentCubemapLights || textureUrl !== this._currentCubemapLights.textureUrl) { + if (this._currentCubemapLights) { + this._lightRoot.remove(this._currentCubemapLights.diffuse); + if (this._currentCubemapLights.specular) { + this._lightRoot.remove(this._currentCubemapLights.specular); + this._currentCubemapLights.specular.cubemap.dispose(renderer.gl); + } } - } - if (textureUrl) { - var lights = helper.createAmbientCubemap(opts, app, function () { - // Use prefitered cubemap - if (lights.specular && (self._skybox instanceof Skybox)) { - self._skybox.setEnvironmentMap(lights.specular.cubemap); + if (textureUrl) { + var lights = helper.createAmbientCubemap(opts, app, function () { + // Use prefitered cubemap + if (lights.specular && (self._skybox instanceof Skybox)) { + self._skybox.setEnvironmentMap(lights.specular.cubemap); + } + app.refresh(); + }); + if (lights.diffuse) { + this._lightRoot.add(lights.diffuse); } - app.refresh(); - }); - if (lights.diffuse) { - this._lightRoot.add(lights.diffuse); + if (lights.specular) { + this._lightRoot.add(lights.specular); + } + + this._currentCubemapLights = lights; + this._currentCubemapLights.textureUrl = textureUrl; } - if (lights.specular) { - this._lightRoot.add(lights.specular); + else if (this._currentCubemapLights) { + this._lightRoot.remove(this._currentCubemapLights.diffuse); + this._lightRoot.remove(this._currentCubemapLights.specular); + this._currentCubemapLights = null; } - - this._currentCubemapLights = lights; - this._currentCubemapLights.textureUrl = textureUrl; - } - else if (this._currentCubemapLights) { - this._lightRoot.remove(this._currentCubemapLights.diffuse); - this._lightRoot.remove(this._currentCubemapLights.specular); - this._currentCubemapLights = null; } } - + if (this._currentCubemapLights) { if (opts.specularIntensity != null && this._currentCubemapLights.specular) { this._currentCubemapLights.specular.intensity = opts.specularIntensity;