预览版源码

This commit is contained in:
SmallMain 2022-06-13 15:28:08 +08:00
parent e8539159d6
commit 6c704a5cd3
4 changed files with 828 additions and 1 deletions

View File

@ -2,7 +2,9 @@
![logo](/docs/static/img/logo2.png)
> 该项目还处于内部完善中
> 该项目当前为预览版,还在完善中,存在以下问题:
> 1.Spine 使用多纹理材质时只支持使用 REALTIME 模式
> 2.还未适配原生平台cocos2d-x、jsb-adapter
这是一个对 Cocos Creator 引擎进行特性增强、修复与优化的**开源非官方服务包Service Pack**。

0
patch/placeholder Normal file
View File

825
src/creator-sp.d.ts vendored Normal file
View File

@ -0,0 +1,825 @@
declare module cc {
/**
* Cocos Creator Service Pack
*/
module sp {
/**
*
*/
const inited: boolean,
/**
*
*
* 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;
}
/**
*
*/
class MultiBatcher {
/**
*
*/
handlers: MultiHandler[];
/**
*
*/
nextHandler: MultiHandler;
/**
*
*/
init(): void;
/**
* cc.Texture2D
*/
requsetMaterial(texture: cc.Texture2D): cc.Material;
/**
* 使 cc.Texture2D
*/
linkMaterial(texture: cc.Texture2D, handler: MultiHandler, index: number): void;
/**
* cc.Texture2D
*/
unlinkMaterial(texture: cc.Texture2D): 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;
}
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;
}
interface RichText {
/**
* 使
*/
customMaterial: cc.Material;
/**
*
*/
autoSwitchMaterial: cc.RenderComponent.EnableType;
/**
*
*/
allowDynamicAtlas: cc.RenderComponent.EnableType;
/**
* DPI
*/
enableRetina: cc.RenderComponent.EnableType;
}
interface MotionStreak {
/**
*
*/
autoSwitchMaterial: cc.RenderComponent.EnableType;
/**
*
*/
_checkSwitchMaterial(): void;
}
/**
*
*
* inspector inspector
*/
class RichTextSP extends cc.Component {
/**
* 使
*/
customMaterial: cc.Material;
/**
*
*/
autoSwitchMaterial: cc.RenderComponent.EnableType;
/**
*
*/
allowDynamicAtlas: cc.RenderComponent.EnableType;
/**
* DPI
*/
enableRetina: cc.RenderComponent.EnableType;
}
interface Texture2D {
/**
*
*/
_multiMaterial: cc.Material;
}
interface Material {
/**
* MultiHandler
*/
_multiHandler?: cc.sp.MultiHandler;
/**
* 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;
/**
* 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: cc.Texture2D;
/**
* 使
*/
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;
}
}

BIN
src/engine/engine.zip Normal file

Binary file not shown.