@pixi-spine/runtime-3.8
Version:
Pixi runtime for spine 3.8 models
1 lines • 3.93 kB
Source Map (JSON)
{"version":3,"file":"Slot.mjs","sources":["../../src/core/Slot.ts"],"sourcesContent":["import { Color, ISlot } from '@pixi-spine/base';\n\nimport type { Attachment } from './attachments/Attachment';\nimport type { Bone } from './Bone';\nimport type { SlotData } from './SlotData';\n\n/**\n * @public\n */\nexport class Slot implements ISlot {\n // this is canon\n blendMode: number;\n data: SlotData;\n bone: Bone;\n color: Color;\n darkColor: Color;\n attachment: Attachment;\n private attachmentTime: number;\n attachmentState: number;\n deform = new Array<number>();\n\n constructor(data: SlotData, bone: Bone) {\n if (data == null) throw new Error('data cannot be null.');\n if (bone == null) throw new Error('bone cannot be null.');\n this.data = data;\n this.bone = bone;\n this.color = new Color();\n this.darkColor = data.darkColor == null ? null : new Color();\n this.setToSetupPose();\n\n this.blendMode = this.data.blendMode;\n }\n\n /** @return May be null. */\n getAttachment(): Attachment {\n return this.attachment;\n }\n\n /** Sets the attachment and if it changed, resets {@link #getAttachmentTime()} and clears {@link #getAttachmentVertices()}.\n * @param attachment May be null. */\n setAttachment(attachment: Attachment) {\n if (this.attachment == attachment) return;\n this.attachment = attachment;\n this.attachmentTime = this.bone.skeleton.time;\n this.deform.length = 0;\n }\n\n setAttachmentTime(time: number) {\n this.attachmentTime = this.bone.skeleton.time - time;\n }\n\n /** Returns the time since the attachment was set. */\n getAttachmentTime(): number {\n return this.bone.skeleton.time - this.attachmentTime;\n }\n\n setToSetupPose() {\n this.color.setFromColor(this.data.color);\n if (this.darkColor != null) this.darkColor.setFromColor(this.data.darkColor);\n if (this.data.attachmentName == null) this.attachment = null;\n else {\n this.attachment = null;\n this.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName));\n }\n }\n}\n"],"names":[],"mappings":";;AASO,MAAM,IAAsB,CAAA;AAAA,EAY/B,WAAA,CAAY,MAAgB,IAAY,EAAA;AAFxC,IAAA,IAAA,CAAA,MAAA,GAAS,I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