First commit
This commit is contained in:
94
engine/viewport.js
Executable file
94
engine/viewport.js
Executable file
@@ -0,0 +1,94 @@
|
||||
|
||||
import renderSystem from './renderSystem.js';
|
||||
import player from './player.js';
|
||||
import eventManager from './eventManager.js';
|
||||
import camera from './camera.js';
|
||||
import scene from './scene.js';
|
||||
import quad from './quad.js';
|
||||
import primitives from './primitives.js';
|
||||
import sampler2D from './sampler2D.js';
|
||||
import linePrimitives from './linePrimitives.js';
|
||||
|
||||
|
||||
/**
|
||||
* viewport
|
||||
**/
|
||||
class viewport{
|
||||
|
||||
constructor( selector ){
|
||||
|
||||
this.width; // width of canvas
|
||||
this.height; // height of canvas
|
||||
|
||||
this.selector = selector; // Dom selector
|
||||
this.gl; // gl context
|
||||
|
||||
if(selector)
|
||||
this.setup();
|
||||
|
||||
}
|
||||
|
||||
setSelector(selector) {
|
||||
|
||||
this.selector = selector;
|
||||
|
||||
|
||||
}
|
||||
|
||||
setup() {
|
||||
|
||||
|
||||
this.system = new renderSystem();
|
||||
this.scene = new scene();
|
||||
|
||||
this.system.setViewport( this );
|
||||
this.system.setGraphicsLibrary("WebGL_1.0");
|
||||
|
||||
this.canvas = document.getElementById( this.selector );
|
||||
|
||||
this.gl = this.system.initializeWebgl( this.canvas );
|
||||
|
||||
this.width = this.canvas.width;
|
||||
this.height = this.canvas.height;
|
||||
|
||||
|
||||
|
||||
// Viewport dependend objects
|
||||
this.mainPlayer = new player();
|
||||
this.events = new eventManager( this );
|
||||
this.mainCamera = new camera();
|
||||
this.scene = new scene();
|
||||
this.quad = new quad();
|
||||
this.primitives = new primitives();
|
||||
this.linePrimitives = new linePrimitives();
|
||||
|
||||
this.linePrimitives.setViewport( this );
|
||||
this.primitives.setViewport( this );
|
||||
this.quad.setViewport( this );
|
||||
this.mainPlayer.setViewport( this );
|
||||
this.mainCamera.setViewport( this );
|
||||
|
||||
|
||||
|
||||
//this.system.createRenderPasses2();
|
||||
//createRenderPasses2
|
||||
//this.events.setViewport( this );
|
||||
}
|
||||
|
||||
addScene( scene ){
|
||||
|
||||
this.scene = scene;
|
||||
|
||||
}
|
||||
|
||||
render(){
|
||||
|
||||
this.mainPlayer.update();
|
||||
this.mainCamera.update();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export {viewport as default};
|
||||
Reference in New Issue
Block a user