/* Phaser v2.6.1 Creature Build - http://phaser.io - @photonstorm - (c) 2016 Photon Storm Ltd. */ function dualQuat(){this.real=quat.create(),this.real[Q_W]=0,this.imaginary=quat.create(),this.imaginary[Q_W]=0,this.tmpQ1=quat.create()}function MeshBone(a,b,c,d){this.key=a,this.world_rest_angle=0,this.rest_parent_mat=mat4.create(),this.rest_parent_inv_mat=mat4.create(),this.rest_world_mat=mat4.create(),this.rest_world_inv_mat=mat4.create(),this.bind_world_mat=mat4.create(),this.bind_world_inv_mat=mat4.create(),this.parent_world_mat=mat4.create(),this.parent_world_inv_mat=mat4.create(),this.local_rest_start_pt=null,this.local_rest_end_pt=null,this.setRestParentMat(d,null),this.setLocalRestStartPt(b),this.setLocalRestEndPt(c),this.setParentWorldInvMat(mat4.create()),this.setParentWorldMat(mat4.create()),this.local_binormal_dir=vec3.fromValues(0,0,1),this.tag_id=0,this.children=[]}function MeshRenderRegion(a,b,c,d,e,f,g){this.store_indices=a,this.store_rest_pts=b,this.store_uvs=c,this.use_local_displacements=!1,this.use_post_displacements=!1,this.use_uv_warp=!1,this.uv_warp_local_offset=vec2.fromValues(0,0),this.uv_warp_global_offset=vec2.fromValues(0,0),this.uv_warp_scale=vec2.fromValues(1,1),this.start_pt_index=d,this.end_pt_index=e,this.start_index=f,this.end_index=g,this.main_bone=null,this.local_displacements=[],this.post_displacements=[],this.uv_warp_ref_uvs=[],this.normal_weight_map={},this.fast_normal_weight_map=[],this.fast_bones_map=[],this.relevant_bones_indices=[],this.use_dq=!0,this.tag_id=-1,this.initUvWarp()}function MeshRenderBoneComposition(){this.root_bone=null,this.bones_map={},this.regions=[],this.regions_map={}}function MeshBoneCache(a){this.key=a}function MeshDisplacementCache(a){this.key=a,this.local_displacements=[],this.post_displacements=[]}function MeshUVWarpCache(a){this.uv_warp_global_offset=vec2.create(),this.uv_warp_local_offset=vec2.create(),this.uv_warp_scale=vec2.fromValues(-1,-1),this.key=a,this.enabled=!1}function MeshBoneCacheManager(){this.is_ready=!1,this.bone_cache_table=null,this.bone_cache_data_ready=null,this.bone_cache_table=[],this.bone_cache_data_ready=[]}function MeshDisplacementCacheManager(){this.is_ready=!1,this.displacement_cache_table=null,this.displacement_cache_data_ready=null,this.displacement_cache_table=[],this.displacement_cache_data_ready=[]}function MeshUVWarpCacheManager(){this.is_ready=!1,this.uv_cache_table=null,this.uv_cache_data_ready=null,this.uv_cache_table=[],this.uv_cache_data_ready=[]}function Creature(a){this.total_num_pts=0,this.total_num_indices=0,this.global_indices=null,this.global_pts=null,this.global_uvs=null,this.render_pts=null,this.render_colours=null,this.render_composition=null,this.boundary_indices=[],this.boundary_min=vec2.create(),this.boundary_max=vec2.create(),this.LoadFromData(a)}function CreatureAnimation(a,b){this.name=b,this.bones_cache=new MeshBoneCacheManager,this.displacement_cache=new MeshDisplacementCacheManager,this.uv_warp_cache=new MeshUVWarpCacheManager,this.cache_pts=[],this.fill_cache_pts=[],this.LoadFromData(b,a)}function CreatureManager(a){this.target_creature=a,this.is_playing=!1,this.run_time=0,this.time_scale=30,this.blending_factor=0,this.should_loop=!0,this.use_custom_time_range=!1,this.custom_start_time=0,this.custom_end_time=0,this.animations={},this.bones_override_callback=null,this.blend_render_pts=[],this.blend_render_pts.push([]),this.blend_render_pts.push([]),this.do_blending=!1,this.active_blend_animation_names=[],this.active_blend_animation_names.push(""),this.active_blend_animation_names.push("")}!function(a){"use strict";var b={};"undefined"==typeof exports?"function"==typeof define&&"object"==typeof define.amd&&define.amd?(b.exports={},define(function(){return b.exports})):b.exports="undefined"!=typeof window?window:a:b.exports=exports,function(a){if(!b)var b=1e-6;if(!c)var c="undefined"!=typeof Float32Array?Float32Array:Array;if(!d)var d=Math.random;var e={};e.setMatrixArrayType=function(a){c=a},"undefined"!=typeof a&&(a.glMatrix=e);var f=Math.PI/180;e.toRadian=function(a){return a*f};var g={};g.create=function(){var a=new c(2);return a[0]=0,a[1]=0,a},g.clone=function(a){var b=new c(2);return b[0]=a[0],b[1]=a[1],b},g.fromValues=function(a,b){var d=new c(2);return d[0]=a,d[1]=b,d},g.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a},g.set=function(a,b,c){return a[0]=b,a[1]=c,a},g.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a},g.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a},g.sub=g.subtract,g.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a},g.mul=g.multiply,g.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a},g.div=g.divide,g.min=function(a,b,c){return a[0]=Math.min(b[0],c[0]),a[1]=Math.min(b[1],c[1]),a},g.max=function(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a},g.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a},g.scaleAndAdd=function(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a},g.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return Math.sqrt(c*c+d*d)},g.dist=g.distance,g.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d},g.sqrDist=g.squaredDistance,g.length=function(a){var b=a[0],c=a[1];return Math.sqrt(b*b+c*c)},g.len=g.length,g.squaredLength=function(a){var b=a[0],c=a[1];return b*b+c*c},g.sqrLen=g.squaredLength,g.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a},g.inverse=function(a,b){return a[0]=1/b[0],a[1]=1/b[1],a},g.normalize=function(a,b){var c=b[0],d=b[1],e=c*c+d*d;return e>0&&(e=1/Math.sqrt(e),a[0]=b[0]*e,a[1]=b[1]*e),a},g.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]},g.cross=function(a,b,c){var d=b[0]*c[1]-b[1]*c[0];return a[0]=a[1]=0,a[2]=d,a},g.lerp=function(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a},g.random=function(a,b){b=b||1;var c=2*d()*Math.PI;return a[0]=Math.cos(c)*b,a[1]=Math.sin(c)*b,a},g.transformMat2=function(a,b,c){var d=b[0],e=b[1];return a[0]=c[0]*d+c[2]*e,a[1]=c[1]*d+c[3]*e,a},g.transformMat2d=function(a,b,c){var d=b[0],e=b[1];return a[0]=c[0]*d+c[2]*e+c[4],a[1]=c[1]*d+c[3]*e+c[5],a},g.transformMat3=function(a,b,c){var d=b[0],e=b[1];return a[0]=c[0]*d+c[3]*e+c[6],a[1]=c[1]*d+c[4]*e+c[7],a},g.transformMat4=function(a,b,c){var d=b[0],e=b[1];return a[0]=c[0]*d+c[4]*e+c[12],a[1]=c[1]*d+c[5]*e+c[13],a},g.forEach=function(){var a=g.create();return function(b,c,d,e,f,g){var h,i;for(c||(c=2),d||(d=0),i=e?Math.min(e*c+d,b.length):b.length,h=d;i>h;h+=c)a[0]=b[h],a[1]=b[h+1],f(a,a,g),b[h]=a[0],b[h+1]=a[1];return b}}(),g.str=function(a){return"vec2("+a[0]+", "+a[1]+")"},"undefined"!=typeof a&&(a.vec2=g);var h={};h.create=function(){var a=new c(3);return a[0]=0,a[1]=0,a[2]=0,a},h.clone=function(a){var b=new c(3);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b},h.fromValues=function(a,b,d){var e=new c(3);return e[0]=a,e[1]=b,e[2]=d,e},h.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a},h.set=function(a,b,c,d){return a[0]=b,a[1]=c,a[2]=d,a},h.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a},h.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a},h.sub=h.subtract,h.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a},h.mul=h.multiply,h.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a},h.div=h.divide,h.min=function(a,b,c){return a[0]=Math.min(b[0],c[0]),a[1]=Math.min(b[1],c[1]),a[2]=Math.min(b[2],c[2]),a},h.max=function(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a},h.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a},h.scaleAndAdd=function(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a},h.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2];return Math.sqrt(c*c+d*d+e*e)},h.dist=h.distance,h.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2];return c*c+d*d+e*e},h.sqrDist=h.squaredDistance,h.length=function(a){var b=a[0],c=a[1],d=a[2];return Math.sqrt(b*b+c*c+d*d)},h.len=h.length,h.squaredLength=function(a){var b=a[0],c=a[1],d=a[2];return b*b+c*c+d*d},h.sqrLen=h.squaredLength,h.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a},h.inverse=function(a,b){return a[0]=1/b[0],a[1]=1/b[1],a[2]=1/b[2],a},h.normalize=function(a,b){var c=b[0],d=b[1],e=b[2],f=c*c+d*d+e*e;return f>0&&(f=1/Math.sqrt(f),a[0]=b[0]*f,a[1]=b[1]*f,a[2]=b[2]*f),a},h.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]},h.cross=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2];return a[0]=e*i-f*h,a[1]=f*g-d*i,a[2]=d*h-e*g,a},h.lerp=function(a,b,c,d){var e=b[0],f=b[1],g=b[2];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a[2]=g+d*(c[2]-g),a},h.random=function(a,b){b=b||1;var c=2*d()*Math.PI,e=2*d()-1,f=Math.sqrt(1-e*e)*b;return a[0]=Math.cos(c)*f,a[1]=Math.sin(c)*f,a[2]=e*b,a},h.transformMat4=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[3]*d+c[7]*e+c[11]*f+c[15];return g=g||1,a[0]=(c[0]*d+c[4]*e+c[8]*f+c[12])/g,a[1]=(c[1]*d+c[5]*e+c[9]*f+c[13])/g,a[2]=(c[2]*d+c[6]*e+c[10]*f+c[14])/g,a},h.transformMat3=function(a,b,c){var d=b[0],e=b[1],f=b[2];return a[0]=d*c[0]+e*c[3]+f*c[6],a[1]=d*c[1]+e*c[4]+f*c[7],a[2]=d*c[2]+e*c[5]+f*c[8],a},h.transformQuat=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2],j=c[3],k=j*d+h*f-i*e,l=j*e+i*d-g*f,m=j*f+g*e-h*d,n=-g*d-h*e-i*f;return a[0]=k*j+n*-g+l*-i-m*-h,a[1]=l*j+n*-h+m*-g-k*-i,a[2]=m*j+n*-i+k*-h-l*-g,a},h.rotateX=function(a,b,c,d){var e=[],f=[];return e[0]=b[0]-c[0],e[1]=b[1]-c[1],e[2]=b[2]-c[2],f[0]=e[0],f[1]=e[1]*Math.cos(d)-e[2]*Math.sin(d),f[2]=e[1]*Math.sin(d)+e[2]*Math.cos(d),a[0]=f[0]+c[0],a[1]=f[1]+c[1],a[2]=f[2]+c[2],a},h.rotateY=function(a,b,c,d){var e=[],f=[];return e[0]=b[0]-c[0],e[1]=b[1]-c[1],e[2]=b[2]-c[2],f[0]=e[2]*Math.sin(d)+e[0]*Math.cos(d),f[1]=e[1],f[2]=e[2]*Math.cos(d)-e[0]*Math.sin(d),a[0]=f[0]+c[0],a[1]=f[1]+c[1],a[2]=f[2]+c[2],a},h.rotateZ=function(a,b,c,d){var e=[],f=[];return e[0]=b[0]-c[0],e[1]=b[1]-c[1],e[2]=b[2]-c[2],f[0]=e[0]*Math.cos(d)-e[1]*Math.sin(d),f[1]=e[0]*Math.sin(d)+e[1]*Math.cos(d),f[2]=e[2],a[0]=f[0]+c[0],a[1]=f[1]+c[1],a[2]=f[2]+c[2],a},h.forEach=function(){var a=h.create();return function(b,c,d,e,f,g){var h,i;for(c||(c=3),d||(d=0),i=e?Math.min(e*c+d,b.length):b.length,h=d;i>h;h+=c)a[0]=b[h],a[1]=b[h+1],a[2]=b[h+2],f(a,a,g),b[h]=a[0],b[h+1]=a[1],b[h+2]=a[2];return b}}(),h.str=function(a){return"vec3("+a[0]+", "+a[1]+", "+a[2]+")"},"undefined"!=typeof a&&(a.vec3=h);var i={};i.create=function(){var a=new c(4);return a[0]=0,a[1]=0,a[2]=0,a[3]=0,a},i.clone=function(a){var b=new c(4);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b},i.fromValues=function(a,b,d,e){var f=new c(4);return f[0]=a,f[1]=b,f[2]=d,f[3]=e,f},i.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a},i.set=function(a,b,c,d,e){return a[0]=b,a[1]=c,a[2]=d,a[3]=e,a},i.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a[3]=b[3]+c[3],a},i.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a[3]=b[3]-c[3],a},i.sub=i.subtract,i.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a[3]=b[3]*c[3],a},i.mul=i.multiply,i.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a[3]=b[3]/c[3],a},i.div=i.divide,i.min=function(a,b,c){return a[0]=Math.min(b[0],c[0]),a[1]=Math.min(b[1],c[1]),a[2]=Math.min(b[2],c[2]),a[3]=Math.min(b[3],c[3]),a},i.max=function(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a[3]=Math.max(b[3],c[3]),a},i.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a},i.scaleAndAdd=function(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a[3]=b[3]+c[3]*d,a},i.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2],f=b[3]-a[3];return Math.sqrt(c*c+d*d+e*e+f*f)},i.dist=i.distance,i.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2],f=b[3]-a[3];return c*c+d*d+e*e+f*f},i.sqrDist=i.squaredDistance,i.length=function(a){var b=a[0],c=a[1],d=a[2],e=a[3];return Math.sqrt(b*b+c*c+d*d+e*e)},i.len=i.length,i.squaredLength=function(a){var b=a[0],c=a[1],d=a[2],e=a[3];return b*b+c*c+d*d+e*e},i.sqrLen=i.squaredLength,i.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=-b[3],a},i.inverse=function(a,b){return a[0]=1/b[0],a[1]=1/b[1],a[2]=1/b[2],a[3]=1/b[3],a},i.normalize=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c*c+d*d+e*e+f*f;return g>0&&(g=1/Math.sqrt(g),a[0]=b[0]*g,a[1]=b[1]*g,a[2]=b[2]*g,a[3]=b[3]*g),a},i.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]},i.lerp=function(a,b,c,d){var e=b[0],f=b[1],g=b[2],h=b[3];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a[2]=g+d*(c[2]-g),a[3]=h+d*(c[3]-h),a},i.random=function(a,b){return b=b||1,a[0]=d(),a[1]=d(),a[2]=d(),a[3]=d(),i.normalize(a,a),i.scale(a,a,b),a},i.transformMat4=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3];return a[0]=c[0]*d+c[4]*e+c[8]*f+c[12]*g,a[1]=c[1]*d+c[5]*e+c[9]*f+c[13]*g,a[2]=c[2]*d+c[6]*e+c[10]*f+c[14]*g,a[3]=c[3]*d+c[7]*e+c[11]*f+c[15]*g,a},i.transformQuat=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2],j=c[3],k=j*d+h*f-i*e,l=j*e+i*d-g*f,m=j*f+g*e-h*d,n=-g*d-h*e-i*f;return a[0]=k*j+n*-g+l*-i-m*-h,a[1]=l*j+n*-h+m*-g-k*-i,a[2]=m*j+n*-i+k*-h-l*-g,a},i.forEach=function(){var a=i.create();return function(b,c,d,e,f,g){var h,i;for(c||(c=4),d||(d=0),i=e?Math.min(e*c+d,b.length):b.length,h=d;i>h;h+=c)a[0]=b[h],a[1]=b[h+1],a[2]=b[h+2],a[3]=b[h+3],f(a,a,g),b[h]=a[0],b[h+1]=a[1],b[h+2]=a[2],b[h+3]=a[3];return b}}(),i.str=function(a){return"vec4("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},"undefined"!=typeof a&&(a.vec4=i);var j={};j.create=function(){var a=new c(4);return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a},j.clone=function(a){var b=new c(4);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b},j.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a},j.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a},j.transpose=function(a,b){if(a===b){var c=b[1];a[1]=b[2],a[2]=c}else a[0]=b[0],a[1]=b[2],a[2]=b[1],a[3]=b[3];return a},j.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c*f-e*d;return g?(g=1/g,a[0]=f*g,a[1]=-d*g,a[2]=-e*g,a[3]=c*g,a):null},j.adjoint=function(a,b){var c=b[0];return a[0]=b[3],a[1]=-b[1],a[2]=-b[2],a[3]=c,a},j.determinant=function(a){return a[0]*a[3]-a[2]*a[1]},j.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=c[0],i=c[1],j=c[2],k=c[3];return a[0]=d*h+f*i,a[1]=e*h+g*i,a[2]=d*j+f*k,a[3]=e*j+g*k,a},j.mul=j.multiply,j.rotate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i+f*h,a[1]=e*i+g*h,a[2]=d*-h+f*i,a[3]=e*-h+g*i,a},j.scale=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=c[0],i=c[1];return a[0]=d*h,a[1]=e*h,a[2]=f*i,a[3]=g*i,a},j.str=function(a){return"mat2("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},j.frob=function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2))},j.LDU=function(a,b,c,d){return a[2]=d[2]/d[0],c[0]=d[0],c[1]=d[1],c[3]=d[3]-a[2]*c[1],[a,b,c]},"undefined"!=typeof a&&(a.mat2=j);var k={};k.create=function(){var a=new c(6);return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a[4]=0,a[5]=0,a},k.clone=function(a){var b=new c(6);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b},k.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a},k.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a[4]=0,a[5]=0,a},k.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=c*f-d*e;return i?(i=1/i,a[0]=f*i,a[1]=-d*i,a[2]=-e*i,a[3]=c*i,a[4]=(e*h-f*g)*i,a[5]=(d*g-c*h)*i,a):null},k.determinant=function(a){return a[0]*a[3]-a[1]*a[2]},k.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=c[0],k=c[1],l=c[2],m=c[3],n=c[4],o=c[5];return a[0]=d*j+f*k,a[1]=e*j+g*k,a[2]=d*l+f*m,a[3]=e*l+g*m,a[4]=d*n+f*o+h,a[5]=e*n+g*o+i,a},k.mul=k.multiply,k.rotate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=Math.sin(c),k=Math.cos(c);return a[0]=d*k+f*j,a[1]=e*k+g*j,a[2]=d*-j+f*k,a[3]=e*-j+g*k,a[4]=h,a[5]=i,a},k.scale=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=c[0],k=c[1];return a[0]=d*j,a[1]=e*j,a[2]=f*k,a[3]=g*k,a[4]=h,a[5]=i,a},k.translate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=c[0],k=c[1];return a[0]=d,a[1]=e,a[2]=f,a[3]=g,a[4]=d*j+f*k+h,a[5]=e*j+g*k+i,a},k.str=function(a){return"mat2d("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+")"},k.frob=function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2)+Math.pow(a[4],2)+Math.pow(a[5],2)+1)},"undefined"!=typeof a&&(a.mat2d=k);var l={};l.create=function(){var a=new c(9);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},l.fromMat4=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[4],a[4]=b[5],a[5]=b[6],a[6]=b[8],a[7]=b[9],a[8]=b[10],a},l.clone=function(a){var b=new c(9);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b},l.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a},l.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},l.transpose=function(a,b){if(a===b){var c=b[1],d=b[2],e=b[5];a[1]=b[3],a[2]=b[6],a[3]=c,a[5]=b[7],a[6]=d,a[7]=e}else a[0]=b[0],a[1]=b[3],a[2]=b[6],a[3]=b[1],a[4]=b[4],a[5]=b[7],a[6]=b[2],a[7]=b[5],a[8]=b[8];return a},l.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=k*g-h*j,m=-k*f+h*i,n=j*f-g*i,o=c*l+d*m+e*n;return o?(o=1/o,a[0]=l*o,a[1]=(-k*d+e*j)*o,a[2]=(h*d-e*g)*o,a[3]=m*o,a[4]=(k*c-e*i)*o,a[5]=(-h*c+e*f)*o,a[6]=n*o,a[7]=(-j*c+d*i)*o,a[8]=(g*c-d*f)*o,a):null},l.adjoint=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8];return a[0]=g*k-h*j,a[1]=e*j-d*k,a[2]=d*h-e*g,a[3]=h*i-f*k,a[4]=c*k-e*i,a[5]=e*f-c*h,a[6]=f*j-g*i,a[7]=d*i-c*j,a[8]=c*g-d*f,a},l.determinant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],i=a[7],j=a[8];return b*(j*f-g*i)+c*(-j*e+g*h)+d*(i*e-f*h)},l.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=c[0],n=c[1],o=c[2],p=c[3],q=c[4],r=c[5],s=c[6],t=c[7],u=c[8];return a[0]=m*d+n*g+o*j,a[1]=m*e+n*h+o*k,a[2]=m*f+n*i+o*l,a[3]=p*d+q*g+r*j,a[4]=p*e+q*h+r*k,a[5]=p*f+q*i+r*l,a[6]=s*d+t*g+u*j,a[7]=s*e+t*h+u*k,a[8]=s*f+t*i+u*l,a},l.mul=l.multiply,l.translate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=c[0],n=c[1];return a[0]=d,a[1]=e,a[2]=f,a[3]=g,a[4]=h,a[5]=i,a[6]=m*d+n*g+j,a[7]=m*e+n*h+k,a[8]=m*f+n*i+l,a},l.rotate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=Math.sin(c),n=Math.cos(c);return a[0]=n*d+m*g,a[1]=n*e+m*h,a[2]=n*f+m*i,a[3]=n*g-m*d,a[4]=n*h-m*e,a[5]=n*i-m*f,a[6]=j,a[7]=k,a[8]=l,a},l.scale=function(a,b,c){var d=c[0],e=c[1];return a[0]=d*b[0],a[1]=d*b[1],a[2]=d*b[2],a[3]=e*b[3],a[4]=e*b[4],a[5]=e*b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a},l.fromMat2d=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=0,a[3]=b[2],a[4]=b[3],a[5]=0,a[6]=b[4],a[7]=b[5],a[8]=1,a},l.fromQuat=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c+c,h=d+d,i=e+e,j=c*g,k=d*g,l=d*h,m=e*g,n=e*h,o=e*i,p=f*g,q=f*h,r=f*i;return a[0]=1-l-o,a[3]=k-r,a[6]=m+q,a[1]=k+r,a[4]=1-j-o,a[7]=n-p,a[2]=m-q,a[5]=n+p,a[8]=1-j-l,a},l.normalFromMat4=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15],s=c*h-d*g,t=c*i-e*g,u=c*j-f*g,v=d*i-e*h,w=d*j-f*h,x=e*j-f*i,y=k*p-l*o,z=k*q-m*o,A=k*r-n*o,B=l*q-m*p,C=l*r-n*p,D=m*r-n*q,E=s*D-t*C+u*B+v*A-w*z+x*y;return E?(E=1/E,a[0]=(h*D-i*C+j*B)*E,a[1]=(i*A-g*D-j*z)*E,a[2]=(g*C-h*A+j*y)*E,a[3]=(e*C-d*D-f*B)*E,a[4]=(c*D-e*A+f*z)*E,a[5]=(d*A-c*C-f*y)*E,a[6]=(p*x-q*w+r*v)*E,a[7]=(q*u-o*x-r*t)*E,a[8]=(o*w-p*u+r*s)*E,a):null},l.str=function(a){return"mat3("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+")"},l.frob=function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2)+Math.pow(a[4],2)+Math.pow(a[5],2)+Math.pow(a[6],2)+Math.pow(a[7],2)+Math.pow(a[8],2))},"undefined"!=typeof a&&(a.mat3=l);var m={};m.create=function(){var a=new c(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},m.clone=function(a){var b=new c(16);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b[9]=a[9],b[10]=a[10],b[11]=a[11],b[12]=a[12],b[13]=a[13],b[14]=a[14],b[15]=a[15],b},m.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a},m.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},m.transpose=function(a,b){if(a===b){var c=b[1],d=b[2],e=b[3],f=b[6],g=b[7],h=b[11];a[1]=b[4],a[2]=b[8],a[3]=b[12],a[4]=c,a[6]=b[9],a[7]=b[13],a[8]=d,a[9]=f,a[11]=b[14],a[12]=e,a[13]=g,a[14]=h}else a[0]=b[0],a[1]=b[4],a[2]=b[8],a[3]=b[12],a[4]=b[1],a[5]=b[5],a[6]=b[9],a[7]=b[13],a[8]=b[2],a[9]=b[6],a[10]=b[10],a[11]=b[14],a[12]=b[3],a[13]=b[7],a[14]=b[11],a[15]=b[15];return a},m.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15],s=c*h-d*g,t=c*i-e*g,u=c*j-f*g,v=d*i-e*h,w=d*j-f*h,x=e*j-f*i,y=k*p-l*o,z=k*q-m*o,A=k*r-n*o,B=l*q-m*p,C=l*r-n*p,D=m*r-n*q,E=s*D-t*C+u*B+v*A-w*z+x*y;return E?(E=1/E,a[0]=(h*D-i*C+j*B)*E,a[1]=(e*C-d*D-f*B)*E,a[2]=(p*x-q*w+r*v)*E,a[3]=(m*w-l*x-n*v)*E,a[4]=(i*A-g*D-j*z)*E,a[5]=(c*D-e*A+f*z)*E,a[6]=(q*u-o*x-r*t)*E,a[7]=(k*x-m*u+n*t)*E,a[8]=(g*C-h*A+j*y)*E,a[9]=(d*A-c*C-f*y)*E,a[10]=(o*w-p*u+r*s)*E,a[11]=(l*u-k*w-n*s)*E,a[12]=(h*z-g*B-i*y)*E,a[13]=(c*B-d*z+e*y)*E,a[14]=(p*t-o*v-q*s)*E,a[15]=(k*v-l*t+m*s)*E,a):null},m.adjoint=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15];return a[0]=h*(m*r-n*q)-l*(i*r-j*q)+p*(i*n-j*m),a[1]=-(d*(m*r-n*q)-l*(e*r-f*q)+p*(e*n-f*m)),a[2]=d*(i*r-j*q)-h*(e*r-f*q)+p*(e*j-f*i),a[3]=-(d*(i*n-j*m)-h*(e*n-f*m)+l*(e*j-f*i)),a[4]=-(g*(m*r-n*q)-k*(i*r-j*q)+o*(i*n-j*m)),a[5]=c*(m*r-n*q)-k*(e*r-f*q)+o*(e*n-f*m),a[6]=-(c*(i*r-j*q)-g*(e*r-f*q)+o*(e*j-f*i)),a[7]=c*(i*n-j*m)-g*(e*n-f*m)+k*(e*j-f*i),a[8]=g*(l*r-n*p)-k*(h*r-j*p)+o*(h*n-j*l),a[9]=-(c*(l*r-n*p)-k*(d*r-f*p)+o*(d*n-f*l)),a[10]=c*(h*r-j*p)-g*(d*r-f*p)+o*(d*j-f*h),a[11]=-(c*(h*n-j*l)-g*(d*n-f*l)+k*(d*j-f*h)),a[12]=-(g*(l*q-m*p)-k*(h*q-i*p)+o*(h*m-i*l)),a[13]=c*(l*q-m*p)-k*(d*q-e*p)+o*(d*m-e*l),a[14]=-(c*(h*q-i*p)-g*(d*q-e*p)+o*(d*i-e*h)),a[15]=c*(h*m-i*l)-g*(d*m-e*l)+k*(d*i-e*h),a},m.determinant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],i=a[7],j=a[8],k=a[9],l=a[10],m=a[11],n=a[12],o=a[13],p=a[14],q=a[15],r=b*g-c*f,s=b*h-d*f,t=b*i-e*f,u=c*h-d*g,v=c*i-e*g,w=d*i-e*h,x=j*o-k*n,y=j*p-l*n,z=j*q-m*n,A=k*p-l*o,B=k*q-m*o,C=l*q-m*p;return r*C-s*B+t*A+u*z-v*y+w*x},m.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],p=b[12],q=b[13],r=b[14],s=b[15],t=c[0],u=c[1],v=c[2],w=c[3];return a[0]=t*d+u*h+v*l+w*p,a[1]=t*e+u*i+v*m+w*q,a[2]=t*f+u*j+v*n+w*r,a[3]=t*g+u*k+v*o+w*s,t=c[4],u=c[5],v=c[6],w=c[7],a[4]=t*d+u*h+v*l+w*p,a[5]=t*e+u*i+v*m+w*q,a[6]=t*f+u*j+v*n+w*r,a[7]=t*g+u*k+v*o+w*s,t=c[8],u=c[9],v=c[10],w=c[11],a[8]=t*d+u*h+v*l+w*p,a[9]=t*e+u*i+v*m+w*q,a[10]=t*f+u*j+v*n+w*r,a[11]=t*g+u*k+v*o+w*s,t=c[12],u=c[13],v=c[14],w=c[15],a[12]=t*d+u*h+v*l+w*p,a[13]=t*e+u*i+v*m+w*q,a[14]=t*f+u*j+v*n+w*r,a[15]=t*g+u*k+v*o+w*s,a},m.mul=m.multiply,m.translate=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p=c[0],q=c[1],r=c[2];return b===a?(a[12]=b[0]*p+b[4]*q+b[8]*r+b[12],a[13]=b[1]*p+b[5]*q+b[9]*r+b[13],a[14]=b[2]*p+b[6]*q+b[10]*r+b[14],a[15]=b[3]*p+b[7]*q+b[11]*r+b[15]):(d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],a[0]=d,a[1]=e,a[2]=f,a[3]=g,a[4]=h,a[5]=i,a[6]=j,a[7]=k,a[8]=l,a[9]=m,a[10]=n,a[11]=o,a[12]=d*p+h*q+l*r+b[12],a[13]=e*p+i*q+m*r+b[13],a[14]=f*p+j*q+n*r+b[14],a[15]=g*p+k*q+o*r+b[15]),a},m.scale=function(a,b,c){var d=c[0],e=c[1],f=c[2];return a[0]=b[0]*d,a[1]=b[1]*d,a[2]=b[2]*d,a[3]=b[3]*d,a[4]=b[4]*e,a[5]=b[5]*e,a[6]=b[6]*e,a[7]=b[7]*e,a[8]=b[8]*f,a[9]=b[9]*f,a[10]=b[10]*f,a[11]=b[11]*f,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a},m.rotate=function(a,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D=e[0],E=e[1],F=e[2],G=Math.sqrt(D*D+E*E+F*F);return Math.abs(G)g?(h.cross(a,b,e),h.length(a)<1e-6&&h.cross(a,c,e),h.normalize(a,a),n.setAxisAngle(d,a,Math.PI),d):g>.999999?(d[0]=0,d[1]=0,d[2]=0,d[3]=1,d):(h.cross(a,e,f),d[0]=a[0],d[1]=a[1],d[2]=a[2],d[3]=1+g,n.normalize(d,d))}}(),n.setAxes=function(){var a=l.create();return function(b,c,d,e){return a[0]=d[0],a[3]=d[1],a[6]=d[2],a[1]=e[0],a[4]=e[1],a[7]=e[2],a[2]=-c[0],a[5]=-c[1],a[8]=-c[2],n.normalize(b,n.fromMat3(b,a))}}(),n.clone=i.clone,n.fromValues=i.fromValues,n.copy=i.copy,n.set=i.set,n.identity=function(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a},n.setAxisAngle=function(a,b,c){c=.5*c;var d=Math.sin(c);return a[0]=d*b[0],a[1]=d*b[1],a[2]=d*b[2],a[3]=Math.cos(c),a},n.add=i.add,n.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=c[0],i=c[1],j=c[2],k=c[3];return a[0]=d*k+g*h+e*j-f*i,a[1]=e*k+g*i+f*h-d*j,a[2]=f*k+g*j+d*i-e*h,a[3]=g*k-d*h-e*i-f*j,a},n.mul=n.multiply,n.scale=i.scale,n.rotateX=function(a,b,c){c*=.5;var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i+g*h,a[1]=e*i+f*h,a[2]=f*i-e*h,a[3]=g*i-d*h,a},n.rotateY=function(a,b,c){c*=.5;var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i-f*h,a[1]=e*i+g*h,a[2]=f*i+d*h,a[3]=g*i-e*h,a},n.rotateZ=function(a,b,c){c*=.5;var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i+e*h,a[1]=e*i-d*h,a[2]=f*i+g*h,a[3]=g*i-f*h,a},n.calculateW=function(a,b){var c=b[0],d=b[1],e=b[2];return a[0]=c,a[1]=d,a[2]=e,a[3]=Math.sqrt(Math.abs(1-c*c-d*d-e*e)),a},n.dot=i.dot,n.lerp=i.lerp,n.slerp=function(a,b,c,d){var e,f,g,h,i,j=b[0],k=b[1],l=b[2],m=b[3],n=c[0],o=c[1],p=c[2],q=c[3];return f=j*n+k*o+l*p+m*q,0>f&&(f=-f,n=-n,o=-o,p=-p,q=-q),1-f>1e-6?(e=Math.acos(f),g=Math.sin(e),h=Math.sin((1-d)*e)/g,i=Math.sin(d*e)/g):(h=1-d,i=d),a[0]=h*j+i*n,a[1]=h*k+i*o,a[2]=h*l+i*p,a[3]=h*m+i*q,a},n.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c*c+d*d+e*e+f*f,h=g?1/g:0;return a[0]=-c*h,a[1]=-d*h,a[2]=-e*h,a[3]=f*h,a},n.conjugate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=b[3],a},n.length=i.length,n.len=n.length,n.squaredLength=i.squaredLength,n.sqrLen=n.squaredLength,n.normalize=i.normalize,n.fromMat3=function(a,b){var c,d=b[0]+b[4]+b[8];if(d>0)c=Math.sqrt(d+1),a[3]=.5*c,c=.5/c,a[0]=(b[5]-b[7])*c,a[1]=(b[6]-b[2])*c,a[2]=(b[1]-b[3])*c;else{var e=0;b[4]>b[0]&&(e=1),b[8]>b[3*e+e]&&(e=2);var f=(e+1)%3,g=(e+2)%3;c=Math.sqrt(b[3*e+e]-b[3*f+f]-b[3*g+g]+1),a[e]=.5*c,c=.5/c,a[3]=(b[3*f+g]-b[3*g+f])*c,a[f]=(b[3*f+e]+b[3*e+f])*c,a[g]=(b[3*g+e]+b[3*e+g])*c}return a},n.str=function(a){return"quat("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},"undefined"!=typeof a&&(a.quat=n)}(b.exports)}(this);var Q_X=0,Q_Y=1,Q_Z=2,Q_W=3;dualQuat.prototype.reset=function(){quat.identity(this.real),this.real[Q_W]=0,quat.identity(this.imaginary),this.imaginary[Q_W]=0,quat.identity(this.tmpQ1)},dualQuat.prototype.createFromData=function(a,b){this.real=a,this.imaginary=quat.create(),this.imaginary[Q_W]=-.5*(b[Q_X]*a[Q_X]+b[Q_Y]*a[Q_Y]+b[Q_Z]*a[Q_Z]),this.imaginary[Q_X]=.5*(b[Q_X]*a[Q_W]+b[Q_Y]*a[Q_Z]-b[Q_Z]*a[Q_Y]),this.imaginary[Q_Y]=.5*(-b[Q_X]*a[Q_Z]+b[Q_Y]*a[Q_W]+b[Q_Z]*a[Q_X]),this.imaginary[Q_Z]=.5*(b[Q_X]*a[Q_Y]-b[Q_Y]*a[Q_X]+b[Q_Z]*a[Q_W])},dualQuat.prototype.add=function(a,b,c){quat.copy(this.tmpQ1,a.real),quat.scale(this.tmpQ1,this.tmpQ1,b),quat.add(this.real,this.tmpQ1,this.real),quat.copy(this.tmpQ1,a.imaginary), quat.scale(this.tmpQ1,this.tmpQ1,c),quat.add(this.imaginary,this.tmpQ1,this.imaginary)},dualQuat.prototype.normalize=function(){var a=quat.length(this.real);this.real=quat.scale(this.real,this.real,1/a),this.imaginary=quat.scale(this.imaginary,this.imaginary,1/a)};var v0=vec3.create(),ve=vec3.create(),trans=vec3.create(),tmpVec1=vec3.create(),tmpVec2=vec3.create(),tmpVec0=vec3.create(),aVec=vec3.create(),rot=vec3.create();dualQuat.prototype.transform=function(a){return v0[Q_X]=this.real[Q_X],v0[Q_Y]=this.real[Q_Y],v0[Q_Z]=this.real[Q_Z],ve[Q_X]=this.imaginary[Q_X],ve[Q_Y]=this.imaginary[Q_Y],ve[Q_Z]=this.imaginary[Q_Z],tmpVec1=vec3.scale(tmpVec1,v0,this.imaginary[Q_W]),tmpVec2=vec3.cross(tmpVec2,v0,ve),tmpVec0=vec3.scale(tmpVec0,ve,this.real[Q_W]),aVec=vec3.subtract(aVec,tmpVec0,tmpVec1),trans=vec3.add(trans,aVec,tmpVec2),trans=vec3.scale(trans,trans,2),rot=vec3.transformQuat(rot,a,this.real),rot=vec3.add(rot,rot,trans)};var Utils={};Utils.setAxisMatrix=function(a,b,c){var d=mat4.create(),e=0,f=4,g=8,h=12,i=1,j=5,k=9,l=13,m=2,n=6,o=10,p=14,q=3,r=7,s=11,t=15;return d[e]=a[Q_X],d[f]=a[Q_Y],d[g]=a[Q_Z],d[i]=b[Q_X],d[j]=b[Q_Y],d[k]=b[Q_Z],d[m]=c[Q_X],d[n]=c[Q_Y],d[o]=c[Q_Z],d[h]=0,d[l]=0,d[p]=0,d[q]=0,d[r]=0,d[s]=0,d[t]=1,d=mat4.transpose(d,d)},Utils.matrixToQuat=function(a){var b,c=quat.create(),d=a,e=d[0],f=d[4],g=d[8],h=d[1],i=d[5],j=d[9],k=d[2],l=d[6],m=d[10],n=e+i+m;return n>0?(b=.5/Math.sqrt(n+1),c[Q_W]=.25/b,c[Q_X]=(l-j)*b,c[Q_Y]=(g-k)*b,c[Q_Z]=(h-f)*b):e>i&&e>m?(b=2*Math.sqrt(1+e-i-m),c[Q_W]=(l-j)/b,c[Q_X]=.25*b,c[Q_Y]=(f+h)/b,c[Q_Z]=(g+k)/b):i>m?(b=2*Math.sqrt(1+i-e-m),c[Q_W]=(g-k)/b,c[Q_X]=(f+h)/b,c[Q_Y]=.25*b,c[Q_Z]=(j+l)/b):(b=2*Math.sqrt(1+m-e-i),c[Q_W]=(h-f)/b,c[Q_X]=(g+k)/b,c[Q_Y]=(j+l)/b,c[Q_Z]=.25*b),c},Utils.rotateVec_90=function(a){var b=vec3.fromValues(-a[Q_Y],a[Q_X],a[Q_Z]);return b},Utils.calcRotateMat=function(a){var b=vec3.clone(a);b=vec3.normalize(b,b);var c=Utils.rotateVec_90(b),d=vec3.fromValues(b[Q_X],b[Q_Y],0),e=vec3.fromValues(c[Q_X],c[Q_Y],0),f=vec3.fromValues(0,0,1),g=mat4.create();return g=Utils.setAxisMatrix(d,e,f)},Utils.getMatTranslate=function(a){var b=vec3.create();return b[Q_X]=a[12],b[Q_Y]=a[13],b[Q_Z]=a[14],b},Utils.addMat=function(a,b){for(var c=mat4.create(),d=0;16>d;d++)c[d]=a[d]+b[d];return c},Utils.mulMat=function(a,b){for(var c=mat4.create(),d=0;16>d;d++)c[d]=a[d]*b;return c},Utils.clamp=function(a,b,c){return b>a?b:a>c?c:a};var newVec1=vec3.create(),newVec2=vec3.create();Utils.vecInterp=function(a,b,c){newVec1=vec3.scale(newVec1,a,1-c),newVec2=vec3.scale(newVec2,b,c);var d=vec3.create();return d=vec3.add(d,newVec1,newVec2)},Utils.vec2Interp=function(a,b,c){var d=vec2.create(),e=vec2.create();d=vec2.scale(d,a,1-c),e=vec2.scale(e,b,c);var f=vec2.create();return f=vec2.add(f,d,e)},MeshBone.prototype.setRestParentMat=function(a,b){this.rest_parent_mat=a,null==b?(this.rest_parent_inv_mat=mat4.clone(this.rest_parent_mat),mat4.invert(this.rest_parent_inv_mat,this.rest_parent_inv_mat)):this.rest_parent_inv_mat=mat4.clone(b)},MeshBone.prototype.setParentWorldMat=function(a){this.parent_world_mat=a},MeshBone.prototype.setParentWorldInvMat=function(a){this.parent_world_inv_mat=a},MeshBone.prototype.getLocalRestStartPt=function(){return this.local_rest_start_pt},MeshBone.prototype.getLocalRestEndPt=function(){return this.local_rest_end_pt},MeshBone.prototype.setLocalRestStartPt=function(a){this.local_rest_start_pt=vec3.create(),this.local_rest_start_pt=vec3.transformMat4(this.local_rest_start_pt,a,this.rest_parent_inv_mat),this.calcRestData()},MeshBone.prototype.setLocalRestEndPt=function(a){this.local_rest_end_pt=vec3.create(),this.local_rest_end_pt=vec3.transformMat4(this.local_rest_end_pt,a,this.rest_parent_inv_mat),this.calcRestData()},MeshBone.prototype.calcRestData=function(){if(null!=this.local_rest_start_pt&&null!=this.local_rest_end_pt){var a=this.computeDirs(this.local_rest_start_pt,this.local_rest_end_pt);this.local_rest_dir=a.first,this.local_rest_normal_dir=a.second,this.computeRestLength()}},MeshBone.prototype.setWorldStartPt=function(a){this.world_start_pt=a},MeshBone.prototype.setWorldEndPt=function(a){this.world_end_pt=a},MeshBone.prototype.fixDQs=function(a){quat.dot(this.world_dq.real,a.real)<0&&(this.world_dq.real=quat.scale(this.world_dq.real,this.world_dq.real,-1),this.world_dq.imaginary=quat.scale(this.world_dq.imaginary,this.world_dq.imaginary,-1));for(var b=0;bf;f++)accum_mat[f]=0;for(var g=Object.keys(c),f=(g.length,0),h=this.getNumPts();h>f;f++){var i=vec3.set(tmp1,this.store_rest_pts[0+d],this.store_rest_pts[1+d],this.store_rest_pts[2+d]);1==this.use_local_displacements&&(i[Q_X]+=this.local_displacements[f][Q_X],i[Q_Y]+=this.local_displacements[f][Q_Y]);for(var j=0;16>j;j++)accum_mat[j]=0;accum_dq.reset();for(var k=this.relevant_bones_indices[f],l=k.length,j=0;l>j;j++){var m=k[j],n=this.fast_bones_map[m],o=this.fast_normal_weight_map[m][f],p=o,q=n.getWorldDq();accum_dq.add(q,o,p)}accum_dq.normalize();var r=vec3.set(tmp2,i[Q_X],i[Q_Y],i[Q_Z]);final_pt=accum_dq.transform(r),1==this.use_post_displacements&&(final_pt[Q_X]+=this.post_displacements[f][Q_X],final_pt[Q_Y]+=this.post_displacements[f][Q_Y]),a[0+e]=final_pt[Q_X],a[1+e]=final_pt[Q_Y],a[2+e]=final_pt[Q_Z],d+=3,e+=3}1==this.use_uv_warp&&this.runUvWarp()},MeshRenderRegion.prototype.setMainBoneKey=function(a){this.main_bone_key=a},MeshRenderRegion.prototype.determineMainBone=function(a){this.main_bone=a.getChildByKey(this.main_bone_key)},MeshRenderRegion.prototype.setUseDq=function(a){this.use_dq=a},MeshRenderRegion.prototype.setName=function(a){this.name=a},MeshRenderRegion.prototype.getName=function(){return this.name},MeshRenderRegion.prototype.setUseLocalDisplacements=function(a){if(this.use_local_displacements=a,this.local_displacements.length!=this.getNumPts()&&this.use_local_displacements){this.local_displacements=[];for(var b=0;bd&&f.push(g)}this.relevant_bones_indices.push(f)}for(var b in a){var i=a[b];this.fast_bones_map.push(i)}},MeshRenderRegion.prototype.initUvWarp=function(){var a=this.getUVsIndex();this.uv_warp_ref_uvs=[];for(var b=0;bd;d++)this.bone_cache_table.push([]),this.bone_cache_data_ready.push(!1);this.is_ready=!1},MeshBoneCacheManager.prototype.getStartTime=function(){return this.start_time},MeshBoneCacheManager.prototype.getEndime=function(){return this.end_time},MeshBoneCacheManager.prototype.getIndexByTime=function(a){var b=a-this.start_time;return b=Utils.clamp(b,0,this.bone_cache_table.length-1)},MeshBoneCacheManager.prototype.retrieveValuesAtTime=function(a,b){var c=this.getIndexByTime(Math.floor(a)),d=this.getIndexByTime(Math.ceil(a)),e=a-Math.floor(a);if(0!=this.bone_cache_data_ready.length&&0!=this.bone_cache_data_ready[c]&&0!=this.bone_cache_data_ready[d])for(var f=this.bone_cache_table[c],g=this.bone_cache_table[d],h=0,i=f.length;i>h;h++){var j=f[h],k=g[h],l=j.getKey(),m=Utils.vecInterp(j.getWorldStartPt(),k.getWorldStartPt(),e),n=Utils.vecInterp(j.getWorldEndPt(),k.getWorldEndPt(),e);b[l].setWorldStartPt(m),b[l].setWorldEndPt(n)}},MeshBoneCacheManager.prototype.allReady=function(){if(this.is_ready)return!0;for(var a=this.end_time-this.start_time+1,b=0,c=0;cd;d++)this.displacement_cache_table.push([]),this.displacement_cache_data_ready.push(!1);this.is_ready=!1},MeshDisplacementCacheManager.prototype.getStartTime=function(){return this.start_time},MeshDisplacementCacheManager.prototype.getEndime=function(){return this.end_time},MeshDisplacementCacheManager.prototype.getIndexByTime=function(a){var b=a-this.start_time;return b=Utils.clamp(b,0,this.displacement_cache_table.length-1)},MeshDisplacementCacheManager.prototype.retrieveValuesAtTime=function(a,b){var c=this.getIndexByTime(Math.floor(a)),d=this.getIndexByTime(Math.ceil(a)),e=a-Math.floor(a);if(0!=this.displacement_cache_data_ready.length&&0!=this.displacement_cache_data_ready[c]&&0!=this.displacement_cache_data_ready[d])for(var f=this.displacement_cache_table[c],g=this.displacement_cache_table[d],h=0;hd;d++)this.uv_cache_table.push([]),this.uv_cache_data_ready.push(!1);this.is_ready=!1},MeshUVWarpCacheManager.prototype.getStartTime=function(){return this.start_time},MeshUVWarpCacheManager.prototype.getEndime=function(){return this.end_time},MeshUVWarpCacheManager.prototype.getIndexByTime=function(a){var b=a-this.start_time;return b=Utils.clamp(b,0,this.uv_cache_table.length-1)},MeshUVWarpCacheManager.prototype.retrieveValuesAtTime=function(a,b){var c=this.getIndexByTime(Math.floor(a)),d=this.getIndexByTime(Math.ceil(a));a-Math.floor(a);if(0!=this.uv_cache_data_ready.length&&0!=this.uv_cache_data_ready[c]&&0!=this.uv_cache_data_ready[d])for(var e=this.uv_cache_table[c],f=this.uv_cache_table[d],g=0;gf;f++){var g=2*f;d.push(vec2.fromValues(c[0+g],c[1+g]))}return d},CreatureModuleUtils.ReadFloatArray3DJSON=function(a,b){for(var c=CreatureModuleUtils.getFloatArray(a[b]),d=[],e=c.length/2,f=0;e>f;f++){var g=2*f;d.push(c[0+g]),d.push(c[1+g]),d.push(0)}return d},CreatureModuleUtils.ReadBoolJSON=function(a,b){var c=a[b];return c},CreatureModuleUtils.ReadFloatArrayJSON=function(a,b){return a[b]},CreatureModuleUtils.ReadIntArrayJSON=function(a,b){return a[b]},CreatureModuleUtils.ReadMatrixJSON=function(a,b){for(var c=CreatureModuleUtils.getFloatArray(a[b]),d=mat4.create(),e=0;16>e;e++)d[e]=c[e];return d},CreatureModuleUtils.ReadVector2JSON=function(a,b){var c=CreatureModuleUtils.getFloatArray(a[b]);return vec2.fromValues(c[0],c[1])},CreatureModuleUtils.ReadVector3JSON=function(a,b){var c=CreatureModuleUtils.getFloatArray(a[b]);return vec3.fromValues(c[0],c[1],0)},CreatureModuleUtils.CreateBones=function(a,b){var c=null,d=a[b],e={},f={};for(var g in d){var h=d[g],i=h.id,j=CreatureModuleUtils.ReadMatrixJSON(h,"restParentMat"),k=CreatureModuleUtils.ReadVector3JSON(h,"localRestStartPt"),l=CreatureModuleUtils.ReadVector3JSON(h,"localRestEndPt"),m=CreatureModuleUtils.ReadIntArrayJSON(h,"children"),n=new MeshBone(g,vec3.create(),vec3.create(),j);n.local_rest_start_pt=k,n.local_rest_end_pt=l,n.calcRestData(),n.setTagId(i),e[i]={first:n,second:m};for(var o=0;od&&(d=h),c>h&&(c=h))}return{first:c,second:d}},CreatureModuleUtils.FillBoneCache=function(a,b,c,d,e){var f=a[b];e.init(c,d);for(var g in f){var h=f[g];cache_list=[];for(var i in h){var j=h[i],k=CreatureModuleUtils.ReadVector3JSON(j,"start_pt"),l=CreatureModuleUtils.ReadVector3JSON(j,"end_pt"),m=new MeshBoneCache(i);m.setWorldStartPt(k),m.setWorldEndPt(l),cache_list.push(m)}var n=e.getIndexByTime(g);e.bone_cache_table[n]=cache_list}e.makeAllReady()},CreatureModuleUtils.FillDeformationCache=function(a,b,c,d,e){var f=a[b];e.init(c,d);for(var g in f){var h=f[g],i=[];for(var j in h){var k=h[j],l=new MeshDisplacementCache(j),m=CreatureModuleUtils.ReadBoolJSON(k,"use_local_displacements"),n=CreatureModuleUtils.ReadBoolJSON(k,"use_post_displacements");if(1==m){var o=CreatureModuleUtils.ReadPointsArray2DJSON(k,"local_displacements");l.setLocalDisplacements(o)}if(1==n){var o=CreatureModuleUtils.ReadPointsArray2DJSON(k,"post_displacements");l.setPostDisplacements(o)}i.push(l)}var p=e.getIndexByTime(g);e.displacement_cache_table[p]=i}e.makeAllReady()},CreatureModuleUtils.FillUVSwapCache=function(a,b,c,d,e){var f=a[b];e.init(c,d);for(var g in f){var h=f[g],i=[];for(var j in h){var k=h[j],l=new MeshUVWarpCache(j),m=CreatureModuleUtils.ReadBoolJSON(k,"enabled");if(l.setEnabled(m),1==m){var n=CreatureModuleUtils.ReadVector2JSON(k,"local_offset"),o=CreatureModuleUtils.ReadVector2JSON(k,"global_offset"),p=CreatureModuleUtils.ReadVector2JSON(k,"scale");l.setUvWarpLocalOffset(n),l.setUvWarpGlobalOffset(o),l.setUvWarpScale(p)}i.push(l)}var q=e.getIndexByTime(g);e.uv_cache_table[q]=i}e.makeAllReady()},Creature.prototype.FillRenderColours=function(a,b,c,d){for(var e=0;e=h&&i>=d){e=!0;break}}e&&a[d]++}this.boundary_indices=[];for(var b=0;bf&&(b[0]=f),b[1]>g&&(b[1]=g),c[0]m;m++)g[j+0]=(1-f)*h[k+0]+f*i[l+0],g[j+1]=(1-f)*h[k+1]+f*i[l+1],g[j+2]=(1-f)*h[k+2]+f*i[l+2],j+=3,k+=3,l+=3},CreatureManager.prototype.CreateAnimation=function(a,b){var c=new CreatureAnimation(a,b);this.AddAnimation(c)},CreatureManager.prototype.CreateAllAnimations=function(a){for(var b=CreatureModuleUtils.GetAllAnimationNames(a),c=0;c0)){for(var d=c.cache_pts,e=c.start_time;e<=c.end_time;e++){this.setRunTime(e);for(var f=[],g=0;g<3*this.target_creature.total_num_pts;g++)f[g]=0;this.PoseCreature(a,f),d.push(f)}this.setRunTime(b)}},CreatureManager.prototype.FillSinglePointCacheFrame=function(a,b){var c=this.getRunTime(),d=this.animations[a];this.setRunTime(b);for(var e=[],f=0;f<3*this.target_creature.total_num_pts;f++)e[f]=0;this.PoseCreature(a,e),d.fill_cache_pts.push(e),d.verifyFillCache(),this.setRunTime(c)},CreatureManager.prototype.GetIsPlaying=function(){return this.is_playing},CreatureManager.prototype.SetShouldLoop=function(a){this.should_loop=a},CreatureManager.prototype.SetUseCustomTimeRange=function(a){this.use_custom_time_range=a},CreatureManager.prototype.SetCustomTimeRange=function(a,b){this.custom_start_time=a,this.custom_end_time=b},CreatureManager.prototype.SetIsPlaying=function(a){this.is_playing=a},CreatureManager.prototype.ResetToStartTimes=function(){var a=this.animations[active_animation_name];this.run_time=a.start_time},CreatureManager.prototype.setRunTime=function(a){this.run_time=a,this.correctTime()},CreatureManager.prototype.increRunTime=function(a){this.run_time+=a,this.correctTime()},CreatureManager.prototype.correctTime=function(){var a=this.animations[this.active_animation_name],b=a.start_time,c=a.end_time;this.use_custom_time_range&&(b=this.custom_start_time,c=this.custom_end_time),this.run_time>c?this.should_loop?this.run_time=b:this.run_time=c:this.run_timea;a++){var b=this.animations[this.active_blend_animation_names[a]];b.cache_pts.length>0?b.poseFromCachePts(this.getRunTime(),this.blend_render_pts[a],this.target_creature.total_num_pts):this.PoseCreature(this.active_blend_animation_names[a],this.blend_render_pts[a])}for(var c=0;c<3*this.target_creature.total_num_pts;c++){var d=c,e=this.blend_render_pts[0][c],f=this.blend_render_pts[1][c];this.target_creature.render_pts.set(d,(1-blending_factor)*e+blending_factor*f)}}else{var b=this.animations[this.active_animation_name];b.cache_pts.length>0?b.poseFromCachePts(this.getRunTime(),this.target_creature.render_pts,this.target_creature.total_num_pts):this.PoseCreature(this.active_animation_name,this.target_creature.render_pts)}},CreatureManager.prototype.SetTimeScale=function(a){this.time_scale=a},CreatureManager.prototype.SetBlending=function(a){if(this.do_blending=a,this.do_blending){if(0==this.blend_render_pts[0].length){for(var b=[],c=0;c<3*target_creature.total_num_pts;c++)b.push(0);this.blend_render_pts.set(0,b)}if(0==this.blend_render_pts[1].length){for(var b=[],c=0;c<3*this.target_creature.total_num_pts;c++)b.push(0);this.blend_render_pts[1]=b}}},CreatureManager.prototype.SetBlendingAnimations=function(a,b){this.active_blend_animation_names[0]=a,this.active_blend_animation_names[1]=b},CreatureManager.prototype.SetBlendingFactor=function(a){this.blending_factor=a},CreatureManager.prototype.IsContactBone=function(a,b){var c=this.target_creature.render_composition.getRootBone();return this.ProcessContactBone(a,b,c)},CreatureManager.prototype.PoseCreature=function(a,b){var c=this.animations[a],d=c.bones_cache,e=c.displacement_cache,f=c.uv_warp_cache,g=this.target_creature.render_composition,h=g.getBonesMap(),i=g.getRegionsMap();d.retrieveValuesAtTime(this.getRunTime(),h),null!=this.bones_override_callback&&this.bones_override_callback(h),e.retrieveValuesAtTime(this.getRunTime(),i),f.retrieveValuesAtTime(this.getRunTime(),i);var j=g.getRegions(),k=g.getBonesMap();g.updateAllTransforms(!1);for(var l=0,m=j.length;m>l;l++){var n=j[l],o=n.getStartPtIndex();n.poseFinalPts(b,3*o,k);for(var p=3*n.getStartPtIndex(),q=3*n.getEndPtIndex(),r=p;q>=r;r+=3)b[r+2]=.001*-l}}; //# sourceMappingURL=creature.map