Commit ac856bdf authored by rockyl's avatar rockyl

修改CameraController方便UI适配

parent 8148721c
{ {
"name": "scilla-core", "name": "scilla-core",
"version": "1.0.0", "version": "1.0.0",
"main": "./dist/bundle.js", "main": "./dist/index.js",
"types": "./types/index.d.ts", "types": "./types/index.d.ts",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
......
...@@ -25,6 +25,6 @@ export default { ...@@ -25,6 +25,6 @@ export default {
useTsconfigDeclarationDir: true, useTsconfigDeclarationDir: true,
}), }),
commonjs(), commonjs(),
uglify({}), //uglify({}),
] ]
}; };
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Created by rockyl on 2018-12-04. * Created by rockyl on 2018-12-04.
*/ */
import {destroyScene, setupScene, } from "./interpreter"; import {cleanEntity, setupScene, } from "./interpreter";
import {addLoader, cacheRes, destroyRes, getAllResUuids, loadJson5} from "../assets-manager"; import {addLoader, cacheRes, destroyRes, getAllResUuids, loadJson5} from "../assets-manager";
import {getRoot, pause, Scene, start} from "../core"; import {getRoot, pause, Scene, start} from "../core";
...@@ -49,7 +49,7 @@ export function mountScene(scene){ ...@@ -49,7 +49,7 @@ export function mountScene(scene){
*/ */
export function unmountScene(scene){ export function unmountScene(scene){
pause(); pause();
destroyScene(scene); cleanEntity(scene.root);
destroyRes(resUUIDs); destroyRes(resUUIDs);
} }
......
...@@ -38,13 +38,12 @@ export function setupScene(scene: Scene, root: Entity): Scene { ...@@ -38,13 +38,12 @@ export function setupScene(scene: Scene, root: Entity): Scene {
} }
/** /**
* 销毁场景 * 清空实体
* @param scene * @param entity
*/ */
export function destroyScene(scene: Scene) { export function cleanEntity(entity: Entity) {
const root = scene.root; entity.removeAllComponents();
root.removeAllComponents(); entity.removeChildren();
root.removeChildren();
} }
/** /**
...@@ -187,12 +186,17 @@ function injectComponents(entity: Entity, config: any, pid?) { ...@@ -187,12 +186,17 @@ function injectComponents(entity: Entity, config: any, pid?) {
const components = entity.components; const components = entity.components;
for (let i = 0, li = config.components.length; i < li; i++) { for (let i = 0, li = config.components.length; i < li; i++) {
const component = config.components[i]; const component = config.components[i];
const {properties} = component;
if (properties) { injectComponentProperties(components[i], component, pid);
injectProperties(components[i], properties, pid);
} }
} }
}
export function injectComponentProperties(component, config, pid?){
const {properties} = config;
if (properties) {
injectProperties(component, properties, pid);
} }
} }
...@@ -201,8 +205,8 @@ function injectComponents(entity: Entity, config: any, pid?) { ...@@ -201,8 +205,8 @@ function injectComponents(entity: Entity, config: any, pid?) {
* @param entity * @param entity
* @param config * @param config
*/ */
function instantiateComponent(entity: Entity, config: any) { export function instantiateComponent(entity: Entity, config: any) {
const {script, properties} = config; const {script, } = config;
let def = getDefByName(script); let def = getDefByName(script);
...@@ -214,6 +218,7 @@ function instantiateComponent(entity: Entity, config: any) { ...@@ -214,6 +218,7 @@ function instantiateComponent(entity: Entity, config: any) {
entity.addComponent(instance); entity.addComponent(instance);
return instance;
} }
/** /**
......
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"outDir": "dist",
"experimentalDecorators": true, "experimentalDecorators": true,
"sourceMap": true, "sourceMap": true,
"declarationDir": "./types", "declarationDir": "types",
"declaration": true, "declaration": true,
"lib": [ "lib": [
"es5", "es5",
...@@ -13,7 +14,6 @@ ...@@ -13,7 +14,6 @@
] ]
}, },
"include": [ "include": [
"src", "src"
"libs"
] ]
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment