more checks

beta.r3js.org
-=yb4f310 2017-06-16 18:45:25 +02:00
parent bb0a861d35
commit 49eafef601
22 changed files with 189 additions and 66 deletions

View File

@ -20,13 +20,6 @@ GameLib.API.Mouse = function(
}
this.parentEntity = parentEntity;
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_MOUSE,
null,
parentEntity
);
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}

View File

@ -39,6 +39,11 @@ GameLib.D3.Coder.CODER_TYPE_CODE_MIRROR = 0x1;
*/
GameLib.D3.Coder.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
var instance = null;
if (update) {

View File

@ -93,6 +93,11 @@ GameLib.D3.Helper.HELPER_TYPE_SKELETON = 0x6;
*/
GameLib.D3.Helper.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
var instance = null;
if (update) {

View File

@ -38,6 +38,11 @@ GameLib.D3.Image.prototype.constructor = GameLib.D3.Image;
*/
GameLib.D3.Image.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
if (update) {
console.log('why the fuck are you updating an image instance?');
if (!this.instance) {

View File

@ -102,6 +102,11 @@ GameLib.D3.Light.LIGHT_TYPE_SPOT = 0x4;
*/
GameLib.D3.Light.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
if (update) {
var oldInstance = null;

View File

@ -74,7 +74,11 @@ GameLib.D3.LookAt.prototype = Object.create(GameLib.D3.API.LookAt.prototype);
GameLib.D3.LookAt.prototype.constructor = GameLib.D3.LookAt;
GameLib.D3.LookAt.prototype.createInstance = function() {
console.log('LookAt.createInstance()');
console.log('GameLib.D3.LookAt.prototype.createInstance()');
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
};
GameLib.D3.LookAt.prototype.toApiObject = function() {

View File

@ -702,6 +702,11 @@ GameLib.D3.Material.prototype.updateMeshBasicMaterialInstance = function() {
*/
GameLib.D3.Material.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
if (update) {
var typeChange = false;

View File

@ -279,6 +279,11 @@ GameLib.D3.Mesh.prototype.customGeometry = function(){
*/
GameLib.D3.Mesh.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
if (update) {
if (this.parentMesh && this.parentMesh.loaded) {

View File

@ -54,13 +54,18 @@ GameLib.D3.Pass.PASS_TYPE_COPY_SHADER = 0x2;
*/
GameLib.D3.Pass.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
var instance = null;
if (update) {
instance = this.instance;
}
if (this.passType == GameLib.D3.Pass.PASS_TYPE_RENDER) {
if (this.passType === GameLib.D3.Pass.PASS_TYPE_RENDER) {
if (this.scene && this.camera) {
if (!THREE.RenderPass) {

View File

@ -124,7 +124,14 @@ GameLib.D3.PathFollowing.prototype = Object.create(GameLib.D3.API.PathFollowing.
GameLib.D3.PathFollowing.prototype.constructor = GameLib.D3.PathFollowing;
GameLib.D3.PathFollowing.prototype.createInstance = function() {
console.log('GameLib.D3.PathFollowing.prototype.createInstance()');
console.log('GameLib.D3.PathFollowing.prototype.createInstance()');
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
};
GameLib.D3.PathFollowing.prototype.toApiObject = function() {

View File

@ -52,24 +52,34 @@ GameLib.D3.Raycaster.prototype.constructor = GameLib.D3.Raycaster;
*/
GameLib.D3.Raycaster.prototype.createInstance = function(update) {
var instance = null;
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
if (update) {
instance = this.instance;
this.instance.set(
this.position.instance,
this.direction.instance
);
return null;
} else {
instance = new THREE.Raycaster();
}
var instance = new THREE.Raycaster();
instance.set(
this.position.instance,
this.direction.instance
);
instance.set(
this.position.instance,
this.direction.instance
);
return instance;
return instance;
}
};
GameLib.D3.Raycaster.prototype.updateInstance = function() {
this.instance = this.createInstance(true);
this.createInstance(true);
};
GameLib.D3.Raycaster.prototype.toApiObject = function() {

View File

@ -60,6 +60,11 @@ GameLib.D3.RenderTarget.RGBA_FORMAT = 1023;
*/
GameLib.D3.RenderTarget.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
var instance = null;
if (update) {

View File

@ -66,43 +66,70 @@ GameLib.D3.Renderer.prototype.constructor = GameLib.D3.Renderer;
*/
GameLib.D3.Renderer.prototype.createInstance = function(update) {
var instance = null;
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
if (update) {
instance = this.instance;
} else {
instance = new THREE.WebGLRenderer({
this.instance.localClippingEnabled = this.localClipping;
this.instance.setSize(
this.width,
this.height
);
this.instance.setClearColor(
new THREE.Color(
this.clearColor.r,
this.clearColor.g,
this.clearColor.b
),
1 - this.clearColor.a
);
this.instance.domElement.width = this.width;
this.instance.domElement.height = this.height;
this.instance.autoClear = this.autoClear;
this.instance.preserveDrawingBuffer = this.preserveDrawingBuffer;
} else {
var instance = new THREE.WebGLRenderer({
canvas : this.domElement.instance
});
instance.localClippingEnabled = this.localClipping;
instance.setSize(
this.width,
this.height
);
instance.setClearColor(
new THREE.Color(
this.clearColor.r,
this.clearColor.g,
this.clearColor.b
),
1 - this.clearColor.a
);
instance.domElement.width = this.width;
instance.domElement.height = this.height;
instance.autoClear = this.autoClear;
instance.preserveDrawingBuffer = this.preserveDrawingBuffer;
return instance;
}
instance.localClippingEnabled = this.localClipping;
instance.setSize(
this.width,
this.height
);
instance.setClearColor(
new THREE.Color(
this.clearColor.r,
this.clearColor.g,
this.clearColor.b
),
1 - this.clearColor.a
);
instance.domElement.width = this.width;
instance.domElement.height = this.height;
instance.autoClear = this.autoClear;
instance.preserveDrawingBuffer = this.preserveDrawingBuffer;
return instance;
};
GameLib.D3.Renderer.prototype.updateInstance = function() {
this.instance = this.createInstance(true);
this.createInstance(true);
};
GameLib.D3.Renderer.prototype.toApiObject = function() {

View File

@ -193,6 +193,11 @@ GameLib.D3.Scene.prototype.constructor = GameLib.D3.Scene;
*/
GameLib.D3.Scene.prototype.createInstance = function() {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
var instance = new THREE.Scene();
instance.name = this.name;

View File

@ -102,6 +102,11 @@ GameLib.D3.Skeleton.prototype.constructor = GameLib.D3.Skeleton;
*/
GameLib.D3.Skeleton.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
var instance = null;
if (update) {

View File

@ -52,6 +52,11 @@ GameLib.D3.Spline.prototype.constructor = GameLib.D3.Spline;
*/
GameLib.D3.Spline.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
if (update) {
return this.instance;
}

View File

@ -62,6 +62,11 @@ GameLib.D3.Stats.prototype.resize = function() {
*/
GameLib.D3.Stats.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
var instance = null;
if (update) {

View File

@ -170,6 +170,11 @@ GameLib.D3.Texture.TEXTURE_TYPE_CUBE = 0x2;
*/
GameLib.D3.Texture.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
if (update) {
if (!this.instance) {

View File

@ -52,7 +52,12 @@ GameLib.D3.Viewport.prototype.constructor = GameLib.D3.Viewport;
* @returns {*}
*/
GameLib.D3.Viewport.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
var instance = null;
if (update) {

View File

@ -33,15 +33,18 @@ GameLib.DomElement.prototype.constructor = GameLib.DomElement;
*/
GameLib.DomElement.prototype.createInstance = function(update) {
var instance = null;
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
if (update) {
instance = this.instance;
return null;
} else {
instance = document.getElementById(this.domElementId);
}
var instance = document.getElementById(this.domElementId);
return instance;
}
return instance;
};
/**

View File

@ -54,16 +54,6 @@ GameLib.GUI = function(
}
};
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_GUI,
{
'domElement': GameLib.DomElement
},
null,
parentEntity
);
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
@ -85,7 +75,18 @@ GameLib.GUI = function(
}
this.objects = objects;
this.instance = this.createInstance();
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_GUI,
{
'domElement': GameLib.DomElement
}
);
};
GameLib.GUI.prototype = Object.create(GameLib.Component.prototype);
@ -119,7 +120,7 @@ GameLib.GUI.prototype.createInstance = function(update) {
* Updates the instance with the current state
*/
GameLib.GUI.prototype.updateInstance = function() {
this.instance = this.createInstance(true);
this.createInstance(true);
};
GameLib.GUI.prototype.addObject = function(object) {

View File

@ -26,7 +26,10 @@ GameLib.Mouse = function (graphics, apiMouse) {
apiMouse.parentEntity
);
this.instance = this.createInstance();
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_MOUSE
);
};
GameLib.Mouse.prototype = Object.create(GameLib.API.Mouse.prototype);
@ -39,6 +42,11 @@ GameLib.Mouse.prototype.constructor = GameLib.Mouse;
*/
GameLib.Mouse.prototype.createInstance = function(update) {
if (!this.loaded) {
console.log('Attempted to create an instance but the runtime object is not fully loaded : ' + this.name);
return null;
}
var instance = null;
if (update) {