diff --git a/gulpfile.js b/gulpfile.js index 1597985..d89ff57 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -174,9 +174,7 @@ gulp.task('compileEditor', ['merge'], gulp.task( 'build', [ - 'merge', - 'compileRuntime', - 'compileEditor' + 'merge' ], function() { @@ -187,9 +185,7 @@ gulp.task( gulp.task( 'default', [ - 'merge', - 'compileRuntime', - 'compileEditor' + 'merge' ], function() { return watch([ @@ -197,9 +193,7 @@ gulp.task( ], function() { gulp.start([ - 'merge', - 'compileRuntime', - 'compileEditor' + 'merge' ]); }) } diff --git a/src/game-lib-a-0.js b/src/game-lib-a-0.js index 0635880..3bba1dc 100644 --- a/src/game-lib-a-0.js +++ b/src/game-lib-a-0.js @@ -55,14 +55,5 @@ if (typeof _ == 'undefined') { var _ = require('lodash'); } - -//#ifdef RUNTIME__ -console.log("Loading runtime library..."); -//#endif - -//#ifdef EDITOR__ -console.log("Loading editor library..."); -//#endif - // This gets injected by gulp -console.log("GameLib compiled at: " + __DATE__); +console.log("Loading GameLib compiled at: " + __DATE__); diff --git a/src/game-lib-d3-api-renderer.js b/src/game-lib-d3-api-renderer.js index 276b203..a79c0ff 100644 --- a/src/game-lib-d3-api-renderer.js +++ b/src/game-lib-d3-api-renderer.js @@ -2,11 +2,11 @@ * This component renders a scene * @param id String * @param name String - * @param rendererType * @param autoClear bool * @param localClipping * @param width * @param height + * @param domElement * @param parentEntity * @param preserveDrawingBuffer * @constructor @@ -19,13 +19,16 @@ GameLib.D3.API.Renderer = function ( width, height, preserveDrawingBuffer, + domElement, parentEntity ) { GameLib.Component.call( this, GameLib.Component.COMPONENT_RENDERER, - null, + { + 'domElement' : GameLib.DomElement + }, null, parentEntity ); @@ -64,6 +67,11 @@ GameLib.D3.API.Renderer = function ( preserveDrawingBuffer = false; } this.preserveDrawingBuffer = preserveDrawingBuffer; + + if (GameLib.Utils.UndefinedOrNull(domElement)) { + domElement = null; + } + this.domElement = domElement; }; GameLib.D3.API.Renderer.prototype = Object.create(GameLib.Component.prototype); @@ -83,6 +91,7 @@ GameLib.D3.API.Renderer.FromObjectComponent = function(objectComponent) { objectComponent.width, objectComponent.height, objectComponent.preserveDrawingBuffer, + objectComponent.domElement, objectComponent.parentEntity ); }; diff --git a/src/game-lib-d3-input-editor.js b/src/game-lib-d3-input-editor.js index 0212245..18ac8b3 100644 --- a/src/game-lib-d3-input-editor.js +++ b/src/game-lib-d3-input-editor.js @@ -55,6 +55,27 @@ GameLib.D3.Input.Editor = function ( ) } + /** + * Cannot create a new Editor object here - it will cause an infinite loop + * + * Parent runtime objects can create their child runtime objects - but child runtime objects should not + * create their parent runtime objects. + * + if (this.editor instanceof GameLib.D3.API.Editor) { + this.editor = new GameLib.D3.Editor( + this.graphics, + this.editor + ) + } + */ + + if (this.camera instanceof GameLib.D3.API.Camera) { + this.camera = new GameLib.D3.Camera( + this.graphics, + this.camera + ) + } + this.meshMoveMode = false; this.meshMoveXMode = false; this.meshMoveYMode = false; @@ -375,7 +396,7 @@ GameLib.D3.Input.Editor.prototype.onMouseMove = function(event) { this.raycaster.instance.setFromCamera( this.mouse, - this.cameras[this.scene.activeCameraIndex].instance + this.camera.instance ); if (this.meshMoveMode) { diff --git a/src/game-lib-d3-renderer.js b/src/game-lib-d3-renderer.js index b2996ca..6e32083 100644 --- a/src/game-lib-d3-renderer.js +++ b/src/game-lib-d3-renderer.js @@ -25,9 +25,17 @@ GameLib.D3.Renderer = function ( apiRenderer.width, apiRenderer.height, apiRenderer.preserveDrawingBuffer, + apiRenderer.domElement, apiRenderer.parentEntity ); + if (this.domElement instanceof GameLib.API.DomElement) { + this.domElement = new GameLib.DomElement( + this.graphics, + this.domElement + ); + } + this.instance = this.createInstance(); }; @@ -36,7 +44,7 @@ GameLib.D3.Renderer.prototype.constructor = GameLib.D3.Renderer; /** * Create Renderer Instance - * @param updates + * @param update * @returns {*} */ GameLib.D3.Renderer.prototype.createInstance = function(update) { @@ -76,6 +84,7 @@ GameLib.D3.Renderer.prototype.toApiComponent = function() { this.width, this.height, this.preserveDrawingBuffer, + this.domElement.toApiDomElement(), GameLib.Utils.IdOrNull(this.parentEntity) ); diff --git a/src/game-lib-system.js b/src/game-lib-system.js index e360576..d9682b3 100644 --- a/src/game-lib-system.js +++ b/src/game-lib-system.js @@ -67,18 +67,16 @@ GameLib.System.prototype.start = function() { throw new Error('Cannot start a rendering system without a valid DOM element'); } - this.domElement.innerHTML = ''; - if (GameLib.Utils.UndefinedOrNull(this.domStats)) { console.warn('No stats DOM - will run the render process without statistics information'); } else { - this.domElement.appendChild(this.domStats); + //this.domElement.instance.appendChild(this.domStats.instance); } this.renderers = this.entityManager.query([GameLib.D3.Renderer]); this.renderers.forEach( function (renderer) { - this.domElement.appendChild(renderer.instance.domElement); + renderer.domElement.instance.appendChild(renderer.instance.domElement); }.bind(this) );