pixi-dragonbones-runtime
Version:
DragonBones Runtime for Pixi.js
3 lines (2 loc) • 4.98 kB
JavaScript
"use strict";var t=require("../core/BaseObject.cjs");require("../core/DragonBones.cjs");var s=require("../geom/ColorTransform.cjs"),e=require("../geom/Rectangle.cjs"),n=require("../geom/Transform.cjs"),i=require("./DisplayData.cjs");class a extends t.BaseObject{constructor(){super(...arguments),this.aabb=new e.Rectangle,this.animationNames=[],this.sortedBones=[],this.sortedSlots=[],this.defaultActions=[],this.actions=[],this.bones={},this.slots={},this.constraints={},this.skins={},this.animations={},this.canvas=null,this.userData=null}static toString(){return"[class dragonBones.ArmatureData]"}_onClear(){for(const t of this.defaultActions)t.returnToPool();for(const t of this.actions)t.returnToPool();for(let t in this.bones)this.bones[t].returnToPool(),delete this.bones[t];for(let t in this.slots)this.slots[t].returnToPool(),delete this.slots[t];for(let t in this.constraints)this.constraints[t].returnToPool(),delete this.constraints[t];for(let t in this.skins)this.skins[t].returnToPool(),delete this.skins[t];for(let t in this.animations)this.animations[t].returnToPool(),delete this.animations[t];null!==this.canvas&&this.canvas.returnToPool(),null!==this.userData&&this.userData.returnToPool(),this.type=0,this.frameRate=0,this.cacheFrameRate=0,this.scale=1,this.name="",this.aabb.clear(),this.animationNames.length=0,this.sortedBones.length=0,this.sortedSlots.length=0,this.defaultActions.length=0,this.actions.length=0,this.defaultSkin=null,this.defaultAnimation=null,this.canvas=null,this.userData=null,this.parent=null}sortBones(){const t=this.sortedBones.length;if(t<=0)return;const s=this.sortedBones.concat();let e=0,n=0;for(this.sortedBones.length=0;n<t;){const i=s[e++];if(e>=t&&(e=0),this.sortedBones.indexOf(i)>=0)continue;let a=!1;for(let t in this.constraints){const s=this.constraints[t];if(s.root===i&&this.sortedBones.indexOf(s.target)<0){a=!0;break}}a||(null!==i.parent&&this.sortedBones.indexOf(i.parent)<0||(this.sortedBones.push(i),n++))}}cacheFrames(t){if(!(this.cacheFrameRate>0)){this.cacheFrameRate=t;for(let t in this.animations)this.animations[t].cacheFrames(this.cacheFrameRate)}}setCacheFrame(t,s){const e=this.parent.cachedFrames;let n=e.length;return e.length+=10,e[n]=t.a,e[n+1]=t.b,e[n+2]=t.c,e[n+3]=t.d,e[n+4]=t.tx,e[n+5]=t.ty,e[n+6]=s.rotation,e[n+7]=s.skew,e[n+8]=s.scaleX,e[n+9]=s.scaleY,n}getCacheFrame(t,s,e){const n=this.parent.cachedFrames;t.a=n[e],t.b=n[e+1],t.c=n[e+2],t.d=n[e+3],t.tx=n[e+4],t.ty=n[e+5],s.rotation=n[e+6],s.skew=n[e+7],s.scaleX=n[e+8],s.scaleY=n[e+9],s.x=t.tx,s.y=t.ty}addBone(t){t.name in this.bones?console.warn("Same bone: "+t.name):(this.bones[t.name]=t,this.sortedBones.push(t))}addSlot(t){t.name in this.slots?console.warn("Same slot: "+t.name):(this.slots[t.name]=t,this.sortedSlots.push(t))}addConstraint(t){t.name in this.constraints?console.warn("Same constraint: "+t.name):this.constraints[t.name]=t}addSkin(t){t.name in this.skins?console.warn("Same skin: "+t.name):(t.parent=this,this.skins[t.name]=t,null===this.defaultSkin&&(this.defaultSkin=t),"default"===t.name&&(this.defaultSkin=t))}addAnimation(t){t.name in this.animations?console.warn("Same animation: "+t.name):(t.parent=this,this.animations[t.name]=t,this.animationNames.push(t.name),null===this.defaultAnimation&&(this.defaultAnimation=t))}addAction(t,s){s?this.defaultActions.push(t):this.actions.push(t)}getBone(t){return t in this.bones?this.bones[t]:null}getSlot(t){return t in this.slots?this.slots[t]:null}getConstraint(t){return t in this.constraints?this.constraints[t]:null}getSkin(t){return t in this.skins?this.skins[t]:null}getMesh(t,s,e){const n=this.getSkin(t);return null===n?null:n.getDisplay(s,e)}getAnimation(t){return t in this.animations?this.animations[t]:null}}class o extends t.BaseObject{constructor(){super(...arguments),this.transform=new n.Transform,this.userData=null}static toString(){return"[class dragonBones.BoneData]"}_onClear(){null!==this.userData&&this.userData.returnToPool(),this.inheritTranslation=!1,this.inheritRotation=!1,this.inheritScale=!1,this.inheritReflection=!1,this.type=0,this.length=0,this.alpha=1,this.name="",this.transform.identity(),this.userData=null,this.parent=null}}class r extends t.BaseObject{constructor(){super(...arguments),this.color=null,this.userData=null}static createColor(){return new s.ColorTransform}static toString(){return"[class dragonBones.SlotData]"}_onClear(){null!==this.userData&&this.userData.returnToPool(),this.blendMode=0,this.displayIndex=0,this.zOrder=0,this.zIndex=0,this.alpha=1,this.name="",this.color=null,this.userData=null,this.parent=null}}r.DEFAULT_COLOR=new s.ColorTransform,exports.ArmatureData=a,exports.BoneData=o,exports.SlotData=r,exports.SurfaceData=class extends o{constructor(){super(...arguments),this.geometry=new i.GeometryData}static toString(){return"[class dragonBones.SurfaceData]"}_onClear(){super._onClear(),this.type=1,this.segmentX=0,this.segmentY=0,this.geometry.clear()}};
//# sourceMappingURL=ArmatureData.cjs.map