smart object creation - image factory override

beta.r3js.org
-=yb4f310 2017-05-11 04:48:02 +02:00
parent 838ae9e3af
commit 4d828ee849
42 changed files with 219 additions and 44 deletions

View File

@ -20,6 +20,10 @@ GameLib.Color = function (
apiColor = {}; apiColor = {};
} }
if (apiColor instanceof GameLib.Color) {
return apiColor;
}
GameLib.API.Color.call( GameLib.API.Color.call(
this, this,
apiColor.r, apiColor.r,

View File

@ -529,51 +529,51 @@ GameLib.D3.API.Material.FromObjectMaterial = function(objectMaterial) {
var apiSpecularMap = null; var apiSpecularMap = null;
if (objectMaterial.alphaMap) { if (objectMaterial.alphaMap) {
apiAlphaMap = objectMaterial.alphaMap; apiAlphaMap = GameLib.D3.API.Texture.FromObjectTexture(objectMaterial.alphaMap);
} }
if (objectMaterial.aoMap) { if (objectMaterial.aoMap) {
apiAoMap = objectMaterial.aoMap; apiAoMap = GameLib.D3.API.Texture.FromObjectTexture(objectMaterial.aoMap);
} }
if (objectMaterial.bumpMap) { if (objectMaterial.bumpMap) {
apiBumpMap = objectMaterial.bumpMap; apiBumpMap = GameLib.D3.API.Texture.FromObjectTexture(objectMaterial.bumpMap);
} }
if (objectMaterial.diffuseMap) { if (objectMaterial.diffuseMap) {
apiDiffuseMap = objectMaterial.diffuseMap; apiDiffuseMap = GameLib.D3.API.Texture.FromObjectTexture(objectMaterial.diffuseMap);
} }
if (objectMaterial.displacementMap) { if (objectMaterial.displacementMap) {
apiDisplacementMap = objectMaterial.displacementMap; apiDisplacementMap = GameLib.D3.API.Texture.FromObjectTexture(objectMaterial.displacementMap);
} }
if (objectMaterial.emissiveMap) { if (objectMaterial.emissiveMap) {
apiEmissiveMap = objectMaterial.emissiveMap; apiEmissiveMap = GameLib.D3.API.Texture.FromObjectTexture(objectMaterial.emissiveMap);
} }
if (objectMaterial.environmentMap) { if (objectMaterial.environmentMap) {
apiEnvironmentMap = objectMaterial.environmentMap; apiEnvironmentMap = GameLib.D3.API.Texture.FromObjectTexture(objectMaterial.environmentMap);
} }
if (objectMaterial.lightMap) { if (objectMaterial.lightMap) {
apiLightMap = objectMaterial.lightMap; apiLightMap = GameLib.D3.API.Texture.FromObjectTexture(objectMaterial.lightMap);
} }
if (objectMaterial.metalnessMap) { if (objectMaterial.metalnessMap) {
apiMetalnessMap = objectMaterial.metalnessMap; apiMetalnessMap = GameLib.D3.API.Texture.FromObjectTexture(objectMaterial.metalnessMap);
} }
if (objectMaterial.normalMap) { if (objectMaterial.normalMap) {
apiNormalMap = objectMaterial.normalMap; apiNormalMap = GameLib.D3.API.Texture.FromObjectTexture(objectMaterial.normalMap);
} }
if (objectMaterial.roughnessMap) { if (objectMaterial.roughnessMap) {
apiRoughnessMap = objectMaterial.roughnessMap; apiRoughnessMap = GameLib.D3.API.Texture.FromObjectTexture(objectMaterial.roughnessMap);
} }
if (objectMaterial.specularMap) { if (objectMaterial.specularMap) {
apiSpecularMap = objectMaterial.specularMap; apiSpecularMap = GameLib.D3.API.Texture.FromObjectTexture(objectMaterial.specularMap);
} }
return new GameLib.D3.API.Material( return new GameLib.D3.API.Material(

View File

@ -106,9 +106,10 @@ GameLib.D3.API.Scene.prototype.constructor = GameLib.D3.API.Scene;
/** /**
* Returns an API scene from an Object scene * Returns an API scene from an Object scene
* @param objectScene * @param objectScene
* @param imageFactory GameLib.D3.ImageFactory
* @constructor * @constructor
*/ */
GameLib.D3.API.Scene.FromObjectScene = function(objectScene) { GameLib.D3.API.Scene.FromObjectScene = function(objectScene, imageFactory) {
var apiImageFactory = null; var apiImageFactory = null;
var apiMeshes = []; var apiMeshes = [];
@ -120,7 +121,12 @@ GameLib.D3.API.Scene.FromObjectScene = function(objectScene) {
var apiQuaternion = new GameLib.API.Quaternion(); var apiQuaternion = new GameLib.API.Quaternion();
var apiScale = new GameLib.API.Vector3(1,1,1); var apiScale = new GameLib.API.Vector3(1,1,1);
if (objectScene.imageFactory) { /**
* Passed in ImageFactory overrides API image factory
*/
if (imageFactory) {
apiImageFactory = imageFactory;
} else if (objectScene.imageFactory) {
apiImageFactory = GameLib.D3.API.ImageFactory.FromObjectImageFactory(objectScene.imageFactory); apiImageFactory = GameLib.D3.API.ImageFactory.FromObjectImageFactory(objectScene.imageFactory);
} }

View File

@ -167,6 +167,9 @@ GameLib.D3.API.Texture = function(
this.encoding = encoding; this.encoding = encoding;
}; };
GameLib.D3.API.Texture.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Texture.prototype.constructor = GameLib.D3.API.Texture;
/** /**
* Creates an API texture from Object data * Creates an API texture from Object data
* @param objectTexture * @param objectTexture

View File

@ -15,6 +15,10 @@ GameLib.D3.BoneWeight = function (
apiBoneWeight = {}; apiBoneWeight = {};
} }
if (apiBoneWeight instanceof GameLib.D3.BoneWeight) {
return apiBoneWeight;
}
GameLib.D3.API.BoneWeight.call( GameLib.D3.API.BoneWeight.call(
this, this,
apiBoneWeight.boneIndex, apiBoneWeight.boneIndex,

View File

@ -15,6 +15,10 @@ GameLib.D3.Bone = function (
apiBone = {}; apiBone = {};
} }
if (apiBone instanceof GameLib.D3.Bone) {
return apiBone;
}
GameLib.D3.API.Bone.call( GameLib.D3.API.Bone.call(
this, this,
apiBone.id, apiBone.id,

View File

@ -16,6 +16,10 @@ GameLib.D3.Camera = function(
apiCamera = {}; apiCamera = {};
} }
if (apiCamera instanceof GameLib.D3.Camera) {
return apiCamera;
}
GameLib.D3.API.Camera.call( GameLib.D3.API.Camera.call(
this, this,
apiCamera.id, apiCamera.id,

View File

@ -13,9 +13,13 @@ GameLib.D3.Composer = function (
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiComposer)) { if (GameLib.Utils.UndefinedOrNull(apiComposer)) {
apiComposer = {}; apiComposer = {};
} }
if (apiComposer instanceof GameLib.D3.Composer) {
return apiComposer;
}
GameLib.D3.API.Composer.call( GameLib.D3.API.Composer.call(
this, this,
apiComposer.id, apiComposer.id,

View File

@ -11,6 +11,10 @@ GameLib.D3.CustomCode = function(
apiCustomCode = {}; apiCustomCode = {};
} }
if (apiCustomCode instanceof GameLib.D3.CustomCode) {
return apiCustomCode;
}
GameLib.D3.API.CustomCode.call( GameLib.D3.API.CustomCode.call(
this, this,
apiCustomCode.id, apiCustomCode.id,

View File

@ -22,6 +22,10 @@ GameLib.D3.Editor = function(
apiEditor = {}; apiEditor = {};
} }
if (apiEditor instanceof GameLib.D3.Editor) {
return apiEditor;
}
GameLib.D3.API.Editor.call( GameLib.D3.API.Editor.call(
this, this,
apiEditor.id, apiEditor.id,
@ -471,3 +475,24 @@ GameLib.D3.Editor.prototype.setSize = function(width, height) {
} }
); );
}; };
/**
* Adds a scene to the Editor
* @param scene GameLib.D3.API.Scene
*/
GameLib.D3.Editor.prototype.addScene = function(scene) {
if (scene instanceof GameLib.D3.Scene) {
this.scenes.push(scene);
this.buildIdToObject();
return;
}
if (scene instanceof GameLib.D3.API.Scene) {
scene = new GameLib.D3.Scene(this.graphics, scene);
this.scenes.push(scene);
this.buildIdToObject();
}
throw new Error('Unhandled scene type : ' + scene);
};

View File

@ -15,6 +15,10 @@ GameLib.D3.Follow = function (
apiFollow = {}; apiFollow = {};
} }
if (apiFollow instanceof GameLib.D3.Follow) {
return apiFollow;
}
GameLib.D3.API.Follow.call( GameLib.D3.API.Follow.call(
this, this,
apiFollow.id, apiFollow.id,

View File

@ -16,6 +16,10 @@ GameLib.D3.Game = function (
apiGame = {}; apiGame = {};
} }
if (apiGame instanceof GameLib.D3.Game) {
return apiGame;
}
GameLib.D3.API.Game.call( GameLib.D3.API.Game.call(
this, this,
apiGame.id, apiGame.id,

View File

@ -1,9 +1,9 @@
/** /**
* The image factory takes care that we only make requests for Image URLs which we have not already started downloading * The image factory takes care that we only make requests for Image URLs which we have not already started downloading
* @param graphics GameLib.D3.Graphics * @param graphics
* @param apiImageFactory GameLib.D3.API.ImageFactory * @param apiImageFactory
* @param progressCallback * @param progressCallback
* @returns {Function} * @returns {GameLib.D3.ImageFactory}
* @constructor * @constructor
*/ */
GameLib.D3.ImageFactory = function ( GameLib.D3.ImageFactory = function (
@ -18,6 +18,10 @@ GameLib.D3.ImageFactory = function (
apiImageFactory = {}; apiImageFactory = {};
} }
if (apiImageFactory instanceof GameLib.D3.ImageFactory) {
return apiImageFactory;
}
if (GameLib.Utils.UndefinedOrNull(progressCallback)) { if (GameLib.Utils.UndefinedOrNull(progressCallback)) {
progressCallback = null; progressCallback = null;
} }

View File

@ -21,12 +21,12 @@ GameLib.D3.Image = function(
this.filename = filename; this.filename = filename;
if (typeof size == 'undefined') { if (GameLib.Utils.UndefinedOrNull(size)) {
size = 0; size = 0;
} }
this.size = size; this.size = size;
if (typeof contentType == 'undefined') { if (GameLib.Utils.UndefinedOrNull(contentType)) {
contentType = 'application/octet-stream'; contentType = 'application/octet-stream';

View File

@ -18,6 +18,10 @@ GameLib.D3.Input.Drive = function (
apiInputDrive = {}; apiInputDrive = {};
} }
if (apiInputDrive instanceof GameLib.D3.Drive) {
return apiInputDrive;
}
GameLib.D3.API.Input.Drive.call( GameLib.D3.API.Input.Drive.call(
this, this,
apiInputDrive.id, apiInputDrive.id,

View File

@ -16,6 +16,10 @@ GameLib.D3.Input.Editor = function (
apiInputEditor = {}; apiInputEditor = {};
} }
if (apiInputEditor instanceof GameLib.D3.Input.Editor) {
return apiInputEditor;
}
GameLib.D3.API.Input.Editor.call( GameLib.D3.API.Input.Editor.call(
this, this,
apiInputEditor.id, apiInputEditor.id,

View File

@ -15,6 +15,10 @@ GameLib.D3.Light = function Light(
apiLight = {}; apiLight = {};
} }
if (apiLight instanceof GameLib.D3.Light) {
return apiLight;
}
GameLib.D3.API.Light.call( GameLib.D3.API.Light.call(
this, this,
apiLight.id, apiLight.id,
@ -96,8 +100,8 @@ GameLib.D3.Light.prototype.createInstance = function(update) {
if (!instance) { if (!instance) {
if ( if (
this.lightType == GameLib.D3.Light.LIGHT_TYPE_AMBIENT || this.lightType === GameLib.D3.Light.LIGHT_TYPE_AMBIENT ||
this.lightType == 'AmbientLight' this.lightType === 'AmbientLight'
) { ) {
instance = new THREE.AmbientLight( instance = new THREE.AmbientLight(
this.color.instance, this.color.instance,
@ -106,8 +110,8 @@ GameLib.D3.Light.prototype.createInstance = function(update) {
} }
if ( if (
this.lightType == GameLib.D3.Light.LIGHT_TYPE_DIRECTIONAL || this.lightType === GameLib.D3.Light.LIGHT_TYPE_DIRECTIONAL ||
this.lightType == 'DirectionalLight' this.lightType === 'DirectionalLight'
) { ) {
instance = new THREE.DirectionalLight( instance = new THREE.DirectionalLight(
this.color.instance, this.color.instance,
@ -116,8 +120,8 @@ GameLib.D3.Light.prototype.createInstance = function(update) {
} }
if ( if (
this.lightType == GameLib.D3.Light.LIGHT_TYPE_POINT || this.lightType === GameLib.D3.Light.LIGHT_TYPE_POINT ||
this.lightType == 'PointLight' this.lightType === 'PointLight'
) { ) {
instance = new THREE.PointLight( instance = new THREE.PointLight(
this.color.instance, this.color.instance,
@ -128,8 +132,8 @@ GameLib.D3.Light.prototype.createInstance = function(update) {
} }
if ( if (
this.lightType == GameLib.D3.Light.LIGHT_TYPE_SPOT || this.lightType === GameLib.D3.Light.LIGHT_TYPE_SPOT ||
this.lightType == 'SpotLight' this.lightType === 'SpotLight'
) { ) {
instance = new THREE.SpotLight( instance = new THREE.SpotLight(
this.color.instance, this.color.instance,

View File

@ -15,6 +15,10 @@ GameLib.D3.LookAt = function (
apiLookAt = {}; apiLookAt = {};
} }
if (apiLookAt instanceof GameLib.D3.LookAt) {
return apiLookAt;
}
GameLib.D3.API.LookAt.call( GameLib.D3.API.LookAt.call(
this, this,
apiLookAt.id, apiLookAt.id,

View File

@ -7,7 +7,7 @@
* @constructor * @constructor
* @returns {GameLib.D3.Material | GameLib.D3.API.Material} * @returns {GameLib.D3.Material | GameLib.D3.API.Material}
*/ */
GameLib.D3.Material = function Material( GameLib.D3.Material = function(
graphics, graphics,
apiMaterial, apiMaterial,
imageFactory imageFactory
@ -20,6 +20,10 @@ GameLib.D3.Material = function Material(
apiMaterial = {}; apiMaterial = {};
} }
if (apiMaterial instanceof GameLib.D3.Material) {
return apiMaterial;
}
if (GameLib.Utils.UndefinedOrNull(imageFactory)) { if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
console.warn('Cannot create a Material fully without specifying an ImageFactory'); console.warn('Cannot create a Material fully without specifying an ImageFactory');
imageFactory = null; imageFactory = null;

View File

@ -19,6 +19,10 @@ GameLib.D3.Mesh = function (
apiMesh = {}; apiMesh = {};
} }
if (apiMesh instanceof GameLib.D3.Mesh) {
return apiMesh;
}
if (GameLib.Utils.UndefinedOrNull(computeNormals)) { if (GameLib.Utils.UndefinedOrNull(computeNormals)) {
computeNormals = true; computeNormals = true;
} }

View File

@ -16,6 +16,10 @@ GameLib.D3.Pass = function (
apiPass = {}; apiPass = {};
} }
if (apiPass instanceof GameLib.D3.Pass) {
return apiPass;
}
GameLib.D3.API.Pass.call( GameLib.D3.API.Pass.call(
this, this,
apiPass.id, apiPass.id,

View File

@ -16,6 +16,10 @@ GameLib.D3.PathFollowing = function (
apiPathFollowing = {}; apiPathFollowing = {};
} }
if (apiPathFollowing instanceof GameLib.D3.PathFollowing) {
return apiPathFollowing;
}
GameLib.D3.API.PathFollowing.call( GameLib.D3.API.PathFollowing.call(
this, this,
apiPathFollowing.id, apiPathFollowing.id,

View File

@ -16,6 +16,10 @@ GameLib.D3.Raycaster = function(
apiRaycaster = {}; apiRaycaster = {};
} }
if (apiRaycaster instanceof GameLib.D3.Raycaster) {
return apiRaycaster;
}
GameLib.D3.API.Raycaster.call( GameLib.D3.API.Raycaster.call(
this, this,
apiRaycaster.id, apiRaycaster.id,

View File

@ -16,6 +16,10 @@ GameLib.D3.RenderTarget = function (
apiRenderTarget = {}; apiRenderTarget = {};
} }
if (apiRenderTarget instanceof GameLib.D3.RenderTarget) {
return apiRenderTarget;
}
GameLib.D3.API.RenderTarget.call( GameLib.D3.API.RenderTarget.call(
this, this,
apiRenderTarget.id, apiRenderTarget.id,

View File

@ -16,6 +16,10 @@ GameLib.D3.Renderer = function (
apiRenderer = {}; apiRenderer = {};
} }
if (apiRenderer instanceof GameLib.D3.Renderer) {
return apiRenderer;
}
GameLib.D3.API.Renderer.call( GameLib.D3.API.Renderer.call(
this, this,
apiRenderer.id, apiRenderer.id,

View File

@ -3,7 +3,6 @@
* created * created
* @param graphics * @param graphics
* @param apiScene GameLib.D3.API.Scene * @param apiScene GameLib.D3.API.Scene
* @param imageFactory
* @param computeNormals * @param computeNormals
* @constructor * @constructor
*/ */
@ -19,6 +18,10 @@ GameLib.D3.Scene = function (
apiScene = {}; apiScene = {};
} }
if (apiScene instanceof GameLib.D3.Scene) {
return apiScene;
}
if (GameLib.Utils.UndefinedOrNull(computeNormals)) { if (GameLib.Utils.UndefinedOrNull(computeNormals)) {
computeNormals = true; computeNormals = true;
} }
@ -253,15 +256,17 @@ GameLib.D3.Scene.prototype.toApiScene = function() {
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.D3.Graphics
* @param objectScene Object * @param objectScene Object
* @param computeNormals boolean to indicate whether or not to recalculate normals * @param computeNormals boolean to indicate whether or not to recalculate normals
* @param imageFactory GameLib.D3.ImageFactory
* @returns {GameLib.D3.Scene} * @returns {GameLib.D3.Scene}
* @constructor * @constructor
*/ */
GameLib.D3.Scene.FromObjectScene = function( GameLib.D3.Scene.FromObjectScene = function(
graphics, graphics,
objectScene, objectScene,
computeNormals computeNormals,
imageFactory
) { ) {
var apiScene = GameLib.D3.API.Scene.FromObjectScene(objectScene); var apiScene = GameLib.D3.API.Scene.FromObjectScene(objectScene, imageFactory);
return new GameLib.D3.Scene( return new GameLib.D3.Scene(
graphics, graphics,
@ -276,18 +281,21 @@ GameLib.D3.Scene.FromObjectScene = function(
* @param objectScene Object (as it comes from the API) * @param objectScene Object (as it comes from the API)
* @param computeNormals * @param computeNormals
* @param onLoaded * @param onLoaded
* @param imageFactory GameLib.D3.ImageFactory
* @constructor * @constructor
*/ */
GameLib.D3.Scene.LoadScene = function( GameLib.D3.Scene.LoadScene = function(
graphics, graphics,
objectScene, objectScene,
computeNormals, computeNormals,
onLoaded onLoaded,
imageFactory
) { ) {
var scene = GameLib.D3.Scene.FromObjectScene( var scene = GameLib.D3.Scene.FromObjectScene(
graphics, graphics,
objectScene, objectScene,
computeNormals computeNormals,
imageFactory
); );
onLoaded(scene); onLoaded(scene);

View File

@ -15,6 +15,10 @@ GameLib.D3.Skeleton = function Skeleton(
apiSkeleton = {}; apiSkeleton = {};
} }
if (apiSkeleton instanceof GameLib.D3.Skeleton) {
return apiSkeleton;
}
GameLib.D3.API.Skeleton.call( GameLib.D3.API.Skeleton.call(
this, this,
apiSkeleton.id, apiSkeleton.id,

View File

@ -15,6 +15,10 @@ GameLib.D3.Spline = function (
apiSpline = {}; apiSpline = {};
} }
if (apiSpline instanceof GameLib.D3.Spline) {
return apiSpline;
}
GameLib.D3.API.Spline.call( GameLib.D3.API.Spline.call(
this, this,
apiSpline.id, apiSpline.id,

View File

@ -6,7 +6,7 @@
* @param imageFactory GameLib.D3.ImageFactory * @param imageFactory GameLib.D3.ImageFactory
* @constructor * @constructor
*/ */
GameLib.D3.Texture = function Texture( GameLib.D3.Texture = function(
graphics, graphics,
apiTexture, apiTexture,
imageFactory imageFactory
@ -18,6 +18,10 @@ GameLib.D3.Texture = function Texture(
apiTexture = {}; apiTexture = {};
} }
if (apiTexture instanceof GameLib.D3.Texture) {
return apiTexture;
}
if (GameLib.Utils.UndefinedOrNull(imageFactory)) { if (GameLib.Utils.UndefinedOrNull(imageFactory)) {
console.warn('Cannot create a Texture without specifying an ImageFactory'); console.warn('Cannot create a Texture without specifying an ImageFactory');
imageFactory = null; imageFactory = null;

View File

@ -15,7 +15,11 @@ GameLib.D3.Vertex = function Vertex(
apiVertex = {}; apiVertex = {};
} }
GameLib.D3.API.Vertex.call( if (apiVertex instanceof GameLib.D3.Vertex) {
return apiVertex;
}
GameLib.D3.API.Vertex.call(
this, this,
apiVertex.position, apiVertex.position,
apiVertex.boneWeights apiVertex.boneWeights

View File

@ -2,7 +2,6 @@
* Viewport Runtime * Viewport Runtime
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.D3.Graphics
* @param apiViewport GameLib.D3.API.Viewport * @param apiViewport GameLib.D3.API.Viewport
* @param imageFactory GameLib.D3.ImageFactory
* @constructor * @constructor
*/ */
GameLib.D3.Viewport = function ( GameLib.D3.Viewport = function (
@ -17,6 +16,10 @@ GameLib.D3.Viewport = function (
apiViewport = {}; apiViewport = {};
} }
if (apiViewport instanceof GameLib.D3.Viewport) {
return apiViewport;
}
GameLib.D3.API.Viewport.call( GameLib.D3.API.Viewport.call(
this, this,
apiViewport.id, apiViewport.id,

View File

@ -5,6 +5,10 @@
*/ */
GameLib.DomElement = function (apiDomElement) { GameLib.DomElement = function (apiDomElement) {
if (apiDomElement instanceof GameLib.DomElement) {
return apiDomElement;
}
GameLib.API.DomElement.call( GameLib.API.DomElement.call(
this, this,
apiDomElement.id, apiDomElement.id,

View File

@ -16,6 +16,10 @@ GameLib.EntityManager = function(
apiEntityManager = {}; apiEntityManager = {};
} }
if (apiEntityManager instanceof GameLib.EntityManager) {
return apiEntityManager;
}
GameLib.API.EntityManager.call( GameLib.API.EntityManager.call(
this, this,
apiEntityManager.id, apiEntityManager.id,

View File

@ -16,6 +16,10 @@ GameLib.Entity = function (
apiEntity = {}; apiEntity = {};
} }
if (apiEntity instanceof GameLib.Entity) {
return apiEntity;
}
GameLib.API.Entity.call( GameLib.API.Entity.call(
this, this,
apiEntity.id, apiEntity.id,

View File

@ -20,6 +20,10 @@ GameLib.Matrix4 = function(
apiMatrix4 = {}; apiMatrix4 = {};
} }
if (apiMatrix4 instanceof GameLib.Matrix4) {
return apiMatrix4;
}
GameLib.API.Matrix4.call( GameLib.API.Matrix4.call(
this, this,
apiMatrix4.rows[0], apiMatrix4.rows[0],

View File

@ -13,6 +13,10 @@ GameLib.Mouse = function (graphics, apiMouse) {
apiMouse = {}; apiMouse = {};
} }
if (apiMouse instanceof GameLib.Mouse) {
return apiMouse;
}
GameLib.API.Mouse.call( GameLib.API.Mouse.call(
this, this,
apiMouse.id, apiMouse.id,

View File

@ -19,6 +19,10 @@ GameLib.Quaternion = function (
apiQuaternion = {}; apiQuaternion = {};
} }
if (apiQuaternion instanceof GameLib.Quaternion) {
return apiQuaternion;
}
GameLib.API.Quaternion.call( GameLib.API.Quaternion.call(
this, this,
apiQuaternion.x, apiQuaternion.x,

View File

@ -16,6 +16,10 @@ GameLib.System = function(
apiSystem = {}; apiSystem = {};
} }
if (apiSystem instanceof GameLib.System) {
return apiSystem;
}
GameLib.API.System.call( GameLib.API.System.call(
this, this,
apiSystem.id, apiSystem.id,

View File

@ -19,6 +19,10 @@ GameLib.Vector2 = function (
apiVector2 = {}; apiVector2 = {};
} }
if (apiVector2 instanceof GameLib.Vector2) {
return apiVector2;
}
GameLib.API.Vector2.call( GameLib.API.Vector2.call(
this, this,
apiVector2.x, apiVector2.x,

View File

@ -19,6 +19,10 @@ GameLib.Vector3 = function (
apiVector3 = {}; apiVector3 = {};
} }
if (apiVector3 instanceof GameLib.Vector3) {
return apiVector3;
}
GameLib.API.Vector3.call( GameLib.API.Vector3.call(
this, this,
apiVector3.x, apiVector3.x,

View File

@ -20,7 +20,11 @@ GameLib.Vector4 = function (
apiVector4 = {}; apiVector4 = {};
} }
GameLib.API.Vector4.call( if (apiVector4 instanceof GameLib.Vector4) {
return apiVector4;
}
GameLib.API.Vector4.call(
this, this,
apiVector4.x, apiVector4.x,
apiVector4.y, apiVector4.y,

View File

@ -1,9 +1,3 @@
if (typeof module !== 'undefined') { if (typeof module !== 'undefined') {
module.exports = GameLib; module.exports = GameLib;
} }