beta.r3js.org
-=yb4f310 2017-06-16 20:03:55 +02:00
parent 49eafef601
commit 68a8eef4bb
9 changed files with 69 additions and 38 deletions

View File

@ -57,13 +57,24 @@ GameLib.Component.prototype.getDependencies = function() {
var dependencies = [];
for (var property in this.linkedObjects) {
//TODO array linked objects
if (this.linkedObjects.hasOwnProperty(property)){
if (
this.hasOwnProperty(property) &&
typeof this[property] === 'string'
) {
dependencies.push(this[property]);
if (this.hasOwnProperty(property)) {
if (typeof this[property] === 'string') {
dependencies.push(this[property]);
}
if (this[property] instanceof Array) {
this[property].map(function(arrayProperty){
if (typeof arrayProperty === 'string') {
dependencies.push(arrayProperty);
}
});
}
}
}
}
@ -88,7 +99,7 @@ GameLib.Component.COMPONENT_COMPOSER = 0xb;
GameLib.Component.COMPONENT_RENDER_TARGET = 0xc;
GameLib.Component.COMPONENT_PASS = 0xd;
GameLib.Component.COMPONENT_SCENE = 0xe;
GameLib.Component.COMPONENT_GAME = 0xf;
GameLib.Component.COMPONENT_RAYCASTER = 0xf;
GameLib.Component.COMPONENT_INPUT_EDITOR = 0x10;
GameLib.Component.COMPONENT_EDITOR = 0x11;
GameLib.Component.COMPONENT_VIEWPORT = 0x12;
@ -129,7 +140,7 @@ GameLib.Component.GetComponentName = function(number) {
case 0xc : return 'GameLib.D3.RenderTarget';
case 0xd : return 'GameLib.D3.Pass';
case 0xe : return 'GameLib.D3.Scene';
case 0xf : return 'GameLib.D3.Game';
case 0xf : return 'GameLib.D3.Raycaster';
case 0x10 : return 'GameLib.D3.InputEditor';
case 0x11 : return 'GameLib.D3.Editor';
case 0x12 : return 'GameLib.D3.Viewport';

View File

@ -16,14 +16,6 @@ GameLib.D3.API.Image = function(
size,
parentEntity
) {
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_IMAGE,
null,
parentEntity
);
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
@ -57,10 +49,15 @@ GameLib.D3.API.Image = function(
}
this.contentType = contentType;
if (GameLib.Utils.UndefinedOrNull(size)) {
size = 0;
}
this.size = size;
if (GameLib.Utils.UndefinedOrNull(size)) {
size = 0;
}
this.size = size;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
};
GameLib.D3.API.Image.prototype = Object.create(GameLib.Component.prototype);

View File

@ -34,6 +34,9 @@ GameLib.D3.API.Raycaster = function(
this.direction = direction;
};
GameLib.D3.API.Raycaster.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Raycaster.prototype.constructor = GameLib.D3.API.Raycaster;
/**
* Returns an API raycaster from an Object raycaster
* @param objectRaycaster

View File

@ -5,6 +5,7 @@
* @param name
* @param object
* @param helperType
* @param parentEntity
* @constructor
*/
GameLib.D3.Helper = function(
@ -12,16 +13,12 @@ GameLib.D3.Helper = function(
id,
name,
object,
helperType
helperType,
parentEntity
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_HELPER
);
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
@ -69,7 +66,15 @@ GameLib.D3.Helper = function(
}
this.helperType = helperType;
this.instance = this.createInstance();
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_HELPER
);
};
GameLib.D3.Helper.prototype = Object.create(GameLib.Component.prototype);
@ -98,12 +103,12 @@ GameLib.D3.Helper.prototype.createInstance = function(update) {
return null;
}
var instance = null;
if (update) {
instance = this.instance;
return;
}
var instance = null;
if (this.helperType === GameLib.D3.Helper.HELPER_TYPE_EDGES) {
instance = new THREE.EdgesHelper(this.object.instance, 0x00FF00);
}
@ -135,5 +140,5 @@ GameLib.D3.Helper.prototype.createInstance = function(update) {
* Updates the instance with the current state
*/
GameLib.D3.Helper.prototype.updateInstance = function() {
this.instance = this.createInstance(true);
this.createInstance(true);
};

View File

@ -26,7 +26,10 @@ GameLib.D3.Image = function(
apiImage.parentEntity
);
this.instance = this.createInstance();
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_IMAGE
);
};
GameLib.D3.Image.prototype = Object.create(GameLib.D3.API.Image.prototype);

View File

@ -239,8 +239,6 @@ GameLib.D3.Material = function(
'specularMap' : GameLib.D3.Texture
}
);
this.updateTextures();
};
GameLib.D3.Material.prototype = Object.create(GameLib.D3.API.Material.prototype);
@ -919,6 +917,10 @@ GameLib.D3.Material.prototype.createInstance = function(update) {
}
);
this.instance = instance;
this.updateTextures();
return instance;
}

View File

@ -40,7 +40,10 @@ GameLib.D3.Raycaster = function(
this
);
this.instance = this.createInstance();
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_RAYCASTER
);
};
GameLib.D3.Raycaster.prototype = Object.create(GameLib.D3.API.Raycaster.prototype);

View File

@ -325,9 +325,14 @@ GameLib.D3.Scene.prototype.addObject = function(object) {
object.parentScene = this;
this.instance.add(object.instance);
if (this.instance) {
this.instance.add(object.instance);
}
this.buildIdToObject();
// this.instance.add(object.instance);
//
// this.buildIdToObject();
};
/**
@ -353,11 +358,13 @@ GameLib.D3.Scene.prototype.removeObject = function(object) {
return;
}
this.instance.remove(object.instance);
if (this.instance) {
this.instance.remove(object.instance);
}
if (object.parentScene === this) {
object.parentScene = null;
}
this.buildIdToObject();
// this.buildIdToObject();
};