phaser/build/creature.min.js
2016-08-26 01:24:15 +01:00

6 lines
No EOL
68 KiB
JavaScript

/* Phaser v2.6.2 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;h<i;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;h<i;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;h<i;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)<b?null:(G=1/G,D*=G,E*=G,F*=G,f=Math.sin(d),g=Math.cos(d),h=1-g,i=c[0],j=c[1],k=c[2],l=c[3],m=c[4],n=c[5],o=c[6],p=c[7],q=c[8],r=c[9],s=c[10],t=c[11],u=D*D*h+g,v=E*D*h+F*f,w=F*D*h-E*f,x=D*E*h-F*f,y=E*E*h+g,z=F*E*h+D*f,A=D*F*h+E*f,B=E*F*h-D*f,C=F*F*h+g,a[0]=i*u+m*v+q*w,a[1]=j*u+n*v+r*w,a[2]=k*u+o*v+s*w,a[3]=l*u+p*v+t*w,a[4]=i*x+m*y+q*z,a[5]=j*x+n*y+r*z,a[6]=k*x+o*y+s*z,a[7]=l*x+p*y+t*z,a[8]=i*A+m*B+q*C,a[9]=j*A+n*B+r*C,a[10]=k*A+o*B+s*C,a[11]=l*A+p*B+t*C,c!==a&&(a[12]=c[12],a[13]=c[13],a[14]=c[14],a[15]=c[15]),a)},m.rotateX=function(a,b,c){var d=Math.sin(c),e=Math.cos(c),f=b[4],g=b[5],h=b[6],i=b[7],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=f*e+j*d,a[5]=g*e+k*d,a[6]=h*e+l*d,a[7]=i*e+m*d,a[8]=j*e-f*d,a[9]=k*e-g*d,a[10]=l*e-h*d,a[11]=m*e-i*d,a},m.rotateY=function(a,b,c){var d=Math.sin(c),e=Math.cos(c),f=b[0],g=b[1],h=b[2],i=b[3],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[0]=f*e-j*d,a[1]=g*e-k*d,a[2]=h*e-l*d,a[3]=i*e-m*d,a[8]=f*d+j*e,a[9]=g*d+k*e,a[10]=h*d+l*e,a[11]=i*d+m*e,a},m.rotateZ=function(a,b,c){var d=Math.sin(c),e=Math.cos(c),f=b[0],g=b[1],h=b[2],i=b[3],j=b[4],k=b[5],l=b[6],m=b[7];return b!==a&&(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[0]=f*e+j*d,a[1]=g*e+k*d,a[2]=h*e+l*d,a[3]=i*e+m*d,a[4]=j*e-f*d,a[5]=k*e-g*d,a[6]=l*e-h*d,a[7]=m*e-i*d,a},m.fromRotationTranslation=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=d+d,i=e+e,j=f+f,k=d*h,l=d*i,m=d*j,n=e*i,o=e*j,p=f*j,q=g*h,r=g*i,s=g*j;return a[0]=1-(n+p),a[1]=l+s,a[2]=m-r,a[3]=0,a[4]=l-s,a[5]=1-(k+p),a[6]=o+q,a[7]=0,a[8]=m+r,a[9]=o-q,a[10]=1-(k+n),a[11]=0,a[12]=c[0],a[13]=c[1],a[14]=c[2],a[15]=1,a},m.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[1]=k+r,a[2]=m-q,a[3]=0,a[4]=k-r,a[5]=1-j-o,a[6]=n+p,a[7]=0,a[8]=m+q,a[9]=n-p,a[10]=1-j-l,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},m.frustum=function(a,b,c,d,e,f,g){var h=1/(c-b),i=1/(e-d),j=1/(f-g);return a[0]=2*f*h,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=2*f*i,a[6]=0,a[7]=0,a[8]=(c+b)*h,a[9]=(e+d)*i,a[10]=(g+f)*j,a[11]=-1,a[12]=0,a[13]=0,a[14]=g*f*2*j,a[15]=0,a},m.perspective=function(a,b,c,d,e){var f=1/Math.tan(b/2),g=1/(d-e);return a[0]=f/c,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=f,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=(e+d)*g,a[11]=-1,a[12]=0,a[13]=0,a[14]=2*e*d*g,a[15]=0,a},m.ortho=function(a,b,c,d,e,f,g){var h=1/(b-c),i=1/(d-e),j=1/(f-g);return a[0]=-2*h,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=-2*i,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=2*j,a[11]=0,a[12]=(b+c)*h,a[13]=(e+d)*i,a[14]=(g+f)*j,a[15]=1,a},m.lookAt=function(a,c,d,e){var f,g,h,i,j,k,l,n,o,p,q=c[0],r=c[1],s=c[2],t=e[0],u=e[1],v=e[2],w=d[0],x=d[1],y=d[2];return Math.abs(q-w)<b&&Math.abs(r-x)<b&&Math.abs(s-y)<b?m.identity(a):(l=q-w,n=r-x,o=s-y,p=1/Math.sqrt(l*l+n*n+o*o),l*=p,n*=p,o*=p,f=u*o-v*n,g=v*l-t*o,h=t*n-u*l,p=Math.sqrt(f*f+g*g+h*h),p?(p=1/p,f*=p,g*=p,h*=p):(f=0,g=0,h=0),i=n*h-o*g,j=o*f-l*h,k=l*g-n*f,p=Math.sqrt(i*i+j*j+k*k),p?(p=1/p,i*=p,j*=p,k*=p):(i=0,j=0,k=0),a[0]=f,a[1]=i,a[2]=l,a[3]=0,a[4]=g,a[5]=j,a[6]=n,a[7]=0,a[8]=h,a[9]=k,a[10]=o,a[11]=0,a[12]=-(f*q+g*r+h*s),a[13]=-(i*q+j*r+k*s),a[14]=-(l*q+n*r+o*s),a[15]=1,a)},m.str=function(a){return"mat4("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+", "+a[9]+", "+a[10]+", "+a[11]+", "+a[12]+", "+a[13]+", "+a[14]+", "+a[15]+")"},m.frob=function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2)+Math.pow(a[4],2)+Math.pow(a[5],2)+Math.pow(a[6],2)+Math.pow(a[7],2)+Math.pow(a[8],2)+Math.pow(a[9],2)+Math.pow(a[10],2)+Math.pow(a[11],2)+Math.pow(a[12],2)+Math.pow(a[13],2)+Math.pow(a[14],2)+Math.pow(a[15],2))},"undefined"!=typeof a&&(a.mat4=m);var n={};n.create=function(){var a=new c(4);return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a},n.rotationTo=function(){var a=h.create(),b=h.fromValues(1,0,0),c=h.fromValues(0,1,0);return function(d,e,f){var g=h.dot(e,f);return g<-.999999?(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,f<0&&(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;d<16;d++)c[d]=a[d]+b[d];return c},Utils.mulMat=function(a,b){for(var c=mat4.create(),d=0;d<16;d++)c[d]=a[d]*b;return c},Utils.clamp=function(a,b,c){return a<b?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;b<this.children.length;b++){var c=this.children[b];c.fixDQs(this.world_dq)}},MeshBone.prototype.initWorldPts=function(){this.setWorldStartPt(this.getWorldRestStartPt()),this.setWorldEndPt(this.getWorldRestEndPt());for(var a=0;a<this.children.length;a++)this.children[a].initWorldPts()},MeshBone.prototype.getWorldRestStartPt=function(){var a=this.rest_parent_mat,b=vec3.create();return b=vec3.transformMat4(b,this.local_rest_start_pt,a)},MeshBone.prototype.getWorldRestEndPt=function(){var a=this.rest_parent_mat,b=vec3.create();return b=vec3.transformMat4(b,this.local_rest_end_pt,a)},MeshBone.prototype.getWorldRestAngle=function(){return this.world_rest_angle},MeshBone.prototype.getWorldRestPos=function(){return this.world_rest_pos},MeshBone.prototype.getWorldStartPt=function(){return this.world_start_pt},MeshBone.prototype.getWorldEndPt=function(){return this.world_end_pt},MeshBone.prototype.getRestParentMat=function(){return this.rest_parent_mat},MeshBone.prototype.getRestWorldMat=function(){return this.rest_world_mat},MeshBone.prototype.getWorldDeltaMat=function(){return this.world_delta_mat},MeshBone.prototype.getParentWorldMat=function(){return this.parent_world_mat},MeshBone.prototype.getParentWorldInvMat=function(){return this.parent_world_inv_mat},MeshBone.prototype.getWorldDq=function(){return this.world_dq},MeshBone.prototype.computeRestParentTransforms=function(){var a=vec3.fromValues(this.local_rest_dir[Q_X],this.local_rest_dir[Q_Y],0),b=vec3.fromValues(this.local_binormal_dir[Q_X],this.local_binormal_dir[Q_Y],this.local_binormal_dir[Q_Z]),c=vec3.fromValues(this.local_rest_normal_dir[Q_X],this.local_rest_normal_dir[Q_Y],0),d=mat4.create();mat4.translate(d,d,this.local_rest_end_pt);var e=mat4.create();e=Utils.setAxisMatrix(a,c,b);var f=mat4.create();f=mat4.multiply(f,d,e),this.rest_world_mat=mat4.create(),this.rest_world_mat=mat4.multiply(this.rest_world_mat,this.rest_parent_mat,f),this.rest_world_inv_mat=mat4.clone(this.rest_world_mat),this.rest_world_inv_mat=mat4.invert(this.rest_world_inv_mat,this.rest_world_inv_mat);var g=vec3.clone(this.getWorldRestEndPt());g=vec3.subtract(g,g,this.getWorldRestStartPt()),g=vec3.normalize(g,g),this.world_rest_pos=this.getWorldRestStartPt();var h=mat4.create();h=mat4.translate(h,h,this.getWorldRestStartPt());var i=vec3.create();i=vec3.sub(i,this.getWorldRestEndPt(),this.getWorldRestStartPt());var j=Utils.calcRotateMat(i),k=mat4.create();k=mat4.multiply(k,h,j),this.bind_world_mat=mat4.clone(k),this.bind_world_inv_mat=mat4.clone(this.bind_world_mat),this.bind_world_inv_mat=mat4.invert(this.bind_world_inv_mat,this.bind_world_inv_mat);for(var l=0;l<this.children.length;l++){var m=this.children[l];m.setRestParentMat(this.rest_world_mat,this.rest_world_inv_mat),m.computeRestParentTransforms()}},MeshBone.prototype.computeParentTransforms=function(){var a=mat4.create();a=mat4.translate(a,a,this.getWorldEndPt());var b=vec3.create();b=vec3.subtract(b,this.getWorldEndpt(),this.getWorldStartPt());var c=Utils.calcRotateMat(b),d=mat4.create();d=mat4.multiply(d,a,c);var e=mat4.clone(d);e=mat4.invert(e,e);for(var f=0;f<children.length;f++){var g=children[f];g.setParentWorldMat(d),g.setParentWorldInvMat(e),g.computeParentTransforms()}},MeshBone.prototype.computeWorldDeltaTransforms=function(){var a=this.computeDirs(this.world_start_pt,this.world_end_pt),b=vec3.fromValues(a.first[Q_X],a.first[Q_Y],0),c=vec3.fromValues(a.second[Q_X],a.second[Q_Y],0),d=vec3.fromValues(this.local_binormal_dir[Q_X],this.local_binormal_dir[Q_Y],this.local_binormal_dir[Q_Z]),e=mat4.create();e=Utils.setAxisMatrix(b,c,d);var f=mat4.create();f=mat4.translate(f,f,this.world_start_pt),this.world_delta_mat=mat4.create(),this.world_delta_mat=mat4.multiply(this.world_delta_mat,f,e),this.world_delta_mat=mat4.multiply(this.world_delta_mat,this.world_delta_mat,this.bind_world_inv_mat);var g=Utils.matrixToQuat(this.world_delta_mat),h=Utils.getMatTranslate(this.world_delta_mat);this.world_dq=new dualQuat,this.world_dq.createFromData(g,h);for(var i=0;i<this.children.length;i++){var j=this.children[i];j.computeWorldDeltaTransforms()}},MeshBone.prototype.addChild=function(a){a.setRestParentMat(this.rest_world_mat,this.rest_world_inv_mat),this.children.push(a)},MeshBone.prototype.getChildren=function(){return this.children},MeshBone.prototype.hasBone=function(a){for(var b=0;b<this.children.length;b++){var c=this.children[b];if(c==a)return!0}return!1},MeshBone.prototype.getChildByKey=function(a){if(this.key===a)return this;for(var b=null,c=0;c<this.children.length;c++){var d=this.children[c],e=d.getChildByKey(a);if(null!=e){b=e;break}}return b},MeshBone.prototype.getKey=function(){return this.key},MeshBone.prototype.getAllBoneKeys=function(){var a=[];a.push(this.getKey());for(var b=0;b<this.children.length;b++){var c=this.children[b].getAllBoneKeys();a=a.concat(c)}return a},MeshBone.prototype.getAllChildren=function(){var a=[];a.push(this);for(var b=0;b<this.children.length;b++){var c=this.children[b].getAllChildren();a=a.concat(c)}return a},MeshBone.prototype.getBoneDepth=function(a,b){if(a==this)return b;for(var c=0;c<this.children.length;c++){var d=this.children[c],e=d.getBoneDepth(a,b+1);if(e!=-1)return e}return-1},MeshBone.prototype.isLeaf=function(){return 0==this.children.length},MeshBone.prototype.deleteChildren=function(){for(var a=0;a<this.children.length;a++){var b=this.children[a];b.deleteChildren()}this.children=[]},MeshBone.prototype.setTagId=function(a){this.tag_id=a},MeshBone.prototype.getTagId=function(){return this.tag_id},MeshBone.prototype.computeDirs=function(a,b){var c=vec3.create();c=vec3.subtract(c,b,a),c=vec3.normalize(c,c);var d=Utils.rotateVec_90(c),e={};return e.first=c,e.second=d,e},MeshBone.prototype.computeRestLength=function(){var a=vec3.create();a=vec3.subtract(a,this.local_rest_end_pt,this.local_rest_start_pt),this.rest_length=vec3.length(a)},MeshRenderRegion.prototype.getIndicesIndex=function(){return this.start_index},MeshRenderRegion.prototype.getRestPtsIndex=function(){return 3*this.start_pt_index},MeshRenderRegion.prototype.getUVsIndex=function(){return 2*this.start_pt_index},MeshRenderRegion.prototype.getNumPts=function(){return this.end_pt_index-this.start_pt_index+1},MeshRenderRegion.prototype.getStartPtIndex=function(){return this.start_pt_index},MeshRenderRegion.prototype.getEndPtIndex=function(){return this.end_pt_index},MeshRenderRegion.prototype.getNumIndices=function(){return this.end_index-this.start_index+1},MeshRenderRegion.prototype.getStartIndex=function(){return this.start_index},MeshRenderRegion.prototype.getEndIndex=function(){return this.end_index};var accum_dq=new dualQuat,accum_mat=mat4.create(),final_pt=vec3.create(),tmp1=vec3.create(),tmp2=vec3.create();MeshRenderRegion.prototype.poseFinalPts=function(a,b,c){for(var d=this.getRestPtsIndex(),e=b,f=0;f<16;f++)accum_mat[f]=0;for(var g=Object.keys(c),f=(g.length,0),h=this.getNumPts();f<h;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;j<16;j++)accum_mat[j]=0;accum_dq.reset();for(var k=this.relevant_bones_indices[f],l=k.length,j=0;j<l;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;b<this.getNumPts();b++)this.local_displacements.push(vec2.create())}},MeshRenderRegion.prototype.getUseLocalDisplacements=function(){return this.use_local_displacements},MeshRenderRegion.prototype.setUsePostDisplacements=function(a){if(this.use_post_displacements=a,this.post_displacements.length!=this.getNumPts()&&this.use_post_displacements){this.post_displacements=[];for(var b=0;b<this.getNumPts();b++)this.post_displacements.push(vec2.create())}},MeshRenderRegion.prototype.getUsePostDisplacements=function(){return this.use_post_displacements},MeshRenderRegion.prototype.getRestLocalPt=function(a){var b=this.getRestPtsIndex()+3*a,c=vec2.fromValues(this.store_rest_pts[0+b],this.store_rest_pts[1+b]);return c},MeshRenderRegion.prototype.getLocalIndex=function(a){var b=this.getIndicesIndex()+a;return this.store_indices[b]},MeshRenderRegion.prototype.clearLocalDisplacements=function(){for(var a=0;a<this.local_displacements.length;a++)this.local_displacements[a]=vec2.create()},MeshRenderRegion.prototype.clearPostDisplacements=function(){for(var a=0;a<this.post_displacements.length;a++)this.post_displacements[a]=vec2.create()},MeshRenderRegion.prototype.setUseUvWarp=function(a){this.use_uv_warp=a,0==this.use_uv_warp&&this.restoreRefUv()},MeshRenderRegion.prototype.getUseUvWarp=function(){return this.use_uv_warp},MeshRenderRegion.prototype.setUvWarpLocalOffset=function(a){this.uv_warp_local_offset=a},MeshRenderRegion.prototype.setUvWarpGlobalOffset=function(a){this.uv_warp_global_offset=a},MeshRenderRegion.prototype.setUvWarpScale=function(a){this.uv_warp_scale=a},MeshRenderRegion.prototype.getUvWarpLocalOffset=function(){return this.uv_warp_local_offset},MeshRenderRegion.prototype.getUvWarpGlobalOffset=function(){return this.uv_warp_global_offset},MeshRenderRegion.prototype.getUvWarpScale=function(){return this.uv_warp_scale},MeshRenderRegion.prototype.runUvWarp=function(){for(var a=this.getUVsIndex(),b=0;b<this.uv_warp_ref_uvs.length;b++){var c=vec2.clone(this.uv_warp_ref_uvs[b]);c=vec2.subtract(c,c,this.uv_warp_local_offset),c[Q_X]*=this.uv_warp_scale[Q_X],c[Q_Y]*=this.uv_warp_scale[Q_Y],c=vec2.add(c,c,this.uv_warp_global_offset),this.store_uvs[0+a]=c[Q_X],this.store_uvs[1+a]=c[Q_Y],a+=2}},MeshRenderRegion.prototype.restoreRefUv=function(){for(var a=this.getUVsIndex(),b=0;b<this.uv_warp_ref_uvs.length;b++){var c=this.uv_warp_ref_uvs[b];this.store_uvs[0+a]=c[Q_X],this.store_uvs[1+a]=c[Q_Y],a+=2}},MeshRenderRegion.prototype.getTagId=function(){return this.tag_id},MeshRenderRegion.prototype.setTagId=function(a){this.tag_id=a},MeshRenderRegion.prototype.initFastNormalWeightMap=function(a){this.relevant_bones_indices=[];for(var b in a){var c=this.normal_weight_map[b];this.fast_normal_weight_map.push(c)}for(var d=.05,e=0;e<this.getNumPts();e++){for(var f=[],g=0;g<this.fast_normal_weight_map.length;g++){var h=this.fast_normal_weight_map[g][e];h>d&&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;b<this.getNumPts();b++)this.uv_warp_ref_uvs.push(vec2.create()),this.uv_warp_ref_uvs[b]=vec2.fromValues(this.store_uvs[a],this.store_uvs[a+1]),a+=2},MeshRenderBoneComposition.prototype.addRegion=function(a){this.regions.push(a)},MeshRenderBoneComposition.prototype.setRootBone=function(a){this.root_bone=a},MeshRenderBoneComposition.prototype.getRootBone=function(){return this.root_bone},MeshRenderBoneComposition.prototype.initBoneMap=function(){this.bones_map=MeshRenderBoneComposition.genBoneMap(this.root_bone)},MeshRenderBoneComposition.prototype.initRegionsMap=function(){this.regions_map={};for(var a=0;a<this.regions.length;a++)cur_key=this.regions[a].getName(),this.regions_map[cur_key]=this.regions[a]},MeshRenderBoneComposition.genBoneMap=function(a){for(var b={},c=a.getAllBoneKeys(),d=0;d<c.length;d++){var e=c[d];b[e]=a.getChildByKey(e)}return b},MeshRenderBoneComposition.prototype.getBonesMap=function(){return this.bones_map},MeshRenderBoneComposition.prototype.getRegionsMap=function(){return this.regions_map},MeshRenderBoneComposition.prototype.getRegions=function(){return this.regions},MeshRenderBoneComposition.prototype.getRegionWithId=function(a){for(var b=0;b<this.regions.length;b++){var c=this.regions[b];if(c.getTagId()==a)return c}return null},MeshRenderBoneComposition.prototype.resetToWorldRestPts=function(){this.getRootBone().initWorldPts()},MeshRenderBoneComposition.prototype.updateAllTransforms=function(a){a&&this.getRootBone().computeParentTransforms(),this.getRootBone().computeWorldDeltaTransforms(),this.getRootBone().fixDQs(this.getRootBone().getWorldDq())},MeshBoneCache.prototype.setWorldStartPt=function(a){this.world_start_pt=a},MeshBoneCache.prototype.setWorldEndPt=function(a){this.world_end_pt=a},MeshBoneCache.prototype.getWorldStartPt=function(){return this.world_start_pt},MeshBoneCache.prototype.getWorldEndPt=function(){return this.world_end_pt},MeshBoneCache.prototype.getKey=function(){return this.key},MeshDisplacementCache.prototype.setLocalDisplacements=function(a){this.local_displacements=a},MeshDisplacementCache.prototype.setPostDisplacements=function(a){this.post_displacements=a},MeshDisplacementCache.prototype.getKey=function(){return this.key},MeshDisplacementCache.prototype.getLocalDisplacements=function(){return this.local_displacements},MeshDisplacementCache.prototype.getPostDisplacements=function(){return this.post_displacements},MeshUVWarpCache.prototype.setUvWarpLocalOffset=function(a){this.uv_warp_local_offset=a},MeshUVWarpCache.prototype.setUvWarpGlobalOffset=function(a){this.uv_warp_global_offset=a},MeshUVWarpCache.prototype.setUvWarpScale=function(a){this.uv_warp_scale=a},MeshUVWarpCache.prototype.getUvWarpLocalOffset=function(){return this.uv_warp_local_offset},MeshUVWarpCache.prototype.getUvWarpGlobalOffset=function(){return this.uv_warp_global_offset},MeshUVWarpCache.prototype.getUvWarpScale=function(){return this.uv_warp_scale},MeshUVWarpCache.prototype.getKey=function(){return this.key},MeshUVWarpCache.prototype.setEnabled=function(a){this.enabled=a},MeshUVWarpCache.prototype.getEnabled=function(){return this.enabled},MeshBoneCacheManager.prototype.init=function(a,b){this.start_time=a,this.end_time=b;var c=this.end_time-this.start_time+1;this.bone_cache_table=[],this.bone_cache_data_ready=[];for(var d=0;d<c;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;h<i;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;c<this.bone_cache_data_ready.size();c++)this.bone_cache_data_ready[c]&&b++;return b==a&&(this.is_ready=!0),this.is_ready},MeshBoneCacheManager.prototype.makeAllReady=function(){for(var a=0;a<this.bone_cache_data_ready.length;a++)this.bone_cache_data_ready[a]=!0},MeshDisplacementCacheManager.prototype.init=function(a,b){this.start_time=a,this.end_time=b;var c=this.end_time-this.start_time+1;this.displacement_cache_table=[],this.displacement_cache_data_ready=[];for(var d=0;d<c;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;h<f.length;h++){var i=f[h],j=g[h],k=i.getKey(),l=b[k];if(l.getUseLocalDisplacements()){var m=l.local_displacements;if(i.getLocalDisplacements().length==m.length&&j.getLocalDisplacements().length==m.length)for(var n=0;n<m.length;n++){var o=Utils.vec2Interp(i.getLocalDisplacements()[n],j.getLocalDisplacements()[n],e);m[n]=o}else for(var n=0;n<m.length;n++)m[n]=vec2.create()}if(l.getUsePostDisplacements()){var m=l.post_displacements;if(i.getPostDisplacements().length==m.length&&j.getPostDisplacements().length==m.length)for(var n=0;n<m.length;n++){var o=Utils.vec2Interp(i.getPostDisplacements()[n],j.getPostDisplacements()[n],e);m[n]=o}else for(var n=0;n<m.length;n++)m.set[n]=vec2.create()}}},MeshDisplacementCacheManager.prototype.allReady=function(){if(this.is_ready)return!0;for(var a=this.end_time-this.start_time+1,b=0,c=0;c<this.displacement_cache_data_ready.length;c++)this.displacement_cache_data_ready[c]&&b++;return b==a&&(this.is_ready=!0),this.is_ready},MeshDisplacementCacheManager.prototype.makeAllReady=function(){for(var a=0;a<this.displacement_cache_data_ready.length;a++)this.displacement_cache_data_ready[a]=!0},MeshUVWarpCacheManager.prototype.init=function(a,b){this.start_time=a,this.end_time=b;var c=this.end_time-this.start_time+1;this.uv_cache_table=[],this.uv_cache_data_ready=[];for(var d=0;d<c;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;g<e.length;g++){var h=e[g],i=(f[g],h.getKey()),j=b[i];if(j.getUseUvWarp()){var k=h.getUvWarpLocalOffset(),l=h.getUvWarpGlobalOffset(),m=h.getUvWarpScale();j.setUvWarpLocalOffset(k),j.setUvWarpGlobalOffset(l),j.setUvWarpScale(m)}}},MeshUVWarpCacheManager.prototype.allReady=function(){if(this.is_ready)return!0;for(var a=this.end_time-this.start_time+1,b=0,c=0;c<this.uv_cache_data_ready.length;c++)uv_cache_data_ready[c]&&b++;return b==a&&(this.is_ready=!0),this.is_ready},MeshUVWarpCacheManager.prototype.makeAllReady=function(){for(var a=0;a<this.uv_cache_data_ready.length;a++)this.uv_cache_data_ready[a]=!0};var CreatureModuleUtils={};CreatureModuleUtils.GetAllAnimationNames=function(a){var b=a.animation,c=[];for(var d in b)c.push(d);return c},CreatureModuleUtils.getFloatArray=function(a){return a},CreatureModuleUtils.getIntArray=function(a){return a},CreatureModuleUtils.ReadPointsArray2DJSON=function(a,b){for(var c=CreatureModuleUtils.getFloatArray(a[b]),d=[],e=c.length/2,f=0;f<e;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;f<e;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;e<16;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;o<m.length;o++){var p=m[o];f[p]=p}}for(var i in e)if(i in f==0){var q=e[i];c=q.first;break}for(var i in e)for(var q=e[i],r=q.first,s=q.second,o=0;o<s.length;o++){var p=s[o],t=e[p].first;r.addChild(t)}return c},CreatureModuleUtils.CreateRegions=function(a,b,c,d,e){var f=[],g=a[b];for(var h in g){var i=g[h],j=i.id,k=i.start_pt_index,l=i.end_pt_index,m=i.start_index,n=i.end_index,o=new MeshRenderRegion(c,d,e,k,l,m,n);o.setName(h),o.setTagId(j);var p=o.normal_weight_map,q=i.weights;for(var r in q){var s=(q[r],CreatureModuleUtils.ReadFloatArrayJSON(q,r));p[r]=s}f.push(o)}return f},CreatureModuleUtils.GetStartEndTimes=function(a,b){var c=0,d=0,e=!0,f=a[b];for(var g in f){var h=(f[g],parseInt(g));e?(c=h,d=h,e=!1):(h>d&&(d=h),h<c&&(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<this.total_num_pts;e++){var f=4*e;this.render_colours[0+f]=a,this.render_colours[1+f]=b,this.render_colours[2+f]=c,this.render_colours[3+f]=d}},Creature.prototype.ComputeBoundaryIndices=function(){for(var a={},b=0;b<this.total_num_pts;b++)a[b]=0;for(var c=this.render_composition.getRegions(),b=0;b<this.global_indices.length;b++){for(var d=this.global_indices[b],e=!1,f=0;f<c.length;f++){var g=c[f],h=g.getStartPtIndex(),i=g.getEndPtIndex();if(d>=h&&d<=i){e=!0;break}}e&&a[d]++}this.boundary_indices=[];for(var b=0;b<this.total_num_pts;b++)a[b]<=5&&this.boundary_indices.push(b)},Creature.prototype.ComputeBoundaryMinMax=function(){this.boundary_indices.length<=0&&this.ComputeBoundaryIndices();for(var a=3*this.boundary_indices[0],b=vec2.fromValues(this.render_pts[a+0],this.render_pts[a+1]),c=vec2.fromValues(b[0],b[1]),d=0;d<this.boundary_indices.length;d++){var e=3*this.boundary_indices[d],f=this.render_pts[e],g=this.render_pts[e+1];b[0]>f&&(b[0]=f),b[1]>g&&(b[1]=g),c[0]<f&&(c[0]=f),c[1]<g&&(c[1]=g)}this.boundary_min=b,this.boundary_max=c},Creature.prototype.LoadFromData=function(a){var b=a.mesh;this.global_pts=CreatureModuleUtils.ReadFloatArray3DJSON(b,"points"),this.total_num_pts=this.global_pts.length/3,this.global_indices=CreatureModuleUtils.ReadIntArrayJSON(b,"indices"),this.total_num_indices=this.global_indices.length,this.global_uvs=CreatureModuleUtils.ReadFloatArrayJSON(b,"uvs"),this.render_colours=[];for(var c=0;c<4*this.total_num_pts;c++)this.render_colours.push(0);this.FillRenderColours(1,1,1,1),this.render_pts=[];var d=CreatureModuleUtils.CreateBones(a,"skeleton"),e=CreatureModuleUtils.CreateRegions(b,"regions",this.global_indices,this.global_pts,this.global_uvs);this.render_composition=new MeshRenderBoneComposition,this.render_composition.setRootBone(d),this.render_composition.getRootBone().computeRestParentTransforms();for(var c=0;c<e.length;c++){var f=e[c];f.setMainBoneKey(d.getKey()),f.determineMainBone(d),this.render_composition.addRegion(f)}this.render_composition.initBoneMap(),this.render_composition.initRegionsMap();for(var c=0;c<e.length;c++){var f=e[c];f.initFastNormalWeightMap(this.render_composition.bones_map)}this.render_composition.resetToWorldRestPts()},CreatureAnimation.prototype.LoadFromData=function(a,b){var c=b.animation,d=c[a],e=CreatureModuleUtils.GetStartEndTimes(d,"bones");this.start_time=e.first,this.end_time=e.second,CreatureModuleUtils.FillBoneCache(d,"bones",this.start_time,this.end_time,this.bones_cache),CreatureModuleUtils.FillDeformationCache(d,"meshes",this.start_time,this.end_time,this.displacement_cache),CreatureModuleUtils.FillUVSwapCache(d,"uv_swaps",this.start_time,this.end_time,this.uv_warp_cache)},CreatureAnimation.prototype.getIndexByTime=function(a){var b=a-this.start_time;return b=Utils.clamp(b,0,this.cache_pts.length-1)},CreatureAnimation.prototype.verifyFillCache=function(){this.fill_cache_pts.length==this.end_time-this.start_time+1&&(this.cache_pts=this.fill_cache_pts)},CreatureAnimation.prototype.poseFromCachePts=function(a,b,c){for(var d=this.getIndexByTime(Math.floor(a)),e=this.getIndexByTime(Math.ceil(a)),f=a-Math.floor(a),g=b,h=this.cache_pts[d],i=this.cache_pts[e],j=0,k=0,l=0,m=0;m<c;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;c<b.length;c++){var d=b[c];this.CreateAnimation(a,d)}this.SetActiveAnimationName(b.get(0))},CreatureManager.prototype.AddAnimation=function(a){this.animations[a.name]=a},CreatureManager.prototype.GetAnimation=function(a){return this.animations[a];
},CreatureManager.prototype.GetCreature=function(){return this.target_creature},CreatureManager.prototype.GetAnimationNames=function(){var a=[];for(var b in animations)a.push(b);return a},CreatureManager.prototype.SetActiveAnimationName=function(a,b){if(null==a||a in this.animations==0)return!1;if(1==b&&this.active_animation_name==a)return!1;this.active_animation_name=a;var c=this.animations[this.active_animation_name];this.run_time=c.start_time;for(var d=c.displacement_cache,e=d.displacement_cache_table[0],f=c.uv_warp_cache,g=f.uv_cache_table[0],h=this.target_creature.render_composition,i=h.getRegions(),j=0,k=0;k<i.length;k++){var l=i[k],m=!(0==e[j].getLocalDisplacements().length),n=!(0==e[j].getPostDisplacements().length);l.setUseLocalDisplacements(m),l.setUsePostDisplacements(n),l.setUseUvWarp(g[j].getEnabled()),j++}return!0},CreatureManager.prototype.GetActiveAnimationName=function(){return this.active_animation_name},CreatureManager.prototype.GetAllAnimations=function(){return this.animations},CreatureManager.prototype.MakePointCache=function(a){var b=this.getRunTime(),c=this.animations[a];if(!(c.length>0)){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_time<b&&(this.should_loop?this.run_time=c:this.run_time=b)},CreatureManager.prototype.getRunTime=function(){return this.run_time},CreatureManager.prototype.Update=function(a){this.is_playing&&(this.increRunTime(a*this.time_scale),this.RunCreature())},CreatureManager.prototype.RunAtTime=function(a){this.is_playing&&(this.setRunTime(a),this.RunCreature())},CreatureManager.prototype.RunCreature=function(){if(this.do_blending){for(var a=0;a<2;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;l<m;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;r<=q;r+=3)b[r+2]=.001*-l}};
//# sourceMappingURL=creature.map