UNPKG

phaser-ce

Version:

Phaser CE (Community Edition) is a fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.

3 lines (2 loc) 71.1 kB
/* Phaser v2.9.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(t,e,r,n){this.key=t,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(n,null),this.setLocalRestStartPt(e),this.setLocalRestEndPt(r),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(t,e,r,n,a,i,s){this.store_indices=t,this.store_rest_pts=e,this.store_uvs=r,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=n,this.end_pt_index=a,this.start_index=i,this.end_index=s,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(t){this.key=t}function MeshDisplacementCache(t){this.key=t,this.local_displacements=[],this.post_displacements=[]}function MeshUVWarpCache(t){this.uv_warp_global_offset=vec2.create(),this.uv_warp_local_offset=vec2.create(),this.uv_warp_scale=vec2.fromValues(-1,-1),this.key=t,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(t,e){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.anchor_point_map={},this.anchor_points_active=!1,this.LoadFromData(t,e)}function CreatureAnimation(t,e){this.name=e,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(e,t)}function CreatureManager(t){this.target_creature=t,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(t){"use strict";var e={};"undefined"==typeof exports?"function"==typeof define&&"object"==typeof define.amd&&define.amd?(e.exports={},define(function(){return e.exports})):e.exports="undefined"!=typeof window?window:t:e.exports=exports,function(t){if(!e)var e=1e-6;if(!r)var r="undefined"!=typeof Float32Array?Float32Array:Array;if(!n)var n=Math.random;var a={};a.setMatrixArrayType=function(t){r=t},void 0!==t&&(t.glMatrix=a);var i=Math.PI/180;a.toRadian=function(t){return t*i};var s={};s.create=function(){var t=new r(2);return t[0]=0,t[1]=0,t},s.clone=function(t){var e=new r(2);return e[0]=t[0],e[1]=t[1],e},s.fromValues=function(t,e){var n=new r(2);return n[0]=t,n[1]=e,n},s.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},s.set=function(t,e,r){return t[0]=e,t[1]=r,t},s.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},s.subtract=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t},s.sub=s.subtract,s.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t},s.mul=s.multiply,s.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t},s.div=s.divide,s.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},s.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},s.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},s.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t},s.distance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1];return Math.sqrt(r*r+n*n)},s.dist=s.distance,s.squaredDistance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n},s.sqrDist=s.squaredDistance,s.length=function(t){var e=t[0],r=t[1];return Math.sqrt(e*e+r*r)},s.len=s.length,s.squaredLength=function(t){var e=t[0],r=t[1];return e*e+r*r},s.sqrLen=s.squaredLength,s.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},s.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},s.normalize=function(t,e){var r=e[0],n=e[1],a=r*r+n*n;return a>0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a),t},s.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},s.cross=function(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t},s.lerp=function(t,e,r,n){var a=e[0],i=e[1];return t[0]=a+n*(r[0]-a),t[1]=i+n*(r[1]-i),t},s.random=function(t,e){e=e||1;var r=2*n()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t},s.transformMat2=function(t,e,r){var n=e[0],a=e[1];return t[0]=r[0]*n+r[2]*a,t[1]=r[1]*n+r[3]*a,t},s.transformMat2d=function(t,e,r){var n=e[0],a=e[1];return t[0]=r[0]*n+r[2]*a+r[4],t[1]=r[1]*n+r[3]*a+r[5],t},s.transformMat3=function(t,e,r){var n=e[0],a=e[1];return t[0]=r[0]*n+r[3]*a+r[6],t[1]=r[1]*n+r[4]*a+r[7],t},s.transformMat4=function(t,e,r){var n=e[0],a=e[1];return t[0]=r[0]*n+r[4]*a+r[12],t[1]=r[1]*n+r[5]*a+r[13],t},s.forEach=function(){var t=s.create();return function(e,r,n,a,i,s){var o,c;for(r||(r=2),n||(n=0),c=a?Math.min(a*r+n,e.length):e.length,o=n;o<c;o+=r)t[0]=e[o],t[1]=e[o+1],i(t,t,s),e[o]=t[0],e[o+1]=t[1];return e}}(),s.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},void 0!==t&&(t.vec2=s);var o={};o.create=function(){var t=new r(3);return t[0]=0,t[1]=0,t[2]=0,t},o.clone=function(t){var e=new r(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},o.fromValues=function(t,e,n){var a=new r(3);return a[0]=t,a[1]=e,a[2]=n,a},o.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},o.set=function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t},o.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},o.subtract=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t},o.sub=o.subtract,o.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t},o.mul=o.multiply,o.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t},o.div=o.divide,o.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t},o.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t},o.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},o.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t},o.distance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],a=e[2]-t[2];return Math.sqrt(r*r+n*n+a*a)},o.dist=o.distance,o.squaredDistance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],a=e[2]-t[2];return r*r+n*n+a*a},o.sqrDist=o.squaredDistance,o.length=function(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)},o.len=o.length,o.squaredLength=function(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n},o.sqrLen=o.squaredLength,o.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},o.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},o.normalize=function(t,e){var r=e[0],n=e[1],a=e[2],i=r*r+n*n+a*a;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i),t},o.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},o.cross=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=r[0],o=r[1],c=r[2];return t[0]=a*c-i*o,t[1]=i*s-n*c,t[2]=n*o-a*s,t},o.lerp=function(t,e,r,n){var a=e[0],i=e[1],s=e[2];return t[0]=a+n*(r[0]-a),t[1]=i+n*(r[1]-i),t[2]=s+n*(r[2]-s),t},o.random=function(t,e){e=e||1;var r=2*n()*Math.PI,a=2*n()-1,i=Math.sqrt(1-a*a)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=a*e,t},o.transformMat4=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=r[3]*n+r[7]*a+r[11]*i+r[15];return s=s||1,t[0]=(r[0]*n+r[4]*a+r[8]*i+r[12])/s,t[1]=(r[1]*n+r[5]*a+r[9]*i+r[13])/s,t[2]=(r[2]*n+r[6]*a+r[10]*i+r[14])/s,t},o.transformMat3=function(t,e,r){var n=e[0],a=e[1],i=e[2];return t[0]=n*r[0]+a*r[3]+i*r[6],t[1]=n*r[1]+a*r[4]+i*r[7],t[2]=n*r[2]+a*r[5]+i*r[8],t},o.transformQuat=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=r[0],o=r[1],c=r[2],h=r[3],u=h*n+o*i-c*a,l=h*a+c*n-s*i,_=h*i+s*a-o*n,p=-s*n-o*a-c*i;return t[0]=u*h+p*-s+l*-c-_*-o,t[1]=l*h+p*-o+_*-s-u*-c,t[2]=_*h+p*-c+u*-o-l*-s,t},o.rotateX=function(t,e,r,n){var a=[],i=[];return a[0]=e[0]-r[0],a[1]=e[1]-r[1],a[2]=e[2]-r[2],i[0]=a[0],i[1]=a[1]*Math.cos(n)-a[2]*Math.sin(n),i[2]=a[1]*Math.sin(n)+a[2]*Math.cos(n),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t},o.rotateY=function(t,e,r,n){var a=[],i=[];return a[0]=e[0]-r[0],a[1]=e[1]-r[1],a[2]=e[2]-r[2],i[0]=a[2]*Math.sin(n)+a[0]*Math.cos(n),i[1]=a[1],i[2]=a[2]*Math.cos(n)-a[0]*Math.sin(n),t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t},o.rotateZ=function(t,e,r,n){var a=[],i=[];return a[0]=e[0]-r[0],a[1]=e[1]-r[1],a[2]=e[2]-r[2],i[0]=a[0]*Math.cos(n)-a[1]*Math.sin(n),i[1]=a[0]*Math.sin(n)+a[1]*Math.cos(n),i[2]=a[2],t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t},o.forEach=function(){var t=o.create();return function(e,r,n,a,i,s){var o,c;for(r||(r=3),n||(n=0),c=a?Math.min(a*r+n,e.length):e.length,o=n;o<c;o+=r)t[0]=e[o],t[1]=e[o+1],t[2]=e[o+2],i(t,t,s),e[o]=t[0],e[o+1]=t[1],e[o+2]=t[2];return e}}(),o.str=function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},void 0!==t&&(t.vec3=o);var c={};c.create=function(){var t=new r(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},c.clone=function(t){var e=new r(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},c.fromValues=function(t,e,n,a){var i=new r(4);return i[0]=t,i[1]=e,i[2]=n,i[3]=a,i},c.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},c.set=function(t,e,r,n,a){return t[0]=e,t[1]=r,t[2]=n,t[3]=a,t},c.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},c.subtract=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t},c.sub=c.subtract,c.multiply=function(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t},c.mul=c.multiply,c.divide=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t},c.div=c.divide,c.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t},c.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t},c.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},c.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t},c.distance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],a=e[2]-t[2],i=e[3]-t[3];return Math.sqrt(r*r+n*n+a*a+i*i)},c.dist=c.distance,c.squaredDistance=function(t,e){var r=e[0]-t[0],n=e[1]-t[1],a=e[2]-t[2],i=e[3]-t[3];return r*r+n*n+a*a+i*i},c.sqrDist=c.squaredDistance,c.length=function(t){var e=t[0],r=t[1],n=t[2],a=t[3];return Math.sqrt(e*e+r*r+n*n+a*a)},c.len=c.length,c.squaredLength=function(t){var e=t[0],r=t[1],n=t[2],a=t[3];return e*e+r*r+n*n+a*a},c.sqrLen=c.squaredLength,c.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},c.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t},c.normalize=function(t,e){var r=e[0],n=e[1],a=e[2],i=e[3],s=r*r+n*n+a*a+i*i;return s>0&&(s=1/Math.sqrt(s),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t[3]=e[3]*s),t},c.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},c.lerp=function(t,e,r,n){var a=e[0],i=e[1],s=e[2],o=e[3];return t[0]=a+n*(r[0]-a),t[1]=i+n*(r[1]-i),t[2]=s+n*(r[2]-s),t[3]=o+n*(r[3]-o),t},c.random=function(t,e){return e=e||1,t[0]=n(),t[1]=n(),t[2]=n(),t[3]=n(),c.normalize(t,t),c.scale(t,t,e),t},c.transformMat4=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3];return t[0]=r[0]*n+r[4]*a+r[8]*i+r[12]*s,t[1]=r[1]*n+r[5]*a+r[9]*i+r[13]*s,t[2]=r[2]*n+r[6]*a+r[10]*i+r[14]*s,t[3]=r[3]*n+r[7]*a+r[11]*i+r[15]*s,t},c.transformQuat=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=r[0],o=r[1],c=r[2],h=r[3],u=h*n+o*i-c*a,l=h*a+c*n-s*i,_=h*i+s*a-o*n,p=-s*n-o*a-c*i;return t[0]=u*h+p*-s+l*-c-_*-o,t[1]=l*h+p*-o+_*-s-u*-c,t[2]=_*h+p*-c+u*-o-l*-s,t},c.forEach=function(){var t=c.create();return function(e,r,n,a,i,s){var o,c;for(r||(r=4),n||(n=0),c=a?Math.min(a*r+n,e.length):e.length,o=n;o<c;o+=r)t[0]=e[o],t[1]=e[o+1],t[2]=e[o+2],t[3]=e[o+3],i(t,t,s),e[o]=t[0],e[o+1]=t[1],e[o+2]=t[2],e[o+3]=t[3];return e}}(),c.str=function(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},void 0!==t&&(t.vec4=c);var h={};h.create=function(){var t=new r(4);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},h.clone=function(t){var e=new r(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},h.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},h.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},h.transpose=function(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t},h.invert=function(t,e){var r=e[0],n=e[1],a=e[2],i=e[3],s=r*i-a*n;return s?(s=1/s,t[0]=i*s,t[1]=-n*s,t[2]=-a*s,t[3]=r*s,t):null},h.adjoint=function(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t},h.determinant=function(t){return t[0]*t[3]-t[2]*t[1]},h.multiply=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=r[0],c=r[1],h=r[2],u=r[3];return t[0]=n*o+i*c,t[1]=a*o+s*c,t[2]=n*h+i*u,t[3]=a*h+s*u,t},h.mul=h.multiply,h.rotate=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*o,t[1]=a*c+s*o,t[2]=n*-o+i*c,t[3]=a*-o+s*c,t},h.scale=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=r[0],c=r[1];return t[0]=n*o,t[1]=a*o,t[2]=i*c,t[3]=s*c,t},h.str=function(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},h.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2))},h.LDU=function(t,e,r,n){return t[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-t[2]*r[1],[t,e,r]},void 0!==t&&(t.mat2=h);var u={};u.create=function(){var t=new r(6);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},u.clone=function(t){var e=new r(6);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},u.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},u.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},u.invert=function(t,e){var r=e[0],n=e[1],a=e[2],i=e[3],s=e[4],o=e[5],c=r*i-n*a;return c?(c=1/c,t[0]=i*c,t[1]=-n*c,t[2]=-a*c,t[3]=r*c,t[4]=(a*o-i*s)*c,t[5]=(n*s-r*o)*c,t):null},u.determinant=function(t){return t[0]*t[3]-t[1]*t[2]},u.multiply=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=e[4],c=e[5],h=r[0],u=r[1],l=r[2],_=r[3],p=r[4],d=r[5];return t[0]=n*h+i*u,t[1]=a*h+s*u,t[2]=n*l+i*_,t[3]=a*l+s*_,t[4]=n*p+i*d+o,t[5]=a*p+s*d+c,t},u.mul=u.multiply,u.rotate=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=e[4],c=e[5],h=Math.sin(r),u=Math.cos(r);return t[0]=n*u+i*h,t[1]=a*u+s*h,t[2]=n*-h+i*u,t[3]=a*-h+s*u,t[4]=o,t[5]=c,t},u.scale=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=e[4],c=e[5],h=r[0],u=r[1];return t[0]=n*h,t[1]=a*h,t[2]=i*u,t[3]=s*u,t[4]=o,t[5]=c,t},u.translate=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=e[4],c=e[5],h=r[0],u=r[1];return t[0]=n,t[1]=a,t[2]=i,t[3]=s,t[4]=n*h+i*u+o,t[5]=a*h+s*u+c,t},u.str=function(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},u.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+1)},void 0!==t&&(t.mat2d=u);var l={};l.create=function(){var t=new r(9);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},l.fromMat4=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},l.clone=function(t){var e=new r(9);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},l.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},l.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},l.transpose=function(t,e){if(t===e){var r=e[1],n=e[2],a=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=a}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},l.invert=function(t,e){var r=e[0],n=e[1],a=e[2],i=e[3],s=e[4],o=e[5],c=e[6],h=e[7],u=e[8],l=u*s-o*h,_=-u*i+o*c,p=h*i-s*c,d=r*l+n*_+a*p;return d?(d=1/d,t[0]=l*d,t[1]=(-u*n+a*h)*d,t[2]=(o*n-a*s)*d,t[3]=_*d,t[4]=(u*r-a*c)*d,t[5]=(-o*r+a*i)*d,t[6]=p*d,t[7]=(-h*r+n*c)*d,t[8]=(s*r-n*i)*d,t):null},l.adjoint=function(t,e){var r=e[0],n=e[1],a=e[2],i=e[3],s=e[4],o=e[5],c=e[6],h=e[7],u=e[8];return t[0]=s*u-o*h,t[1]=a*h-n*u,t[2]=n*o-a*s,t[3]=o*c-i*u,t[4]=r*u-a*c,t[5]=a*i-r*o,t[6]=i*h-s*c,t[7]=n*c-r*h,t[8]=r*s-n*i,t},l.determinant=function(t){var e=t[0],r=t[1],n=t[2],a=t[3],i=t[4],s=t[5],o=t[6],c=t[7],h=t[8];return e*(h*i-s*c)+r*(-h*a+s*o)+n*(c*a-i*o)},l.multiply=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=e[4],c=e[5],h=e[6],u=e[7],l=e[8],_=r[0],p=r[1],d=r[2],m=r[3],f=r[4],v=r[5],g=r[6],M=r[7],y=r[8];return t[0]=_*n+p*s+d*h,t[1]=_*a+p*o+d*u,t[2]=_*i+p*c+d*l,t[3]=m*n+f*s+v*h,t[4]=m*a+f*o+v*u,t[5]=m*i+f*c+v*l,t[6]=g*n+M*s+y*h,t[7]=g*a+M*o+y*u,t[8]=g*i+M*c+y*l,t},l.mul=l.multiply,l.translate=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=e[4],c=e[5],h=e[6],u=e[7],l=e[8],_=r[0],p=r[1];return t[0]=n,t[1]=a,t[2]=i,t[3]=s,t[4]=o,t[5]=c,t[6]=_*n+p*s+h,t[7]=_*a+p*o+u,t[8]=_*i+p*c+l,t},l.rotate=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=e[4],c=e[5],h=e[6],u=e[7],l=e[8],_=Math.sin(r),p=Math.cos(r);return t[0]=p*n+_*s,t[1]=p*a+_*o,t[2]=p*i+_*c,t[3]=p*s-_*n,t[4]=p*o-_*a,t[5]=p*c-_*i,t[6]=h,t[7]=u,t[8]=l,t},l.scale=function(t,e,r){var n=r[0],a=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=a*e[3],t[4]=a*e[4],t[5]=a*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},l.fromMat2d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t},l.fromQuat=function(t,e){var r=e[0],n=e[1],a=e[2],i=e[3],s=r+r,o=n+n,c=a+a,h=r*s,u=n*s,l=n*o,_=a*s,p=a*o,d=a*c,m=i*s,f=i*o,v=i*c;return t[0]=1-l-d,t[3]=u-v,t[6]=_+f,t[1]=u+v,t[4]=1-h-d,t[7]=p-m,t[2]=_-f,t[5]=p+m,t[8]=1-h-l,t},l.normalFromMat4=function(t,e){var r=e[0],n=e[1],a=e[2],i=e[3],s=e[4],o=e[5],c=e[6],h=e[7],u=e[8],l=e[9],_=e[10],p=e[11],d=e[12],m=e[13],f=e[14],v=e[15],g=r*o-n*s,M=r*c-a*s,y=r*h-i*s,R=n*c-a*o,C=n*h-i*o,b=a*h-i*c,w=u*m-l*d,Q=u*f-_*d,U=u*v-p*d,B=l*f-_*m,P=l*v-p*m,W=_*v-p*f,x=g*W-M*P+y*B+R*U-C*Q+b*w;return x?(x=1/x,t[0]=(o*W-c*P+h*B)*x,t[1]=(c*U-s*W-h*Q)*x,t[2]=(s*P-o*U+h*w)*x,t[3]=(a*P-n*W-i*B)*x,t[4]=(r*W-a*U+i*Q)*x,t[5]=(n*U-r*P-i*w)*x,t[6]=(m*b-f*C+v*R)*x,t[7]=(f*y-d*b-v*M)*x,t[8]=(d*C-m*y+v*g)*x,t):null},l.str=function(t){return"mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"},l.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2))},void 0!==t&&(t.mat3=l);var _={};_.create=function(){var t=new r(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},_.clone=function(t){var e=new r(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},_.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},_.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},_.transpose=function(t,e){if(t===e){var r=e[1],n=e[2],a=e[3],i=e[6],s=e[7],o=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=i,t[11]=e[14],t[12]=a,t[13]=s,t[14]=o}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t},_.invert=function(t,e){var r=e[0],n=e[1],a=e[2],i=e[3],s=e[4],o=e[5],c=e[6],h=e[7],u=e[8],l=e[9],_=e[10],p=e[11],d=e[12],m=e[13],f=e[14],v=e[15],g=r*o-n*s,M=r*c-a*s,y=r*h-i*s,R=n*c-a*o,C=n*h-i*o,b=a*h-i*c,w=u*m-l*d,Q=u*f-_*d,U=u*v-p*d,B=l*f-_*m,P=l*v-p*m,W=_*v-p*f,x=g*W-M*P+y*B+R*U-C*Q+b*w;return x?(x=1/x,t[0]=(o*W-c*P+h*B)*x,t[1]=(a*P-n*W-i*B)*x,t[2]=(m*b-f*C+v*R)*x,t[3]=(_*C-l*b-p*R)*x,t[4]=(c*U-s*W-h*Q)*x,t[5]=(r*W-a*U+i*Q)*x,t[6]=(f*y-d*b-v*M)*x,t[7]=(u*b-_*y+p*M)*x,t[8]=(s*P-o*U+h*w)*x,t[9]=(n*U-r*P-i*w)*x,t[10]=(d*C-m*y+v*g)*x,t[11]=(l*y-u*C-p*g)*x,t[12]=(o*Q-s*B-c*w)*x,t[13]=(r*B-n*Q+a*w)*x,t[14]=(m*M-d*R-f*g)*x,t[15]=(u*R-l*M+_*g)*x,t):null},_.adjoint=function(t,e){var r=e[0],n=e[1],a=e[2],i=e[3],s=e[4],o=e[5],c=e[6],h=e[7],u=e[8],l=e[9],_=e[10],p=e[11],d=e[12],m=e[13],f=e[14],v=e[15];return t[0]=o*(_*v-p*f)-l*(c*v-h*f)+m*(c*p-h*_),t[1]=-(n*(_*v-p*f)-l*(a*v-i*f)+m*(a*p-i*_)),t[2]=n*(c*v-h*f)-o*(a*v-i*f)+m*(a*h-i*c),t[3]=-(n*(c*p-h*_)-o*(a*p-i*_)+l*(a*h-i*c)),t[4]=-(s*(_*v-p*f)-u*(c*v-h*f)+d*(c*p-h*_)),t[5]=r*(_*v-p*f)-u*(a*v-i*f)+d*(a*p-i*_),t[6]=-(r*(c*v-h*f)-s*(a*v-i*f)+d*(a*h-i*c)),t[7]=r*(c*p-h*_)-s*(a*p-i*_)+u*(a*h-i*c),t[8]=s*(l*v-p*m)-u*(o*v-h*m)+d*(o*p-h*l),t[9]=-(r*(l*v-p*m)-u*(n*v-i*m)+d*(n*p-i*l)),t[10]=r*(o*v-h*m)-s*(n*v-i*m)+d*(n*h-i*o),t[11]=-(r*(o*p-h*l)-s*(n*p-i*l)+u*(n*h-i*o)),t[12]=-(s*(l*f-_*m)-u*(o*f-c*m)+d*(o*_-c*l)),t[13]=r*(l*f-_*m)-u*(n*f-a*m)+d*(n*_-a*l),t[14]=-(r*(o*f-c*m)-s*(n*f-a*m)+d*(n*c-a*o)),t[15]=r*(o*_-c*l)-s*(n*_-a*l)+u*(n*c-a*o),t},_.determinant=function(t){var e=t[0],r=t[1],n=t[2],a=t[3],i=t[4],s=t[5],o=t[6],c=t[7],h=t[8],u=t[9],l=t[10],_=t[11],p=t[12],d=t[13],m=t[14],f=t[15];return(e*s-r*i)*(l*f-_*m)-(e*o-n*i)*(u*f-_*d)+(e*c-a*i)*(u*m-l*d)+(r*o-n*s)*(h*f-_*p)-(r*c-a*s)*(h*m-l*p)+(n*c-a*o)*(h*d-u*p)},_.multiply=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=e[4],c=e[5],h=e[6],u=e[7],l=e[8],_=e[9],p=e[10],d=e[11],m=e[12],f=e[13],v=e[14],g=e[15],M=r[0],y=r[1],R=r[2],C=r[3];return t[0]=M*n+y*o+R*l+C*m,t[1]=M*a+y*c+R*_+C*f,t[2]=M*i+y*h+R*p+C*v,t[3]=M*s+y*u+R*d+C*g,M=r[4],y=r[5],R=r[6],C=r[7],t[4]=M*n+y*o+R*l+C*m,t[5]=M*a+y*c+R*_+C*f,t[6]=M*i+y*h+R*p+C*v,t[7]=M*s+y*u+R*d+C*g,M=r[8],y=r[9],R=r[10],C=r[11],t[8]=M*n+y*o+R*l+C*m,t[9]=M*a+y*c+R*_+C*f,t[10]=M*i+y*h+R*p+C*v,t[11]=M*s+y*u+R*d+C*g,M=r[12],y=r[13],R=r[14],C=r[15],t[12]=M*n+y*o+R*l+C*m,t[13]=M*a+y*c+R*_+C*f,t[14]=M*i+y*h+R*p+C*v,t[15]=M*s+y*u+R*d+C*g,t},_.mul=_.multiply,_.translate=function(t,e,r){var n,a,i,s,o,c,h,u,l,_,p,d,m=r[0],f=r[1],v=r[2];return e===t?(t[12]=e[0]*m+e[4]*f+e[8]*v+e[12],t[13]=e[1]*m+e[5]*f+e[9]*v+e[13],t[14]=e[2]*m+e[6]*f+e[10]*v+e[14],t[15]=e[3]*m+e[7]*f+e[11]*v+e[15]):(n=e[0],a=e[1],i=e[2],s=e[3],o=e[4],c=e[5],h=e[6],u=e[7],l=e[8],_=e[9],p=e[10],d=e[11],t[0]=n,t[1]=a,t[2]=i,t[3]=s,t[4]=o,t[5]=c,t[6]=h,t[7]=u,t[8]=l,t[9]=_,t[10]=p,t[11]=d,t[12]=n*m+o*f+l*v+e[12],t[13]=a*m+c*f+_*v+e[13],t[14]=i*m+h*f+p*v+e[14],t[15]=s*m+u*f+d*v+e[15]),t},_.scale=function(t,e,r){var n=r[0],a=r[1],i=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*a,t[5]=e[5]*a,t[6]=e[6]*a,t[7]=e[7]*a,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},_.rotate=function(t,r,n,a){var i,s,o,c,h,u,l,_,p,d,m,f,v,g,M,y,R,C,b,w,Q,U,B,P,W=a[0],x=a[1],A=a[2],V=Math.sqrt(W*W+x*x+A*A);return Math.abs(V)<e?null:(V=1/V,W*=V,x*=V,A*=V,i=Math.sin(n),s=Math.cos(n),o=1-s,c=r[0],h=r[1],u=r[2],l=r[3],_=r[4],p=r[5],d=r[6],m=r[7],f=r[8],v=r[9],g=r[10],M=r[11],y=W*W*o+s,R=x*W*o+A*i,C=A*W*o-x*i,b=W*x*o-A*i,w=x*x*o+s,Q=A*x*o+W*i,U=W*A*o+x*i,B=x*A*o-W*i,P=A*A*o+s,t[0]=c*y+_*R+f*C,t[1]=h*y+p*R+v*C,t[2]=u*y+d*R+g*C,t[3]=l*y+m*R+M*C,t[4]=c*b+_*w+f*Q,t[5]=h*b+p*w+v*Q,t[6]=u*b+d*w+g*Q,t[7]=l*b+m*w+M*Q,t[8]=c*U+_*B+f*P,t[9]=h*U+p*B+v*P,t[10]=u*U+d*B+g*P,t[11]=l*U+m*B+M*P,r!==t&&(t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15]),t)},_.rotateX=function(t,e,r){var n=Math.sin(r),a=Math.cos(r),i=e[4],s=e[5],o=e[6],c=e[7],h=e[8],u=e[9],l=e[10],_=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=i*a+h*n,t[5]=s*a+u*n,t[6]=o*a+l*n,t[7]=c*a+_*n,t[8]=h*a-i*n,t[9]=u*a-s*n,t[10]=l*a-o*n,t[11]=_*a-c*n,t},_.rotateY=function(t,e,r){var n=Math.sin(r),a=Math.cos(r),i=e[0],s=e[1],o=e[2],c=e[3],h=e[8],u=e[9],l=e[10],_=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*a-h*n,t[1]=s*a-u*n,t[2]=o*a-l*n,t[3]=c*a-_*n,t[8]=i*n+h*a,t[9]=s*n+u*a,t[10]=o*n+l*a,t[11]=c*n+_*a,t},_.rotateZ=function(t,e,r){var n=Math.sin(r),a=Math.cos(r),i=e[0],s=e[1],o=e[2],c=e[3],h=e[4],u=e[5],l=e[6],_=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*a+h*n,t[1]=s*a+u*n,t[2]=o*a+l*n,t[3]=c*a+_*n,t[4]=h*a-i*n,t[5]=u*a-s*n,t[6]=l*a-o*n,t[7]=_*a-c*n,t},_.fromRotationTranslation=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=n+n,c=a+a,h=i+i,u=n*o,l=n*c,_=n*h,p=a*c,d=a*h,m=i*h,f=s*o,v=s*c,g=s*h;return t[0]=1-(p+m),t[1]=l+g,t[2]=_-v,t[3]=0,t[4]=l-g,t[5]=1-(u+m),t[6]=d+f,t[7]=0,t[8]=_+v,t[9]=d-f,t[10]=1-(u+p),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t},_.fromQuat=function(t,e){var r=e[0],n=e[1],a=e[2],i=e[3],s=r+r,o=n+n,c=a+a,h=r*s,u=n*s,l=n*o,_=a*s,p=a*o,d=a*c,m=i*s,f=i*o,v=i*c;return t[0]=1-l-d,t[1]=u+v,t[2]=_-f,t[3]=0,t[4]=u-v,t[5]=1-h-d,t[6]=p+m,t[7]=0,t[8]=_+f,t[9]=p-m,t[10]=1-h-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},_.frustum=function(t,e,r,n,a,i,s){var o=1/(r-e),c=1/(a-n),h=1/(i-s);return t[0]=2*i*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*i*c,t[6]=0,t[7]=0,t[8]=(r+e)*o,t[9]=(a+n)*c,t[10]=(s+i)*h,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*i*2*h,t[15]=0,t},_.perspective=function(t,e,r,n,a){var i=1/Math.tan(e/2),s=1/(n-a);return t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(a+n)*s,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*a*n*s,t[15]=0,t},_.ortho=function(t,e,r,n,a,i,s){var o=1/(e-r),c=1/(n-a),h=1/(i-s);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*h,t[11]=0,t[12]=(e+r)*o,t[13]=(a+n)*c,t[14]=(s+i)*h,t[15]=1,t},_.lookAt=function(t,r,n,a){var i,s,o,c,h,u,l,p,d,m,f=r[0],v=r[1],g=r[2],M=a[0],y=a[1],R=a[2],C=n[0],b=n[1],w=n[2];return Math.abs(f-C)<e&&Math.abs(v-b)<e&&Math.abs(g-w)<e?_.identity(t):(l=f-C,p=v-b,d=g-w,m=1/Math.sqrt(l*l+p*p+d*d),l*=m,p*=m,d*=m,i=y*d-R*p,s=R*l-M*d,o=M*p-y*l,(m=Math.sqrt(i*i+s*s+o*o))?(i*=m=1/m,s*=m,o*=m):(i=0,s=0,o=0),c=p*o-d*s,h=d*i-l*o,u=l*s-p*i,(m=Math.sqrt(c*c+h*h+u*u))?(c*=m=1/m,h*=m,u*=m):(c=0,h=0,u=0),t[0]=i,t[1]=c,t[2]=l,t[3]=0,t[4]=s,t[5]=h,t[6]=p,t[7]=0,t[8]=o,t[9]=u,t[10]=d,t[11]=0,t[12]=-(i*f+s*v+o*g),t[13]=-(c*f+h*v+u*g),t[14]=-(l*f+p*v+d*g),t[15]=1,t)},_.str=function(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},_.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2)+Math.pow(t[9],2)+Math.pow(t[10],2)+Math.pow(t[11],2)+Math.pow(t[12],2)+Math.pow(t[13],2)+Math.pow(t[14],2)+Math.pow(t[15],2))},void 0!==t&&(t.mat4=_);var p={};p.create=function(){var t=new r(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},p.rotationTo=function(){var t=o.create(),e=o.fromValues(1,0,0),r=o.fromValues(0,1,0);return function(n,a,i){var s=o.dot(a,i);return s<-.999999?(o.cross(t,e,a),o.length(t)<1e-6&&o.cross(t,r,a),o.normalize(t,t),p.setAxisAngle(n,t,Math.PI),n):s>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(o.cross(t,a,i),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+s,p.normalize(n,n))}}(),p.setAxes=function(){var t=l.create();return function(e,r,n,a){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=a[0],t[4]=a[1],t[7]=a[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],p.normalize(e,p.fromMat3(e,t))}}(),p.clone=c.clone,p.fromValues=c.fromValues,p.copy=c.copy,p.set=c.set,p.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},p.setAxisAngle=function(t,e,r){r*=.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t},p.add=c.add,p.multiply=function(t,e,r){var n=e[0],a=e[1],i=e[2],s=e[3],o=r[0],c=r[1],h=r[2],u=r[3];return t[0]=n*u+s*o+a*h-i*c,t[1]=a*u+s*c+i*o-n*h,t[2]=i*u+s*h+n*c-a*o,t[3]=s*u-n*o-a*c-i*h,t},p.mul=p.multiply,p.scale=c.scale,p.rotateX=function(t,e,r){r*=.5;var n=e[0],a=e[1],i=e[2],s=e[3],o=Math.sin(r),c=Math.cos(r);return t[0]=n*c+s*o,t[1]=a*c+i*o,t[2]=i*c-a*o,t[3]=s*c-n*o,t},p.rotateY=function(t,e,r){r*=.5;var n=e[0],a=e[1],i=e[2],s=e[3],o=Math.sin(r),c=Math.cos(r);return t[0]=n*c-i*o,t[1]=a*c+s*o,t[2]=i*c+n*o,t[3]=s*c-a*o,t},p.rotateZ=function(t,e,r){r*=.5;var n=e[0],a=e[1],i=e[2],s=e[3],o=Math.sin(r),c=Math.cos(r);return t[0]=n*c+a*o,t[1]=a*c-n*o,t[2]=i*c+s*o,t[3]=s*c-i*o,t},p.calculateW=function(t,e){var r=e[0],n=e[1],a=e[2];return t[0]=r,t[1]=n,t[2]=a,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-a*a)),t},p.dot=c.dot,p.lerp=c.lerp,p.slerp=function(t,e,r,n){var a,i,s,o,c,h=e[0],u=e[1],l=e[2],_=e[3],p=r[0],d=r[1],m=r[2],f=r[3];return(i=h*p+u*d+l*m+_*f)<0&&(i=-i,p=-p,d=-d,m=-m,f=-f),1-i>1e-6?(a=Math.acos(i),s=Math.sin(a),o=Math.sin((1-n)*a)/s,c=Math.sin(n*a)/s):(o=1-n,c=n),t[0]=o*h+c*p,t[1]=o*u+c*d,t[2]=o*l+c*m,t[3]=o*_+c*f,t},p.invert=function(t,e){var r=e[0],n=e[1],a=e[2],i=e[3],s=r*r+n*n+a*a+i*i,o=s?1/s:0;return t[0]=-r*o,t[1]=-n*o,t[2]=-a*o,t[3]=i*o,t},p.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},p.length=c.length,p.len=p.length,p.squaredLength=c.squaredLength,p.sqrLen=p.squaredLength,p.normalize=c.normalize,p.fromMat3=function(t,e){var r,n=e[0]+e[4]+e[8];if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var a=0;e[4]>e[0]&&(a=1),e[8]>e[3*a+a]&&(a=2);var i=(a+1)%3,s=(a+2)%3;r=Math.sqrt(e[3*a+a]-e[3*i+i]-e[3*s+s]+1),t[a]=.5*r,r=.5/r,t[3]=(e[3*i+s]-e[3*s+i])*r,t[i]=(e[3*i+a]+e[3*a+i])*r,t[s]=(e[3*s+a]+e[3*a+s])*r}return t},p.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},void 0!==t&&(t.quat=p)}(e.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(t,e){this.real=t,this.imaginary=quat.create(),this.imaginary[Q_W]=-.5*(e[Q_X]*t[Q_X]+e[Q_Y]*t[Q_Y]+e[Q_Z]*t[Q_Z]),this.imaginary[Q_X]=.5*(e[Q_X]*t[Q_W]+e[Q_Y]*t[Q_Z]-e[Q_Z]*t[Q_Y]),this.imaginary[Q_Y]=.5*(-e[Q_X]*t[Q_Z]+e[Q_Y]*t[Q_W]+e[Q_Z]*t[Q_X]),this.imaginary[Q_Z]=.5*(e[Q_X]*t[Q_Y]-e[Q_Y]*t[Q_X]+e[Q_Z]*t[Q_W])},dualQuat.prototype.add=function(t,e,r){quat.copy(this.tmpQ1,t.real),quat.scale(this.tmpQ1,this.tmpQ1,e),quat.add(this.real,this.tmpQ1,this.real),quat.copy(this.tmpQ1,t.imaginary),quat.scale(this.tmpQ1,this.tmpQ1,r),quat.add(this.imaginary,this.tmpQ1,this.imaginary)},dualQuat.prototype.normalize=function(){var t=quat.length(this.real);this.real=quat.scale(this.real,this.real,1/t),this.imaginary=quat.scale(this.imaginary,this.imaginary,1/t)};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(t){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,t,this.real),rot=vec3.add(rot,rot,trans)};var Utils={};Utils.setAxisMatrix=function(t,e,r){var n=mat4.create();return n[0]=t[Q_X],n[4]=t[Q_Y],n[8]=t[Q_Z],n[1]=e[Q_X],n[5]=e[Q_Y],n[9]=e[Q_Z],n[2]=r[Q_X],n[6]=r[Q_Y],n[10]=r[Q_Z],n[12]=0,n[13]=0,n[14]=0,n[3]=0,n[7]=0,n[11]=0,n[15]=1,n=mat4.transpose(n,n)},Utils.matrixToQuat=function(t){var e,r=quat.create(),n=t,a=n[0],i=n[4],s=n[8],o=n[1],c=n[5],h=n[9],u=n[2],l=n[6],_=n[10],p=a+c+_;return p>0?(e=.5/Math.sqrt(p+1),r[Q_W]=.25/e,r[Q_X]=(l-h)*e,r[Q_Y]=(s-u)*e,r[Q_Z]=(o-i)*e):a>c&&a>_?(e=2*Math.sqrt(1+a-c-_),r[Q_W]=(l-h)/e,r[Q_X]=.25*e,r[Q_Y]=(i+o)/e,r[Q_Z]=(s+u)/e):c>_?(e=2*Math.sqrt(1+c-a-_),r[Q_W]=(s-u)/e,r[Q_X]=(i+o)/e,r[Q_Y]=.25*e,r[Q_Z]=(h+l)/e):(e=2*Math.sqrt(1+_-a-c),r[Q_W]=(o-i)/e,r[Q_X]=(s+u)/e,r[Q_Y]=(h+l)/e,r[Q_Z]=.25*e),r},Utils.rotateVec_90=function(t){return vec3.fromValues(-t[Q_Y],t[Q_X],t[Q_Z])},Utils.calcRotateMat=function(t){var e=vec3.clone(t);e=vec3.normalize(e,e);var r=Utils.rotateVec_90(e),n=vec3.fromValues(e[Q_X],e[Q_Y],0),a=vec3.fromValues(r[Q_X],r[Q_Y],0),i=vec3.fromValues(0,0,1);mat4.create();return Utils.setAxisMatrix(n,a,i)},Utils.getMatTranslate=function(t){var e=vec3.create();return e[Q_X]=t[12],e[Q_Y]=t[13],e[Q_Z]=t[14],e},Utils.addMat=function(t,e){for(var r=mat4.create(),n=0;n<16;n++)r[n]=t[n]+e[n];return r},Utils.mulMat=function(t,e){for(var r=mat4.create(),n=0;n<16;n++)r[n]=t[n]*e;return r},Utils.clamp=function(t,e,r){return t<e?e:t>r?r:t};var newVec1=vec3.create(),newVec2=vec3.create();Utils.vecInterp=function(t,e,r){newVec1=vec3.scale(newVec1,t,1-r),newVec2=vec3.scale(newVec2,e,r);var n=vec3.create();return n=vec3.add(n,newVec1,newVec2)},Utils.vec2Interp=function(t,e,r){var n=vec2.create(),a=vec2.create();n=vec2.scale(n,t,1-r),a=vec2.scale(a,e,r);var i=vec2.create();return i=vec2.add(i,n,a)},MeshBone.prototype.setRestParentMat=function(t,e){this.rest_parent_mat=t,null==e?(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(e)},MeshBone.prototype.setParentWorldMat=function(t){this.parent_world_mat=t},MeshBone.prototype.setParentWorldInvMat=function(t){this.parent_world_inv_mat=t},MeshBone.prototype.getLocalRestStartPt=function(){return this.local_rest_start_pt},MeshBone.prototype.getLocalRestEndPt=function(){return this.local_rest_end_pt},MeshBone.prototype.setLocalRestStartPt=function(t){this.local_rest_start_pt=vec3.create(),this.local_rest_start_pt=vec3.transformMat4(this.local_rest_start_pt,t,this.rest_parent_inv_mat),this.calcRestData()},MeshBone.prototype.setLocalRestEndPt=function(t){this.local_rest_end_pt=vec3.create(),this.local_rest_end_pt=vec3.transformMat4(this.local_rest_end_pt,t,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 t=this.computeDirs(this.local_rest_start_pt,this.local_rest_end_pt);this.local_rest_dir=t.first,this.local_rest_normal_dir=t.second,this.computeRestLength()}},MeshBone.prototype.setWorldStartPt=function(t){this.world_start_pt=t},MeshBone.prototype.setWorldEndPt=function(t){this.world_end_pt=t},MeshBone.prototype.fixDQs=function(t){quat.dot(this.world_dq.real,t.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 e=0;e<this.children.length;e++)this.children[e].fixDQs(this.world_dq)},MeshBone.prototype.initWorldPts=function(){this.setWorldStartPt(this.getWorldRestStartPt()),this.setWorldEndPt(this.getWorldRestEndPt());for(var t=0;t<this.children.length;t++)this.children[t].initWorldPts()},MeshBone.prototype.getWorldRestStartPt=function(){var t=this.rest_parent_mat,e=vec3.create();return e=vec3.transformMat4(e,this.local_rest_start_pt,t)},MeshBone.prototype.getWorldRestEndPt=function(){var t=this.rest_parent_mat,e=vec3.create();return e=vec3.transformMat4(e,this.local_rest_end_pt,t)},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 t=vec3.fromValues(this.local_rest_dir[Q_X],this.local_rest_dir[Q_Y],0),e=vec3.fromValues(this.local_binormal_dir[Q_X],this.local_binormal_dir[Q_Y],this.local_binormal_dir[Q_Z]),r=vec3.fromValues(this.local_rest_normal_dir[Q_X],this.local_rest_normal_dir[Q_Y],0),n=mat4.create();mat4.translate(n,n,this.local_rest_end_pt);var a=mat4.create();a=Utils.setAxisMatrix(t,r,e);var i=mat4.create();i=mat4.multiply(i,n,a),this.rest_world_mat=mat4.create(),this.rest_world_mat=mat4.multiply(this.rest_world_mat,this.rest_parent_mat,i),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 s=vec3.clone(this.getWorldRestEndPt());s=vec3.subtract(s,s,this.getWorldRestStartPt()),s=vec3.normalize(s,s),this.world_rest_pos=this.getWorldRestStartPt();var o=mat4.create();o=mat4.translate(o,o,this.getWorldRestStartPt());var c=vec3.create();c=vec3.sub(c,this.getWorldRestEndPt(),this.getWorldRestStartPt());var h=Utils.calcRotateMat(c),u=mat4.create();u=mat4.multiply(u,o,h),this.bind_world_mat=mat4.clone(u),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 _=this.children[l];_.setRestParentMat(this.rest_world_mat,this.rest_world_inv_mat),_.computeRestParentTransforms()}},MeshBone.prototype.computeParentTransforms=function(){var t=mat4.create();t=mat4.translate(t,t,this.getWorldEndPt());var e=vec3.create();e=vec3.subtract(e,this.getWorldEndpt(),this.getWorldStartPt());var r=Utils.calcRotateMat(e),n=mat4.create();n=mat4.multiply(n,t,r);var a=mat4.clone(n);a=mat4.invert(a,a);for(var i=0;i<children.length;i++){var s=children[i];s.setParentWorldMat(n),s.setParentWorldInvMat(a),s.computeParentTransforms()}},MeshBone.prototype.computeWorldDeltaTransforms=function(){var t=this.computeDirs(this.world_start_pt,this.world_end_pt),e=vec3.fromValues(t.first[Q_X],t.first[Q_Y],0),r=vec3.fromValues(t.second[Q_X],t.second[Q_Y],0),n=vec3.fromValues(this.local_binormal_dir[Q_X],this.local_binormal_dir[Q_Y],this.local_binormal_dir[Q_Z]),a=mat4.create();a=Utils.setAxisMatrix(e,r,n);var i=mat4.create();i=mat4.translate(i,i,this.world_start_pt),this.world_delta_mat=mat4.create(),this.world_delta_mat=mat4.multiply(this.world_delta_mat,i,a),this.world_delta_mat=mat4.multiply(this.world_delta_mat,this.world_delta_mat,this.bind_world_inv_mat);var s=Utils.matrixToQuat(this.world_delta_mat),o=Utils.getMatTranslate(this.world_delta_mat);this.world_dq=new dualQuat,this.world_dq.createFromData(s,o);for(var c=0;c<this.children.length;c++)this.children[c].computeWorldDeltaTransforms()},MeshBone.prototype.addChild=function(t){t.setRestParentMat(this.rest_world_mat,this.rest_world_inv_mat),this.children.push(t)},MeshBone.prototype.getChildren=function(){return this.children},MeshBone.prototype.hasBone=function(t){for(var e=0;e<this.children.length;e++)if(this.children[e]==t)return!0;return!1},MeshBone.prototype.getChildByKey=function(t){if(this.key===t)return this;for(var e=null,r=0;r<this.children.length;r++){var n=this.children[r].getChildByKey(t);if(null!=n){e=n;break}}return e},MeshBone.prototype.getKey=function(){return this.key},MeshBone.prototype.getAllBoneKeys=function(){var t=[];t.push(this.getKey());for(var e=0;e<this.children.length;e++){var r=this.children[e].getAllBoneKeys();t=t.concat(r)}return t},MeshBone.prototype.getAllChildren=function(){var t=[];t.push(this);for(var e=0;e<this.children.length;e++){var r=this.children[e].getAllChildren();t=t.concat(r)}return t},MeshBone.prototype.getBoneDepth=function(t,e){if(t==this)return e;for(var r=0;r<this.children.length;r++){var n=this.children[r].getBoneDepth(t,e+1);if(-1!=n)return n}return-1},MeshBone.prototype.isLeaf=function(){return 0==this.children.length},MeshBone.prototype.deleteChildren=function(){for(var t=0;t<this.children.length;t++)this.children[t].deleteChildren();this.children=[]},MeshBone.prototype.setTagId=function(t){this.tag_id=t},MeshBone.prototype.getTagId=function(){return this.tag_id},MeshBone.prototype.computeDirs=function(t,e){var r=vec3.create();r=vec3.subtract(r,e,t),r=vec3.normalize(r,r);var n=Utils.rotateVec_90(r),a={};return a.first=r,a.second=n,a},MeshBone.prototype.computeRestLength=function(){var t=vec3.create();t=vec3.subtract(t,this.local_rest_end_pt,this.local_rest_start_pt),this.rest_length=vec3.length(t)},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(t,e,r){for(var n=this.getRestPtsIndex(),a=e,i=0;i<16;i++)accum_mat[i]=0;Object.keys(r).length;for(var i=0,s=this.getNumPts();i<s;i++){var o=vec3.set(tmp1,this.store_rest_pts[0+n],this.store_rest_pts[1+n],this.store_rest_pts[2+n]);1==this.use_local_displacements&&(o[Q_X]+=this.local_displacements[i][Q_X],o[Q_Y]+=this.local_displacements[i][Q_Y]);for(u=0;u<16;u++)accum_mat[u]=0;accum_dq.reset();for(var c=this.relevant_bones_indices[i],h=c.length,u=0;u<h;u++){var l=c[u],_=this.fast_bones_map[l],p=this.fast_normal_weight_map[l][i],d=p,m=_.getWorldDq();accum_dq.add(m,p,d)}accum_dq.normalize();var f=vec3.set(tmp2,o[Q_X],o[Q_Y],o[Q_Z]);final_pt=accum_dq.transform(f),1==this.use_post_displacements&&(final_pt[Q_X]+=this.post_displacements[i][Q_X],final_pt[Q_Y]+=this.post_displacements[i][Q_Y]),t[0+a]=final_pt[Q_X],t[1+a]=final_pt[Q_Y],t[2+a]=final_pt[Q_Z],n+=3,a+=3}1==this.use_uv_warp&&this.runUvWarp()},MeshRenderRegion.prototype.setMainBoneKey=function(t){this.main_bone_key=t},MeshRenderRegion.prototype.determineMainBone=function(t){this.main_bone=t.getChildByKey(this.main_bone_key)},MeshRenderRegion.prototype.setUseDq=function(t){this.use_dq=t},MeshRenderRegion.prototype.setName=function(t){this.name=t},MeshRenderRegion.prototype.getName=function(){return this.name},MeshRenderRegion.prototype.setUseLocalDisplacements=function(t){if(this.use_local_displacements=t,this.local_displacements.length!=this.getNumPts()&&this.use_local_displacements){this.local_displacements=[];for(var e=0;e<this.getNumPts();e++)this.local_displacements.push(vec2.create())}},MeshRenderRegion.prototype.getUseLocalDisplacements=function(){return this.use_local_displacements},MeshRenderRegion.prototype.setUsePostDisplacements=function(t){if(this.use_post_displacements=t,this.post_displacements.length!=this.getNumPts()&&this.use_post_displacements){this.post_displacements=[];for(var e=0;e<this.getNumPts();e++)this.post_displacements.push(vec2.create())}},MeshRenderRegion.prototype.getUsePostDisplacements=function(){return this.use_post_displacements},MeshRenderRegion.prototype.getRestLocalPt=function(t){var e=this.getRestPtsIndex()+3*t;return vec2.fromValues(this.store_rest_pts[0+e],this.store_rest_pts[1+e])},MeshRenderRegion.prototype.getLocalIndex=function(t){var e=this.getIndicesIndex()+t;return this.store_indices[e]},MeshRenderRegion.prototype.clearLocalDisplacements=function(){for(var t=0;t<this.local_displacements.length;t++)this.local_displacements[t]=vec2.create()},MeshRenderRegion.prototype.clearPostDisplacements=function(){for(var t=0;t<this.post_displacements.length;t++)this.post_displacements[t]=vec2.create()},MeshRenderRegion.prototype.setUseUvWarp=function(t){this.use_uv_warp=t,0==this.use_uv_warp&&this.restoreRefUv()},MeshRenderRegion.prototype.getUseUvWarp=function(){return this.use_uv_warp},MeshRenderRegion.prototype.setUvWarpLocalOffset=function(t){this.uv_warp_local_offset=t},MeshRenderRegion.prototype.setUvWarpGlobalOffset=function(t){this.uv_warp_global_offset=t},MeshRenderRegion.prototype.setUvWarpScale=function(t){this.uv_warp_scale=t},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 t=this.getUVsIndex(),e=0;e<this.uv_warp_ref_uvs.length;e++){var r=vec2.clone(this.uv_warp_ref_uvs[e]);(r=vec2.subtract(r,r,this.uv_warp_local_offset))[Q_X]*=this.uv_warp_scale[Q_X],r[Q_Y]*=this.uv_warp_scale[Q_Y],r=vec2.add(r,r,this.uv_warp_global_offset),this.store_uvs[0+t]=r[Q_X],this.store_uvs[1+t]=r[Q_Y],t+=2}},MeshRenderRegion.prototype.restoreRefUv=function(){for(var t=this.getUVsIndex(),e=0;e<this.uv_warp_ref_uvs.length;e++){var r=this.uv_warp_ref_uvs[e];this.store_uvs[0+t]=r[Q_X],this.store_uvs[1+t]=r[Q_Y],t+=2}},MeshRenderRegion.prototype.getTagId=function(){return this.tag_id},MeshRenderRegion.prototype.setTagId=function(t){this.tag_id=t},MeshRenderRegion.prototype.initFastNormalWeightMap=function(t){this.relevant_bones_indices=[];for(var e in t){var r=this.normal_weight_map[e];this.fast_normal_weight_map.push(r)}for(var n=0;n<this.getNumPts();n++){for(var a=[],i=0;i<this.fast_normal_weight_map.length;i++)this.fast_normal_weight_map[i][n]>.05&&a.push(i);this.relevant_bones_indices.push(a)}for(var e in t){var s=t[e];this.fast_bones_map.push(s)}},MeshRenderRegion.prototype.initUvWarp=function(){var t=this.getUVsIndex();this.uv_warp_ref_uvs=[];for(var e=0;e<this.getNumPts();e++)this.uv_warp_ref_uvs.push(vec2.create()),this.uv_warp_ref_uvs[e]=vec2.fromValues(this.store_uvs[t],this.store_uvs[t+1]),t+=2},MeshRenderBoneComposition.prototype.addRegion=function(t){this.regions.push(t)},MeshRenderBoneComposition.prototype.setRootBone=function(t){this.root_bone=t},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 t=0;t<this.regions.length;t++)cur_key=this.regions[t].getName(),this.regions_map[cur_key]=this.regions[t]},MeshRenderBoneComposition.genBoneMap=function(t){for(var e={},r=t.getAllBoneKeys(),n=0;n<r.length;n++){var a=r[n];e[a]=t.getChildByKey(a)}return e},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(t){for(var e=0;e<this.regions.length;e++){var r=this.regions[e];if(r.getTagId()==t)return r}return null},MeshRenderBoneComposition.prototype.resetToWorldRestPts=function(){this.getRootBone().initWorldPts()},MeshRenderBoneComposition.prototype.updateAllTransforms=function(t){t&&this.getRootBone().computeParentTransforms(),this.getRootBone().computeWorldDeltaTransforms(),this.getRootBone().fixDQs(this.getRootBone().getWorldDq())},MeshBoneCache.prototype.setWorldStartPt=function(t){this.world_start_pt=t},MeshBoneCache.prototype.setWorldEndPt=function(t){this.world_end_pt=t},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(t){this.local_displacements=t},MeshDisplacementCache.prototype.setPostDisplacements=function(t){this.post_displacements=t},MeshDisplacementCache.prototype.getKey=function(){return this.key},MeshDisplacementCache.prototype.getLocalDisplacements=function(){return this.local_displacements},M