Complete Cocos Creator port with level bundles, themes, and tooling.

Adds level prefabs, theme assets, audio, extensions, and deployment scripts for the Unity WebGL migration.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-16 15:30:58 +08:00
parent cba5105908
commit d393302388
6248 changed files with 17322729 additions and 11036 deletions

View File

@@ -0,0 +1,29 @@
'use strict';
export const ALPHAKEY = {
"__type__": "cc.AlphaKey",
"alpha": 1,
"time": 0,
};
export class AlphaKey {
static create() {
return JSON.parse(JSON.stringify(ALPHAKEY));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(ALPHAKEY));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await AlphaKey.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,35 @@
'use strict';
export const ANIMATION = {
"__type__": "cc.Animation",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"playOnLoad": false,
"_clips": [],
"_defaultClip": null,
};
export class Animation {
static create() {
return JSON.parse(JSON.stringify(ANIMATION));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(ANIMATION));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Animation.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,40 @@
'use strict';
export const ANIMATIONCLIP = {
"__type__": "cc.AnimationClip",
"_name": "",
"_objFlags": 0,
"_native": "",
"sample": 60,
"speed": 1,
"wrapMode": 1,
"events": [],
"_duration": 0,
"_keys": [],
"_stepness": 0,
"_curves": [],
"_commonTargets": [],
"_hash": 0,
};
export class AnimationClip {
static create() {
return JSON.parse(JSON.stringify(ANIMATIONCLIP));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(ANIMATIONCLIP));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await AnimationClip.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,43 @@
'use strict';
export const ANIMATIONCURVE = {
"__type__": "cc.AnimationCurve",
"preWrapMode": 2,
"postWrapMode": 8,
"keyFrames": [
{
"time": 0,
"value": 1,
"inTangent": 0,
"outTangent": 0,
},
{
"time": 1,
"value": 1,
"inTangent": 0,
"outTangent": 0,
},
],
};
export class AnimationCurve {
static create() {
return JSON.parse(JSON.stringify(ANIMATIONCURVE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(ANIMATIONCURVE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await AnimationCurve.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,91 @@
'use strict';
import { getBlendFactor2DTo3D } from "../common/utlis";
import { ImporterBase } from "../common/base";
export const ARMATUREDISPLAY = {
"__type__": "dragonBones.ArmatureDisplay",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_visFlags": 0,
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255,
},
"playTimes": -1,
"premultipliedAlpha": false,
"_defaultArmatureIndexValue": -1,
"_dragonAsset": null,
"_dragonAtlasAsset": null,
"_armatureName": "weapon_1005",
"_animationName": "",
"_animationIndexValue": 0,
"_defaultCacheModeValue": 0,
"_timeScale": 1,
"_playTimes": -1,
"_debugBones": false,
"_enableBatch": false,
"_sockets": [],
};
export class ArmatureDisplay {
static create() {
return JSON.parse(JSON.stringify(ARMATUREDISPLAY));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(ARMATUREDISPLAY));
for (let key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) {
continue;
}
if (key.startsWith('_N$')) {
key = key.replace(/N\$/, '');
}
if (key === '_materials') {
let material = value[0];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
}
source._customMaterial = material;
}
else if (key === '_dragonAsset') {
source._dragonAsset = {
__uuid__: await ImporterBase.getUuid(value.__uuid__),
};
}
else if (key === '_dragonAtlasAsset') {
source._dragonAtlasAsset = {
__uuid__: await ImporterBase.getUuid(value.__uuid__),
};
}
else if (key === '_srcBlendFactor') {
source._srcBlendFactor = getBlendFactor2DTo3D(value);
} else if (key === '_dstBlendFactor') {
source._dstBlendFactor = getBlendFactor2DTo3D(value);
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ArmatureDisplay.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,30 @@
'use strict';
export const ASSET = {
"__type__": "cc.Asset",
"_name": "",
"_objFlags": 0,
"_native": "",
};
export class Asset {
static create() {
return JSON.parse(JSON.stringify(ASSET));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(ASSET));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Asset.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,32 @@
'use strict';
export const AUDIOCLIP = {
"__type__": "cc.AudioClip",
"_name": "",
"_objFlags": 0,
"_native": "",
"_duration": 0,
"_loadMode": 3,
};
export class AudioClip {
static create() {
return JSON.parse(JSON.stringify(AUDIOCLIP));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(AUDIOCLIP));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await AudioClip.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,36 @@
'use strict';
export const AUDIOSOURCE = {
"__type__": "cc.AudioSource",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_clip": null,
"_loop": false,
"_playOnAwake": true,
"_volume": 1,
};
export class AudioSource {
static create() {
return JSON.parse(JSON.stringify(AUDIOSOURCE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(AUDIOSOURCE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await AudioSource.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,34 @@
'use strict';
export const BASENODE = {
"__type__": "cc.BaseNode",
"_name": "New Node",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [],
"_prefab": null,
};
export class BaseNode {
static create() {
return JSON.parse(JSON.stringify(BASENODE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(BASENODE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await BaseNode.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,36 @@
'use strict';
export const BILLBOARD = {
"__type__": "cc.Billboard",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_texture": null,
"_height": 0,
"_width": 0,
"_rotation": 0,
};
export class Billboard {
static create() {
return JSON.parse(JSON.stringify(BILLBOARD));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(BILLBOARD));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Billboard.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,34 @@
'use strict';
export const BITMAPFONT = {
"__type__": "cc.BitmapFont",
"_name": "",
"_objFlags": 0,
"_native": "",
"fntDataStr": "",
"spriteFrame": null,
"fontSize": -1,
"fntConfig": null,
};
export class BitmapFont {
static create() {
return JSON.parse(JSON.stringify(BITMAPFONT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(BITMAPFONT));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await BitmapFont.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,32 @@
'use strict';
export const BLOCKINPUTEVENTS = {
"__type__": "cc.BlockInputEvents",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
};
export class BlockInputEvents {
static create() {
return JSON.parse(JSON.stringify(BLOCKINPUTEVENTS));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(BLOCKINPUTEVENTS));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await BlockInputEvents.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,62 @@
'use strict';
import { ImporterBase } from "../common/base";
export const BOXCOLLIDER = {
"__type__": "cc.BoxCollider",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_material": null,
"_isTrigger": false,
"_center": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"_size": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1,
},
};
export class BoxCollider {
static create() {
return JSON.parse(JSON.stringify(BOXCOLLIDER));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(BOXCOLLIDER));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_materials') {
source._materials = [];
for (let i = 0; i < value.length; ++i) {
let material = value[0];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
source._materials.push(material);
}
}
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await BoxCollider.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,48 @@
'use strict';
export const BOXCOLLIDER2D = {
"__type__": "cc.BoxCollider2D",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"tag": 0,
"_group": 1,
"_density": 1,
"_sensor": false,
"_friction": 0.2,
"_restitution": 0,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"_size": {
"__type__": "cc.Size",
"width": 1,
"height": 1,
},
};
export class BoxCollider2D {
static create() {
return JSON.parse(JSON.stringify(BOXCOLLIDER2D));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(BOXCOLLIDER2D));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await BoxCollider2D.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,30 @@
'use strict';
export const BUFFERASSET = {
"__type__": "cc.BufferAsset",
"_name": "",
"_objFlags": 0,
"_native": "",
};
export class BufferAsset {
static create() {
return JSON.parse(JSON.stringify(BUFFERASSET));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(BUFFERASSET));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await BufferAsset.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,33 @@
'use strict';
export const BURST = {
"__type__": "cc.Burst",
"_time": 0,
"_repeatCount": 1,
"repeatInterval": 1,
"count": {
"__id__": 1,
},
};
export class Burst {
static create() {
return JSON.parse(JSON.stringify(BURST));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(BURST));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Burst.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,130 @@
'use strict';
import { ImporterBase } from "../common/base";
export const BUTTON = {
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"clickEvents": [],
"_interactable": true,
"_transition": 0,
"_normalColor": {
"__type__": "cc.Color",
"r": 214,
"g": 214,
"b": 214,
"a": 255,
},
"_hoverColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255,
},
"_pressedColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255,
},
"_disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255,
},
"_normalSprite": null,
"_hoverSprite": null,
"_pressedSprite": null,
"_disabledSprite": null,
"_duration": 0.1,
"_zoomScale": 1.2,
"_target": null,
};
export class Button {
static create() {
return JSON.parse(JSON.stringify(BUTTON));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(BUTTON));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
switch (key) {
case '_normalMaterial':
case '_grayMaterial':
case '_N$enableAutoGrayEffect':
break;
case 'duration':
source._duration = value;
break;
case 'zoomScale':
source._zoomScale = value;
break;
case '_N$interactable':
source._interactable = value;
break;
case '_N$transition':
case 'transition':
source._transition = value;
break;
case '_N$normalColor':
source._normalColor = value;
break;
case '_N$pressedColor':
case 'pressedColor':
source._pressedColor = value;
break;
case '_N$hoverColor':
case 'hoverColor':
source._hoverColor = value;
break;
case '_N$disabledColor':
source._disabledColor = value;
break;
case '_N$normalSprite':
source._normalSprite = {
__uuid__: await ImporterBase.getUuid(value.__uuid__, 'spriteFrame'),
};
break;
case '_N$pressedSprite':
source._pressedSprite = {
__uuid__: await ImporterBase.getUuid(value.__uuid__, 'spriteFrame'),
};
break;
case '_N$hoverSprite':
source._hoverSprite = {
__uuid__: await ImporterBase.getUuid(value.__uuid__, 'spriteFrame'),
};
break;
case '_N$disabledSprite':
source._disabledSprite = {
__uuid__: await ImporterBase.getUuid(value.__uuid__, 'spriteFrame'),
};
break;
case '_N$target':
source._target = value;
break;
default:
source[key] = value;
break;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Button.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,111 @@
'use strict';
import { Node } from "./Node";
import { layerToGroupMap } from '../common/utlis';
export const CAMERA = {
"__type__": "cc.Camera",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_projection": 1,
"_priority": 0,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 10,
"_near": 1,
"_far": 1000,
"_color": {
"__type__": "cc.Color",
"r": 51,
"g": 51,
"b": 51,
"a": 255,
},
"_depth": 1,
"_stencil": 0,
"_clearFlags": 7,
"_rect": {
"__type__": "cc.Rect",
"x": 0,
"y": 0,
"width": 1,
"height": 1,
},
"_aperture": 19,
"_shutter": 7,
"_iso": 0,
"_screenScale": 1,
"_visibility": -325058561,
"_targetTexture": null,
};
export class Camera {
static addToScene(canvas: any, json3D: any) {
const canvasID = canvas.node.__id__;
const canvasNode = json3D[canvasID];
const cameraNode = Node.create(`UICamera_${canvasNode._name}`, canvasID);
json3D.push(cameraNode);
const cameraNodeID = json3D.length - 1;
canvasNode._children.push({
__id__: cameraNodeID,
});
const camera = Camera.create(cameraNodeID);
json3D.push(camera);
const cameraID = json3D.length - 1;
Node.addComponents(cameraNode, cameraID);
canvas._cameraComponent = {
__id__: cameraID,
};
}
static create(nodeID: number) {
const camera = JSON.parse(JSON.stringify(CAMERA));
camera.node = {
__id__: nodeID,
};
return camera;
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(CAMERA));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_cullingMask') {
source._visibility = value;
}
else if (key === '_depth') {
source._priority = value;
}
else if (key === '_backgroundColor') {
source._color = value;
}
else if (key === '_ortho') {
// ORTHO = 0, PERSPECTIVE = 1
source._projection = value === true ? 0 : 1;
}
else if (key === '_nearClip') {
source._near = value;
}
else if (key === '_farClip') {
source._far = value;
}
else if (key === '_orthoSize') {
source._orthoHeight = value;
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Camera.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,179 @@
'use strict';
import { Node } from "./Node";
import { UITransform } from "./UITransform";
import { Widget } from "./Widget";
import {
hasComponent,
setColor,
hasUIRenderComponent,
getComponentByType,
getDesignResolution
} from "../common/utlis";
import { Camera } from "./Camera";
export const CANVAS = {
"__type__": "cc.Canvas",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"_cameraComponent": null,
"_alignCanvasWithScreen": true,
"_id": "e6QojeC9FOBZjtx9CZWAUA"
};
const NAME = 'RenderRoot2D';
export const RENDER2D = {
"__type__": `cc.${NAME}`,
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
};
export class Canvas {
static async checkDesignResolution (json: any, sceneName: any) {
const canvasNodeIDs = json.map((item: any) => {
if (item.__type__ === 'cc.Canvas') {
return item.node.__id__;
}
return null
}).filter(Boolean);
for (let canvasNodeID of canvasNodeIDs) {
const canvasName = json[canvasNodeID] && json[canvasNodeID]._name;
const component = getComponentByType(canvasNodeID, 'cc.UITransform', json);
if (component) {
const { width, height } = await getDesignResolution();
if (component._contentSize.width !== width || component._contentSize.height !== height) {
console.warn(Editor.I18n.t('plugin-import-2x.canvas_tips', { scene: sceneName +'.scene', name: canvasName }));
}
}
}
}
static getCameraIDByCanvasChildren(canvas: any, json3D: any) {
const node = json3D[canvas.node.__id__];
for (let child of node._children) {
const item = json3D[child.__id__];
if (item._name === 'Main Camera') {
for (let childComponent of item._components) {
const component = json3D[childComponent.__id__];
if (component.__type__ === 'cc.Camera') {
return childComponent;
}
}
}
}
return null;
}
static async updateCameraComponent(json3D: any, json2D: any) {
for (let i = 0; i < json3D.length; ++i) {
const target = json3D[i];
if (target.__type__ === 'cc.Canvas') {
const item = Canvas.getCameraIDByCanvasChildren(target, json3D);
if (item) {
target._cameraComponent = item;
const camera = json2D[item.__id__];
target._alignCanvasWithScreen = camera._alignWithScreen;
}
else {
Camera.addToScene(target, json3D);
}
}
}
}
static async insert(json3D: any) {
// 把放在 Canvas 外的 ui 组件都归位新的 Canvas 中
const scene = json3D[1];
const children = scene._children.slice();
let node;
let renderNodeID;
for (const child of children) {
const item = json3D[child.__id__];
if (!hasComponent(item, json3D, 'cc.Canvas') && hasUIRenderComponent(item, json3D)) {
const width = await Editor.Profile.getProject('project', 'general.designResolution.width');
const height = await Editor.Profile.getProject('project', 'general.designResolution.height');
if (!node) {
node = Node.create(NAME, 1);
json3D.push(node);
renderNodeID = json3D.length - 1;
scene._children.push({
__id__: renderNodeID,
});
// add Render2D component
const render2D = Canvas.create(renderNodeID, NAME, true);
json3D.push(render2D);
const render2DID = json3D.length - 1;
Node.addComponents(node, render2DID);
// add uitransform component
const uiTransform = UITransform.create(renderNodeID);
uiTransform._contentSize.width = width;
uiTransform._contentSize.height = height;
uiTransform._anchorPoint.x = 0;
uiTransform._anchorPoint.y = 0;
json3D.push(uiTransform);
Node.addComponents(node, json3D.length - 1);
// add widget component
const widget = Widget.create(renderNodeID);
widget._alignFlags = 45;
json3D.push(widget);
Node.addComponents(node, json3D.length - 1);
}
item._parent = {
__id__: renderNodeID,
};
Node.addChildren(node, child.__id__);
const index = scene._children.indexOf(child);
scene._children.splice(index, 1);
}
}
}
static create(nodeID?: number, name?: string, isRender2D?: boolean) {
let component;
if (isRender2D) {
component = JSON.parse(JSON.stringify(RENDER2D));
}
else {
component = JSON.parse(JSON.stringify(CANVAS));
}
if (name) {
component._name = name;
}
if (nodeID) {
component.node = {
__id__: nodeID,
};
}
return component;
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(CANVAS));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === 'node') {
source.node = value;
setColor(source, value.__id__, json2D);
}
else if (key === '_name' || key === '_id' || key === '_objFlags' || key === '_enabled') {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Canvas.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,59 @@
'use strict';
import { ImporterBase } from "../common/base";
export const CAPSULECOLLIDER = {
"__type__": "cc.CapsuleCollider",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_material": null,
"_isTrigger": false,
"_center": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"_radius": 0.5,
"_cylinderHeight": 1,
"_direction": 1,
};
export class CapsuleCollider {
static create() {
return JSON.parse(JSON.stringify(CAPSULECOLLIDER));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(CAPSULECOLLIDER));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_materials') {
source._materials = [];
for (let i = 0; i < value.length; ++i) {
let material = value[0];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
source._materials.push(material);
}
}
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await CapsuleCollider.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,44 @@
'use strict';
export const CIRCLECOLLIDER2D = {
"__type__": "cc.CircleCollider2D",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"tag": 0,
"_group": 1,
"_density": 1,
"_sensor": false,
"_friction": 0.2,
"_restitution": 0,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"_radius": 1,
};
export class CircleCollider2D {
static create() {
return JSON.parse(JSON.stringify(CIRCLECOLLIDER2D));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(CIRCLECOLLIDER2D));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await CircleCollider2D.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,56 @@
'use strict';
import { ImporterBase } from "../common/base";
export const COLLIDER = {
"__type__": "cc.Collider",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_material": null,
"_isTrigger": false,
"_center": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
};
export class Collider {
static create() {
return JSON.parse(JSON.stringify(COLLIDER));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(COLLIDER));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_materials') {
source._materials = [];
for (let i = 0; i < value.length; ++i) {
let material = value[0];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
source._materials.push(material);
}
}
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Collider.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,43 @@
'use strict';
export const COLLIDER2D = {
"__type__": "cc.Collider2D",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"tag": 0,
"_group": 1,
"_density": 1,
"_sensor": false,
"_friction": 0.2,
"_restitution": 0,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
};
export class Collider2D {
static create() {
return JSON.parse(JSON.stringify(COLLIDER2D));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(COLLIDER2D));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Collider2D.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,35 @@
'use strict';
export const COLORKEY = {
"__type__": "cc.ColorKey",
"color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255,
},
"time": 0,
};
export class ColorKey {
static create() {
return JSON.parse(JSON.stringify(COLORKEY));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(COLORKEY));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ColorKey.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,36 @@
'use strict';
export const COLOROVERTIMEMODULE = {
"__type__": "cc.ColorOvertimeModule",
"_enable": false,
"color": {
"__id__": 1,
},
};
export class ColorOvertimeModule {
static create() {
return JSON.parse(JSON.stringify(COLOROVERTIMEMODULE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(COLOROVERTIMEMODULE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === 'enable') {
source._enable = value;
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ColorOvertimeModule.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,28 @@
'use strict';
export const COMPPREFABINFO = {
"__type__": "cc.CompPrefabInfo",
"fileId": "",
};
export class CompPrefabInfo {
static create() {
return JSON.parse(JSON.stringify(COMPPREFABINFO));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(COMPPREFABINFO));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await CompPrefabInfo.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,31 @@
'use strict';
export const COMPACTVALUETYPEARRAY = {
"__type__": "cc.CompactValueTypeArray",
"_byteOffset": 0,
"_unitCount": 0,
"_unitElement": 0,
"_length": 0,
};
export class CompactValueTypeArray {
static create() {
return JSON.parse(JSON.stringify(COMPACTVALUETYPEARRAY));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(COMPACTVALUETYPEARRAY));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await CompactValueTypeArray.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,32 @@
'use strict';
export const COMPONENT = {
"__type__": "cc.Component",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
};
export class Component {
static create() {
return JSON.parse(JSON.stringify(COMPONENT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(COMPONENT));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Component.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,28 @@
'use strict';
export const COMPONENTMODIFIER = {
"__type__": "cc.ComponentModifier",
"component": "",
};
export class ComponentModifier {
static create() {
return JSON.parse(JSON.stringify(COMPONENTMODIFIER));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(COMPONENTMODIFIER));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ComponentModifier.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,59 @@
'use strict';
import { ImporterBase } from "../common/base";
export const CONECOLLIDER = {
"__type__": "cc.ConeCollider",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_material": null,
"_isTrigger": false,
"_center": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"_radius": 0.5,
"_height": 1,
"_direction": 1,
};
export class ConeCollider {
static create() {
return JSON.parse(JSON.stringify(CONECOLLIDER));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(CONECOLLIDER));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_materials') {
source._materials = [];
for (let i = 0; i < value.length; ++i) {
let material = value[0];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
source._materials.push(material);
}
}
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ConeCollider.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,56 @@
'use strict';
export const CONSTANTFORCE = {
"__type__": "cc.ConstantForce",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_force": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"_localForce": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"_torque": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"_localTorque": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
};
export class ConstantForce {
static create() {
return JSON.parse(JSON.stringify(CONSTANTFORCE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(CONSTANTFORCE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ConstantForce.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,34 @@
'use strict';
export const CONSTRAINT = {
"__type__": "cc.Constraint",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_enableCollision": true,
"_connectedBody": null,
};
export class Constraint {
static create() {
return JSON.parse(JSON.stringify(CONSTRAINT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(CONSTRAINT));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Constraint.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,27 @@
'use strict';
export const CUBICSPLINENUMBERVALUE = {
"__type__": "cc.CubicSplineNumberValue",
};
export class CubicSplineNumberValue {
static create() {
return JSON.parse(JSON.stringify(CUBICSPLINENUMBERVALUE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(CUBICSPLINENUMBERVALUE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await CubicSplineNumberValue.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,42 @@
'use strict';
export const CUBICSPLINEVALUECLASS = {
"__type__": "cc.CubicSplineVec2Value",
"dataPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"inTangent": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"outTangent": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
};
export class CubicSplineValueClass {
static create() {
return JSON.parse(JSON.stringify(CUBICSPLINEVALUECLASS));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(CUBICSPLINEVALUECLASS));
for (const key in json2D) {
const value = json2D[key];
if (value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await CubicSplineValueClass.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,32 @@
'use strict';
export const CURVERANGE = {
"__type__": "cc.CurveRange",
"mode": 0,
"constant": 0,
"constantMin": 0,
"constantMax": 0,
"multiplier": 1,
};
export class CurveRange {
static create() {
return JSON.parse(JSON.stringify(CURVERANGE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(CURVERANGE));
for (const key in json2D) {
const value = json2D[key];
if (value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await CurveRange.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,27 @@
'use strict';
export const CURVEVALUEADAPTER = {
"__type__": "cc.CurveValueAdapter",
};
export class CurveValueAdapter {
static create() {
return JSON.parse(JSON.stringify(CURVEVALUEADAPTER));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(CURVEVALUEADAPTER));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await CurveValueAdapter.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,59 @@
'use strict';
import { ImporterBase } from "../common/base";
export const CYLINDERCOLLIDER = {
"__type__": "cc.CylinderCollider",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_material": null,
"_isTrigger": false,
"_center": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"_radius": 0.5,
"_height": 2,
"_direction": 1,
};
export class CylinderCollider {
static create() {
return JSON.parse(JSON.stringify(CYLINDERCOLLIDER));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(CYLINDERCOLLIDER));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_materials') {
source._materials = [];
for (let i = 0; i < value.length; ++i) {
let material = value[0];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
source._materials.push(material);
}
}
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await CylinderCollider.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,45 @@
'use strict';
export const DIRECTIONALLIGHT = {
"__type__": "cc.DirectionalLight",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255,
},
"_useColorTemperature": false,
"_colorTemperature": 6550,
"_staticSettings": {
"__id__": 1,
},
"_illuminance": 65000,
};
export class DirectionalLight {
static create() {
return JSON.parse(JSON.stringify(DIRECTIONALLIGHT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(DIRECTIONALLIGHT));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await DirectionalLight.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,46 @@
'use strict';
export const DISTANCEJOINT2D = {
"__type__": "cc.DistanceJoint2D",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"anchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"connectedAnchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"collideConnected": false,
"connectedBody": null,
"_maxLength": 5,
"_autoCalcDistance": true,
};
export class DistanceJoint2D {
static create() {
return JSON.parse(JSON.stringify(DISTANCEJOINT2D));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(DISTANCEJOINT2D));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await DistanceJoint2D.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,49 @@
'use strict';
export const EDITBOX = {
"__type__": "cc.EditBox",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"editingDidBegan": [],
"textChanged": [],
"editingDidEnded": [],
"editingReturn": [],
"_textLabel": null,
"_placeholderLabel": null,
"_returnType": 0,
"_useOriginalSize": true,
"_string": "",
"_tabIndex": 0,
"_backgroundImage": null,
"_inputFlag": 5,
"_inputMode": 0,
"_maxLength": 20,
};
export class EditBox {
static create() {
return JSON.parse(JSON.stringify(EDITBOX));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(EDITBOX));
for (let key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key.startsWith('_N$')) {
key = key.replace(/N\$/, '');
}
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await EditBox.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,33 @@
'use strict';
export const EFFECTASSET = {
"__type__": "cc.EffectAsset",
"_name": "",
"_objFlags": 0,
"_native": "",
"techniques": [],
"shaders": [],
"combinations": [],
};
export class EffectAsset {
static create() {
return JSON.parse(JSON.stringify(EFFECTASSET));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(EFFECTASSET));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await EffectAsset.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,32 @@
'use strict';
export const EVENTHANDLER = {
"__type__": "cc.ClickEvent",
"target": null,
"component": "",
"_componentId": "",
"handler": "",
"customEventData": "",
};
export class EventHandler {
static create() {
return JSON.parse(JSON.stringify(EVENTHANDLER));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(EVENTHANDLER));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await EventHandler.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,46 @@
'use strict';
export const FIXEDJOINT2D = {
"__type__": "cc.FixedJoint2D",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"anchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"connectedAnchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"collideConnected": false,
"connectedBody": null,
"_frequency": 0.7,
"_dampingRatio": 0.5,
};
export class FixedJoint2D {
static create() {
return JSON.parse(JSON.stringify(FIXEDJOINT2D));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(FIXEDJOINT2D));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await FixedJoint2D.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,30 @@
'use strict';
export const FONT = {
"__type__": "cc.Font",
"_name": "",
"_objFlags": 0,
"_native": "",
};
export class Font {
static create() {
return JSON.parse(JSON.stringify(FONT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(FONT));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Font.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,38 @@
'use strict';
export const FORCEOVERTIMEMODULE = {
"__type__": "cc.ForceOvertimeModule",
"_enable": false,
"x": {
"__id__": 1,
},
"y": {
"__id__": 2,
},
"z": {
"__id__": 3,
},
"space": 1,
};
export class ForceOvertimeModule {
static create() {
return JSON.parse(JSON.stringify(FORCEOVERTIMEMODULE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(FORCEOVERTIMEMODULE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ForceOvertimeModule.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,31 @@
'use strict';
export const FORWARDFLOW = {
"__type__": "ForwardFlow",
"_name": "",
"_priority": 0,
"_tag": 0,
"_stages": [],
};
export class ForwardFlow {
static create() {
return JSON.parse(JSON.stringify(FORWARDFLOW));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(FORWARDFLOW));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ForwardFlow.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,34 @@
'use strict';
export const FORWARDPIPELINE = {
"__type__": "ForwardPipeline",
"_name": "",
"_objFlags": 0,
"_native": "",
"_tag": 0,
"_flows": [],
"renderTextures": [],
"materials": [],
};
export class ForwardPipeline {
static create() {
return JSON.parse(JSON.stringify(FORWARDPIPELINE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(FORWARDPIPELINE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ForwardPipeline.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,31 @@
'use strict';
export const FORWARDSTAGE = {
"__type__": "ForwardStage",
"_name": "",
"_priority": 0,
"_tag": 0,
"renderQueues": [],
};
export class ForwardStage {
static create() {
return JSON.parse(JSON.stringify(FORWARDSTAGE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(FORWARDSTAGE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ForwardStage.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,30 @@
'use strict';
export const GRADIENT = {
"__type__": "cc.Gradient",
"colorKeys": [],
"alphaKeys": [],
"mode": 0,
};
export class Gradient {
static create() {
return JSON.parse(JSON.stringify(GRADIENT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(GRADIENT));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Gradient.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,35 @@
'use strict';
export const GRADIENTRANGE = {
"__type__": "cc.GradientRange",
"_mode": 0,
"color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255,
},
};
export class GradientRange {
static create() {
return JSON.parse(JSON.stringify(GRADIENTRANGE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(GRADIENTRANGE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await GradientRange.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,80 @@
'use strict';
import { ImporterBase } from "../common/base";
import { getBlendFactor2DTo3D } from "../common/utlis";
export const GRAPHICS = {
"__type__": "cc.Graphics",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_customMaterial": null,
"_visFlags": 0,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255,
},
"_lineWidth": 1,
"_strokeColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255,
},
"_lineJoin": 2,
"_lineCap": 0,
"_fillColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255,
},
"_miterLimit": 10,
};
export class Graphics {
static create() {
return JSON.parse(JSON.stringify(GRAPHICS));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(GRAPHICS));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) {
continue;
}
if (key === '_materials') {
let material = value[0];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
}
source._customMaterial = material;
} else if (key === '_srcBlendFactor') {
source._srcBlendFactor = getBlendFactor2DTo3D(value);
} else if (key === '_dstBlendFactor') {
source._dstBlendFactor = getBlendFactor2DTo3D(value);
} else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Graphics.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,28 @@
'use strict';
export const HIERACHYMODIFIER = {
"__type__": "cc.HierachyModifier",
"path": "",
};
export class HierachyModifier {
static create() {
return JSON.parse(JSON.stringify(HIERACHYMODIFIER));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(HIERACHYMODIFIER));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await HierachyModifier.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,58 @@
'use strict';
export const HINGECONSTRAINT = {
"__type__": "cc.HingeConstraint",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_enableCollision": true,
"_connectedBody": null,
"axisA": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"axisB": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"pivotA": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"pivotB": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
};
export class HingeConstraint {
static create() {
return JSON.parse(JSON.stringify(HINGECONSTRAINT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(HINGECONSTRAINT));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await HingeConstraint.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,50 @@
'use strict';
export const HINGEJOINT2D = {
"__type__": "cc.HingeJoint2D",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"anchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"connectedAnchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"collideConnected": false,
"connectedBody": null,
"_enableLimit": false,
"_lowerAngle": 0,
"_upperAngle": 0,
"_enableMotor": false,
"_maxMotorTorque": 1000,
"_motorSpeed": 0,
};
export class HingeJoint2D {
static create() {
return JSON.parse(JSON.stringify(HINGEJOINT2D));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(HINGEJOINT2D));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await HingeJoint2D.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,28 @@
'use strict';
export const IMAGEASSET = {
"__type__": "cc.ImageAsset",
"content": "",
};
export class ImageAsset {
static create() {
return JSON.parse(JSON.stringify(IMAGEASSET));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(IMAGEASSET));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ImageAsset.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,30 @@
'use strict';
export const JAVASCRIPT = {
"__type__": "cc.JavaScript",
"_name": "",
"_objFlags": 0,
"_native": "",
};
export class JavaScript {
static create() {
return JSON.parse(JSON.stringify(JAVASCRIPT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(JAVASCRIPT));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await JavaScript.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,44 @@
'use strict';
export const JOINT2D = {
"__type__": "cc.Joint2D",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"anchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"connectedAnchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"collideConnected": false,
"connectedBody": null,
};
export class Joint2D {
static create() {
return JSON.parse(JSON.stringify(JOINT2D));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(JOINT2D));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Joint2D.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,31 @@
'use strict';
export const JSONASSET = {
"__type__": "cc.JsonAsset",
"_name": "",
"_objFlags": 0,
"_native": "",
"json": null,
};
export class JsonAsset {
static create() {
return JSON.parse(JSON.stringify(JSONASSET));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(JSONASSET));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await JsonAsset.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,31 @@
'use strict';
export const KEYFRAME = {
"__type__": "cc.Keyframe",
"time": 0,
"value": 0,
"inTangent": 0,
"outTangent": 0,
};
export class Keyframe {
static create() {
return JSON.parse(JSON.stringify(KEYFRAME));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(KEYFRAME));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Keyframe.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,100 @@
'use strict';
import { ImporterBase } from "../common/base";
import { getBlendFactor2DTo3D, setColor } from "../common/utlis";
export const LABEL = {
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_customMaterial": null,
"_visFlags": 0,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255,
},
"_useOriginalSize": true,
"_string": "label",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 0,
"_fontSize": 40,
"_fontFamily": "Arial",
"_lineHeight": 40,
"_overflow": 0,
"_enableWrapText": true,
"_font": null,
"_isSystemFontUsed": true,
"_isItalic": false,
"_isBold": false,
"_isUnderline": false,
"_underlineHeight": 0,
"_cacheMode": 0,
};
export class Label {
static create() {
return JSON.parse(JSON.stringify(LABEL));
}
static async migrate(index: number, json2D: any, json3D: any) {
const source = JSON.parse(JSON.stringify(LABEL));
const label = json2D[index];
for (const key in label) {
const value = label[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === 'node') {
source.node = value;
setColor(source, value.__id__, json2D);
}
else if (key === '_materials') {
// for (let i = 0; i < value.length; ++i) {
let material = value[0];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
}
source._customMaterial = material;
// }
} else if (key === '_N$file') {
source._font = {
__uuid__: await ImporterBase.getUuid(value.__uuid__),
};
} else if (key === '_N$string') {
source._string = value;
} else if (key === '_N$fontFamily') {
source._fontFamily = value;
} else if (key === '_N$overflow') {
source._overflow = value;
} else if (key === '_N$cacheMode') {
source._cacheMode = value;
} else if (key === '_N$horizontalAlign') {
source._horizontalAlign = value;
} else if (key === '_N$verticalAlign') {
source._verticalAlign = value;
} else if (key === '_srcBlendFactor') {
source._srcBlendFactor = getBlendFactor2DTo3D(value);
} else if (key === '_dstBlendFactor') {
source._dstBlendFactor = getBlendFactor2DTo3D(value);
} else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Label.migrate(index, json2D, json3D);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,34 @@
'use strict';
export const LABELATLAS = {
"__type__": "cc.LabelAtlas",
"_name": "",
"_objFlags": 0,
"_native": "",
"fntDataStr": "",
"spriteFrame": null,
"fontSize": -1,
"fntConfig": null,
};
export class LabelAtlas {
static create() {
return JSON.parse(JSON.stringify(LABELATLAS));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(LABELATLAS));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await LabelAtlas.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,48 @@
'use strict';
import { setColor } from "../common/utlis";
export const LABELOUTLINE = {
"__type__": "cc.LabelOutline",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255,
},
"_width": 2,
};
export class LabelOutline {
static create() {
return JSON.parse(JSON.stringify(LABELOUTLINE));
}
static async migrate(json2D: any, json3D: any) {
const source = JSON.parse(JSON.stringify(LABELOUTLINE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === 'node') {
source.node = value;
setColor(source, value.__id__, json2D);
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await LabelOutline.migrate(json2D[index], json3D);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,53 @@
'use strict';
import { setColor } from "../common/utlis";
export const LABELSHADOW = {
"__type__": "cc.LabelShadow",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255,
},
"_offset": {
"__type__": "cc.Vec2",
"x": 2,
"y": 2,
},
"_blur": 2,
};
export class LabelShadow {
static create() {
return JSON.parse(JSON.stringify(LABELSHADOW));
}
static async migrate(json2D: any, json3D: any) {
const source = JSON.parse(JSON.stringify(LABELSHADOW));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === 'node') {
source.node = value;
setColor(source, value.__id__, json2D);
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await LabelShadow.migrate(json2D[index], json3D);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,59 @@
'use strict';
export const LAYOUT = {
"__type__": "cc.Layout",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_resizeMode": 0,
"_N$layoutType": 0,
"_N$padding": 0,
"_cellSize": {
"__type__": "cc.Size",
"width": 40,
"height": 40,
},
"_startAxis": 0,
"_paddingLeft": 0,
"_paddingRight": 0,
"_paddingTop": 0,
"_paddingBottom": 0,
"_spacingX": 0,
"_spacingY": 0,
"_verticalDirection": 1,
"_horizontalDirection": 0,
"_affectedByScale": false,
};
export class Layout {
static create() {
return JSON.parse(JSON.stringify(LAYOUT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(LAYOUT));
for (let key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key.startsWith('_N$')) {
key = key.replace(/N\$/, '');
}
if (key === '_padding') {
source._paddingLeft = source._paddingRight = source._paddingTop = source._paddingBottom = value;
} else if (key === '_resize') {
source._resizeMode = value;
} else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Layout.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,51 @@
'use strict';
import { StaticLightSettings } from "./StaticLightSettings";
export const LIGHT = {
"__type__": "cc.Light",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255,
},
"_useColorTemperature": false,
"_colorTemperature": 6550,
"_staticSettings": {
"__id__": 1,
},
};
export class Light {
static create() {
return JSON.parse(JSON.stringify(LIGHT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(LIGHT));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Light.migrate(json2D[index]);
const settings = StaticLightSettings.create();
json3D.push(settings);
source._staticSettings = {
__id__: json3D.length - 1,
};
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,43 @@
'use strict';
export const LIMITVELOCITYOVERTIMEMODULE = {
"__type__": "cc.LimitVelocityOvertimeModule",
"_enable": false,
"limitX": {
"__id__": 1,
},
"limitY": {
"__id__": 2,
},
"limitZ": {
"__id__": 3,
},
"limit": {
"__id__": 4,
},
"dampen": 3,
"separateAxes": false,
"space": 1,
};
export class LimitVelocityOvertimeModule {
static create() {
return JSON.parse(JSON.stringify(LIMITVELOCITYOVERTIMEMODULE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(LIMITVELOCITYOVERTIMEMODULE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await LimitVelocityOvertimeModule.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,51 @@
'use strict';
export const LINE = {
"__type__": "cc.Line",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_texture": null,
"_worldSpace": false,
"_positions": [],
"_width": {
"__id__": 1,
},
"_tile": {
"__type__": "cc.Vec2",
"x": 1,
"y": 1,
},
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"_color": {
"__id__": 2,
},
};
export class Line {
static create() {
return JSON.parse(JSON.stringify(LINE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(LINE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Line.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,84 @@
'use strict';
import { ImporterBase } from "../common/base";
import { getBlendFactor2DTo3D, setColor } from "../common/utlis";
export const MASK = {
"__type__": "cc.Mask",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_materials": [],
"_visFlags": 0,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255,
},
"_type": 0,
"_inverted": false,
"_segments": 64,
"_spriteFrame": null,
"_alphaThreshold": 0.1,
};
export class Mask {
static typeTo2D(type: number) {
switch (type) {
case 2: // IMAGE_STENCIL
return 3; // IMAGE_STENCIL
}
return type;
}
static create() {
return JSON.parse(JSON.stringify(MASK));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(MASK));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === 'node') {
source.node = value;
setColor(source, value.__id__, json2D);
}
else if (key === '_type') {
source._type = Mask.typeTo2D(value);
}
else if (key === '_N$alphaThreshold') {
source._alphaThreshold = value;
}
else if (key === '_spriteFrame') {
source._spriteFrame = {
__uuid__: await ImporterBase.getUuid(value.__uuid__, 'spriteFrame'),
};
}
else if (key === '_N$inverted') {
source._inverted = value;
} else if (key === '_srcBlendFactor') {
source._srcBlendFactor = getBlendFactor2DTo3D(value);
} else if (key === '_dstBlendFactor') {
source._dstBlendFactor = getBlendFactor2DTo3D(value);
} else if (key === '_materials') {
source._materials = [];
} else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Mask.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,77 @@
'use strict';
import { ImporterBase } from "../common/base";
export const MATERIAL = {
"__type__": "cc.Material",
"_name": "",
"_objFlags": 0,
"_native": "",
"_effectAsset": null,
"_techIdx": 0,
"_defines": [],
"_states": [],
"_props": [],
};
export class Material {
static create() {
return JSON.parse(JSON.stringify(MATERIAL));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(MATERIAL));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_effectAsset') {
source._effectAsset = {
"__uuid__": await ImporterBase.getUuid(json2D._effectAsset.__uuid__),
};
}
else if (key === '_techniqueData') {
for (const key in json2D._techniqueData) {
const data = json2D._techniqueData[key];
if (data.defines) {
const defines: any = {};
for (let defineKey in data.defines) {
let va = data.defines[defineKey];
if (defineKey === 'USE_DIFFUSE_TEXTURE') {
defineKey = 'USE_TEXTURE';
}
defines[defineKey] = va;
}
source._defines.push(defines);
}
if (data.props) {
const props: any = {};
for (let propKey in data.props) {
const value = data.props[propKey];
if (propKey === 'mainTexture' || propKey === 'texture' || propKey === 'diffuseTexture') {
// 由于 texture 是关键字,所有都改成 mainTexture
propKey = 'mainTexture';
props[propKey] = {
__uuid__: await ImporterBase.getUuid(value.__uuid__, 'texture'),
};
}
else {
props[propKey] = value;
}
}
data.props && source._props.push(props);
}
}
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Material.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,36 @@
'use strict';
export const MESH = {
"__type__": "cc.Mesh",
"_name": "",
"_objFlags": 0,
"_native": "",
"_struct": {
"vertexBundles": [],
"primitives": [],
},
"_dataLength": 0,
"_hash": 0,
};
export class Mesh {
static create() {
return JSON.parse(JSON.stringify(MESH));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(MESH));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Mesh.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,63 @@
'use strict';
import { ImporterBase } from "../common/base";
export const MESHCOLLIDER = {
"__type__": "cc.MeshCollider",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_material": null,
"_isTrigger": false,
"_center": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"_mesh": null,
"_convex": false,
};
export class MeshCollider {
static create() {
return JSON.parse(JSON.stringify(MESHCOLLIDER));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(MESHCOLLIDER));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_materials') {
source._materials = [];
for (let i = 0; i < value.length; ++i) {
let material = value[0];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
source._materials.push(material);
}
}
}
else if (key === '_mesh') {
source._mesh = {
__uuid__: await ImporterBase.getUuid(value.__uuid__),
};
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await MeshCollider.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,71 @@
'use strict';
import { ImporterBase } from "../common/base";
import { ModelLightmapSettings } from "./ModelLightmapSettings";
export const MESHRENDERER = {
"__type__": "cc.MeshRenderer",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_materials": [],
"_visFlags": 0,
"lightmapSettings": null,
"_mesh": null,
"_shadowCastingMode": 0,
"_shadowReceivingMode": 1,
"_enableMorph": true,
};
export class MeshRenderer {
static create() {
return JSON.parse(JSON.stringify(MESHRENDERER));
}
static async migrate(index: any, json2D: any) {
const json = json2D[index];
const source = JSON.parse(JSON.stringify(MESHRENDERER));
for (const key in json) {
const value = json[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_materials') {
source._materials = [];
for (let i = 0; i < value.length; ++i) {
let material = value[0];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
source._materials.push(material);
}
}
}
else if (key === '_receiveShadows') {
// 1 = ON, 0 = OFF
source._shadowReceivingMode = value === 'true' ? 1 : 0;
}
else if (key === '_mesh') {
source._mesh = {
__uuid__: await ImporterBase.getUuid(value.__uuid__),
};
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await MeshRenderer.migrate(index, json2D);
const modelLightmapSettings = ModelLightmapSettings.create();
json3D.push(modelLightmapSettings);
source.lightmapSettings = {
__id__: json3D.length - 1,
};
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,422 @@
import { Animation } from "./Animation";
import { AnimationClip } from "./AnimationClip";
import { Asset } from "./Asset";
import { AudioClip } from "./AudioClip";
import { AudioSource } from "./AudioSource";
import { ArmatureDisplay } from "./ArmatureDisplay";// dragonBones.ArmatureDisplay
import { BaseNode } from "./BaseNode";
import { Billboard } from "./Billboard";
import { BitmapFont } from "./BitmapFont";
import { BlockInputEvents } from "./BlockInputEvents";
import { BoxCollider } from "./BoxCollider";
import { BoxCollider2D } from "./BoxCollider2D";
import { BufferAsset } from "./BufferAsset";
import { Button } from "./Button";
import { Camera } from "./Camera";
import { Canvas } from "./Canvas";
import { CapsuleCollider } from "./CapsuleCollider";
import { CircleCollider2D } from "./CircleCollider2D";
import { Collider } from "./Collider";
import { Collider2D } from "./Collider2D";
import { CompPrefabInfo } from "./CompPrefabInfo";
import { CompactValueTypeArray } from "./CompactValueTypeArray";
import { Component } from "./Component";
import { ComponentModifier } from "./ComponentModifier";
import { ConeCollider } from "./ConeCollider";
import { ConstantForce } from "./ConstantForce";
import { Constraint } from "./Constraint";
import { CubicSplineNumberValue } from "./CubicSplineNumberValue";
import { CubicSplineValueClass } from "./CubicSplineValueClass";
import { CurveRange } from "./CurveRange";
import { CurveValueAdapter } from "./CurveValueAdapter";
import { CylinderCollider } from "./CylinderCollider";
import { DirectionalLight } from "./DirectionalLight";
import { DistanceJoint2D } from "./DistanceJoint2D";
import { EditBox } from "./EditBox";
import { EffectAsset } from "./EffectAsset";
import { EventHandler } from "./EventHandler";
import { FixedJoint2D } from "./FixedJoint2D";
import { Font } from "./Font";
import { ForwardFlow } from "./ForwardFlow";
import { ForwardPipeline } from "./ForwardPipeline";
import { ForwardStage } from "./ForwardStage";
import { Graphics } from "./Graphics";
import { HierachyModifier } from "./HierachyModifier";
import { HingeConstraint } from "./HingeConstraint";
import { HingeJoint2D } from "./HingeJoint2D";
import { ImageAsset } from "./ImageAsset";
import { JavaScript } from "./JavaScript";
import { Joint2D } from "./Joint2D";
import { JsonAsset } from "./JsonAsset";
import { Label } from "./Label";
import { LabelAtlas } from "./LabelAtlas";
import { LabelOutline } from "./LabelOutline";
import { LabelShadow } from "./LabelShadow";
import { Layout } from "./Layout";
import { Light } from "./Light";
import { Line } from "./Line";
import { Mask } from "./Mask";
import { Material } from "./Material";
import { Mesh } from "./Mesh";
import { MeshCollider } from "./MeshCollider";
import { MeshRenderer } from "./MeshRenderer";
import { ModelLightmapSettings } from "./ModelLightmapSettings";
import { MissingScript } from "./MissingScript";
import { MotionStreak } from "./MotionStreak";
import { MouseJoint2D } from "./MouseJoint2D";
import { Node } from "./Node";
import { PageView } from "./PageView";
import { PageViewIndicator } from "./PageViewIndicator";
import { ParticleAsset } from "./ParticleAsset";
import { ParticleSystem } from "./ParticleSystem";
import { ParticleSystem2D } from "./ParticleSystem2D";
import { PhysicsMaterial } from "./PhysicsMaterial";
import { PlaneCollider } from "./PlaneCollider";
import { PointToPointConstraint } from "./PointToPointConstraint";
import { PolygonCollider2D } from "./PolygonCollider2D";
import { Prefab } from "./Prefab";
import { PrefabInfo } from "./PrefabInfo";
import { Primitive } from "./Primitive";
import { PrivateNode } from "./PrivateNode";
import { ProgressBar } from "./ProgressBar";
import { RawAsset } from "./RawAsset";
import { RelativeJoint2D } from "./RelativeJoint2D";
import { RenderFlow } from "./RenderFlow";
import { RenderPipeline } from "./RenderPipeline";
import { RenderStage } from "./RenderStage";
import { RenderTexture } from "./RenderTexture";
import { RenderableComponent } from "./RenderableComponent";
import { RichText } from "./RichText";
import { RigidBody } from "./RigidBody";
import { RigidBody2D } from "./RigidBody2D";
import { SafeArea } from "./SafeArea";
import { Scene } from "./Scene";
import { SceneAsset } from "./SceneAsset";
import { Script } from "./Script";
import { Scrollbar } from "./ScrollBar";
import { ScrollView } from "./ScrollView";
import { ShadowFlow } from "./ShadowFlow";
import { ShadowStage } from "./ShadowStage";
import { SimplexCollider } from "./SimplexCollider";
import { Skeleton } from "./Skeleton";
import { SkeletalAnimation } from "./SkeletalAnimation";
import { SkinnedMeshBatchRenderer } from "./SkinnedMeshBatchRenderer";
import { SkinnedMeshRenderer } from "./SkinnedMeshRenderer";
import { SkinnedMeshUnit } from "./SkinnedMeshUnit";
import { Slider } from "./Slider";
import { SliderJoint2D } from "./SliderJoint2D";
import { SphereCollider } from "./SphereCollider";
import { SphereLight } from "./SphereLight";
import { SpotLight } from "./SpotLight";
import { SpringJoint2D } from "./SpringJoint2D";
import { Sprite } from "./Sprite";
import { SpriteAtlas } from "./SpriteAtlas";
import { SpriteFrame } from "./SpriteFrame";
import { SubContextView } from "./SubContextView";
import { TTFFont } from "./TTFFont";
import { TextAsset } from "./TextAsset";
import { Texture2D } from "./Texture2D";
import { TextureCube } from "./TextureCube";
import { TiledLayer } from "./TiledLayer";
import { TiledMap } from "./TiledMap";
import { TiledMapAsset } from "./TiledMapAsset";
import { TiledObjectGroup } from "./TiledObjectGroup";
import { TiledTile } from "./TiledTile";
import { TiledUserNodeData } from "./TiledUserNodeData";
import { Toggle } from "./Toggle";
import { ToggleContainer } from "./ToggleContainer";
import { TypeScript } from "./TypeScript";
import { UIComponent } from "./UIComponent";
import { UICoordinateTracker } from "./UICoordinateTracker";
import { UIMeshRenderer } from "./UIMeshRenderer";
import { UIOpacity } from "./UIOpacity";
import { UIRenderable } from "./UIRenderable";
import { UIReorderComponent } from "./UIReorderComponent";
import { UIStaticBatch } from "./UIStaticBatch";
import { UITransform } from "./UITransform";
import { UniformCurveValueAdapter } from "./UniformCurveValueAdapter";
import { VideoClip } from "./VideoClip";
import { VideoPlayer } from "./VideoPlayer";
import { ViewGroup } from "./ViewGroup";
import { WebView } from "./WebView";
import { WheelJoint2D } from "./WheelJoint2D";
import { Widget } from "./Widget";
import { AnimationCurve } from "./AnimationCurve";
import { Keyframe } from "./Keyframe";
import { AlphaKey } from "./AlphaKey";
import { Gradient } from "./Gradient";
import { GradientRange } from "./GradientRange";
import { Burst } from "./Burst";
import { ShapeModule } from "./ShapeModule";
import { ColorOvertimeModule } from "./ColorOvertimeModule";
import { SizeOvertimeModule } from "./SizeOvertimeModule";
import { VelocityOvertimeModule } from "./VelocityOvertimeModule";
import { ForceOvertimeModule } from "./ForceOvertimeModule";
import { LimitVelocityOvertimeModule } from "./LimitVelocityOvertimeModule";
import { RotationOvertimeModule } from "./RotationOvertimeModule";
import { TextureAnimationModule } from "./TextureAnimationModule";
import { ColorKey } from "./ColorKey";
import { TrailModule } from "./TrailModule";
import { ImporterBase } from "../common/base";
import { Sp_Skeleton } from "./SpSkeleton";
import { StudioComponent } from "./StudioComponent";
import { StudioWidget } from "./StudioWidget";
import { getBlendFactor2DTo3D, getColor } from "../common/utlis";
const CCCLASS_LIST = {
'cc.Animation': Animation,
'cc.AnimationClip': AnimationClip,
'cc.AnimationCurve': AnimationCurve,
'cc.Asset': Asset,
'cc.AlphaKey': AlphaKey,
'cc.AudioClip': AudioClip,
'cc.AudioSource': AudioSource,
'cc.Burst': Burst,
'cc.Button': Button,
'cc.BaseNode': BaseNode,
'cc.Billboard': Billboard,
'cc.BitmapFont': BitmapFont,
'cc.BoxCollider2D': BoxCollider2D,
'cc.BlockInputEvents': BlockInputEvents,
'cc.BufferAsset': BufferAsset,
'cc.BoxCollider': BoxCollider,
'cc.ColorKey': ColorKey,
'cc.Camera': Camera,
'cc.Canvas': Canvas,
'cc.CapsuleCollider': CapsuleCollider,
'cc.CircleCollider2D': CircleCollider2D,
'cc.Collider': Collider,
'cc.Collider2D': Collider2D,
'cc.CompPrefabInfo': CompPrefabInfo,
'cc.CompactValueTypeArray': CompactValueTypeArray,
'cc.Component': Component,
'cc.ComponentModifier': ComponentModifier,
'cc.ConeCollider': ConeCollider,
'cc.ConstantForce': ConstantForce,
'cc.Constraint': Constraint,
'cc.CubicSplineNumberValue': CubicSplineNumberValue,
'cc.CubicSplineValueClass': CubicSplineValueClass,
'cc.CurveRange': CurveRange,
'cc.CurveValueAdapter': CurveValueAdapter,
'cc.CylinderCollider': CylinderCollider,
'cc.ColorOvertimeModule': ColorOvertimeModule,
'cc.DirectionalLight': DirectionalLight,
'cc.DistanceJoint2D': DistanceJoint2D,
'cc.EditBox': EditBox,
'cc.EffectAsset': EffectAsset,
'cc.EventHandler': EventHandler,
'cc.FixedJoint2D': FixedJoint2D,
'cc.Font': Font,
'cc.ForwardFlow': ForwardFlow,
'cc.ForwardPipeline': ForwardPipeline,
'cc.ForwardStage': ForwardStage,
'cc.ForceOvertimeModule': ForceOvertimeModule,
'cc.Graphics': Graphics,
'cc.Gradient': Gradient,
'cc.GradientRange': GradientRange,
'cc.HierachyModifier': HierachyModifier,
'cc.HingeConstraint': HingeConstraint,
'cc.HingeJoint2D': HingeJoint2D,
'cc.ImageAsset': ImageAsset,
'cc.JavaScript': JavaScript,
'cc.Joint2D': Joint2D,
'cc.JsonAsset': JsonAsset,
'cc.Keyframe': Keyframe,
'cc.Label': Label,
'cc.LabelAtlas': LabelAtlas,
'cc.LabelOutline': LabelOutline,
'cc.LabelShadow': LabelShadow,
'cc.Layout': Layout,
'cc.Light': Light,
'cc.Line': Line,
'cc.LimitVelocityOvertimeModule': LimitVelocityOvertimeModule,
'cc.Mask': Mask,
'cc.Material': Material,
'cc.Mesh': Mesh,
'cc.MeshCollider': MeshCollider,
'cc.MeshRenderer': MeshRenderer,
'cc.ModelLightmapSettings': ModelLightmapSettings,
'cc.MissingScript': MissingScript,
'cc.MotionStreak': MotionStreak,
'cc.MouseJoint2D': MouseJoint2D,
'cc.Node': Node,
'cc.PageView': PageView,
'cc.PageViewIndicator': PageViewIndicator,
'cc.ParticleAsset': ParticleAsset,
'cc.ParticleSystem': ParticleSystem,
'cc.ParticleSystem2D': ParticleSystem2D,
'cc.PhysicsMaterial': PhysicsMaterial,
'cc.PlaneCollider': PlaneCollider,
'cc.PointToPointConstraint': PointToPointConstraint,
'cc.PolygonCollider2D': PolygonCollider2D,
'cc.Prefab': Prefab,
'cc.PrefabInfo': PrefabInfo,
'cc.Primitive': Primitive,
'cc.PrivateNode': PrivateNode,
'cc.ProgressBar': ProgressBar,
'cc.RawAsset': RawAsset,
'cc.RenderFlow': RenderFlow,
'cc.RenderStage': RenderStage,
'cc.RichText': RichText,
'cc.RigidBody': RigidBody,
'cc.RigidBody2D': RigidBody2D,
'cc.RenderTexture': RenderTexture,
'cc.RenderPipeline': RenderPipeline,
'cc.RelativeJoint2D': RelativeJoint2D,
'cc.RenderableComponent': RenderableComponent,
'cc.RotationOvertimeModule': RotationOvertimeModule,
'cc.ShapeModule': ShapeModule,
'cc.SafeArea': SafeArea,
'cc.Scene': Scene,
'cc.SceneAsset': SceneAsset,
'cc.Script': Script,
'cc.Scrollbar': Scrollbar,
'cc.ScrollView': ScrollView,
'cc.ShadowFlow': ShadowFlow,
'cc.ShadowStage': ShadowStage,
'cc.SimplexCollider': SimplexCollider,
'cc.Skeleton': Skeleton,
'cc.SkeletalAnimation': SkeletalAnimation,
'cc.SkinnedMeshBatchRenderer': SkinnedMeshBatchRenderer,
'cc.SkinnedMeshRenderer': SkinnedMeshRenderer,
'cc.SkinnedMeshUnit': SkinnedMeshUnit,
'cc.Slider': Slider,
'cc.SliderJoint2D': SliderJoint2D,
'cc.SphereCollider': SphereCollider,
'cc.SphereLight': SphereLight,
'cc.SpotLight': SpotLight,
'cc.SpringJoint2D': SpringJoint2D,
'cc.Sprite': Sprite,
'cc.SpriteAtlas': SpriteAtlas,
'cc.SpriteFrame': SpriteFrame,
'cc.SubContextView': SubContextView,
'cc.SizeOvertimeModule': SizeOvertimeModule,
'cc.TTFFont': TTFFont,
'cc.TextAsset': TextAsset,
'cc.Texture2D': Texture2D,
'cc.TextureCube': TextureCube,
'cc.TiledLayer': TiledLayer,
'cc.TiledMap': TiledMap,
'cc.TiledMapAsset': TiledMapAsset,
'cc.TiledObjectGroup': TiledObjectGroup,
'cc.TiledTile': TiledTile,
'cc.TiledUserNodeData': TiledUserNodeData,
'cc.Toggle': Toggle,
'cc.ToggleContainer': ToggleContainer,
'cc.TypeScript': TypeScript,
'cc.TextureAnimationModule': TextureAnimationModule,
'cc.TrailModule': TrailModule,
'cc.UIComponent': UIComponent,
'cc.UICoordinateTracker': UICoordinateTracker,
'cc.UIMeshRenderer': UIMeshRenderer,
'cc.UIOpacity': UIOpacity,
'cc.UIRenderable': UIRenderable,
'cc.UIReorderComponent': UIReorderComponent,
'cc.UIStaticBatch': UIStaticBatch,
'cc.UITransform': UITransform,
'cc.UniformCurveValueAdapter': UniformCurveValueAdapter,
'cc.VideoClip': VideoClip,
'cc.VideoPlayer': VideoPlayer,
'cc.ViewGroup': ViewGroup,
'cc.VelocityOvertimeModule': VelocityOvertimeModule,
'cc.WebView': WebView,
'cc.WheelJoint2D': WheelJoint2D,
'cc.Widget': Widget,
'dragonBones.ArmatureDisplay': ArmatureDisplay,
'sp.Skeleton': Sp_Skeleton,
'cc.StudioComponent': StudioComponent,
'cc.StudioWidget': StudioWidget,
};
const RENAME_COMPONENT: any = {
'cc.BoxCollider3D': 'cc.BoxCollider',
'cc.BoxCollider': 'cc.BoxCollider2D',
'cc.PhysicsBoxCollider': 'cc.BoxCollider2D',
'cc.CircleCollider': 'cc.CircleCollider2D',
'cc.PhysicsCircleCollider': 'cc.CircleCollider2D',
'cc.Collider': 'cc.Collider2D',
'cc.PhysicsCollider': 'cc.Collider2D',
'cc.PhysicsChainCollider': 'cc.Collider2D',
'cc.Collider3D': 'cc.Collider',
'cc.DistanceJoint': 'cc.DistanceJoint2D',
'cc.ClickEvent': 'cc.EventHandler',
'cc.MouseJoint': 'cc.MouseJoint2D',
'cc.WheelJoint': 'cc.WheelJoint2D',
'cc.PolygonCollider': 'cc.PolygonCollider2D',
'cc.PhysicsPolygonCollider': 'cc.PolygonCollider2D',
'cc.ParticleSystem': 'cc.ParticleSystem2D',
'cc.ParticleSystem3D': 'cc.ParticleSystem',
'cc.Joint': 'cc.Joint2D',
'cc.RigidBody': 'cc.RigidBody2D',
'cc.RigidBody3D': 'cc.RigidBody',
'cc.SphereCollider3D': 'cc.SphereCollider',
'cc.RenderComponent': 'cc.UIRenderable',
'cc.SkeletonAnimation': 'cc.SkeletalAnimation',
'cc.StudioWidget': 'cc.Widget',
};
export class MigrateManager {
static logs: string[] = [];
static async migrate(index: number, json2D: any, json3D: any) {
const element2D = json2D[index];
let type = element2D.__type__ || element2D[0].__type__;// 粒子存的是数组
if (type === 'cc.Light') {
switch (element2D._type) {
case 0:
type = 'cc.DirectionalLight';
break;
case 1:
type = 'cc.PointLight';
break;
case 2:
type = 'cc.SpotLight';
break;
case 3:// 环境不支持,已导入到场景中,而且实现也不一样
break;
}
}
const renameTyep = RENAME_COMPONENT[type];
if (renameTyep) {
type = renameTyep;
}
// @ts-ignore
const CCClass = CCCLASS_LIST[type];
if (CCClass) {
return await CCClass.apply(index, json2D, json3D);
}
else {
if (type.startsWith('cc.')) {
if (!MigrateManager.logs.includes(type)) {
MigrateManager.logs.push(type);
}
// console.log('未适配类型:' + type + ' ' + index);
}
let source: any = {};
for (const key in element2D) {
let value = element2D[key];
if (value && value.__uuid__) {
value.__uuid__ = await ImporterBase.getUuid(value.__uuid__);
}
else if (key === '_srcBlendFactor' || key === '_dstBlendFactor') {
value = getBlendFactor2DTo3D(value);
if (!source._color) {
source._color = getColor(json2D[element2D.node.__id__]);
}
}
source[key] = value;
}
let content = JSON.stringify(source, undefined, 2);
const __uuids__ = content.match(/(?<=__uuid__": ")(.*)(?=")/g) || [];
for (let uuid of __uuids__) {
const oldUuid = uuid;
uuid = await ImporterBase.getUuid(uuid) as string;
content = content.replace(oldUuid, uuid);
}
source = JSON.parse(content);
json3D.splice(index, 1, source);
return source;
}
}
}

View File

@@ -0,0 +1,27 @@
'use strict';
export const MISSINGSCRIPT = {
"__type__": "cc.MissingScript",
};
export class MissingScript {
static create() {
return JSON.parse(JSON.stringify(MISSINGSCRIPT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(MISSINGSCRIPT));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await MissingScript.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,41 @@
'use strict';
export const MODELLIGHTMAPSETTINGS = {
"__type__": "cc.ModelLightmapSettings",
"texture": null,
"uvParam": {
"__type__": "cc.Vec4",
"x": 0,
"y": 0,
"z": 0,
"w": 0,
},
"_bakeable": false,
"_castShadow": false,
"_receiveShadow": false,
"_recieveShadow": false,
"_lightmapSize": 64,
};
export class ModelLightmapSettings {
static create() {
return JSON.parse(JSON.stringify(MODELLIGHTMAPSETTINGS));
}
static async migrate(index: any, json2D: any) {
const source = JSON.parse(JSON.stringify(MODELLIGHTMAPSETTINGS));
const json = json2D[index];
for (const key in json) {
const value = json[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ModelLightmapSettings.migrate(index, json2D);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,63 @@
'use strict';
import { getBlendFactor2DTo3D } from "../common/utlis";
import { ImporterBase } from "../common/base";
export const MOTIONSTREAK = {
"__type__": "cc.MotionStreak",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_materials": [],
"_visFlags": 0,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255,
},
"_preview": false,
"_fadeTime": 1,
"_minSeg": 1,
"_stroke": 64,
"_texture": null,
"_fastMode": false,
};
export class MotionStreak {
static create() {
return JSON.parse(JSON.stringify(MOTIONSTREAK));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(MOTIONSTREAK));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_srcBlendFactor') {
source._srcBlendFactor = getBlendFactor2DTo3D(value);
} else if (key === '_dstBlendFactor') {
source._dstBlendFactor = getBlendFactor2DTo3D(value);
} else if (key === '_texture') {
source._texture = {
__uuid__: await ImporterBase.getUuid(value.__uuid__, 'texture'),
};
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await MotionStreak.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,47 @@
'use strict';
export const MOUSEJOINT2D = {
"__type__": "cc.MouseJoint2D",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"anchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"connectedAnchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"collideConnected": false,
"connectedBody": null,
"_maxForce": 1000,
"_dampingRatio": 0.7,
"_frequency": 5,
};
export class MouseJoint2D {
static create() {
return JSON.parse(JSON.stringify(MOUSEJOINT2D));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(MOUSEJOINT2D));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await MouseJoint2D.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,152 @@
'use strict';
import { getGroupLayerByIndex, fromEuler, hasUIRenderComponent, hasCanvasComponent } from '../common/utlis';
import { UITransform } from "./UITransform";
import { UIOpacity } from "./UIOpacity";
export const NODE = {
"__type__": "cc.Node",
"_name": "New Node",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1,
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1,
},
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
};
export class Node {
static create(name?: string, parentID?: number) {
const node = JSON.parse(JSON.stringify(NODE));
if (name) {
node._name = name;
}
if (parentID) {
node._parent = {
__id__: parentID,
};
}
return node;
}
static addComponents(node: any, componentID: number) {
node._components.push({
__id__: componentID,
});
}
static addChildren(node: any, childID: number) {
node._children.push({
__id__: childID,
});
}
static async migrate(index: number, json2D: any, json3D: any) {
const source = JSON.parse(JSON.stringify(NODE));
const node = json2D[index];
// 先导入 components
if (node._components) {
for (const component of node._components) {
const element = source._components.find((obj: any) => {
return obj.__id__ === component.__id__;
});
if (!element) {
source._components.push(component);
}
}
}
for (const key in node) {
const value = node[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_groupIndex' || key === 'groupIndex') {
let layer = await getGroupLayerByIndex(value);
// 如果是 Canvas 并且 layer 是默认的,就设置为 UI_2D
if (layer === 1 && hasCanvasComponent(node, json2D)) {
layer = 1 << 25;
}
if (!layer) {
console.warn(`The group layer: ${layer} no found. node name: ${node._name}`);
layer = value;
}
source._layer = layer;
}
else if (key === '_color' || key === '_components') {
continue;
}
else if (key === '_trs') {
const trs = value.array;
source._lpos.x = trs[0];
source._lpos.y = trs[1];
source._lpos.z = trs[2];
source._lrot.x = trs[3];
source._lrot.y = trs[4];
source._lrot.z = trs[5];
source._lrot.w = trs[6] === 0 ? 1 : trs[6];
source._lscale.x = trs[7];
source._lscale.y = trs[8];
// 如果不是 3d 节点并且 scale z 是 0就默认设置为 1
if (!node['_is3DNode'] && trs[9] === 0) {
trs[9] = 1;
}
source._lscale.z = trs[9];
}
else if (key === '_eulerAngles') {
source._euler.x = value.x;
source._euler.y = value.y;
source._euler.z = value.z;
}
else if (key === '_contentSize') {
if (hasUIRenderComponent(source, json2D)) {
UITransform.setContentSize(source, index, value, json3D);
}
}
else if (key === '_anchorPoint') {
if (hasUIRenderComponent(source, json2D)) {
UITransform.setAnchorPoint(source, index, value, json3D);
}
}
else if (key === '_opacity') {
if (hasUIRenderComponent(source, json2D)) {
UIOpacity.setOpacity(source, index, value, json3D);
}
}
else {
source[key] = value;
}
}
fromEuler(source._lrot, source._euler.x, source._euler.y, source._euler.z);
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Node.migrate(index, json2D, json3D);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,77 @@
'use strict';
export const PAGEVIEW = {
"__type__": "cc.PageView",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"bounceDuration": 1,
"brake": 0.5,
"elastic": true,
"inertia": true,
"horizontal": true,
"vertical": true,
"cancelInnerEvents": true,
"scrollEvents": [],
"_content": null,
"_horizontalScrollBar": null,
"_verticalScrollBar": null,
"autoPageTurningThreshold": 100,
"pageTurningSpeed": 0.3,
"pageEvents": [],
"_sizeMode": 0,
"_direction": 0,
"_scrollThreshold": 0.5,
"_pageTurningEventTiming": 0.1,
"_indicator": null,
};
export class PageView {
static create() {
return JSON.parse(JSON.stringify(PAGEVIEW));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(PAGEVIEW));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
switch (key) {
case '_N$content':
case 'content':
source._content = value;
break;
case 'scrollThreshold':
source._scrollThreshold = value;
break;
case 'pageTurningEventTiming':
source._pageTurningEventTiming = value;
break;
case '_N$sizeMode':
case 'sizeMode':
source._sizeMode = value;
break;
case '_N$direction':
case 'direction':
source._direction = value;
break;
case '_N$indicator':
case 'indicator':
source._indicator = value;
break;
default:
source[key] = value;
break;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await PageView.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,55 @@
'use strict';
import { ImporterBase } from "../common/base";
export const PAGEVIEWINDICATOR = {
"__type__": "cc.PageViewIndicator",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"spacing": 0,
"_spriteFrame": null,
"_direction": 0,
"_cellSize": {
"__type__": "cc.Size",
"width": 20,
"height": 20,
},
};
export class PageViewIndicator {
static create() {
return JSON.parse(JSON.stringify(PAGEVIEWINDICATOR));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(PAGEVIEWINDICATOR));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === 'spriteFrame') {
source._spriteFrame = {
__uuid__: await ImporterBase.getUuid(value.__uuid__, 'spriteFrame'),
};
}
else if (key === 'cellSize') {
source._cellSize = value;
}
else if (key === 'direction') {
source._direction = value;
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await PageViewIndicator.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,31 @@
'use strict';
export const PARTICLEASSET = {
"__type__": "cc.ParticleAsset",
"_name": "",
"_objFlags": 0,
"_native": "",
"spriteFrame": null,
};
export class ParticleAsset {
static create() {
return JSON.parse(JSON.stringify(PARTICLEASSET));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(PARTICLEASSET));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ParticleAsset.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,171 @@
'use strict';
import { ImporterBase } from "../common/base";
import {GradientRange} from "./GradientRange";
import {CurveRange} from "./CurveRange";
export const PARTICLESYSTEM = {
"__type__": "cc.ParticleSystem",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_materials": [],
"_visFlags": 0,
"startColor": {
"__id__": -1,
},
"scaleSpace": 1,
"startSize3D": false,
"startSizeX": {
"__id__": 2,
},
"startSize": {
"__id__": 2,
},
"startSizeY": {
"__id__": 3,
},
"startSizeZ": {
"__id__": 4,
},
"startSpeed": {
"__id__": 5,
},
"startRotation3D": false,
"startRotationX": {
"__id__": 6,
},
"startRotationY": {
"__id__": 7,
},
"startRotationZ": {
"__id__": 8,
},
"startRotation": {
"__id__": 8,
},
"startDelay": {
"__id__": 9,
},
"startLifetime": {
"__id__": 10,
},
"duration": 5,
"loop": true,
"simulationSpeed": 1,
"playOnAwake": true,
"gravityModifier": {
"__id__": 11,
},
"rateOverTime": {
"__id__": 12,
},
"rateOverDistance": {
"__id__": 13,
},
"bursts": [],
"_colorOverLifetimeModule": null,
"_shapeModule": null,
"_sizeOvertimeModule": null,
"_velocityOvertimeModule": null,
"_forceOvertimeModule": null,
"_limitVelocityOvertimeModule": null,
"_rotationOvertimeModule": null,
"_textureAnimationModule": null,
"_trailModule": null,
"renderer": {
"__id__": 14,
},
"enableCulling": false,
"_prewarm": false,
"_capacity": 100,
"_simulationSpace": 1,
};
const PARTICLESYSTEMRENDERER = {
"__type__": "cc.ParticleSystemRenderer",
"_renderMode": 0,
"_velocityScale": 1,
"_lengthScale": 1,
"_mesh": null,
"_mainTexture": null,
"_useGPU": false,
};
export class ParticleSystem {
static create() {
return JSON.parse(JSON.stringify(PARTICLESYSTEM));
}
static createRenderer() {
return JSON.parse(JSON.stringify(PARTICLESYSTEMRENDERER));
}
static async migrate(particleSystem: any) {
const source = JSON.parse(JSON.stringify(PARTICLESYSTEM));
for (const key in particleSystem) {
const value = particleSystem[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_materials') {
source._materials = [];
for (let i = 0; i < value.length; ++i) {
let material = value[i];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
source._materials.push(material);
}
}
}
else if (key === '_velocityScale' || key === '_lengthScale' || key === '_mesh' || key === '_renderMode') {
// 不做处理
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const particleSystem = json2D[index];
const source = await ParticleSystem.migrate(particleSystem);
const renderer = ParticleSystem.createRenderer();
renderer._velocityScale = particleSystem._velocityScale;
renderer._lengthScale = particleSystem._lengthScale;
renderer._renderMode = particleSystem._renderMode;
if (particleSystem._mesh) {
renderer._mesh = {
__uuid__: await ImporterBase.getUuid(particleSystem._mesh.__uuid__),
};
}
json3D.push(renderer);
source.renderer.__id__ = json3D.length - 1;
const gr = GradientRange.create();
json3D.push(gr);
let cr = CurveRange.create();
json3D.push(cr);
source.startSizeX = json3D.length - 1;
cr = CurveRange.create();
json3D.push(cr);
source.startSizeY = json3D.length - 1;
cr = CurveRange.create();
json3D.push(cr);
source.startSizeZ = json3D.length - 1;
cr = CurveRange.create();
json3D.push(cr);
source.startRotationX = json3D.length - 1;
cr = CurveRange.create();
json3D.push(cr);
source.startRotationY = json3D.length - 1;
cr = CurveRange.create();
json3D.push(cr);
source.startRotationZ = json3D.length - 1;
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,171 @@
'use strict';
import { ImporterBase } from "../common/base";
import { getBlendFactor2DTo3D, setColor } from "../common/utlis";
export const PARTICLESYSTEM2D = {
"__type__": "cc.ParticleSystem2D",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_materials": null,
"_visFlags": 0,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255,
},
"preview": true,
"_custom": false,
"_file": null,
"_spriteFrame": null,
"_texture": null,
"playOnLoad": true,
"autoRemoveOnFinish": false,
"_totalParticles": 150,
"duration": -1,
"emissionRate": 10,
"life": 1,
"lifeVar": 0,
"_startColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255,
},
"_startColorVar": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 0,
},
"_endColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 0,
},
"_endColorVar": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 0,
},
"angle": 90,
"angleVar": 20,
"startSize": 50,
"startSizeVar": 0,
"endSize": 0,
"endSizeVar": 0,
"startSpin": 0,
"startSpinVar": 0,
"endSpin": 0,
"endSpinVar": 0,
"sourcePos": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"posVar": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"_positionType": 0,
"emitterMode": 0,
"gravity": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"speed": 180,
"speedVar": 50,
"tangentialAccel": 80,
"tangentialAccelVar": 0,
"radialAccel": 0,
"radialAccelVar": 0,
"rotationIsDir": false,
"startRadius": 0,
"startRadiusVar": 0,
"endRadius": 0,
"endRadiusVar": 0,
"rotatePerS": 0,
"rotatePerSVar": 0,
};
export class ParticleSystem2D {
static create() {
return JSON.parse(JSON.stringify(PARTICLESYSTEM2D));
}
static async migrate(json2D: any, json3D: any) {
const source = JSON.parse(JSON.stringify(PARTICLESYSTEM2D));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === 'node') {
source.node = value;
setColor(source, value.__id__, json2D);
}
else if (key === '_N$preview') {
source.preview = value;
}
else if (key === '_materials') {
if (key === '_materials') {
source._materials = [];
for (let i = 0; i < value.length; ++i) {
let material = value[i];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
source._materials.push(material);
}
}
}
}
else if (key === '_totalParticles') {
source.totalParticles = value;
}
else if (key === '_spriteFrame') {
source._spriteFrame = {
__uuid__: await ImporterBase.getUuid(value.__uuid__, 'spriteFrame'),
};
}
else if (key === '_texture') {
source._texture = {
__uuid__: await ImporterBase.getUuid(value.__uuid__, 'texture'),
};
}
else if (key === '_file') {
source._file = {
__uuid__: await ImporterBase.getUuid(value.__uuid__),
};
} else if (key === '_dstBlendFactor') {
source._dstBlendFactor = getBlendFactor2DTo3D(value);
} else if (key === '_srcBlendFactor') {
source._srcBlendFactor = getBlendFactor2DTo3D(value);
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ParticleSystem2D.migrate(json2D[index], json3D);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,34 @@
'use strict';
export const PHYSICSMATERIAL = {
"__type__": "cc.PhysicsMaterial",
"_name": "",
"_objFlags": 0,
"_native": "",
"_friction": 0.5,
"_rollingFriction": 0.1,
"_spinningFriction": 0.1,
"_restitution": 0.1,
};
export class PhysicsMaterial {
static create() {
return JSON.parse(JSON.stringify(PHYSICSMATERIAL));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(PHYSICSMATERIAL));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await PhysicsMaterial.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,63 @@
'use strict';
import { ImporterBase } from "../common/base";
export const PLANECOLLIDER = {
"__type__": "cc.PlaneCollider",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_material": null,
"_isTrigger": false,
"_center": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"_normal": {
"__type__": "cc.Vec3",
"x": 0,
"y": 1,
"z": 0,
},
"_constant": 0,
};
export class PlaneCollider {
static create() {
return JSON.parse(JSON.stringify(PLANECOLLIDER));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(PLANECOLLIDER));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_materials') {
source._materials = [];
for (let i = 0; i < value.length; ++i) {
let material = value[0];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
source._materials.push(material);
}
}
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await PlaneCollider.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,46 @@
'use strict';
export const POINTTOPOINTCONSTRAINT = {
"__type__": "cc.PointToPointConstraint",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_enableCollision": true,
"_connectedBody": null,
"_pivotA": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"_pivotB": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
};
export class PointToPointConstraint {
static create() {
return JSON.parse(JSON.stringify(POINTTOPOINTCONSTRAINT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(POINTTOPOINTCONSTRAINT));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await PointToPointConstraint.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,49 @@
'use strict';
export const POLYGONCOLLIDER2D = {
"__type__": "cc.PolygonCollider2D",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"tag": 0,
"_group": 1,
"_density": 1,
"_sensor": false,
"_friction": 0.2,
"_restitution": 0,
"_offset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"_points": [],
};
export class PolygonCollider2D {
static create() {
return JSON.parse(JSON.stringify(POLYGONCOLLIDER2D));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(POLYGONCOLLIDER2D));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === 'points') {
source._point = value;
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await PolygonCollider2D.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,33 @@
'use strict';
export const PREFAB = {
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": null,
"optimizationPolicy": 0,
"asyncLoadAssets": false,
};
export class Prefab {
static create() {
return JSON.parse(JSON.stringify(PREFAB));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(PREFAB));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Prefab.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,59 @@
'use strict';
import { ImporterBase } from "../common/base";
export const PREFABINFO = {
"__type__": "cc.PrefabInfo",
"root": null,
"asset": null,
"fileId": "",
"sync": false,
"_synced": {
"default": false,
"serializable": false,
},
};
export class PrefabInfo {
static create() {
return JSON.parse(JSON.stringify(PREFABINFO));
}
static async migrate(json2D: any, json3D: any) {
const source = JSON.parse(JSON.stringify(PREFABINFO));
let isPrefab = false;
if (json3D && json3D[0]) {
isPrefab = json3D[0].__type__ === 'cc.Prefab';
}
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === 'asset') {
if (value.__uuid__) {
let __uuid__;
if (isPrefab) {
__uuid__ = ImporterBase.getNewUuid(value.__uuid__);
} else {
__uuid__ = await ImporterBase.getUuid(value.__uuid__);
}
source.asset = {
__uuid__: __uuid__,
};
}
else if (value.__id__) {
source.asset = value;
}
}
else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await PrefabInfo.migrate(json2D[index], json3D);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,38 @@
'use strict';
export const PRIMITIVE = {
"__type__": "cc.Primitive",
"_name": "",
"_objFlags": 0,
"_native": "",
"_struct": {
"vertexBundles": [],
"primitives": [],
},
"_dataLength": 0,
"_hash": 0,
"type": 0,
"info": {},
};
export class Primitive {
static create() {
return JSON.parse(JSON.stringify(PRIMITIVE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(PRIMITIVE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await Primitive.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,137 @@
'use strict';
import { getGroupLayerByIndex } from "../common/utlis";
import { UITransform } from "./UITransform";
import { UIOpacity } from "./UIOpacity";
export const PRIVATENODE = {
"__type__": "cc.PrivateNode",
"_name": "New Node",
"_objFlags": 1024,
"_parent": null,
"_children": [],
"_active": true,
"_components": [],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1,
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1,
},
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0,
},
};
export class PrivateNode {
static create() {
return JSON.parse(JSON.stringify(PRIVATENODE));
}
static async migrate(index: number, json2D: any, json3D: any) {
const source = JSON.parse(JSON.stringify(PRIVATENODE));
const privateNode = json2D[index];
for (const key in privateNode) {
const value = privateNode[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key === '_groupIndex') {
let layer = await getGroupLayerByIndex(value);
if (!layer) {
console.warn(`The group layer: ${index} no found. node name: ${privateNode._name}`);
layer = value;
}
source._layer = layer;
}
else if (key === '_trs') {
const trs = value.array;
source._lpos.x = trs[0];
source._lpos.y = trs[1];
source._lpos.z = trs[2];
source._lrot.x = trs[3];
source._lrot.y = trs[4];
source._lrot.z = trs[5];
source._lrot.w = trs[6];
source._lscale.x = trs[7];
source._lscale.y = trs[8];
source._lscale.z = trs[9];
}
else if (key === '_eulerAngles') {
source._euler.x = value.x;
source._euler.y = value.y;
source._euler.z = value.z;
}
else if (key === '_contentSize' || key === '_anchorPoint') {
let uiTransform: any = null;
source._components.find((obj: any) => {
const comp = json3D[obj.__id__];
if (comp && comp.__type__ === 'cc.UITransform') {
uiTransform = comp;
return comp;
}
});
if (!uiTransform) {
uiTransform = UITransform.create();
uiTransform.node = {
__id__: index,
};
json3D.push(uiTransform);
source._components.push({
__id__: json3D.length - 1,
});
}
if (key === '_contentSize') {
uiTransform._contentSize = privateNode._contentSize;
} else if (key === '_anchorPoint') {
uiTransform._anchorPoint = privateNode._anchorPoint;
}
} else if (key === '_opacity') {
let uiOpacity: any = null;
source._components.find((obj: any) => {
const comp = json3D[obj.__id__];
if (comp && comp.__type__ === 'cc.UIOpacity') {
uiOpacity = comp;
return comp;
}
});
if (!uiOpacity) {
uiOpacity = UIOpacity.create();
uiOpacity.node = {
__id__: index,
};
json3D.push(uiOpacity);
source._components.push({
__id__: json3D.length - 1,
});
}
uiOpacity._opacity = privateNode._opacity;
} else {
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await PrivateNode.migrate(index, json2D, json3D);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,40 @@
'use strict';
export const PROGRESSBAR = {
"__type__": "cc.ProgressBar",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_barSprite": null,
"_mode": 0,
"_totalLength": 1,
"_progress": 0.1,
"_reverse": false,
};
export class ProgressBar {
static create() {
return JSON.parse(JSON.stringify(PROGRESSBAR));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(PROGRESSBAR));
for (let key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
if (key.startsWith('_N$')) {
key = key.replace(/N\$/, '');
}
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await ProgressBar.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,29 @@
'use strict';
export const RAWASSET = {
"__type__": "cc.RawAsset",
"_name": "",
"_objFlags": 0,
};
export class RawAsset {
static create() {
return JSON.parse(JSON.stringify(RAWASSET));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(RAWASSET));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await RawAsset.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,54 @@
'use strict';
export const RELATIVEJOINT2D = {
"__type__": "cc.RelativeJoint2D",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"anchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"connectedAnchor": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"collideConnected": false,
"connectedBody": null,
"_maxForce": 5,
"_maxTorque": 0.7,
"_correctionFactor": 0.3,
"_angularOffset": 0,
"_linearOffset": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0,
},
"_autoCalcOffset": true,
};
export class RelativeJoint2D {
static create() {
return JSON.parse(JSON.stringify(RELATIVEJOINT2D));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(RELATIVEJOINT2D));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await RelativeJoint2D.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,31 @@
'use strict';
export const RENDERFLOW = {
"__type__": "RenderFlow",
"_name": "",
"_priority": 0,
"_tag": 0,
"_stages": [],
};
export class RenderFlow {
static create() {
return JSON.parse(JSON.stringify(RENDERFLOW));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(RENDERFLOW));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await RenderFlow.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,32 @@
'use strict';
export const RENDERPIPELINE = {
"__type__": "cc.RenderPipeline",
"_name": "",
"_objFlags": 0,
"_native": "",
"_tag": 0,
"_flows": [],
};
export class RenderPipeline {
static create() {
return JSON.parse(JSON.stringify(RENDERPIPELINE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(RENDERPIPELINE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await RenderPipeline.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,30 @@
'use strict';
export const RENDERSTAGE = {
"__type__": "RenderStage",
"_name": "",
"_priority": 0,
"_tag": 0,
};
export class RenderStage {
static create() {
return JSON.parse(JSON.stringify(RENDERSTAGE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(RENDERSTAGE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await RenderStage.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,32 @@
'use strict';
export const RENDERTEXTURE = {
"__type__": "cc.RenderTexture",
"_name": "",
"_objFlags": 0,
"_native": "",
"_width": 1,
"_height": 1,
};
export class RenderTexture {
static create() {
return JSON.parse(JSON.stringify(RENDERTEXTURE));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(RENDERTEXTURE));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await RenderTexture.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,34 @@
'use strict';
export const RENDERABLECOMPONENT = {
"__type__": "cc.RenderableComponent",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_materials": [],
"_visFlags": 0,
};
export class RenderableComponent {
static create() {
return JSON.parse(JSON.stringify(RENDERABLECOMPONENT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(RENDERABLECOMPONENT));
for (const key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) { continue; }
source[key] = value;
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await RenderableComponent.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

View File

@@ -0,0 +1,78 @@
'use strict';
import { ImporterBase } from "../common/base";
import { getBlendFactor2DTo3D } from "../common/utlis";
export const RICHTEXT = {
"__type__": "cc.RichText",
"_name": "",
"_objFlags": 0,
"node": null,
"_enabled": true,
"__prefab": null,
"_lineHeight": 40,
"_string": "<color=#00ff00>Rich</color><color=#0fffff>Text</color>",
"_horizontalAlign": 0,
"_fontSize": 40,
"_maxWidth": 0,
"_fontFamily": "Arial",
"_font": null,
"_isSystemFontUsed": true,
"_userDefinedFont": null,
"_cacheMode": 0,
"_imageAtlas": null,
"_handleTouchEvent": true,
};
export class RichText {
static create() {
return JSON.parse(JSON.stringify(RICHTEXT));
}
static async migrate(json2D: any) {
const source = JSON.parse(JSON.stringify(RICHTEXT));
for (let key in json2D) {
const value = json2D[key];
if (key === '__type__' || value === undefined || value === null) {
continue;
}
if (key === 'node') {
source.node = value;
const node = json2D[value.__id__];
if (node && node._color) {
source._color.r = node._color.r;
source._color.g = node._color.g;
source._color.b = node._color.b;
source._color.a = node._color.a;
}
} else if (key === '_materials') {
// for (let i = 0; i < value.length; ++i) {
let material = value[0];
if (material) {
material = {
__uuid__: await ImporterBase.getUuid(material.__uuid__),
};
}
source._customMaterial = material;
// }
} else if (key === '_srcBlendFactor') {
source._srcBlendFactor = getBlendFactor2DTo3D(value);
} else if (key === '_dstBlendFactor') {
source._dstBlendFactor = getBlendFactor2DTo3D(value);
} else {
key = key.replace(/_N\$/, '_');
if (value.__uuid__) {
value.__uuid__ = await ImporterBase.getUuid(value.__uuid__);
}
source[key] = value;
}
}
return source;
}
static async apply(index: number, json2D: any, json3D: any) {
const source = await RichText.migrate(json2D[index]);
json3D.splice(index, 1, source);
return source;
}
}

Some files were not shown because too many files have changed in this diff Show More