to API Object
parent
1535237170
commit
7c9c8d19bb
|
@ -168,6 +168,7 @@ R3.Event.Emit = function(
|
|||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (clientCallback) {
|
||||
|
|
|
@ -924,12 +924,12 @@ R3.Component.prototype.toApiObject = function() {
|
|||
/**
|
||||
* Check if this property is an array of something
|
||||
*/
|
||||
if (this[property].isArray) {
|
||||
if (this[property] instanceof Array) {
|
||||
|
||||
/**
|
||||
* Quick sanity check that the apiObject also thinks this is an array
|
||||
*/
|
||||
if (!arrayObject[property].isArray) {
|
||||
if (!apiObject[property] instanceof Array) {
|
||||
throw new Error('The API Object ' + apiObject + ' does not seem to think ' + property + ' is an array');
|
||||
}
|
||||
|
||||
|
@ -944,7 +944,7 @@ R3.Component.prototype.toApiObject = function() {
|
|||
throw new Error('Please don\'t store Runtime Objects in Arrays');
|
||||
}
|
||||
|
||||
if (item.isArray) {
|
||||
if (item instanceof Array) {
|
||||
result[index] = item.reduce(
|
||||
function (subResult, subItem) {
|
||||
subResult.push(this.getPropertyValue(subItem));
|
||||
|
|
|
@ -16,8 +16,6 @@ R3.API.Controls = function(
|
|||
apiComponent.canvas = null;
|
||||
}
|
||||
this.canvas = apiComponent.canvas;
|
||||
|
||||
this.previousCanvas = this.canvas;
|
||||
};
|
||||
|
||||
R3.API.Controls.prototype = Object.create(R3.API.Component.prototype);
|
||||
|
|
|
@ -36,6 +36,7 @@ R3.API.CustomCode = function(
|
|||
"\t * Set some initialization code here\n" +
|
||||
"\t */\n" +
|
||||
"\tthis.totalTime = 0;\n" +
|
||||
"\tproject.cameras[1].position.y = 10;\n" +
|
||||
"\n" +
|
||||
"\tthis.initialized = true;\n" +
|
||||
"}\n" +
|
||||
|
@ -44,7 +45,8 @@ R3.API.CustomCode = function(
|
|||
"\n" +
|
||||
"\tthis.totalTime += project.clock.delta;\n" +
|
||||
"\t\n" +
|
||||
"\tproject.cameras[1].position.x = 4 * Math.sin(this.totalTime);\n" +
|
||||
"\tproject.cameras[1].position.x = 15 * Math.sin(this.totalTime * 0.1);\n" +
|
||||
"\tproject.cameras[1].position.z = 15 * Math.cos(this.totalTime * 0.1);\n" +
|
||||
"\tproject.cameras[1].lookAt.x = 0;\n" +
|
||||
"\tproject.cameras[1].lookAt.y = 0;\n" +
|
||||
"\tproject.cameras[1].lookAt.z = 0;\n" +
|
||||
|
|
|
@ -32,10 +32,17 @@ R3.API.Quaternion = function(
|
|||
this.w = apiComponent.w;
|
||||
|
||||
if (R3.Utils.UndefinedOrNull(apiComponent.axis)) {
|
||||
|
||||
var name = 'Quaternion Axis';
|
||||
|
||||
if (this.parent && this.parent.name) {
|
||||
name = this.parent.name + ' - Quaternion Axis';
|
||||
}
|
||||
|
||||
apiComponent.axis = new R3.API.Vector3(
|
||||
{
|
||||
parent : this.parent,
|
||||
name : this.parent.name + ' - Quaternion Axis',
|
||||
name : name,
|
||||
register : this.register
|
||||
}
|
||||
);
|
||||
|
|
|
@ -57,7 +57,13 @@ R3.D3.API.Composer = function(
|
|||
|
||||
if (R3.Utils.UndefinedOrNull(apiComponent.passes)) {
|
||||
|
||||
apiComponent.passes = this.renderer.scenes.reduce(
|
||||
var passes = [];
|
||||
|
||||
if (this.renderer && this.renderer.scenes) {
|
||||
/**
|
||||
* Construct default render passes
|
||||
*/
|
||||
passes = this.renderer.scenes.reduce(
|
||||
function(result, scene) {
|
||||
|
||||
result.push(
|
||||
|
@ -75,8 +81,10 @@ R3.D3.API.Composer = function(
|
|||
}.bind(this),
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
apiComponent.passes.push(
|
||||
if (this.renderer) {
|
||||
passes.push(
|
||||
new R3.D3.API.Pass.Bloom(
|
||||
{
|
||||
parent: this,
|
||||
|
@ -84,9 +92,11 @@ R3.D3.API.Composer = function(
|
|||
renderer: this.renderer
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
apiComponent.passes.push(
|
||||
if (this.renderer) {
|
||||
passes.push(
|
||||
new R3.D3.API.Pass.FXAA(
|
||||
{
|
||||
parent: this,
|
||||
|
@ -95,7 +105,9 @@ R3.D3.API.Composer = function(
|
|||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
apiComponent.passes = passes;
|
||||
|
||||
}
|
||||
this.passes = apiComponent.passes;
|
||||
|
|
|
@ -273,8 +273,13 @@ R3.System.Storage.prototype.save = function(data, callback, errorCallback) {
|
|||
var saved = [];
|
||||
var failed = [];
|
||||
|
||||
if (typeof XMLHttpRequest === 'undefined') {
|
||||
console.log('Implement server side save here');
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.savedSubscription || this.savedErrorSubscription) {
|
||||
console.warn('another save is in progress');
|
||||
console.warn('Another save is in progress');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -350,6 +355,7 @@ R3.System.Storage.prototype.save = function(data, callback, errorCallback) {
|
|||
);
|
||||
|
||||
var apiUrl = null;
|
||||
var apiAuthorization = null;
|
||||
|
||||
var event = R3.Event.GET_API_URL;
|
||||
|
||||
|
@ -361,10 +367,13 @@ R3.System.Storage.prototype.save = function(data, callback, errorCallback) {
|
|||
event,
|
||||
null,
|
||||
function(urlData) {
|
||||
apiUrl = urlData.apiUrl
|
||||
apiUrl = urlData.apiUrl;
|
||||
apiAuthorization = urlData.apiAuthorization;
|
||||
}
|
||||
);
|
||||
|
||||
try {
|
||||
|
||||
var apiObjects = Object.keys(data.component.idToObject).reduce(
|
||||
|
||||
function (result, componentId) {
|
||||
|
@ -381,12 +390,22 @@ R3.System.Storage.prototype.save = function(data, callback, errorCallback) {
|
|||
[]
|
||||
);
|
||||
|
||||
if (typeof XMLHttpRequest === 'undefined') {
|
||||
console.log('Implement server side save here');
|
||||
return;
|
||||
} catch (error) {
|
||||
|
||||
this.savedSubscription.remove();
|
||||
this.savedErrorSubscription.remove();
|
||||
|
||||
this.savedSubscription = null;
|
||||
this.savedErrorSubscription = null;
|
||||
|
||||
throw new Error('An error occurred during save:' + error.message);
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
apiObjects.map(
|
||||
|
||||
function(apiObject) {
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
@ -403,22 +422,8 @@ R3.System.Storage.prototype.save = function(data, callback, errorCallback) {
|
|||
|
||||
xhr.onload = function() {
|
||||
|
||||
try {
|
||||
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
|
||||
} catch (error) {
|
||||
|
||||
R3.Event.Emit(
|
||||
R3.Event.SAVE_COMPONENT_ERROR,
|
||||
{
|
||||
message: this.responseText,
|
||||
component : apiObject
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if (response.result === 'success') {
|
||||
|
||||
R3.Event.Emit(
|
||||
|
@ -453,6 +458,17 @@ R3.System.Storage.prototype.save = function(data, callback, errorCallback) {
|
|||
}
|
||||
);
|
||||
|
||||
} catch (error) {
|
||||
|
||||
R3.Event.Emit(
|
||||
R3.Event.SAVE_COMPONENT_ERROR,
|
||||
{
|
||||
message: this.responseText,
|
||||
component : apiObject
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue