mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
rename scene-manager to render-scene
This commit is contained in:
+17
-17
@@ -3,7 +3,7 @@ import { GFXDevice } from "../gfx/device";
|
||||
import { RenderView, RenderViewInfo, RenderViewPriority } from "../pipeline/render-view";
|
||||
import { RenderPipeline } from "../pipeline/render-pipeline";
|
||||
import { ForwardPipeline } from "../pipeline/forward/forward-pipeline";
|
||||
import { SceneManager, SceneManagerInfo } from "../scene/scene-manager";
|
||||
import { RenderScene, RenderSceneInfo } from "../renderer/scene/render-scene";
|
||||
|
||||
export interface RootInfo {
|
||||
};
|
||||
@@ -38,7 +38,7 @@ export class Root {
|
||||
|
||||
public destroy() {
|
||||
this.destroyViews();
|
||||
this.destroySceneManagers();
|
||||
this.destroyScenes();
|
||||
|
||||
if (this._pipeline) {
|
||||
this._pipeline.destroy();
|
||||
@@ -87,31 +87,31 @@ export class Root {
|
||||
this._windows = [];
|
||||
}
|
||||
|
||||
public createSceneManager(info: SceneManagerInfo): SceneManager | null {
|
||||
let scene = new SceneManager;
|
||||
public createScene(info: RenderSceneInfo): RenderScene | null {
|
||||
let scene = new RenderScene;
|
||||
if(scene.initialize(info)) {
|
||||
this._sceneMgrs.push(scene);
|
||||
this._scenes.push(scene);
|
||||
return scene;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public destroySceneManager(sceneMgr: SceneManager) {
|
||||
for (let i = 0; i < this._sceneMgrs.length; ++i) {
|
||||
if (this._sceneMgrs[i] === sceneMgr) {
|
||||
sceneMgr.destroy();
|
||||
this._sceneMgrs.splice(i);
|
||||
public destroyScene(scene: RenderScene) {
|
||||
for (let i = 0; i < this._scenes.length; ++i) {
|
||||
if (this._scenes[i] === scene) {
|
||||
scene.destroy();
|
||||
this._scenes.splice(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public destroySceneManagers() {
|
||||
for (let i = 0; i < this._sceneMgrs.length; ++i) {
|
||||
this._sceneMgrs[i].destroy();
|
||||
public destroyScenes() {
|
||||
for (let i = 0; i < this._scenes.length; ++i) {
|
||||
this._scenes[i].destroy();
|
||||
}
|
||||
this._sceneMgrs = [];
|
||||
this._scenes = [];
|
||||
}
|
||||
|
||||
public createView(info: RenderViewInfo): RenderView | null {
|
||||
@@ -155,8 +155,8 @@ export class Root {
|
||||
return this._pipeline;
|
||||
}
|
||||
|
||||
public get sceneManagers(): SceneManager[] {
|
||||
return this._sceneMgrs;
|
||||
public get sceneManagers(): RenderScene[] {
|
||||
return this._scenes;
|
||||
}
|
||||
|
||||
public get views(): RenderView[] {
|
||||
@@ -167,6 +167,6 @@ export class Root {
|
||||
private _windows: GFXWindow[] = [];
|
||||
private _mainWindow: GFXWindow | null = null;
|
||||
private _pipeline: RenderPipeline | null = null;
|
||||
private _sceneMgrs: SceneManager[] = [];
|
||||
private _scenes: RenderScene[] = [];
|
||||
private _views: RenderView[] = [];
|
||||
};
|
||||
|
||||
@@ -18,9 +18,9 @@ export default class Camera {
|
||||
/**
|
||||
* Setup a default perspective camera
|
||||
*/
|
||||
constructor(sceneMgr, name) {
|
||||
constructor(scene, name) {
|
||||
|
||||
this._sceneMgr = sceneMgr;
|
||||
this._scene = scene;
|
||||
this._name = name;
|
||||
|
||||
this._poolID = -1;
|
||||
@@ -55,8 +55,8 @@ export default class Camera {
|
||||
this._orthoHeight = 10;
|
||||
}
|
||||
|
||||
get sceneMgr() {
|
||||
return this._sceneMgr;
|
||||
get scene() {
|
||||
return this._scene;
|
||||
}
|
||||
|
||||
get name() {
|
||||
|
||||
@@ -51,9 +51,9 @@ export default class Light {
|
||||
/**
|
||||
* Setup a default directional light with no shadows
|
||||
*/
|
||||
constructor(sceneMgr, name) {
|
||||
constructor(scene, name) {
|
||||
|
||||
this._sceneMgr = sceneMgr;
|
||||
this._scene = scene;
|
||||
this._name = name;
|
||||
|
||||
this._poolID = -1;
|
||||
@@ -94,8 +94,8 @@ export default class Light {
|
||||
this._shadowFrustumSize = 50; // used for directional light.
|
||||
}
|
||||
|
||||
get sceneMgr() {
|
||||
return this._sceneMgr;
|
||||
get scene() {
|
||||
return this._scene;
|
||||
}
|
||||
|
||||
get name() {
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
import Node from "../scene-graph/node";
|
||||
import Camera from "../renderer/scene/camera";
|
||||
import Light from "../renderer/scene/light";
|
||||
import Node from "../../scene-graph/node";
|
||||
import Camera from "./camera";
|
||||
import Light from "./light";
|
||||
|
||||
export interface SceneManagerInfo {
|
||||
export interface RenderSceneInfo {
|
||||
name: string;
|
||||
};
|
||||
|
||||
export interface SceneNodeInfo {
|
||||
name: string;
|
||||
isStatic: boolean;
|
||||
isStatic?: boolean;
|
||||
//parent: Node;
|
||||
}
|
||||
|
||||
export class SceneManager {
|
||||
export class RenderScene {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
public initialize(info: SceneManagerInfo): boolean {
|
||||
public initialize(info: RenderSceneInfo): boolean {
|
||||
this._name = info.name;
|
||||
|
||||
let cameraNode = this.createNode({ name: "mainCamNode", isStatic: false });
|
||||
this._mainCamera = this.createCamera("mainCamera");
|
||||
this._mainCamera.setNode(cameraNode);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -69,6 +73,7 @@ export class SceneManager {
|
||||
|
||||
public destroyCameras() {
|
||||
this._cameras = [];
|
||||
this._mainCamera = null;
|
||||
}
|
||||
|
||||
public getCamera(name: string): Camera | null {
|
||||
@@ -124,8 +129,9 @@ export class SceneManager {
|
||||
return this._lights;
|
||||
}
|
||||
|
||||
protected _name: string = "";
|
||||
protected _nodes: Map<number, Node> = new Map;
|
||||
protected _cameras: Camera[] = [];
|
||||
protected _lights: Light[] = [];
|
||||
private _name: string = "";
|
||||
private _nodes: Map<number, Node> = new Map;
|
||||
private _cameras: Camera[] = [];
|
||||
private _mainCamera: Camera | null = null;
|
||||
private _lights: Light[] = [];
|
||||
};
|
||||
Reference in New Issue
Block a user