no graphics for something

beta.r3js.org
-=yb4f310 2017-05-10 15:56:27 +02:00
parent a32037a826
commit 838ae9e3af
7 changed files with 56 additions and 55 deletions

View File

@ -1,14 +1,14 @@
/** /**
* GameLib Namespace * GameLib Namespace
*/ */
if (typeof GameLib == 'undefined') { if (typeof GameLib === 'undefined') {
function GameLib() {} function GameLib() {}
} }
/** /**
* GameLib.D3 Namespace * GameLib.D3 Namespace
*/ */
if (typeof GameLib.D3 == 'undefined') { if (typeof GameLib.D3 === 'undefined') {
GameLib.D3 = function(){}; GameLib.D3 = function(){};
} }
@ -16,14 +16,14 @@ if (typeof GameLib.D3 == 'undefined') {
* GameLib.D3.API Namespace * GameLib.D3.API Namespace
* @constructor * @constructor
*/ */
if (typeof GameLib.D3.API == 'undefined') { if (typeof GameLib.D3.API === 'undefined') {
GameLib.D3.API = function(){}; GameLib.D3.API = function(){};
} }
/** /**
* GameLib.API Namespace * GameLib.API Namespace
*/ */
if (typeof GameLib.API == 'undefined') { if (typeof GameLib.API === 'undefined') {
GameLib.API = function(){}; GameLib.API = function(){};
} }
@ -31,13 +31,13 @@ if (typeof GameLib.API == 'undefined') {
* GameLib.D3.Runtime Namespace * GameLib.D3.Runtime Namespace
* @constructor * @constructor
*/ */
if (typeof GameLib.D3.Runtime == 'undefined') { if (typeof GameLib.D3.Runtime === 'undefined') {
GameLib.D3.Runtime = function(){}; GameLib.D3.Runtime = function(){};
} }
if (typeof Q == 'undefined') { if (typeof Q === 'undefined') {
if (typeof require == 'undefined') { if (typeof require === 'undefined') {
console.warn('You need the Q promise library for the GameLib.D3'); console.warn('You need the Q promise library for the GameLib.D3');
throw new Error('You need the Q promise library for the GameLib.D3'); throw new Error('You need the Q promise library for the GameLib.D3');
} }
@ -45,9 +45,9 @@ if (typeof Q == 'undefined') {
var Q = require('q'); var Q = require('q');
} }
if (typeof _ == 'undefined') { if (typeof _ === 'undefined') {
if (typeof require == 'undefined') { if (typeof require === 'undefined') {
console.warn('You need the lodash library for the GameLib.D3'); console.warn('You need the lodash library for the GameLib.D3');
throw new Error('You need the lodash library for the GameLib.D3'); throw new Error('You need the lodash library for the GameLib.D3');
} }

View File

@ -18,7 +18,7 @@ GameLib.D3.API.Input.Editor = function (
id, id,
name, name,
domElement, domElement,
domContainer, // domContainer,
editor, editor,
camera, camera,
widthOffset, widthOffset,
@ -53,11 +53,11 @@ GameLib.D3.API.Input.Editor = function (
domElement = null; domElement = null;
} }
this.domElement = domElement; this.domElement = domElement;
//
if (GameLib.Utils.UndefinedOrNull(domContainer)) { // if (GameLib.Utils.UndefinedOrNull(domContainer)) {
domContainer = null; // domContainer = null;
} // }
this.domContainer = domContainer; // this.domContainer = domContainer;
if (GameLib.Utils.UndefinedOrNull(editor)) { if (GameLib.Utils.UndefinedOrNull(editor)) {
editor = null; editor = null;
@ -109,7 +109,7 @@ GameLib.D3.API.Input.Editor.FromObjectComponent = function(objectComponent) {
objectComponent.id, objectComponent.id,
objectComponent.name, objectComponent.name,
objectComponent.domElement, objectComponent.domElement,
objectComponent.domContainer, // objectComponent.domContainer,
objectComponent.editor, objectComponent.editor,
objectComponent.camera, objectComponent.camera,
objectComponent.widthOffset, objectComponent.widthOffset,

View File

@ -2,6 +2,7 @@
* Raw Scene API object - should always correspond with the Scene Schema * Raw Scene API object - should always correspond with the Scene Schema
* @param id String * @param id String
* @param name String * @param name String
* @param imageFactory [GameLib.D3.API.ImageFactory]
* @param meshes [GameLib.D3.API.Mesh] * @param meshes [GameLib.D3.API.Mesh]
* @param position GameLib.API.Vector3 * @param position GameLib.API.Vector3
* @param quaternion GameLib.API.Quaternion * @param quaternion GameLib.API.Quaternion

View File

@ -2,13 +2,11 @@
* Input parent class * Input parent class
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.D3.Graphics
* @param apiInputEditor GameLib.D3.API.Input.Editor * @param apiInputEditor GameLib.D3.API.Input.Editor
* @param dom GameLib.DOM
* @constructor * @constructor
*/ */
GameLib.D3.Input.Editor = function ( GameLib.D3.Input.Editor = function (
graphics, graphics,
apiInputEditor, apiInputEditor
dom
) { ) {
this.graphics = graphics; this.graphics = graphics;
@ -23,7 +21,7 @@ GameLib.D3.Input.Editor = function (
apiInputEditor.id, apiInputEditor.id,
apiInputEditor.name, apiInputEditor.name,
apiInputEditor.domElement, apiInputEditor.domElement,
apiInputEditor.domContainer, // apiInputEditor.domContainer,
apiInputEditor.editor, apiInputEditor.editor,
apiInputEditor.camera, apiInputEditor.camera,
apiInputEditor.widthOffset, apiInputEditor.widthOffset,
@ -34,26 +32,24 @@ GameLib.D3.Input.Editor = function (
apiInputEditor.parentEntity apiInputEditor.parentEntity
); );
if (GameLib.Utils.UndefinedOrNull(dom)) { // if (GameLib.Utils.UndefinedOrNull(dom)) {
console.warn('Cannot create window resize event without handle to the DOM'); // console.warn('Cannot create window resize event without handle to the DOM');
dom = null; // dom = null;
// throw new Error('Cannot create Input without an handle to the DOM'); // // throw new Error('Cannot create Input without an handle to the DOM');
} // }
this.dom = dom; // this.dom = dom;
if (this.domElement instanceof GameLib.API.DomElement) { if (this.domElement instanceof GameLib.API.DomElement) {
this.domElement = new GameLib.DomElement( this.domElement = new GameLib.DomElement(
this.graphics,
this.domElement this.domElement
) )
} }
if (this.domContainer instanceof GameLib.API.DomElement) { // if (this.domContainer instanceof GameLib.API.DomElement) {
this.domContainer = new GameLib.DomElement( // this.domContainer = new GameLib.DomElement(
this.graphics, // this.domContainer
this.domContainer // )
) // }
}
/** /**
* Cannot create a new Editor object here - it will cause an infinite loop * Cannot create a new Editor object here - it will cause an infinite loop
@ -171,7 +167,7 @@ GameLib.D3.Input.Editor.prototype.toApiComponent = function() {
this.id, this.id,
this.name, this.name,
this.domElementId, this.domElementId,
this.domContainerId, // this.domContainerId,
GameLib.Utils.IdOrNull(this.editor), GameLib.Utils.IdOrNull(this.editor),
GameLib.Utils.IdOrNull(this.camera), GameLib.Utils.IdOrNull(this.camera),
this.widthOffset, this.widthOffset,
@ -196,9 +192,9 @@ GameLib.D3.Input.Editor.FromObjectComponent = function(graphics, objectComponent
}; };
GameLib.D3.Input.Editor.prototype.onWindowResize = function() { GameLib.D3.Input.Editor.prototype.onWindowResize = function() {
//
this.domContainer.instance.style.height = (this.window.innerHeight - this.containerHeightOffset) + 'px'; // this.domContainer.instance.style.height = (this.window.innerHeight - this.containerHeightOffset) + 'px';
this.domContainer.instance.style.width = (this.window.innerWidth - this.containerWidthOffset) + 'px'; // this.domContainer.instance.style.width = (this.window.innerWidth - this.containerWidthOffset) + 'px';
var width = this.window.innerWidth - this.widthOffset; var width = this.window.innerWidth - this.widthOffset;

View File

@ -31,7 +31,6 @@ GameLib.D3.Renderer = function (
if (this.domElement instanceof GameLib.API.DomElement) { if (this.domElement instanceof GameLib.API.DomElement) {
this.domElement = new GameLib.DomElement( this.domElement = new GameLib.DomElement(
this.graphics,
this.domElement this.domElement
); );
} }

View File

@ -1,13 +1,9 @@
/** /**
* Runtime domElement for updating instance objects * Runtime domElement for updating instance objects
* @param graphics GameLib.D3.Graphics
* @param apiDomElement GameLib.API.DomElement * @param apiDomElement GameLib.API.DomElement
* @constructor * @constructor
*/ */
GameLib.DomElement = function (graphics, apiDomElement) { GameLib.DomElement = function (apiDomElement) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
GameLib.API.DomElement.call( GameLib.API.DomElement.call(
this, this,
@ -29,7 +25,16 @@ GameLib.DomElement.prototype.constructor = GameLib.DomElement;
* @returns {*} * @returns {*}
*/ */
GameLib.DomElement.prototype.createInstance = function(update) { GameLib.DomElement.prototype.createInstance = function(update) {
return document.getElementById(this.domElementId);
var instance = null;
if (update) {
instance = this.instance;
} else {
instance = document.getElementById(this.domElementId);
}
return instance;
}; };
/** /**

View File

@ -36,7 +36,6 @@ GameLib.System = function(
if (this.domElement instanceof GameLib.API.DomElement) { if (this.domElement instanceof GameLib.API.DomElement) {
this.domElement = new GameLib.DomElement( this.domElement = new GameLib.DomElement(
this.graphics,
this.domElement this.domElement
); );
} }
@ -56,11 +55,11 @@ GameLib.System.SYSTEM_TYPE_ALL = 0x7;
*/ */
GameLib.System.prototype.start = function() { GameLib.System.prototype.start = function() {
if (this.systemType == GameLib.System.SYSTEM_TYPE_INPUT) { if (this.systemType === GameLib.System.SYSTEM_TYPE_INPUT) {
this.driveInputObjects = this.entityManager.query([GameLib.D3.Input.Drive]); this.driveInputObjects = this.entityManager.query([GameLib.D3.Input.Drive]);
} }
if (this.systemType == GameLib.System.SYSTEM_TYPE_RENDER) { if (this.systemType === GameLib.System.SYSTEM_TYPE_RENDER) {
if (GameLib.Utils.UndefinedOrNull(this.domElement)) { if (GameLib.Utils.UndefinedOrNull(this.domElement)) {
console.warn('Cannot start a rendering system without a valid DOM element'); console.warn('Cannot start a rendering system without a valid DOM element');
@ -83,7 +82,7 @@ GameLib.System.prototype.start = function() {
this.viewports = this.entityManager.query([GameLib.D3.Viewport]); this.viewports = this.entityManager.query([GameLib.D3.Viewport]);
} }
if (this.systemType == GameLib.System.SYSTEM_TYPE_ANIMATION) { if (this.systemType === GameLib.System.SYSTEM_TYPE_ANIMATION) {
this.pathFollowingObjects = this.entityManager.query([GameLib.D3.PathFollowing]); this.pathFollowingObjects = this.entityManager.query([GameLib.D3.PathFollowing]);
this.followObjects = this.entityManager.query([GameLib.D3.Follow]); this.followObjects = this.entityManager.query([GameLib.D3.Follow]);
this.meshObjects = this.entityManager.query([GameLib.D3.Mesh]); this.meshObjects = this.entityManager.query([GameLib.D3.Mesh]);
@ -100,7 +99,7 @@ GameLib.System.prototype.start = function() {
*/ */
GameLib.System.prototype.update = function(deltaTime) { GameLib.System.prototype.update = function(deltaTime) {
if (this.systemType == GameLib.System.SYSTEM_TYPE_INPUT) { if (this.systemType === GameLib.System.SYSTEM_TYPE_INPUT) {
this.driveInputObjects.forEach( this.driveInputObjects.forEach(
function(object) { function(object) {
object.update(deltaTime); object.update(deltaTime);
@ -108,7 +107,8 @@ GameLib.System.prototype.update = function(deltaTime) {
); );
} }
if (this.systemType == GameLib.System.SYSTEM_TYPE_ANIMATION) { if (this.systemType === GameLib.System.SYSTEM_TYPE_ANIMATION) {
this.pathFollowingObjects.forEach( this.pathFollowingObjects.forEach(
function(object) { function(object) {
object.update(deltaTime); object.update(deltaTime);
@ -146,7 +146,7 @@ GameLib.System.prototype.update = function(deltaTime) {
); );
} }
if (this.systemType == GameLib.System.SYSTEM_TYPE_RENDER) { if (this.systemType === GameLib.System.SYSTEM_TYPE_RENDER) {
this.viewports.forEach( this.viewports.forEach(
function (viewport) { function (viewport) {
viewport.update(deltaTime); viewport.update(deltaTime);
@ -162,17 +162,17 @@ GameLib.System.prototype.update = function(deltaTime) {
*/ */
GameLib.System.prototype.stop = function() { GameLib.System.prototype.stop = function() {
if (this.systemType == GameLib.System.SYSTEM_TYPE_INPUT) { if (this.systemType === GameLib.System.SYSTEM_TYPE_INPUT) {
this.driveInputObjects = []; this.driveInputObjects = [];
} }
if (this.systemType == GameLib.System.SYSTEM_TYPE_RENDER) { if (this.systemType === GameLib.System.SYSTEM_TYPE_RENDER) {
this.domElement.innerHTML = 'Rendering System Stopped'; this.domElement.innerHTML = 'Rendering System Stopped';
this.renderers = []; this.renderers = [];
this.viewports = []; this.viewports = [];
} }
if (this.systemType == GameLib.System.SYSTEM_TYPE_ANIMATION) { if (this.systemType === GameLib.System.SYSTEM_TYPE_ANIMATION) {
this.pathFollowingObjects = []; this.pathFollowingObjects = [];
this.followObjects = []; this.followObjects = [];
this.meshObjects = []; this.meshObjects = [];
@ -185,7 +185,7 @@ GameLib.System.prototype.stop = function() {
/** /**
* Converts runtime vector to API Vector * Converts runtime vector to API Vector
* @returns {GameLib.API.Mouse} * @returns {GameLib.API.System}
*/ */
GameLib.System.prototype.toApiSystem = function() { GameLib.System.prototype.toApiSystem = function() {