diff --git a/src/game-lib-a-component-a.js b/src/game-lib-a-component-a.js index 154fc70..79dfeab 100644 --- a/src/game-lib-a-component-a.js +++ b/src/game-lib-a-component-a.js @@ -27,7 +27,7 @@ GameLib.Component = function( //this.parentObjects = []; - this.build = true; + this.built = true; //this.linkedObjects.parentEntity = GameLib.Entity; }; @@ -70,17 +70,17 @@ GameLib.Component.COMPONENT_GUI = 0x1f; * Components are linked at runtime - for storing, we just store the ID * @returns {*} */ -GameLib.Component.prototype.toApiComponent = function() { +GameLib.Component.prototype.toApiObject = function() { return this.id; }; GameLib.Component.prototype.buildIdToObject = function() { - if (!this.build) { + if (!this.built) { return; } - this.build = false; + this.built = false; this.idToObject = {}; @@ -100,7 +100,7 @@ GameLib.Component.prototype.buildIdToObject = function() { this.idToObject[this.id] = this; - this.build = true; + this.built = true; }; /** diff --git a/src/game-lib-color.js b/src/game-lib-color.js index 6a90199..3d9b408 100644 --- a/src/game-lib-color.js +++ b/src/game-lib-color.js @@ -86,7 +86,7 @@ GameLib.Color.prototype.updateInstance = function() { * Converts runtime color to API Color * @returns {GameLib.API.Color} */ -GameLib.Color.prototype.toApiColor = function() { +GameLib.Color.prototype.toApiObject = function() { return new GameLib.API.Color( this.r, this.g, diff --git a/src/game-lib-d3-bone-weight.js b/src/game-lib-d3-bone-weight.js index 230d7f9..d3827c5 100644 --- a/src/game-lib-d3-bone-weight.js +++ b/src/game-lib-d3-bone-weight.js @@ -33,7 +33,7 @@ GameLib.D3.BoneWeight.prototype.constructor = GameLib.D3.BoneWeight; * Converts a GameLib.D3.BoneWeight to GameLib.D3.API.BoneWeight * @returns {GameLib.D3.API.BoneWeight} */ -GameLib.D3.BoneWeight.prototype.toApiBoneWeight = function() { +GameLib.D3.BoneWeight.prototype.toApiObject = function() { var apiBoneWeight = new GameLib.D3.API.BoneWeight( this.boneIndex, diff --git a/src/game-lib-d3-bone.js b/src/game-lib-d3-bone.js index 76ce071..a139a4b 100644 --- a/src/game-lib-d3-bone.js +++ b/src/game-lib-d3-bone.js @@ -109,17 +109,17 @@ GameLib.D3.Bone.prototype.updateInstance = function() { * Converts a GameLib.D3.Bone to GameLib.D3.API.Bone * @returns {GameLib.D3.API.Bone} */ -GameLib.D3.Bone.prototype.toApiBone = function() { +GameLib.D3.Bone.prototype.toApiObject = function() { var apiBone = new GameLib.D3.API.Bone( this.id, this.name, this.childBoneIds, this.parentBoneIds, - this.position.toApiVector(), - this.quaternion.toApiQuaternion(), - this.scale.toApiVector(), - this.up.toApiVector() + this.position.toApiObject(), + this.quaternion.toApiObject(), + this.scale.toApiObject(), + this.up.toApiObject() ); return apiBone; diff --git a/src/game-lib-d3-camera.js b/src/game-lib-d3-camera.js index 5bd6b4b..e28e7cf 100644 --- a/src/game-lib-d3-camera.js +++ b/src/game-lib-d3-camera.js @@ -182,7 +182,7 @@ GameLib.D3.Camera.prototype.updateInstance = function() { * Converts a GameLib.D3.Camera to a new GameLib.D3.API.Camera * @returns {GameLib.D3.API.Camera} */ -GameLib.D3.Camera.prototype.toApiCamera = function() { +GameLib.D3.Camera.prototype.toApiObject = function() { return new GameLib.D3.API.Camera( this.id, @@ -192,15 +192,15 @@ GameLib.D3.Camera.prototype.toApiCamera = function() { this.aspect, this.near, this.far, - this.position.toApiVector(), - this.lookAt.toApiVector(), + this.position.toApiObject(), + this.lookAt.toApiObject(), this.minX, this.maxX, this.minY, this.maxY, this.minZ, this.maxZ, - this.quaternion.toApiQuaternion(), + this.quaternion.toApiObject(), GameLib.Utils.IdOrNull(this.parentEntity), this.eyeSeparation, this.focalLength diff --git a/src/game-lib-d3-composer.js b/src/game-lib-d3-composer.js index 3647727..45e144e 100644 --- a/src/game-lib-d3-composer.js +++ b/src/game-lib-d3-composer.js @@ -113,7 +113,7 @@ GameLib.D3.Composer.prototype.updateInstance = function() { * GameLib.D3.Composer to GameLib.D3.API.Composer * @returns {GameLib.D3.API.Composer} */ -GameLib.D3.Composer.prototype.toApiComponent = function() { +GameLib.D3.Composer.prototype.toApiObject = function() { var apiComposer = new GameLib.D3.API.Composer( this.id, diff --git a/src/game-lib-d3-custom-code.js b/src/game-lib-d3-custom-code.js index 7881aa5..e39a72d 100644 --- a/src/game-lib-d3-custom-code.js +++ b/src/game-lib-d3-custom-code.js @@ -59,7 +59,7 @@ GameLib.D3.CustomCode.prototype.updateInstance = function() { * Converts a GameLib.D3.CustomCode to a new GameLib.D3.API.CustomCode * @returns {GameLib.D3.API.CustomCode} */ -GameLib.D3.CustomCode.prototype.toApiCustomCode = function() { +GameLib.D3.CustomCode.prototype.toApiObject = function() { var apiArgs = []; diff --git a/src/game-lib-d3-editor.js b/src/game-lib-d3-editor.js index 2d41248..414ed02 100644 --- a/src/game-lib-d3-editor.js +++ b/src/game-lib-d3-editor.js @@ -240,7 +240,7 @@ GameLib.D3.Editor.prototype.updateInstance = function() { * Converts a GameLib.D3.Editor to a new GameLib.D3.API.Editor * @returns {GameLib.D3.API.Editor} */ -GameLib.D3.Editor.prototype.toApiEditor = function() { +GameLib.D3.Editor.prototype.toApiObject = function() { var apiImageFactory = null; var apiGames = []; @@ -254,14 +254,14 @@ GameLib.D3.Editor.prototype.toApiEditor = function() { var apiEntityManager = null; if (this.imageFactory instanceof GameLib.D3.ImageFactory) { - apiImageFactory = this.imageFactory.toApiImageFactory(); + apiImageFactory = this.imageFactory.toApiObject(); } if (this.games) { apiGames = this.games.map( function(game) { if (game instanceof GameLib.D3.Game) { - return game.toApiGame(); + return game.toApiObject(); } else { console.warn('game not an instance of Game'); throw new Error('game not an instance of Game'); @@ -274,7 +274,7 @@ GameLib.D3.Editor.prototype.toApiEditor = function() { apiScenes = this.scenes.map( function(scene) { if (scene instanceof GameLib.D3.Scene) { - return scene.toApiScene(); + return scene.toApiObject(); } else { console.warn('scene not an instance of Scene'); throw new Error('scene not an instance of Scene'); @@ -287,7 +287,7 @@ GameLib.D3.Editor.prototype.toApiEditor = function() { apiCameras = this.cameras.map( function(camera) { if (camera instanceof GameLib.D3.Camera) { - return camera.toApiCamera(); + return camera.toApiObject(); } else { console.warn('camera not an instance of Camera'); throw new Error('camera not an instance of Camera'); @@ -300,7 +300,7 @@ GameLib.D3.Editor.prototype.toApiEditor = function() { apiComposers = this.composers.map( function(composer) { if (composer instanceof GameLib.D3.Composer) { - return composer.toApiComponent(); + return composer.toApiObject(); } else { console.warn('composer not an instance of Composer'); throw new Error('composer not an instance of Composer'); @@ -313,7 +313,7 @@ GameLib.D3.Editor.prototype.toApiEditor = function() { apiViewports = this.viewports.map( function(viewport) { if (viewport instanceof GameLib.D3.Viewport) { - return viewport.toApiComponent(); + return viewport.toApiObject(); } else { console.warn('viewport not an instance of Viewport'); throw new Error('viewport not an instance of Viewport'); @@ -326,7 +326,7 @@ GameLib.D3.Editor.prototype.toApiEditor = function() { apiRenderers = this.renderers.map( function(renderer) { if (renderer instanceof GameLib.D3.Renderer) { - return renderer.toApiComponent(); + return renderer.toApiObject(); } else { console.warn('renderer not an instance of Renderer'); throw new Error('renderer not an instance of Renderer'); @@ -339,7 +339,7 @@ GameLib.D3.Editor.prototype.toApiEditor = function() { apiRenderTargets = this.renderTargets.map( function(renderTarget) { if (renderTarget instanceof GameLib.D3.RenderTarget) { - return renderTarget.toApiComponent(); + return renderTarget.toApiObject(); } else { console.warn('renderTarget not an instance of RenderTarget'); throw new Error('renderTarget not an instance of RenderTarget'); @@ -352,7 +352,7 @@ GameLib.D3.Editor.prototype.toApiEditor = function() { apiSystems = this.systems.map( function(system) { if (system instanceof GameLib.System) { - return system.toApiComponent(); + return system.toApiObject(); } else { console.warn('system not an instance of System'); throw new Error('system not an instance of System'); @@ -363,7 +363,7 @@ GameLib.D3.Editor.prototype.toApiEditor = function() { if (this.entityManager) { if (this.entityManager instanceof GameLib.EntityManager) { - apiEntityManager = this.entityManager.toApiEntityManager(); + apiEntityManager = this.entityManager.toApiObject(); } else { console.warn('entityManager not an instance of EntityManager'); throw new Error('entityManager not an instance of EntityManager'); diff --git a/src/game-lib-d3-follow.js b/src/game-lib-d3-follow.js index 32cb4e0..cfecddf 100644 --- a/src/game-lib-d3-follow.js +++ b/src/game-lib-d3-follow.js @@ -68,14 +68,14 @@ GameLib.D3.Follow = function ( GameLib.D3.Follow.prototype = Object.create(GameLib.D3.API.Follow.prototype); GameLib.D3.Follow.prototype.constructor = GameLib.D3.Follow; -GameLib.D3.Follow.prototype.toApiComponent = function() { +GameLib.D3.Follow.prototype.toApiObject = function() { var apiFollow = new GameLib.D3.API.Follow( this.id, this.name, GameLib.Utils.IdOrNull(this.currentComponent), GameLib.Utils.IdOrNull(this.targetComponent), - this.targetPositionOffset.toApiVector(), + this.targetPositionOffset.toApiObject(), this.minDistance, this.moveSpeed, GameLib.Utils.IdOrNull(this.parentEntity) diff --git a/src/game-lib-d3-game.js b/src/game-lib-d3-game.js index b267ba6..959d1e9 100644 --- a/src/game-lib-d3-game.js +++ b/src/game-lib-d3-game.js @@ -201,7 +201,7 @@ GameLib.D3.Game.prototype.updateInstance = function() { * Converts a GameLib.D3.Game to a new GameLib.D3.API.Game * @returns {GameLib.D3.API.Game} */ -GameLib.D3.Game.prototype.toApiGame = function() { +GameLib.D3.Game.prototype.toApiObject = function() { var apiImageFactory = null; var apiCameras = []; @@ -213,14 +213,14 @@ GameLib.D3.Game.prototype.toApiGame = function() { var apiEntityManager = null; if (this.imageFactory instanceof GameLib.D3.ImageFactory) { - apiImageFactory = this.imageFactory.toApiImageFactory(); + apiImageFactory = this.imageFactory.toApiObject(); } if (this.cameras) { apiCameras = this.cameras.map( function(camera) { if (camera instanceof GameLib.D3.Camera) { - return camera.toApiCamera(); + return camera.toApiObject(); } else { console.warn('camera not an instance of Camera'); throw new Error('camera not an instance of Camera'); @@ -233,7 +233,7 @@ GameLib.D3.Game.prototype.toApiGame = function() { apiComposers = this.composers.map( function(composer) { if (composer instanceof GameLib.D3.Composer) { - return composer.toApiComponent(); + return composer.toApiObject(); } else { console.warn('composer not an instance of Composer'); throw new Error('composer not an instance of Composer'); @@ -246,7 +246,7 @@ GameLib.D3.Game.prototype.toApiGame = function() { apiViewports = this.viewports.map( function(viewport) { if (viewport instanceof GameLib.D3.Viewport) { - return viewport.toApiComponent(); + return viewport.toApiObject(); } else { console.warn('viewport not an instance of Viewport'); throw new Error('viewport not an instance of Viewport'); @@ -259,7 +259,7 @@ GameLib.D3.Game.prototype.toApiGame = function() { apiRenderers = this.renderers.map( function(renderer) { if (renderer instanceof GameLib.D3.Renderer) { - return renderer.toApiComponent(); + return renderer.toApiObject(); } else { console.warn('renderer not an instance of Renderer'); throw new Error('renderer not an instance of Renderer'); @@ -272,7 +272,7 @@ GameLib.D3.Game.prototype.toApiGame = function() { apiRenderTargets = this.renderTargets.map( function(renderTarget) { if (renderTarget instanceof GameLib.D3.RenderTarget) { - return renderTarget.toApiComponent(); + return renderTarget.toApiObject(); } else { console.warn('renderTarget not an instance of RenderTarget'); throw new Error('renderTarget not an instance of RenderTarget'); @@ -285,7 +285,7 @@ GameLib.D3.Game.prototype.toApiGame = function() { apiSystems = this.systems.map( function(system) { if (system instanceof GameLib.System) { - return system.toApiComponent(); + return system.toApiObject(); } else { console.warn('system not an instance of System'); throw new Error('system not an instance of System'); @@ -296,7 +296,7 @@ GameLib.D3.Game.prototype.toApiGame = function() { if (this.entityManager) { if (this.entityManager instanceof GameLib.EntityManager) { - apiEntityManager = this.entityManager.toApiEntityManager(); + apiEntityManager = this.entityManager.toApiObject(); } else { console.warn('entityManager not an instance of EntityManager'); throw new Error('entityManager not an instance of EntityManager'); diff --git a/src/game-lib-d3-image-factory.js b/src/game-lib-d3-image-factory.js index 094abff..464df9a 100644 --- a/src/game-lib-d3-image-factory.js +++ b/src/game-lib-d3-image-factory.js @@ -115,7 +115,7 @@ GameLib.D3.ImageFactory.prototype.loadImage = function( * Converts a GameLib.D3.ImageFactory to a GameLib.D3.API.ImageFactory * @returns {GameLib.D3.API.ImageFactory} */ -GameLib.D3.ImageFactory.prototype.toApiImageFactory = function() { +GameLib.D3.ImageFactory.prototype.toApiObject = function() { return new GameLib.D3.API.ImageFactory( this.id, this.name, diff --git a/src/game-lib-d3-input-drive.js b/src/game-lib-d3-input-drive.js index 60a05fc..a999a76 100644 --- a/src/game-lib-d3-input-drive.js +++ b/src/game-lib-d3-input-drive.js @@ -104,7 +104,7 @@ GameLib.D3.Input.Drive.prototype.updateInstance = function() { * GameLib.D3.Input.Drive to GameLib.D3.API.Input.Drive * @returns {GameLib.D3.API.Input.Drive} */ -GameLib.D3.Input.Drive.prototype.toApiComponent = function() { +GameLib.D3.Input.Drive.prototype.toApiObject = function() { var apiInputDrive = new GameLib.D3.API.Input.Drive( this.id, diff --git a/src/game-lib-d3-input-editor.js b/src/game-lib-d3-input-editor.js index d16a4b7..12c06ba 100644 --- a/src/game-lib-d3-input-editor.js +++ b/src/game-lib-d3-input-editor.js @@ -91,7 +91,7 @@ GameLib.D3.Input.Editor.prototype.updateInstance = function() { * GameLib.D3.Input.Editor to GameLib.D3.API.Input.Editor * @returns {GameLib.D3.API.Input.Editor} */ -GameLib.D3.Input.Editor.prototype.toApiComponent = function() { +GameLib.D3.Input.Editor.prototype.toApiObject = function() { var apiInputEditor = new GameLib.D3.API.Input.Editor( this.id, @@ -212,6 +212,8 @@ GameLib.D3.Input.Editor.prototype.onMouseDown = function(entity) { return; } + var gui = entity.getFirstComponent(GameLib.GUI); + if (intersects[0].selected) { helper = new GameLib.D3.Helper( @@ -233,12 +235,12 @@ GameLib.D3.Input.Editor.prototype.onMouseDown = function(entity) { scene.instance.add(helper.instance); - var gui = entity.getFirstComponent(GameLib.GUI); - - gui.instance.add(intersects[0], 'name'); + gui.addObject(intersects[0]); } else { + gui.removeObject(intersects[0]); + var components = entity.getComponents(GameLib.D3.Helper); helper = components.reduce( @@ -266,6 +268,8 @@ GameLib.D3.Input.Editor.prototype.onMouseDown = function(entity) { console.warn('failed to locate helper object which should exist for ' + intersects[0].name); } } + + gui.build(); } } } diff --git a/src/game-lib-d3-light.js b/src/game-lib-d3-light.js index f177b5e..e66dc51 100644 --- a/src/game-lib-d3-light.js +++ b/src/game-lib-d3-light.js @@ -201,18 +201,18 @@ GameLib.D3.Light.prototype.clone = function() { * Converts a GameLib.D3.Light to a GameLib.D3.API.Light * @returns {GameLib.D3.API.Light} */ -GameLib.D3.Light.prototype.toApiLight = function() { +GameLib.D3.Light.prototype.toApiObject = function() { return new GameLib.D3.API.Light( this.id, this.lightType, this.name, - this.color.toApiColor(), + this.color.toApiObject(), this.intensity, - this.position.toApiVector(), - this.targetPosition.toApiVector(), - this.quaternion.toApiQuaternion(), + this.position.toApiObject(), + this.targetPosition.toApiObject(), + this.quaternion.toApiObject(), this.rotation, - this.scale.toApiVector(), + this.scale.toApiObject(), this.distance, this.decay, this.power, diff --git a/src/game-lib-d3-look-at.js b/src/game-lib-d3-look-at.js index 9aaacdb..b30fe3a 100644 --- a/src/game-lib-d3-look-at.js +++ b/src/game-lib-d3-look-at.js @@ -66,14 +66,14 @@ GameLib.D3.LookAt = function ( GameLib.D3.LookAt.prototype = Object.create(GameLib.D3.API.LookAt.prototype); GameLib.D3.LookAt.prototype.constructor = GameLib.D3.LookAt; -GameLib.D3.LookAt.prototype.toApiComponent = function() { +GameLib.D3.LookAt.prototype.toApiObject = function() { var apiLookAt = new GameLib.D3.API.LookAt( this.id, this.name, GameLib.Utils.IdOrNull(this.currentComponent), GameLib.Utils.IdOrNull(this.targetComponent), - this.targetPositionOffset.toApiVector(), + this.targetPositionOffset.toApiObject(), this.rotationSpeed, GameLib.Utils.IdOrNull(this.parentEntity) ); diff --git a/src/game-lib-d3-material.js b/src/game-lib-d3-material.js index 22a6902..8ab2f1b 100644 --- a/src/game-lib-d3-material.js +++ b/src/game-lib-d3-material.js @@ -673,66 +673,66 @@ GameLib.D3.Material.prototype.clone = function() { * Converts a GameLib.D3.Material to a GameLib.D3.API.Material * @returns {GameLib.D3.API.Material} */ -GameLib.D3.Material.prototype.toApiMaterial = function() { +GameLib.D3.Material.prototype.toApiObject = function() { var apiAlphaMap = null; if (this.alphaMap) { - apiAlphaMap = this.alphaMap.toApiTexture(); + apiAlphaMap = this.alphaMap.toApiObject(); } var apiAoMap = null; if (this.aoMap) { - apiAoMap = this.aoMap.toApiTexture(); + apiAoMap = this.aoMap.toApiObject(); } var apiBumpMap = null; if (this.bumpMap) { - apiBumpMap = this.bumpMap.toApiTexture(); + apiBumpMap = this.bumpMap.toApiObject(); } var apiDiffuseMap = null; if (this.diffuseMap) { - apiDiffuseMap = this.diffuseMap.toApiTexture(); + apiDiffuseMap = this.diffuseMap.toApiObject(); } var apiDisplacementMap = null; if (this.displacementMap) { - apiDisplacementMap = this.displacementMap.toApiTexture(); + apiDisplacementMap = this.displacementMap.toApiObject(); } var apiEmissiveMap = null; if (this.emissiveMap) { - apiEmissiveMap = this.emissiveMap.toApiTexture(); + apiEmissiveMap = this.emissiveMap.toApiObject(); } var apiEnvironmentMap = null; if (this.environmentMap) { - apiEnvironmentMap = this.environmentMap.toApiTexture(); + apiEnvironmentMap = this.environmentMap.toApiObject(); } var apiLightMap = null; if (this.lightMap) { - apiLightMap = this.lightMap.toApiTexture(); + apiLightMap = this.lightMap.toApiObject(); } var apiMetalnessMap = null; if (this.metalnessMap) { - apiMetalnessMap = this.metalnessMap.toApiTexture(); + apiMetalnessMap = this.metalnessMap.toApiObject(); } var apiNormalMap = null; if (this.normalMap) { - apiNormalMap = this.normalMap.toApiTexture(); + apiNormalMap = this.normalMap.toApiObject(); } var apiRoughnessMap = null; if (this.roughnessMap) { - apiRoughnessMap = this.roughnessMap.toApiTexture(); + apiRoughnessMap = this.roughnessMap.toApiObject(); } var apiSpecularMap = null; if (this.specularMap) { - apiSpecularMap = this.specularMap.toApiTexture(); + apiSpecularMap = this.specularMap.toApiObject(); } return new GameLib.D3.API.Material( @@ -742,11 +742,11 @@ GameLib.D3.Material.prototype.toApiMaterial = function() { this.opacity, this.side, this.transparent, - this.specular.toApiColor(), + this.specular.toApiObject(), this.lightMapIntensity, this.aoMapIntensity, - this.color.toApiColor(), - this.emissive.toApiColor(), + this.color.toApiObject(), + this.emissive.toApiObject(), this.emissiveIntensity, this.combine, this.shininess, diff --git a/src/game-lib-d3-mesh.js b/src/game-lib-d3-mesh.js index 6e86d28..ce3f842 100644 --- a/src/game-lib-d3-mesh.js +++ b/src/game-lib-d3-mesh.js @@ -434,12 +434,12 @@ GameLib.D3.Mesh.prototype.clone = function() { * Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh * @returns {GameLib.D3.API.Mesh} */ -GameLib.D3.Mesh.prototype.toApiMesh = function() { +GameLib.D3.Mesh.prototype.toApiObject = function() { var apiSkeleton = null; if (this.skeleton) { - apiSkeleton = this.skeleton.toApiSkeleton(); + apiSkeleton = this.skeleton.toApiObject(); } return new GameLib.D3.API.Mesh( @@ -448,7 +448,7 @@ GameLib.D3.Mesh.prototype.toApiMesh = function() { this.name, this.vertices.map( function (vertex) { - return vertex.toApiVertex(); + return vertex.toApiObject(); } ), this.faces, @@ -459,14 +459,14 @@ GameLib.D3.Mesh.prototype.toApiMesh = function() { apiSkeleton, this.skinIndices, this.skinWeights, - this.position.toApiVector(), - this.quaternion.toApiQuaternion(), - this.scale.toApiVector(), - this.localPosition.toApiVector(), - this.localRotation.toApiVector(), - this.localScale.toApiVector(), - this.up.toApiVector(), - this.modelMatrix.toApiMatrix(), + this.position.toApiObject(), + this.quaternion.toApiObject(), + this.scale.toApiObject(), + this.localPosition.toApiObject(), + this.localRotation.toApiObject(), + this.localScale.toApiObject(), + this.up.toApiObject(), + this.modelMatrix.toApiObject(), GameLib.Utils.IdOrNull(this.parentEntity), this.renderOrder ); diff --git a/src/game-lib-d3-pass.js b/src/game-lib-d3-pass.js index 2771cd8..35bb438 100644 --- a/src/game-lib-d3-pass.js +++ b/src/game-lib-d3-pass.js @@ -101,7 +101,7 @@ GameLib.D3.Pass.prototype.updateInstance = function() { * GameLib.D3.Pass to GameLib.D3.API.Pass * @returns {GameLib.D3.API.Pass} */ -GameLib.D3.Pass.prototype.toApiComponent = function() { +GameLib.D3.Pass.prototype.toApiObject = function() { var apiPass = new GameLib.D3.API.Pass( this.id, diff --git a/src/game-lib-d3-path-following.js b/src/game-lib-d3-path-following.js index a53f692..4c73ad0 100644 --- a/src/game-lib-d3-path-following.js +++ b/src/game-lib-d3-path-following.js @@ -115,7 +115,7 @@ GameLib.D3.PathFollowing = function ( GameLib.D3.PathFollowing.prototype = Object.create(GameLib.D3.API.PathFollowing.prototype); GameLib.D3.PathFollowing.prototype.constructor = GameLib.D3.PathFollowing; -GameLib.D3.PathFollowing.prototype.toApiComponent = function() { +GameLib.D3.PathFollowing.prototype.toApiObject = function() { var apiPathFollowing = new GameLib.D3.API.PathFollowing( this.id, @@ -125,20 +125,20 @@ GameLib.D3.PathFollowing.prototype.toApiComponent = function() { GameLib.Utils.IdOrNull(this.raytraceMesh), this.accelleration, this.maxSpeed, - this.baseOffset.toApiVector(), - this.maxOffset.toApiVector(), + this.baseOffset.toApiObject(), + this.maxOffset.toApiObject(), this.steeringSpeed, - this.targetOffset.toApiVector(), - this.currentOffset.toApiVector(), + this.targetOffset.toApiObject(), + this.currentOffset.toApiObject(), this.currentPathValue, this.currentSpeed, this.direction, - this.raycaster.toApiRaycaster(), - this.currentPosition.toApiVector(), - this.futurePosition.toApiVector(), - this.up.toApiVector(), - this.rotationMatrix.toApiMatrix(), - this.rotationVector.toApiQuaternion(), + this.raycaster.toApiObject(), + this.currentPosition.toApiObject(), + this.futurePosition.toApiObject(), + this.up.toApiObject(), + this.rotationMatrix.toApiObject(), + this.rotationVector.toApiObject(), GameLib.Utils.IdOrNull(this.parentEntity) ); diff --git a/src/game-lib-d3-raycaster.js b/src/game-lib-d3-raycaster.js index 0f9d70d..8082804 100644 --- a/src/game-lib-d3-raycaster.js +++ b/src/game-lib-d3-raycaster.js @@ -72,12 +72,12 @@ GameLib.D3.Raycaster.prototype.updateInstance = function() { this.instance = this.createInstance(true); }; -GameLib.D3.Raycaster.prototype.toApiRaycaster = function() { +GameLib.D3.Raycaster.prototype.toApiObject = function() { return new GameLib.D3.API.Raycaster( this.id, this.name, - this.position.toApiVector(), - this.direction.toApiVector() + this.position.toApiObject(), + this.direction.toApiObject() ) }; diff --git a/src/game-lib-d3-render-target.js b/src/game-lib-d3-render-target.js index b2c1dff..4ceabcc 100644 --- a/src/game-lib-d3-render-target.js +++ b/src/game-lib-d3-render-target.js @@ -99,7 +99,7 @@ GameLib.D3.RenderTarget.prototype.updateInstance = function() { * Render Target to API Render Target * @returns {GameLib.D3.API.RenderTarget} */ -GameLib.D3.RenderTarget.prototype.toApiComponent = function() { +GameLib.D3.RenderTarget.prototype.toApiObject = function() { var apiRenderTarget = new GameLib.D3.API.RenderTarget( this.id, diff --git a/src/game-lib-d3-renderer.js b/src/game-lib-d3-renderer.js index 2b2c690..cd5af2b 100644 --- a/src/game-lib-d3-renderer.js +++ b/src/game-lib-d3-renderer.js @@ -82,7 +82,7 @@ GameLib.D3.Renderer.prototype.updateInstance = function() { this.instance = this.createInstance(true); }; -GameLib.D3.Renderer.prototype.toApiComponent = function() { +GameLib.D3.Renderer.prototype.toApiObject = function() { var apiRenderer = new GameLib.D3.API.Renderer( this.id, @@ -92,7 +92,7 @@ GameLib.D3.Renderer.prototype.toApiComponent = function() { this.width, this.height, this.preserveDrawingBuffer, - this.domElement.toApiDomElement(), + this.domElement.toApiObject(), GameLib.Utils.IdOrNull(this.parentEntity) ); diff --git a/src/game-lib-d3-scene.js b/src/game-lib-d3-scene.js index fab28f2..7cb5b85 100644 --- a/src/game-lib-d3-scene.js +++ b/src/game-lib-d3-scene.js @@ -204,34 +204,34 @@ GameLib.D3.Scene.prototype.createInstance = function() { * Converts a GameLib.D3.Scene to a GameLib.D3.API.Scene * @returns {GameLib.D3.API.Scene} */ -GameLib.D3.Scene.prototype.toApiScene = function() { +GameLib.D3.Scene.prototype.toApiObject = function() { var apiImageFactory = null; if (this.imageFactory instanceof GameLib.D3.ImageFactory) { - apiImageFactory = this.imageFactory.toApiImageFactory(); + apiImageFactory = this.imageFactory.toApiObject(); } var apiMeshes = this.meshes.map( function(mesh) { - return mesh.toApiMesh(); + return mesh.toApiObject(); } ); var apiLights = this.lights.map( function(light) { - return light.toApiLight(); + return light.toApiObject(); } ); var apiTextures = this.textures.map( function(texture) { - return texture.toApiTexture(); + return texture.toApiObject(); } ); var apiMaterials = this.materials.map( function(material) { - return material.toApiMaterial(); + return material.toApiObject(); } ); @@ -240,9 +240,9 @@ GameLib.D3.Scene.prototype.toApiScene = function() { this.name, apiImageFactory, apiMeshes, - this.position.toApiVector(), - this.quaternion.toApiQuaternion(), - this.scale.toApiVector(), + this.position.toApiObject(), + this.quaternion.toApiObject(), + this.scale.toApiObject(), this.parentGameId, apiLights, apiTextures, diff --git a/src/game-lib-d3-skeleton.js b/src/game-lib-d3-skeleton.js index 9d7b79e..41885f3 100644 --- a/src/game-lib-d3-skeleton.js +++ b/src/game-lib-d3-skeleton.js @@ -176,19 +176,19 @@ GameLib.D3.Skeleton.prototype.updateInstance = function() { * Converts a GameLib.D3.Skeleton to GameLib.D3.API.Skeleton * @returns {GameLib.D3.API.Skeleton} */ -GameLib.D3.Skeleton.prototype.toApiSkeleton = function() { +GameLib.D3.Skeleton.prototype.toApiObject = function() { var apiSkeleton = new GameLib.D3.API.Skeleton( this.id, this.name, this.bones.map( function (bone) { - return bone.toApiBone(); + return bone.toApiObject(); } ), this.boneInverses.map( function (boneInverse) { - return boneInverse.toApiMatrix(); + return boneInverse.toApiObject(); } ), this.useVertexTexture, @@ -196,7 +196,7 @@ GameLib.D3.Skeleton.prototype.toApiSkeleton = function() { this.boneTextureHeight, this.boneMatrices.map( function (boneMatrix) { - return boneMatrix.toApiMatrix(); + return boneMatrix.toApiObject(); } ), this.boneTexture, diff --git a/src/game-lib-d3-spline.js b/src/game-lib-d3-spline.js index 370f1af..3c108e9 100644 --- a/src/game-lib-d3-spline.js +++ b/src/game-lib-d3-spline.js @@ -73,14 +73,14 @@ GameLib.D3.Spline.prototype.updateInstance = function() { * Converts a GameLib.D3.Spline to GameLib.D3.API.Spline * @returns {GameLib.D3.API.Spline} */ -GameLib.D3.Spline.prototype.toApiComponent = function() { +GameLib.D3.Spline.prototype.toApiObject = function() { return new GameLib.D3.API.Spline( this.id, this.name, this.vertices.map( function (vertex) { - return vertex.toApiVector() + return vertex.toApiObject() } ), GameLib.Utils.IdOrNull(this.parentEntity) diff --git a/src/game-lib-d3-texture.js b/src/game-lib-d3-texture.js index ed06daa..d6fa013 100644 --- a/src/game-lib-d3-texture.js +++ b/src/game-lib-d3-texture.js @@ -248,7 +248,7 @@ GameLib.D3.Texture.prototype.clone = function() { * Converts a GameLib.D3.Texture to a GameLib.D3.API.Texture * @returns {GameLib.D3.API.Texture} */ -GameLib.D3.Texture.prototype.toApiTexture = function() { +GameLib.D3.Texture.prototype.toApiObject = function() { return new GameLib.D3.API.Texture( this.id, @@ -257,7 +257,7 @@ GameLib.D3.Texture.prototype.toApiTexture = function() { this.imagePath, this.wrapS, this.wrapT, - this.repeat.toApiVector(), + this.repeat.toApiObject(), this.data, this.format, this.mapping, @@ -265,7 +265,7 @@ GameLib.D3.Texture.prototype.toApiTexture = function() { this.minFilter, this.textureType, this.anisotropy, - this.offset.toApiVector(), + this.offset.toApiObject(), this.generateMipmaps, this.flipY, this.mipmaps, diff --git a/src/game-lib-d3-vertex.js b/src/game-lib-d3-vertex.js index 5531df4..a124542 100644 --- a/src/game-lib-d3-vertex.js +++ b/src/game-lib-d3-vertex.js @@ -48,12 +48,12 @@ GameLib.D3.Vertex.prototype.constructor = GameLib.D3.Vertex; * Converts a GameLib.D3.Vertex to GameLib.D3.API.Vertex * @returns {GameLib.D3.API.Vertex} */ -GameLib.D3.Vertex.prototype.toApiVertex = function() { +GameLib.D3.Vertex.prototype.toApiObject = function() { return new GameLib.D3.API.Vertex( - this.position.toApiVector(), + this.position.toApiObject(), this.boneWeights.map(function(boneWeight){ - return boneWeight.toApiBoneWeight(); + return boneWeight.toApiObject(); }) ); diff --git a/src/game-lib-d3-viewport.js b/src/game-lib-d3-viewport.js index 322299d..b6bdd80 100644 --- a/src/game-lib-d3-viewport.js +++ b/src/game-lib-d3-viewport.js @@ -138,7 +138,7 @@ GameLib.D3.Viewport.prototype.updateInstance = function() { * GameLib.D3.Viewport to GameLib.D3.API.Viewport * @returns {GameLib.D3.API.Viewport} */ -GameLib.D3.Viewport.prototype.toApiComponent = function() { +GameLib.D3.Viewport.prototype.toApiObject = function() { var apiViewport = new GameLib.D3.API.Viewport( this.id, diff --git a/src/game-lib-dom-element.js b/src/game-lib-dom-element.js index 2450efc..02132d9 100644 --- a/src/game-lib-dom-element.js +++ b/src/game-lib-dom-element.js @@ -52,7 +52,7 @@ GameLib.DomElement.prototype.updateInstance = function() { * Converts runtime vector to API Vector * @returns {GameLib.API.DomElement} */ -GameLib.DomElement.prototype.toApiDomElement = function() { +GameLib.DomElement.prototype.toApiObject = function() { return new GameLib.API.DomElement( this.id, this.name, diff --git a/src/game-lib-entity-manager.js b/src/game-lib-entity-manager.js index c215130..fe51541 100644 --- a/src/game-lib-entity-manager.js +++ b/src/game-lib-entity-manager.js @@ -209,17 +209,17 @@ GameLib.EntityManager.prototype.queryComponents = function(constructor) { * Converts a GameLib.Entity to GameLib.API.Entity * @returns {GameLib.API.EntityManager} */ -GameLib.EntityManager.prototype.toApiEntityManager = function() { +GameLib.EntityManager.prototype.toApiObject = function() { var apiEntities = this.entities.map( function (entity) { - return entity.toApiEntity(); + return entity.toApiObject(); } ); // var apiSystems = this.systems.map( // function (system) { - // return system.toApiSystem(); + // return system.toApiObject(); // } // ); diff --git a/src/game-lib-entity.js b/src/game-lib-entity.js index f02a915..9f09310 100644 --- a/src/game-lib-entity.js +++ b/src/game-lib-entity.js @@ -192,11 +192,11 @@ GameLib.Entity.prototype.updateInstance = function() { * Converts a GameLib.Entity to GameLib.API.Entity * @returns {GameLib.API.Entity} */ -GameLib.Entity.prototype.toApiEntity = function() { +GameLib.Entity.prototype.toApiObject = function() { var apiComponents = this.components.map( function(component) { - return component.toApiComponent(); + return component.toApiObject(); } ); diff --git a/src/game-lib-gui.js b/src/game-lib-gui.js index c35d104..41844a2 100644 --- a/src/game-lib-gui.js +++ b/src/game-lib-gui.js @@ -4,6 +4,7 @@ * @param id * @param name * @param domElement + * @param objects * @param parentEntity * @constructor */ @@ -12,6 +13,7 @@ GameLib.GUI = function( id, name, domElement, + objects, parentEntity ) { if (GameLib.Utils.UndefinedOrNull(gui)) { @@ -45,6 +47,11 @@ GameLib.GUI = function( } this.domElement = domElement; + if (GameLib.Utils.UndefinedOrNull(objects)) { + objects = []; + } + this.objects = objects; + this.instance = this.createInstance(); }; @@ -60,11 +67,15 @@ GameLib.GUI.prototype.createInstance = function(update) { var instance = null; if (update) { - this.instance = new this.gui( { autoPlace: false } ); instance = this.instance; } else { - instance = new this.gui( { autoPlace: false } ); - } + instance = new dat.GUI( { autoPlace: false } ); + + + + + + } return instance; }; @@ -75,3 +86,68 @@ GameLib.GUI.prototype.createInstance = function(update) { GameLib.GUI.prototype.updateInstance = function() { this.instance = this.createInstance(true); }; + +GameLib.GUI.prototype.addObject = function(object) { + this.objects.push(object); +}; + +GameLib.GUI.prototype.removeObject = function(object) { + + var index = this.objects.indexOf(object); + + if (index === -1) { + console.warn('could not find object to remove'); + return false; + } else { + this.objects.splice(index, 1); + } + + return true; +}; + + +GameLib.GUI.prototype.build = function() { + + this.instance.removeAllFolders(); + + var discoveredObjects = []; + + this.objects.map( + + function(object) { + + if (object.idToObject) { + for (var property in object.idToObject) { + if (object.idToObject.hasOwnProperty(property)) { + discoveredObjects.push(object.idToObject[property]); + } + } + } + + }.bind(this) + ); + + discoveredObjects.map( + function(object) { + + var apiObject = object.toApiObject(); + + var folder = this.instance.addFolder(apiObject.name); + + for (var property in apiObject) { + if ( + apiObject.hasOwnProperty(property) && + object.hasOwnProperty(property) + ) { + + if (typeof (object[property]) === 'object') { + console.log('ignored: ' + property); + } else { + folder.add(object, property); + } + } + } + }.bind(this) + ); + +}; \ No newline at end of file diff --git a/src/game-lib-matrix-4.js b/src/game-lib-matrix-4.js index 0f79786..b54c945 100644 --- a/src/game-lib-matrix-4.js +++ b/src/game-lib-matrix-4.js @@ -144,12 +144,12 @@ GameLib.Matrix4.prototype.updateInstance = function() { * GameLib.Matrix4 to GameLib.API.Matrix4 * @returns {*} */ -GameLib.Matrix4.prototype.toApiMatrix = function () { +GameLib.Matrix4.prototype.toApiObject = function () { return this.rows.map( function(row) { if (row instanceof GameLib.Vector4) { - return row.toApiVector(); + return row.toApiObject(); } else { console.warn('Incompatible conversion to API matrix for vector: ', row); throw new Error('Incompatible conversion to API matrix for a vector'); diff --git a/src/game-lib-mouse.js b/src/game-lib-mouse.js index 9c94176..ae613e2 100644 --- a/src/game-lib-mouse.js +++ b/src/game-lib-mouse.js @@ -59,7 +59,7 @@ GameLib.Mouse.prototype.updateInstance = function() { * Converts runtime vector to API Vector * @returns {GameLib.API.Mouse} */ -GameLib.Mouse.prototype.toApiMouse = function() { +GameLib.Mouse.prototype.toApiObject = function() { return new GameLib.API.Mouse( this.id, this.name, diff --git a/src/game-lib-quaternion.js b/src/game-lib-quaternion.js index 9b98e21..60a69c5 100644 --- a/src/game-lib-quaternion.js +++ b/src/game-lib-quaternion.js @@ -100,13 +100,13 @@ GameLib.Quaternion.prototype.updateInstance = function() { * Converts runtime quaternion to API quaternion * @returns {*} */ -GameLib.Quaternion.prototype.toApiQuaternion = function() { +GameLib.Quaternion.prototype.toApiObject = function() { return new GameLib.API.Quaternion( this.x, this.y, this.z, this.w, - this.axis.toApiVector(), + this.axis.toApiObject(), this.angle ); }; diff --git a/src/game-lib-system.js b/src/game-lib-system.js index c83dad3..b38237c 100644 --- a/src/game-lib-system.js +++ b/src/game-lib-system.js @@ -103,15 +103,15 @@ GameLib.System.prototype.start = function() { function(entity) { var stats = entity.getFirstComponent(GameLib.D3.Stats); stats.instance.dom.style.position = 'absolute'; - // stats.instance.dom.style.float = 'left'; stats.instance.dom.style.top = '34px'; - stats.instance.dom.style.left = 'unset'; + stats.instance.dom.style.left = '0px'; stats.domElement.instance.parentElement.appendChild(stats.instance.dom); var gui = entity.getFirstComponent(GameLib.GUI); gui.instance.domElement.style.position = 'absolute'; gui.instance.domElement.style.top = '34px'; gui.instance.domElement.style.right = '0px'; + gui.instance.domElement.getElementsByTagName('ul')[0].style.maxHeight = window.innerHeight - 93 + 'px'; gui.domElement.instance.parentElement.appendChild(gui.instance.domElement); } ) @@ -274,16 +274,16 @@ GameLib.System.prototype.stop = function() { * Converts runtime vector to API Vector * @returns {GameLib.API.System} */ -GameLib.System.prototype.toApiSystem = function() { +GameLib.System.prototype.toApiObject = function() { var apiDomElement = null; if (this.domElement instanceof GameLib.DomElement) { - apiDomElement = this.domElement.toApiDomElement(); + apiDomElement = this.domElement.toApiObject(); } var apiDomStats = null; if (this.domStats instanceof GameLib.DomElement) { - apiDomStats = this.domStats.toApiDomElement(); + apiDomStats = this.domStats.toApiObject(); } return new GameLib.API.System( diff --git a/src/game-lib-vector2.js b/src/game-lib-vector2.js index 91649a1..4ce59fc 100644 --- a/src/game-lib-vector2.js +++ b/src/game-lib-vector2.js @@ -83,7 +83,7 @@ GameLib.Vector2.prototype.updateInstance = function() { * Converts runtime vector to API Vector * @returns {GameLib.API.Vector2} */ -GameLib.Vector2.prototype.toApiVector = function() { +GameLib.Vector2.prototype.toApiObject = function() { return new GameLib.API.Vector2( this.x, this.y diff --git a/src/game-lib-vector3.js b/src/game-lib-vector3.js index a15f865..1fd19da 100644 --- a/src/game-lib-vector3.js +++ b/src/game-lib-vector3.js @@ -87,7 +87,7 @@ GameLib.Vector3.prototype.updateInstance = function() { /** * Converts runtime vector to API Vector */ -GameLib.Vector3.prototype.toApiVector = function() { +GameLib.Vector3.prototype.toApiObject = function() { return new GameLib.API.Vector3( this.x, this.y, diff --git a/src/game-lib-vector4.js b/src/game-lib-vector4.js index 0377623..de9820c 100644 --- a/src/game-lib-vector4.js +++ b/src/game-lib-vector4.js @@ -86,7 +86,7 @@ GameLib.Vector4.prototype.updateInstance = function() { /** * Converts runtime vector to API Vector */ -GameLib.Vector4.prototype.toApiVector = function() { +GameLib.Vector4.prototype.toApiObject = function() { return new GameLib.API.Vector4( this.x, this.y,