more checks
parent
bb0a861d35
commit
49eafef601
|
@ -20,13 +20,6 @@ GameLib.API.Mouse = function(
|
||||||
}
|
}
|
||||||
this.parentEntity = parentEntity;
|
this.parentEntity = parentEntity;
|
||||||
|
|
||||||
GameLib.Component.call(
|
|
||||||
this,
|
|
||||||
GameLib.Component.COMPONENT_MOUSE,
|
|
||||||
null,
|
|
||||||
parentEntity
|
|
||||||
);
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,11 @@ GameLib.D3.Coder.CODER_TYPE_CODE_MIRROR = 0x1;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Coder.prototype.createInstance = function(update) {
|
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;
|
var instance = null;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
|
|
|
@ -93,6 +93,11 @@ GameLib.D3.Helper.HELPER_TYPE_SKELETON = 0x6;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Helper.prototype.createInstance = function(update) {
|
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;
|
var instance = null;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
|
|
|
@ -38,6 +38,11 @@ GameLib.D3.Image.prototype.constructor = GameLib.D3.Image;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Image.prototype.createInstance = function(update) {
|
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) {
|
if (update) {
|
||||||
console.log('why the fuck are you updating an image instance?');
|
console.log('why the fuck are you updating an image instance?');
|
||||||
if (!this.instance) {
|
if (!this.instance) {
|
||||||
|
|
|
@ -102,6 +102,11 @@ GameLib.D3.Light.LIGHT_TYPE_SPOT = 0x4;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Light.prototype.createInstance = function(update) {
|
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) {
|
if (update) {
|
||||||
|
|
||||||
var oldInstance = null;
|
var oldInstance = null;
|
||||||
|
|
|
@ -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.constructor = GameLib.D3.LookAt;
|
||||||
|
|
||||||
GameLib.D3.LookAt.prototype.createInstance = function() {
|
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() {
|
GameLib.D3.LookAt.prototype.toApiObject = function() {
|
||||||
|
|
|
@ -702,6 +702,11 @@ GameLib.D3.Material.prototype.updateMeshBasicMaterialInstance = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Material.prototype.createInstance = function(update) {
|
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) {
|
if (update) {
|
||||||
|
|
||||||
var typeChange = false;
|
var typeChange = false;
|
||||||
|
|
|
@ -279,6 +279,11 @@ GameLib.D3.Mesh.prototype.customGeometry = function(){
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Mesh.prototype.createInstance = function(update) {
|
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 (update) {
|
||||||
|
|
||||||
if (this.parentMesh && this.parentMesh.loaded) {
|
if (this.parentMesh && this.parentMesh.loaded) {
|
||||||
|
|
|
@ -54,13 +54,18 @@ GameLib.D3.Pass.PASS_TYPE_COPY_SHADER = 0x2;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Pass.prototype.createInstance = function(update) {
|
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;
|
var instance = null;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
instance = this.instance;
|
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 (this.scene && this.camera) {
|
||||||
if (!THREE.RenderPass) {
|
if (!THREE.RenderPass) {
|
||||||
|
|
|
@ -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.constructor = GameLib.D3.PathFollowing;
|
||||||
|
|
||||||
GameLib.D3.PathFollowing.prototype.createInstance = function() {
|
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() {
|
GameLib.D3.PathFollowing.prototype.toApiObject = function() {
|
||||||
|
|
|
@ -52,24 +52,34 @@ GameLib.D3.Raycaster.prototype.constructor = GameLib.D3.Raycaster;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Raycaster.prototype.createInstance = function(update) {
|
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) {
|
if (update) {
|
||||||
instance = this.instance;
|
|
||||||
|
this.instance.set(
|
||||||
|
this.position.instance,
|
||||||
|
this.direction.instance
|
||||||
|
);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
instance = new THREE.Raycaster();
|
var instance = new THREE.Raycaster();
|
||||||
}
|
|
||||||
|
|
||||||
instance.set(
|
instance.set(
|
||||||
this.position.instance,
|
this.position.instance,
|
||||||
this.direction.instance
|
this.direction.instance
|
||||||
);
|
);
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Raycaster.prototype.updateInstance = function() {
|
GameLib.D3.Raycaster.prototype.updateInstance = function() {
|
||||||
this.instance = this.createInstance(true);
|
this.createInstance(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Raycaster.prototype.toApiObject = function() {
|
GameLib.D3.Raycaster.prototype.toApiObject = function() {
|
||||||
|
|
|
@ -60,6 +60,11 @@ GameLib.D3.RenderTarget.RGBA_FORMAT = 1023;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.RenderTarget.prototype.createInstance = function(update) {
|
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;
|
var instance = null;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
|
|
|
@ -66,43 +66,70 @@ GameLib.D3.Renderer.prototype.constructor = GameLib.D3.Renderer;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Renderer.prototype.createInstance = function(update) {
|
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) {
|
if (update) {
|
||||||
instance = this.instance;
|
|
||||||
} else {
|
this.instance.localClippingEnabled = this.localClipping;
|
||||||
instance = new THREE.WebGLRenderer({
|
|
||||||
|
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
|
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() {
|
GameLib.D3.Renderer.prototype.updateInstance = function() {
|
||||||
this.instance = this.createInstance(true);
|
this.createInstance(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Renderer.prototype.toApiObject = function() {
|
GameLib.D3.Renderer.prototype.toApiObject = function() {
|
||||||
|
|
|
@ -193,6 +193,11 @@ GameLib.D3.Scene.prototype.constructor = GameLib.D3.Scene;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Scene.prototype.createInstance = function() {
|
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();
|
var instance = new THREE.Scene();
|
||||||
|
|
||||||
instance.name = this.name;
|
instance.name = this.name;
|
||||||
|
|
|
@ -102,6 +102,11 @@ GameLib.D3.Skeleton.prototype.constructor = GameLib.D3.Skeleton;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Skeleton.prototype.createInstance = function(update) {
|
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;
|
var instance = null;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
|
|
|
@ -52,6 +52,11 @@ GameLib.D3.Spline.prototype.constructor = GameLib.D3.Spline;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Spline.prototype.createInstance = function(update) {
|
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) {
|
if (update) {
|
||||||
return this.instance;
|
return this.instance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,11 @@ GameLib.D3.Stats.prototype.resize = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Stats.prototype.createInstance = function(update) {
|
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;
|
var instance = null;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
|
|
|
@ -170,6 +170,11 @@ GameLib.D3.Texture.TEXTURE_TYPE_CUBE = 0x2;
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Texture.prototype.createInstance = function(update) {
|
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 (update) {
|
||||||
|
|
||||||
if (!this.instance) {
|
if (!this.instance) {
|
||||||
|
|
|
@ -52,7 +52,12 @@ GameLib.D3.Viewport.prototype.constructor = GameLib.D3.Viewport;
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Viewport.prototype.createInstance = function(update) {
|
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;
|
var instance = null;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
|
|
|
@ -33,15 +33,18 @@ GameLib.DomElement.prototype.constructor = GameLib.DomElement;
|
||||||
*/
|
*/
|
||||||
GameLib.DomElement.prototype.createInstance = function(update) {
|
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) {
|
if (update) {
|
||||||
instance = this.instance;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
instance = document.getElementById(this.domElementId);
|
var instance = document.getElementById(this.domElementId);
|
||||||
}
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
return instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
}
|
}
|
||||||
|
@ -85,7 +75,18 @@ GameLib.GUI = function(
|
||||||
}
|
}
|
||||||
this.objects = objects;
|
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);
|
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
|
* Updates the instance with the current state
|
||||||
*/
|
*/
|
||||||
GameLib.GUI.prototype.updateInstance = function() {
|
GameLib.GUI.prototype.updateInstance = function() {
|
||||||
this.instance = this.createInstance(true);
|
this.createInstance(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.GUI.prototype.addObject = function(object) {
|
GameLib.GUI.prototype.addObject = function(object) {
|
||||||
|
|
|
@ -26,7 +26,10 @@ GameLib.Mouse = function (graphics, apiMouse) {
|
||||||
apiMouse.parentEntity
|
apiMouse.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
this.instance = this.createInstance();
|
GameLib.Component.call(
|
||||||
|
this,
|
||||||
|
GameLib.Component.COMPONENT_MOUSE
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.Mouse.prototype = Object.create(GameLib.API.Mouse.prototype);
|
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) {
|
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;
|
var instance = null;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
|
|
Loading…
Reference in New Issue