diff --git a/dist/qtek.js b/dist/qtek.js index 8cf7e79ed..536578273 100644 --- a/dist/qtek.js +++ b/dist/qtek.js @@ -360,7 +360,7 @@ return /******/ (function(modules) { // webpackBootstrap var deferredClips = []; for (var i = 0; i < len; i++) { var clip = clips[i]; - var e = clip.step(time, delta); + var e = clip.step(time, delta, false); // Throw out the events need to be called after // stage.render, like finish if (e) { @@ -1712,7 +1712,7 @@ return /******/ (function(modules) { // webpackBootstrap * @param {number} time * @return {string} */ - step: function (time, deltaTime) { + step: function (time, deltaTime, silent) { if (!this._initialized) { this._startTime = time + this.delay; this._initialized = true; @@ -1723,7 +1723,7 @@ return /******/ (function(modules) { // webpackBootstrap this._currentTime = time; if (this._paused) { - return; + return 'paused'; } if (time < this._startTime) { @@ -1746,7 +1746,10 @@ return /******/ (function(modules) { // webpackBootstrap else { schedule = percent; } - this.fire('frame', schedule); + + if (!silent) { + this.fire('frame', schedule); + } if (percent === 1) { if (this._loop && this._loopRemained > 0) { @@ -8044,14 +8047,19 @@ return /******/ (function(modules) { // webpackBootstrap SamplerClip.prototype.constructor = SamplerClip; - SamplerClip.prototype.step = function (time, dTime) { + SamplerClip.prototype.step = function (time, dTime, silent) { - var ret = Clip.prototype.step.call(this, time, dTime); + var ret = Clip.prototype.step.call(this, time, dTime, true); if (ret !== 'finish') { this.setTime(this.getElapsedTime()); } + // PENDING Schedule, puased ? + if (!silent && ret !== 'paused') { + this.fire('frame'); + } + return ret; }; @@ -8062,8 +8070,21 @@ return /******/ (function(modules) { // webpackBootstrap var channels = this.channels; var len = channels.time.length; var key = -1; + // Only one frame + if (len === 1) { + if (channels.rotation) { + quat.copy(this.rotation, channels.rotation); + } + if (channels.position) { + vec3.copy(this.position, channels.position); + } + if (channels.scale) { + vec3.copy(this.scale, channels.scale); + } + return; + } // Clamp - if (time <= channels.time[0]) { + else if (time <= channels.time[0]) { time = channels.time[0]; key = 0; } @@ -8335,14 +8356,19 @@ return /******/ (function(modules) { // webpackBootstrap TransformClip.prototype.constructor = TransformClip; - TransformClip.prototype.step = function (time, dTime) { + TransformClip.prototype.step = function (time, dTime, silent) { - var ret = Clip.prototype.step.call(this, time, dTime); + var ret = Clip.prototype.step.call(this, time, dTime, true); if (ret !== 'finish') { this.setTime(this.getElapsedTime()); } + // PENDING Schedule + if (!silent && ret !== 'paused') { + this.fire('frame'); + } + return ret; }; @@ -8593,14 +8619,19 @@ return /******/ (function(modules) { // webpackBootstrap SkinningClip.prototype.constructor = SkinningClip; - SkinningClip.prototype.step = function(time, dTime) { + SkinningClip.prototype.step = function(time, dTime, silent) { - var ret = Clip.prototype.step.call(this, time, dTime); + var ret = Clip.prototype.step.call(this, time, dTime, true); if (ret !== 'finish') { this.setTime(this.getElapsedTime()); } + // PENDING Schedule + if (!silent && ret !== 'paused') { + this.fire('frame'); + } + return ret; }; @@ -12855,8 +12886,9 @@ return /******/ (function(modules) { // webpackBootstrap var near = (-1 - m14) / m10; var far = (1 - m14) / m10; - boundingBox.min.set(left, bottom, far); - boundingBox.max.set(right, top, near); + + boundingBox.min.set(Math.min(left, right), Math.min(bottom, top), Math.min(far, near)); + boundingBox.max.set(Math.max(right, left), Math.max(top, bottom), Math.max(near, far)); var min = boundingBox.min._array; var max = boundingBox.max._array; @@ -16617,6 +16649,8 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; + + // TODO Shader library var Pass = __webpack_require__(47); var Node = __webpack_require__(37); @@ -17962,28 +17996,14 @@ return /******/ (function(modules) { // webpackBootstrap var vendor = __webpack_require__(51); function getArrayCtorByType (type) { - var ArrayConstructor; - switch(type) { - case 'byte': - ArrayConstructor = vendor.Int8Array; - break; - case 'ubyte': - ArrayConstructor = vendor.Uint8Array; - break; - case 'short': - ArrayConstructor = vendor.Int16Array; - break; - case 'ushort': - ArrayConstructor = vendor.Uint16Array; - break; - default: - ArrayConstructor = vendor.Float32Array; - break; - } - return ArrayConstructor; + return ({ + 'byte': vendor.Int8Array, + 'ubyte': vendor.Uint8Array, + 'short': vendor.Int16Array, + 'ushort': vendor.Uint16Array + })[type] || vendor.Float32Array; } - function Attribute(name, type, size, semantic) { this.name = name; this.type = type; @@ -18891,7 +18911,7 @@ return /******/ (function(modules) { // webpackBootstrap this._textureSlot = slot || 0; }, - useCurrentTextureSlot: function (_gl, texture) { + takeCurrentTextureSlot: function (_gl, texture) { var textureSlot = this._textureSlot; this.useTextureSlot(_gl, texture, textureSlot); @@ -19429,7 +19449,10 @@ return /******/ (function(modules) { // webpackBootstrap defines[symbol] = true; } else { - defines[symbol] = value ? parseFloat(value) : null; + defines[symbol] = value + // If can parse to float + ? (isNaN(parseFloat(value)) ? value : parseFloat(value)) + : null; } } return ''; @@ -19716,32 +19739,47 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Object} */ bind: function(_gl, shader, prevMaterial, prevShader) { + // PENDING Same texture in different material take different slot? // May use shader of other material if shader code are same var shader = shader || this.shader; - var sameShader = prevShader === shader; + // var sameShader = prevShader === shader; var currentTextureSlot = shader.currentTextureSlot(); + + for (var u = 0; u < this._enabledUniforms.length; u++) { + var symbol = this._enabledUniforms[u]; + var uniformValue = this.uniforms[symbol].value; + if (uniformValue instanceof Texture) { + // Reset slot + uniformValue.__slot = -1; + } + else if (uniformValue instanceof Array) { + for (var i = 0; i < uniformValue.length; i++) { + if (uniformValue[i] instanceof Texture) { + uniformValue[i].__slot = -1; + } + } + } + } // Set uniforms for (var u = 0; u < this._enabledUniforms.length; u++) { var symbol = this._enabledUniforms[u]; var uniform = this.uniforms[symbol]; var uniformValue = uniform.value; + + // PENDING // When binding two materials with the same shader // Many uniforms will be be set twice even if they have the same value // So add a evaluation to see if the uniform is really needed to be set - if (prevMaterial && sameShader) { - if (prevMaterial.uniforms[symbol].value === uniformValue) { - continue; - } - } - - if (uniformValue === undefined) { - console.warn('Uniform value "' + symbol + '" is undefined'); - continue; - } - else if (uniformValue === null) { + // if (prevMaterial && sameShader) { + // if (prevMaterial.uniforms[symbol].value === uniformValue) { + // continue; + // } + // } + + if (uniformValue === null) { // FIXME Assume material with same shader have same order uniforms // Or if different material use same textures, // the slot will be different and still skipped because optimization @@ -19750,22 +19788,25 @@ return /******/ (function(modules) { // webpackBootstrap var res = shader.setUniform(_gl, '1i', symbol, slot); if (res) { // Texture is enabled // Still occupy the slot to make sure same texture in different materials have same slot. - shader.useCurrentTextureSlot(_gl, null); + shader.takeCurrentTextureSlot(_gl, null); } } continue; } - else if (uniformValue instanceof Array - && !uniformValue.length) { - continue; - } else if (uniformValue instanceof Texture) { - var slot = shader.currentTextureSlot(); - var res = shader.setUniform(_gl, '1i', symbol, slot); - if (!res) { // Texture is not enabled - continue; + if (uniformValue.__slot < 0) { + var slot = shader.currentTextureSlot(); + var res = shader.setUniform(_gl, '1i', symbol, slot); + if (!res) { // Texture uniform is not enabled + continue; + } + shader.takeCurrentTextureSlot(_gl, uniformValue); + uniformValue.__slot = slot; + } + // Multiple uniform use same texture.. + else { + shader.setUniform(_gl, '1i', symbol, uniformValue.__slot); } - shader.useCurrentTextureSlot(_gl, uniformValue); } else if (uniformValue instanceof Array) { if (uniformValue.length === 0) { @@ -19783,10 +19824,15 @@ return /******/ (function(modules) { // webpackBootstrap for (var i = 0; i < uniformValue.length; i++) { var texture = uniformValue[i]; - var slot = shader.currentTextureSlot(); - arr.push(slot); - - shader.useCurrentTextureSlot(_gl, texture); + if (texture.__slot < 0) { + var slot = shader.currentTextureSlot(); + arr.push(slot); + shader.takeCurrentTextureSlot(_gl, texture); + texture.__slot = slot; + } + else { + arr.push(texture.__slot); + } } shader.setUniform(_gl, '1iv', symbol, arr); @@ -19873,6 +19919,10 @@ return /******/ (function(modules) { // webpackBootstrap else { var uniform = this.uniforms[symbol]; if (uniform) { + if (typeof value === 'undefined') { + console.warn('Uniform value "' + symbol + '" is undefined'); + value = null; + } uniform.value = value; } } @@ -20030,6 +20080,9 @@ return /******/ (function(modules) { // webpackBootstrap shader = shader || this.material.shader; // Set pose matrices of skinned mesh if (this.skeleton) { + // TODO Multiple mesh share same skeleton + this.skeleton.update(); + var skinMatricesArray = this.skeleton.getSubSkinMatrices(this.__GUID__, this.joints); if (this.useSkinMatricesTexture) { @@ -20207,11 +20260,16 @@ return /******/ (function(modules) { // webpackBootstrap * @type {boolean} */ ignorePicking: false, + /** + * @type {boolean} + */ + ignorePreZ: false, /** * @return {boolean} */ isRenderable: function() { + // TODO Shader ? return this.geometry && this.material && !this.invisible && this.geometry.vertexCount > 0; }, @@ -21958,6 +22016,16 @@ return /******/ (function(modules) { // webpackBootstrap var transparentQueue = scene.transparentQueue; var sceneMaterial = scene.material; + // StandardMaterial needs updateShader method so shader can be created on demand. + for (var i = 0; i < opaqueQueue.length; i++) { + var material = opaqueQueue[i].material; + material.updateShader && material.updateShader(_gl); + } + // StandardMaterial needs updateShader method so shader can be created on demand. + for (var i = 0; i < transparentQueue.length; i++) { + var material = transparentQueue[i].material; + material.updateShader && material.updateShader(_gl); + } scene.trigger('beforerender', this, scene, camera); // Sort render queue // Calculate the object depth @@ -22062,85 +22130,18 @@ return /******/ (function(modules) { // webpackBootstrap var prevMaterial; var prevShader; - // Status - var depthTest, depthMask; - var culling, cullFace, frontFace; - var culledRenderQueue; if (preZ) { - var preZPassMaterial = this._prezMaterial || new Material({ - shader: new Shader({ - vertex: Shader.source('qtek.prez.vertex'), - fragment: Shader.source('qtek.prez.fragment') - }) - }); - this._prezMaterial = preZPassMaterial; - var preZPassShader = preZPassMaterial.shader; - - culledRenderQueue = []; - preZPassShader.bind(_gl); - _gl.colorMask(false, false, false, false); - _gl.depthMask(true); - _gl.enable(_gl.DEPTH_TEST); - for (var i = 0; i < queue.length; i++) { - var renderable = queue[i]; - if (!this.ifRenderObject(renderable)) { - continue; - } - - var worldM = renderable.worldTransform._array; - var geometry = renderable.geometry; - - mat4.multiplyAffine(matrices.WORLDVIEW, matrices.VIEW , worldM); - - if (geometry.boundingBox) { - if (this.isFrustumCulled( - renderable, scene, camera, matrices.WORLDVIEW, matrices.PROJECTION - )) { - continue; - } - } - if (renderable.skeleton) { // FIXME skinned mesh - continue; - } - - mat4.multiply(matrices.WORLDVIEWPROJECTION, matrices.VIEWPROJECTION , worldM); - - if (renderable.cullFace !== cullFace) { - cullFace = renderable.cullFace; - _gl.cullFace(cullFace); - } - if (renderable.frontFace !== frontFace) { - frontFace = renderable.frontFace; - _gl.frontFace(frontFace); - } - if (renderable.culling !== culling) { - culling = renderable.culling; - culling ? _gl.enable(_gl.CULL_FACE) : _gl.disable(_gl.CULL_FACE); - } - - var semanticInfo = preZPassShader.matrixSemantics.WORLDVIEWPROJECTION; - preZPassShader.setUniform(_gl, semanticInfo.type, semanticInfo.symbol, matrices.WORLDVIEWPROJECTION); - - // PENDING If invoke beforeRender hook - renderable.render(_gl, preZPassMaterial.shader); - culledRenderQueue.push(renderable); - } - _gl.depthFunc(_gl.LEQUAL); - _gl.colorMask(true, true, true, true); - _gl.depthMask(false); - - // Reset current shader. - this._currentShader = null; + culledRenderQueue = this._renderPreZ(queue, scene, camera); } else { culledRenderQueue = queue; _gl.depthFunc(_gl.LESS); } - culling = null; - cullFace = null; - frontFace = null; + // Status + var depthTest, depthMask; + var culling, cullFace, frontFace; for (var i = 0; i < culledRenderQueue.length; i++) { var renderable = culledRenderQueue[i]; @@ -22162,10 +22163,6 @@ return /******/ (function(modules) { // webpackBootstrap } var material = globalMaterial || renderable.material; - // StandardMaterial needs updateShader method so shader can be created on demand. - if (material !== prevMaterial) { - material.updateShader && material.updateShader(_gl); - } var shader = material.shader; @@ -22309,6 +22306,77 @@ return /******/ (function(modules) { // webpackBootstrap return renderInfo; }, + _renderPreZ: function (queue, scene, camera) { + var _gl = this.gl; + var preZPassMaterial = this._prezMaterial || new Material({ + shader: new Shader({ + vertex: Shader.source('qtek.prez.vertex'), + fragment: Shader.source('qtek.prez.fragment') + }) + }); + this._prezMaterial = preZPassMaterial; + var preZPassShader = preZPassMaterial.shader; + + var culledRenderQueue = []; + // Status + var culling, cullFace, frontFace; + + preZPassShader.bind(_gl); + _gl.colorMask(false, false, false, false); + _gl.depthMask(true); + _gl.enable(_gl.DEPTH_TEST); + for (var i = 0; i < queue.length; i++) { + var renderable = queue[i]; + // PENDING + if (!this.ifRenderObject(renderable)) { + continue; + } + + var worldM = renderable.worldTransform._array; + var geometry = renderable.geometry; + + mat4.multiplyAffine(matrices.WORLDVIEW, matrices.VIEW , worldM); + + if (geometry.boundingBox) { + if (this.isFrustumCulled( + renderable, scene, camera, matrices.WORLDVIEW, matrices.PROJECTION + )) { + continue; + } + } + culledRenderQueue.push(renderable); + if (renderable.skeleton || renderable.ignorePreZ) { // FIXME skinned mesh and custom vertex shader material. + continue; + } + + mat4.multiply(matrices.WORLDVIEWPROJECTION, matrices.VIEWPROJECTION , worldM); + + if (renderable.cullFace !== cullFace) { + cullFace = renderable.cullFace; + _gl.cullFace(cullFace); + } + if (renderable.frontFace !== frontFace) { + frontFace = renderable.frontFace; + _gl.frontFace(frontFace); + } + if (renderable.culling !== culling) { + culling = renderable.culling; + culling ? _gl.enable(_gl.CULL_FACE) : _gl.disable(_gl.CULL_FACE); + } + + var semanticInfo = preZPassShader.matrixSemantics.WORLDVIEWPROJECTION; + preZPassShader.setUniform(_gl, semanticInfo.type, semanticInfo.symbol, matrices.WORLDVIEWPROJECTION); + + // PENDING If invoke beforeRender hook + renderable.render(_gl, preZPassMaterial.shader); + } + _gl.depthFunc(_gl.LEQUAL); + _gl.colorMask(true, true, true, true); + _gl.depthMask(true); + + return culledRenderQueue; + }, + /** * If an scene object is culled by camera frustum * @@ -23893,7 +23961,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports) { - module.exports = "\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\n@export qtek.util.calculate_attenuation\n\nuniform float attenuationFactor : 5.0;\n\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\n@end\n\n@export qtek.util.edge_factor\n\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\n@end\n\n@export qtek.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n \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\n return res;\n}\n@end\n\n@export qtek.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n \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\n\n@export qtek.util.float\n@import qtek.util.encode_float\n@import qtek.util.decode_float\n@end\n\n\n\n@export qtek.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n }\n@end\n\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\n@export qtek.util.rgbm\n@import qtek.util.rgbm_decode\n@import qtek.util.rgbm_encode\n\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}\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\n@end\n\n\n@export qtek.util.srgb\n\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}\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\n\n@export qtek.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n\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\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\n#endif\n\n@end\n\n@export qtek.chunk.skin_matrix\n\nmat4 skinMatrixWS;\nif (weight.x > 0.0)\n{\n skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\n}\nif (weight.y > 0.0)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 0.0)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 0.0)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n\n\n\n@export qtek.util.parallax_correct\n\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\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n\n return normalize(fixedPos - boxCenter);\n}\n\n@end\n\n\n\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"; + module.exports = "\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\n@export qtek.util.calculate_attenuation\n\nuniform float attenuationFactor : 5.0;\n\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\n@end\n\n@export qtek.util.edge_factor\n\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\n@end\n\n@export qtek.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n \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\n return res;\n}\n@end\n\n@export qtek.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n \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\n\n@export qtek.util.float\n@import qtek.util.encode_float\n@import qtek.util.decode_float\n@end\n\n\n\n@export qtek.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n }\n@end\n\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\n@export qtek.util.rgbm\n@import qtek.util.rgbm_decode\n@import qtek.util.rgbm_encode\n\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}\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\n@end\n\n\n@export qtek.util.srgb\n\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}\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\n\n@export qtek.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n\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\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\n#endif\n\n@end\n\n@export qtek.chunk.skin_matrix\n\nmat4 skinMatrixWS;\nif (weight.x > 1e-4)\n{\n skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\n}\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-3)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n\n\n\n@export qtek.util.parallax_correct\n\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\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n\n return normalize(fixedPos - boxCenter);\n}\n\n@end\n\n\n\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"; /***/ }, @@ -25090,7 +25158,7 @@ return /******/ (function(modules) { // webpackBootstrap var slot = shader.currentTextureSlot(); var result = shader.setUniform(_gl, '1i', symbol, slot); if (result) { - shader.useCurrentTextureSlot(_gl, texture); + shader.takeCurrentTextureSlot(_gl, texture); } } } @@ -27003,6 +27071,7 @@ return /******/ (function(modules) { // webpackBootstrap */ crossOrigin: '', + shaderLibrary: null }, function () { @@ -27304,6 +27373,7 @@ return /******/ (function(modules) { // webpackBootstrap var rootJoint = bindNodeToJoint(jointsMap, rootNodes[i], -1, rootNode); // Root joint may not in the skeleton if (rootJoint) { + skeleton.roots = skeleton.roots || []; skeleton.roots.push(rootJoint); } } @@ -27625,7 +27695,9 @@ return /******/ (function(modules) { // webpackBootstrap geometry: geometry, material: material }); - if (material.shader.isTextureEnabled('normalMap')) { + if (((material instanceof StandardMaterial) && material.normalMap) + || (material.shader && material.shader.isTextureEnabled('normalMap')) + ) { if (!mesh.geometry.attributes.tangent.value) { mesh.geometry.generateTangents(); } @@ -27843,7 +27915,6 @@ return /******/ (function(modules) { // webpackBootstrap var rotationArr = parameters.rotation; if (rotationArr) { for (var i = 0; i < parameters.TIME.length; i++) { - parameters.TIME[i] *= 1000; var offset = i * 4; if (rotationArr) { quatTmp[0] = rotationArr[offset]; @@ -27857,6 +27928,9 @@ return /******/ (function(modules) { // webpackBootstrap } } } + for (var i = 0; i < parameters.TIME.length; i++) { + parameters.TIME[i] *= 1000; + } // TODO // if (nodeAnimationClips[targetId]) { // continue; @@ -28370,7 +28444,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports) { - module.exports = "\n\n@export qtek.standard.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#if defined(AOMAP_ENABLED)\nattribute vec2 texcoord2 : TEXCOORD_1;\n#endif\n\nattribute vec3 normal : NORMAL;\nattribute vec4 tangent : TANGENT;\n\n#ifdef VERTEX_COLOR\nattribute vec4 color : COLOR;\n#endif\n\nattribute vec3 barycentric;\n\n@import qtek.chunk.skinning_header\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\nvarying vec3 v_Barycentric;\n\n#ifdef NORMALMAP_ENABLED\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n#if defined(AOMAP_ENABLED)\nvarying vec2 v_Texcoord2;\n#endif\n\nvoid main()\n{\n\n vec3 skinnedPosition = position;\n vec3 skinnedNormal = normal;\n vec3 skinnedTangent = tangent.xyz;\n#ifdef SKINNING\n\n @import qtek.chunk.skin_matrix\n\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n skinnedNormal = (skinMatrixWS * vec4(normal, 0.0)).xyz;\n skinnedTangent = (skinMatrixWS * vec4(tangent.xyz, 0.0)).xyz;\n#endif\n\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_WorldPosition = (world * vec4(skinnedPosition, 1.0)).xyz;\n v_Barycentric = barycentric;\n\n v_Normal = normalize((worldInverseTranspose * vec4(skinnedNormal, 0.0)).xyz);\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(skinnedTangent, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = color;\n#endif\n\n#if defined(AOMAP_ENABLED)\n v_Texcoord2 = texcoord2;\n#endif\n}\n\n@end\n\n\n@export qtek.standard.fragment\n\n#define PI 3.14159265358979\n\n#define GLOSS_CHANEL 0\n#define ROUGHNESS_CHANNEL 0\n#define METALNESS_CHANNEL 1\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n#ifdef NORMALMAP_ENABLED\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\nuniform sampler2D normalMap;\n#endif\n\n#ifdef DIFFUSEMAP_ENABLED\nuniform sampler2D diffuseMap;\n#endif\n\n#ifdef SPECULARMAP_ENABLED\nuniform sampler2D specularMap;\n#endif\n\n#ifdef USE_ROUGHNESS\nuniform float roughness : 0.5;\n #ifdef ROUGHNESSMAP_ENABLED\nuniform sampler2D roughnessMap;\n #endif\n#else\nuniform float glossiness: 0.5;\n #ifdef GLOSSMAP_ENABLED\nuniform sampler2D glossMap;\n #endif\n#endif\n\n#ifdef METALNESSMAP_ENABLED\nuniform sampler2D metalnessMap;\n#endif\n\n#ifdef ENVIRONMENTMAP_ENABLED\nuniform samplerCube environmentMap;\n\n #ifdef PARALLAX_CORRECTED\nuniform vec3 environmentBoxMin;\nuniform vec3 environmentBoxMax;\n #endif\n\n#endif\n\n#ifdef BRDFLOOKUP_ENABLED\nuniform sampler2D brdfLookup;\n#endif\n\n#ifdef EMISSIVEMAP_ENABLED\nuniform sampler2D emissiveMap;\n#endif\n\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n\n#ifdef AOMAP_ENABLED\nuniform sampler2D aoMap;\nuniform float aoIntensity;\nvarying vec2 v_Texcoord2;\n#endif\n\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform float alpha : 1.0;\n\n#ifdef ALPHA_TEST\nuniform float alphaCutoff: 0.9;\n#endif\n\n#ifdef USE_METALNESS\nuniform float metalness : 0.0;\n#else\nuniform vec3 specularColor : [0.1, 0.1, 0.1];\n#endif\n\nuniform vec3 emission : [0.0, 0.0, 0.0];\n\nuniform float emissionIntensity: 1;\n\nuniform float lineWidth : 0.0;\nuniform vec3 lineColor : [0.0, 0.0, 0.0];\nvarying vec3 v_Barycentric;\n\n#ifdef ENVIRONMENTMAP_PREFILTER\nuniform float maxMipmapLevel: 5;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import qtek.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import qtek.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import qtek.header.ambient_cubemap_light\n#endif\n\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\n@import qtek.util.calculate_attenuation\n\n@import qtek.util.edge_factor\n\n@import qtek.util.rgbm\n\n@import qtek.util.srgb\n\n@import qtek.plugin.compute_shadow_map\n\n@import qtek.util.parallax_correct\n\n\nfloat G_Smith(float g, float ndv, float ndl)\n{\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nfloat D_GGX(float g, 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 / (PI * tmp * tmp);\n}\n\n\nvoid main()\n{\n vec4 albedoColor = vec4(color, alpha);\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n#ifdef DIFFUSEMAP_ENABLED\n vec4 texel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n #endif\n albedoColor.rgb *= texel.rgb;\n #ifdef DIFFUSEMAP_ALPHA_ALPHA\n albedoColor.a *= texel.a;\n #endif\n\n#endif\n\n\n#ifdef USE_METALNESS\n float m = metalness;\n\n #ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_Texcoord)[METALNESS_CHANNEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n #endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 spec = mix(vec3(0.04), baseColor, m);\n#else\n vec3 spec = specularColor;\n#endif\n\n#ifdef USE_ROUGHNESS\n float g = 1.0 - roughness;\n #ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_Texcoord)[ROUGHNESS_CHANNEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n #endif\n#else\n float g = glossiness;\n #ifdef GLOSSMAP_ENABLED\n float g2 = texture2D(glossMap, v_Texcoord)[GLOSS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n #endif\n#endif\n\n#ifdef SPECULARMAP_ENABLED\n spec *= texture2D(specularMap, v_Texcoord).rgb;\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n#ifdef NORMALMAP_ENABLED\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#endif\n\n vec3 diffuseTerm = vec3(0.0, 0.0, 0.0);\n vec3 specularTerm = vec3(0.0, 0.0, 0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, spec);\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_];\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N) * ambientSHLightColor[_idx_];\n }}\n#endif\n\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\n vec3 lightPosition = pointLightPosition[_idx_];\n vec3 lc = pointLightColor[_idx_];\n float range = pointLightRange[_idx_];\n\n vec3 L = lightPosition - v_WorldPosition;\n\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\n float shadowContrib = 1.0;\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\n if(shadowEnabled)\n {\n shadowContrib = shadowContribsPoint[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * attenuation * shadowContrib;\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n\n vec3 L = -normalize(directionalLightDirection[_idx_]);\n vec3 lc = directionalLightColor[_idx_];\n\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\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if(shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n#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\n vec3 L = lightPosition - v_WorldPosition;\n float dist = length(L);\n float attenuation = lightAttenuation(dist, range);\n\n L /= dist;\n float c = dot(spotLightDirection, L);\n\n float falloff;\n falloff = clamp((c - a) /( b - a), 0.0, 1.0);\n falloff = pow(falloff, falloffFactor);\n\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\n float shadowContrib = 1.0;\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsSpot[i];\n }\n#endif\n\n vec3 li = lc * attenuation * (1.0 - falloff) * shadowContrib * ndl;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }\n#endif\n\n vec4 outColor = albedoColor;\n outColor.rgb *= diffuseTerm;\n\n outColor.rgb += specularTerm;\n\n\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\n#ifdef ENVIRONMENTMAP_ENABLED\n\n vec3 envWeight = g * fresnelTerm;\n vec3 L = reflect(-V, N);\n\n #ifdef PARALLAX_CORRECTED\n L = parallaxCorrect(L, v_WorldPosition, environmentBoxMin, environmentBoxMax);\n #endif\n\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\n #ifdef BRDFLOOKUP_ENABLED\n vec2 brdfParam = texture2D(brdfLookup, vec2(rough, ndv)).xy;\n envWeight = spec * brdfParam.x + brdfParam.y;\n #endif\n\n #else\n vec3 envTexel = textureCube(environmentMap, L).xyz;\n #endif\n\n outColor.rgb += envTexel * envWeight;\n#endif\n\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\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\n outColor.rgb *= aoFactor;\n\n vec3 lEmission = emission;\n#ifdef EMISSIVEMAP_ENABLED\n lEmission *= texture2D(emissiveMap, v_Texcoord).rgb;\n#endif\n outColor.rgb += lEmission * emissionIntensity;\n\n#ifdef GAMMA_ENCODE\n outColor.rgb = pow(outColor.rgb, vec3(1 / 2.2));\n#endif\n\n if(lineWidth > 0.)\n {\n outColor.rgb = mix(lineColor, vec3(outColor.rgb), edgeFactor(lineWidth));\n }\n\n#ifdef ALPHA_TEST\n if (outColor.a < alphaCutoff) {\n discard;\n }\n#endif\n\n gl_FragColor = encodeHDR(outColor);\n}\n\n@end\n"; + module.exports = "\n\n@export qtek.standard.vertex\n\n#define SHADER_NAME standard\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#if defined(AOMAP_ENABLED)\nattribute vec2 texcoord2 : TEXCOORD_1;\n#endif\n\nattribute vec3 normal : NORMAL;\nattribute vec4 tangent : TANGENT;\n\n#ifdef VERTEX_COLOR\nattribute vec4 color : COLOR;\n#endif\n\nattribute vec3 barycentric;\n\n@import qtek.chunk.skinning_header\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\nvarying vec3 v_Barycentric;\n\n#ifdef NORMALMAP_ENABLED\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n#if defined(AOMAP_ENABLED)\nvarying vec2 v_Texcoord2;\n#endif\n\nvoid main()\n{\n\n vec3 skinnedPosition = position;\n vec3 skinnedNormal = normal;\n vec3 skinnedTangent = tangent.xyz;\n#ifdef SKINNING\n\n @import qtek.chunk.skin_matrix\n\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n skinnedNormal = (skinMatrixWS * vec4(normal, 0.0)).xyz;\n skinnedTangent = (skinMatrixWS * vec4(tangent.xyz, 0.0)).xyz;\n#endif\n\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_WorldPosition = (world * vec4(skinnedPosition, 1.0)).xyz;\n v_Barycentric = barycentric;\n\n v_Normal = normalize((worldInverseTranspose * vec4(skinnedNormal, 0.0)).xyz);\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(skinnedTangent, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = color;\n#endif\n\n#if defined(AOMAP_ENABLED)\n v_Texcoord2 = texcoord2;\n#endif\n}\n\n@end\n\n\n@export qtek.standard.fragment\n\n#define PI 3.14159265358979\n\n#define GLOSS_CHANEL 0\n#define ROUGHNESS_CHANNEL 0\n#define METALNESS_CHANNEL 1\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n#ifdef NORMALMAP_ENABLED\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\nuniform sampler2D normalMap;\n#endif\n\n#ifdef DIFFUSEMAP_ENABLED\nuniform sampler2D diffuseMap;\n#endif\n\n#ifdef SPECULARMAP_ENABLED\nuniform sampler2D specularMap;\n#endif\n\n#ifdef USE_ROUGHNESS\nuniform float roughness : 0.5;\n #ifdef ROUGHNESSMAP_ENABLED\nuniform sampler2D roughnessMap;\n #endif\n#else\nuniform float glossiness: 0.5;\n #ifdef GLOSSMAP_ENABLED\nuniform sampler2D glossMap;\n #endif\n#endif\n\n#ifdef METALNESSMAP_ENABLED\nuniform sampler2D metalnessMap;\n#endif\n\n#ifdef ENVIRONMENTMAP_ENABLED\nuniform samplerCube environmentMap;\n\n #ifdef PARALLAX_CORRECTED\nuniform vec3 environmentBoxMin;\nuniform vec3 environmentBoxMax;\n #endif\n\n#endif\n\n#ifdef BRDFLOOKUP_ENABLED\nuniform sampler2D brdfLookup;\n#endif\n\n#ifdef EMISSIVEMAP_ENABLED\nuniform sampler2D emissiveMap;\n#endif\n\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n\n#ifdef AOMAP_ENABLED\nuniform sampler2D aoMap;\nuniform float aoIntensity;\nvarying vec2 v_Texcoord2;\n#endif\n\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform float alpha : 1.0;\n\n#ifdef ALPHA_TEST\nuniform float alphaCutoff: 0.9;\n#endif\n\n#ifdef USE_METALNESS\nuniform float metalness : 0.0;\n#else\nuniform vec3 specularColor : [0.1, 0.1, 0.1];\n#endif\n\nuniform vec3 emission : [0.0, 0.0, 0.0];\n\nuniform float emissionIntensity: 1;\n\nuniform float lineWidth : 0.0;\nuniform vec3 lineColor : [0.0, 0.0, 0.0];\nvarying vec3 v_Barycentric;\n\n#ifdef ENVIRONMENTMAP_PREFILTER\nuniform float maxMipmapLevel: 5;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import qtek.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import qtek.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import qtek.header.ambient_cubemap_light\n#endif\n\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\n@import qtek.util.calculate_attenuation\n\n@import qtek.util.edge_factor\n\n@import qtek.util.rgbm\n\n@import qtek.util.srgb\n\n@import qtek.plugin.compute_shadow_map\n\n@import qtek.util.parallax_correct\n\n\nfloat G_Smith(float g, float ndv, float ndl)\n{\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nfloat D_GGX(float g, 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 / (PI * tmp * tmp);\n}\n\n\nvoid main()\n{\n vec4 albedoColor = vec4(color, alpha);\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n#ifdef DIFFUSEMAP_ENABLED\n vec4 texel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n #endif\n albedoColor.rgb *= texel.rgb;\n #ifdef DIFFUSEMAP_ALPHA_ALPHA\n albedoColor.a *= texel.a;\n #endif\n\n#endif\n\n\n#ifdef USE_METALNESS\n float m = metalness;\n\n #ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_Texcoord)[METALNESS_CHANNEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n #endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 spec = mix(vec3(0.04), baseColor, m);\n#else\n vec3 spec = specularColor;\n#endif\n\n#ifdef USE_ROUGHNESS\n float g = 1.0 - roughness;\n #ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_Texcoord)[ROUGHNESS_CHANNEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n #endif\n#else\n float g = glossiness;\n #ifdef GLOSSMAP_ENABLED\n float g2 = texture2D(glossMap, v_Texcoord)[GLOSS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n #endif\n#endif\n\n#ifdef SPECULARMAP_ENABLED\n spec *= texture2D(specularMap, v_Texcoord).rgb;\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n#ifdef NORMALMAP_ENABLED\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#endif\n\n vec3 diffuseTerm = vec3(0.0, 0.0, 0.0);\n vec3 specularTerm = vec3(0.0, 0.0, 0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, spec);\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_];\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N) * ambientSHLightColor[_idx_];\n }}\n#endif\n\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\n vec3 lightPosition = pointLightPosition[_idx_];\n vec3 lc = pointLightColor[_idx_];\n float range = pointLightRange[_idx_];\n\n vec3 L = lightPosition - v_WorldPosition;\n\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\n float shadowContrib = 1.0;\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\n if(shadowEnabled)\n {\n shadowContrib = shadowContribsPoint[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * attenuation * shadowContrib;\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n\n vec3 L = -normalize(directionalLightDirection[_idx_]);\n vec3 lc = directionalLightColor[_idx_];\n\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\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if(shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n#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\n vec3 L = lightPosition - v_WorldPosition;\n float dist = length(L);\n float attenuation = lightAttenuation(dist, range);\n\n L /= dist;\n float c = dot(spotLightDirection, L);\n\n float falloff;\n falloff = clamp((c - a) /( b - a), 0.0, 1.0);\n falloff = pow(falloff, falloffFactor);\n\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\n float shadowContrib = 1.0;\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsSpot[i];\n }\n#endif\n\n vec3 li = lc * attenuation * (1.0 - falloff) * shadowContrib * ndl;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }\n#endif\n\n vec4 outColor = albedoColor;\n outColor.rgb *= diffuseTerm;\n\n outColor.rgb += specularTerm;\n\n\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\n#ifdef ENVIRONMENTMAP_ENABLED\n\n vec3 envWeight = g * fresnelTerm;\n vec3 L = reflect(-V, N);\n\n #ifdef PARALLAX_CORRECTED\n L = parallaxCorrect(L, v_WorldPosition, environmentBoxMin, environmentBoxMax);\n #endif\n\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\n #ifdef BRDFLOOKUP_ENABLED\n vec2 brdfParam = texture2D(brdfLookup, vec2(rough, ndv)).xy;\n envWeight = spec * brdfParam.x + brdfParam.y;\n #endif\n\n #else\n vec3 envTexel = textureCube(environmentMap, L).xyz;\n #endif\n\n outColor.rgb += envTexel * envWeight;\n#endif\n\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\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\n outColor.rgb *= aoFactor;\n\n vec3 lEmission = emission;\n#ifdef EMISSIVEMAP_ENABLED\n lEmission *= texture2D(emissiveMap, v_Texcoord).rgb;\n#endif\n outColor.rgb += lEmission * emissionIntensity;\n\n#ifdef GAMMA_ENCODE\n outColor.rgb = pow(outColor.rgb, vec3(1 / 2.2));\n#endif\n\n if(lineWidth > 0.)\n {\n outColor.rgb = mix(lineColor, vec3(outColor.rgb), edgeFactor(lineWidth));\n }\n\n#ifdef ALPHA_TEST\n if (outColor.a < alphaCutoff) {\n discard;\n }\n#endif\n\n gl_FragColor = encodeHDR(outColor);\n}\n\n@end\n"; /***/ }, @@ -28404,13 +28478,6 @@ return /******/ (function(modules) { // webpackBootstrap */ name: '', - /** - * root joints - * @type {Array.} - */ - // PENDING If needs this? - roots: [], - /** * joints * @type {Array.} @@ -28528,9 +28595,6 @@ return /******/ (function(modules) { // webpackBootstrap var m4 = mat4.create(); return function () { - for (var i = 0; i < this.roots.length; i++) { - this.roots[i].node.update(true); - } this._invBindPoseMatricesArray = new Float32Array(this.joints.length * 16); this._skinMatricesArray = new Float32Array(this.joints.length * 16); @@ -28581,10 +28645,6 @@ return /******/ (function(modules) { // webpackBootstrap update: (function () { var m4 = mat4.create(); return function () { - for (var i = 0; i < this.roots.length; i++) { - this.roots[i].node.update(true); - } - for (var i = 0; i < this.joints.length; i++) { var joint = this.joints[i]; mat4.multiply( @@ -28680,9 +28740,6 @@ return /******/ (function(modules) { // webpackBootstrap } skeleton.joints.push(newJoint); } - for (var i = 0; i < this.roots.length; i++) { - skeleton.roots.push(skeleton.joints[this.roots[i].index]); - } if (this._invBindPoseMatricesArray) { var len = this._invBindPoseMatricesArray.length; @@ -28715,6 +28772,7 @@ return /******/ (function(modules) { // webpackBootstrap var Shader = __webpack_require__(52); + Shader['import'](__webpack_require__(65)); Shader['import'](__webpack_require__(74)); // Some build in shaders @@ -28781,7 +28839,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports) { - module.exports = "@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\n@export qtek.compositor.kernel.gaussian_13\n\nfloat gaussianKernel[13];\n\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\n@end\n\n\n@export qtek.compositor.gaussian_blur\n\nuniform sampler2D texture; varying vec2 v_Texcoord;\n\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n\n@import qtek.util.rgbm\n@import qtek.util.clamp_sample\n\nvoid main (void)\n{\n @import qtek.compositor.kernel.gaussian_9\n\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\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\n@end\n"; + module.exports = "@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\n@export qtek.compositor.kernel.gaussian_13\n\nfloat gaussianKernel[13];\n\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\n@end\n\n\n@export qtek.compositor.gaussian_blur\n\n#define SHADER_NAME gaussian_blur\n\nuniform sampler2D texture; varying vec2 v_Texcoord;\n\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n\n@import qtek.util.rgbm\n@import qtek.util.clamp_sample\n\nvoid main (void)\n{\n @import qtek.compositor.kernel.gaussian_9\n\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\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\n@end\n"; /***/ }, @@ -28946,6 +29004,7 @@ return /******/ (function(modules) { // webpackBootstrap 5121: vendor.Uint8Array, 5122: vendor.Int16Array, 5123: vendor.Uint16Array, + 5125: vendor.Uint32Array, 5126: vendor.Float32Array }; var SIZE_MAP = { @@ -28958,6 +29017,39 @@ return /******/ (function(modules) { // webpackBootstrap MAT4: 16 }; + function getAccessorData(json, lib, accessorIdx, isIndices) { + var accessorInfo = json.accessors[accessorIdx]; + + var bufferViewInfo = json.bufferViews[accessorInfo.bufferView]; + var buffer = lib.buffers[bufferViewInfo.buffer]; + var byteOffset = (bufferViewInfo.byteOffset || 0) + (accessorInfo.byteOffset || 0); + var ArrayCtor = ARRAY_CTOR_MAP[accessorInfo.componentType] || vendor.Float32Array; + + var size = isIndices ? 1 : SIZE_MAP[accessorInfo.type]; + var arr = new ArrayCtor(buffer, byteOffset, size * accessorInfo.count); + + var quantizeExtension = accessorInfo.extensions && accessorInfo.extensions['WEB3D_quantized_attributes']; + if (quantizeExtension) { + var decodedArr = new vendor.Float32Array(size * accessorInfo.count); + var decodeMatrix = quantizeExtension.decodeMatrix; + var decodeOffset, decodeScale; + var decodeOffset = new Array(size); + var decodeScale = new Array(size); + for (var k = 0; k < size; k++) { + decodeOffset[k] = decodeMatrix[size * (size + 1) + k]; + decodeScale[k] = decodeMatrix[k * (size + 1) + k]; + } + for (var i = 0; i < accessorInfo.count; i++) { + for (var k = 0; k < size; k++) { + decodedArr[i * size + k] = arr[i * size + k] * decodeScale[k] + decodeOffset[k]; + } + } + + arr = decodedArr; + } + return arr; + } + /** * @typedef {Object} qtek.loader.GLTF.IResult * @property {qtek.Scene} scene @@ -29028,6 +29120,12 @@ return /******/ (function(modules) { // webpackBootstrap * @type {string} */ crossOrigin: '', + /** + * @type {boolean} + */ + // PENDING + // https://github.com/KhronosGroup/glTF/issues/674 + textureFlipY: false, shaderLibrary: null }, @@ -29111,7 +29209,8 @@ return /******/ (function(modules) { // webpackBootstrap materials: lib.materials, skeletons: lib.skeletons, meshes: lib.meshes, - clips: lib.clips + clips: lib.clips, + nodes: lib.nodes }; } @@ -29126,11 +29225,15 @@ return /******/ (function(modules) { // webpackBootstrap self._parseNodes(json, lib); // Only support one scene. - var sceneInfo = json.scenes[json.scene]; - for (var i = 0; i < sceneInfo.nodes.length; i++) { - var node = lib.nodes[sceneInfo.nodes[i]]; - node.update(); - rootNode.add(node); + if (json.scenes) { + var sceneInfo = json.scenes[json.scene]; + if (sceneInfo) { + for (var i = 0; i < sceneInfo.nodes.length; i++) { + var node = lib.nodes[sceneInfo.nodes[i]]; + node.update(); + rootNode.add(node); + } + } } if (self.includeMesh) { @@ -29275,9 +29378,7 @@ return /******/ (function(modules) { // webpackBootstrap util.defaults(parameters, { wrapS: Texture.REPEAT, wrapT: Texture.REPEAT, - // PENDING - // https://github.com/KhronosGroup/glTF/issues/674 - // flipY: false + flipY: this.textureFlipY }); var target = textureInfo.target || glenum.TEXTURE_2D; @@ -29298,13 +29399,13 @@ return /******/ (function(modules) { // webpackBootstrap _KHRCommonMaterialToStandard: function (materialInfo, lib) { var uniforms = {}; var commonMaterialInfo = materialInfo.extensions['KHR_materials_common']; - uniforms = commonMaterialInfo.values; + uniforms = commonMaterialInfo.values || {}; if (typeof uniforms.diffuse === 'number') { - uniforms.diffuse = lib.textures[uniforms.diffuse] + uniforms.diffuse = lib.textures[uniforms.diffuse] || null; } if (typeof uniforms.emission === 'number') { - uniforms.emission = lib.textures[uniforms.emission] + uniforms.emission = lib.textures[uniforms.emission] || null; } var enabledTextures = []; @@ -29326,7 +29427,10 @@ return /******/ (function(modules) { // webpackBootstrap }); } else { - var fragmentDefines = {}; + var fragmentDefines = { + USE_ROUGHNESS: null, + USE_METALNESS: null + }; if (materialInfo.doubleSided) { fragmentDefines.DOUBLE_SIDED = null; } @@ -29339,7 +29443,7 @@ return /******/ (function(modules) { // webpackBootstrap }); } - if (materialInfo.transparent) { + if (uniforms.transparent) { material.depthMask = false; material.depthTest = true; material.transparent = true; @@ -29375,10 +29479,10 @@ return /******/ (function(modules) { // webpackBootstrap // TODO texCoord var normalTextureIndex = materialInfo.normalTexture.index; if (isStandardMaterial) { - material.normalMap = lib.textures[normalTextureIndex]; + material.normalMap = lib.textures[normalTextureIndex] || null; } else { - material.set('normalMap', lib.textures[normalTextureIndex]); + material.set('normalMap', lib.textures[normalTextureIndex] || null); } } if (uniforms['shininess'] != null) { @@ -29411,19 +29515,19 @@ return /******/ (function(modules) { // webpackBootstrap var enabledTextures = []; // TODO texCoord if (metallicRoughnessMatInfo.baseColorTexture) { - diffuseMap = lib.textures[metallicRoughnessMatInfo.baseColorTexture.index]; + diffuseMap = lib.textures[metallicRoughnessMatInfo.baseColorTexture.index] || null; enabledTextures.push('diffuseMap'); } if (metallicRoughnessMatInfo.metallicRoughnessTexture) { - roughnessMap = lib.textures[metallicRoughnessMatInfo.metallicRoughnessTexture.index]; + roughnessMap = lib.textures[metallicRoughnessMatInfo.metallicRoughnessTexture.index] || null; enabledTextures.push('metalnessMap', 'roughnessMap'); } if (materialInfo.normalTexture) { - normalMap = lib.textures[materialInfo.normalTexture.index]; + normalMap = lib.textures[materialInfo.normalTexture.index] || null; enabledTextures.push('normalMap'); } if (materialInfo.emissiveTexture) { - emissiveMap = lib.textures[materialInfo.emissiveTexture.index]; + emissiveMap = lib.textures[materialInfo.emissiveTexture.index] || null; enabledTextures.push('emissiveMap'); } @@ -29522,22 +29626,16 @@ return /******/ (function(modules) { // webpackBootstrap if (!attributeName) { continue; } - var componentType = attributeInfo.componentType; - var attributeType = attributeInfo.type; - ArrayCtor = ARRAY_CTOR_MAP[componentType] || vendor.Float32Array; - size = SIZE_MAP[attributeType]; - - var bufferViewInfo = json.bufferViews[attributeInfo.bufferView]; - var buffer = lib.buffers[bufferViewInfo.buffer]; - // byteoffset is optional - var byteOffset = (bufferViewInfo.byteOffset || 0) + (attributeInfo.byteOffset || 0); - - var size; - var ArrayCtor; - var attributeArray = new ArrayCtor(buffer, byteOffset, attributeInfo.count * size); + var size = SIZE_MAP[attributeInfo.type]; + var attributeArray = getAccessorData(json, lib, accessorIdx); + // WebGL attribute buffer not support uint32. + // Direct use Float32Array may also have issue. + if (attributeArray instanceof vendor.Uint32Array) { + attributeArray = new Float32Array(attributeArray); + } if (semantic === 'WEIGHTS_0' && size === 4) { // Weight data in QTEK has only 3 component, the last component can be evaluated since it is normalized - var weightArray = new ArrayCtor(attributeInfo.count * 3); + var weightArray = new attributeArray.constructor(attributeInfo.count * 3); for (var i = 0; i < attributeInfo.count; i++) { weightArray[i * 3] = attributeArray[i * 4]; weightArray[i * 3 + 1] = attributeArray[i * 4 + 1]; @@ -29548,6 +29646,21 @@ return /******/ (function(modules) { // webpackBootstrap else { geometry.attributes[attributeName].value = attributeArray; } + var attributeType = 'float'; + if (attributeArray instanceof vendor.Uint16Array) { + attributeType = 'ushort'; + } + else if (attributeArray instanceof vendor.Int16Array) { + attributeType = 'short'; + } + else if (attributeArray instanceof vendor.Uint8Array) { + attributeType = 'ubyte'; + } + else if (attributeArray instanceof vendor.Int8Array) { + attributeType = 'byte'; + } + geometry.attributes[attributeName].type = attributeType; + if (semantic === 'POSITION') { // Bounding Box var min = attributeInfo.min; @@ -29562,14 +29675,7 @@ return /******/ (function(modules) { // webpackBootstrap } // Parse indices - var indicesInfo = json.accessors[primitiveInfo.indices]; - - var bufferViewInfo = json.bufferViews[indicesInfo.bufferView]; - var buffer = lib.buffers[bufferViewInfo.buffer]; - var byteOffset = (bufferViewInfo.byteOffset || 0) + (indicesInfo.byteOffset || 0); - - var IndicesCtor = indicesInfo.componentType === 0x1405 ? vendor.Uint32Array : vendor.Uint16Array; - geometry.indices = new IndicesCtor(buffer, byteOffset, indicesInfo.count); + geometry.indices = getAccessorData(json, lib, primitiveInfo.indices, true); var material = lib.materials[primitiveInfo.material]; // Use default material @@ -29583,7 +29689,9 @@ return /******/ (function(modules) { // webpackBootstrap material: material, mode: [Mesh.POINTS, Mesh.LINES, Mesh.LINE_LOOP, Mesh.LINE_STRIP, Mesh.TRIANGLES, Mesh.TRIANGLE_STRIP, Mesh.TRIANGLE_FAN][primitiveInfo.mode] || Mesh.TRIANGLES }); - if (material.shader.isTextureEnabled('normalMap')) { + if (((material instanceof StandardMaterial) && material.normalMap) + || (material.shader && material.shader.isTextureEnabled('normalMap')) + ) { if (!mesh.geometry.attributes.tangent.value) { mesh.geometry.generateTangents(); } @@ -29702,18 +29810,6 @@ return /******/ (function(modules) { // webpackBootstrap }, _parseAnimations: function (json, lib) { - function getAccessorData(accessorIdx) { - var accessorInfo = json.accessors[accessorIdx]; - - var bufferViewInfo = json.bufferViews[accessorInfo.bufferView]; - var buffer = lib.buffers[bufferViewInfo.buffer]; - var byteOffset = (bufferViewInfo.byteOffset || 0) + (accessorInfo.byteOffset || 0); - var ArrayCtor = ARRAY_CTOR_MAP[accessorInfo.componentType] || vendor.Float32Array; - - var size = SIZE_MAP[accessorInfo.type]; - return new ArrayCtor(buffer, byteOffset, size * accessorInfo.count); - } - function checkChannelPath(channelInfo) { if (channelInfo.path === 'weights') { console.warn('GLTFLoader not support morph targets yet.'); @@ -29742,7 +29838,7 @@ return /******/ (function(modules) { // webpackBootstrap } } - + var timeAccessorMultiplied = {}; util.each(json.animations, function (animationInfo, idx) { var channels = animationInfo.channels.filter(checkChannelPath); @@ -29763,17 +29859,18 @@ return /******/ (function(modules) { // webpackBootstrap clip = clips[channelHash] = new SamplerClip({ target: targetNode, name: targetNode ? targetNode.name : '', - targetNodeIndex: channelInfo.target.node, - // PENDING, If write here loop: true, onframe: clipOnframe }); - clip.channels.time = getAccessorData(samplerInfo.input); + clip.targetNodeIndex = channelInfo.target.node; + clip.channels.time = getAccessorData(json, lib, samplerInfo.input); var frameLen = clip.channels.time.length; - // TODO May share same buffer data ? - for (var k = 0; k < frameLen; k++) { - clip.channels.time[k] *= 1000; + if (!timeAccessorMultiplied[samplerInfo.input]) { + for (var k = 0; k < frameLen; k++) { + clip.channels.time[k] *= 1000; + } + timeAccessorMultiplied[samplerInfo.input] = true; } clip.life = clip.channels.time[frameLen - 1]; @@ -29789,7 +29886,7 @@ return /******/ (function(modules) { // webpackBootstrap path = 'position'; } - clip.channels[path] = getAccessorData(samplerInfo.output); + clip.channels[path] = getAccessorData(json, lib, samplerInfo.output); } for (var key in clips) { @@ -29797,6 +29894,15 @@ return /******/ (function(modules) { // webpackBootstrap } }, this); + + // PENDING + var maxLife = lib.clips.reduce(function (maxTime, clip) { + return Math.max(maxTime, clip.life); + }, 0); + lib.clips.forEach(function (clip) { + clip.life = maxLife; + }); + return lib.clips; } }); @@ -33431,7 +33537,7 @@ return /******/ (function(modules) { // webpackBootstrap dom.removeEventListener('mousewheel', this._mouseWheelHandler); if (this.animation) { - this.animation.removeEventListener('frame', this.update); + this.animation.off('frame', this.update); } this.stopAllAnimation(); }, @@ -33729,6 +33835,11 @@ return /******/ (function(modules) { // webpackBootstrap v.normalize().scale(speed); }, + // TODO Following code will cause decompose problem. + // camera.position.y = 2; + // camera.position.z = -4; + // camera.lookAt(scene.position); + // decomposeTransform: function () { if (!this.target) { return; @@ -33941,7 +34052,7 @@ return /******/ (function(modules) { // webpackBootstrap this._target = val; this.decomposeTransform(); } - }) + }); module.exports = OrbitControl; @@ -35901,7 +36012,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports) { - module.exports = '0.4.2'; + module.exports = '0.4.3'; /***/ }, diff --git a/dist/qtek.min.js b/dist/qtek.min.js index 3c2ec7d15..191fd3b1b 100644 --- a/dist/qtek.min.js +++ b/dist/qtek.min.js @@ -1,14 +1,14 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.qtek=e():t.qtek=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){t.exports=n(119)},function(t,e,n){!function(t){"use strict";var n={};n.exports=e,function(t){if(!e)var e=1e-6;if(!n)var n="undefined"!=typeof Float32Array?Float32Array:Array;if(!r)var r=Math.random;var i={};i.setMatrixArrayType=function(t){n=t},"undefined"!=typeof t&&(t.glMatrix=i);var a=Math.PI/180;i.toRadian=function(t){return t*a};var o={};o.create=function(){var t=new n(2);return t[0]=0,t[1]=0,t},o.clone=function(t){var e=new n(2);return e[0]=t[0],e[1]=t[1],e},o.fromValues=function(t,e){var r=new n(2);return r[0]=t,r[1]=e,r},o.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},o.set=function(t,e,n){return t[0]=e,t[1]=n,t},o.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t},o.subtract=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t},o.sub=o.subtract,o.multiply=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t},o.mul=o.multiply,o.divide=function(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t},o.div=o.divide,o.min=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t},o.max=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t},o.scale=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t},o.scaleAndAdd=function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t},o.distance=function(t,e){var n=e[0]-t[0],r=e[1]-t[1];return Math.sqrt(n*n+r*r)},o.dist=o.distance,o.squaredDistance=function(t,e){var n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r},o.sqrDist=o.squaredDistance,o.length=function(t){var e=t[0],n=t[1];return Math.sqrt(e*e+n*n)},o.len=o.length,o.squaredLength=function(t){var e=t[0],n=t[1];return e*e+n*n},o.sqrLen=o.squaredLength,o.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},o.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},o.normalize=function(t,e){var n=e[0],r=e[1],i=n*n+r*r;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i),t},o.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},o.cross=function(t,e,n){var r=e[0]*n[1]-e[1]*n[0];return t[0]=t[1]=0,t[2]=r,t},o.lerp=function(t,e,n,r){var i=e[0],a=e[1];return t[0]=i+r*(n[0]-i),t[1]=a+r*(n[1]-a),t},o.random=function(t,e){e=e||1;var n=2*r()*Math.PI;return t[0]=Math.cos(n)*e,t[1]=Math.sin(n)*e,t},o.transformMat2=function(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[2]*i,t[1]=n[1]*r+n[3]*i,t},o.transformMat2d=function(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[2]*i+n[4],t[1]=n[1]*r+n[3]*i+n[5],t},o.transformMat3=function(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[3]*i+n[6],t[1]=n[1]*r+n[4]*i+n[7],t},o.transformMat4=function(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[4]*i+n[12],t[1]=n[1]*r+n[5]*i+n[13],t},o.forEach=function(){var t=o.create();return function(e,n,r,i,a,o){var s,u;for(n||(n=2),r||(r=0),u=i?Math.min(i*n+r,e.length):e.length,s=r;s0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t},s.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},s.cross=function(t,e,n){var r=e[0],i=e[1],a=e[2],o=n[0],s=n[1],u=n[2];return t[0]=i*u-a*s,t[1]=a*o-r*u,t[2]=r*s-i*o,t},s.lerp=function(t,e,n,r){var i=e[0],a=e[1],o=e[2];return t[0]=i+r*(n[0]-i),t[1]=a+r*(n[1]-a),t[2]=o+r*(n[2]-o),t},s.random=function(t,e){e=e||1;var n=2*r()*Math.PI,i=2*r()-1,a=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(n)*a,t[1]=Math.sin(n)*a,t[2]=i*e,t},s.transformMat4=function(t,e,n){var r=e[0],i=e[1],a=e[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/o,t[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/o,t[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/o,t},s.transformMat3=function(t,e,n){var r=e[0],i=e[1],a=e[2];return t[0]=r*n[0]+i*n[3]+a*n[6],t[1]=r*n[1]+i*n[4]+a*n[7],t[2]=r*n[2]+i*n[5]+a*n[8],t},s.transformQuat=function(t,e,n){var r=e[0],i=e[1],a=e[2],o=n[0],s=n[1],u=n[2],l=n[3],c=l*r+s*a-u*i,h=l*i+u*r-o*a,f=l*a+o*i-s*r,d=-o*r-s*i-u*a;return t[0]=c*l+d*-o+h*-u-f*-s,t[1]=h*l+d*-s+f*-o-c*-u,t[2]=f*l+d*-u+c*-s-h*-o,t},s.rotateX=function(t,e,n,r){var i=[],a=[];return i[0]=e[0]-n[0],i[1]=e[1]-n[1],i[2]=e[2]-n[2],a[0]=i[0],a[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),a[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),t[0]=a[0]+n[0],t[1]=a[1]+n[1],t[2]=a[2]+n[2],t},s.rotateY=function(t,e,n,r){var i=[],a=[];return i[0]=e[0]-n[0],i[1]=e[1]-n[1],i[2]=e[2]-n[2],a[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),a[1]=i[1],a[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),t[0]=a[0]+n[0],t[1]=a[1]+n[1],t[2]=a[2]+n[2],t},s.rotateZ=function(t,e,n,r){var i=[],a=[];return i[0]=e[0]-n[0],i[1]=e[1]-n[1],i[2]=e[2]-n[2],a[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),a[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),a[2]=i[2],t[0]=a[0]+n[0],t[1]=a[1]+n[1],t[2]=a[2]+n[2],t},s.forEach=function(){var t=s.create();return function(e,n,r,i,a,o){var s,u;for(n||(n=3),r||(r=0),u=i?Math.min(i*n+r,e.length):e.length,s=r;s1?0:Math.acos(i)},s.str=function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},"undefined"!=typeof t&&(t.vec3=s);var u={};u.create=function(){var t=new n(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},u.clone=function(t){var e=new n(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},u.fromValues=function(t,e,r,i){var a=new n(4);return a[0]=t,a[1]=e,a[2]=r,a[3]=i,a},u.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},u.set=function(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t},u.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t},u.subtract=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t},u.sub=u.subtract,u.multiply=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t[3]=e[3]*n[3],t},u.mul=u.multiply,u.divide=function(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t[3]=e[3]/n[3],t},u.div=u.divide,u.min=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t[3]=Math.min(e[3],n[3]),t},u.max=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t[3]=Math.max(e[3],n[3]),t},u.scale=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t},u.scaleAndAdd=function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t},u.distance=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(n*n+r*r+i*i+a*a)},u.dist=u.distance,u.squaredDistance=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return n*n+r*r+i*i+a*a},u.sqrDist=u.squaredDistance,u.length=function(t){var e=t[0],n=t[1],r=t[2],i=t[3];return Math.sqrt(e*e+n*n+r*r+i*i)},u.len=u.length,u.squaredLength=function(t){var e=t[0],n=t[1],r=t[2],i=t[3];return e*e+n*n+r*r+i*i},u.sqrLen=u.squaredLength,u.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},u.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t},u.normalize=function(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],o=n*n+r*r+i*i+a*a;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t[3]=e[3]*o),t},u.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},u.lerp=function(t,e,n,r){var i=e[0],a=e[1],o=e[2],s=e[3];return t[0]=i+r*(n[0]-i),t[1]=a+r*(n[1]-a),t[2]=o+r*(n[2]-o),t[3]=s+r*(n[3]-s),t},u.random=function(t,e){return e=e||1,t[0]=r(),t[1]=r(),t[2]=r(),t[3]=r(),u.normalize(t,t),u.scale(t,t,e),t},u.transformMat4=function(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*o,t[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*o,t[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*o,t[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*o,t},u.transformQuat=function(t,e,n){var r=e[0],i=e[1],a=e[2],o=n[0],s=n[1],u=n[2],l=n[3],c=l*r+s*a-u*i,h=l*i+u*r-o*a,f=l*a+o*i-s*r,d=-o*r-s*i-u*a;return t[0]=c*l+d*-o+h*-u-f*-s,t[1]=h*l+d*-s+f*-o-c*-u,t[2]=f*l+d*-u+c*-s-h*-o,t},u.forEach=function(){var t=u.create();return function(e,n,r,i,a,o){var s,u;for(n||(n=4),r||(r=0),u=i?Math.min(i*n+r,e.length):e.length,s=r;s.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(s.cross(t,i,a),r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=1+o,d.normalize(r,r))}}(),d.setAxes=function(){var t=h.create();return function(e,n,r,i){return t[0]=r[0],t[3]=r[1],t[6]=r[2],t[1]=i[0],t[4]=i[1],t[7]=i[2],t[2]=-n[0],t[5]=-n[1],t[8]=-n[2],d.normalize(e,d.fromMat3(e,t))}}(),d.clone=u.clone,d.fromValues=u.fromValues,d.copy=u.copy,d.set=u.set,d.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},d.setAxisAngle=function(t,e,n){n=.5*n;var r=Math.sin(n);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(n),t},d.add=u.add,d.multiply=function(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3],s=n[0],u=n[1],l=n[2],c=n[3];return t[0]=r*c+o*s+i*l-a*u,t[1]=i*c+o*u+a*s-r*l,t[2]=a*c+o*l+r*u-i*s,t[3]=o*c-r*s-i*u-a*l,t},d.mul=d.multiply,d.scale=u.scale,d.rotateX=function(t,e,n){n*=.5;var r=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(n),u=Math.cos(n);return t[0]=r*u+o*s,t[1]=i*u+a*s,t[2]=a*u-i*s,t[3]=o*u-r*s,t},d.rotateY=function(t,e,n){n*=.5;var r=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(n),u=Math.cos(n);return t[0]=r*u-a*s,t[1]=i*u+o*s,t[2]=a*u+r*s,t[3]=o*u-i*s,t},d.rotateZ=function(t,e,n){n*=.5;var r=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(n),u=Math.cos(n);return t[0]=r*u+i*s,t[1]=i*u-r*s,t[2]=a*u+o*s,t[3]=o*u-a*s,t},d.calculateW=function(t,e){var n=e[0],r=e[1],i=e[2];return t[0]=n,t[1]=r,t[2]=i,t[3]=Math.sqrt(Math.abs(1-n*n-r*r-i*i)),t},d.dot=u.dot,d.lerp=u.lerp,d.slerp=function(t,e,n,r){var i,a,o,s,u,l=e[0],c=e[1],h=e[2],f=e[3],d=n[0],_=n[1],p=n[2],m=n[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-r)*i)/o,u=Math.sin(r*i)/o):(s=1-r,u=r),t[0]=s*l+u*d,t[1]=s*c+u*_,t[2]=s*h+u*p,t[3]=s*f+u*m,t},d.invert=function(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],o=n*n+r*r+i*i+a*a,s=o?1/o:0;return t[0]=-n*s,t[1]=-r*s,t[2]=-i*s,t[3]=a*s,t},d.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},d.length=u.length,d.len=d.length,d.squaredLength=u.squaredLength,d.sqrLen=d.squaredLength,d.normalize=u.normalize,d.fromMat3=function(t,e){var n,r=e[0]+e[4]+e[8];if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{var i=0;e[4]>e[0]&&(i=1),e[8]>e[3*i+i]&&(i=2);var a=(i+1)%3,o=(i+2)%3;n=Math.sqrt(e[3*i+i]-e[3*a+a]-e[3*o+o]+1),t[i]=.5*n,n=.5/n,t[3]=(e[3*a+o]-e[3*o+a])*n,t[a]=(e[3*a+i]+e[3*i+a])*n,t[o]=(e[3*o+i]+e[3*i+o])*n}return t},d.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},"undefined"!=typeof t&&(t.quat=d)}(n.exports)}(this)},function(t,e,n){"use strict";var r=n(68),i=n(43),a=n(15),o=function(){this.__GUID__=a.genGUID()};o.__initializers__=[function(t){a.extend(this,t)}],a.extend(o,r),a.extend(o.prototype,i),t.exports=o},function(t,e,n){"use strict";function r(t,e,n){return tn?n:t}var i=n(1),a=i.vec3,o=function(t,e,n){t=t||0,e=e||0,n=n||0,this._array=a.fromValues(t,e,n),this._dirty=!0};o.prototype={constructor:o,add:function(t){return a.add(this._array,this._array,t._array),this._dirty=!0,this},set:function(t,e,n){return this._array[0]=t,this._array[1]=e,this._array[2]=n,this._dirty=!0,this},setArray:function(t){return this._array[0]=t[0],this._array[1]=t[1],this._array[2]=t[2],this._dirty=!0,this},clone:function(){return new o(this.x,this.y,this.z)},copy:function(t){return a.copy(this._array,t._array),this._dirty=!0,this},cross:function(t,e){return a.cross(this._array,t._array,e._array),this._dirty=!0,this},dist:function(t){return a.dist(this._array,t._array)},distance:function(t){return a.distance(this._array,t._array)},div:function(t){return a.div(this._array,this._array,t._array),this._dirty=!0,this},divide:function(t){return a.divide(this._array,this._array,t._array),this._dirty=!0,this},dot:function(t){return a.dot(this._array,t._array)},len:function(){return a.len(this._array)},length:function(){return a.length(this._array)},lerp:function(t,e,n){return a.lerp(this._array,t._array,e._array,n),this._dirty=!0,this},min:function(t){return a.min(this._array,this._array,t._array),this._dirty=!0,this},max:function(t){return a.max(this._array,this._array,t._array),this._dirty=!0,this},mul:function(t){return a.mul(this._array,this._array,t._array),this._dirty=!0,this},multiply:function(t){return a.multiply(this._array,this._array,t._array),this._dirty=!0,this},negate:function(){return a.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return a.normalize(this._array,this._array),this._dirty=!0,this},random:function(t){return a.random(this._array,t),this._dirty=!0,this},scale:function(t){return a.scale(this._array,this._array,t),this._dirty=!0,this},scaleAndAdd:function(t,e){return a.scaleAndAdd(this._array,this._array,t._array,e),this._dirty=!0,this},sqrDist:function(t){return a.sqrDist(this._array,t._array)},squaredDistance:function(t){return a.squaredDistance(this._array,t._array)},sqrLen:function(){return a.sqrLen(this._array)},squaredLength:function(){return a.squaredLength(this._array)},sub:function(t){return a.sub(this._array,this._array,t._array),this._dirty=!0,this},subtract:function(t){return a.subtract(this._array,this._array,t._array),this._dirty=!0,this},transformMat3:function(t){return a.transformMat3(this._array,this._array,t._array),this._dirty=!0,this},transformMat4:function(t){return a.transformMat4(this._array,this._array,t._array),this._dirty=!0,this},transformQuat:function(t){return a.transformQuat(this._array,this._array,t._array),this._dirty=!0,this},applyProjection:function(t){var e=this._array;if(t=t._array,0===t[15]){var n=-1/e[2];e[0]=t[0]*e[0]*n,e[1]=t[5]*e[1]*n,e[2]=(t[10]*e[2]+t[14])*n}else e[0]=t[0]*e[0]+t[12],e[1]=t[5]*e[1]+t[13],e[2]=t[10]*e[2]+t[14];return this._dirty=!0,this},eulerFromQuat:function(t,e){o.eulerFromQuat(this,t,e)},eulerFromMat3:function(t,e){o.eulerFromMat3(this,t,e); -},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}};var s=Object.defineProperty;if(s){var u=o.prototype;s(u,"x",{get:function(){return this._array[0]},set:function(t){this._array[0]=t,this._dirty=!0}}),s(u,"y",{get:function(){return this._array[1]},set:function(t){this._array[1]=t,this._dirty=!0}}),s(u,"z",{get:function(){return this._array[2]},set:function(t){this._array[2]=t,this._dirty=!0}})}o.add=function(t,e,n){return a.add(t._array,e._array,n._array),t._dirty=!0,t},o.set=function(t,e,n,r){a.set(t._array,e,n,r),t._dirty=!0},o.copy=function(t,e){return a.copy(t._array,e._array),t._dirty=!0,t},o.cross=function(t,e,n){return a.cross(t._array,e._array,n._array),t._dirty=!0,t},o.dist=function(t,e){return a.distance(t._array,e._array)},o.distance=o.dist,o.div=function(t,e,n){return a.divide(t._array,e._array,n._array),t._dirty=!0,t},o.divide=o.div,o.dot=function(t,e){return a.dot(t._array,e._array)},o.len=function(t){return a.length(t._array)},o.lerp=function(t,e,n,r){return a.lerp(t._array,e._array,n._array,r),t._dirty=!0,t},o.min=function(t,e,n){return a.min(t._array,e._array,n._array),t._dirty=!0,t},o.max=function(t,e,n){return a.max(t._array,e._array,n._array),t._dirty=!0,t},o.mul=function(t,e,n){return a.multiply(t._array,e._array,n._array),t._dirty=!0,t},o.multiply=o.mul,o.negate=function(t,e){return a.negate(t._array,e._array),t._dirty=!0,t},o.normalize=function(t,e){return a.normalize(t._array,e._array),t._dirty=!0,t},o.random=function(t,e){return a.random(t._array,e),t._dirty=!0,t},o.scale=function(t,e,n){return a.scale(t._array,e._array,n),t._dirty=!0,t},o.scaleAndAdd=function(t,e,n,r){return a.scaleAndAdd(t._array,e._array,n._array,r),t._dirty=!0,t},o.sqrDist=function(t,e){return a.sqrDist(t._array,e._array)},o.squaredDistance=o.sqrDist,o.sqrLen=function(t){return a.sqrLen(t._array)},o.squaredLength=o.sqrLen,o.sub=function(t,e,n){return a.subtract(t._array,e._array,n._array),t._dirty=!0,t},o.subtract=o.sub,o.transformMat3=function(t,e,n){return a.transformMat3(t._array,e._array,n._array),t._dirty=!0,t},o.transformMat4=function(t,e,n){return a.transformMat4(t._array,e._array,n._array),t._dirty=!0,t},o.transformQuat=function(t,e,n){return a.transformQuat(t._array,e._array,n._array),t._dirty=!0,t};var l=Math.atan2,c=Math.asin,h=Math.abs;o.eulerFromQuat=function(t,e,n){t._dirty=!0,e=e._array;var i=t._array,a=e[0],o=e[1],s=e[2],u=e[3],h=a*a,f=o*o,d=s*s,_=u*u,n=(n||"XYZ").toUpperCase();switch(n){case"XYZ":i[0]=l(2*(a*u-o*s),_-h-f+d),i[1]=c(r(2*(a*s+o*u),-1,1)),i[2]=l(2*(s*u-a*o),_+h-f-d);break;case"YXZ":i[0]=c(r(2*(a*u-o*s),-1,1)),i[1]=l(2*(a*s+o*u),_-h-f+d),i[2]=l(2*(a*o+s*u),_-h+f-d);break;case"ZXY":i[0]=c(r(2*(a*u+o*s),-1,1)),i[1]=l(2*(o*u-s*a),_-h-f+d),i[2]=l(2*(s*u-a*o),_-h+f-d);break;case"ZYX":i[0]=l(2*(a*u+s*o),_-h-f+d),i[1]=c(r(2*(o*u-a*s),-1,1)),i[2]=l(2*(a*o+s*u),_+h-f-d);break;case"YZX":i[0]=l(2*(a*u-s*o),_-h+f-d),i[1]=l(2*(o*u-a*s),_+h-f-d),i[2]=c(r(2*(a*o+s*u),-1,1));break;case"XZY":i[0]=l(2*(a*u+o*s),_-h+f-d),i[1]=l(2*(a*s+o*u),_+h-f-d),i[2]=c(r(2*(s*u-a*o),-1,1));break;default:console.warn("Unkown order: "+n)}return t},o.eulerFromMat3=function(t,e,n){var i=e._array,a=i[0],o=i[3],s=i[6],u=i[1],f=i[4],d=i[7],_=i[2],p=i[5],m=i[8],v=t._array,n=(n||"XYZ").toUpperCase();switch(n){case"XYZ":v[1]=c(r(s,-1,1)),h(s)<.99999?(v[0]=l(-d,m),v[2]=l(-o,a)):(v[0]=l(p,f),v[2]=0);break;case"YXZ":v[0]=c(-r(d,-1,1)),h(d)<.99999?(v[1]=l(s,m),v[2]=l(u,f)):(v[1]=l(-_,a),v[2]=0);break;case"ZXY":v[0]=c(r(p,-1,1)),h(p)<.99999?(v[1]=l(-_,m),v[2]=l(-o,f)):(v[1]=0,v[2]=l(u,a));break;case"ZYX":v[1]=c(-r(_,-1,1)),h(_)<.99999?(v[0]=l(p,m),v[2]=l(u,a)):(v[0]=0,v[2]=l(-o,f));break;case"YZX":v[2]=c(r(u,-1,1)),h(u)<.99999?(v[0]=l(-d,f),v[1]=l(-_,a)):(v[0]=0,v[1]=l(s,m));break;case"XZY":v[2]=c(-r(o,-1,1)),h(o)<.99999?(v[0]=l(p,f),v[1]=l(s,a)):(v[0]=l(-d,m),v[1]=0);break;default:console.warn("Unkown order: "+n)}return t._dirty=!0,t},o.POSITIVE_X=new o(1,0,0),o.NEGATIVE_X=new o((-1),0,0),o.POSITIVE_Y=new o(0,1,0),o.NEGATIVE_Y=new o(0,(-1),0),o.POSITIVE_Z=new o(0,0,1),o.NEGATIVE_Z=new o(0,0,(-1)),o.UP=new o(0,1,0),o.ZERO=new o(0,0,0),t.exports=o},function(t,e){t.exports={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(t,e,n){"use strict";function r(){return{locations:{},attriblocations:{}}}function i(t,e,n){if(!t.getShaderParameter(e,t.COMPILE_STATUS))return[t.getShaderInfoLog(e),a(n)].join("\n")}function a(t){for(var e=t.split("\n"),n=0,r=e.length;n0&&r.push("#define "+i.toUpperCase()+"_COUNT "+a)}for(var o in n){var s=n[o];s.enabled&&r.push("#define "+o.toUpperCase()+"_ENABLED")}for(var o in t){var u=t[o];null===u?r.push("#define "+o):r.push("#define "+o+" "+u.toString())}return r.join("\n")},_unrollLoop:function(t,e){function n(t,n,i,a){var o="";isNaN(n)&&(n=n in e?e[n]:r[n]),isNaN(i)&&(i=i in e?e[i]:r[i]);for(var s=parseInt(n);s=0)n.attribSemantics[u]={symbol:a,type:c},h=!1;else if(E.indexOf(u)>=0){var f=!1,d=u;u.match(/TRANSPOSE$/)&&(f=!0,d=u.slice(0,-9)),n.matrixSemantics[u]={symbol:a,type:c,isTranspose:f,semanticNoTranspose:d},h=!1}else if(T.indexOf(u)>=0)n.uniformSemantics[u]={symbol:a,type:c},h=!1;else if("unconfigurable"===u)h=!1;else{if(l=n._parseDefaultValue(i,u),!l)throw new Error('Unkown semantic "'+u+'"');u=""}h&&(e[a]={type:c,value:o?y.array:l||y[i],semantic:u||null})}return["uniform",i,a,o].join(" ")+";\n"}}var e={},n=this,r="vertex";this._uniformList=[],this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(_,t),r="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(_,t),n.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=e},_parseDefaultValue:function(t,e){var n=/\[\s*(.*)\s*\]/;{if("vec2"!==t&&"vec3"!==t&&"vec4"!==t)return"bool"===t?function(){return"true"===e.toLowerCase()}:"float"===t?function(){return parseFloat(e)}:"int"===t?function(){return parseInt(e)}:void 0;var r=n.exec(e)[1];if(r){var i=r.split(/\s*,\s*/);return function(){return new l.Float32Array(i)}}}},createUniforms:function(){var t={};for(var e in this.uniformTemplates){var n=this.uniformTemplates[e];t[e]={type:n.type,value:n.value()}}return t},attached:function(){this._attacheMaterialNumber++},detached:function(){this._attacheMaterialNumber--},isAttachedToAny:function(){return 0!==this._attacheMaterialNumber},_parseAttributes:function(){function t(t,r,i,a,o){if(r&&i){var s=1;switch(r){case"vec4":s=4;break;case"vec3":s=3;break;case"vec2":s=2;break;case"float":s=1}if(e[i]={type:"float",size:s,semantic:o||null},o){if(x.indexOf(o)<0)throw new Error('Unkown semantic "'+o+'"');n.attribSemantics[o]={symbol:i,type:r}}}return["attribute",r,i].join(" ")+";\n"}var e={},n=this;this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(p,t),this.attributeTemplates=e},_parseDefines:function(){function t(t,r,i){var a="vertex"===n?e.vertexDefines:e.fragmentDefines;return a[r]||("false"==i?a[r]=!1:"true"==i?a[r]=!0:a[r]=i?parseFloat(i):null),""}var e=this,n="vertex";this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(m,t),n="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(m,t)},_buildProgram:function(t,e,n){var r=this._cache;r.get("program")&&t.deleteProgram(r.get("program"));var a=t.createProgram(),o=t.createShader(t.VERTEX_SHADER);t.shaderSource(o,e),t.compileShader(o);var s=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(s,n),t.compileShader(s);var u=i(t,o,e);if(u)return u;if(u=i(t,s,n))return u;if(t.attachShader(a,o),t.attachShader(a,s),this.attribSemantics.POSITION)t.bindAttribLocation(a,0,this.attribSemantics.POSITION.symbol);else{var l=Object.keys(this.attributeTemplates);t.bindAttribLocation(a,0,l[0])}if(t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))return"Could not link program\nVALIDATE_STATUS: "+t.getProgramParameter(a,t.VALIDATE_STATUS)+", gl error ["+t.getError()+"]";for(var c=0;c=0},set:function(t,e){if("object"==typeof t)for(var n in t){var r=t[n];this.set(n,r)}else{var i=this.uniforms[t];i&&(i.value=e)}},get:function(t){var e=this.uniforms[t];if(e)return e.value},attachShader:function(t,e){this.shader&&this.shader.detached();var n=this.uniforms;this.uniforms=t.createUniforms(),this.shader=t;var r=this.uniforms;if(this._enabledUniforms=Object.keys(r),this._enabledUniforms.sort(),e)for(var i in n)r[i]&&(r[i].value=n[i].value);t.attached()},detachShader:function(){this.shader.detached(),this.shader=null,this.uniforms={}},clone:function(){var t=new this.constructor({name:this.name,shader:this.shader});for(var e in this.uniforms)t.uniforms[e].value=this.uniforms[e].value;return t.depthTest=this.depthTest,t.depthMask=this.depthMask,t.transparent=this.transparent,t.blend=this.blend,t},dispose:function(t,e){if(e)for(var n in this.uniforms){var r=this.uniforms[n].value;if(r)if(r instanceof i)r.dispose(t);else if(r instanceof Array)for(var a=0;a>e;return t+1},dispose:function(t){var e=this._cache;e.use(t.__GLID__);var n=e.get("webgl_texture");n&&t.deleteTexture(n),e.deleteContext(t.__GLID__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(s.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t}}),Object.defineProperty(s.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t}}),s.BYTE=i.BYTE,s.UNSIGNED_BYTE=i.UNSIGNED_BYTE,s.SHORT=i.SHORT,s.UNSIGNED_SHORT=i.UNSIGNED_SHORT,s.INT=i.INT,s.UNSIGNED_INT=i.UNSIGNED_INT,s.FLOAT=i.FLOAT,s.HALF_FLOAT=36193,s.UNSIGNED_INT_24_8_WEBGL=34042,s.DEPTH_COMPONENT=i.DEPTH_COMPONENT,s.DEPTH_STENCIL=i.DEPTH_STENCIL,s.ALPHA=i.ALPHA,s.RGB=i.RGB,s.RGBA=i.RGBA,s.LUMINANCE=i.LUMINANCE,s.LUMINANCE_ALPHA=i.LUMINANCE_ALPHA,s.SRGB=35904,s.SRGB_ALPHA=35906,s.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,s.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,s.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,s.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,s.NEAREST=i.NEAREST,s.LINEAR=i.LINEAR,s.NEAREST_MIPMAP_NEAREST=i.NEAREST_MIPMAP_NEAREST,s.LINEAR_MIPMAP_NEAREST=i.LINEAR_MIPMAP_NEAREST,s.NEAREST_MIPMAP_LINEAR=i.NEAREST_MIPMAP_LINEAR,s.LINEAR_MIPMAP_LINEAR=i.LINEAR_MIPMAP_LINEAR,s.REPEAT=i.REPEAT,s.CLAMP_TO_EDGE=i.CLAMP_TO_EDGE,s.MIRRORED_REPEAT=i.MIRRORED_REPEAT,t.exports=s},function(t,e,n){var r=n(7),i=n(14),a=n(4),o=n(52),s=o.isPowerOfTwo,u=r.extend(function(){return{image:null,pixels:null,mipmaps:[]}},{update:function(t){t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),this.updateCommon(t);var e=this.format,n=this.type;t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,this.wrapS),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,this.wrapT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,this.magFilter),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,this.minFilter);var r=i.getExtension(t,"EXT_texture_filter_anisotropic");if(r&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===n){var o=i.getExtension(t,"OES_texture_half_float");o||(n=a.FLOAT)}if(this.mipmaps.length)for(var s=this.width,u=this.height,l=0;l=r.COMPRESSED_RGB_S3TC_DXT1_EXT?t.compressedTexImage2D(t.TEXTURE_2D,n,o,i,a,0,e.pixels):t.texImage2D(t.TEXTURE_2D,n,o,i,a,0,o,s,e.pixels)},generateMipmap:function(t){this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_2D))},isPowerOfTwo:function(){var t,e;return this.image?(t=this.image.width,e=this.image.height):(t=this.width,e=this.height),s(t)&&s(e)},isRenderable:function(){return this.image?"CANVAS"===this.image.nodeName||"VIDEO"===this.image.nodeName||this.image.complete:!(!this.width||!this.height)},bind:function(t){t.bindTexture(t.TEXTURE_2D,this.getWebGLTexture(t)); -},unbind:function(t){t.bindTexture(t.TEXTURE_2D,null)},load:function(t,e){var n=new Image;e&&(n.crossOrigin=e);var r=this;return n.onload=function(){r.dirty(),r.trigger("success",r),n.onload=null},n.onerror=function(){r.trigger("error",r),n.onerror=null},n.src=t,this.image=n,this}});Object.defineProperty(u.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(t){this.image?console.warn("Texture from image can't set width"):(this._width!==t&&this.dirty(),this._width=t)}}),Object.defineProperty(u.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(t){this.image?console.warn("Texture from image can't set height"):(this._height!==t&&this.dirty(),this._height=t)}}),t.exports=u},function(t,e,n){"use strict";var r=n(3),i=n(1),a=i.vec3,o=a.copy,s=a.set,u=function(t,e){this.min=t||new r(1/0,1/0,1/0),this.max=e||new r((-(1/0)),(-(1/0)),(-(1/0)))};u.prototype={constructor:u,updateFromVertices:function(t){if(t.length>0){var e=this.min,n=this.max,r=e._array,i=n._array;o(r,t[0]),o(i,t[0]);for(var a=1;ai[0]&&(i[0]=s[0]),s[1]>i[1]&&(i[1]=s[1]),s[2]>i[2]&&(i[2]=s[2])}e._dirty=!0,n._dirty=!0}},union:function(t){var e=this.min,n=this.max;return a.min(e._array,e._array,t.min._array),a.max(n._array,n._array,t.max._array),e._dirty=!0,n._dirty=!0,this},intersection:function(t){var e=this.min,n=this.max;return a.max(e._array,e._array,t.min._array),a.min(n._array,n._array,t.max._array),e._dirty=!0,n._dirty=!0,this},intersectBoundingBox:function(t){var e=this.min._array,n=this.max._array,r=t.min._array,i=t.max._array;return!(e[0]>i[0]||e[1]>i[1]||e[2]>i[2]||n[0]=i[0]&&n[1]>=i[1]&&n[2]>=i[2]},containPoint:function(t){var e=this.min._array,n=this.max._array,r=t._array;return e[0]<=r[0]&&e[1]<=r[1]&&e[2]<=r[2]&&n[0]>=r[0]&&n[1]>=r[1]&&n[2]>=r[2]},isFinite:function(){var t=this.min._array,e=this.max._array;return isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])&&isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])},applyTransform:function(){var t=a.create(),e=a.create(),n=a.create(),r=a.create(),i=a.create(),o=a.create();return function(a){var s=this.min._array,u=this.max._array,l=a._array;return t[0]=l[0]*s[0],t[1]=l[1]*s[0],t[2]=l[2]*s[0],e[0]=l[0]*u[0],e[1]=l[1]*u[0],e[2]=l[2]*u[0],n[0]=l[4]*s[1],n[1]=l[5]*s[1],n[2]=l[6]*s[1],r[0]=l[4]*u[1],r[1]=l[5]*u[1],r[2]=l[6]*u[1],i[0]=l[8]*s[2],i[1]=l[9]*s[2],i[2]=l[10]*s[2],o[0]=l[8]*u[2],o[1]=l[9]*u[2],o[2]=l[10]*u[2],s[0]=Math.min(t[0],e[0])+Math.min(n[0],r[0])+Math.min(i[0],o[0])+l[12],s[1]=Math.min(t[1],e[1])+Math.min(n[1],r[1])+Math.min(i[1],o[1])+l[13],s[2]=Math.min(t[2],e[2])+Math.min(n[2],r[2])+Math.min(i[2],o[2])+l[14],u[0]=Math.max(t[0],e[0])+Math.max(n[0],r[0])+Math.max(i[0],o[0])+l[12],u[1]=Math.max(t[1],e[1])+Math.max(n[1],r[1])+Math.max(i[1],o[1])+l[13],u[2]=Math.max(t[2],e[2])+Math.max(n[2],r[2])+Math.max(i[2],o[2])+l[14],this.min._dirty=!0,this.max._dirty=!0,this}}(),applyProjection:function(t){var e=this.min._array,n=this.max._array,r=t._array,i=e[0],a=e[1],o=e[2],s=n[0],u=n[1],l=e[2],c=n[0],h=n[1],f=n[2];if(1===r[15])e[0]=r[0]*i+r[12],e[1]=r[5]*a+r[13],n[2]=r[10]*o+r[14],n[0]=r[0]*c+r[12],n[1]=r[5]*h+r[13],e[2]=r[10]*f+r[14];else{var d=-1/o;e[0]=r[0]*i*d,e[1]=r[5]*a*d,n[2]=(r[10]*o+r[14])*d,d=-1/l,n[0]=r[0]*s*d,n[1]=r[5]*u*d,d=-1/f,e[2]=(r[10]*f+r[14])*d}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var t=this.vertices;if(!t){for(var t=[],e=0;e<8;e++)t[e]=a.fromValues(0,0,0);this.vertices=t}var n=this.min._array,r=this.max._array;return s(t[0],n[0],n[1],n[2]),s(t[1],n[0],r[1],n[2]),s(t[2],r[0],n[1],n[2]),s(t[3],r[0],r[1],n[2]),s(t[4],n[0],n[1],r[2]),s(t[5],n[0],r[1],r[2]),s(t[6],r[0],n[1],r[2]),s(t[7],r[0],r[1],r[2]),this},copy:function(t){var e=this.min,n=this.max;return o(e._array,t.min._array),o(n._array,t.max._array),e._dirty=!0,n._dirty=!0,this},clone:function(){var t=new u;return t.copy(this),t}},t.exports=u},function(t,e,n){"use strict";function r(t){return"attr_"+t}var i=n(58),a=n(9),o=n(1),s=n(11),u=n(4),l=o.mat4,c=o.vec3,h=i.StaticAttribute,f=c.create,d=c.add,_=c.set,p=i.extend(function(){return{attributes:{position:new h("position","float",3,"POSITION"),texcoord0:new h("texcoord0","float",2,"TEXCOORD_0"),texcoord1:new h("texcoord1","float",2,"TEXCOORD_1"),normal:new h("normal","float",3,"NORMAL"),tangent:new h("tangent","float",4,"TANGENT"),color:new h("color","float",4,"COLOR"),weight:new h("weight","float",3,"WEIGHT"),joint:new h("joint","float",4,"JOINT"),barycentric:new h("barycentric","float",3,null)},hint:u.STATIC_DRAW,indices:null,_normalType:"vertex",_enabledAttributes:null}},{updateBoundingBox:function(){var t=this.boundingBox;t||(t=this.boundingBox=new a);var e=this.attributes.position.value;if(e&&e.length){var n=t.min,r=t.max,i=n._array,o=r._array;c.set(i,e[0],e[1],e[2]),c.set(o,e[0],e[1],e[2]);for(var s=3;so[0]&&(o[0]=u),l>o[1]&&(o[1]=l),h>o[2]&&(o[2]=h)}n._dirty=!0,r._dirty=!0}},dirty:function(){for(var t=this.getEnabledAttributes(),e=0;e=0){e||(e=f());var n=this.indices;return e[0]=n[3*t],e[1]=n[3*t+1],e[2]=n[3*t+2],e}},setTriangleIndices:function(t,e){var n=this.indices;n[3*t]=e[0],n[3*t+1]=e[1],n[3*t+2]=e[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(t){var e,n=this.vertexCount>65535?s.Uint32Array:s.Uint16Array;if(t[0]&&t[0].length){var r=0,i=3;e=new n(t.length*i);for(var a=0;a=0&&(e.splice(n,1),delete this.attributes[t],!0)},getEnabledAttributes:function(){var t=this._enabledAttributes,e=this._attributeList;if(t)return t;for(var n=[],r=this.vertexCount,i=0;i65535&&(this.indices=new s.Uint32Array(this.indices));for(var t=this.attributes,e=this.indices,n=this.getEnabledAttributes(),r={},i=0;i256?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(),e.setUniform(t,"1f","skinMatricesTextureSize",i)}else e.setUniformOfSemantic(t,"SKIN_MATRIX",n)}return r.prototype.render.call(this,t,e)},getSkinMatricesTexture:function(){return this._skinMatricesTexture=this._skinMatricesTexture||new a({type:i.FLOAT,minFilter:i.NEAREST,magFilter:i.NEAREST,useMipmap:!1,flipY:!1}),this._skinMatricesTexture}});o.POINTS=i.POINTS,o.LINES=i.LINES,o.LINE_LOOP=i.LINE_LOOP,o.LINE_STRIP=i.LINE_STRIP,o.TRIANGLES=i.TRIANGLES,o.TRIANGLE_STRIP=i.TRIANGLE_STRIP,o.TRIANGLE_FAN=i.TRIANGLE_FAN,o.BACK=i.BACK,o.FRONT=i.FRONT,o.FRONT_AND_BACK=i.FRONT_AND_BACK,o.CW=i.CW,o.CCW=i.CCW,t.exports=o},function(t,e){"use strict";var n=["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear","OES_standard_derivatives","OES_vertex_array_object","OES_element_index_uint","WEBGL_compressed_texture_s3tc","WEBGL_depth_texture","EXT_texture_filter_anisotropic","EXT_shader_texture_lod","WEBGL_draw_buffers","EXT_frag_depth","EXT_sRGB"],r=["MAX_TEXTURE_SIZE","MAX_CUBE_MAP_TEXTURE_SIZE"],i={},a={},o={initialize:function(t){var e=t.__GLID__;if(!i[e]){i[e]={},a[e]={};for(var o=0;o1&&t.texParameterf(t.TEXTURE_CUBE_MAP,r.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===n){var i=a.getExtension(t,"OES_texture_half_float");i||(n=o.FLOAT)}if(this.mipmaps.length)for(var s=this.width,u=this.height,l=0;l0?(this._restartInLoop(t),this._loopRemained--,"restart"):(this._needsRemove=!0,"finish"):null}}},setTime:function(t){return this.step(t+this._startTime)},restart:function(t){var e=0;t&&(this._elapse(t),e=this._elapsedTime%this.life),t=t||(new Date).getTime(),this._startTime=t-e+this.delay,this._elapsedTime=0,this._needsRemove=!1,this._paused=!1},getElapsedTime:function(){return this._elapsedTime},_restartInLoop:function(t){this._startTime=t+this.gap,this._elapsedTime=0},_elapse:function(t,e){this._elapsedTime+=e*this.playbackRate},fire:function(t,e){var n="on"+t;this[n]&&this[n](this.target,e)},clone:function(){var t=new this.constructor;return t.name=this.name,t._loop=this._loop,t._loopRemained=this._loopRemained,t.life=this.life,t.gap=this.gap,t.delay=this.delay,t},pause:function(){this._paused=!0},resume:function(){this._paused=!1}},a.prototype.constructor=a,t.exports=a},function(t,e,n){"use strict";var r=n(36),i=r.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var t=this.fov/180*Math.PI;this.projectionMatrix.perspective(t,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var t=this.projectionMatrix._array,e=2*Math.atan(1/t[5]);this.fov=e/Math.PI*180,this.aspect=t[5]/t[0],this.near=t[14]/(t[10]-1),this.far=t[14]/(t[10]+1)},clone:function(){var t=r.prototype.clone.call(this);return t.fov=this.fov,t.aspect=this.aspect,t.near=this.near,t.far=this.far,t}});t.exports=i},function(t,e,n){"use strict";var r=n(2),i=n(28),a=n(45),o=n(5),s=n(6),u=n(13),l=n(14),c=n(4);o["import"](n(134));var h=new a,f=new u({geometry:h,frustumCulling:!1}),d=new i,_=r.extend(function(){return{fragment:"",outputs:null,material:null,blendWithPrevious:!1,clearColor:!1,clearDepth:!0}},function(){var t=new o({vertex:o.source("qtek.compositor.vertex"),fragment:this.fragment}),e=new s({shader:t});t.enableTexturesAll(),this.material=e},{setUniform:function(t,e){var n=this.material.uniforms[t];n&&(n.value=e)},getUniform:function(t){var e=this.material.uniforms[t];if(e)return e.value},attachOutput:function(t,e){this.outputs||(this.outputs={}),e=e||c.COLOR_ATTACHMENT0,this.outputs[e]=t},detachOutput:function(t){for(var e in this.outputs)this.outputs[e]===t&&(this.outputs[e]=null)},bind:function(t,e){if(this.outputs)for(var n in this.outputs){var r=this.outputs[n];r&&e.attach(r,n)}e&&e.bind(t)},unbind:function(t,e){e.unbind(t)},render:function(t,e){var n=t.gl;if(e){this.bind(t,e);var r=l.getExtension(n,"EXT_draw_buffers");if(r&&this.outputs){var i=[];for(var a in this.outputs)a=+a,a>=n.COLOR_ATTACHMENT0&&a<=n.COLOR_ATTACHMENT0+8&&i.push(a);r.drawBuffersEXT(i)}}this.trigger("beforerender",this,t);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;s instanceof Array&&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(t),this.trigger("afterrender",this,t),e&&this.unbind(t,e)},renderQuad:function(t){f.material=this.material,t.renderQueue([f],d)},dispose:function(t){this.material.dispose(t)}});t.exports=_},function(t,e,n){"use strict";function r(t,e){if(e.castShadow&&!t.castShadow)return!0}var i=n(18),a=n(12),o=n(9),s=i.extend(function(){return{material:null,autoUpdate:!0,opaqueQueue:[],transparentQueue:[],lights:[],viewBoundingBoxLastFrame:new o,_lightUniforms:{},_lightNumber:{},_opaqueObjectCount:0,_transparentObjectCount:0,_nodeRepository:{}}},function(){this._scene=this},{addToScene:function(t){t.name&&(this._nodeRepository[t.name]=t)},removeFromScene:function(t){t.name&&delete this._nodeRepository[t.name]},getNode:function(t){return this._nodeRepository[t]},cloneNode:function(t){var e=t.clone(),n={},r=function(i,a){i.skeleton&&(a.skeleton=i.skeleton.clone(t,e),a.joints=i.joints.slice()),i.material&&(n[i.material.__GUID__]={oldMat:i.material});for(var o=0;o0&&this._updateRenderQueue(r)}},_updateLightUniforms:function(){var t=this.lights;t.sort(r);var e=this._lightUniforms;for(var n in e)for(var i in e[n])e[n][i].value.length=0;for(var a=0;a0){var e=this.outputs[t];e.keepLastFrame?(this._prevOutputTextures[t]&&this._compositor.releaseTexture(this._prevOutputTextures[t]),this._prevOutputTextures[t]=this._outputTextures[t]):this._compositor.releaseTexture(this._outputTextures[t])}}});t.exports=i},function(t,e){"use strict";function n(t){var e=new XMLHttpRequest;e.open("get",t.url),e.responseType=t.responseType||"text",t.onprogress&&(e.onprogress=function(e){if(e.lengthComputable){var n=e.loaded/e.total;t.onprogress(n,e.loaded,e.total)}else t.onprogress(null)}),e.onload=function(n){t.onload&&t.onload(e.response)},t.onerror&&(e.onerror=t.onerror),e.send(null)}t.exports={get:n}},function(t,e,n){"use strict";var r=n(1),i=r.vec2,a=function(t,e){t=t||0,e=e||0,this._array=i.fromValues(t,e),this._dirty=!0};if(a.prototype={constructor:a,add:function(t){return i.add(this._array,this._array,t._array),this._dirty=!0,this},set:function(t,e){return this._array[0]=t,this._array[1]=e,this._dirty=!0,this},setArray:function(t){return this._array[0]=t[0],this._array[1]=t[1],this._dirty=!0,this},clone:function(){return new a(this.x,this.y)},copy:function(t){return i.copy(this._array,t._array),this._dirty=!0,this},cross:function(t,e){return i.cross(t._array,this._array,e._array),t._dirty=!0,this},dist:function(t){return i.dist(this._array,t._array)},distance:function(t){return i.distance(this._array,t._array)},div:function(t){return i.div(this._array,this._array,t._array),this._dirty=!0,this},divide:function(t){return i.divide(this._array,this._array,t._array),this._dirty=!0,this},dot:function(t){return i.dot(this._array,t._array)},len:function(){return i.len(this._array)},length:function(){return i.length(this._array)},lerp:function(t,e,n){return i.lerp(this._array,t._array,e._array,n),this._dirty=!0,this},min:function(t){return i.min(this._array,this._array,t._array),this._dirty=!0,this},max:function(t){return i.max(this._array,this._array,t._array),this._dirty=!0,this},mul:function(t){return i.mul(this._array,this._array,t._array),this._dirty=!0,this},multiply:function(t){return i.multiply(this._array,this._array,t._array),this._dirty=!0,this},negate:function(){return i.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return i.normalize(this._array,this._array),this._dirty=!0,this},random:function(t){return i.random(this._array,t),this._dirty=!0,this},scale:function(t){return i.scale(this._array,this._array,t),this._dirty=!0,this},scaleAndAdd:function(t,e){return i.scaleAndAdd(this._array,this._array,t._array,e),this._dirty=!0,this},sqrDist:function(t){return i.sqrDist(this._array,t._array)},squaredDistance:function(t){return i.squaredDistance(this._array,t._array)},sqrLen:function(){return i.sqrLen(this._array)},squaredLength:function(){return i.squaredLength(this._array)},sub:function(t){return i.sub(this._array,this._array,t._array),this._dirty=!0,this},subtract:function(t){return i.subtract(this._array,this._array,t._array),this._dirty=!0,this},transformMat2:function(t){return i.transformMat2(this._array,this._array,t._array),this._dirty=!0,this},transformMat2d:function(t){return i.transformMat2d(this._array,this._array,t._array),this._dirty=!0,this},transformMat3:function(t){return i.transformMat3(this._array,this._array,t._array),this._dirty=!0,this},transformMat4:function(t){return i.transformMat4(this._array,this._array,t._array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}},Object.defineProperty){var o=a.prototype;Object.defineProperty(o,"x",{get:function(){return this._array[0]},set:function(t){this._array[0]=t,this._dirty=!0}}),Object.defineProperty(o,"y",{get:function(){return this._array[1]},set:function(t){this._array[1]=t,this._dirty=!0}})}a.add=function(t,e,n){return i.add(t._array,e._array,n._array),t._dirty=!0,t},a.set=function(t,e,n){return i.set(t._array,e,n),t._dirty=!0,t},a.copy=function(t,e){return i.copy(t._array,e._array),t._dirty=!0,t},a.cross=function(t,e,n){return i.cross(t._array,e._array,n._array),t._dirty=!0,t},a.dist=function(t,e){return i.distance(t._array,e._array)},a.distance=a.dist,a.div=function(t,e,n){return i.divide(t._array,e._array,n._array),t._dirty=!0,t},a.divide=a.div,a.dot=function(t,e){return i.dot(t._array,e._array)},a.len=function(t){return i.length(t._array)},a.lerp=function(t,e,n,r){return i.lerp(t._array,e._array,n._array,r),t._dirty=!0,t},a.min=function(t,e,n){return i.min(t._array,e._array,n._array),t._dirty=!0,t},a.max=function(t,e,n){return i.max(t._array,e._array,n._array),t._dirty=!0,t},a.mul=function(t,e,n){return i.multiply(t._array,e._array,n._array),t._dirty=!0,t},a.multiply=a.mul,a.negate=function(t,e){return i.negate(t._array,e._array),t._dirty=!0,t},a.normalize=function(t,e){return i.normalize(t._array,e._array),t._dirty=!0,t},a.random=function(t,e){return i.random(t._array,e),t._dirty=!0,t},a.scale=function(t,e,n){return i.scale(t._array,e._array,n),t._dirty=!0,t},a.scaleAndAdd=function(t,e,n,r){return i.scaleAndAdd(t._array,e._array,n._array,r),t._dirty=!0,t},a.sqrDist=function(t,e){return i.sqrDist(t._array,e._array)},a.squaredDistance=a.sqrDist,a.sqrLen=function(t){return i.sqrLen(t._array)},a.squaredLength=a.sqrLen,a.sub=function(t,e,n){return i.subtract(t._array,e._array,n._array),t._dirty=!0,t},a.subtract=a.sub,a.transformMat2=function(t,e,n){return i.transformMat2(t._array,e._array,n._array),t._dirty=!0,t},a.transformMat2d=function(t,e,n){return i.transformMat2d(t._array,e._array,n._array),t._dirty=!0,t},a.transformMat3=function(t,e,n){return i.transformMat3(t._array,e._array,n._array),t._dirty=!0,t},a.transformMat4=function(t,e,n){return i.transformMat4(t._array,e._array,n._array),t._dirty=!0,t},t.exports=a},function(t,e,n){function r(){this._pool={}}function i(t,e,n){o[t]={vertex:e,fragment:n}}var a=n(5),o=(n(15),{});r.prototype.get=function(t,e){var n=[],r={},i={};"string"==typeof e?n=Array.prototype.slice.call(arguments,1):"[object Object]"==Object.prototype.toString.call(e)?(n=e.textures||[],r=e.vertexDefines||{},i=e.fragmentDefines||{}):e instanceof Array&&(n=e);var s=Object.keys(r),u=Object.keys(i);n.sort(),s.sort(),u.sort();var l=[t];l=l.concat(n);for(var c=0;c0},beforeRender:function(t){},afterRender:function(t,e){},getBoundingBox:function(t,e){return e=a.prototype.getBoundingBox.call(this,t,e),this.geometry&&this.geometry.boundingBox&&e.union(this.geometry.boundingBox),e},render:function(t,e){var e=e||this.material.shader,n=this.geometry,a=this.mode,h=n.vertexCount,f=n.isUseIndices(),d=s.getExtension(t,"OES_element_index_uint"),_=d&&h>65535,p=_?t.UNSIGNED_INT:t.UNSIGNED_SHORT,m=s.getExtension(t,"OES_vertex_array_object"),v=!n.dynamic,g=this._renderInfo;g.vertexCount=h,g.triangleCount=0,g.drawCallCount=0;var y=!1;if(i=t.__GLID__+"-"+n.__GUID__+"-"+e.__GUID__,i!==u?y=!0:(h>65535&&!d&&f||m&&v||n._cache.isDirty())&&(y=!0),u=i,y){var x=this._drawCache[i];if(!x){var T=n.getBufferChunks(t);if(!T)return;x=[];for(var E=0;Eh)){var f=Math.sqrt(h-c),d=u-f,_=u+f;return i||(i=new r),d<0?_<0?null:(a.scaleAndAdd(i._array,o,s,_),i):(a.scaleAndAdd(i._array,o,s,d),i)}}}(),intersectBoundingBox:function(t,e){var n,i,o,s,u,l,c=this.direction._array,h=this.origin._array,f=t.min._array,d=t.max._array,_=1/c[0],p=1/c[1],m=1/c[2];if(_>=0?(n=(f[0]-h[0])*_,i=(d[0]-h[0])*_):(i=(f[0]-h[0])*_,n=(d[0]-h[0])*_),p>=0?(o=(f[1]-h[1])*p,s=(d[1]-h[1])*p):(s=(f[1]-h[1])*p,o=(d[1]-h[1])*p),n>s||o>i)return null;if((o>n||n!==n)&&(n=o),(s=0?(u=(f[2]-h[2])*m,l=(d[2]-h[2])*m):(l=(f[2]-h[2])*m,u=(d[2]-h[2])*m),n>l||u>i)return null;if((u>n||n!==n)&&(n=u),(l=0?n:i;return e||(e=new r),a.scaleAndAdd(e._array,h,c,v),e},intersectTriangle:function(){var t=a.create(),e=a.create(),n=a.create(),i=a.create();return function(s,u,l,c,h,f){var d=this.direction._array,_=this.origin._array;s=s._array,u=u._array,l=l._array,a.sub(t,u,s),a.sub(e,l,s),a.cross(i,e,d);var p=a.dot(t,i);if(c){if(p>-o)return null}else if(p>-o&&p1)return null;a.cross(i,t,n);var v=a.dot(d,i)/p;if(v<0||v>1||m+v>1)return null;a.cross(i,t,e);var g=-a.dot(n,i)/p;return g<0?null:(h||(h=new r),f&&r.set(f,1-m-v,m,v),a.scaleAndAdd(h._array,_,d,g),h)}}(),applyTransform:function(t){r.add(this.direction,this.direction,this.origin),r.transformMat4(this.origin,this.origin,t),r.transformMat4(this.direction,this.direction,t),r.sub(this.direction,this.direction,this.origin),r.normalize(this.direction,this.direction)},copy:function(t){r.copy(this.origin,t.origin),r.copy(this.direction,t.direction)},clone:function(){var t=new s;return t.copy(this),t}},t.exports=s},function(t,e,n){var r=n(2),i=n(3),a=n(21),o=n(17),s=["px","nx","py","ny","pz","nz"],u=r.extend(function(){var t={position:new i,far:1e3,near:.1,texture:null,shadowMapPass:null},e=t._cameras={px:new a({fov:90}),nx:new a({fov:90}),py:new a({fov:90}),ny:new a({fov:90}),pz:new a({fov:90}),nz:new a({fov:90})};return e.px.lookAt(i.POSITIVE_X,i.NEGATIVE_Y),e.nx.lookAt(i.NEGATIVE_X,i.NEGATIVE_Y),e.py.lookAt(i.POSITIVE_Y,i.POSITIVE_Z),e.ny.lookAt(i.NEGATIVE_Y,i.NEGATIVE_Z),e.pz.lookAt(i.POSITIVE_Z,i.NEGATIVE_Y),e.nz.lookAt(i.NEGATIVE_Z,i.NEGATIVE_Y),t._frameBuffer=new o,t},{getCamera:function(t){return this._cameras[t]},render:function(t,e,n){var r=t.gl;n||e.update();for(var a=this.texture.width,o=2*Math.atan(a/(a-.5))/Math.PI*180,u=0;u<6;u++){var l=s[u],c=this._cameras[l];if(i.copy(c.position,this.position),c.far=this.far,c.near=this.near,c.fov=o,this.shadowMapPass){c.update();var h=e.getBoundingBox(function(t){return!t.invisible});h.applyTransform(c.viewMatrix),e.viewBoundingBoxLastFrame.copy(h),this.shadowMapPass.render(t,e,c,!0)}this._frameBuffer.attach(this.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+u),this._frameBuffer.bind(t),t.render(e,c,!0),this._frameBuffer.unbind(t)}},dispose:function(t){this._frameBuffer.dispose(t)}});t.exports=u},function(t,e,n){"use strict";var r=n(18),i=n(16),a=n(50),o=n(34),s=n(1),u=s.vec3,l=s.vec4,c=r.extend(function(){return{projectionMatrix:new i,invProjectionMatrix:new i,viewMatrix:new i,frustum:new a}},function(){this.update(!0)},{update:function(t){r.prototype.update.call(this,t),i.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),i.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(t){i.copy(this.viewMatrix,t),i.invert(this.worldTransform,t),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(t){i.copy(this.projectionMatrix,t),i.invert(this.invProjectionMatrix,t),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:function(){var t=l.create();return function(e,n){var r=void 0!==n?n:new o,i=e._array[0],a=e._array[1];return l.set(t,i,a,-1,1),l.transformMat4(t,t,this.invProjectionMatrix._array),l.transformMat4(t,t,this.worldTransform._array),u.scale(r.origin._array,t,1/t[3]),l.set(t,i,a,1,1),l.transformMat4(t,t,this.invProjectionMatrix._array),l.transformMat4(t,t,this.worldTransform._array),u.scale(t,t,1/t[3]),u.sub(r.direction._array,t,r.origin._array),u.normalize(r.direction._array,r.direction._array),r.direction._dirty=!0,r.origin._dirty=!0,r}}()});t.exports=c},function(t,e,n){"use strict";var r=n(2),i=n(14),a=n(4),o=(n(11),n(9)),s=n(16),u=(n(27),n(6)),l=n(26),c=n(5);c["import"](n(78)),c["import"](n(56));var h=n(1),f=h.mat4,d=h.vec3,_=f.create,p=0,m={},v=r.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 t=this.canvas;try{var e={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!this.gl)throw new Error;null==this.gl.__GLID__&&(this.gl.__GLID__=p++,i.initialize(this.gl)),this.resize()}catch(n){throw"Error creating WebGL Context "+n}},{resize:function(t,e){var n=this.canvas,r=this.devicePixelRatio;null!=t?(n.style.width=t+"px",n.style.height=e+"px",n.width=t*r,n.height=e*r,this._width=t,this._height=e):(this._width=n.width/r,this._height=n.height/r),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var t=this.viewport;return t.width/t.height},setDevicePixelRatio:function(t){this.devicePixelRatio=t,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getExtension:function(t){return i.getExtension(this.gl,t)},setViewport:function(t,e,n,r,i){if("object"==typeof t){var a=t;t=a.x,e=a.y,n=a.width,r=a.height,i=a.devicePixelRatio}i=i||this.devicePixelRatio,this.gl.viewport(t*i,e*i,n*i,r*i),this.viewport={x:t,y:e,width:n,height:r,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 t=this._clearStack.pop();this.clearColor=t.clearColor,this.clearBit=t.clearBit}},bindSceneRendering:function(t){this._sceneRendering=t},beforeRenderObject:function(){},afterRenderObject:function(){},render:function(t,e,n,r){var i=this.gl;this._sceneRendering=t;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)}n||t.update(!1),e.getScene()||e.update(!0);var l=t.opaqueQueue,c=t.transparentQueue,h=t.material;if(t.trigger("beforerender",this,t,e),c.length>0)for(var p=_(),m=d.create(),v=0;v0&&t.min._array[2]<0&&(t.max._array[2]=-1e-20),t.applyProjection(e);var u=t.min._array,l=t.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(t){this.disposeNode(t,!0,!0),t.dispose()},disposeNode:function(t,e,n){var r={},i=this.gl;t.getParent()&&t.getParent().remove(t),t.traverse(function(t){t.geometry&&e&&t.geometry.dispose(i),t.material&&(r[t.material.__GUID__]=t.material),t.dispose&&t.dispose(i)});for(var a in r){var o=r[a];o.dispose(i,n)}},disposeShader:function(t){t.dispose(this.gl)},disposeGeometry:function(t){t.dispose(this.gl)},disposeTexture:function(t){t.dispose(this.gl)},disposeFrameBuffer:function(t){t.dispose(this.gl)},dispose:function(){i.dispose(this.gl)},screenToNDC:function(t,e,n){n||(n=new l),e=this._height-e;var r=this.viewport,i=n._array;return i[0]=(t-r.x)/r.width,i[0]=2*i[0]-1,i[1]=(e-r.y)/r.height,i[1]=2*i[1]-1,n}});v.opaqueSortFunc=v.prototype.opaqueSortFunc=function(t,e){return t.renderOrder===e.renderOrder?t.material.shader===e.material.shader?t.material===e.material?t.geometry.__GUID__-e.geometry.__GUID__:t.material.__GUID__-e.material.__GUID__:t.material.shader.__GUID__-e.material.shader.__GUID__:t.renderOrder-e.renderOrder},v.transparentSortFunc=v.prototype.transparentSortFunc=function(t,e){return t.renderOrder===e.renderOrder?t.__depth===e.__depth?t.material.shader===e.material.shader?t.material===e.material?t.geometry.__GUID__-e.geometry.__GUID__:t.material.__GUID__-e.material.__GUID__:t.material.shader.__GUID__-e.material.shader.__GUID__:t.__depth-e.__depth:t.renderOrder-e.renderOrder};var g={WORLD:_(),VIEW:_(),PROJECTION:_(),WORLDVIEW:_(),VIEWPROJECTION:_(),WORLDVIEWPROJECTION:_(),WORLDINVERSE:_(),VIEWINVERSE:_(),PROJECTIONINVERSE:_(),WORLDVIEWINVERSE:_(),VIEWPROJECTIONINVERSE:_(),WORLDVIEWPROJECTIONINVERSE:_(),WORLDTRANSPOSE:_(),VIEWTRANSPOSE:_(),PROJECTIONTRANSPOSE:_(),WORLDVIEWTRANSPOSE:_(),VIEWPROJECTIONTRANSPOSE:_(),WORLDVIEWPROJECTIONTRANSPOSE:_(),WORLDINVERSETRANSPOSE:_(),VIEWINVERSETRANSPOSE:_(),PROJECTIONINVERSETRANSPOSE:_(),WORLDVIEWINVERSETRANSPOSE:_(),VIEWPROJECTIONINVERSETRANSPOSE:_(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:_()};v.COLOR_BUFFER_BIT=a.COLOR_BUFFER_BIT,v.DEPTH_BUFFER_BIT=a.DEPTH_BUFFER_BIT,v.STENCIL_BUFFER_BIT=a.STENCIL_BUFFER_BIT,t.exports=v},function(t,e,n){"use strict";var r=n(2),i=n(30),a=n(1),o=a.quat,s=a.vec3,u=a.mat4,l=r.extend(function(){return{relativeRootNode:null,name:"",roots:[],joints:[],_clips:[],_invBindPoseMatricesArray:null,_jointMatricesSubArrays:[],_skinMatricesArray:null,_skinMatricesSubArrays:[],_subSkinMatricesArray:{}}},{addClip:function(t,e){for(var n=0;n0&&this._clips.splice(e,1)},removeClipsAll:function(){this._clips=[]},getClip:function(t){if(this._clips[t])return this._clips[t].clip},getClipNumber:function(){return this._clips.length},updateJointMatrices:function(){var t=u.create();return function(){for(var e=0;e1e-6?(o=Math.acos(s),u=Math.sin(o),l=Math.sin((1-r)*o)/u,c=Math.sin(r*o)/u):(l=1-r,c=r),t[0]=l*h+c*p,t[1]=l*f+c*m,t[2]=l*d+c*v,t[3]=l*_+c*g,t}var a=n(20),o=n(40),s=n(1),u=s.quat,l=s.vec3,c=function(t){t=t||{},a.call(this,t),this.position=l.create(),this.rotation=u.create(),this.scale=l.fromValues(1,1,1),this.channels={time:null,position:null,rotation:null,scale:null},this._cacheKey=0,this._cacheTime=0};c.prototype=Object.create(a.prototype),c.prototype.constructor=c,c.prototype.step=function(t,e){var n=a.prototype.step.call(this,t,e);return"finish"!==n&&this.setTime(this.getElapsedTime()),n},c.prototype.setTime=function(t){if(this.channels.time){var e=this.channels,n=e.time.length,a=-1;if(t<=e.time[0])t=e.time[0],a=0;else if(t>=e.time[n-1])t=e.time[n-1],a=n-2;else if(t=0;s--)if(e.time[s-1]<=t&&e.time[s]>t){a=s-1;break}}else for(var s=this._cacheKey;st){a=s;break}if(a>-1){this._cacheKey=a,this._cacheTime=t;var u=a,l=a+1,c=e.time[u],h=e.time[l],f=(t-c)/(h-c);e.rotation&&i(this.rotation,e.rotation,e.rotation,f,4*u,4*l),e.position&&r(this.position,e.position,e.position,f,3*u,3*l),e.scale&&r(this.scale,e.scale,e.scale,f,3*u,3*l)}a==n-2&&(this._cacheKey=0,this._cacheTime=0)}},c.prototype.getSubClip=function(t,e){var n=new c({name:this.name}),r=this.channels.time[0];t=Math.min(Math.max(t,r),this.life),e=Math.min(Math.max(e,r),this.life);var i=this._findRange(t),a=this._findRange(e),o=a[0]-i[0]+1;0===i[1]&&0===a[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(t);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;st&&(r=i);var a=0;if(r>=0)var o=e.time[r],s=e.time[r+1],a=(t-o)/(s-o);return[r,a]},c.prototype.blend1D=o.prototype.blend1D,c.prototype.blend2D=o.prototype.blend2D,c.prototype.additiveBlend=o.prototype.additiveBlend,c.prototype.subtractiveBlend=o.prototype.subtractiveBlend,c.prototype.clone=function(){var t=a.prototype.clone.call(this);return t.channels={time:this.channels.time||null,position:this.channels.position||null,rotation:this.channels.rotation||null,scale:this.channels.scale||null},l.copy(t.position,this.position),u.copy(t.rotation,this.rotation),l.copy(t.scale,this.scale),t},t.exports=c},function(t,e,n){"use strict";function r(t,e){return t.time-e.time}var i=n(20),a=n(1),o=a.quat,s=a.vec3,u=function(t){t=t||{},i.call(this,t),this.keyFrames=[],t.keyFrames&&this.addKeyFrames(t.keyFrames),this.position=s.create(),this.rotation=o.create(),this.scale=s.fromValues(1,1,1),this._cacheKey=0,this._cacheTime=0};u.prototype=Object.create(i.prototype),u.prototype.constructor=u,u.prototype.step=function(t,e){var n=i.prototype.step.call(this,t,e);return"finish"!==n&&this.setTime(this.getElapsedTime()),n},u.prototype.setTime=function(t){this._interpolateField(t,"position"),this._interpolateField(t,"rotation"),this._interpolateField(t,"scale")},u.prototype.addKeyFrame=function(t){for(var e=0;e=t.time)return this.keyFrames.splice(e,0,t),e}this.life=t.time,this.keyFrames.push(t)},u.prototype.addKeyFrames=function(t){for(var e=0;ei[i.length-1].time)){if(t=a-1?a-1:this._cacheKey+1,l=u;l>=0;l--)if(i[l].time<=t&&i[l][e])n=i[l],this._cacheKey=l,this._cacheTime=t;else if(i[l][e]){r=i[l];break}}else for(var l=this._cacheKey;l65535?Uint32Array:Uint16Array,p=this.indices=new _(e*t*6),m=this.radius,v=this.phiStart,g=this.phiLength,y=this.thetaStart,x=this.thetaLength,m=this.radius,T=[],E=[],b=0,S=1/m;for(d=0;d<=t;d++)for(f=0;f<=e;f++)c=f/e,h=d/t,s=-m*Math.cos(v+c*g)*Math.sin(y+h*x),u=m*Math.cos(y+h*x),l=m*Math.sin(v+c*g)*Math.sin(y+h*x),T[0]=s,T[1]=u,T[2]=l,E[0]=c,E[1]=h,n.set(b,T),r.set(b,E),T[0]*=S,T[1]*=S,T[2]*=S,i.set(b,T),b++;var A,N,w,M,C=e+1,R=0;for(d=0;dthis.distance,i=1;i<8;i++)if(a.dot(e[i]._array,n)>this.distance!=r)return!0},intersectLine:function(){var t=a.create();return function(e,n,i){var o=this.distanceToPoint(e),s=this.distanceToPoint(n);if(o>0&&s>0||o<0&&s<0)return null;var u=this.normal._array,l=this.distance,c=e._array;a.sub(t,n._array,e._array),a.normalize(t,t);var h=a.dot(u,t);if(0===h)return null;i||(i=new r);var f=(a.dot(u,c)-l)/h;return a.scaleAndAdd(i._array,c,t,-f),i._dirty=!0,i}}(),applyTransform:function(){var t=o.create(),e=s.create(),n=s.create();return n[3]=1,function(r){r=r._array,a.scale(n,this.normal._array,this.distance),s.transformMat4(n,n,r),this.distance=a.dot(n,this.normal._array),o.invert(t,r),o.transpose(t,t),e[3]=0,a.copy(e,this.normal._array),s.transformMat4(e,e,t),a.copy(this.normal._array,e)}}(),copy:function(t){a.copy(this.normal._array,t.normal._array),this.normal._dirty=!0,this.distance=t.distance},clone:function(){var t=new u;return t.copy(this),t}},t.exports=u},function(t,e){var n={};n.isPowerOfTwo=function(t){return 0===(t&t-1)},n.nextPowerOfTwo=function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t},n.nearestPowerOfTwo=function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))},t.exports=n},function(t,e,n){var r=n(13),i=n(70),a=n(5),o=n(6);a["import"](n(79));var s=r.extend(function(){var t=new a({vertex:a.source("qtek.skybox.vertex"),fragment:a.source("qtek.skybox.fragment")}),e=new o({shader:t,depthMask:!1});return{scene:null,geometry:new i,material:e,environmentMap:null,culling:!1}},function(){var t=this.scene;t&&this.attachScene(t),this.environmentMap&&this.setEnvironmentMap(this.environmentMap)},{attachScene:function(t){this.scene&&this.detachScene(),this.scene=t,t.on("beforerender",this._beforeRenderScene,this)},detachScene:function(){this.scene&&this.scene.off("beforerender",this._beforeRenderScene),this.scene=null},dispose:function(t){this.detachScene(),this.geometry.dispose(t),this.material.dispose(t)},setEnvironmentMap:function(t){this.material.set("environmentMap",t)},getEnvironmentMap:function(){return this.material.get("environmentMap")},_beforeRenderScene:function(t,e,n){this.renderSkybox(t,n)},renderSkybox:function(t,e){this.position.copy(e.getWorldPosition()),this.update(),t.gl.disable(t.gl.BLEND),t.renderQueue([this],e)}});t.exports=s},function(t,e,n){var r=n(13),i=n(46),a=n(5),o=n(6);a["import"](n(77));var s=r.extend(function(){var t=new a({vertex:a.source("qtek.basic.vertex"),fragment:a.source("qtek.basic.fragment")});t.enableTexture("diffuseMap");var e=new o({shader:t,depthMask:!1});return{scene:null,geometry:new i({widthSegments:30,heightSegments:30}),material:e,environmentMap:null,culling:!1}},function(){var t=this.scene;t&&this.attachScene(t),this.environmentMap&&this.setEnvironmentMap(this.environmentMap)},{attachScene:function(t){this.scene&&this.detachScene(),this.scene=t,t.on("beforerender",this._beforeRenderScene,this)},detachScene:function(){this.scene&&this.scene.off("beforerender",this._beforeRenderScene),this.scene=null},_beforeRenderScene:function(t,e,n){this.position.copy(n.getWorldPosition()),this.update(),t.renderQueue([this],n)},setEnvironmentMap:function(t){this.material.set("diffuseMap",t)},getEnvironmentMap:function(){return this.material.get("diffuseMap")},dispose:function(t){this.detachScene(),this.geometry.dispose(t),this.material.dispose(t)}});t.exports=s},function(t,e,n){var r=n(27),i=n(5);i["import"](n(81)),i["import"](n(77)),i["import"](n(148)),i["import"](n(80)),i["import"](n(150)),i["import"](n(79)),i["import"](n(56)),r.template("qtek.basic",i.source("qtek.basic.vertex"),i.source("qtek.basic.fragment")),r.template("qtek.lambert",i.source("qtek.lambert.vertex"),i.source("qtek.lambert.fragment")),r.template("qtek.wireframe",i.source("qtek.wireframe.vertex"),i.source("qtek.wireframe.fragment")),r.template("qtek.skybox",i.source("qtek.skybox.vertex"),i.source("qtek.skybox.fragment")),r.template("qtek.prez",i.source("qtek.prez.vertex"),i.source("qtek.prez.fragment")),r.template("qtek.standard",i.source("qtek.standard.vertex"),i.source("qtek.standard.fragment")),i["import"](n(123)),i["import"](n(121)),i["import"](n(130)),i["import"](n(131)),i["import"](n(135)),i["import"](n(132)),i["import"](n(122)),i["import"](n(125)),i["import"](n(133)),i["import"](n(128)),i["import"](n(124)),i["import"](n(129)),i["import"](n(120)),i["import"](n(126)),i["import"](n(127))},function(t,e){t.exports="@export qtek.prez.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\n\n@import qtek.chunk.skinning_header\n\nvoid main()\n{\n\n vec3 skinnedPosition = position;\n\n#ifdef SKINNING\n\n @import qtek.chunk.skin_matrix\n\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n}\n\n@end\n\n\n@export qtek.prez.fragment\n\nvoid main()\n{\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n\n@end"},function(t,e,n){"use strict";var r=n(8),i=n(19),a=n(25),o=n(35),s=n(54),u=n(23),l=n(83),c=n(85),h={loadTexture:function(t,e,n,a){var o;if("function"==typeof e?(n=e,a=n,e={}):e=e||{},"string"==typeof t){if(t.match(/.hdr$/)||"hdr"===e.fileType)return o=new r({width:0,height:0}),h._fetchTexture(t,function(t){c.parseRGBE(t,o,e.exposure),o.dirty(),n&&n(o)},a),o;t.match(/.dds$/)||"dds"===e.fileType?(o=new r({width:0,height:0}),h._fetchTexture(t,function(t){l.parse(t,o),o.dirty(),n&&n(o)},a)):(o=new r,o.load(t),o.success(n),o.error(a))}else if("object"==typeof t&&"undefined"!=typeof t.px){var o=new i;o.load(t),o.success(n),o.error(a)}return o},loadPanorama:function(t,e,n,r,i,a){var o=this;"function"==typeof r?(i=r,a=i,r={}):r=r||{},h.loadTexture(e,r,function(e){e.flipY=r.flipY||!1,o.panoramaToCubeMap(t,e,n,r),e.dispose(t.gl),i&&i(n)},a)},panoramaToCubeMap:function(t,e,n,r){var i=new o,a=new s({scene:new u});return a.material.set("diffuseMap",e),r=r||{},r.encodeRGBM&&a.material.shader.define("fragment","RGBM_ENCODE"),i.texture=n,i.render(t,a.scene),i.texture=null,i.dispose(t),n},_fetchTexture:function(t,e,n){a.get({url:t,responseType:"arraybuffer",onload:e,onerror:n})},createChessboard:function(t,e,n,i){t=t||512,e=e||64,n=n||"black",i=i||"white";var a=Math.ceil(t/e),o=document.createElement("canvas");o.width=t,o.height=t;var s=o.getContext("2d");s.fillStyle=i,s.fillRect(0,0,t,t),s.fillStyle=n;for(var u=0;ui;if(a)t.length=i;else for(var o=r;o=0&&!(E[N]<=e);N--);N=Math.min(N,v-2)}else{for(N=O;Ne);N++);N=Math.min(N-1,v-2)}O=N,k=e;var n=E[N+1]-E[N];0!==n&&(R=(e-E[N])/n,m?(P=b[N],L=b[0===N?N:N-1],I=b[N>v-2?v-1:N+1],D=b[N>v-3?v-1:N+2],u?_(t,i,u(d(t,i),L,P,I,D,R)):y?l(L,P,I,D,R,R*R,R*R*R,d(t,i),x):_(t,i,c(L,P,I,D,R,R*R,R*R*R))):u?_(t,i,u(d(t,i),b[N],b[N+1],R)):y?o(b[N],b[N+1],R,d(t,i),x):_(t,i,a(b[N],b[N+1],R)))},B=new p({target:t._target,life:T,loop:t._loop,delay:t._delay,onframe:F,onfinish:n});return e&&"spline"!==e&&B.setEasing(e),B}}}function _(t,e,n,a,o){this._tracks={},this._target=t,this._loop=e||!1,this._getter=n||r,this._setter=a||i,this._interpolater=o||null,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]}var p=n(20),m=Array.prototype.slice;_.prototype={constructor:_,when:function(t,e){for(var n in e)this._tracks[n]||(this._tracks[n]=[],0!==t&&this._tracks[n].push({time:0,value:u(this._getter(this._target,n))})),this._tracks[n].push({time:parseInt(t),value:e[n]});return this},during:function(t){return this._onframeList.push(t),this},_doneCallback:function(){this._tracks={},this._clipList.length=0;for(var t=this._doneList,e=t.length,n=0;n0)for(var e=0;e0){var e=this.outputs[t];e.keepLastFrame?(this._prevOutputTextures[t]&&this._compositor.releaseTexture(this._prevOutputTextures[t]),this._prevOutputTextures[t]=this._outputTextures[t]):this._compositor.releaseTexture(this._outputTextures[t]); -}}});t.exports=a},function(t,e,n){"use strict";var r=n(2),i=n(24),a=r.extend(function(){return{nodes:[]}},{dirty:function(){this._dirty=!0},addNode:function(t){this.nodes.indexOf(t)>=0||(this.nodes.push(t),this._dirty=!0)},removeNode:function(t){"string"==typeof t&&(t=this.getNodeByName(t));var e=this.nodes.indexOf(t);e>=0&&(this.nodes.splice(e,1),this._dirty=!0)},getNodeByName:function(t){for(var e=0;e=e.COLOR_ATTACHMENT0&&c<=e.COLOR_ATTACHMENT0+8&&f.push(c);h.drawBuffersEXT(f)}t.saveClear(),t.clearBit=a.DEPTH_BUFFER_BIT|a.COLOR_BUFFER_BIT,n=t.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),t.restoreClear(),r.unbind(t)}else n=t.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",n),this._rendering=!1,this._rendered=!0}});t.exports=s},function(t,e,n){"use strict";var r=n(24),i=r.extend(function(){return{texture:null,outputs:{color:{}}}},function(){},{getOutput:function(t,e){return this.texture},beforeFrame:function(){},afterFrame:function(){}});t.exports=i},function(t,e){"use strict";function n(t,e,n){"object"==typeof e&&(n=e,e=null);var a,o=this;if(!(t instanceof Function)){a=[];for(var s in t)t.hasOwnProperty(s)&&a.push(s)}var u=function(e){if(o.apply(this,arguments),t instanceof Function?r(this,t.call(this,e)):i(this,t,a),this.constructor===u)for(var n=u.__initializers__,s=0;s0&&(r.shader.define("vertex","SKINNING"),r.shader.define("vertex","JOINT_COUNT",t),i.shader.define("vertex","SKINNING"),i.shader.define("vertex","JOINT_COUNT",t)),n={material1:r,material2:i},e[t]=n}return n.used=!0,n},_resetGBufferMaterials:function(){for(var t in this._gBufferMaterials)this._gBufferMaterials[t].used=!1},_cleanGBufferMaterials:function(t){for(var e in this._gBufferMaterials){var n=this._gBufferMaterials[e];n.used||(n.material1.dispose(t),n.material2.dispose(t))}},_replaceGBufferMat:function(t,e){for(var n=0;n1&&a&&a.length>1){var s=n(a)/n(o);!isFinite(s)&&(s=1),e.pinchScale=s;var u=r(a);return e.pinchX=u[0],e.pinchY=u[1],{type:"pinch",target:t[0].target,event:e}}}}};t.exports=i},function(t,e){t.exports="@export qtek.basic.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position : POSITION;\n\nattribute vec3 barycentric;\n\n@import qtek.chunk.skinning_header\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Barycentric;\n\nvoid main()\n{\n vec3 skinnedPosition = position;\n\n#ifdef SKINNING\n @import qtek.chunk.skin_matrix\n\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_Barycentric = barycentric;\n\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n}\n\n@end\n\n\n\n\n@export qtek.basic.fragment\n\n\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\n#ifdef ALPHA_TEST\nuniform float alphaCutoff: 0.9;\n#endif\n\nuniform float lineWidth : 0.0;\nuniform vec3 lineColor : [0.0, 0.0, 0.0];\nvarying vec3 v_Barycentric;\n\n@import qtek.util.edge_factor\n\n@import qtek.util.rgbm\n\n@import qtek.util.srgb\n\nvoid main()\n{\n\n#ifdef RENDER_TEXCOORD\n gl_FragColor = vec4(v_Texcoord, 1.0, 1.0);\n return;\n#endif\n\n gl_FragColor = vec4(color, alpha);\n\n#ifdef DIFFUSEMAP_ENABLED\n vec4 tex = decodeHDR(texture2D(diffuseMap, v_Texcoord));\n\n#ifdef SRGB_DECODE\n tex = sRGBToLinear(tex);\n#endif\n\n#if defined(DIFFUSEMAP_ALPHA_ALPHA)\n gl_FragColor.a = tex.a;\n#endif\n\n gl_FragColor.rgb *= tex.rgb;\n#endif\n\n gl_FragColor.rgb += emission;\n if( lineWidth > 0.01)\n {\n gl_FragColor.rgb = gl_FragColor.rgb * mix(lineColor, vec3(1.0), edgeFactor(lineWidth));\n }\n\n#ifdef GAMMA_ENCODE\n gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(1 / 2.2));\n#endif\n\n#ifdef ALPHA_TEST\n if (gl_FragColor.a < alphaCutoff) {\n discard;\n }\n#endif\n\n gl_FragColor = encodeHDR(gl_FragColor);\n\n}\n\n@end"},function(t,e,n){var r="uniform vec3 ",i="uniform float ",a="@export qtek.header.",o="@end",s=":unconfigurable;";t.exports=[a+"directional_light",r+"directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]"+s,r+"directionalLightColor[DIRECTIONAL_LIGHT_COUNT]"+s,o,a+"ambient_light",r+"ambientLightColor[AMBIENT_LIGHT_COUNT]"+s,o,a+"ambient_sh_light",r+"ambientSHLightColor[AMBIENT_SH_LIGHT_COUNT]"+s,r+"ambientSHLightCoefficients[AMBIENT_SH_LIGHT_COUNT * 9]"+s,n(147),o,a+"ambient_cubemap_light",r+"ambientCubemapLightColor[AMBIENT_CUBEMAP_LIGHT_COUNT]"+s,"uniform samplerCube ambientCubemapLightCubemap[AMBIENT_CUBEMAP_LIGHT_COUNT]"+s,"uniform sampler2D ambientCubemapLightBRDFLookup[AMBIENT_CUBEMAP_LIGHT_COUNT]"+s,o,a+"point_light",r+"pointLightPosition[POINT_LIGHT_COUNT]"+s,i+"pointLightRange[POINT_LIGHT_COUNT]"+s,r+"pointLightColor[POINT_LIGHT_COUNT]"+s,o,a+"spot_light",r+"spotLightPosition[SPOT_LIGHT_COUNT]"+s,r+"spotLightDirection[SPOT_LIGHT_COUNT]"+s,i+"spotLightRange[SPOT_LIGHT_COUNT]"+s,i+"spotLightUmbraAngleCosine[SPOT_LIGHT_COUNT]"+s,i+"spotLightPenumbraAngleCosine[SPOT_LIGHT_COUNT]"+s,i+"spotLightFalloffFactor[SPOT_LIGHT_COUNT]"+s,r+"spotLightColor[SPOT_LIGHT_COUNT]"+s,o].join("\n")},function(t,e){t.exports="@export qtek.skybox.vertex\n\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\n\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n@export qtek.skybox.fragment\n\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform float lod: 0.0;\n\nvarying vec3 v_WorldPosition;\n\n@import qtek.util.rgbm\n\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 viewDirection = normalize(v_WorldPosition - eyePos);\n\n vec3 tex = decodeHDR(textureCubeLodEXT(environmentMap, viewDirection, lod)).rgb;\n\n#ifdef SRGB_DECODE\n tex.rgb = pow(tex.rgb, vec3(2.2));\n#endif\n\n gl_FragColor = encodeHDR(vec4(tex, 1.0));\n}\n@end"},function(t,e){t.exports="\n\n@export qtek.standard.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#if defined(AOMAP_ENABLED)\nattribute vec2 texcoord2 : TEXCOORD_1;\n#endif\n\nattribute vec3 normal : NORMAL;\nattribute vec4 tangent : TANGENT;\n\n#ifdef VERTEX_COLOR\nattribute vec4 color : COLOR;\n#endif\n\nattribute vec3 barycentric;\n\n@import qtek.chunk.skinning_header\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\nvarying vec3 v_Barycentric;\n\n#ifdef NORMALMAP_ENABLED\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n#if defined(AOMAP_ENABLED)\nvarying vec2 v_Texcoord2;\n#endif\n\nvoid main()\n{\n\n vec3 skinnedPosition = position;\n vec3 skinnedNormal = normal;\n vec3 skinnedTangent = tangent.xyz;\n#ifdef SKINNING\n\n @import qtek.chunk.skin_matrix\n\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n skinnedNormal = (skinMatrixWS * vec4(normal, 0.0)).xyz;\n skinnedTangent = (skinMatrixWS * vec4(tangent.xyz, 0.0)).xyz;\n#endif\n\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_WorldPosition = (world * vec4(skinnedPosition, 1.0)).xyz;\n v_Barycentric = barycentric;\n\n v_Normal = normalize((worldInverseTranspose * vec4(skinnedNormal, 0.0)).xyz);\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(skinnedTangent, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = color;\n#endif\n\n#if defined(AOMAP_ENABLED)\n v_Texcoord2 = texcoord2;\n#endif\n}\n\n@end\n\n\n@export qtek.standard.fragment\n\n#define PI 3.14159265358979\n\n#define GLOSS_CHANEL 0\n#define ROUGHNESS_CHANNEL 0\n#define METALNESS_CHANNEL 1\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n#ifdef NORMALMAP_ENABLED\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\nuniform sampler2D normalMap;\n#endif\n\n#ifdef DIFFUSEMAP_ENABLED\nuniform sampler2D diffuseMap;\n#endif\n\n#ifdef SPECULARMAP_ENABLED\nuniform sampler2D specularMap;\n#endif\n\n#ifdef USE_ROUGHNESS\nuniform float roughness : 0.5;\n #ifdef ROUGHNESSMAP_ENABLED\nuniform sampler2D roughnessMap;\n #endif\n#else\nuniform float glossiness: 0.5;\n #ifdef GLOSSMAP_ENABLED\nuniform sampler2D glossMap;\n #endif\n#endif\n\n#ifdef METALNESSMAP_ENABLED\nuniform sampler2D metalnessMap;\n#endif\n\n#ifdef ENVIRONMENTMAP_ENABLED\nuniform samplerCube environmentMap;\n\n #ifdef PARALLAX_CORRECTED\nuniform vec3 environmentBoxMin;\nuniform vec3 environmentBoxMax;\n #endif\n\n#endif\n\n#ifdef BRDFLOOKUP_ENABLED\nuniform sampler2D brdfLookup;\n#endif\n\n#ifdef EMISSIVEMAP_ENABLED\nuniform sampler2D emissiveMap;\n#endif\n\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n\n#ifdef AOMAP_ENABLED\nuniform sampler2D aoMap;\nuniform float aoIntensity;\nvarying vec2 v_Texcoord2;\n#endif\n\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform float alpha : 1.0;\n\n#ifdef ALPHA_TEST\nuniform float alphaCutoff: 0.9;\n#endif\n\n#ifdef USE_METALNESS\nuniform float metalness : 0.0;\n#else\nuniform vec3 specularColor : [0.1, 0.1, 0.1];\n#endif\n\nuniform vec3 emission : [0.0, 0.0, 0.0];\n\nuniform float emissionIntensity: 1;\n\nuniform float lineWidth : 0.0;\nuniform vec3 lineColor : [0.0, 0.0, 0.0];\nvarying vec3 v_Barycentric;\n\n#ifdef ENVIRONMENTMAP_PREFILTER\nuniform float maxMipmapLevel: 5;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import qtek.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import qtek.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import qtek.header.ambient_cubemap_light\n#endif\n\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\n@import qtek.util.calculate_attenuation\n\n@import qtek.util.edge_factor\n\n@import qtek.util.rgbm\n\n@import qtek.util.srgb\n\n@import qtek.plugin.compute_shadow_map\n\n@import qtek.util.parallax_correct\n\n\nfloat G_Smith(float g, float ndv, float ndl)\n{\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nfloat D_GGX(float g, 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 / (PI * tmp * tmp);\n}\n\n\nvoid main()\n{\n vec4 albedoColor = vec4(color, alpha);\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n#ifdef DIFFUSEMAP_ENABLED\n vec4 texel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n #endif\n albedoColor.rgb *= texel.rgb;\n #ifdef DIFFUSEMAP_ALPHA_ALPHA\n albedoColor.a *= texel.a;\n #endif\n\n#endif\n\n\n#ifdef USE_METALNESS\n float m = metalness;\n\n #ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_Texcoord)[METALNESS_CHANNEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n #endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 spec = mix(vec3(0.04), baseColor, m);\n#else\n vec3 spec = specularColor;\n#endif\n\n#ifdef USE_ROUGHNESS\n float g = 1.0 - roughness;\n #ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_Texcoord)[ROUGHNESS_CHANNEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n #endif\n#else\n float g = glossiness;\n #ifdef GLOSSMAP_ENABLED\n float g2 = texture2D(glossMap, v_Texcoord)[GLOSS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n #endif\n#endif\n\n#ifdef SPECULARMAP_ENABLED\n spec *= texture2D(specularMap, v_Texcoord).rgb;\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n#ifdef NORMALMAP_ENABLED\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#endif\n\n vec3 diffuseTerm = vec3(0.0, 0.0, 0.0);\n vec3 specularTerm = vec3(0.0, 0.0, 0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, spec);\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_];\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N) * ambientSHLightColor[_idx_];\n }}\n#endif\n\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\n vec3 lightPosition = pointLightPosition[_idx_];\n vec3 lc = pointLightColor[_idx_];\n float range = pointLightRange[_idx_];\n\n vec3 L = lightPosition - v_WorldPosition;\n\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\n float shadowContrib = 1.0;\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\n if(shadowEnabled)\n {\n shadowContrib = shadowContribsPoint[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * attenuation * shadowContrib;\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n\n vec3 L = -normalize(directionalLightDirection[_idx_]);\n vec3 lc = directionalLightColor[_idx_];\n\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\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if(shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n#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\n vec3 L = lightPosition - v_WorldPosition;\n float dist = length(L);\n float attenuation = lightAttenuation(dist, range);\n\n L /= dist;\n float c = dot(spotLightDirection, L);\n\n float falloff;\n falloff = clamp((c - a) /( b - a), 0.0, 1.0);\n falloff = pow(falloff, falloffFactor);\n\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\n float shadowContrib = 1.0;\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsSpot[i];\n }\n#endif\n\n vec3 li = lc * attenuation * (1.0 - falloff) * shadowContrib * ndl;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }\n#endif\n\n vec4 outColor = albedoColor;\n outColor.rgb *= diffuseTerm;\n\n outColor.rgb += specularTerm;\n\n\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\n#ifdef ENVIRONMENTMAP_ENABLED\n\n vec3 envWeight = g * fresnelTerm;\n vec3 L = reflect(-V, N);\n\n #ifdef PARALLAX_CORRECTED\n L = parallaxCorrect(L, v_WorldPosition, environmentBoxMin, environmentBoxMax);\n #endif\n\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\n #ifdef BRDFLOOKUP_ENABLED\n vec2 brdfParam = texture2D(brdfLookup, vec2(rough, ndv)).xy;\n envWeight = spec * brdfParam.x + brdfParam.y;\n #endif\n\n #else\n vec3 envTexel = textureCube(environmentMap, L).xyz;\n #endif\n\n outColor.rgb += envTexel * envWeight;\n#endif\n\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\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\n outColor.rgb *= aoFactor;\n\n vec3 lEmission = emission;\n#ifdef EMISSIVEMAP_ENABLED\n lEmission *= texture2D(emissiveMap, v_Texcoord).rgb;\n#endif\n outColor.rgb += lEmission * emissionIntensity;\n\n#ifdef GAMMA_ENCODE\n outColor.rgb = pow(outColor.rgb, vec3(1 / 2.2));\n#endif\n\n if(lineWidth > 0.)\n {\n outColor.rgb = mix(lineColor, vec3(outColor.rgb), edgeFactor(lineWidth));\n }\n\n#ifdef ALPHA_TEST\n if (outColor.a < alphaCutoff) {\n discard;\n }\n#endif\n\n gl_FragColor = encodeHDR(outColor);\n}\n\n@end\n"; -},function(t,e){t.exports="\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\n@export qtek.util.calculate_attenuation\n\nuniform float attenuationFactor : 5.0;\n\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\n@end\n\n@export qtek.util.edge_factor\n\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\n@end\n\n@export qtek.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n \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\n return res;\n}\n@end\n\n@export qtek.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n \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\n\n@export qtek.util.float\n@import qtek.util.encode_float\n@import qtek.util.decode_float\n@end\n\n\n\n@export qtek.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n }\n@end\n\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\n@export qtek.util.rgbm\n@import qtek.util.rgbm_decode\n@import qtek.util.rgbm_encode\n\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}\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\n@end\n\n\n@export qtek.util.srgb\n\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}\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\n\n@export qtek.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n\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\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\n#endif\n\n@end\n\n@export qtek.chunk.skin_matrix\n\nmat4 skinMatrixWS;\nif (weight.x > 0.0)\n{\n skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\n}\nif (weight.y > 0.0)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 0.0)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 0.0)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n\n\n\n@export qtek.util.parallax_correct\n\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\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n\n return normalize(fixedPos - boxCenter);\n}\n\n@end\n\n\n\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"},function(t,e,n){var r=n(8),i=n(19),a=n(7),o=n(17),s=n(22),u=n(6),l=n(5),c=n(53),h=n(23),f=n(35),d=n(11),_=n(57),p=n(154),m=n(155),v={},g=["px","nx","py","ny","pz","nz"];v.prefilterEnvironmentMap=function(t,e,n,s,p){p&&s||(s=v.generateNormalDistribution(),p=v.integrateBRDF(t,s)),n=n||{};var y=n.width||64,x=n.height||64,T=n.type||e.type,E=new i({width:y,height:x,type:T,flipY:!1,mipmaps:[]});E.isPowerOfTwo()||console.warn("Width and height must be power of two to enable mipmap.");var b=Math.min(y,x),S=Math.log(b)/Math.log(2)+1,A=new u({shader:new l({vertex:l.source("qtek.skybox.vertex"),fragment:m})});A.set("normalDistribution",s),n.encodeRGBM&&A.shader.define("fragment","RGBM_ENCODE"),n.decodeRGBM&&A.shader.define("fragment","RGBM_DECODE");var N,w=new h;if(e instanceof r){var M=new i({width:y,height:x,type:T===a.FLOAT?a.HALF_FLOAT:T});_.panoramaToCubeMap(t,e,M,{encodeRGBM:n.decodeRGBM}),e=M}N=new c({scene:w,material:A}),N.material.set("environmentMap",e);var C=new f({texture:E});n.encodeRGBM&&(T=E.type=a.UNSIGNED_BYTE);for(var R=new r({width:y,height:x,type:T}),L=new o({depthBuffer:!1}),P=d[T===a.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],I=0;I>>16)>>>0;u=((1431655765&u)<<1|(2863311530&u)>>>1)>>>0,u=((858993459&u)<<2|(3435973836&u)>>>2)>>>0,u=((252645135&u)<<4|(4042322160&u)>>>4)>>>0,u=(((16711935&u)<<8|(4278255360&u)>>>8)>>>0)/4294967296;for(var l=0;ll&&(l=t[e][0]),t[e][1]c&&(c=t[e][1]);n=l-s,r=c-u,i=Math.max(n,r),a=s+.5*n,o=u+.5*r,t.push([a-20*i,o-i],[a,o+20*i],[a+20*i,o-i])}function r(t,e,n,r){var i,a,o,s,u,l,c=t[e],h=t[n],f=t[r],d=h[0]-c[0],_=h[1]-c[1],p=f[0]-c[0],m=f[1]-c[1],v=d*(c[0]+h[0])+_*(c[1]+h[1]),g=p*(c[0]+f[0])+m*(c[1]+f[1]),y=2*(d*(f[1]-h[1])-_*(f[0]-h[0]));return Math.abs(y)<1e-6?(i=Math.min(c[0],h[0],f[0]),a=Math.min(c[1],h[1],f[1]),o=.5*(Math.max(c[0],h[0],f[0])-i),s=.5*(Math.max(c[1],h[1],f[1])-a),u=i+o,l=a+s):(u=(m*v-_*g)/y,l=(d*g-p*v)/y,o=u-c[0],s=l-c[1]),{i:e,j:n,k:r,x:u,y:l,r:o*o+s*s}}function i(t){var e,n,r,i,a,o=t.length;t:for(;o;)for(n=t[--o],e=t[--o],r=o;r;)if(a=t[--r],i=t[--r],e===i&&n===a||e===a&&n===i){t.splice(o,2),t.splice(r,2),o-=2;continue t}}var a={triangulate:function(t,e){var a,o,s,u,l,c,h,f,d,_,p,m=t.length;if(m<3)return[];if(t=t.slice(0),e)for(a=m;a--;)t[a]=t[a][e];for(s=new Array(m),a=m;a--;)s[a]=a;for(s.sort(function(e,n){return t[n][0]-t[e][0]}),n(t),u=[r(t,m+0,m+1,m+2)],l=[],c=[],a=s.length;a--;){for(p=s[a],c.length=0,o=u.length;o--;)h=t[p][0]-u[o].x,h>0&&h*h>u[o].r?(l.push(u[o]),u.splice(o,1)):(f=t[p][1]-u[o].y,h*h+f*f>u[o].r||(c.push(u[o].i,u[o].j,u[o].j,u[o].k,u[o].k,u[o].i),u.splice(o,1)));for(i(c),o=c.length;o;)_=c[--o],d=c[--o],u.push(r(t,d,_,p))}for(a=u.length;a--;)l.push(u[a]);for(u.length=0,a=l.length;a--;)if(l[a].it[0][0]&&e[0]>t[1][0]&&e[0]>t[2][0]||e[1]t[0][1]&&e[1]>t[1][1]&&e[1]>t[2][1])return null;var n=t[1][0]-t[0][0],r=t[2][0]-t[0][0],i=t[1][1]-t[0][1],a=t[2][1]-t[0][1],o=n*a-r*i;if(0===o)return null;var s=(a*(e[0]-t[0][0])-r*(e[1]-t[0][1]))/o,u=(n*(e[1]-t[0][1])-i*(e[0]-t[0][0]))/o;return s<0||u<0||s+u>1?null:[s,u]}};t.exports=a},function(t,e,n){"use strict";function r(t,e,n,r){if(t[3]>0){var i=Math.pow(2,t[3]-128-8+r);e[n+0]=t[0]*i,e[n+1]=t[1]*i,e[n+2]=t[2]*i}else e[n+0]=0,e[n+1]=0,e[n+2]=0;return e[n+3]=1,e}function i(t,e,n){for(var r="",i=e;i0;)if(t[o][0]=e[n++],t[o][1]=e[n++],t[o][2]=e[n++],t[o][3]=e[n++],1===t[o][0]&&1===t[o][1]&&1===t[o][2]){for(var u=t[o][3]<>>0;u>0;u--)a(t[o-1],t[o]),o++,s--;i+=8}else o++,s--,i=0;return n}function s(t,e,n,r){if(rf)return o(t,e,n,r);var i=e[n++];if(2!=i)return o(t,e,n-1,r);if(t[0][1]=e[n++],t[0][2]=e[n++],i=e[n++],(t[0][2]<<8>>>0|i)>>>0!==r)return null;for(var i=0;i<4;i++)for(var a=0;a128){s=(127&s)>>>0;for(var u=e[n++];s--;)t[a++][i]=u}else for(;s--;)t[a++][i]=e[n++]}return n}var u=n(7),l=n(8),c=String.fromCharCode,h=8,f=32767,d={parseRGBE:function(t,e,n){null==n&&(n=0);var a=new Uint8Array(t),o=a.length;if("#?"===i(a,0,2)){for(var h=2;h=o)){h+=2;for(var f="";h=0&&this._clips.splice(e,1)},removeAnimator:function(t){for(var e=t.getClips(),n=0;nt)this.inputs.unshift(r);else if(this.inputs[i-1].position<=t)this.inputs.push(r);else{var a=this._findKey(t);this.inputs.splice(a,r)}return r},a.prototype.step=function(t){var e=r.prototype.step.call(this,t);return"finish"!==e&&this.setTime(this._elapsedTime),e},a.prototype.setTime=function(t){var e=this.position,n=this.inputs,i=n.length,a=n[0].position,o=n[i-1].position;if(e<=a||e>=o){var s=e<=a?n[0]:n[i-1],u=s.clip,l=s.offset;u.setTime((t+l)%u.life),u.output instanceof r?this.output.copy(u.output):this.output.copy(u)}else{var c=this._findKey(e),h=n[c],f=n[c+1],d=h.clip,_=f.clip;d.setTime((t+h.offset)%d.life),_.setTime((t+f.offset)%_.life);var p=(this.position-h.position)/(f.position-h.position),m=d.output instanceof r?d.output:d,v=_.output instanceof r?_.output:_;this.output.blend1D(m,v,p)}},a.prototype.clone=function(t){var e=r.prototype.clone.call(this);e.output=this.output.clone();for(var n=0;n=n[i].position&&t=0;i--)t>=n[i].position&&t=0&&(this._cacheKey=e,this._cachePosition=t),e},t.exports=a},function(t,e,n){"use strict";var r=n(20),i=n(84),a=n(26),o=function(t){t=t||{},r.call(this,t),this.output=t.output||null,this.inputs=t.inputs||[],this.position=new a,this._cacheTriangle=null,this._triangles=[],this._updateTriangles()};o.prototype=new r,o.prototype.constructor=o,o.prototype.addInput=function(t,e,n){var r={position:t,clip:e,offset:n||0};return this.inputs.push(r),this.life=Math.max(e.life,this.life),this._updateTriangles(),r},o.prototype._updateTriangles=function(){var t=this.inputs.map(function(t){return t.position});this._triangles=i.triangulate(t,"_array")},o.prototype.step=function(t){var e=r.prototype.step.call(this,t);return"finish"!==e&&this.setTime(this._elapsedTime),e},o.prototype.setTime=function(t){var e=this._findTriangle(this.position);if(e){var n=e[1],i=e[2],a=e[0],o=this.inputs[a.indices[0]],s=this.inputs[a.indices[1]],u=this.inputs[a.indices[2]],l=o.clip,c=s.clip,h=u.clip;l.setTime((t+o.offset)%l.life),c.setTime((t+s.offset)%c.life),h.setTime((t+u.offset)%h.life);var f=l.output instanceof r?l.output:l,d=c.output instanceof r?c.output:c,_=h.output instanceof r?h.output:h;this.output.blend2D(f,d,_,n,i)}},o.prototype.clone=function(t){var e=r.prototype.clone.call(this);e.output=this.output.clone();for(var n=0;n0,l=e.color;e.depth=0,u&&p.set(l,0,0,0,0);for(var c=!0,h=1/r,f=0;f-g&&_-g&&m-g&&v0){var v=d[0],w=(v[0]+1)*u,M=(-v[1]+1)*c;e.fillStyle=m,"rectangle"===A?e.fillRect(w-N,M-N,S,S):"circle"===A&&(e.beginPath(),e.arc(w,M,N,0,2*Math.PI),e.fill())}}}e.restore()},dispose:function(){this._triangles.clear(),this._lines.clear(),this._points.clear(),this._primitives=[],this.ctx=null,this.canvas=null}});t.exports=T},function(t,e,n){"use strict";var r=n(2),i=r.extend({cancelBubble:!1},{stopPropagation:function(){this.cancelBubble=!0}});i["throw"]=function(t,e,n){var r=new i(n);for(r.type=t,r.target=e;e&&!r.cancelBubble;)r.currentTarget=e,e.trigger(t,r),e=e.getParent()},t.exports=i},function(t,e,n){"use strict";var r=n(42),i=function(t){this._list=new r,this._map={},this._maxSize=t||10};i.prototype.setMaxSize=function(t){this._maxSize=t},i.prototype.put=function(t,e){if("undefined"==typeof this._map[t]){var n=this._list.length();if(n>=this._maxSize&&n>0){var r=this._list.head;this._list.remove(r),delete this._map[r.key]}var i=this._list.insert(e);i.key=t,this._map[t]=i}},i.prototype.get=function(t){var e=this._map[t];if("undefined"!=typeof e)return e!==this._list.tail&&(this._list.remove(e),this._list.insertEntry(e)),e.value},i.prototype.remove=function(t){var e=this._map[t];"undefined"!=typeof e&&(delete this._map[t],this._list.remove(e))},i.prototype.clear=function(){this._list.clear(),this._map={}},t.exports=i},function(t,e,n){"use strict";var r=n(2),i=n(5),a=n(6),o=n(17),s=n(22),u=n(8),l=n(7),c=n(13),h=n(46),f=n(44),d=n(71),_=n(16),p=n(3),m=n(69);i["import"](n(81)),i["import"](n(142)),i["import"](n(145)),i["import"](n(140)),i["import"](n(136)),i["import"](n(138)),i["import"](n(137)),i["import"](n(143)),i["import"](n(144)),i["import"](n(146)),i["import"](n(56));var v={},g=r.extend(function(){var t=i.source("qtek.compositor.vertex"),e=i.source("qtek.deferred.light_volume.vertex"),n=new i({vertex:t,fragment:i.source("qtek.deferred.directional_light")}),r=n.clone();r.define("fragment","SHADOWMAP_ENABLED");var c=function(t){t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ONE)},v=function(t){return new a({shader:t,blend:c,transparent:!0,depthMask:!1})},g=function(t,n){var r=new i({vertex:e,fragment:i.source("qtek.deferred."+t)});return n&&r.define("fragment","SHADOWMAP_ENABLED"),r},y=new f({capSegments:10}),x=new _;x.rotateX(Math.PI/2).translate(new p(0,(-1),0)),y.applyTransform(x);var T=new d({capSegments:10});return x.identity().rotateZ(Math.PI/2),T.applyTransform(x),{shadowMapPass:null,autoResize:!0,_createLightPassMat:v,_gBuffer:new m,_lightAccumFrameBuffer:new o({depthBuffer:!1}),_lightAccumTex:new u({type:l.HALF_FLOAT,minFilter:l.NEAREST,magFilter:l.NEAREST}),_fullQuadPass:new s({blendWithPrevious:!0}),_directionalLightMat:v(n),_directionalLightMatWithShadow:v(r),_ambientMat:v(new i({vertex:t,fragment:i.source("qtek.deferred.ambient_light")})),_ambientSHMat:v(new i({vertex:t,fragment:i.source("qtek.deferred.ambient_sh_light")})),_ambientCubemapMat:v(new i({vertex:t,fragment:i.source("qtek.deferred.ambient_cubemap_light")})),_spotLightShader:g("spot_light"),_pointLightShader:g("point_light"),_spotLightShaderWithShadow:g("spot_light",!0),_pointLightShaderWithShadow:g("point_light",!0),_sphereLightShader:g("sphere_light"),_tubeLightShader:g("tube_light"),_lightSphereGeo:new h({widthSegments:10,heightSegements:10}),_lightConeGeo:y,_lightCylinderGeo:T,_outputPass:new s({fragment:i.source("qtek.compositor.output")})}},{render:function(t,e,n,r){r=r||{},r.renderToTarget=r.renderToTarget||!1,r.notUpdateShadow=r.notUpdateShadow||!1,r.notUpdateScene=r.notUpdateScene||!1,r.notUpdateScene||e.update(!1,!0),n.update(!0);var i=t.getDevicePixelRatio();!this.autoResize||t.getWidth()*i===this._lightAccumTex.width&&t.getHeight()*i===this._lightAccumTex.height||this.resize(t.getWidth()*i,t.getHeight()*i),this._gBuffer.update(t,e,n),this._accumulateLightBuffer(t,e,n,!r.notUpdateShadow),r.renderToTarget||(this._outputPass.setUniform("texture",this._lightAccumTex),this._outputPass.render(t))},getTargetTexture:function(){return this._lightAccumTex},getTargetFrameBuffer:function(){return this._lightAccumFrameBuffer},getGBuffer:function(){return this._gBuffer},setViewport:function(t,e,n,r,i){this._gBuffer.setViewport(t,e,n,r,i),this._lightAccumFrameBuffer.viewport=this._gBuffer.getViewport()},resize:function(t,e){this._lightAccumTex.width=t,this._lightAccumTex.height=e,this._gBuffer.resize(t,e)},_accumulateLightBuffer:function(t,e,n,r){for(var i=t.gl,a=this._lightAccumTex,o=this._lightAccumFrameBuffer,s=n.getWorldPosition()._array,u=0;u1?k.name=[s.name,l].join("-"):k.name=s.name),e.meshes[a].push(k)}}},_parseNodes:function(t,e){for(var n in t.nodes){var r,i=t.nodes[n];if(i.camera&&this.includeCamera){var a=t.cameras[i.camera];"perspective"===a.projection?r=new m({name:i.name,aspect:a.aspect_ratio,fov:a.xfov,far:a.zfar,near:a.znear}):(r=new v,console.warn("TODO:Orthographic camera")),r.setName(i.name),e.cameras[i.name]=r}else if(i.lights&&this.includeLight){for(var o=[],s=0;s1?F.name=[r.name,a].join("-"):F.name=r.name),e.meshes[i].push(F)}},this)},_instanceCamera:function(t,e){var n=t.cameras[e.camera];if("perspective"===n.type){var r=n.perspective||{};return new v({name:e.name,aspect:r.aspectRatio,fov:r.yfov,far:r.zfar,near:r.znear})}var i=n.orthographic||{};return new g({name:e.name,top:i.ymag,right:i.xmag,left:-i.xmag,bottom:-i.ymag,near:i.znear,far:i.zfar})},_parseNodes:function(t,e){function n(t){return new c({name:t.name,geometry:t.geometry,material:t.material,mode:t.mode})}a.each(t.nodes,function(t,r){var i;if(null!=t.camera&&this.includeCamera)this._instanceCamera(t.camera),e.cameras.push(i);else if(null!=t.mesh&&this.includeMesh){var a=e.meshes[t.mesh];if(a)if(1===a.length)i=n(a[0]),i.setName(t.name);else{i=new h,i.setName(t.name);for(var o=0;o0&&o.scaleAndAdd(t._array,t._array,this.force._array,r/n)}});t.exports=s},function(t,e,n){"use strict";var r=n(31),i=n(10),a=n(6),o=n(5);o["import"](n(110));var s=new o({vertex:o.source("qtek.particle.vertex"),fragment:o.source("qtek.particle.fragment")});s.enableTexture("sprite");var u=r.extend({loop:!0,oneshot:!1,duration:1,spriteAnimationTileX:1,spriteAnimationTileY:1,spriteAnimationRepeat:0,mode:r.POINTS,ignorePicking:!0,_elapsedTime:0,_emitting:!0},function(){this.geometry=new i({dynamic:!0}),this.material||(this.material=new a({shader:s,transparent:!0,depthMask:!1})),this._particles=[],this._fields=[],this._emitters=[]},{culling:!1,frustumCulling:!1,castShadow:!1,receiveShadow:!1,addEmitter:function(t){this._emitters.push(t)},removeEmitter:function(t){this._emitters.splice(this._emitters.indexOf(t),1)},addField:function(t){this._fields.push(t)},removeField:function(t){this._fields.splice(this._fields.indexOf(t),1)},reset:function(){for(var t=0;t=i.life?(i.emitter.kill(i),e[n]=e[r-1],e.pop(),r--):n++}for(var n=0;n0)for(var a=0;a1,o=t.attributes.position.value,s=t.attributes.normal.value,u=t.attributes.texcoord0.value,l=t.attributes.texcoord1.value,c=this._particles.length;o&&o.length===3*c||(o=t.attributes.position.value=new Float32Array(3*c),s=t.attributes.normal.value=new Float32Array(3*c),a&&(u=t.attributes.texcoord0.value=new Float32Array(2*c),l=t.attributes.texcoord1.value=new Float32Array(2*c)));for(var h=1/e,f=0;fthis.duration&&!this.loop},dispose:function(t){for(var e=0;e>16,n=t-(e<<8)>>8,r=t-(e<<16)-(n<<8);return[e,n,r]}function i(t,e,n){return(t<<16)+(e<<8)+n}var a=n(2),o=n(17),s=n(8),u=n(5),l=n(6);u["import"](n(113));var c=a.extend(function(){return{renderer:null,downSampleRatio:1,width:100,height:100,lookupOffset:1,_frameBuffer:null,_texture:null,_shader:null,_idMaterials:[],_lookupTable:[],_meshMaterials:[],_idOffset:0}},function(){this.renderer&&(this.width=this.renderer.getWidth(),this.height=this.renderer.getHeight()),this._init()},{_init:function(){this._texture=new s({width:this.width*this.downSampleRatio,height:this.height*this.downSampleRatio}),this._frameBuffer=new o,this._shader=new u({vertex:u.source("qtek.picking.color.vertex"),fragment:u.source("qtek.picking.color.fragment")})},setPrecision:function(t){this._texture.width=this.width*t,this._texture.height=this.height*t,this.downSampleRatio=t},resize:function(t,e){this._texture.width=t*this.downSampleRatio,this._texture.height=e*this.downSampleRatio,this.width=t,this.height=e,this._texture.dirty()},update:function(t,e){var n=this.renderer;n.getWidth()===this.width&&n.getHeight()===this.height||this.resize(n.width,n.height),this._frameBuffer.attach(this._texture),this._frameBuffer.bind(n),this._idOffset=this.lookupOffset,this._setMaterial(t),n.render(t,e),this._restoreMaterial(),this._frameBuffer.unbind(n)},_setMaterial:function(t){for(var e=0;e0},update:function(t){if(t=t||16,this._rotating){var e=("cw"===this.autoRotateDirection?1:-1)*this.autoRotateSpeed/180*Math.PI;this._phi-=e*t/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(t,50)),this._updatePan(Math.min(t,50)),this._updateRotate(Math.min(t,50)),this._updateTransform(),this.target.update(),this.trigger("update"),this._needsUpdate=!1)},_updateRotate:function(t){var e=this._rotateVelocity;this._phi=e.y*t/20+this._phi,this._theta=e.x*t/20+this._theta,this.setAlpha(this.getAlpha()),this.setBeta(this.getBeta()),this._vectorDamping(e,this.damping)},_updateDistance:function(t){this._setDistance(this._distance+this._zoomSpeed*t/20),this._zoomSpeed*=this.damping},_setDistance:function(t){this._distance=Math.max(Math.min(t,this.maxDistance),this.minDistance)},_updatePan:function(t){var e=this._panVelocity,n=this._distance,r=this.target,i=r.worldTransform.y,a=r.worldTransform.x;this._center.scaleAndAdd(a,-e.x*n/200).scaleAndAdd(i,-e.y*n/200),this._vectorDamping(e,0)},_updateTransform:function(){var t=this.target,e=new o,n=this._theta+Math.PI/2,r=this._phi+Math.PI/2,i=Math.sin(n);e.x=i*Math.cos(r),e.y=-Math.cos(n),e.z=i*Math.sin(r),t.position.copy(this._center).scaleAndAdd(e,this._distance),t.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var t=this.autoRotateAfterStill,e=this;!isNaN(t)&&t>0&&(this._stillTimeout=setTimeout(function(){e._rotating=!0},1e3*t))},_vectorDamping:function(t,e){var n=t.len();n*=e,n<1e-4&&(n=0),t.normalize().scale(n)},decomposeTransform:function(){if(this.target){var t=new o;t.eulerFromQuat(this.target.rotation.normalize(),"ZYX"),this._theta=-t.x,this._phi=-t.y,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this._setDistance(this.target.position.dist(this._center))}},_mouseDownHandler:function(t){if(!this._isAnimating()){var e=t.clientX,n=t.clientY;if(t.targetTouches){var r=t.targetTouches[0];e=r.clientX,n=r.clientY,this._mode="rotate",this._processGesture(t,"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===t.button?this._mode="rotate":1===t.button&&(this._mode="pan"),this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=e,this._mouseY=n}},_mouseMoveHandler:function(t){if(!this._isAnimating()){var e,n=t.clientX,i=t.clientY;if(t.targetTouches){var a=t.targetTouches[0];n=a.clientX,i=a.clientY,e=this._processGesture(t,"change")}var o=r(this.panSensitivity),s=r(this.rotateSensitivity);e||("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,t.preventDefault()}},_mouseWheelHandler:function(t){if(!this._isAnimating()){var e=t.wheelDelta||-t.detail;0!==e&&this._zoomHandler(t,e>0?-1:1)}},_pinchHandler:function(t){this._isAnimating()||this._zoomHandler(t,t.pinchScale>1?-.4:.4)},_zoomHandler:function(t,e){var n=(t.clientX,t.clientY,Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance)));this._zoomSpeed=e*Math.max(n/40*this.zoomSensitivity,.2),this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),t.preventDefault()},_mouseUpHandler:function(t){var e=this.domElement;e.removeEventListener("touchmove",this._mouseMoveHandler),e.removeEventListener("touchend",this._mouseUpHandler),e.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseup",this._mouseUpHandler),this._processGesture(t,"end")},_addAnimator:function(t){var e=this._animators;return e.push(t),t.done(function(){var n=e.indexOf(t);n>=0&&e.splice(n,1)}),t},_processGesture:function(t,e){var n=this._gestureMgr;"start"===e&&n.clear();var r=n.recognize(t,null,this.domElement);if("end"===e&&n.clear(),r){var i=r.type;t.gestureEvent=i,this._pinchHandler(r.event)}return r}});Object.defineProperty(u.prototype,"autoRotate",{get:function(){return this._autoRotate},set:function(t){this._autoRotate=t,this._rotating=t}}),Object.defineProperty(u.prototype,"target",{get:function(){return this._target},set:function(t){t&&t.target&&this.setCenter(t.target.toArray()),this._target=t,this.decomposeTransform()}}),t.exports=u},function(t,e,n){var r=n(2),i=(n(73),r.extend(function(){console.warn("TODO")},{render:function(t,e,n){}}));t.exports=i},function(t,e,n){var r=n(2),i=n(4),a=n(3),o=n(9),s=n(50),u=n(16),l=n(37),c=n(5),h=(n(12),n(13),n(49)),f=n(47),d=n(48),_=(n(27),n(6)),p=n(17),m=n(7),v=n(8),g=n(19),y=n(21),x=n(28),T=n(22),E=n(41),b=n(1),S=b.mat4,A=(b.vec3,["px","nx","py","ny","pz","nz"]);c["import"](n(149));var N=r.extend(function(){return{softShadow:N.PCF,shadowBlur:1,lightFrustumBias:2,kernelPCF:new Float32Array([1,0,1,1,-1,1,0,1,-1,0,-1,-1,1,-1,0,-1]),precision:"mediump",_frameBuffer:new p,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_meshMaterials:{},_depthMaterials:{},_depthShaders:{},_distanceMaterials:{},_opaqueCasters:[],_receivers:[],_lightsCastShadow:[],_lightCameras:{},_texturePool:new E}},function(){this._gaussianPassH=new T({fragment:c.source("qtek.compositor.gaussian_blur")}),this._gaussianPassV=new T({fragment:c.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 T({fragment:c.source("qtek.sm.debug_depth")})},{render:function(t,e,n,r){this.trigger("beforerender",this,t,e,n),this._renderShadowPass(t,e,n,r),this.trigger("afterrender",this,t,e,n)},renderDebug:function(t,e){t.saveClear();var n=t.viewport,r=0,i=0,a=e||n.width/4,o=a;this.softShadow===N.VSM?this._outputDepthPass.material.shader.define("fragment","USE_VSM"):this._outputDepthPass.material.shader.undefine("fragment","USE_VSM"); -for(var s in this._textures){var u=this._textures[s];t.setViewport(r,i,a*u.width/u.height,o),this._outputDepthPass.setUniform("depthMap",u),this._outputDepthPass.render(t),r+=a*u.width/u.height}t.setViewport(n),t.restoreClear()},_bindDepthMaterial:function(t,e,n){for(var r=0;r0&&(f.define("vertex","SKINNING"),f.define("vertex","JOINT_COUNT",l)),s&&f.define("both","SHADOW_TRANSPARENT"),o.useSkinMatricesTexture&&f.define("vertex","USE_SKIN_MATRICES_TEXTURE"),this._depthShaders[a]=f),h||(h=new _({shader:f}),this._depthMaterials[i]=h),o.material=h,this.softShadow===N.VSM?f.define("fragment","USE_VSM"):f.undefine("fragment","USE_VSM"),h.setUniform("bias",e),h.setUniform("slopeScale",n),s&&h.set("shadowTransparentMap",u))}},_bindDistanceMaterial:function(t,e){for(var n=e.getWorldPosition()._array,r=0;r0&&(o.shader.define("vertex","SKINNING"),o.shader.define("vertex","JOINT_COUNT",a)),this._distanceMaterials[a]=o),i.material=o,this.softShadow===N.VSM?o.shader.define("fragment","USE_VSM"):o.shader.undefine("fragment","USE_VSM")),o.set("lightPosition",n),o.set("range",e.range)}},saveMaterial:function(t){for(var e=0;e1&&(m=g,g.shadowCascade>4)){console.warn("Support at most 4 cascade");continue}this.renderDirectionalLightShadow(t,e,n,g,this._opaqueCasters,_,c,l)}else g instanceof h?this.renderSpotLightShadow(t,g,this._opaqueCasters,u,s):g instanceof d&&this.renderPointLightShadow(t,g,this._opaqueCasters,p);this._shadowMapNumber[g.type]++}this.restoreMaterial(this._opaqueCasters);var y=_.slice(),x=_.slice();y.pop(),x.shift(),y.reverse(),x.reverse(),c.reverse();for(var T=s.map(i),E=l.map(i),b={},v=0;v0&&(N.fragmentDefines[R]=C,w=!0)}w&&N.dirty(),m?N.define("fragment","SHADOW_CASCADE",m.shadowCascade):N.undefine("fragment","SHADOW_CASCADE"),b[N.__GUID__]=!0}s.length>0&&(A.setUniform("spotLightShadowMaps",s),A.setUniform("spotLightMatrices",u),A.setUniform("spotLightShadowMapSizes",T)),l.length>0&&(A.setUniform("directionalLightShadowMaps",l),m&&(A.setUniform("shadowCascadeClipsNear",y),A.setUniform("shadowCascadeClipsFar",x)),A.setUniform("directionalLightMatrices",c),A.setUniform("directionalLightShadowMapSizes",E)),p.length>0&&A.setUniform("pointLightShadowMaps",p)}}},renderDirectionalLightShadow:function(){var t=new s,e=new u,n=new o,r=new u,i=new u,a=new u,c=new u;return function(o,s,h,f,d,_,p,m){var v=f.shadowBias;this._bindDepthMaterial(d,v,f.shadowSlopeScale),d.sort(l.opaqueSortFunc);var g=Math.min(-s.viewBoundingBoxLastFrame.min.z,h.far),x=Math.max(-s.viewBoundingBoxLastFrame.max.z,h.near),T=this._getDirectionalLightCamera(f,s,h),E=a._array;c.copy(T.projectionMatrix),S.invert(i._array,T.worldTransform._array),S.multiply(i._array,i._array,h.worldTransform._array),S.multiply(E,c._array,i._array);for(var b=[],A=h instanceof y,w=(h.near+h.far)/(h.near-h.far),M=2*h.near*h.far/(h.near-h.far),C=0;C<=f.shadowCascade;C++){var R=x*Math.pow(g/x,C/f.shadowCascade),L=x+(g-x)*C/f.shadowCascade,P=R*f.cascadeSplitLogFactor+L*(1-f.cascadeSplitLogFactor);b.push(P),_.push(-(-P*w+M)/-P)}var I=this._getTexture(f,f.shadowCascade);m.push(I);var D=o.viewport,O=o.gl;this._frameBuffer.attach(I),this._frameBuffer.bind(o),O.clear(O.COLOR_BUFFER_BIT|O.DEPTH_BUFFER_BIT);for(var C=0;C0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i),t},o.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},o.cross=function(t,e,n){var r=e[0]*n[1]-e[1]*n[0];return t[0]=t[1]=0,t[2]=r,t},o.lerp=function(t,e,n,r){var i=e[0],a=e[1];return t[0]=i+r*(n[0]-i),t[1]=a+r*(n[1]-a),t},o.random=function(t,e){e=e||1;var n=2*r()*Math.PI;return t[0]=Math.cos(n)*e,t[1]=Math.sin(n)*e,t},o.transformMat2=function(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[2]*i,t[1]=n[1]*r+n[3]*i,t},o.transformMat2d=function(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[2]*i+n[4],t[1]=n[1]*r+n[3]*i+n[5],t},o.transformMat3=function(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[3]*i+n[6],t[1]=n[1]*r+n[4]*i+n[7],t},o.transformMat4=function(t,e,n){var r=e[0],i=e[1];return t[0]=n[0]*r+n[4]*i+n[12],t[1]=n[1]*r+n[5]*i+n[13],t},o.forEach=function(){var t=o.create();return function(e,n,r,i,a,o){var s,u;for(n||(n=2),r||(r=0),u=i?Math.min(i*n+r,e.length):e.length,s=r;s0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t},s.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},s.cross=function(t,e,n){var r=e[0],i=e[1],a=e[2],o=n[0],s=n[1],u=n[2];return t[0]=i*u-a*s,t[1]=a*o-r*u,t[2]=r*s-i*o,t},s.lerp=function(t,e,n,r){var i=e[0],a=e[1],o=e[2];return t[0]=i+r*(n[0]-i),t[1]=a+r*(n[1]-a),t[2]=o+r*(n[2]-o),t},s.random=function(t,e){e=e||1;var n=2*r()*Math.PI,i=2*r()-1,a=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(n)*a,t[1]=Math.sin(n)*a,t[2]=i*e,t},s.transformMat4=function(t,e,n){var r=e[0],i=e[1],a=e[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/o,t[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/o,t[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/o,t},s.transformMat3=function(t,e,n){var r=e[0],i=e[1],a=e[2];return t[0]=r*n[0]+i*n[3]+a*n[6],t[1]=r*n[1]+i*n[4]+a*n[7],t[2]=r*n[2]+i*n[5]+a*n[8],t},s.transformQuat=function(t,e,n){var r=e[0],i=e[1],a=e[2],o=n[0],s=n[1],u=n[2],l=n[3],c=l*r+s*a-u*i,h=l*i+u*r-o*a,f=l*a+o*i-s*r,d=-o*r-s*i-u*a;return t[0]=c*l+d*-o+h*-u-f*-s,t[1]=h*l+d*-s+f*-o-c*-u,t[2]=f*l+d*-u+c*-s-h*-o,t},s.rotateX=function(t,e,n,r){var i=[],a=[];return i[0]=e[0]-n[0],i[1]=e[1]-n[1],i[2]=e[2]-n[2],a[0]=i[0],a[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),a[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),t[0]=a[0]+n[0],t[1]=a[1]+n[1],t[2]=a[2]+n[2],t},s.rotateY=function(t,e,n,r){var i=[],a=[];return i[0]=e[0]-n[0],i[1]=e[1]-n[1],i[2]=e[2]-n[2],a[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),a[1]=i[1],a[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),t[0]=a[0]+n[0],t[1]=a[1]+n[1],t[2]=a[2]+n[2],t},s.rotateZ=function(t,e,n,r){var i=[],a=[];return i[0]=e[0]-n[0],i[1]=e[1]-n[1],i[2]=e[2]-n[2],a[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),a[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),a[2]=i[2],t[0]=a[0]+n[0],t[1]=a[1]+n[1],t[2]=a[2]+n[2],t},s.forEach=function(){var t=s.create();return function(e,n,r,i,a,o){var s,u;for(n||(n=3),r||(r=0),u=i?Math.min(i*n+r,e.length):e.length,s=r;s1?0:Math.acos(i)},s.str=function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},"undefined"!=typeof t&&(t.vec3=s);var u={};u.create=function(){var t=new n(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},u.clone=function(t){var e=new n(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},u.fromValues=function(t,e,r,i){var a=new n(4);return a[0]=t,a[1]=e,a[2]=r,a[3]=i,a},u.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},u.set=function(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t},u.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t},u.subtract=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t},u.sub=u.subtract,u.multiply=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t[3]=e[3]*n[3],t},u.mul=u.multiply,u.divide=function(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t[3]=e[3]/n[3],t},u.div=u.divide,u.min=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t[3]=Math.min(e[3],n[3]),t},u.max=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t[3]=Math.max(e[3],n[3]),t},u.scale=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t},u.scaleAndAdd=function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t},u.distance=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return Math.sqrt(n*n+r*r+i*i+a*a)},u.dist=u.distance,u.squaredDistance=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return n*n+r*r+i*i+a*a},u.sqrDist=u.squaredDistance,u.length=function(t){var e=t[0],n=t[1],r=t[2],i=t[3];return Math.sqrt(e*e+n*n+r*r+i*i)},u.len=u.length,u.squaredLength=function(t){var e=t[0],n=t[1],r=t[2],i=t[3];return e*e+n*n+r*r+i*i},u.sqrLen=u.squaredLength,u.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},u.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t},u.normalize=function(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],o=n*n+r*r+i*i+a*a;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t[3]=e[3]*o),t},u.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},u.lerp=function(t,e,n,r){var i=e[0],a=e[1],o=e[2],s=e[3];return t[0]=i+r*(n[0]-i),t[1]=a+r*(n[1]-a),t[2]=o+r*(n[2]-o),t[3]=s+r*(n[3]-s),t},u.random=function(t,e){return e=e||1,t[0]=r(),t[1]=r(),t[2]=r(),t[3]=r(),u.normalize(t,t),u.scale(t,t,e),t},u.transformMat4=function(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*o,t[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*o,t[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*o,t[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*o,t},u.transformQuat=function(t,e,n){var r=e[0],i=e[1],a=e[2],o=n[0],s=n[1],u=n[2],l=n[3],c=l*r+s*a-u*i,h=l*i+u*r-o*a,f=l*a+o*i-s*r,d=-o*r-s*i-u*a;return t[0]=c*l+d*-o+h*-u-f*-s,t[1]=h*l+d*-s+f*-o-c*-u,t[2]=f*l+d*-u+c*-s-h*-o,t},u.forEach=function(){var t=u.create();return function(e,n,r,i,a,o){var s,u;for(n||(n=4),r||(r=0),u=i?Math.min(i*n+r,e.length):e.length,s=r;s.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(s.cross(t,i,a),r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=1+o,d.normalize(r,r))}}(),d.setAxes=function(){var t=h.create();return function(e,n,r,i){return t[0]=r[0],t[3]=r[1],t[6]=r[2],t[1]=i[0],t[4]=i[1],t[7]=i[2],t[2]=-n[0],t[5]=-n[1],t[8]=-n[2],d.normalize(e,d.fromMat3(e,t))}}(),d.clone=u.clone,d.fromValues=u.fromValues,d.copy=u.copy,d.set=u.set,d.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},d.setAxisAngle=function(t,e,n){n=.5*n;var r=Math.sin(n);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(n),t},d.add=u.add,d.multiply=function(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3],s=n[0],u=n[1],l=n[2],c=n[3];return t[0]=r*c+o*s+i*l-a*u,t[1]=i*c+o*u+a*s-r*l,t[2]=a*c+o*l+r*u-i*s,t[3]=o*c-r*s-i*u-a*l,t},d.mul=d.multiply,d.scale=u.scale,d.rotateX=function(t,e,n){n*=.5;var r=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(n),u=Math.cos(n);return t[0]=r*u+o*s,t[1]=i*u+a*s,t[2]=a*u-i*s,t[3]=o*u-r*s,t},d.rotateY=function(t,e,n){n*=.5;var r=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(n),u=Math.cos(n);return t[0]=r*u-a*s,t[1]=i*u+o*s,t[2]=a*u+r*s,t[3]=o*u-i*s,t},d.rotateZ=function(t,e,n){n*=.5;var r=e[0],i=e[1],a=e[2],o=e[3],s=Math.sin(n),u=Math.cos(n);return t[0]=r*u+i*s,t[1]=i*u-r*s,t[2]=a*u+o*s,t[3]=o*u-a*s,t},d.calculateW=function(t,e){var n=e[0],r=e[1],i=e[2];return t[0]=n,t[1]=r,t[2]=i,t[3]=Math.sqrt(Math.abs(1-n*n-r*r-i*i)),t},d.dot=u.dot,d.lerp=u.lerp,d.slerp=function(t,e,n,r){var i,a,o,s,u,l=e[0],c=e[1],h=e[2],f=e[3],d=n[0],_=n[1],p=n[2],m=n[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-r)*i)/o,u=Math.sin(r*i)/o):(s=1-r,u=r),t[0]=s*l+u*d,t[1]=s*c+u*_,t[2]=s*h+u*p,t[3]=s*f+u*m,t},d.invert=function(t,e){var n=e[0],r=e[1],i=e[2],a=e[3],o=n*n+r*r+i*i+a*a,s=o?1/o:0;return t[0]=-n*s,t[1]=-r*s,t[2]=-i*s,t[3]=a*s,t},d.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},d.length=u.length,d.len=d.length,d.squaredLength=u.squaredLength,d.sqrLen=d.squaredLength,d.normalize=u.normalize,d.fromMat3=function(t,e){var n,r=e[0]+e[4]+e[8];if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{var i=0;e[4]>e[0]&&(i=1),e[8]>e[3*i+i]&&(i=2);var a=(i+1)%3,o=(i+2)%3;n=Math.sqrt(e[3*i+i]-e[3*a+a]-e[3*o+o]+1),t[i]=.5*n,n=.5/n,t[3]=(e[3*a+o]-e[3*o+a])*n,t[a]=(e[3*a+i]+e[3*i+a])*n,t[o]=(e[3*o+i]+e[3*i+o])*n}return t},d.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},"undefined"!=typeof t&&(t.quat=d)}(n.exports)}(this)},function(t,e,n){"use strict";var r=n(69),i=n(43),a=n(15),o=function(){this.__GUID__=a.genGUID()};o.__initializers__=[function(t){a.extend(this,t)}],a.extend(o,r),a.extend(o.prototype,i),t.exports=o},function(t,e,n){"use strict";function r(t,e,n){return tn?n:t}var i=n(1),a=i.vec3,o=function(t,e,n){t=t||0,e=e||0,n=n||0,this._array=a.fromValues(t,e,n),this._dirty=!0};o.prototype={constructor:o,add:function(t){return a.add(this._array,this._array,t._array),this._dirty=!0,this},set:function(t,e,n){return this._array[0]=t,this._array[1]=e,this._array[2]=n,this._dirty=!0,this},setArray:function(t){return this._array[0]=t[0],this._array[1]=t[1],this._array[2]=t[2],this._dirty=!0,this},clone:function(){return new o(this.x,this.y,this.z)},copy:function(t){return a.copy(this._array,t._array),this._dirty=!0,this},cross:function(t,e){return a.cross(this._array,t._array,e._array),this._dirty=!0,this},dist:function(t){return a.dist(this._array,t._array)},distance:function(t){return a.distance(this._array,t._array)},div:function(t){return a.div(this._array,this._array,t._array),this._dirty=!0,this},divide:function(t){return a.divide(this._array,this._array,t._array),this._dirty=!0,this},dot:function(t){return a.dot(this._array,t._array)},len:function(){return a.len(this._array)},length:function(){return a.length(this._array)},lerp:function(t,e,n){return a.lerp(this._array,t._array,e._array,n),this._dirty=!0,this},min:function(t){return a.min(this._array,this._array,t._array),this._dirty=!0,this},max:function(t){return a.max(this._array,this._array,t._array),this._dirty=!0,this},mul:function(t){return a.mul(this._array,this._array,t._array),this._dirty=!0,this},multiply:function(t){return a.multiply(this._array,this._array,t._array),this._dirty=!0,this},negate:function(){return a.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return a.normalize(this._array,this._array),this._dirty=!0,this},random:function(t){return a.random(this._array,t),this._dirty=!0,this},scale:function(t){return a.scale(this._array,this._array,t),this._dirty=!0,this},scaleAndAdd:function(t,e){return a.scaleAndAdd(this._array,this._array,t._array,e),this._dirty=!0,this},sqrDist:function(t){return a.sqrDist(this._array,t._array)},squaredDistance:function(t){return a.squaredDistance(this._array,t._array)},sqrLen:function(){return a.sqrLen(this._array)},squaredLength:function(){return a.squaredLength(this._array)},sub:function(t){return a.sub(this._array,this._array,t._array),this._dirty=!0,this},subtract:function(t){return a.subtract(this._array,this._array,t._array),this._dirty=!0,this},transformMat3:function(t){return a.transformMat3(this._array,this._array,t._array),this._dirty=!0,this},transformMat4:function(t){return a.transformMat4(this._array,this._array,t._array),this._dirty=!0,this},transformQuat:function(t){return a.transformQuat(this._array,this._array,t._array),this._dirty=!0,this},applyProjection:function(t){var e=this._array;if(t=t._array,0===t[15]){var n=-1/e[2];e[0]=t[0]*e[0]*n,e[1]=t[5]*e[1]*n,e[2]=(t[10]*e[2]+t[14])*n}else e[0]=t[0]*e[0]+t[12],e[1]=t[5]*e[1]+t[13],e[2]=t[10]*e[2]+t[14];return this._dirty=!0,this},eulerFromQuat:function(t,e){o.eulerFromQuat(this,t,e)},eulerFromMat3:function(t,e){o.eulerFromMat3(this,t,e); +},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}};var s=Object.defineProperty;if(s){var u=o.prototype;s(u,"x",{get:function(){return this._array[0]},set:function(t){this._array[0]=t,this._dirty=!0}}),s(u,"y",{get:function(){return this._array[1]},set:function(t){this._array[1]=t,this._dirty=!0}}),s(u,"z",{get:function(){return this._array[2]},set:function(t){this._array[2]=t,this._dirty=!0}})}o.add=function(t,e,n){return a.add(t._array,e._array,n._array),t._dirty=!0,t},o.set=function(t,e,n,r){a.set(t._array,e,n,r),t._dirty=!0},o.copy=function(t,e){return a.copy(t._array,e._array),t._dirty=!0,t},o.cross=function(t,e,n){return a.cross(t._array,e._array,n._array),t._dirty=!0,t},o.dist=function(t,e){return a.distance(t._array,e._array)},o.distance=o.dist,o.div=function(t,e,n){return a.divide(t._array,e._array,n._array),t._dirty=!0,t},o.divide=o.div,o.dot=function(t,e){return a.dot(t._array,e._array)},o.len=function(t){return a.length(t._array)},o.lerp=function(t,e,n,r){return a.lerp(t._array,e._array,n._array,r),t._dirty=!0,t},o.min=function(t,e,n){return a.min(t._array,e._array,n._array),t._dirty=!0,t},o.max=function(t,e,n){return a.max(t._array,e._array,n._array),t._dirty=!0,t},o.mul=function(t,e,n){return a.multiply(t._array,e._array,n._array),t._dirty=!0,t},o.multiply=o.mul,o.negate=function(t,e){return a.negate(t._array,e._array),t._dirty=!0,t},o.normalize=function(t,e){return a.normalize(t._array,e._array),t._dirty=!0,t},o.random=function(t,e){return a.random(t._array,e),t._dirty=!0,t},o.scale=function(t,e,n){return a.scale(t._array,e._array,n),t._dirty=!0,t},o.scaleAndAdd=function(t,e,n,r){return a.scaleAndAdd(t._array,e._array,n._array,r),t._dirty=!0,t},o.sqrDist=function(t,e){return a.sqrDist(t._array,e._array)},o.squaredDistance=o.sqrDist,o.sqrLen=function(t){return a.sqrLen(t._array)},o.squaredLength=o.sqrLen,o.sub=function(t,e,n){return a.subtract(t._array,e._array,n._array),t._dirty=!0,t},o.subtract=o.sub,o.transformMat3=function(t,e,n){return a.transformMat3(t._array,e._array,n._array),t._dirty=!0,t},o.transformMat4=function(t,e,n){return a.transformMat4(t._array,e._array,n._array),t._dirty=!0,t},o.transformQuat=function(t,e,n){return a.transformQuat(t._array,e._array,n._array),t._dirty=!0,t};var l=Math.atan2,c=Math.asin,h=Math.abs;o.eulerFromQuat=function(t,e,n){t._dirty=!0,e=e._array;var i=t._array,a=e[0],o=e[1],s=e[2],u=e[3],h=a*a,f=o*o,d=s*s,_=u*u,n=(n||"XYZ").toUpperCase();switch(n){case"XYZ":i[0]=l(2*(a*u-o*s),_-h-f+d),i[1]=c(r(2*(a*s+o*u),-1,1)),i[2]=l(2*(s*u-a*o),_+h-f-d);break;case"YXZ":i[0]=c(r(2*(a*u-o*s),-1,1)),i[1]=l(2*(a*s+o*u),_-h-f+d),i[2]=l(2*(a*o+s*u),_-h+f-d);break;case"ZXY":i[0]=c(r(2*(a*u+o*s),-1,1)),i[1]=l(2*(o*u-s*a),_-h-f+d),i[2]=l(2*(s*u-a*o),_-h+f-d);break;case"ZYX":i[0]=l(2*(a*u+s*o),_-h-f+d),i[1]=c(r(2*(o*u-a*s),-1,1)),i[2]=l(2*(a*o+s*u),_+h-f-d);break;case"YZX":i[0]=l(2*(a*u-s*o),_-h+f-d),i[1]=l(2*(o*u-a*s),_+h-f-d),i[2]=c(r(2*(a*o+s*u),-1,1));break;case"XZY":i[0]=l(2*(a*u+o*s),_-h+f-d),i[1]=l(2*(a*s+o*u),_+h-f-d),i[2]=c(r(2*(s*u-a*o),-1,1));break;default:console.warn("Unkown order: "+n)}return t},o.eulerFromMat3=function(t,e,n){var i=e._array,a=i[0],o=i[3],s=i[6],u=i[1],f=i[4],d=i[7],_=i[2],p=i[5],m=i[8],v=t._array,n=(n||"XYZ").toUpperCase();switch(n){case"XYZ":v[1]=c(r(s,-1,1)),h(s)<.99999?(v[0]=l(-d,m),v[2]=l(-o,a)):(v[0]=l(p,f),v[2]=0);break;case"YXZ":v[0]=c(-r(d,-1,1)),h(d)<.99999?(v[1]=l(s,m),v[2]=l(u,f)):(v[1]=l(-_,a),v[2]=0);break;case"ZXY":v[0]=c(r(p,-1,1)),h(p)<.99999?(v[1]=l(-_,m),v[2]=l(-o,f)):(v[1]=0,v[2]=l(u,a));break;case"ZYX":v[1]=c(-r(_,-1,1)),h(_)<.99999?(v[0]=l(p,m),v[2]=l(u,a)):(v[0]=0,v[2]=l(-o,f));break;case"YZX":v[2]=c(r(u,-1,1)),h(u)<.99999?(v[0]=l(-d,f),v[1]=l(-_,a)):(v[0]=0,v[1]=l(s,m));break;case"XZY":v[2]=c(-r(o,-1,1)),h(o)<.99999?(v[0]=l(p,f),v[1]=l(s,a)):(v[0]=l(-d,m),v[1]=0);break;default:console.warn("Unkown order: "+n)}return t._dirty=!0,t},o.POSITIVE_X=new o(1,0,0),o.NEGATIVE_X=new o((-1),0,0),o.POSITIVE_Y=new o(0,1,0),o.NEGATIVE_Y=new o(0,(-1),0),o.POSITIVE_Z=new o(0,0,1),o.NEGATIVE_Z=new o(0,0,(-1)),o.UP=new o(0,1,0),o.ZERO=new o(0,0,0),t.exports=o},function(t,e){t.exports={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(t,e,n){"use strict";function r(){return{locations:{},attriblocations:{}}}function i(t,e,n){if(!t.getShaderParameter(e,t.COMPILE_STATUS))return[t.getShaderInfoLog(e),a(n)].join("\n")}function a(t){for(var e=t.split("\n"),n=0,r=e.length;n0&&r.push("#define "+i.toUpperCase()+"_COUNT "+a)}for(var o in n){var s=n[o];s.enabled&&r.push("#define "+o.toUpperCase()+"_ENABLED")}for(var o in t){var u=t[o];null===u?r.push("#define "+o):r.push("#define "+o+" "+u.toString())}return r.join("\n")},_unrollLoop:function(t,e){function n(t,n,i,a){var o="";isNaN(n)&&(n=n in e?e[n]:r[n]),isNaN(i)&&(i=i in e?e[i]:r[i]);for(var s=parseInt(n);s=0)n.attribSemantics[u]={symbol:a,type:c},h=!1;else if(E.indexOf(u)>=0){var f=!1,d=u;u.match(/TRANSPOSE$/)&&(f=!0,d=u.slice(0,-9)),n.matrixSemantics[u]={symbol:a,type:c,isTranspose:f,semanticNoTranspose:d},h=!1}else if(T.indexOf(u)>=0)n.uniformSemantics[u]={symbol:a,type:c},h=!1;else if("unconfigurable"===u)h=!1;else{if(l=n._parseDefaultValue(i,u),!l)throw new Error('Unkown semantic "'+u+'"');u=""}h&&(e[a]={type:c,value:o?y.array:l||y[i],semantic:u||null})}return["uniform",i,a,o].join(" ")+";\n"}}var e={},n=this,r="vertex";this._uniformList=[],this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(_,t),r="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(_,t),n.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=e},_parseDefaultValue:function(t,e){var n=/\[\s*(.*)\s*\]/;{if("vec2"!==t&&"vec3"!==t&&"vec4"!==t)return"bool"===t?function(){return"true"===e.toLowerCase()}:"float"===t?function(){return parseFloat(e)}:"int"===t?function(){return parseInt(e)}:void 0;var r=n.exec(e)[1];if(r){var i=r.split(/\s*,\s*/);return function(){return new l.Float32Array(i)}}}},createUniforms:function(){var t={};for(var e in this.uniformTemplates){var n=this.uniformTemplates[e];t[e]={type:n.type,value:n.value()}}return t},attached:function(){this._attacheMaterialNumber++},detached:function(){this._attacheMaterialNumber--},isAttachedToAny:function(){return 0!==this._attacheMaterialNumber},_parseAttributes:function(){function t(t,r,i,a,o){if(r&&i){var s=1;switch(r){case"vec4":s=4;break;case"vec3":s=3;break;case"vec2":s=2;break;case"float":s=1}if(e[i]={type:"float",size:s,semantic:o||null},o){if(x.indexOf(o)<0)throw new Error('Unkown semantic "'+o+'"');n.attribSemantics[o]={symbol:i,type:r}}}return["attribute",r,i].join(" ")+";\n"}var e={},n=this;this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(p,t),this.attributeTemplates=e},_parseDefines:function(){function t(t,r,i){var a="vertex"===n?e.vertexDefines:e.fragmentDefines;return a[r]||("false"==i?a[r]=!1:"true"==i?a[r]=!0:a[r]=i?isNaN(parseFloat(i))?i:parseFloat(i):null),""}var e=this,n="vertex";this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(m,t),n="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(m,t)},_buildProgram:function(t,e,n){var r=this._cache;r.get("program")&&t.deleteProgram(r.get("program"));var a=t.createProgram(),o=t.createShader(t.VERTEX_SHADER);t.shaderSource(o,e),t.compileShader(o);var s=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(s,n),t.compileShader(s);var u=i(t,o,e);if(u)return u;if(u=i(t,s,n))return u;if(t.attachShader(a,o),t.attachShader(a,s),this.attribSemantics.POSITION)t.bindAttribLocation(a,0,this.attribSemantics.POSITION.symbol);else{var l=Object.keys(this.attributeTemplates);t.bindAttribLocation(a,0,l[0])}if(t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))return"Could not link program\nVALIDATE_STATUS: "+t.getProgramParameter(a,t.VALIDATE_STATUS)+", gl error ["+t.getError()+"]";for(var c=0;c=0},set:function(t,e){if("object"==typeof t)for(var n in t){var r=t[n];this.set(n,r)}else{var i=this.uniforms[t];i&&("undefined"==typeof e&&(console.warn('Uniform value "'+t+'" is undefined'),e=null),i.value=e)}},get:function(t){var e=this.uniforms[t];if(e)return e.value},attachShader:function(t,e){this.shader&&this.shader.detached();var n=this.uniforms;this.uniforms=t.createUniforms(),this.shader=t;var r=this.uniforms;if(this._enabledUniforms=Object.keys(r),this._enabledUniforms.sort(),e)for(var i in n)r[i]&&(r[i].value=n[i].value);t.attached()},detachShader:function(){this.shader.detached(),this.shader=null,this.uniforms={}},clone:function(){var t=new this.constructor({name:this.name,shader:this.shader});for(var e in this.uniforms)t.uniforms[e].value=this.uniforms[e].value;return t.depthTest=this.depthTest,t.depthMask=this.depthMask,t.transparent=this.transparent,t.blend=this.blend,t},dispose:function(t,e){if(e)for(var n in this.uniforms){var r=this.uniforms[n].value;if(r)if(r instanceof i)r.dispose(t);else if(r instanceof Array)for(var a=0;a>e;return t+1},dispose:function(t){var e=this._cache;e.use(t.__GLID__);var n=e.get("webgl_texture");n&&t.deleteTexture(n),e.deleteContext(t.__GLID__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(s.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t}}),Object.defineProperty(s.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t}}),s.BYTE=i.BYTE,s.UNSIGNED_BYTE=i.UNSIGNED_BYTE,s.SHORT=i.SHORT,s.UNSIGNED_SHORT=i.UNSIGNED_SHORT,s.INT=i.INT,s.UNSIGNED_INT=i.UNSIGNED_INT,s.FLOAT=i.FLOAT,s.HALF_FLOAT=36193,s.UNSIGNED_INT_24_8_WEBGL=34042,s.DEPTH_COMPONENT=i.DEPTH_COMPONENT,s.DEPTH_STENCIL=i.DEPTH_STENCIL,s.ALPHA=i.ALPHA,s.RGB=i.RGB,s.RGBA=i.RGBA,s.LUMINANCE=i.LUMINANCE,s.LUMINANCE_ALPHA=i.LUMINANCE_ALPHA,s.SRGB=35904,s.SRGB_ALPHA=35906,s.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,s.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,s.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,s.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,s.NEAREST=i.NEAREST,s.LINEAR=i.LINEAR,s.NEAREST_MIPMAP_NEAREST=i.NEAREST_MIPMAP_NEAREST,s.LINEAR_MIPMAP_NEAREST=i.LINEAR_MIPMAP_NEAREST,s.NEAREST_MIPMAP_LINEAR=i.NEAREST_MIPMAP_LINEAR,s.LINEAR_MIPMAP_LINEAR=i.LINEAR_MIPMAP_LINEAR,s.REPEAT=i.REPEAT,s.CLAMP_TO_EDGE=i.CLAMP_TO_EDGE,s.MIRRORED_REPEAT=i.MIRRORED_REPEAT,t.exports=s},function(t,e,n){var r=n(7),i=n(14),a=n(4),o=n(52),s=o.isPowerOfTwo,u=r.extend(function(){return{image:null,pixels:null,mipmaps:[]}},{update:function(t){t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),this.updateCommon(t);var e=this.format,n=this.type;t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,this.wrapS),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,this.wrapT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,this.magFilter),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,this.minFilter);var r=i.getExtension(t,"EXT_texture_filter_anisotropic");if(r&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===n){var o=i.getExtension(t,"OES_texture_half_float");o||(n=a.FLOAT)}if(this.mipmaps.length)for(var s=this.width,u=this.height,l=0;l=r.COMPRESSED_RGB_S3TC_DXT1_EXT?t.compressedTexImage2D(t.TEXTURE_2D,n,o,i,a,0,e.pixels):t.texImage2D(t.TEXTURE_2D,n,o,i,a,0,o,s,e.pixels)},generateMipmap:function(t){this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_2D))},isPowerOfTwo:function(){var t,e;return this.image?(t=this.image.width, +e=this.image.height):(t=this.width,e=this.height),s(t)&&s(e)},isRenderable:function(){return this.image?"CANVAS"===this.image.nodeName||"VIDEO"===this.image.nodeName||this.image.complete:!(!this.width||!this.height)},bind:function(t){t.bindTexture(t.TEXTURE_2D,this.getWebGLTexture(t))},unbind:function(t){t.bindTexture(t.TEXTURE_2D,null)},load:function(t,e){var n=new Image;e&&(n.crossOrigin=e);var r=this;return n.onload=function(){r.dirty(),r.trigger("success",r),n.onload=null},n.onerror=function(){r.trigger("error",r),n.onerror=null},n.src=t,this.image=n,this}});Object.defineProperty(u.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(t){this.image?console.warn("Texture from image can't set width"):(this._width!==t&&this.dirty(),this._width=t)}}),Object.defineProperty(u.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(t){this.image?console.warn("Texture from image can't set height"):(this._height!==t&&this.dirty(),this._height=t)}}),t.exports=u},function(t,e,n){"use strict";var r=n(3),i=n(1),a=i.vec3,o=a.copy,s=a.set,u=function(t,e){this.min=t||new r(1/0,1/0,1/0),this.max=e||new r((-(1/0)),(-(1/0)),(-(1/0)))};u.prototype={constructor:u,updateFromVertices:function(t){if(t.length>0){var e=this.min,n=this.max,r=e._array,i=n._array;o(r,t[0]),o(i,t[0]);for(var a=1;ai[0]&&(i[0]=s[0]),s[1]>i[1]&&(i[1]=s[1]),s[2]>i[2]&&(i[2]=s[2])}e._dirty=!0,n._dirty=!0}},union:function(t){var e=this.min,n=this.max;return a.min(e._array,e._array,t.min._array),a.max(n._array,n._array,t.max._array),e._dirty=!0,n._dirty=!0,this},intersection:function(t){var e=this.min,n=this.max;return a.max(e._array,e._array,t.min._array),a.min(n._array,n._array,t.max._array),e._dirty=!0,n._dirty=!0,this},intersectBoundingBox:function(t){var e=this.min._array,n=this.max._array,r=t.min._array,i=t.max._array;return!(e[0]>i[0]||e[1]>i[1]||e[2]>i[2]||n[0]=i[0]&&n[1]>=i[1]&&n[2]>=i[2]},containPoint:function(t){var e=this.min._array,n=this.max._array,r=t._array;return e[0]<=r[0]&&e[1]<=r[1]&&e[2]<=r[2]&&n[0]>=r[0]&&n[1]>=r[1]&&n[2]>=r[2]},isFinite:function(){var t=this.min._array,e=this.max._array;return isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])&&isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])},applyTransform:function(){var t=a.create(),e=a.create(),n=a.create(),r=a.create(),i=a.create(),o=a.create();return function(a){var s=this.min._array,u=this.max._array,l=a._array;return t[0]=l[0]*s[0],t[1]=l[1]*s[0],t[2]=l[2]*s[0],e[0]=l[0]*u[0],e[1]=l[1]*u[0],e[2]=l[2]*u[0],n[0]=l[4]*s[1],n[1]=l[5]*s[1],n[2]=l[6]*s[1],r[0]=l[4]*u[1],r[1]=l[5]*u[1],r[2]=l[6]*u[1],i[0]=l[8]*s[2],i[1]=l[9]*s[2],i[2]=l[10]*s[2],o[0]=l[8]*u[2],o[1]=l[9]*u[2],o[2]=l[10]*u[2],s[0]=Math.min(t[0],e[0])+Math.min(n[0],r[0])+Math.min(i[0],o[0])+l[12],s[1]=Math.min(t[1],e[1])+Math.min(n[1],r[1])+Math.min(i[1],o[1])+l[13],s[2]=Math.min(t[2],e[2])+Math.min(n[2],r[2])+Math.min(i[2],o[2])+l[14],u[0]=Math.max(t[0],e[0])+Math.max(n[0],r[0])+Math.max(i[0],o[0])+l[12],u[1]=Math.max(t[1],e[1])+Math.max(n[1],r[1])+Math.max(i[1],o[1])+l[13],u[2]=Math.max(t[2],e[2])+Math.max(n[2],r[2])+Math.max(i[2],o[2])+l[14],this.min._dirty=!0,this.max._dirty=!0,this}}(),applyProjection:function(t){var e=this.min._array,n=this.max._array,r=t._array,i=e[0],a=e[1],o=e[2],s=n[0],u=n[1],l=e[2],c=n[0],h=n[1],f=n[2];if(1===r[15])e[0]=r[0]*i+r[12],e[1]=r[5]*a+r[13],n[2]=r[10]*o+r[14],n[0]=r[0]*c+r[12],n[1]=r[5]*h+r[13],e[2]=r[10]*f+r[14];else{var d=-1/o;e[0]=r[0]*i*d,e[1]=r[5]*a*d,n[2]=(r[10]*o+r[14])*d,d=-1/l,n[0]=r[0]*s*d,n[1]=r[5]*u*d,d=-1/f,e[2]=(r[10]*f+r[14])*d}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var t=this.vertices;if(!t){for(var t=[],e=0;e<8;e++)t[e]=a.fromValues(0,0,0);this.vertices=t}var n=this.min._array,r=this.max._array;return s(t[0],n[0],n[1],n[2]),s(t[1],n[0],r[1],n[2]),s(t[2],r[0],n[1],n[2]),s(t[3],r[0],r[1],n[2]),s(t[4],n[0],n[1],r[2]),s(t[5],n[0],r[1],r[2]),s(t[6],r[0],n[1],r[2]),s(t[7],r[0],r[1],r[2]),this},copy:function(t){var e=this.min,n=this.max;return o(e._array,t.min._array),o(n._array,t.max._array),e._dirty=!0,n._dirty=!0,this},clone:function(){var t=new u;return t.copy(this),t}},t.exports=u},function(t,e,n){"use strict";function r(t){return"attr_"+t}var i=n(59),a=n(9),o=n(1),s=n(11),u=n(4),l=o.mat4,c=o.vec3,h=i.StaticAttribute,f=c.create,d=c.add,_=c.set,p=i.extend(function(){return{attributes:{position:new h("position","float",3,"POSITION"),texcoord0:new h("texcoord0","float",2,"TEXCOORD_0"),texcoord1:new h("texcoord1","float",2,"TEXCOORD_1"),normal:new h("normal","float",3,"NORMAL"),tangent:new h("tangent","float",4,"TANGENT"),color:new h("color","float",4,"COLOR"),weight:new h("weight","float",3,"WEIGHT"),joint:new h("joint","float",4,"JOINT"),barycentric:new h("barycentric","float",3,null)},hint:u.STATIC_DRAW,indices:null,_normalType:"vertex",_enabledAttributes:null}},{updateBoundingBox:function(){var t=this.boundingBox;t||(t=this.boundingBox=new a);var e=this.attributes.position.value;if(e&&e.length){var n=t.min,r=t.max,i=n._array,o=r._array;c.set(i,e[0],e[1],e[2]),c.set(o,e[0],e[1],e[2]);for(var s=3;so[0]&&(o[0]=u),l>o[1]&&(o[1]=l),h>o[2]&&(o[2]=h)}n._dirty=!0,r._dirty=!0}},dirty:function(){for(var t=this.getEnabledAttributes(),e=0;e=0){e||(e=f());var n=this.indices;return e[0]=n[3*t],e[1]=n[3*t+1],e[2]=n[3*t+2],e}},setTriangleIndices:function(t,e){var n=this.indices;n[3*t]=e[0],n[3*t+1]=e[1],n[3*t+2]=e[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(t){var e,n=this.vertexCount>65535?s.Uint32Array:s.Uint16Array;if(t[0]&&t[0].length){var r=0,i=3;e=new n(t.length*i);for(var a=0;a=0&&(e.splice(n,1),delete this.attributes[t],!0)},getEnabledAttributes:function(){var t=this._enabledAttributes,e=this._attributeList;if(t)return t;for(var n=[],r=this.vertexCount,i=0;i65535&&(this.indices=new s.Uint32Array(this.indices));for(var t=this.attributes,e=this.indices,n=this.getEnabledAttributes(),r={},i=0;i256?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(),e.setUniform(t,"1f","skinMatricesTextureSize",i)}else e.setUniformOfSemantic(t,"SKIN_MATRIX",n)}return r.prototype.render.call(this,t,e)},getSkinMatricesTexture:function(){return this._skinMatricesTexture=this._skinMatricesTexture||new a({type:i.FLOAT,minFilter:i.NEAREST,magFilter:i.NEAREST,useMipmap:!1,flipY:!1}),this._skinMatricesTexture}});o.POINTS=i.POINTS,o.LINES=i.LINES,o.LINE_LOOP=i.LINE_LOOP,o.LINE_STRIP=i.LINE_STRIP,o.TRIANGLES=i.TRIANGLES,o.TRIANGLE_STRIP=i.TRIANGLE_STRIP,o.TRIANGLE_FAN=i.TRIANGLE_FAN,o.BACK=i.BACK,o.FRONT=i.FRONT,o.FRONT_AND_BACK=i.FRONT_AND_BACK,o.CW=i.CW,o.CCW=i.CCW,t.exports=o},function(t,e){"use strict";var n=["OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear","OES_standard_derivatives","OES_vertex_array_object","OES_element_index_uint","WEBGL_compressed_texture_s3tc","WEBGL_depth_texture","EXT_texture_filter_anisotropic","EXT_shader_texture_lod","WEBGL_draw_buffers","EXT_frag_depth","EXT_sRGB"],r=["MAX_TEXTURE_SIZE","MAX_CUBE_MAP_TEXTURE_SIZE"],i={},a={},o={initialize:function(t){var e=t.__GLID__;if(!i[e]){i[e]={},a[e]={};for(var o=0;o1&&t.texParameterf(t.TEXTURE_CUBE_MAP,r.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===n){var i=a.getExtension(t,"OES_texture_half_float");i||(n=o.FLOAT)}if(this.mipmaps.length)for(var s=this.width,u=this.height,l=0;l0?(this._restartInLoop(t),this._loopRemained--,"restart"):(this._needsRemove=!0,"finish"):null}}},setTime:function(t){return this.step(t+this._startTime)},restart:function(t){var e=0;t&&(this._elapse(t),e=this._elapsedTime%this.life),t=t||(new Date).getTime(),this._startTime=t-e+this.delay,this._elapsedTime=0,this._needsRemove=!1,this._paused=!1},getElapsedTime:function(){return this._elapsedTime},_restartInLoop:function(t){this._startTime=t+this.gap,this._elapsedTime=0},_elapse:function(t,e){this._elapsedTime+=e*this.playbackRate},fire:function(t,e){var n="on"+t;this[n]&&this[n](this.target,e)},clone:function(){var t=new this.constructor;return t.name=this.name,t._loop=this._loop,t._loopRemained=this._loopRemained,t.life=this.life,t.gap=this.gap,t.delay=this.delay,t},pause:function(){this._paused=!0},resume:function(){this._paused=!1}},a.prototype.constructor=a,t.exports=a},function(t,e,n){"use strict";var r=n(36),i=r.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var t=this.fov/180*Math.PI;this.projectionMatrix.perspective(t,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var t=this.projectionMatrix._array,e=2*Math.atan(1/t[5]);this.fov=e/Math.PI*180,this.aspect=t[5]/t[0],this.near=t[14]/(t[10]-1),this.far=t[14]/(t[10]+1)},clone:function(){var t=r.prototype.clone.call(this);return t.fov=this.fov,t.aspect=this.aspect,t.near=this.near,t.far=this.far,t}});t.exports=i},function(t,e,n){"use strict";var r=n(2),i=n(28),a=n(45),o=n(5),s=n(6),u=n(13),l=n(14),c=n(4);o["import"](n(134));var h=new a,f=new u({geometry:h,frustumCulling:!1}),d=new i,_=r.extend(function(){return{fragment:"",outputs:null,material:null,blendWithPrevious:!1,clearColor:!1,clearDepth:!0}},function(){var t=new o({vertex:o.source("qtek.compositor.vertex"),fragment:this.fragment}),e=new s({shader:t});t.enableTexturesAll(),this.material=e},{setUniform:function(t,e){var n=this.material.uniforms[t];n&&(n.value=e)},getUniform:function(t){var e=this.material.uniforms[t];if(e)return e.value},attachOutput:function(t,e){this.outputs||(this.outputs={}),e=e||c.COLOR_ATTACHMENT0,this.outputs[e]=t},detachOutput:function(t){for(var e in this.outputs)this.outputs[e]===t&&(this.outputs[e]=null)},bind:function(t,e){if(this.outputs)for(var n in this.outputs){var r=this.outputs[n];r&&e.attach(r,n)}e&&e.bind(t)},unbind:function(t,e){e.unbind(t)},render:function(t,e){var n=t.gl;if(e){this.bind(t,e);var r=l.getExtension(n,"EXT_draw_buffers");if(r&&this.outputs){var i=[];for(var a in this.outputs)a=+a,a>=n.COLOR_ATTACHMENT0&&a<=n.COLOR_ATTACHMENT0+8&&i.push(a);r.drawBuffersEXT(i)}}this.trigger("beforerender",this,t);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;s instanceof Array&&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(t),this.trigger("afterrender",this,t),e&&this.unbind(t,e)},renderQuad:function(t){f.material=this.material,t.renderQueue([f],d)},dispose:function(t){this.material.dispose(t)}});t.exports=_},function(t,e,n){"use strict";function r(t,e){if(e.castShadow&&!t.castShadow)return!0}var i=n(18),a=n(12),o=n(9),s=i.extend(function(){return{material:null,autoUpdate:!0,opaqueQueue:[],transparentQueue:[],lights:[],viewBoundingBoxLastFrame:new o,_lightUniforms:{},_lightNumber:{},_opaqueObjectCount:0,_transparentObjectCount:0,_nodeRepository:{}}},function(){this._scene=this},{addToScene:function(t){t.name&&(this._nodeRepository[t.name]=t)},removeFromScene:function(t){t.name&&delete this._nodeRepository[t.name]},getNode:function(t){return this._nodeRepository[t]},cloneNode:function(t){var e=t.clone(),n={},r=function(i,a){i.skeleton&&(a.skeleton=i.skeleton.clone(t,e),a.joints=i.joints.slice()),i.material&&(n[i.material.__GUID__]={oldMat:i.material});for(var o=0;o0&&this._updateRenderQueue(r)}},_updateLightUniforms:function(){var t=this.lights;t.sort(r);var e=this._lightUniforms;for(var n in e)for(var i in e[n])e[n][i].value.length=0;for(var a=0;a0){var e=this.outputs[t];e.keepLastFrame?(this._prevOutputTextures[t]&&this._compositor.releaseTexture(this._prevOutputTextures[t]),this._prevOutputTextures[t]=this._outputTextures[t]):this._compositor.releaseTexture(this._outputTextures[t])}}});t.exports=i},function(t,e){"use strict";function n(t){var e=new XMLHttpRequest;e.open("get",t.url),e.responseType=t.responseType||"text",t.onprogress&&(e.onprogress=function(e){if(e.lengthComputable){var n=e.loaded/e.total;t.onprogress(n,e.loaded,e.total)}else t.onprogress(null)}),e.onload=function(n){t.onload&&t.onload(e.response)},t.onerror&&(e.onerror=t.onerror),e.send(null)}t.exports={get:n}},function(t,e,n){"use strict";var r=n(1),i=r.vec2,a=function(t,e){t=t||0,e=e||0,this._array=i.fromValues(t,e),this._dirty=!0};if(a.prototype={constructor:a,add:function(t){return i.add(this._array,this._array,t._array),this._dirty=!0,this},set:function(t,e){return this._array[0]=t,this._array[1]=e,this._dirty=!0,this},setArray:function(t){return this._array[0]=t[0],this._array[1]=t[1],this._dirty=!0,this},clone:function(){return new a(this.x,this.y)},copy:function(t){return i.copy(this._array,t._array),this._dirty=!0,this},cross:function(t,e){return i.cross(t._array,this._array,e._array),t._dirty=!0,this},dist:function(t){return i.dist(this._array,t._array)},distance:function(t){return i.distance(this._array,t._array)},div:function(t){return i.div(this._array,this._array,t._array),this._dirty=!0,this},divide:function(t){return i.divide(this._array,this._array,t._array),this._dirty=!0,this},dot:function(t){return i.dot(this._array,t._array)},len:function(){return i.len(this._array)},length:function(){return i.length(this._array)},lerp:function(t,e,n){return i.lerp(this._array,t._array,e._array,n),this._dirty=!0,this},min:function(t){return i.min(this._array,this._array,t._array),this._dirty=!0,this},max:function(t){return i.max(this._array,this._array,t._array),this._dirty=!0,this},mul:function(t){return i.mul(this._array,this._array,t._array),this._dirty=!0,this},multiply:function(t){return i.multiply(this._array,this._array,t._array),this._dirty=!0,this},negate:function(){return i.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return i.normalize(this._array,this._array),this._dirty=!0,this},random:function(t){return i.random(this._array,t),this._dirty=!0,this},scale:function(t){return i.scale(this._array,this._array,t),this._dirty=!0,this},scaleAndAdd:function(t,e){return i.scaleAndAdd(this._array,this._array,t._array,e),this._dirty=!0,this},sqrDist:function(t){return i.sqrDist(this._array,t._array)},squaredDistance:function(t){return i.squaredDistance(this._array,t._array)},sqrLen:function(){return i.sqrLen(this._array)},squaredLength:function(){return i.squaredLength(this._array)},sub:function(t){return i.sub(this._array,this._array,t._array),this._dirty=!0,this},subtract:function(t){return i.subtract(this._array,this._array,t._array),this._dirty=!0,this},transformMat2:function(t){return i.transformMat2(this._array,this._array,t._array),this._dirty=!0,this},transformMat2d:function(t){return i.transformMat2d(this._array,this._array,t._array),this._dirty=!0,this},transformMat3:function(t){return i.transformMat3(this._array,this._array,t._array),this._dirty=!0,this},transformMat4:function(t){return i.transformMat4(this._array,this._array,t._array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}},Object.defineProperty){var o=a.prototype;Object.defineProperty(o,"x",{get:function(){return this._array[0]},set:function(t){this._array[0]=t,this._dirty=!0}}),Object.defineProperty(o,"y",{get:function(){return this._array[1]},set:function(t){this._array[1]=t,this._dirty=!0}})}a.add=function(t,e,n){return i.add(t._array,e._array,n._array),t._dirty=!0,t},a.set=function(t,e,n){return i.set(t._array,e,n),t._dirty=!0,t},a.copy=function(t,e){return i.copy(t._array,e._array),t._dirty=!0,t},a.cross=function(t,e,n){return i.cross(t._array,e._array,n._array),t._dirty=!0,t},a.dist=function(t,e){return i.distance(t._array,e._array)},a.distance=a.dist,a.div=function(t,e,n){return i.divide(t._array,e._array,n._array),t._dirty=!0,t},a.divide=a.div,a.dot=function(t,e){return i.dot(t._array,e._array)},a.len=function(t){return i.length(t._array)},a.lerp=function(t,e,n,r){return i.lerp(t._array,e._array,n._array,r),t._dirty=!0,t},a.min=function(t,e,n){return i.min(t._array,e._array,n._array),t._dirty=!0,t},a.max=function(t,e,n){return i.max(t._array,e._array,n._array),t._dirty=!0,t},a.mul=function(t,e,n){return i.multiply(t._array,e._array,n._array),t._dirty=!0,t},a.multiply=a.mul,a.negate=function(t,e){return i.negate(t._array,e._array),t._dirty=!0,t},a.normalize=function(t,e){return i.normalize(t._array,e._array),t._dirty=!0,t},a.random=function(t,e){return i.random(t._array,e),t._dirty=!0,t},a.scale=function(t,e,n){return i.scale(t._array,e._array,n),t._dirty=!0,t},a.scaleAndAdd=function(t,e,n,r){return i.scaleAndAdd(t._array,e._array,n._array,r),t._dirty=!0,t},a.sqrDist=function(t,e){return i.sqrDist(t._array,e._array)},a.squaredDistance=a.sqrDist,a.sqrLen=function(t){return i.sqrLen(t._array)},a.squaredLength=a.sqrLen,a.sub=function(t,e,n){return i.subtract(t._array,e._array,n._array),t._dirty=!0,t},a.subtract=a.sub,a.transformMat2=function(t,e,n){return i.transformMat2(t._array,e._array,n._array),t._dirty=!0,t},a.transformMat2d=function(t,e,n){return i.transformMat2d(t._array,e._array,n._array),t._dirty=!0,t},a.transformMat3=function(t,e,n){return i.transformMat3(t._array,e._array,n._array),t._dirty=!0,t},a.transformMat4=function(t,e,n){return i.transformMat4(t._array,e._array,n._array),t._dirty=!0,t},t.exports=a},function(t,e,n){function r(){this._pool={}}function i(t,e,n){o[t]={vertex:e,fragment:n}}var a=n(5),o=(n(15),{});r.prototype.get=function(t,e){var n=[],r={},i={};"string"==typeof e?n=Array.prototype.slice.call(arguments,1):"[object Object]"==Object.prototype.toString.call(e)?(n=e.textures||[],r=e.vertexDefines||{},i=e.fragmentDefines||{}):e instanceof Array&&(n=e);var s=Object.keys(r),u=Object.keys(i);n.sort(),s.sort(),u.sort();var l=[t];l=l.concat(n);for(var c=0;c0},beforeRender:function(t){},afterRender:function(t,e){},getBoundingBox:function(t,e){return e=a.prototype.getBoundingBox.call(this,t,e),this.geometry&&this.geometry.boundingBox&&e.union(this.geometry.boundingBox),e},render:function(t,e){var e=e||this.material.shader,n=this.geometry,a=this.mode,h=n.vertexCount,f=n.isUseIndices(),d=s.getExtension(t,"OES_element_index_uint"),_=d&&h>65535,p=_?t.UNSIGNED_INT:t.UNSIGNED_SHORT,m=s.getExtension(t,"OES_vertex_array_object"),v=!n.dynamic,g=this._renderInfo;g.vertexCount=h,g.triangleCount=0,g.drawCallCount=0;var y=!1;if(i=t.__GLID__+"-"+n.__GUID__+"-"+e.__GUID__,i!==u?y=!0:(h>65535&&!d&&f||m&&v||n._cache.isDirty())&&(y=!0),u=i,y){var x=this._drawCache[i];if(!x){var T=n.getBufferChunks(t);if(!T)return;x=[];for(var E=0;Eh)){var f=Math.sqrt(h-c),d=u-f,_=u+f;return i||(i=new r),d<0?_<0?null:(a.scaleAndAdd(i._array,o,s,_),i):(a.scaleAndAdd(i._array,o,s,d),i)}}}(),intersectBoundingBox:function(t,e){var n,i,o,s,u,l,c=this.direction._array,h=this.origin._array,f=t.min._array,d=t.max._array,_=1/c[0],p=1/c[1],m=1/c[2];if(_>=0?(n=(f[0]-h[0])*_,i=(d[0]-h[0])*_):(i=(f[0]-h[0])*_,n=(d[0]-h[0])*_),p>=0?(o=(f[1]-h[1])*p,s=(d[1]-h[1])*p):(s=(f[1]-h[1])*p,o=(d[1]-h[1])*p),n>s||o>i)return null;if((o>n||n!==n)&&(n=o),(s=0?(u=(f[2]-h[2])*m,l=(d[2]-h[2])*m):(l=(f[2]-h[2])*m,u=(d[2]-h[2])*m),n>l||u>i)return null;if((u>n||n!==n)&&(n=u),(l=0?n:i;return e||(e=new r),a.scaleAndAdd(e._array,h,c,v),e},intersectTriangle:function(){var t=a.create(),e=a.create(),n=a.create(),i=a.create();return function(s,u,l,c,h,f){var d=this.direction._array,_=this.origin._array;s=s._array,u=u._array,l=l._array,a.sub(t,u,s),a.sub(e,l,s),a.cross(i,e,d);var p=a.dot(t,i);if(c){if(p>-o)return null}else if(p>-o&&p1)return null;a.cross(i,t,n);var v=a.dot(d,i)/p;if(v<0||v>1||m+v>1)return null;a.cross(i,t,e);var g=-a.dot(n,i)/p;return g<0?null:(h||(h=new r),f&&r.set(f,1-m-v,m,v),a.scaleAndAdd(h._array,_,d,g),h)}}(),applyTransform:function(t){r.add(this.direction,this.direction,this.origin),r.transformMat4(this.origin,this.origin,t),r.transformMat4(this.direction,this.direction,t),r.sub(this.direction,this.direction,this.origin),r.normalize(this.direction,this.direction)},copy:function(t){r.copy(this.origin,t.origin),r.copy(this.direction,t.direction)},clone:function(){var t=new s;return t.copy(this),t}},t.exports=s},function(t,e,n){var r=n(2),i=n(3),a=n(21),o=n(17),s=["px","nx","py","ny","pz","nz"],u=r.extend(function(){var t={position:new i,far:1e3,near:.1,texture:null,shadowMapPass:null},e=t._cameras={px:new a({fov:90}),nx:new a({fov:90}),py:new a({fov:90}),ny:new a({fov:90}),pz:new a({fov:90}),nz:new a({fov:90})};return e.px.lookAt(i.POSITIVE_X,i.NEGATIVE_Y),e.nx.lookAt(i.NEGATIVE_X,i.NEGATIVE_Y),e.py.lookAt(i.POSITIVE_Y,i.POSITIVE_Z),e.ny.lookAt(i.NEGATIVE_Y,i.NEGATIVE_Z),e.pz.lookAt(i.POSITIVE_Z,i.NEGATIVE_Y),e.nz.lookAt(i.NEGATIVE_Z,i.NEGATIVE_Y),t._frameBuffer=new o,t},{getCamera:function(t){return this._cameras[t]},render:function(t,e,n){var r=t.gl;n||e.update();for(var a=this.texture.width,o=2*Math.atan(a/(a-.5))/Math.PI*180,u=0;u<6;u++){var l=s[u],c=this._cameras[l];if(i.copy(c.position,this.position),c.far=this.far,c.near=this.near,c.fov=o,this.shadowMapPass){c.update();var h=e.getBoundingBox(function(t){return!t.invisible});h.applyTransform(c.viewMatrix),e.viewBoundingBoxLastFrame.copy(h),this.shadowMapPass.render(t,e,c,!0)}this._frameBuffer.attach(this.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+u),this._frameBuffer.bind(t),t.render(e,c,!0),this._frameBuffer.unbind(t)}},dispose:function(t){this._frameBuffer.dispose(t)}});t.exports=u},function(t,e,n){"use strict";var r=n(18),i=n(16),a=n(50),o=n(34),s=n(1),u=s.vec3,l=s.vec4,c=r.extend(function(){return{projectionMatrix:new i,invProjectionMatrix:new i,viewMatrix:new i,frustum:new a}},function(){this.update(!0)},{update:function(t){r.prototype.update.call(this,t),i.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),i.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(t){i.copy(this.viewMatrix,t),i.invert(this.worldTransform,t),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(t){i.copy(this.projectionMatrix,t),i.invert(this.invProjectionMatrix,t),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:function(){var t=l.create();return function(e,n){var r=void 0!==n?n:new o,i=e._array[0],a=e._array[1];return l.set(t,i,a,-1,1),l.transformMat4(t,t,this.invProjectionMatrix._array),l.transformMat4(t,t,this.worldTransform._array),u.scale(r.origin._array,t,1/t[3]),l.set(t,i,a,1,1),l.transformMat4(t,t,this.invProjectionMatrix._array),l.transformMat4(t,t,this.worldTransform._array),u.scale(t,t,1/t[3]),u.sub(r.direction._array,t,r.origin._array),u.normalize(r.direction._array,r.direction._array),r.direction._dirty=!0,r.origin._dirty=!0,r}}()});t.exports=c},function(t,e,n){"use strict";var r=n(2),i=n(14),a=n(4),o=(n(11),n(9)),s=n(16),u=(n(27),n(6)),l=n(26),c=n(5);c["import"](n(56)),c["import"](n(57));var h=n(1),f=h.mat4,d=h.vec3,_=f.create,p=0,m={},v=r.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 t=this.canvas;try{var e={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!this.gl)throw new Error;null==this.gl.__GLID__&&(this.gl.__GLID__=p++,i.initialize(this.gl)),this.resize()}catch(n){throw"Error creating WebGL Context "+n}},{resize:function(t,e){var n=this.canvas,r=this.devicePixelRatio;null!=t?(n.style.width=t+"px",n.style.height=e+"px",n.width=t*r,n.height=e*r,this._width=t,this._height=e):(this._width=n.width/r,this._height=n.height/r),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var t=this.viewport;return t.width/t.height},setDevicePixelRatio:function(t){this.devicePixelRatio=t,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getExtension:function(t){return i.getExtension(this.gl,t)},setViewport:function(t,e,n,r,i){if("object"==typeof t){var a=t;t=a.x,e=a.y,n=a.width,r=a.height,i=a.devicePixelRatio}i=i||this.devicePixelRatio,this.gl.viewport(t*i,e*i,n*i,r*i),this.viewport={x:t,y:e,width:n,height:r,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 t=this._clearStack.pop();this.clearColor=t.clearColor,this.clearBit=t.clearBit}},bindSceneRendering:function(t){this._sceneRendering=t},beforeRenderObject:function(){},afterRenderObject:function(){},render:function(t,e,n,r){var i=this.gl;this._sceneRendering=t;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)}n||t.update(!1),e.getScene()||e.update(!0);for(var l=t.opaqueQueue,c=t.transparentQueue,h=t.material,p=0;p0)for(var v=_(),g=d.create(),p=0;p0&&t.min._array[2]<0&&(t.max._array[2]=-1e-20),t.applyProjection(e);var u=t.min._array,l=t.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(t){this.disposeNode(t,!0,!0),t.dispose()},disposeNode:function(t,e,n){var r={},i=this.gl;t.getParent()&&t.getParent().remove(t),t.traverse(function(t){t.geometry&&e&&t.geometry.dispose(i),t.material&&(r[t.material.__GUID__]=t.material),t.dispose&&t.dispose(i)});for(var a in r){var o=r[a];o.dispose(i,n)}},disposeShader:function(t){t.dispose(this.gl)},disposeGeometry:function(t){t.dispose(this.gl)},disposeTexture:function(t){t.dispose(this.gl)},disposeFrameBuffer:function(t){t.dispose(this.gl)},dispose:function(){i.dispose(this.gl)},screenToNDC:function(t,e,n){n||(n=new l),e=this._height-e;var r=this.viewport,i=n._array;return i[0]=(t-r.x)/r.width,i[0]=2*i[0]-1,i[1]=(e-r.y)/r.height,i[1]=2*i[1]-1,n}});v.opaqueSortFunc=v.prototype.opaqueSortFunc=function(t,e){return t.renderOrder===e.renderOrder?t.material.shader===e.material.shader?t.material===e.material?t.geometry.__GUID__-e.geometry.__GUID__:t.material.__GUID__-e.material.__GUID__:t.material.shader.__GUID__-e.material.shader.__GUID__:t.renderOrder-e.renderOrder},v.transparentSortFunc=v.prototype.transparentSortFunc=function(t,e){return t.renderOrder===e.renderOrder?t.__depth===e.__depth?t.material.shader===e.material.shader?t.material===e.material?t.geometry.__GUID__-e.geometry.__GUID__:t.material.__GUID__-e.material.__GUID__:t.material.shader.__GUID__-e.material.shader.__GUID__:t.__depth-e.__depth:t.renderOrder-e.renderOrder};var g={WORLD:_(),VIEW:_(),PROJECTION:_(),WORLDVIEW:_(),VIEWPROJECTION:_(),WORLDVIEWPROJECTION:_(),WORLDINVERSE:_(),VIEWINVERSE:_(),PROJECTIONINVERSE:_(),WORLDVIEWINVERSE:_(),VIEWPROJECTIONINVERSE:_(),WORLDVIEWPROJECTIONINVERSE:_(),WORLDTRANSPOSE:_(),VIEWTRANSPOSE:_(),PROJECTIONTRANSPOSE:_(),WORLDVIEWTRANSPOSE:_(),VIEWPROJECTIONTRANSPOSE:_(),WORLDVIEWPROJECTIONTRANSPOSE:_(),WORLDINVERSETRANSPOSE:_(),VIEWINVERSETRANSPOSE:_(),PROJECTIONINVERSETRANSPOSE:_(),WORLDVIEWINVERSETRANSPOSE:_(),VIEWPROJECTIONINVERSETRANSPOSE:_(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:_()};v.COLOR_BUFFER_BIT=a.COLOR_BUFFER_BIT,v.DEPTH_BUFFER_BIT=a.DEPTH_BUFFER_BIT,v.STENCIL_BUFFER_BIT=a.STENCIL_BUFFER_BIT,t.exports=v},function(t,e,n){"use strict";var r=n(2),i=n(30),a=n(1),o=a.quat,s=a.vec3,u=a.mat4,l=r.extend(function(){return{relativeRootNode:null,name:"",joints:[],_clips:[],_invBindPoseMatricesArray:null,_jointMatricesSubArrays:[],_skinMatricesArray:null,_skinMatricesSubArrays:[],_subSkinMatricesArray:{}}},{addClip:function(t,e){for(var n=0;n0&&this._clips.splice(e,1)},removeClipsAll:function(){this._clips=[]},getClip:function(t){if(this._clips[t])return this._clips[t].clip},getClipNumber:function(){return this._clips.length},updateJointMatrices:function(){var t=u.create();return function(){this._invBindPoseMatricesArray=new Float32Array(16*this.joints.length),this._skinMatricesArray=new Float32Array(16*this.joints.length);for(var e=0;e1e-6?(o=Math.acos(s),u=Math.sin(o),l=Math.sin((1-r)*o)/u,c=Math.sin(r*o)/u):(l=1-r,c=r),t[0]=l*h+c*p,t[1]=l*f+c*m,t[2]=l*d+c*v,t[3]=l*_+c*g,t}var a=n(20),o=n(40),s=n(1),u=s.quat,l=s.vec3,c=function(t){t=t||{},a.call(this,t),this.position=l.create(),this.rotation=u.create(),this.scale=l.fromValues(1,1,1),this.channels={time:null,position:null,rotation:null,scale:null},this._cacheKey=0,this._cacheTime=0};c.prototype=Object.create(a.prototype),c.prototype.constructor=c,c.prototype.step=function(t,e,n){var r=a.prototype.step.call(this,t,e,!0);return"finish"!==r&&this.setTime(this.getElapsedTime()),n||"paused"===r||this.fire("frame"),r},c.prototype.setTime=function(t){if(this.channels.time){var e=this.channels,n=e.time.length,a=-1;if(1===n)return e.rotation&&u.copy(this.rotation,e.rotation),e.position&&l.copy(this.position,e.position),void(e.scale&&l.copy(this.scale,e.scale));if(t<=e.time[0])t=e.time[0],a=0;else if(t>=e.time[n-1])t=e.time[n-1],a=n-2;else if(t=0;s--)if(e.time[s-1]<=t&&e.time[s]>t){a=s-1;break}}else for(var s=this._cacheKey;st){a=s;break}if(a>-1){this._cacheKey=a,this._cacheTime=t;var c=a,h=a+1,f=e.time[c],d=e.time[h],_=(t-f)/(d-f);e.rotation&&i(this.rotation,e.rotation,e.rotation,_,4*c,4*h),e.position&&r(this.position,e.position,e.position,_,3*c,3*h),e.scale&&r(this.scale,e.scale,e.scale,_,3*c,3*h)}a==n-2&&(this._cacheKey=0,this._cacheTime=0)}},c.prototype.getSubClip=function(t,e){var n=new c({name:this.name}),r=this.channels.time[0];t=Math.min(Math.max(t,r),this.life),e=Math.min(Math.max(e,r),this.life);var i=this._findRange(t),a=this._findRange(e),o=a[0]-i[0]+1;0===i[1]&&0===a[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(t);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;st&&(r=i);var a=0;if(r>=0)var o=e.time[r],s=e.time[r+1],a=(t-o)/(s-o);return[r,a]},c.prototype.blend1D=o.prototype.blend1D,c.prototype.blend2D=o.prototype.blend2D,c.prototype.additiveBlend=o.prototype.additiveBlend,c.prototype.subtractiveBlend=o.prototype.subtractiveBlend,c.prototype.clone=function(){var t=a.prototype.clone.call(this);return t.channels={time:this.channels.time||null,position:this.channels.position||null,rotation:this.channels.rotation||null,scale:this.channels.scale||null},l.copy(t.position,this.position),u.copy(t.rotation,this.rotation),l.copy(t.scale,this.scale),t},t.exports=c},function(t,e,n){"use strict";function r(t,e){return t.time-e.time}var i=n(20),a=n(1),o=a.quat,s=a.vec3,u=function(t){t=t||{},i.call(this,t),this.keyFrames=[],t.keyFrames&&this.addKeyFrames(t.keyFrames),this.position=s.create(),this.rotation=o.create(),this.scale=s.fromValues(1,1,1),this._cacheKey=0,this._cacheTime=0};u.prototype=Object.create(i.prototype),u.prototype.constructor=u,u.prototype.step=function(t,e,n){var r=i.prototype.step.call(this,t,e,!0);return"finish"!==r&&this.setTime(this.getElapsedTime()),n||"paused"===r||this.fire("frame"),r},u.prototype.setTime=function(t){this._interpolateField(t,"position"),this._interpolateField(t,"rotation"),this._interpolateField(t,"scale")},u.prototype.addKeyFrame=function(t){for(var e=0;e=t.time)return this.keyFrames.splice(e,0,t),e}this.life=t.time,this.keyFrames.push(t)},u.prototype.addKeyFrames=function(t){for(var e=0;ei[i.length-1].time)){if(t=a-1?a-1:this._cacheKey+1,l=u;l>=0;l--)if(i[l].time<=t&&i[l][e])n=i[l],this._cacheKey=l,this._cacheTime=t;else if(i[l][e]){r=i[l];break}}else for(var l=this._cacheKey;l65535?Uint32Array:Uint16Array,p=this.indices=new _(e*t*6),m=this.radius,v=this.phiStart,g=this.phiLength,y=this.thetaStart,x=this.thetaLength,m=this.radius,T=[],E=[],b=0,S=1/m;for(d=0;d<=t;d++)for(f=0;f<=e;f++)c=f/e,h=d/t,s=-m*Math.cos(v+c*g)*Math.sin(y+h*x),u=m*Math.cos(y+h*x),l=m*Math.sin(v+c*g)*Math.sin(y+h*x),T[0]=s,T[1]=u,T[2]=l,E[0]=c,E[1]=h,n.set(b,T),r.set(b,E),T[0]*=S,T[1]*=S,T[2]*=S,i.set(b,T),b++;var A,N,w,M,C=e+1,R=0;for(d=0;dthis.distance,i=1;i<8;i++)if(a.dot(e[i]._array,n)>this.distance!=r)return!0},intersectLine:function(){var t=a.create();return function(e,n,i){var o=this.distanceToPoint(e),s=this.distanceToPoint(n);if(o>0&&s>0||o<0&&s<0)return null;var u=this.normal._array,l=this.distance,c=e._array;a.sub(t,n._array,e._array),a.normalize(t,t);var h=a.dot(u,t);if(0===h)return null;i||(i=new r);var f=(a.dot(u,c)-l)/h;return a.scaleAndAdd(i._array,c,t,-f),i._dirty=!0,i}}(),applyTransform:function(){var t=o.create(),e=s.create(),n=s.create();return n[3]=1,function(r){r=r._array,a.scale(n,this.normal._array,this.distance),s.transformMat4(n,n,r),this.distance=a.dot(n,this.normal._array),o.invert(t,r),o.transpose(t,t),e[3]=0,a.copy(e,this.normal._array),s.transformMat4(e,e,t),a.copy(this.normal._array,e)}}(),copy:function(t){a.copy(this.normal._array,t.normal._array),this.normal._dirty=!0,this.distance=t.distance},clone:function(){var t=new u;return t.copy(this),t}},t.exports=u},function(t,e){var n={};n.isPowerOfTwo=function(t){return 0===(t&t-1)},n.nextPowerOfTwo=function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t},n.nearestPowerOfTwo=function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))},t.exports=n},function(t,e,n){var r=n(13),i=n(71),a=n(5),o=n(6);a["import"](n(79));var s=r.extend(function(){var t=new a({vertex:a.source("qtek.skybox.vertex"),fragment:a.source("qtek.skybox.fragment")}),e=new o({shader:t,depthMask:!1});return{scene:null,geometry:new i,material:e,environmentMap:null,culling:!1}},function(){var t=this.scene;t&&this.attachScene(t),this.environmentMap&&this.setEnvironmentMap(this.environmentMap)},{attachScene:function(t){this.scene&&this.detachScene(),this.scene=t,t.on("beforerender",this._beforeRenderScene,this)},detachScene:function(){this.scene&&this.scene.off("beforerender",this._beforeRenderScene),this.scene=null},dispose:function(t){this.detachScene(),this.geometry.dispose(t),this.material.dispose(t)},setEnvironmentMap:function(t){this.material.set("environmentMap",t)},getEnvironmentMap:function(){return this.material.get("environmentMap")},_beforeRenderScene:function(t,e,n){this.renderSkybox(t,n)},renderSkybox:function(t,e){this.position.copy(e.getWorldPosition()),this.update(),t.gl.disable(t.gl.BLEND),t.renderQueue([this],e)}});t.exports=s},function(t,e,n){var r=n(13),i=n(46),a=n(5),o=n(6);a["import"](n(78));var s=r.extend(function(){var t=new a({vertex:a.source("qtek.basic.vertex"),fragment:a.source("qtek.basic.fragment")});t.enableTexture("diffuseMap");var e=new o({shader:t,depthMask:!1});return{scene:null,geometry:new i({widthSegments:30,heightSegments:30}),material:e,environmentMap:null,culling:!1}},function(){var t=this.scene;t&&this.attachScene(t),this.environmentMap&&this.setEnvironmentMap(this.environmentMap)},{attachScene:function(t){this.scene&&this.detachScene(),this.scene=t,t.on("beforerender",this._beforeRenderScene,this)},detachScene:function(){this.scene&&this.scene.off("beforerender",this._beforeRenderScene),this.scene=null},_beforeRenderScene:function(t,e,n){this.position.copy(n.getWorldPosition()),this.update(),t.renderQueue([this],n)},setEnvironmentMap:function(t){this.material.set("diffuseMap",t)},getEnvironmentMap:function(){return this.material.get("diffuseMap")},dispose:function(t){this.detachScene(),this.geometry.dispose(t),this.material.dispose(t)}});t.exports=s},function(t,e,n){var r=n(27),i=n(5);i["import"](n(56)),i["import"](n(81)),i["import"](n(78)),i["import"](n(148)),i["import"](n(80)),i["import"](n(150)),i["import"](n(79)),i["import"](n(57)),r.template("qtek.basic",i.source("qtek.basic.vertex"),i.source("qtek.basic.fragment")),r.template("qtek.lambert",i.source("qtek.lambert.vertex"),i.source("qtek.lambert.fragment")),r.template("qtek.wireframe",i.source("qtek.wireframe.vertex"),i.source("qtek.wireframe.fragment")),r.template("qtek.skybox",i.source("qtek.skybox.vertex"),i.source("qtek.skybox.fragment")),r.template("qtek.prez",i.source("qtek.prez.vertex"),i.source("qtek.prez.fragment")),r.template("qtek.standard",i.source("qtek.standard.vertex"),i.source("qtek.standard.fragment")),i["import"](n(123)),i["import"](n(121)),i["import"](n(130)),i["import"](n(131)),i["import"](n(135)),i["import"](n(132)),i["import"](n(122)),i["import"](n(125)),i["import"](n(133)),i["import"](n(128)),i["import"](n(124)),i["import"](n(129)),i["import"](n(120)),i["import"](n(126)),i["import"](n(127))},function(t,e,n){var r="uniform vec3 ",i="uniform float ",a="@export qtek.header.",o="@end",s=":unconfigurable;";t.exports=[a+"directional_light",r+"directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]"+s,r+"directionalLightColor[DIRECTIONAL_LIGHT_COUNT]"+s,o,a+"ambient_light",r+"ambientLightColor[AMBIENT_LIGHT_COUNT]"+s,o,a+"ambient_sh_light",r+"ambientSHLightColor[AMBIENT_SH_LIGHT_COUNT]"+s,r+"ambientSHLightCoefficients[AMBIENT_SH_LIGHT_COUNT * 9]"+s,n(147),o,a+"ambient_cubemap_light",r+"ambientCubemapLightColor[AMBIENT_CUBEMAP_LIGHT_COUNT]"+s,"uniform samplerCube ambientCubemapLightCubemap[AMBIENT_CUBEMAP_LIGHT_COUNT]"+s,"uniform sampler2D ambientCubemapLightBRDFLookup[AMBIENT_CUBEMAP_LIGHT_COUNT]"+s,o,a+"point_light",r+"pointLightPosition[POINT_LIGHT_COUNT]"+s,i+"pointLightRange[POINT_LIGHT_COUNT]"+s,r+"pointLightColor[POINT_LIGHT_COUNT]"+s,o,a+"spot_light",r+"spotLightPosition[SPOT_LIGHT_COUNT]"+s,r+"spotLightDirection[SPOT_LIGHT_COUNT]"+s,i+"spotLightRange[SPOT_LIGHT_COUNT]"+s,i+"spotLightUmbraAngleCosine[SPOT_LIGHT_COUNT]"+s,i+"spotLightPenumbraAngleCosine[SPOT_LIGHT_COUNT]"+s,i+"spotLightFalloffFactor[SPOT_LIGHT_COUNT]"+s,r+"spotLightColor[SPOT_LIGHT_COUNT]"+s,o].join("\n")},function(t,e){t.exports="@export qtek.prez.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\n\n@import qtek.chunk.skinning_header\n\nvoid main()\n{\n\n vec3 skinnedPosition = position;\n\n#ifdef SKINNING\n\n @import qtek.chunk.skin_matrix\n\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n}\n\n@end\n\n\n@export qtek.prez.fragment\n\nvoid main()\n{\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n\n@end"},function(t,e,n){"use strict";var r=n(8),i=n(19),a=n(25),o=n(35),s=n(54),u=n(23),l=n(83),c=n(85),h={loadTexture:function(t,e,n,a){var o;if("function"==typeof e?(n=e,a=n,e={}):e=e||{},"string"==typeof t){if(t.match(/.hdr$/)||"hdr"===e.fileType)return o=new r({width:0,height:0}),h._fetchTexture(t,function(t){c.parseRGBE(t,o,e.exposure),o.dirty(),n&&n(o)},a),o;t.match(/.dds$/)||"dds"===e.fileType?(o=new r({width:0,height:0}),h._fetchTexture(t,function(t){l.parse(t,o),o.dirty(),n&&n(o)},a)):(o=new r,o.load(t),o.success(n),o.error(a))}else if("object"==typeof t&&"undefined"!=typeof t.px){var o=new i;o.load(t),o.success(n),o.error(a)}return o},loadPanorama:function(t,e,n,r,i,a){var o=this;"function"==typeof r?(i=r,a=i,r={}):r=r||{},h.loadTexture(e,r,function(e){e.flipY=r.flipY||!1,o.panoramaToCubeMap(t,e,n,r),e.dispose(t.gl),i&&i(n)},a)},panoramaToCubeMap:function(t,e,n,r){var i=new o,a=new s({scene:new u});return a.material.set("diffuseMap",e),r=r||{},r.encodeRGBM&&a.material.shader.define("fragment","RGBM_ENCODE"),i.texture=n,i.render(t,a.scene),i.texture=null,i.dispose(t),n},_fetchTexture:function(t,e,n){a.get({url:t,responseType:"arraybuffer",onload:e,onerror:n})},createChessboard:function(t,e,n,i){t=t||512,e=e||64,n=n||"black",i=i||"white";var a=Math.ceil(t/e),o=document.createElement("canvas");o.width=t,o.height=t;var s=o.getContext("2d");s.fillStyle=i,s.fillRect(0,0,t,t),s.fillStyle=n;for(var u=0;ui;if(a)t.length=i;else for(var o=r;o=0&&!(E[N]<=e);N--);N=Math.min(N,v-2)}else{for(N=O;Ne);N++);N=Math.min(N-1,v-2)}O=N,k=e;var n=E[N+1]-E[N];0!==n&&(R=(e-E[N])/n,m?(P=b[N],L=b[0===N?N:N-1],I=b[N>v-2?v-1:N+1],D=b[N>v-3?v-1:N+2],u?_(t,i,u(d(t,i),L,P,I,D,R)):y?l(L,P,I,D,R,R*R,R*R*R,d(t,i),x):_(t,i,c(L,P,I,D,R,R*R,R*R*R))):u?_(t,i,u(d(t,i),b[N],b[N+1],R)):y?o(b[N],b[N+1],R,d(t,i),x):_(t,i,a(b[N],b[N+1],R)))},B=new p({target:t._target,life:T,loop:t._loop,delay:t._delay,onframe:F,onfinish:n});return e&&"spline"!==e&&B.setEasing(e),B}}}function _(t,e,n,a,o){this._tracks={},this._target=t,this._loop=e||!1,this._getter=n||r,this._setter=a||i,this._interpolater=o||null,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]}var p=n(20),m=Array.prototype.slice;_.prototype={constructor:_,when:function(t,e){for(var n in e)this._tracks[n]||(this._tracks[n]=[],0!==t&&this._tracks[n].push({time:0,value:u(this._getter(this._target,n))})),this._tracks[n].push({time:parseInt(t),value:e[n]});return this},during:function(t){return this._onframeList.push(t),this},_doneCallback:function(){this._tracks={},this._clipList.length=0;for(var t=this._doneList,e=t.length,n=0;n0)for(var e=0;e0){var e=this.outputs[t];e.keepLastFrame?(this._prevOutputTextures[t]&&this._compositor.releaseTexture(this._prevOutputTextures[t]),this._prevOutputTextures[t]=this._outputTextures[t]):this._compositor.releaseTexture(this._outputTextures[t])}}});t.exports=a},function(t,e,n){"use strict";var r=n(2),i=n(24),a=r.extend(function(){return{nodes:[]}},{dirty:function(){this._dirty=!0},addNode:function(t){this.nodes.indexOf(t)>=0||(this.nodes.push(t),this._dirty=!0)},removeNode:function(t){"string"==typeof t&&(t=this.getNodeByName(t));var e=this.nodes.indexOf(t);e>=0&&(this.nodes.splice(e,1),this._dirty=!0)},getNodeByName:function(t){for(var e=0;e=e.COLOR_ATTACHMENT0&&c<=e.COLOR_ATTACHMENT0+8&&f.push(c);h.drawBuffersEXT(f)}t.saveClear(),t.clearBit=a.DEPTH_BUFFER_BIT|a.COLOR_BUFFER_BIT,n=t.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),t.restoreClear(),r.unbind(t)}else n=t.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",n),this._rendering=!1,this._rendered=!0}});t.exports=s},function(t,e,n){"use strict";var r=n(24),i=r.extend(function(){return{texture:null,outputs:{color:{}}}},function(){},{getOutput:function(t,e){return this.texture},beforeFrame:function(){},afterFrame:function(){}});t.exports=i},function(t,e){"use strict";function n(t,e,n){"object"==typeof e&&(n=e,e=null);var a,o=this;if(!(t instanceof Function)){a=[];for(var s in t)t.hasOwnProperty(s)&&a.push(s)}var u=function(e){if(o.apply(this,arguments),t instanceof Function?r(this,t.call(this,e)):i(this,t,a),this.constructor===u)for(var n=u.__initializers__,s=0;s0&&(r.shader.define("vertex","SKINNING"),r.shader.define("vertex","JOINT_COUNT",t),i.shader.define("vertex","SKINNING"),i.shader.define("vertex","JOINT_COUNT",t)),n={material1:r,material2:i},e[t]=n}return n.used=!0,n},_resetGBufferMaterials:function(){for(var t in this._gBufferMaterials)this._gBufferMaterials[t].used=!1},_cleanGBufferMaterials:function(t){for(var e in this._gBufferMaterials){var n=this._gBufferMaterials[e];n.used||(n.material1.dispose(t),n.material2.dispose(t))}},_replaceGBufferMat:function(t,e){for(var n=0;n1&&a&&a.length>1){var s=n(a)/n(o);!isFinite(s)&&(s=1),e.pinchScale=s;var u=r(a);return e.pinchX=u[0],e.pinchY=u[1],{type:"pinch",target:t[0].target,event:e}}}}};t.exports=i},function(t,e){t.exports="@export qtek.basic.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position : POSITION;\n\nattribute vec3 barycentric;\n\n@import qtek.chunk.skinning_header\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Barycentric;\n\nvoid main()\n{\n vec3 skinnedPosition = position;\n\n#ifdef SKINNING\n @import qtek.chunk.skin_matrix\n\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_Barycentric = barycentric;\n\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n}\n\n@end\n\n\n\n\n@export qtek.basic.fragment\n\n\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\n#ifdef ALPHA_TEST\nuniform float alphaCutoff: 0.9;\n#endif\n\nuniform float lineWidth : 0.0;\nuniform vec3 lineColor : [0.0, 0.0, 0.0];\nvarying vec3 v_Barycentric;\n\n@import qtek.util.edge_factor\n\n@import qtek.util.rgbm\n\n@import qtek.util.srgb\n\nvoid main()\n{\n\n#ifdef RENDER_TEXCOORD\n gl_FragColor = vec4(v_Texcoord, 1.0, 1.0);\n return;\n#endif\n\n gl_FragColor = vec4(color, alpha);\n\n#ifdef DIFFUSEMAP_ENABLED\n vec4 tex = decodeHDR(texture2D(diffuseMap, v_Texcoord));\n\n#ifdef SRGB_DECODE\n tex = sRGBToLinear(tex);\n#endif\n\n#if defined(DIFFUSEMAP_ALPHA_ALPHA)\n gl_FragColor.a = tex.a;\n#endif\n\n gl_FragColor.rgb *= tex.rgb;\n#endif\n\n gl_FragColor.rgb += emission;\n if( lineWidth > 0.01)\n {\n gl_FragColor.rgb = gl_FragColor.rgb * mix(lineColor, vec3(1.0), edgeFactor(lineWidth));\n }\n\n#ifdef GAMMA_ENCODE\n gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(1 / 2.2));\n#endif\n\n#ifdef ALPHA_TEST\n if (gl_FragColor.a < alphaCutoff) {\n discard;\n }\n#endif\n\n gl_FragColor = encodeHDR(gl_FragColor);\n\n}\n\n@end"},function(t,e){t.exports="@export qtek.skybox.vertex\n\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\n\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n@export qtek.skybox.fragment\n\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform float lod: 0.0;\n\nvarying vec3 v_WorldPosition;\n\n@import qtek.util.rgbm\n\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 viewDirection = normalize(v_WorldPosition - eyePos);\n\n vec3 tex = decodeHDR(textureCubeLodEXT(environmentMap, viewDirection, lod)).rgb;\n\n#ifdef SRGB_DECODE\n tex.rgb = pow(tex.rgb, vec3(2.2));\n#endif\n\n gl_FragColor = encodeHDR(vec4(tex, 1.0));\n}\n@end"},function(t,e){t.exports="\n\n@export qtek.standard.vertex\n\n#define SHADER_NAME standard\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#if defined(AOMAP_ENABLED)\nattribute vec2 texcoord2 : TEXCOORD_1;\n#endif\n\nattribute vec3 normal : NORMAL;\nattribute vec4 tangent : TANGENT;\n\n#ifdef VERTEX_COLOR\nattribute vec4 color : COLOR;\n#endif\n\nattribute vec3 barycentric;\n\n@import qtek.chunk.skinning_header\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\nvarying vec3 v_Barycentric;\n\n#ifdef NORMALMAP_ENABLED\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n#if defined(AOMAP_ENABLED)\nvarying vec2 v_Texcoord2;\n#endif\n\nvoid main()\n{\n\n vec3 skinnedPosition = position;\n vec3 skinnedNormal = normal;\n vec3 skinnedTangent = tangent.xyz;\n#ifdef SKINNING\n\n @import qtek.chunk.skin_matrix\n\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n skinnedNormal = (skinMatrixWS * vec4(normal, 0.0)).xyz;\n skinnedTangent = (skinMatrixWS * vec4(tangent.xyz, 0.0)).xyz;\n#endif\n\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_WorldPosition = (world * vec4(skinnedPosition, 1.0)).xyz;\n v_Barycentric = barycentric;\n\n v_Normal = normalize((worldInverseTranspose * vec4(skinnedNormal, 0.0)).xyz);\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(skinnedTangent, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = color;\n#endif\n\n#if defined(AOMAP_ENABLED)\n v_Texcoord2 = texcoord2;\n#endif\n}\n\n@end\n\n\n@export qtek.standard.fragment\n\n#define PI 3.14159265358979\n\n#define GLOSS_CHANEL 0\n#define ROUGHNESS_CHANNEL 0\n#define METALNESS_CHANNEL 1\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n#ifdef NORMALMAP_ENABLED\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\nuniform sampler2D normalMap;\n#endif\n\n#ifdef DIFFUSEMAP_ENABLED\nuniform sampler2D diffuseMap;\n#endif\n\n#ifdef SPECULARMAP_ENABLED\nuniform sampler2D specularMap;\n#endif\n\n#ifdef USE_ROUGHNESS\nuniform float roughness : 0.5;\n #ifdef ROUGHNESSMAP_ENABLED\nuniform sampler2D roughnessMap;\n #endif\n#else\nuniform float glossiness: 0.5;\n #ifdef GLOSSMAP_ENABLED\nuniform sampler2D glossMap;\n #endif\n#endif\n\n#ifdef METALNESSMAP_ENABLED\nuniform sampler2D metalnessMap;\n#endif\n\n#ifdef ENVIRONMENTMAP_ENABLED\nuniform samplerCube environmentMap;\n\n #ifdef PARALLAX_CORRECTED\nuniform vec3 environmentBoxMin;\nuniform vec3 environmentBoxMax;\n #endif\n\n#endif\n\n#ifdef BRDFLOOKUP_ENABLED\nuniform sampler2D brdfLookup;\n#endif\n\n#ifdef EMISSIVEMAP_ENABLED\nuniform sampler2D emissiveMap;\n#endif\n\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n\n#ifdef AOMAP_ENABLED\nuniform sampler2D aoMap;\nuniform float aoIntensity;\nvarying vec2 v_Texcoord2;\n#endif\n\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform float alpha : 1.0;\n\n#ifdef ALPHA_TEST\nuniform float alphaCutoff: 0.9;\n#endif\n\n#ifdef USE_METALNESS\nuniform float metalness : 0.0;\n#else\nuniform vec3 specularColor : [0.1, 0.1, 0.1];\n#endif\n\nuniform vec3 emission : [0.0, 0.0, 0.0];\n\nuniform float emissionIntensity: 1;\n\nuniform float lineWidth : 0.0;\nuniform vec3 lineColor : [0.0, 0.0, 0.0];\nvarying vec3 v_Barycentric;\n\n#ifdef ENVIRONMENTMAP_PREFILTER\nuniform float maxMipmapLevel: 5;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import qtek.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import qtek.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import qtek.header.ambient_cubemap_light\n#endif\n\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\n@import qtek.util.calculate_attenuation\n\n@import qtek.util.edge_factor\n\n@import qtek.util.rgbm\n\n@import qtek.util.srgb\n\n@import qtek.plugin.compute_shadow_map\n\n@import qtek.util.parallax_correct\n\n\nfloat G_Smith(float g, float ndv, float ndl)\n{\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nfloat D_GGX(float g, 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 / (PI * tmp * tmp);\n}\n\n\nvoid main()\n{\n vec4 albedoColor = vec4(color, alpha);\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n#ifdef DIFFUSEMAP_ENABLED\n vec4 texel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n #endif\n albedoColor.rgb *= texel.rgb;\n #ifdef DIFFUSEMAP_ALPHA_ALPHA\n albedoColor.a *= texel.a;\n #endif\n\n#endif\n\n\n#ifdef USE_METALNESS\n float m = metalness;\n\n #ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_Texcoord)[METALNESS_CHANNEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n #endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 spec = mix(vec3(0.04), baseColor, m);\n#else\n vec3 spec = specularColor;\n#endif\n\n#ifdef USE_ROUGHNESS\n float g = 1.0 - roughness;\n #ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_Texcoord)[ROUGHNESS_CHANNEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n #endif\n#else\n float g = glossiness;\n #ifdef GLOSSMAP_ENABLED\n float g2 = texture2D(glossMap, v_Texcoord)[GLOSS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n #endif\n#endif\n\n#ifdef SPECULARMAP_ENABLED\n spec *= texture2D(specularMap, v_Texcoord).rgb;\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n#ifdef NORMALMAP_ENABLED\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#endif\n\n vec3 diffuseTerm = vec3(0.0, 0.0, 0.0);\n vec3 specularTerm = vec3(0.0, 0.0, 0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, spec);\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_];\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N) * ambientSHLightColor[_idx_];\n }}\n#endif\n\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\n vec3 lightPosition = pointLightPosition[_idx_];\n vec3 lc = pointLightColor[_idx_];\n float range = pointLightRange[_idx_];\n\n vec3 L = lightPosition - v_WorldPosition;\n\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\n float shadowContrib = 1.0;\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\n if(shadowEnabled)\n {\n shadowContrib = shadowContribsPoint[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * attenuation * shadowContrib;\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n\n vec3 L = -normalize(directionalLightDirection[_idx_]);\n vec3 lc = directionalLightColor[_idx_];\n\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\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if(shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n#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\n vec3 L = lightPosition - v_WorldPosition;\n float dist = length(L);\n float attenuation = lightAttenuation(dist, range);\n\n L /= dist;\n float c = dot(spotLightDirection, L);\n\n float falloff;\n falloff = clamp((c - a) /( b - a), 0.0, 1.0);\n falloff = pow(falloff, falloffFactor);\n\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\n float shadowContrib = 1.0;\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsSpot[i];\n }\n#endif\n\n vec3 li = lc * attenuation * (1.0 - falloff) * shadowContrib * ndl;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }\n#endif\n\n vec4 outColor = albedoColor;\n outColor.rgb *= diffuseTerm;\n\n outColor.rgb += specularTerm;\n\n\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\n#ifdef ENVIRONMENTMAP_ENABLED\n\n vec3 envWeight = g * fresnelTerm;\n vec3 L = reflect(-V, N);\n\n #ifdef PARALLAX_CORRECTED\n L = parallaxCorrect(L, v_WorldPosition, environmentBoxMin, environmentBoxMax);\n #endif\n\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\n #ifdef BRDFLOOKUP_ENABLED\n vec2 brdfParam = texture2D(brdfLookup, vec2(rough, ndv)).xy;\n envWeight = spec * brdfParam.x + brdfParam.y;\n #endif\n\n #else\n vec3 envTexel = textureCube(environmentMap, L).xyz;\n #endif\n\n outColor.rgb += envTexel * envWeight;\n#endif\n\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\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\n outColor.rgb *= aoFactor;\n\n vec3 lEmission = emission;\n#ifdef EMISSIVEMAP_ENABLED\n lEmission *= texture2D(emissiveMap, v_Texcoord).rgb;\n#endif\n outColor.rgb += lEmission * emissionIntensity;\n\n#ifdef GAMMA_ENCODE\n outColor.rgb = pow(outColor.rgb, vec3(1 / 2.2));\n#endif\n\n if(lineWidth > 0.)\n {\n outColor.rgb = mix(lineColor, vec3(outColor.rgb), edgeFactor(lineWidth));\n }\n\n#ifdef ALPHA_TEST\n if (outColor.a < alphaCutoff) {\n discard;\n }\n#endif\n\n gl_FragColor = encodeHDR(outColor);\n}\n\n@end\n"; +},function(t,e){t.exports="\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\n@export qtek.util.calculate_attenuation\n\nuniform float attenuationFactor : 5.0;\n\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\n@end\n\n@export qtek.util.edge_factor\n\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\n@end\n\n@export qtek.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n \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\n return res;\n}\n@end\n\n@export qtek.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n \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\n\n@export qtek.util.float\n@import qtek.util.encode_float\n@import qtek.util.decode_float\n@end\n\n\n\n@export qtek.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n }\n@end\n\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\n@export qtek.util.rgbm\n@import qtek.util.rgbm_decode\n@import qtek.util.rgbm_encode\n\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}\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\n@end\n\n\n@export qtek.util.srgb\n\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}\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\n\n@export qtek.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n\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\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\n#endif\n\n@end\n\n@export qtek.chunk.skin_matrix\n\nmat4 skinMatrixWS;\nif (weight.x > 1e-4)\n{\n skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\n}\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-3)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n\n\n\n@export qtek.util.parallax_correct\n\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\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n\n return normalize(fixedPos - boxCenter);\n}\n\n@end\n\n\n\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"},function(t,e,n){var r=n(8),i=n(19),a=n(7),o=n(17),s=n(22),u=n(6),l=n(5),c=n(53),h=n(23),f=n(35),d=n(11),_=n(58),p=n(154),m=n(155),v={},g=["px","nx","py","ny","pz","nz"];v.prefilterEnvironmentMap=function(t,e,n,s,p){p&&s||(s=v.generateNormalDistribution(),p=v.integrateBRDF(t,s)),n=n||{};var y=n.width||64,x=n.height||64,T=n.type||e.type,E=new i({width:y,height:x,type:T,flipY:!1,mipmaps:[]});E.isPowerOfTwo()||console.warn("Width and height must be power of two to enable mipmap.");var b=Math.min(y,x),S=Math.log(b)/Math.log(2)+1,A=new u({shader:new l({vertex:l.source("qtek.skybox.vertex"),fragment:m})});A.set("normalDistribution",s),n.encodeRGBM&&A.shader.define("fragment","RGBM_ENCODE"),n.decodeRGBM&&A.shader.define("fragment","RGBM_DECODE");var N,w=new h;if(e instanceof r){var M=new i({width:y,height:x,type:T===a.FLOAT?a.HALF_FLOAT:T});_.panoramaToCubeMap(t,e,M,{encodeRGBM:n.decodeRGBM}),e=M}N=new c({scene:w,material:A}),N.material.set("environmentMap",e);var C=new f({texture:E});n.encodeRGBM&&(T=E.type=a.UNSIGNED_BYTE);for(var R=new r({width:y,height:x,type:T}),L=new o({depthBuffer:!1}),P=d[T===a.UNSIGNED_BYTE?"Uint8Array":"Float32Array"],I=0;I>>16)>>>0;u=((1431655765&u)<<1|(2863311530&u)>>>1)>>>0,u=((858993459&u)<<2|(3435973836&u)>>>2)>>>0,u=((252645135&u)<<4|(4042322160&u)>>>4)>>>0,u=(((16711935&u)<<8|(4278255360&u)>>>8)>>>0)/4294967296;for(var l=0;ll&&(l=t[e][0]),t[e][1]c&&(c=t[e][1]);n=l-s,r=c-u,i=Math.max(n,r),a=s+.5*n,o=u+.5*r,t.push([a-20*i,o-i],[a,o+20*i],[a+20*i,o-i])}function r(t,e,n,r){var i,a,o,s,u,l,c=t[e],h=t[n],f=t[r],d=h[0]-c[0],_=h[1]-c[1],p=f[0]-c[0],m=f[1]-c[1],v=d*(c[0]+h[0])+_*(c[1]+h[1]),g=p*(c[0]+f[0])+m*(c[1]+f[1]),y=2*(d*(f[1]-h[1])-_*(f[0]-h[0]));return Math.abs(y)<1e-6?(i=Math.min(c[0],h[0],f[0]),a=Math.min(c[1],h[1],f[1]),o=.5*(Math.max(c[0],h[0],f[0])-i),s=.5*(Math.max(c[1],h[1],f[1])-a),u=i+o,l=a+s):(u=(m*v-_*g)/y,l=(d*g-p*v)/y,o=u-c[0],s=l-c[1]),{i:e,j:n,k:r,x:u,y:l,r:o*o+s*s}}function i(t){var e,n,r,i,a,o=t.length;t:for(;o;)for(n=t[--o],e=t[--o],r=o;r;)if(a=t[--r],i=t[--r],e===i&&n===a||e===a&&n===i){t.splice(o,2),t.splice(r,2),o-=2;continue t}}var a={triangulate:function(t,e){var a,o,s,u,l,c,h,f,d,_,p,m=t.length;if(m<3)return[];if(t=t.slice(0),e)for(a=m;a--;)t[a]=t[a][e];for(s=new Array(m),a=m;a--;)s[a]=a;for(s.sort(function(e,n){return t[n][0]-t[e][0]}),n(t),u=[r(t,m+0,m+1,m+2)],l=[],c=[],a=s.length;a--;){for(p=s[a],c.length=0,o=u.length;o--;)h=t[p][0]-u[o].x,h>0&&h*h>u[o].r?(l.push(u[o]),u.splice(o,1)):(f=t[p][1]-u[o].y,h*h+f*f>u[o].r||(c.push(u[o].i,u[o].j,u[o].j,u[o].k,u[o].k,u[o].i),u.splice(o,1)));for(i(c),o=c.length;o;)_=c[--o],d=c[--o],u.push(r(t,d,_,p))}for(a=u.length;a--;)l.push(u[a]);for(u.length=0,a=l.length;a--;)if(l[a].it[0][0]&&e[0]>t[1][0]&&e[0]>t[2][0]||e[1]t[0][1]&&e[1]>t[1][1]&&e[1]>t[2][1])return null;var n=t[1][0]-t[0][0],r=t[2][0]-t[0][0],i=t[1][1]-t[0][1],a=t[2][1]-t[0][1],o=n*a-r*i;if(0===o)return null;var s=(a*(e[0]-t[0][0])-r*(e[1]-t[0][1]))/o,u=(n*(e[1]-t[0][1])-i*(e[0]-t[0][0]))/o;return s<0||u<0||s+u>1?null:[s,u]}};t.exports=a},function(t,e,n){"use strict";function r(t,e,n,r){if(t[3]>0){var i=Math.pow(2,t[3]-128-8+r);e[n+0]=t[0]*i,e[n+1]=t[1]*i,e[n+2]=t[2]*i}else e[n+0]=0,e[n+1]=0,e[n+2]=0;return e[n+3]=1,e}function i(t,e,n){for(var r="",i=e;i0;)if(t[o][0]=e[n++],t[o][1]=e[n++],t[o][2]=e[n++],t[o][3]=e[n++],1===t[o][0]&&1===t[o][1]&&1===t[o][2]){for(var u=t[o][3]<>>0;u>0;u--)a(t[o-1],t[o]),o++,s--;i+=8}else o++,s--,i=0;return n}function s(t,e,n,r){if(rf)return o(t,e,n,r);var i=e[n++];if(2!=i)return o(t,e,n-1,r);if(t[0][1]=e[n++],t[0][2]=e[n++],i=e[n++],(t[0][2]<<8>>>0|i)>>>0!==r)return null;for(var i=0;i<4;i++)for(var a=0;a128){s=(127&s)>>>0;for(var u=e[n++];s--;)t[a++][i]=u}else for(;s--;)t[a++][i]=e[n++]}return n}var u=n(7),l=n(8),c=String.fromCharCode,h=8,f=32767,d={parseRGBE:function(t,e,n){null==n&&(n=0);var a=new Uint8Array(t),o=a.length;if("#?"===i(a,0,2)){for(var h=2;h=o)){h+=2;for(var f="";h=0&&this._clips.splice(e,1)},removeAnimator:function(t){for(var e=t.getClips(),n=0;nt)this.inputs.unshift(r);else if(this.inputs[i-1].position<=t)this.inputs.push(r);else{var a=this._findKey(t);this.inputs.splice(a,r)}return r},a.prototype.step=function(t){var e=r.prototype.step.call(this,t);return"finish"!==e&&this.setTime(this._elapsedTime),e},a.prototype.setTime=function(t){var e=this.position,n=this.inputs,i=n.length,a=n[0].position,o=n[i-1].position;if(e<=a||e>=o){var s=e<=a?n[0]:n[i-1],u=s.clip,l=s.offset;u.setTime((t+l)%u.life),u.output instanceof r?this.output.copy(u.output):this.output.copy(u)}else{var c=this._findKey(e),h=n[c],f=n[c+1],d=h.clip,_=f.clip;d.setTime((t+h.offset)%d.life),_.setTime((t+f.offset)%_.life);var p=(this.position-h.position)/(f.position-h.position),m=d.output instanceof r?d.output:d,v=_.output instanceof r?_.output:_;this.output.blend1D(m,v,p)}},a.prototype.clone=function(t){var e=r.prototype.clone.call(this);e.output=this.output.clone();for(var n=0;n=n[i].position&&t=0;i--)t>=n[i].position&&t=0&&(this._cacheKey=e,this._cachePosition=t),e},t.exports=a},function(t,e,n){"use strict";var r=n(20),i=n(84),a=n(26),o=function(t){t=t||{},r.call(this,t),this.output=t.output||null,this.inputs=t.inputs||[],this.position=new a,this._cacheTriangle=null,this._triangles=[],this._updateTriangles()};o.prototype=new r,o.prototype.constructor=o,o.prototype.addInput=function(t,e,n){var r={position:t,clip:e,offset:n||0};return this.inputs.push(r),this.life=Math.max(e.life,this.life),this._updateTriangles(),r},o.prototype._updateTriangles=function(){var t=this.inputs.map(function(t){return t.position});this._triangles=i.triangulate(t,"_array")},o.prototype.step=function(t){var e=r.prototype.step.call(this,t);return"finish"!==e&&this.setTime(this._elapsedTime),e},o.prototype.setTime=function(t){var e=this._findTriangle(this.position);if(e){var n=e[1],i=e[2],a=e[0],o=this.inputs[a.indices[0]],s=this.inputs[a.indices[1]],u=this.inputs[a.indices[2]],l=o.clip,c=s.clip,h=u.clip;l.setTime((t+o.offset)%l.life),c.setTime((t+s.offset)%c.life),h.setTime((t+u.offset)%h.life);var f=l.output instanceof r?l.output:l,d=c.output instanceof r?c.output:c,_=h.output instanceof r?h.output:h;this.output.blend2D(f,d,_,n,i)}},o.prototype.clone=function(t){var e=r.prototype.clone.call(this);e.output=this.output.clone();for(var n=0;n0,l=e.color;e.depth=0,u&&p.set(l,0,0,0,0);for(var c=!0,h=1/r,f=0;f-g&&_-g&&m-g&&v0){var v=d[0],w=(v[0]+1)*u,M=(-v[1]+1)*c;e.fillStyle=m,"rectangle"===A?e.fillRect(w-N,M-N,S,S):"circle"===A&&(e.beginPath(),e.arc(w,M,N,0,2*Math.PI),e.fill())}}}e.restore()},dispose:function(){this._triangles.clear(),this._lines.clear(),this._points.clear(),this._primitives=[],this.ctx=null,this.canvas=null}});t.exports=T},function(t,e,n){"use strict";var r=n(2),i=r.extend({cancelBubble:!1},{stopPropagation:function(){this.cancelBubble=!0}});i["throw"]=function(t,e,n){var r=new i(n);for(r.type=t,r.target=e;e&&!r.cancelBubble;)r.currentTarget=e,e.trigger(t,r),e=e.getParent()},t.exports=i},function(t,e,n){"use strict";var r=n(42),i=function(t){this._list=new r,this._map={},this._maxSize=t||10};i.prototype.setMaxSize=function(t){this._maxSize=t},i.prototype.put=function(t,e){if("undefined"==typeof this._map[t]){var n=this._list.length();if(n>=this._maxSize&&n>0){var r=this._list.head;this._list.remove(r),delete this._map[r.key]}var i=this._list.insert(e);i.key=t,this._map[t]=i}},i.prototype.get=function(t){var e=this._map[t];if("undefined"!=typeof e)return e!==this._list.tail&&(this._list.remove(e),this._list.insertEntry(e)),e.value},i.prototype.remove=function(t){var e=this._map[t];"undefined"!=typeof e&&(delete this._map[t],this._list.remove(e))},i.prototype.clear=function(){this._list.clear(),this._map={}},t.exports=i},function(t,e,n){"use strict";var r=n(2),i=n(5),a=n(6),o=n(17),s=n(22),u=n(8),l=n(7),c=n(13),h=n(46),f=n(44),d=n(72),_=n(16),p=n(3),m=n(70);i["import"](n(81)),i["import"](n(142)),i["import"](n(145)),i["import"](n(140)),i["import"](n(136)),i["import"](n(138)),i["import"](n(137)),i["import"](n(143)),i["import"](n(144)),i["import"](n(146)),i["import"](n(57));var v={},g=r.extend(function(){var t=i.source("qtek.compositor.vertex"),e=i.source("qtek.deferred.light_volume.vertex"),n=new i({vertex:t,fragment:i.source("qtek.deferred.directional_light")}),r=n.clone();r.define("fragment","SHADOWMAP_ENABLED");var c=function(t){t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ONE)},v=function(t){return new a({shader:t,blend:c,transparent:!0,depthMask:!1})},g=function(t,n){var r=new i({vertex:e,fragment:i.source("qtek.deferred."+t)});return n&&r.define("fragment","SHADOWMAP_ENABLED"),r},y=new f({capSegments:10}),x=new _;x.rotateX(Math.PI/2).translate(new p(0,(-1),0)),y.applyTransform(x);var T=new d({capSegments:10});return x.identity().rotateZ(Math.PI/2),T.applyTransform(x),{shadowMapPass:null,autoResize:!0,_createLightPassMat:v,_gBuffer:new m,_lightAccumFrameBuffer:new o({depthBuffer:!1}),_lightAccumTex:new u({type:l.HALF_FLOAT,minFilter:l.NEAREST,magFilter:l.NEAREST}),_fullQuadPass:new s({blendWithPrevious:!0}),_directionalLightMat:v(n),_directionalLightMatWithShadow:v(r),_ambientMat:v(new i({vertex:t,fragment:i.source("qtek.deferred.ambient_light")})),_ambientSHMat:v(new i({vertex:t,fragment:i.source("qtek.deferred.ambient_sh_light")})),_ambientCubemapMat:v(new i({vertex:t,fragment:i.source("qtek.deferred.ambient_cubemap_light")})),_spotLightShader:g("spot_light"),_pointLightShader:g("point_light"),_spotLightShaderWithShadow:g("spot_light",!0),_pointLightShaderWithShadow:g("point_light",!0),_sphereLightShader:g("sphere_light"),_tubeLightShader:g("tube_light"),_lightSphereGeo:new h({widthSegments:10,heightSegements:10}),_lightConeGeo:y,_lightCylinderGeo:T,_outputPass:new s({fragment:i.source("qtek.compositor.output")})}},{render:function(t,e,n,r){r=r||{},r.renderToTarget=r.renderToTarget||!1,r.notUpdateShadow=r.notUpdateShadow||!1,r.notUpdateScene=r.notUpdateScene||!1,r.notUpdateScene||e.update(!1,!0),n.update(!0);var i=t.getDevicePixelRatio();!this.autoResize||t.getWidth()*i===this._lightAccumTex.width&&t.getHeight()*i===this._lightAccumTex.height||this.resize(t.getWidth()*i,t.getHeight()*i),this._gBuffer.update(t,e,n),this._accumulateLightBuffer(t,e,n,!r.notUpdateShadow),r.renderToTarget||(this._outputPass.setUniform("texture",this._lightAccumTex),this._outputPass.render(t))},getTargetTexture:function(){return this._lightAccumTex},getTargetFrameBuffer:function(){return this._lightAccumFrameBuffer},getGBuffer:function(){return this._gBuffer},setViewport:function(t,e,n,r,i){this._gBuffer.setViewport(t,e,n,r,i),this._lightAccumFrameBuffer.viewport=this._gBuffer.getViewport()},resize:function(t,e){this._lightAccumTex.width=t,this._lightAccumTex.height=e,this._gBuffer.resize(t,e)},_accumulateLightBuffer:function(t,e,n,r){for(var i=t.gl,a=this._lightAccumTex,o=this._lightAccumFrameBuffer,s=n.getWorldPosition()._array,u=0;u1?F.name=[s.name,h].join("-"):F.name=s.name),e.meshes[a].push(F)}}},_parseNodes:function(t,e){for(var n in t.nodes){var r,i=t.nodes[n];if(i.camera&&this.includeCamera){var a=t.cameras[i.camera];"perspective"===a.projection?r=new m({name:i.name,aspect:a.aspect_ratio,fov:a.xfov,far:a.zfar,near:a.znear}):(r=new v,console.warn("TODO:Orthographic camera")),r.setName(i.name),e.cameras[i.name]=r}else if(i.lights&&this.includeLight){for(var o=[],s=0;s1?L.name=[i.name,o].join("-"):L.name=i.name),e.meshes[a].push(L)}},this)},_instanceCamera:function(t,e){var n=t.cameras[e.camera];if("perspective"===n.type){var r=n.perspective||{};return new g({name:e.name,aspect:r.aspectRatio,fov:r.yfov,far:r.zfar,near:r.znear})}var i=n.orthographic||{};return new y({name:e.name,top:i.ymag,right:i.xmag,left:-i.xmag,bottom:-i.ymag,near:i.znear,far:i.zfar})},_parseNodes:function(t,e){function n(t){return new h({name:t.name,geometry:t.geometry,material:t.material,mode:t.mode})}o.each(t.nodes,function(t,r){var i;if(null!=t.camera&&this.includeCamera)this._instanceCamera(t.camera),e.cameras.push(i);else if(null!=t.mesh&&this.includeMesh){var a=e.meshes[t.mesh];if(a)if(1===a.length)i=n(a[0]),i.setName(t.name);else{i=new f,i.setName(t.name);for(var o=0;o0&&o.scaleAndAdd(t._array,t._array,this.force._array,r/n)}});t.exports=s},function(t,e,n){"use strict";var r=n(31),i=n(10),a=n(6),o=n(5);o["import"](n(110));var s=new o({vertex:o.source("qtek.particle.vertex"),fragment:o.source("qtek.particle.fragment")});s.enableTexture("sprite");var u=r.extend({loop:!0,oneshot:!1,duration:1,spriteAnimationTileX:1,spriteAnimationTileY:1,spriteAnimationRepeat:0,mode:r.POINTS,ignorePicking:!0,_elapsedTime:0,_emitting:!0},function(){this.geometry=new i({dynamic:!0}),this.material||(this.material=new a({shader:s,transparent:!0,depthMask:!1})),this._particles=[],this._fields=[],this._emitters=[]},{culling:!1,frustumCulling:!1,castShadow:!1,receiveShadow:!1,addEmitter:function(t){this._emitters.push(t)},removeEmitter:function(t){this._emitters.splice(this._emitters.indexOf(t),1)},addField:function(t){this._fields.push(t)},removeField:function(t){this._fields.splice(this._fields.indexOf(t),1)},reset:function(){for(var t=0;t=i.life?(i.emitter.kill(i),e[n]=e[r-1],e.pop(),r--):n++}for(var n=0;n0)for(var a=0;a1,o=t.attributes.position.value,s=t.attributes.normal.value,u=t.attributes.texcoord0.value,l=t.attributes.texcoord1.value,c=this._particles.length;o&&o.length===3*c||(o=t.attributes.position.value=new Float32Array(3*c),s=t.attributes.normal.value=new Float32Array(3*c),a&&(u=t.attributes.texcoord0.value=new Float32Array(2*c),l=t.attributes.texcoord1.value=new Float32Array(2*c)));for(var h=1/e,f=0;fthis.duration&&!this.loop},dispose:function(t){for(var e=0;e>16,n=t-(e<<8)>>8,r=t-(e<<16)-(n<<8);return[e,n,r]}function i(t,e,n){return(t<<16)+(e<<8)+n}var a=n(2),o=n(17),s=n(8),u=n(5),l=n(6);u["import"](n(113));var c=a.extend(function(){return{renderer:null,downSampleRatio:1,width:100,height:100,lookupOffset:1,_frameBuffer:null,_texture:null,_shader:null,_idMaterials:[],_lookupTable:[],_meshMaterials:[],_idOffset:0}},function(){this.renderer&&(this.width=this.renderer.getWidth(),this.height=this.renderer.getHeight()),this._init()},{_init:function(){this._texture=new s({width:this.width*this.downSampleRatio,height:this.height*this.downSampleRatio}),this._frameBuffer=new o,this._shader=new u({vertex:u.source("qtek.picking.color.vertex"),fragment:u.source("qtek.picking.color.fragment")})},setPrecision:function(t){this._texture.width=this.width*t,this._texture.height=this.height*t,this.downSampleRatio=t},resize:function(t,e){this._texture.width=t*this.downSampleRatio,this._texture.height=e*this.downSampleRatio,this.width=t,this.height=e,this._texture.dirty()},update:function(t,e){var n=this.renderer;n.getWidth()===this.width&&n.getHeight()===this.height||this.resize(n.width,n.height),this._frameBuffer.attach(this._texture),this._frameBuffer.bind(n),this._idOffset=this.lookupOffset,this._setMaterial(t),n.render(t,e),this._restoreMaterial(),this._frameBuffer.unbind(n)},_setMaterial:function(t){for(var e=0;e0},update:function(t){if(t=t||16,this._rotating){var e=("cw"===this.autoRotateDirection?1:-1)*this.autoRotateSpeed/180*Math.PI;this._phi-=e*t/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(t,50)),this._updatePan(Math.min(t,50)),this._updateRotate(Math.min(t,50)),this._updateTransform(),this.target.update(),this.trigger("update"),this._needsUpdate=!1)},_updateRotate:function(t){var e=this._rotateVelocity;this._phi=e.y*t/20+this._phi,this._theta=e.x*t/20+this._theta,this.setAlpha(this.getAlpha()),this.setBeta(this.getBeta()),this._vectorDamping(e,this.damping)},_updateDistance:function(t){this._setDistance(this._distance+this._zoomSpeed*t/20),this._zoomSpeed*=this.damping},_setDistance:function(t){this._distance=Math.max(Math.min(t,this.maxDistance),this.minDistance)},_updatePan:function(t){var e=this._panVelocity,n=this._distance,r=this.target,i=r.worldTransform.y,a=r.worldTransform.x;this._center.scaleAndAdd(a,-e.x*n/200).scaleAndAdd(i,-e.y*n/200),this._vectorDamping(e,0)},_updateTransform:function(){var t=this.target,e=new o,n=this._theta+Math.PI/2,r=this._phi+Math.PI/2,i=Math.sin(n);e.x=i*Math.cos(r),e.y=-Math.cos(n),e.z=i*Math.sin(r),t.position.copy(this._center).scaleAndAdd(e,this._distance),t.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var t=this.autoRotateAfterStill,e=this;!isNaN(t)&&t>0&&(this._stillTimeout=setTimeout(function(){e._rotating=!0},1e3*t))},_vectorDamping:function(t,e){var n=t.len();n*=e,n<1e-4&&(n=0),t.normalize().scale(n)},decomposeTransform:function(){if(this.target){var t=new o;t.eulerFromQuat(this.target.rotation.normalize(),"ZYX"),this._theta=-t.x,this._phi=-t.y,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this._setDistance(this.target.position.dist(this._center))}},_mouseDownHandler:function(t){if(!this._isAnimating()){var e=t.clientX,n=t.clientY;if(t.targetTouches){var r=t.targetTouches[0];e=r.clientX,n=r.clientY,this._mode="rotate",this._processGesture(t,"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===t.button?this._mode="rotate":1===t.button&&(this._mode="pan"),this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=e,this._mouseY=n}},_mouseMoveHandler:function(t){if(!this._isAnimating()){var e,n=t.clientX,i=t.clientY;if(t.targetTouches){var a=t.targetTouches[0];n=a.clientX,i=a.clientY,e=this._processGesture(t,"change")}var o=r(this.panSensitivity),s=r(this.rotateSensitivity);e||("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,t.preventDefault()}},_mouseWheelHandler:function(t){if(!this._isAnimating()){var e=t.wheelDelta||-t.detail;0!==e&&this._zoomHandler(t,e>0?-1:1)}},_pinchHandler:function(t){this._isAnimating()||this._zoomHandler(t,t.pinchScale>1?-.4:.4)},_zoomHandler:function(t,e){var n=(t.clientX,t.clientY,Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance)));this._zoomSpeed=e*Math.max(n/40*this.zoomSensitivity,.2),this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),t.preventDefault()},_mouseUpHandler:function(t){var e=this.domElement;e.removeEventListener("touchmove",this._mouseMoveHandler),e.removeEventListener("touchend",this._mouseUpHandler),e.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseup",this._mouseUpHandler),this._processGesture(t,"end")},_addAnimator:function(t){var e=this._animators;return e.push(t),t.done(function(){var n=e.indexOf(t);n>=0&&e.splice(n,1)}),t},_processGesture:function(t,e){var n=this._gestureMgr;"start"===e&&n.clear();var r=n.recognize(t,null,this.domElement);if("end"===e&&n.clear(),r){var i=r.type;t.gestureEvent=i,this._pinchHandler(r.event)}return r}});Object.defineProperty(u.prototype,"autoRotate",{get:function(){return this._autoRotate},set:function(t){this._autoRotate=t,this._rotating=t}}),Object.defineProperty(u.prototype,"target",{get:function(){return this._target},set:function(t){t&&t.target&&this.setCenter(t.target.toArray()),this._target=t,this.decomposeTransform()}}),t.exports=u},function(t,e,n){var r=n(2),i=(n(74),r.extend(function(){console.warn("TODO")},{render:function(t,e,n){}}));t.exports=i},function(t,e,n){var r=n(2),i=n(4),a=n(3),o=n(9),s=n(50),u=n(16),l=n(37),c=n(5),h=(n(12),n(13),n(49)),f=n(47),d=n(48),_=(n(27),n(6)),p=n(17),m=n(7),v=n(8),g=n(19),y=n(21),x=n(28),T=n(22),E=n(41),b=n(1),S=b.mat4,A=(b.vec3,["px","nx","py","ny","pz","nz"]);c["import"](n(149));var N=r.extend(function(){return{softShadow:N.PCF,shadowBlur:1,lightFrustumBias:2,kernelPCF:new Float32Array([1,0,1,1,-1,1,0,1,-1,0,-1,-1,1,-1,0,-1]),precision:"mediump",_frameBuffer:new p,_textures:{},_shadowMapNumber:{POINT_LIGHT:0,DIRECTIONAL_LIGHT:0,SPOT_LIGHT:0},_meshMaterials:{},_depthMaterials:{},_depthShaders:{},_distanceMaterials:{},_opaqueCasters:[],_receivers:[],_lightsCastShadow:[],_lightCameras:{},_texturePool:new E}},function(){this._gaussianPassH=new T({fragment:c.source("qtek.compositor.gaussian_blur")}),this._gaussianPassV=new T({ +fragment:c.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 T({fragment:c.source("qtek.sm.debug_depth")})},{render:function(t,e,n,r){this.trigger("beforerender",this,t,e,n),this._renderShadowPass(t,e,n,r),this.trigger("afterrender",this,t,e,n)},renderDebug:function(t,e){t.saveClear();var n=t.viewport,r=0,i=0,a=e||n.width/4,o=a;this.softShadow===N.VSM?this._outputDepthPass.material.shader.define("fragment","USE_VSM"):this._outputDepthPass.material.shader.undefine("fragment","USE_VSM");for(var s in this._textures){var u=this._textures[s];t.setViewport(r,i,a*u.width/u.height,o),this._outputDepthPass.setUniform("depthMap",u),this._outputDepthPass.render(t),r+=a*u.width/u.height}t.setViewport(n),t.restoreClear()},_bindDepthMaterial:function(t,e,n){for(var r=0;r0&&(f.define("vertex","SKINNING"),f.define("vertex","JOINT_COUNT",l)),s&&f.define("both","SHADOW_TRANSPARENT"),o.useSkinMatricesTexture&&f.define("vertex","USE_SKIN_MATRICES_TEXTURE"),this._depthShaders[a]=f),h||(h=new _({shader:f}),this._depthMaterials[i]=h),o.material=h,this.softShadow===N.VSM?f.define("fragment","USE_VSM"):f.undefine("fragment","USE_VSM"),h.setUniform("bias",e),h.setUniform("slopeScale",n),s&&h.set("shadowTransparentMap",u))}},_bindDistanceMaterial:function(t,e){for(var n=e.getWorldPosition()._array,r=0;r0&&(o.shader.define("vertex","SKINNING"),o.shader.define("vertex","JOINT_COUNT",a)),this._distanceMaterials[a]=o),i.material=o,this.softShadow===N.VSM?o.shader.define("fragment","USE_VSM"):o.shader.undefine("fragment","USE_VSM")),o.set("lightPosition",n),o.set("range",e.range)}},saveMaterial:function(t){for(var e=0;e1&&(m=g,g.shadowCascade>4)){console.warn("Support at most 4 cascade");continue}this.renderDirectionalLightShadow(t,e,n,g,this._opaqueCasters,_,c,l)}else g instanceof h?this.renderSpotLightShadow(t,g,this._opaqueCasters,u,s):g instanceof d&&this.renderPointLightShadow(t,g,this._opaqueCasters,p);this._shadowMapNumber[g.type]++}this.restoreMaterial(this._opaqueCasters);var y=_.slice(),x=_.slice();y.pop(),x.shift(),y.reverse(),x.reverse(),c.reverse();for(var T=s.map(i),E=l.map(i),b={},v=0;v0&&(N.fragmentDefines[R]=C,w=!0)}w&&N.dirty(),m?N.define("fragment","SHADOW_CASCADE",m.shadowCascade):N.undefine("fragment","SHADOW_CASCADE"),b[N.__GUID__]=!0}s.length>0&&(A.setUniform("spotLightShadowMaps",s),A.setUniform("spotLightMatrices",u),A.setUniform("spotLightShadowMapSizes",T)),l.length>0&&(A.setUniform("directionalLightShadowMaps",l),m&&(A.setUniform("shadowCascadeClipsNear",y),A.setUniform("shadowCascadeClipsFar",x)),A.setUniform("directionalLightMatrices",c),A.setUniform("directionalLightShadowMapSizes",E)),p.length>0&&A.setUniform("pointLightShadowMaps",p)}}},renderDirectionalLightShadow:function(){var t=new s,e=new u,n=new o,r=new u,i=new u,a=new u,c=new u;return function(o,s,h,f,d,_,p,m){var v=f.shadowBias;this._bindDepthMaterial(d,v,f.shadowSlopeScale),d.sort(l.opaqueSortFunc);var g=Math.min(-s.viewBoundingBoxLastFrame.min.z,h.far),x=Math.max(-s.viewBoundingBoxLastFrame.max.z,h.near),T=this._getDirectionalLightCamera(f,s,h),E=a._array;c.copy(T.projectionMatrix),S.invert(i._array,T.worldTransform._array),S.multiply(i._array,i._array,h.worldTransform._array),S.multiply(E,c._array,i._array);for(var b=[],A=h instanceof y,w=(h.near+h.far)/(h.near-h.far),M=2*h.near*h.far/(h.near-h.far),C=0;C<=f.shadowCascade;C++){var R=x*Math.pow(g/x,C/f.shadowCascade),L=x+(g-x)*C/f.shadowCascade,P=R*f.cascadeSplitLogFactor+L*(1-f.cascadeSplitLogFactor);b.push(P),_.push(-(-P*w+M)/-P)}var I=this._getTexture(f,f.shadowCascade);m.push(I);var D=o.viewport,O=o.gl;this._frameBuffer.attach(I),this._frameBuffer.bind(o),O.clear(O.COLOR_BUFFER_BIT|O.DEPTH_BUFFER_BIT);for(var C=0;Ct[1][0]&&(t[1][0]=h),f>t[1][1]&&(t[1][1]=f),t[0][0]-=.1,t[0][1]-=.1,t[1][0]+=.1,t[1][1]+=.1;var p=i(s,c,h,f,d,_);this._pointTypes[r]=p<=0?u:l,p<=0&&this._candidates.push(r),a=r,r++}this._gridWidth=(t[1][0]-t[0][0])/this._gridNumber,this._gridHeight=(t[1][1]-t[0][1])/this._gridNumber;for(var r=0;rn&&(n=s),u>r&&(r=u),ln&&(n=l),c>r&&(r=c),i[0][0]=Math.floor((t-h[0][0])/this._gridWidth),i[1][0]=Math.floor((n-h[0][0])/this._gridWidth),i[0][1]=Math.floor((e-h[0][1])/this._gridHeight),i[1][1]=Math.floor((r-h[0][1])/this._gridHeight),i}}(),c.prototype.isTriangleConvex2=function(t,e,n){return this.triangleArea(t,e,n)<0},c.prototype.triangleArea=function(t,e,n){var r=this._points,i=r[2*t],a=r[2*t+1],o=r[2*e],s=r[2*e+1],u=r[2*n],l=r[2*n+1];return(o-i)*(l-s)-(s-a)*(u-o)};var h={flatPoints:function(t){for(var e=new s.Float64Array(2*t.length),n=0;n=65535?u.indices=new Uint32Array(3*v):u.indices=new Uint16Array(3*v);for(var E=0,b=0,S=a.isUseIndices(),A=0;A0;){for(var S=[],A=[],N=[],w=0,x=0;x=0&&A[I]===-1&&(w65535?q.indices=new Uint32Array(3*B.triangles.length):q.indices=new Uint16Array(3*B.triangles.length);var J=0;j=0;for(var x=0;x=0?q.attributes.joint.value[nt]=U[I]:q.attributes.joint.value[nt]=-1}j++}q.indices[J++]=k[L]}q.updateBoundingBox(),D.add(z)}for(var rt=t.children(),x=0;x 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\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n"},function(t,e){t.exports="#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\n\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\n\nuniform float roughness : 0.5;\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n\nconst float fSampleNumber = float(SAMPLE_NUMBER);\n\n@import qtek.util.rgbm\n\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n\n vec3 upVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n vec3 tangentX = normalize(cross(upVector, N));\n vec3 tangentY = cross(N, tangentX);\n return tangentX * H.x + tangentY * H.y + N * H.z;\n}\n\nvoid main() {\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n\n vec3 N = V;\n vec3 R = V;\n\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n\n\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"},function(t,e){t.exports="uniform samplerCube environmentMap;\n\nvarying vec2 v_Texcoord;\n\n#define TEXTURE_SIZE 16\n\nmat3 front = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n);\n\nmat3 back = mat3(\n -1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, -1.0\n);\n\nmat3 left = mat3(\n 0.0, 0.0, -1.0,\n 0.0, 1.0, 0.0,\n 1.0, 0.0, 0.0\n);\n\nmat3 right = mat3(\n 0.0, 0.0, 1.0,\n 0.0, 1.0, 0.0,\n -1.0, 0.0, 0.0\n);\n\nmat3 up = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 0.0, 1.0,\n 0.0, -1.0, 0.0\n);\n\nmat3 down = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 0.0, -1.0,\n 0.0, 1.0, 0.0\n);\n\n\nfloat harmonics(vec3 normal){\n int index = int(gl_FragCoord.x);\n\n float x = normal.x;\n float y = normal.y;\n float z = normal.z;\n\n if(index==0){\n return 1.0;\n }\n else if(index==1){\n return x;\n }\n else if(index==2){\n return y;\n }\n else if(index==3){\n return z;\n }\n else if(index==4){\n return x*z;\n }\n else if(index==5){\n return y*z;\n }\n else if(index==6){\n return x*y;\n }\n else if(index==7){\n return 3.0*z*z - 1.0;\n }\n else{\n return x*x - y*y;\n }\n}\n\nvec3 sampleSide(mat3 rot)\n{\n\n vec3 result = vec3(0.0);\n float divider = 0.0;\n for (int i = 0; i < TEXTURE_SIZE * TEXTURE_SIZE; i++) {\n float x = mod(float(i), float(TEXTURE_SIZE));\n float y = float(i / TEXTURE_SIZE);\n\n vec2 sidecoord = ((vec2(x, y) + vec2(0.5, 0.5)) / vec2(TEXTURE_SIZE)) * 2.0 - 1.0;\n vec3 normal = normalize(vec3(sidecoord, -1.0));\n vec3 fetchNormal = rot * normal;\n vec3 texel = textureCube(environmentMap, fetchNormal).rgb;\n\n result += harmonics(fetchNormal) * texel * -normal.z;\n\n divider += -normal.z;\n }\n\n return result / divider;\n}\n\nvoid main()\n{\n vec3 result = (\n sampleSide(front) +\n sampleSide(back) +\n sampleSide(left) +\n sampleSide(right) +\n sampleSide(up) +\n sampleSide(down)\n ) / 6.0;\n gl_FragColor = vec4(result, 1.0);\n}"; -},function(t,e){t.exports="0.4.2"},function(t,e,n){function r(t,e,n){return t*(1-n)+e*n}var i=n(13),a=n(6),o=n(10),s=n(5),u=n(2),l=n(21);s["import"](n(160));var c=u.extend(function(){return{clearColor:[0,0,0,1],_mesh:new i({geometry:new o,culling:!1,material:new a({depthTest:!1,shader:new s({vertex:s.source("qtek.vr.disorter.output.vertex"),fragment:s.source("qtek.vr.disorter.output.fragment")})})}),_fakeCamera:new l}},{render:function(t,e){var n=this.clearColor,r=t.gl;r.clearColor(n[0],n[1],n[2],n[3]),r.clear(r.COLOR_BUFFER_BIT),r.disable(r.BLEND),this._mesh.material.set("texture",e),t.saveViewport(),t.setViewport(0,0,t.getWidth(),t.getHeight()),t.renderQueue([this._mesh],this._fakeCamera),t.restoreViewport()},updateFromVRDisplay:function(t){t.deviceInfo_?this._updateMesh(20,20,t.deviceInfo_):console.warn("Cant get vrDisplay.deviceInfo_, seems code changed")},_updateMesh:function(t,e,n){var i=this._mesh.geometry.attributes.position,a=this._mesh.geometry.attributes.texcoord0;i.init(2*t*e),a.init(2*t*e);for(var o=n.getLeftEyeVisibleTanAngles(),s=n.getLeftEyeNoLensTanAngles(),u=n.getLeftEyeVisibleScreenRect(s),l=0,c=[],h=[],f=0;f<2;f++){for(var d=0;dt[1][0]&&(t[1][0]=h),f>t[1][1]&&(t[1][1]=f),t[0][0]-=.1,t[0][1]-=.1,t[1][0]+=.1,t[1][1]+=.1;var p=i(s,c,h,f,d,_);this._pointTypes[r]=p<=0?u:l,p<=0&&this._candidates.push(r),a=r,r++}this._gridWidth=(t[1][0]-t[0][0])/this._gridNumber,this._gridHeight=(t[1][1]-t[0][1])/this._gridNumber;for(var r=0;rn&&(n=s),u>r&&(r=u),ln&&(n=l),c>r&&(r=c),i[0][0]=Math.floor((t-h[0][0])/this._gridWidth),i[1][0]=Math.floor((n-h[0][0])/this._gridWidth),i[0][1]=Math.floor((e-h[0][1])/this._gridHeight),i[1][1]=Math.floor((r-h[0][1])/this._gridHeight),i}}(),c.prototype.isTriangleConvex2=function(t,e,n){return this.triangleArea(t,e,n)<0},c.prototype.triangleArea=function(t,e,n){var r=this._points,i=r[2*t],a=r[2*t+1],o=r[2*e],s=r[2*e+1],u=r[2*n],l=r[2*n+1];return(o-i)*(l-s)-(s-a)*(u-o)};var h={flatPoints:function(t){for(var e=new s.Float64Array(2*t.length),n=0;n=65535?u.indices=new Uint32Array(3*v):u.indices=new Uint16Array(3*v);for(var E=0,b=0,S=a.isUseIndices(),A=0;A0;){for(var S=[],A=[],N=[],w=0,x=0;x=0&&A[I]===-1&&(w65535?q.indices=new Uint32Array(3*B.triangles.length):q.indices=new Uint16Array(3*B.triangles.length);var J=0;j=0;for(var x=0;x=0?q.attributes.joint.value[nt]=U[I]:q.attributes.joint.value[nt]=-1}j++}q.indices[J++]=k[L]}q.updateBoundingBox(),D.add(z)}for(var rt=t.children(),x=0;x 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\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n"},function(t,e){t.exports="#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\n\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\n\nuniform float roughness : 0.5;\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n\nconst float fSampleNumber = float(SAMPLE_NUMBER);\n\n@import qtek.util.rgbm\n\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n\n vec3 upVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n vec3 tangentX = normalize(cross(upVector, N));\n vec3 tangentY = cross(N, tangentX);\n return tangentX * H.x + tangentY * H.y + N * H.z;\n}\n\nvoid main() {\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n\n vec3 N = V;\n vec3 R = V;\n\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n\n\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n"},function(t,e){t.exports="uniform samplerCube environmentMap;\n\nvarying vec2 v_Texcoord;\n\n#define TEXTURE_SIZE 16\n\nmat3 front = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n);\n\nmat3 back = mat3(\n -1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, -1.0\n);\n\nmat3 left = mat3(\n 0.0, 0.0, -1.0,\n 0.0, 1.0, 0.0,\n 1.0, 0.0, 0.0\n);\n\nmat3 right = mat3(\n 0.0, 0.0, 1.0,\n 0.0, 1.0, 0.0,\n -1.0, 0.0, 0.0\n);\n\nmat3 up = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 0.0, 1.0,\n 0.0, -1.0, 0.0\n);\n\nmat3 down = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 0.0, -1.0,\n 0.0, 1.0, 0.0\n);\n\n\nfloat harmonics(vec3 normal){\n int index = int(gl_FragCoord.x);\n\n float x = normal.x;\n float y = normal.y;\n float z = normal.z;\n\n if(index==0){\n return 1.0;\n }\n else if(index==1){\n return x;\n }\n else if(index==2){\n return y;\n }\n else if(index==3){\n return z;\n }\n else if(index==4){\n return x*z;\n }\n else if(index==5){\n return y*z;\n }\n else if(index==6){\n return x*y;\n }\n else if(index==7){\n return 3.0*z*z - 1.0;\n }\n else{\n return x*x - y*y;\n }\n}\n\nvec3 sampleSide(mat3 rot)\n{\n\n vec3 result = vec3(0.0);\n float divider = 0.0;\n for (int i = 0; i < TEXTURE_SIZE * TEXTURE_SIZE; i++) {\n float x = mod(float(i), float(TEXTURE_SIZE));\n float y = float(i / TEXTURE_SIZE);\n\n vec2 sidecoord = ((vec2(x, y) + vec2(0.5, 0.5)) / vec2(TEXTURE_SIZE)) * 2.0 - 1.0;\n vec3 normal = normalize(vec3(sidecoord, -1.0));\n vec3 fetchNormal = rot * normal;\n vec3 texel = textureCube(environmentMap, fetchNormal).rgb;\n\n result += harmonics(fetchNormal) * texel * -normal.z;\n\n divider += -normal.z;\n }\n\n return result / divider;\n}\n\nvoid main()\n{\n vec3 result = (\n sampleSide(front) +\n sampleSide(back) +\n sampleSide(left) +\n sampleSide(right) +\n sampleSide(up) +\n sampleSide(down)\n ) / 6.0;\n gl_FragColor = vec4(result, 1.0);\n}"; +},function(t,e){t.exports="0.4.3"},function(t,e,n){function r(t,e,n){return t*(1-n)+e*n}var i=n(13),a=n(6),o=n(10),s=n(5),u=n(2),l=n(21);s["import"](n(160));var c=u.extend(function(){return{clearColor:[0,0,0,1],_mesh:new i({geometry:new o,culling:!1,material:new a({depthTest:!1,shader:new s({vertex:s.source("qtek.vr.disorter.output.vertex"),fragment:s.source("qtek.vr.disorter.output.fragment")})})}),_fakeCamera:new l}},{render:function(t,e){var n=this.clearColor,r=t.gl;r.clearColor(n[0],n[1],n[2],n[3]),r.clear(r.COLOR_BUFFER_BIT),r.disable(r.BLEND),this._mesh.material.set("texture",e),t.saveViewport(),t.setViewport(0,0,t.getWidth(),t.getHeight()),t.renderQueue([this._mesh],this._fakeCamera),t.restoreViewport()},updateFromVRDisplay:function(t){t.deviceInfo_?this._updateMesh(20,20,t.deviceInfo_):console.warn("Cant get vrDisplay.deviceInfo_, seems code changed")},_updateMesh:function(t,e,n){var i=this._mesh.geometry.attributes.position,a=this._mesh.geometry.attributes.texcoord0;i.init(2*t*e),a.init(2*t*e);for(var o=n.getLeftEyeVisibleTanAngles(),s=n.getLeftEyeNoLensTanAngles(),u=n.getLeftEyeVisibleScreenRect(s),l=0,c=[],h=[],f=0;f<2;f++){for(var d=0;d