child objects don't instantiate parent objects
parent
4832eb5b3d
commit
d717c22c03
12
gulpfile.js
12
gulpfile.js
|
@ -174,9 +174,7 @@ gulp.task('compileEditor', ['merge'],
|
||||||
gulp.task(
|
gulp.task(
|
||||||
'build',
|
'build',
|
||||||
[
|
[
|
||||||
'merge',
|
'merge'
|
||||||
'compileRuntime',
|
|
||||||
'compileEditor'
|
|
||||||
],
|
],
|
||||||
function() {
|
function() {
|
||||||
|
|
||||||
|
@ -187,9 +185,7 @@ gulp.task(
|
||||||
gulp.task(
|
gulp.task(
|
||||||
'default',
|
'default',
|
||||||
[
|
[
|
||||||
'merge',
|
'merge'
|
||||||
'compileRuntime',
|
|
||||||
'compileEditor'
|
|
||||||
],
|
],
|
||||||
function() {
|
function() {
|
||||||
return watch([
|
return watch([
|
||||||
|
@ -197,9 +193,7 @@ gulp.task(
|
||||||
],
|
],
|
||||||
function() {
|
function() {
|
||||||
gulp.start([
|
gulp.start([
|
||||||
'merge',
|
'merge'
|
||||||
'compileRuntime',
|
|
||||||
'compileEditor'
|
|
||||||
]);
|
]);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,14 +55,5 @@ if (typeof _ == 'undefined') {
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//#ifdef RUNTIME__
|
|
||||||
console.log("Loading runtime library...");
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
//#ifdef EDITOR__
|
|
||||||
console.log("Loading editor library...");
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
// This gets injected by gulp
|
// This gets injected by gulp
|
||||||
console.log("GameLib compiled at: " + __DATE__);
|
console.log("Loading GameLib compiled at: " + __DATE__);
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
* This component renders a scene
|
* This component renders a scene
|
||||||
* @param id String
|
* @param id String
|
||||||
* @param name String
|
* @param name String
|
||||||
* @param rendererType
|
|
||||||
* @param autoClear bool
|
* @param autoClear bool
|
||||||
* @param localClipping
|
* @param localClipping
|
||||||
* @param width
|
* @param width
|
||||||
* @param height
|
* @param height
|
||||||
|
* @param domElement
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
* @param preserveDrawingBuffer
|
* @param preserveDrawingBuffer
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -19,13 +19,16 @@ GameLib.D3.API.Renderer = function (
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
preserveDrawingBuffer,
|
preserveDrawingBuffer,
|
||||||
|
domElement,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
GameLib.Component.call(
|
GameLib.Component.call(
|
||||||
this,
|
this,
|
||||||
GameLib.Component.COMPONENT_RENDERER,
|
GameLib.Component.COMPONENT_RENDERER,
|
||||||
null,
|
{
|
||||||
|
'domElement' : GameLib.DomElement
|
||||||
|
},
|
||||||
null,
|
null,
|
||||||
parentEntity
|
parentEntity
|
||||||
);
|
);
|
||||||
|
@ -64,6 +67,11 @@ GameLib.D3.API.Renderer = function (
|
||||||
preserveDrawingBuffer = false;
|
preserveDrawingBuffer = false;
|
||||||
}
|
}
|
||||||
this.preserveDrawingBuffer = preserveDrawingBuffer;
|
this.preserveDrawingBuffer = preserveDrawingBuffer;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(domElement)) {
|
||||||
|
domElement = null;
|
||||||
|
}
|
||||||
|
this.domElement = domElement;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Renderer.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Renderer.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
@ -83,6 +91,7 @@ GameLib.D3.API.Renderer.FromObjectComponent = function(objectComponent) {
|
||||||
objectComponent.width,
|
objectComponent.width,
|
||||||
objectComponent.height,
|
objectComponent.height,
|
||||||
objectComponent.preserveDrawingBuffer,
|
objectComponent.preserveDrawingBuffer,
|
||||||
|
objectComponent.domElement,
|
||||||
objectComponent.parentEntity
|
objectComponent.parentEntity
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -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.meshMoveMode = false;
|
||||||
this.meshMoveXMode = false;
|
this.meshMoveXMode = false;
|
||||||
this.meshMoveYMode = false;
|
this.meshMoveYMode = false;
|
||||||
|
@ -375,7 +396,7 @@ GameLib.D3.Input.Editor.prototype.onMouseMove = function(event) {
|
||||||
|
|
||||||
this.raycaster.instance.setFromCamera(
|
this.raycaster.instance.setFromCamera(
|
||||||
this.mouse,
|
this.mouse,
|
||||||
this.cameras[this.scene.activeCameraIndex].instance
|
this.camera.instance
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.meshMoveMode) {
|
if (this.meshMoveMode) {
|
||||||
|
|
|
@ -25,9 +25,17 @@ GameLib.D3.Renderer = function (
|
||||||
apiRenderer.width,
|
apiRenderer.width,
|
||||||
apiRenderer.height,
|
apiRenderer.height,
|
||||||
apiRenderer.preserveDrawingBuffer,
|
apiRenderer.preserveDrawingBuffer,
|
||||||
|
apiRenderer.domElement,
|
||||||
apiRenderer.parentEntity
|
apiRenderer.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (this.domElement instanceof GameLib.API.DomElement) {
|
||||||
|
this.domElement = new GameLib.DomElement(
|
||||||
|
this.graphics,
|
||||||
|
this.domElement
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
this.instance = this.createInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,7 +44,7 @@ GameLib.D3.Renderer.prototype.constructor = GameLib.D3.Renderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Renderer Instance
|
* Create Renderer Instance
|
||||||
* @param updates
|
* @param update
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Renderer.prototype.createInstance = function(update) {
|
GameLib.D3.Renderer.prototype.createInstance = function(update) {
|
||||||
|
@ -76,6 +84,7 @@ GameLib.D3.Renderer.prototype.toApiComponent = function() {
|
||||||
this.width,
|
this.width,
|
||||||
this.height,
|
this.height,
|
||||||
this.preserveDrawingBuffer,
|
this.preserveDrawingBuffer,
|
||||||
|
this.domElement.toApiDomElement(),
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -67,18 +67,16 @@ GameLib.System.prototype.start = function() {
|
||||||
throw new Error('Cannot start a rendering system without a valid DOM element');
|
throw new Error('Cannot start a rendering system without a valid DOM element');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.domElement.innerHTML = '';
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(this.domStats)) {
|
if (GameLib.Utils.UndefinedOrNull(this.domStats)) {
|
||||||
console.warn('No stats DOM - will run the render process without statistics information');
|
console.warn('No stats DOM - will run the render process without statistics information');
|
||||||
} else {
|
} else {
|
||||||
this.domElement.appendChild(this.domStats);
|
//this.domElement.instance.appendChild(this.domStats.instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.renderers = this.entityManager.query([GameLib.D3.Renderer]);
|
this.renderers = this.entityManager.query([GameLib.D3.Renderer]);
|
||||||
this.renderers.forEach(
|
this.renderers.forEach(
|
||||||
function (renderer) {
|
function (renderer) {
|
||||||
this.domElement.appendChild(renderer.instance.domElement);
|
renderer.domElement.instance.appendChild(renderer.instance.domElement);
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue