diff --git a/src/game-lib-a-component-a.js b/src/game-lib-a-component-a.js index f33ee82..8f3996c 100644 --- a/src/game-lib-a-component-a.js +++ b/src/game-lib-a-component-a.js @@ -479,13 +479,15 @@ GameLib.Component.prototype.buildIdToObject = function() { } if (this instanceof GameLib.D3.Scene) { - this.clones.map( - function(clone) { - if (this.idToObject.hasOwnProperty(clone.id)) { - delete this.idToObject[clone.id]; - } - }.bind(this) - ) + if (!this.storeClones) { + this.clones.map( + function (clone) { + if (this.idToObject.hasOwnProperty(clone.id)) { + delete this.idToObject[clone.id]; + } + }.bind(this) + ) + } } this.idToObject[this.id] = this; @@ -616,43 +618,6 @@ GameLib.Component.prototype.cloneInstance = function() { return clone; }; -// GameLib.Component.prototype.getStorageDependencies = function() { -// -// var dependencies = {}; -// -// for (var property in this.linkedObjects) { -// if (this.linkedObjects.hasOwnProperty(property)){ -// if (this.hasOwnProperty(property)) { -// -// if ( -// this[property] instanceof Array && -// this.linkedObjects[property] instanceof Array -// ) { -// -// if (this.linkedObjects[property].length !== 1) { -// console.log('Invalid formed argument type'); -// } -// -// dependencies[property] = this[property].map( -// function(__constructor) { -// return function(arrayProperty){ -// if (arrayProperty instanceof __constructor) { -// return GameLib.Utils.IdOrNull(arrayProperty); -// } -// }.bind(this) -// }(this.linkedObjects[property][0]) -// ); -// -// } else if (this[property] instanceof this.linkedObjects[property]) { -// dependencies[property] = GameLib.Utils.IdOrNull(this[property]); -// } -// } -// } -// } -// -// return dependencies; -// }; - GameLib.Component.prototype.saveToRemoteAPI = function() { this.save(true); }; @@ -671,14 +636,6 @@ GameLib.Component.prototype.save = function(remote) { apiObject.componentType = this.idToObject[property].componentType; - // var storageDependencies = this.idToObject[property].getStorageDependencies(); - // - // for (var storageProperty in storageDependencies) { - // if (storageDependencies.hasOwnProperty(storageProperty)) { - // apiObject[storageProperty] = storageDependencies[storageProperty]; - // } - // } - this.publish( GameLib.Event.SAVE_COMPONENT, { diff --git a/src/game-lib-d3-scene.js b/src/game-lib-d3-scene.js index ba6714b..47df724 100644 --- a/src/game-lib-d3-scene.js +++ b/src/game-lib-d3-scene.js @@ -147,6 +147,8 @@ GameLib.D3.Scene = function ( this.clones = []; + this.storeClones = false; + GameLib.Component.call( this, GameLib.Component.COMPONENT_SCENE, @@ -296,7 +298,7 @@ GameLib.D3.Scene.prototype.toApiObject = function() { /** * Do not store any cloned meshes */ - if (this.clones.indexOf(mesh) === -1) { + if ((this.clones.indexOf(mesh) === -1) || this.storeClones) { result.push(GameLib.Utils.IdOrNull(mesh)); } @@ -311,7 +313,7 @@ GameLib.D3.Scene.prototype.toApiObject = function() { /** * Do not store any cloned lights */ - if (this.clones.indexOf(light) === -1) { + if (this.clones.indexOf(light) === -1 || this.storeClones) { result.push(GameLib.Utils.IdOrNull(light)); }