child objects don't instantiate parent objects

beta.r3js.org
Theunis J. Botha 2017-03-30 17:31:01 +02:00
parent 4832eb5b3d
commit d717c22c03
6 changed files with 49 additions and 27 deletions

View File

@ -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'
]);
})
}

View File

@ -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__);

View File

@ -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
);
};

View File

@ -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) {

View File

@ -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)
);

View File

@ -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)
);