Skip to content

Separate each engines' codes to different individual packages#39

Merged
Egliss merged 14 commits into
masterfrom
feature/separate_engines
Jun 13, 2019
Merged

Separate each engines' codes to different individual packages#39
Egliss merged 14 commits into
masterfrom
feature/separate_engines

Conversation

@dolow
Copy link
Copy Markdown
Contributor

@dolow dolow commented Jun 4, 2019

Summary

Separated engine specific codes to different module.

figure: workflow example / CocosCreator to PIXI.js
charts

Added packages

  • scene-graph-pixi/runtime as @drecom/scene-graph-pixi-rt
  • scene-graph-three/runtime as @drecom/scene-graph-three-rt
  • scene-graph-unity/client as @drecom/scene-graph-unity-cli
  • scene-graph-cocos/client as @drecom/scene-graph-cocos-cli

Added CircleCI job for each new package

Removed engine things from scene-graph-mediator-rt,cli

Changed module loading method

Each engine implementation is loaded with require dynamically before this PR.
Ref:

public static getSceneExporterClass(runtimeId: string): SceneExporterConstructor | null {
const id = runtimeId.toLowerCase();
if (RuntimeIdentifiers.COCOS_CREATOR_V1.indexOf(id) !== -1) {
return require('../exporter/scene/CocosCreator').default;
}
if (RuntimeIdentifiers.COCOS_CREATOR_V2.indexOf(id) !== -1) {
return require('../exporter/scene/CocosCreatorV2').default;
}
if (RuntimeIdentifiers.UNITY.indexOf(id) !== -1) {
return require('../exporter/scene/Unity').default;
}
return null;
}

After this, each module registers itself to ExportManager.

ExportManager.registerExporterClass(identifier, sceneExporter, assetExporter);

Because export process is expected to be kicked from some GUI in the future, GUI should know which engine is available ahead of process running.

Files to review

Because there are bunch of artifacts, reviewers need instruction which files should be reviewd.

  • packages/scene-graph-cocos/client/package.json
  • packages/scene-graph-cocos/client/src/*
  • packages/scene-graph-mediator/client/package.json
  • packages/scene-graph-mediator/client/src/*
  • packages/scene-graph-mediator/runtime/package.json
  • packages/scene-graph-mediator/runtime/src/*
  • packages/scene-graph-pixi/runtime/package.json
  • packages/scene-graph-pixi/runtime/src/*
  • packages/scene-graph-three/runtime/package.json
  • packages/scene-graph-three/runtime/src/*
  • packages/scene-graph-unity/client/package.json
  • packages/scene-graph-unity/client/src/*

Test

  • CircleCI (see below)
  • export cocos sample.fire scene
  • export cocos mask_sample.fire
  • import cocos sample.fire scene into pixi runtime w/animation
  • import cocos mask_sample.fire scene into pixi runtime

Todo

  • Rename scene-graph-cocos-animation/runtime to scene-graph-cocos-animation-pixi/runtime.
  • Change npm dependencies with relative path to proper npm package name with version.
    I'm not going to do it in this PR.

}

if (args.listRuntimes) {
const runtimes = ExportManager.getRegisteredExporterRuntimes();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function for debugging became a little new feature.

import * as Zlib from 'runtime/three/Zlib';
import NURBSCurve from 'runtime/three/NURBSCurve';
import TgaLoader from 'runtime/three/loaders/TgaLoader';
import ThreeLoader from '../interface/ThreeLoader';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use THREE, refer ThreeLoader's threeRef static property instead of using imported three module, this is because to share the same three object among scripts.

"keywords": [],
"author": "Drecom Co.,Ltd.",
"devDependencies": {
"@drecom/scene-graph-mediator-cli": "file:../../scene-graph-mediator/client",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update package reference after npm release.


for (const [key, value] of resourceMap.entries()) {
const entity = value;
const it = resourceMap.entries();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed TypeScript transpile error.
Iterator object can not be iterated with for...of.

@dolow dolow requested review from Egliss and zprodev June 5, 2019 06:02
@dolow dolow requested a review from takeshi-sakurai June 11, 2019 07:38
args = parseArgs();
} catch (e) {
console.log(e);
console.log(CliHelptext);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be no opportunity for usage to be displayed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commander shows instruction with --help option.

$ ./bin/cli.js --help

@dolow dolow mentioned this pull request Jun 11, 2019
6 tasks
Copy link
Copy Markdown

@zprodev zprodev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@takeshi-sakurai takeshi-sakurai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@Egliss Egliss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants