UNPKG

pixi-dragonbones-runtime

Version:
428 lines (427 loc) 15.1 kB
/** * The MIT License (MIT) * * Copyright (c) 2012-2018 DragonBones team and other contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import { BaseObject, BlendMode } from "../core/index.js"; import { Matrix, ColorTransform } from "../geom/index.js"; import { DisplayData, TextureData, GeometryData, BoundingBoxData, SlotData } from "../model/index.js"; import { Armature } from "./Armature.js"; import { Bone } from "./Bone.js"; import { TransformObject } from "./TransformObject.js"; /** * @private */ export declare class DisplayFrame extends BaseObject { static toString(): string; rawDisplayData: DisplayData | null; displayData: DisplayData | null; textureData: TextureData | null; display: any | Armature | null; readonly deformVertices: Array<number>; protected _onClear(): void; updateDeformVertices(): void; getGeometryData(): GeometryData | null; getBoundingBox(): BoundingBoxData | null; getTextureData(): TextureData | null; } /** * [en] The slot attached to the armature, controls the display status and properties of the display object. * A bone can contain multiple slots. * A slot can contain multiple display objects, displaying only one of the display objects at a time, * but you can toggle the display object into frame animation while the animation is playing. * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, * and a custom other display object. * * [zh] 插槽附着在骨骼上,控制显示对象的显示状态和属性。 * 一个骨骼上可以包含多个插槽。 * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 * * @see Armature * @see Bone * @see SlotData * @version DragonBones 3.0 */ export declare abstract class Slot extends TransformObject { /** * [en] Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states. * * [zh] 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 * * @default null * @see AnimationState#displayControl * @see AnimationState#name * @see AnimationState#group * @version DragonBones 4.5 */ displayController: string | null; protected _displayDataDirty: boolean; protected _displayDirty: boolean; protected _geometryDirty: boolean; protected _textureDirty: boolean; protected _visibleDirty: boolean; protected _blendModeDirty: boolean; protected _zOrderDirty: boolean; /** * @internal */ _colorDirty: boolean; /** * @internal */ _verticesDirty: boolean; protected _transformDirty: boolean; protected _visible: boolean; protected _blendMode: BlendMode; protected _displayIndex: number; protected _animationDisplayIndex: number; protected _cachedFrameIndex: number; /** * @internal */ _zOrder: number; /** * @internal */ _zIndex: number; /** * @internal */ _pivotX: number; /** * @internal */ _pivotY: number; protected readonly _localMatrix: Matrix; /** * @internal */ readonly _colorTransform: ColorTransform; /** * @internal */ readonly _displayFrames: Array<DisplayFrame>; /** * @internal */ readonly _geometryBones: Array<Bone | null>; /** * @internal */ _slotData: SlotData; /** * @internal */ _displayFrame: DisplayFrame | null; /** * @internal */ _geometryData: GeometryData | null; protected _boundingBoxData: BoundingBoxData | null; protected _textureData: TextureData | null; protected _rawDisplay: any; protected _meshDisplay: any; protected _display: any | null; protected _childArmature: Armature | null; /** * @private */ protected _parent: Bone; /** * @internal */ _cachedFrameIndices: Array<number> | null; protected _onClear(): void; protected abstract _initDisplay(value: any, isRetain: boolean): void; protected abstract _disposeDisplay(value: any, isRelease: boolean): void; protected abstract _onUpdateDisplay(): void; protected abstract _addDisplay(): void; protected abstract _replaceDisplay(value: any): void; protected abstract _removeDisplay(): void; protected abstract _updateZOrder(): void; /** * @internal */ abstract _updateVisible(): void; protected abstract _updateBlendMode(): void; protected abstract _updateColor(): void; protected abstract _updateFrame(): void; protected abstract _updateMesh(): void; protected abstract _updateTransform(): void; protected abstract _identityTransform(): void; protected _hasDisplay(display: any): boolean; /** * @internal */ _isBonesUpdate(): boolean; /** * @internal */ _updateAlpha(): void; protected _updateDisplayData(): void; protected _updateDisplay(): void; protected _updateGlobalTransformMatrix(isCache: boolean): void; /** * @internal */ _setDisplayIndex(value: number, isAnimation?: boolean): void; /** * @internal */ _setZOrder(value: number): boolean; /** * @internal */ _setColor(value: ColorTransform): boolean; /** * @internal */ init(slotData: SlotData, armatureValue: Armature, rawDisplay: any, meshDisplay: any): void; /** * @internal */ update(cacheFrameIndex: number): void; /** * [en] Forces the slot to update the state of the display object in the next frame. * * [zh] 强制插槽在下一帧更新显示对象的状态。 * * @version DragonBones 4.5 */ invalidUpdate(): void; /** * @private */ updateTransformAndMatrix(): void; /** * @private */ replaceRawDisplayData(displayData: DisplayData | null, index?: number): void; /** * @private */ replaceDisplayData(displayData: DisplayData | null, index?: number): void; /** * @private */ replaceTextureData(textureData: TextureData | null, index?: number): void; /** * @private */ replaceDisplay(value: any | Armature | null, index?: number): void; /** * [en] Check whether a specific point is inside a custom bounding box in the slot. * The coordinate system of the point is the inner coordinate system of the armature. * Custom bounding boxes need to be customized in Dragonbones Pro. * * [zh] 检查特定点是否在插槽的自定义边界框内。 * 点的坐标系为骨架内坐标系。 * 自定义边界框需要在 DragonBones Pro 中自定义。 * * @param x - [en] The horizontal coordinate of the point. * @param x - [zh] 点的水平坐标。 * * @param y - [en] The vertical coordinate of the point. * @param y - [zh] 点的垂直坐标。 * * @version DragonBones 5.0 */ containsPoint(x: number, y: number): boolean; /** * [en] Check whether a specific segment intersects a custom bounding box for the slot. * The coordinate system of the segment and intersection is the inner coordinate system of the armature. * Custom bounding boxes need to be customized in Dragonbones Pro. * * [zh] 检查特定线段是否与插槽的自定义边界框相交。 * 线段和交点的坐标系均为骨架内坐标系。 * 自定义边界框需要在 DragonBones Pro 中自定义。 * * @param xA - [en] The horizontal coordinate of the beginning of the segment. * @param xA - [zh] 线段起点的水平坐标。 * * @param yA - [en] The vertical coordinate of the beginning of the segment. * @param yA - [zh] 线段起点的垂直坐标。 * * @param xB - [en] The horizontal coordinate of the end point of the segment. * @param xB - [zh] 线段终点的水平坐标。 * * @param yB - [en] The vertical coordinate of the end point of the segment. * @param yB - [zh] 线段终点的垂直坐标。 * * @param intersectionPointA - [en] The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) * @param intersectionPointA - [zh] 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) * * @param intersectionPointB - [en] The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) * @param intersectionPointB - [zh] 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) * * @param normalRadians - [en] The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) * @param normalRadians - [zh] 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) * * @returns [en] Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] * @returns [zh] 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] * * @version DragonBones 5.0 */ intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { x: number; y: number; } | null, intersectionPointB?: { x: number; y: number; } | null, normalRadians?: { x: number; y: number; } | null): number; /** * @private */ getDisplayFrameAt(index: number): DisplayFrame; /** * [en] The visible of slot's display object. * * [zh] 插槽的显示对象的可见。 * * @default true * @version DragonBones 5.6 */ get visible(): boolean; set visible(value: boolean); /** * @private */ get displayFrameCount(): number; set displayFrameCount(value: number); /** * [en] The index of the display object displayed in the display list. * * [zh] 此时显示的显示对象在显示列表中的索引。 * * @example * ```ts * let slot = armature.getSlot("weapon"); * slot.displayIndex = 3; * slot.displayController = "none"; * ``` * @version DragonBones 4.5 */ get displayIndex(): number; set displayIndex(value: number); /** * [en] The slot name. * * [zh] 插槽名称。 * * @see SlotData#name * @version DragonBones 3.0 */ get name(): string; /** * [en] Contains a display list of display objects or child armatures. * * [zh] 包含显示对象或子骨架的显示列表。 * * @version DragonBones 3.0 */ get displayList(): Array<any>; set displayList(value: Array<any>); /** * [en] The slot data. * * [zh] 插槽数据。 * * @see SlotData * @version DragonBones 4.5 */ get slotData(): SlotData; /** * [en] The custom bounding box data for the slot at current time. * * [zh] 插槽此时的自定义包围盒数据。 * * @version DragonBones 5.0 */ get boundingBoxData(): BoundingBoxData | null; /** * @private */ get rawDisplay(): any; /** * @private */ get meshDisplay(): any; /** * [en] The display object that the slot displays at this time. * * [zh] 插槽此时显示的显示对象。 * * @example * ```ts * let slot = armature.getSlot("text"); * slot.display = new yourEngine.TextField(); * ``` * @version DragonBones 3.0 */ get display(): any; set display(value: any); /** * [en] The child armature that the slot displayed at current time. * * [zh] 插槽此时显示的子骨架。 * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 * * @example * ```ts * let slot = armature.getSlot("weapon"); * let prevChildArmature = slot.childArmature; * if (prevChildArmature) { * prevChildArmature.dispose(); * } * slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project"); * ``` * @version DragonBones 3.0 */ get childArmature(): Armature | null; set childArmature(value: Armature | null); /** * [en] The parent bone to which it belongs. * * [zh] 所属的父骨骼。 * * @version DragonBones 3.0 */ get parent(): Bone; /** * [en] Deprecated, please refer to {@link #display}. * * [zh] 已废弃,请参考 {@link #display}。 * * @deprecated */ getDisplay(): any; /** * [en] Deprecated, please refer to {@link #display}. * * [zh] 已废弃,请参考 {@link #display}。 * * @deprecated */ setDisplay(value: any): void; }