cocos-enhance-kit/creator-sp.d.ts

856 lines
19 KiB
TypeScript
Raw Normal View History

2022-06-24 17:04:46 +00:00
declare module cc {
/**
* Cocos Creator Service Pack
*/
module sp {
/**
*
*/
const inited: boolean,
/**
*
*/
const version: string,
/**
*
*
* 8
*/
const MAX_MULTITEXTURE_NUM: number;
/**
*
*/
let autoSwitchMaterial: boolean;
/**
*
*/
let allowDynamicAtlas: boolean;
/**
* Label DPI
*/
let enableLabelRetina: boolean;
/**
* Label
*/
let labelRetinaScale: number;
/**
* Char
*/
let charAtlasAutoBatchCount: number;
/**
* Char
*/
let charAtlasAutoResetBeforeSceneLoad: boolean;
/**
* Effect Asset
*/
const multi2dSpriteEffectAsset: cc.EffectAsset;
/**
* property index to name
*/
function propertyIndex2Name(index: number): string;
/**
* property name to index
*/
function propertyName2Index(name: string): number;
/**
* Material
*/
class MultiHandler {
/**
*
*/
material: cc.Material;
/**
* Texture
*
* cc.Texture2D
*/
protected textures: any[];
/**
*
*/
protected hasEmptySlot: boolean;
constructor(material?: cc.Material);
/**
* Material
*
* Material textures
*/
syncTextures(): void;
/**
* cc.Texture2D
*/
setTexture(index: number, texture: cc.Texture2D): void;
/**
*
*
* cc.Texture2D
*/
removeTexture(texture: any): void;
/**
*
*
* cc.Texture2D
*/
hasTexture(texture: any): boolean;
/**
* Index -1
*
* cc.Texture2D
*/
getIndex(texture: any): number;
/**
* index
*
* cc.Texture2D
*/
getTexture(index: number): any;
/**
* Index -1
*/
getEmptyIndex(): number;
/**
* -1 cc.Texture2D
*/
autoSetTexture(texture: cc.Texture2D): number;
}
/**
*
*/
class MultiBatcher {
/**
*
*/
handlers: MultiHandler[];
/**
*
*/
nextHandler: MultiHandler;
/**
*
*/
init(): void;
/**
* cc.Texture2D
*/
requsetMaterial(texture: cc.Texture2D): cc.Material;
/**
* 使
*/
reset(): void;
}
};
namespace RenderComponent {
export enum EnableType {
/**
* !#en Global.
* !#zh 使
* @property {Number} GLOBAL
*/
GLOBAL = 0,
/**
* !#en Enable.
* !#zh
* @property {Number} ENABLE
*/
ENABLE = 1,
/**
* !#en Disable.
* !#zh
* @property {Number} DISABLE
*/
DISABLE = 2,
}
}
interface RenderComponent {
/**
* `updateRenderData` 使 Texture Index
*/
_texIdDirty: boolean;
/**
* 使 Texture Index
*/
_texId: number;
/**
* `_texId`使 Texture Index
*/
_updateMultiTexId(material: cc.MaterialVariant, texture: cc.Texture2D);
}
interface Label {
/**
*
*/
autoSwitchMaterial: cc.RenderComponent.EnableType;
/**
*
*/
allowDynamicAtlas: cc.RenderComponent.EnableType;
/**
* DPI
*/
enableRetina: cc.RenderComponent.EnableType;
/**
*
*/
setVertsDirty(): void;
}
namespace Label {
/**
* CHAR
*/
class LetterAtlas {
/**
*
*/
_atlases: cc.Label.LetterAtlases;
/**
*
*/
_texture: cc.RenderTexture;
/**
*
*/
_id: number;
/**
*
*/
_tmpId: number;
/**
*
*/
frees: cc.BitmapFont.FontLetterDefinition[];
/**
*
*/
waitCleans: cc.BitmapFont.FontLetterDefinition[];
/**
*
*/
reset(): void;
/**
*
*/
destroy(): void;
}
/**
* CHAR
*/
class LetterAtlases {
/**
*
*/
atlases: any[];
/**
* Char
*/
material: cc.Material;
/**
* Fake MaterialVariant
*/
fakeMaterial: { material: cc.Material };
/**
* cc.BitmapFont.FontAtlas
*/
_fontDefDictionary: any;
/**
* 使 CHAR
*/
getLetterDefinitionForChar(char: string, labelInfo: any): any;
/**
*
*/
getLetter(key: string): cc.BitmapFont.FontLetterDefinition;
/**
*
*/
deleteLetter(letter: cc.BitmapFont.FontLetterDefinition): void;
/**
*
*/
reset(): void;
/**
*
*/
destroy(): void;
}
/**
* CHAR
*/
const _shareAtlas: LetterAtlases;
}
namespace BitmapFont {
/**
* Letter
*/
class FontLetterDefinition {
u: number;
v: number;
w: number;
h: number;
offsetX: number;
offsetY: number;
textureID: number;
valid: boolean;
xAdvance: number;
texture: cc.Texture2D;
atlas: cc.Label.LetterAtlas;
ref: number;
_inCleans: boolean;
_hash: string;
_width: number;
_height: number;
}
}
interface Sprite {
/**
*
*/
autoSwitchMaterial: cc.RenderComponent.EnableType;
/**
*
*/
allowDynamicAtlas: cc.RenderComponent.EnableType;
/**
*
*/
setVertsDirty(): void;
}
interface RichText {
/**
* 使
*/
customMaterial: cc.Material;
/**
*
*/
autoSwitchMaterial: cc.RenderComponent.EnableType;
/**
*
*/
allowDynamicAtlas: cc.RenderComponent.EnableType;
/**
* DPI
*/
enableRetina: cc.RenderComponent.EnableType;
/**
*
*/
setVertsDirty(): void;
}
interface MotionStreak {
/**
*
*/
autoSwitchMaterial: cc.RenderComponent.EnableType;
/**
*
*/
_checkSwitchMaterial(): void;
/**
*
*/
setVertsDirty(): void;
}
interface Texture2D {
/**
*
*/
_multiMaterial: cc.Material;
/**
*
*
* @param material
* @param index
*/
linkMaterial(material: cc.Material, index?: number): boolean;
/**
*
*/
unlinkMaterial(): void;
/**
*
*/
getLinkedMaterial(): cc.Material;
/**
*
*/
hasLinkedMaterial(): boolean;
}
interface Material {
/**
* MultiHandler
*/
_multiHandler?: cc.sp.MultiHandler;
/**
* `USE_MULTI_TEXTURE`
*/
updateMultiSupport(): boolean;
/**
* MultiHandler
*/
isMultiSupport(): boolean;
/**
* MultiHandler
*/
setMultiSupport(bool: boolean): void;
/**
* MultiHandler
*/
getMultiHandler(): cc.sp.MultiHandler;
}
namespace DynamicAtlasManager {
/**
*
*/
class Atlas {
/**
*
*/
static ignoreRectSize: number;
/**
* Atlas
*/
static DEFAULT_HASH: string;
/**
*
*/
width: number;
/**
*
*/
height: number;
/**
*
*/
padding: number;
/**
*
*/
border: number;
/**
*
*/
rootRect: Rect;
/**
*
*/
freeRects: Rect[];
/**
* 使
*/
_count: number;
/**
* cc.RenderTexture
*/
_texture: cc.RenderTexture;
/**
* texture update dirty
*/
_dirty: boolean;
constructor(width: number, height: number, padding?: number, border?: number);
/**
* push to free rects
*/
protected pushFreeRect(rect: Rect): void;
/**
* faster remove from free rects
*/
protected removeFreeRect(index: number): void;
/**
* change member from free rects
*/
protected replaceFreeRect(index: number, rect: Rect): void;
/**
* SpriteFrame
*/
insertSpriteFrame(spriteFrame: cc.SpriteFrame): { x: number, y: number, texture: cc.Texture2D };
/**
*
*/
deleteSpriteFrame(texture: cc.Texture2D, frame: cc.SpriteFrame): boolean;
/**
*
*/
deleteInnerRect(rect: Rect): void;
/**
*
*/
deleteInnerTexture(texture: cc.Texture2D): boolean;
/**
* 使
*/
isEmpty(): boolean;
/**
*
*/
reset(): void;
/**
*
*/
destroy(): void;
}
/**
*
*/
class Rect {
/**
*
*/
static reuse(atlas: Atlas, width: number, height: number, x: number, y: number): cc.DynamicAtlasManager.Rect;
/**
*
*/
static recycle(rect: Rect): void;
/**
* Atlas
*/
atlas: Atlas;
/**
*
*/
width: number;
/**
*
*/
height: number;
/**
*
*/
x: number;
/**
*
*/
y: number;
/**
* freeRects
*/
cacheIndex: number;
/**
* cc.Texture2D UUID
*/
uuid: string;
/**
* 使
*/
spriteFrames: cc.SpriteFrame[] = [];
/**
*
*/
parentRect: Rect | undefined;
/**
*
*/
subRectA: Rect | undefined;
/**
*
*/
subRectB: Rect | undefined;
/**
*
*/
subRectC: Rect | undefined;
/**
*
*/
used: number;
/**
*
*/
readonly sizes: number;
constructor(atlas: Atlas, width: number, height: number, x: number, y: number);
}
}
interface DynamicAtlasManager {
/**
* !#en Is enable autoMultiBatch.
* !#zh
* @property autoMultiBatch
* @type {Boolean}
*/
autoMultiBatch: boolean;
/**
* !#en Is enable autoResetBeforeSceneLoad.
* !#zh
* @property autoResetBeforeSceneLoad
* @type {Boolean}
*/
autoResetBeforeSceneLoad: boolean;
/**
*
*/
atlases: cc.DynamicAtlasManager.Atlas[];
/**
* <`texture._uuid`, Rect>
*/
rects: Record<string, cc.DynamicAtlasManager.Rect>;
/**
* !#en Delete a sprite frame from the dynamic atlas.
* !#zh 使使
* @method deleteSpriteFrame
* @param {SpriteFrame} spriteFrame
*/
deleteSpriteFrame(spriteFrame: cc.SpriteFrame): void;
/**
* !#en Delete a texture from the dynamic atlas.
* !#zh 使
* @method deleteTexture
* @param {Texture2D} texture
*/
deleteTexture(texture: cc.Texture2D): void;
}
}
declare module sp {
interface SkeletonData {
/**
* SkeletonData
*/
clone(): SkeletonData;
}
namespace SkeletonData {
/**
* SpriteFrame spine.TextureAtlasRegion
*
* @param spriteFrame cc.SpriteFrame
* @param original region `name` `page`
*/
function createRegion(spriteFrame: cc.SpriteFrame, original?: spine.TextureRegion): spine.TextureAtlasRegion;
/**
* spine.TextureAtlasRegion SpriteFrame
*
* SpriteFrame region 270 0
*
* @param region spine.TextureAtlasRegion
*/
function createSpriteFrame(region: spine.TextureAtlasRegion): cc.SpriteFrame;
}
interface Skeleton {
/**
*
*/
autoSwitchMaterial: cc.RenderComponent.EnableType;
/**
*
*/
allowDynamicAtlas: cc.RenderComponent.EnableType;
/**
* slot attachment attachment regionSkeleton Skeleton Data
*/
getRegion(slotName: string, attachmentName: string): spine.TextureRegion | null;
/**
* slot attachment attachment regionSkeleton Skeleton Data
*/
setRegion(slotName: string, attachmentName: string, region: spine.TextureRegion): boolean;
/**
*
*/
setVertsDirty(): void;
}
}