store clones option

beta.r3js.org
-=yb4f310 2017-11-09 16:58:14 +01:00
parent 68e1c09557
commit ff2fd4651c
2 changed files with 13 additions and 54 deletions

View File

@ -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,
{

View File

@ -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));
}