UNPKG

@pixi-spine/base

Version:

Base of pixi-spine integration, common files for spine runtimes of different versions

1 lines 7.16 kB
{"version":3,"file":"ISkeleton.mjs","sources":["../../src/core/ISkeleton.ts"],"sourcesContent":["import type { AttachmentType } from './AttachmentType';\nimport type { IAnimation, IEventData } from './IAnimation';\nimport type { IIkConstraintData, IPathConstraintData, ITransformConstraintData } from './IConstraint';\nimport type { Color, Vector2, Map } from './Utils';\nimport type { TextureRegion } from './TextureRegion';\nimport type { BLEND_MODES, Matrix } from '@pixi/core';\n\n// This enum was moved from BoneData.ts of spine 3.7, 3.8 and 4.0\n\n/** Determines how a bone inherits world transforms from parent bones.\n * @public\n * */\nexport enum TransformMode {\n Normal,\n OnlyTranslation,\n NoRotationOrReflection,\n NoScale,\n NoScaleOrReflection,\n}\n\n/**\n * @public\n */\nexport interface IBone {\n data: IBoneData;\n matrix: Matrix;\n active: boolean;\n}\n\n/**\n * @public\n */\nexport interface ISkin {\n name: string;\n attachments: Array<Map<IAttachment>>;\n\n getAttachment(slotIndex: number, name: string): IAttachment | null;\n}\n\n/**\n * @public\n */\nexport interface IAttachment {\n name: string;\n type: AttachmentType;\n readonly sequence?: ISequence;\n}\n\n/**\n * @public\n */\nexport interface IHasTextureRegion {\n /** The name used to find the {@link #region()}. */\n path: string;\n\n /** The region used to draw the attachment. After setting the region or if the region's properties are changed,\n * {@link #updateRegion()} must be called. */\n region: TextureRegion | null;\n\n /** Updates any values the attachment calculates using the {@link #getRegion()}. Must be called after setting the\n * {@link #getRegion()} or if the region's properties are changed. */\n // updateRegion (): void;\n\n /** The color to tint the attachment. */\n color: Color;\n\n readonly sequence: ISequence | null;\n}\n\n/**\n * @public\n */\nexport interface ISequence {\n id: number;\n regions: TextureRegion[];\n apply(slot: ISlot, attachment: IHasTextureRegion): void;\n}\n\n/**\n * @public\n */\nexport interface IVertexAttachment<Slot extends ISlot = ISlot> extends IAttachment {\n id: number;\n computeWorldVerticesOld(slot: Slot, worldVertices: ArrayLike<number>): void;\n computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;\n worldVerticesLength: number;\n}\n\n/**\n * @public\n */\nexport interface IClippingAttachment extends IVertexAttachment {\n endSlot?: ISlotData;\n}\n\n/**\n * @public\n */\nexport interface IRegionAttachment extends IAttachment {\n region: TextureRegion;\n color: Color;\n x;\n y;\n scaleX;\n scaleY;\n rotation;\n width;\n height: number;\n}\n\n/**\n * @public\n */\nexport interface IMeshAttachment extends IVertexAttachment {\n region: TextureRegion;\n color: Color;\n regionUVs: Float32Array;\n triangles: number[];\n hullLength: number;\n}\n\n/**\n * @public\n */\nexport interface ISlotData {\n index: number;\n name: string;\n boneData: IBoneData;\n color: Color;\n darkColor: Color;\n attachmentName: string;\n blendMode: BLEND_MODES;\n}\n\n/**\n * @public\n */\nexport interface IBoneData {\n index: number;\n name: string;\n parent: IBoneData;\n length: number;\n x: number;\n y: number;\n rotation: number;\n scaleX: number;\n scaleY: number;\n shearX: number;\n shearY: number;\n transformMode: TransformMode;\n}\n\n/**\n * @public\n */\nexport interface ISlot {\n getAttachment(): IAttachment;\n data: ISlotData;\n color: Color;\n darkColor: Color;\n blendMode: number;\n bone: IBone;\n\n sprites?: any;\n currentSprite?: any;\n currentSpriteName?: string;\n\n meshes?: any;\n currentMesh?: any;\n currentMeshName?: string;\n currentMeshId?: number;\n\n currentGraphics?: any;\n clippingContainer?: any;\n\n hackRegion?: TextureRegion;\n hackAttachment?: IAttachment;\n}\n\n/**\n * @public\n */\nexport interface ISkeleton<SkeletonData extends ISkeletonData = ISkeletonData, Bone extends IBone = IBone, Slot extends ISlot = ISlot, Skin extends ISkin = ISkin> {\n bones: Bone[];\n slots: Slot[];\n drawOrder: Slot[];\n skin: Skin;\n data: SkeletonData;\n x: number; // added for debug purposes\n y: number; // added for debug purposes\n updateWorldTransform(): void;\n setToSetupPose(): void;\n findSlotIndex(slotName: string): number;\n getAttachmentByName(slotName: string, attachmentName: string): IAttachment;\n\n setBonesToSetupPose(): void;\n setSlotsToSetupPose(): void;\n findBone(boneName: string): Bone;\n findSlot(slotName: string): Slot;\n findBoneIndex(boneName: string): number;\n findSlotIndex(slotName: string): number;\n setSkinByName(skinName: string): void;\n setAttachment(slotName: string, attachmentName: string): void;\n getBounds(offset: Vector2, size: Vector2, temp: Array<number>): void;\n}\n\n/**\n * @public\n */\nexport interface ISkeletonParser {\n scale: number;\n}\n\n/**\n * @public\n */\nexport interface ISkeletonData<\n BoneData extends IBoneData = IBoneData,\n SlotData extends ISlotData = ISlotData,\n Skin extends ISkin = ISkin,\n Animation extends IAnimation = IAnimation,\n EventData extends IEventData = IEventData,\n IkConstraintData extends IIkConstraintData = IIkConstraintData,\n TransformConstraintData extends ITransformConstraintData = ITransformConstraintData,\n PathConstraintData extends IPathConstraintData = IPathConstraintData\n> {\n name: string;\n bones: BoneData[];\n slots: SlotData[];\n skins: Skin[];\n defaultSkin: Skin;\n events: EventData[];\n animations: Animation[];\n version: string;\n hash: string;\n width: number;\n height: number;\n ikConstraints: IkConstraintData[];\n transformConstraints: TransformConstraintData[];\n pathConstraints: PathConstraintData[];\n\n findBone(boneName: string): BoneData | null;\n findBoneIndex(boneName: string): number;\n findSlot(slotName: string): SlotData | null;\n findSlotIndex(slotName: string): number;\n findSkin(skinName: string): Skin | null;\n\n findEvent(eventDataName: string): EventData | null;\n findAnimation(animationName: string): Animation | null;\n findIkConstraint(constraintName: string): IkConstraintData | null;\n findTransformConstraint(constraintName: string): TransformConstraintData | null;\n findPathConstraint(constraintName: string): PathConstraintData | null;\n}\n"],"names":["TransformMode"],"mappings":"AAYY,IAAA,aAAA,qBAAAA,cAAL,KAAA;AACH,EAAAA,cAAA,CAAA,cAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAA,CAAA;AACA,EAAAA,cAAA,CAAA,cAAA,CAAA,iBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,iBAAA,CAAA;AACA,EAAAA,cAAA,CAAA,cAAA,CAAA,wBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,wBAAA,CAAA;AACA,EAAAA,cAAA,CAAA,cAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAA,CAAA;AACA,EAAAA,cAAA,CAAA,cAAA,CAAA,qBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,qBAAA,CAAA;AALQ,EAAAA,OAAAA,cAAAA,CAAAA;AAAA,CAAA,EAAA,aAAA,IAAA,EAAA;;;;"}