comp / ent refactor

beta.r3js.org
Theunis J. Botha 2016-11-29 11:26:16 +01:00
parent 50a3abf1ae
commit daf6624854
3 changed files with 20 additions and 18 deletions

View File

@ -132,9 +132,9 @@ GameLib.D3.Entity.prototype.register = function(
parentScene parentScene
) { ) {
// this.parentScene = parentScene; // this.parentScene = parentScene;
//
// if (this.id != null && parentScene.meshIdToMesh[this.id]) { // if (this.mesh && this.mesh.id != null && parentScene.meshIdToMesh[this.mesh.id]) {
// parentScene.instance.add(parentScene.meshIdToMesh[this.id]); // parentScene.instance.add(parentScene.meshIdToMesh[this.mesh.id]);
// this.mesh = parentScene.meshIdToMesh[this.id]; // this.mesh = parentScene.meshIdToMesh[this.id];
// } // }

View File

@ -97,58 +97,58 @@ GameLib.D3.Scene.API = function(
name = 'unnamed'; name = 'unnamed';
} }
this.name = name; this.name = name;
if (typeof meshes == 'undefined') { if (GameLib.D3.Utils.UndefinedOrNull(meshes)) {
meshes = []; meshes = [];
} }
this.meshes = meshes; this.meshes = meshes;
if (typeof quaternion == 'undefined') { if (GameLib.D3.Utils.UndefinedOrNull(quaternion)) {
quaternion = new GameLib.D3.Vector4(); quaternion = new GameLib.D3.Vector4();
} }
this.quaternion = quaternion; this.quaternion = quaternion;
if (typeof position == 'undefined') { if (GameLib.D3.Utils.UndefinedOrNull(position)) {
position = new GameLib.D3.Vector3(0,0,0); position = new GameLib.D3.Vector3();
} }
this.position = position; this.position = position;
if (typeof rotation == 'undefined') { if (GameLib.D3.Utils.UndefinedOrNull(rotation)) {
rotation = new GameLib.D3.Vector3(0,0,0); rotation = new GameLib.D3.Vector3();
} }
this.rotation = rotation; this.rotation = rotation;
if (typeof scale == 'undefined') { if (GameLib.D3.Utils.UndefinedOrNull(scale)) {
scale = new GameLib.D3.Vector3(1,1,1); scale = new GameLib.D3.Vector3(1,1,1);
} }
this.scale = scale; this.scale = scale;
if (typeof parentSceneId == 'undefined') { if (GameLib.D3.Utils.UndefinedOrNull(parentSceneId)) {
parentSceneId = null; parentSceneId = null;
} }
this.parentSceneId = parentSceneId; this.parentSceneId = parentSceneId;
if (typeof lights == 'undefined') { if (GameLib.D3.Utils.UndefinedOrNull(lights)) {
lights = []; lights = [];
} }
this.lights = lights; this.lights = lights;
if (typeof worlds == 'undefined') { if (GameLib.D3.Utils.UndefinedOrNull(worlds)) {
worlds = []; worlds = [];
} }
this.worlds = worlds; this.worlds = worlds;
if (typeof entities == 'undefined') { if (GameLib.D3.Utils.UndefinedOrNull(entities)) {
entities = []; entities = [];
} }
this.entities = entities; this.entities = entities;
if (typeof components == 'undefined') { if (GameLib.D3.Utils.UndefinedOrNull(components)) {
components = []; components = [];
} }
this.components = components; this.components = components;
if (typeof shapes == 'undefined') { if (GameLib.D3.Utils.UndefinedOrNull(shapes)) {
shapes = []; shapes = [];
} }
this.shapes = shapes; this.shapes = shapes;

View File

@ -19,6 +19,8 @@ GameLib.D3.Vector3.Runtime = function RuntimeVector3(graphics, parentObject, api
} }
} }
GameLib.D3.Utils.Extend(GameLib.D3.Vector3.Runtime, GameLib.D3.Vector3);
this.apiVector = apiVector; this.apiVector = apiVector;
this.graphics = graphics; this.graphics = graphics;
@ -33,7 +35,7 @@ GameLib.D3.Vector3.Runtime = function RuntimeVector3(graphics, parentObject, api
}; };
GameLib.D3.Vector3.Runtime.prototype.createInstance = function() { GameLib.D3.Vector3.Runtime.prototype.createInstance = function() {
return this.graphics.instance.Vector3(this.x, this.y, this.z); return new this.graphics.instance.Vector3(this.x, this.y, this.z);
}; };
GameLib.D3.Vector3.Runtime.prototype.updateInstance = function() { GameLib.D3.Vector3.Runtime.prototype.updateInstance = function() {