remove coder and physics deps

beta.r3js.org
-=yb4f310 2017-10-09 12:45:29 +02:00
parent 5c5ea74e14
commit 0e1967595b
3 changed files with 82 additions and 41 deletions

View File

@ -1,17 +1,12 @@
/**
* Creates a Animation object
* @param coder
* @param apiAnimation GameLib.D3.API.Animation
* @constructor
*/
GameLib.D3.Animation = function(
coder,
apiAnimation
) {
this.coder = coder;
this.coder.isNotCodeMirrorThrow();
if (GameLib.Utils.UndefinedOrNull(apiAnimation)) {
apiAnimation = {};
}
@ -182,21 +177,28 @@ GameLib.D3.Animation.prototype.toApiObject = function() {
/**
* Converts from an Object Animation to a GameLib.D3.Animation
* @param coder GameLib.D3.Coder
* @param objectAnimation Object
* @returns {GameLib.D3.Animation}
* @constructor
*/
GameLib.D3.Animation.FromObject = function(coder, objectAnimation) {
GameLib.D3.Animation.FromObject = function(objectAnimation) {
var apiAnimation = GameLib.D3.API.Animation.FromObject(objectAnimation);
return new GameLib.D3.Animation(
coder,
apiAnimation
);
};
GameLib.D3.Animation.prototype.launchEditor = function(){
GameLib.Event.Emit(
GameLib.Event.GET_CODER_IMPLEMENTATION,
null,
function(coder) {
this.coder = coder;
this.coder.isNotCodeMirrorThrow();
}.bind(this)
);
var property = null;
if (this.functionType === GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_ROTATION) {

View File

@ -1,17 +1,12 @@
/**
* Creates a CustomCode object
* @param coder
* @param apiCustomCode GameLib.D3.API.CustomCode
* @constructor
*/
GameLib.D3.CustomCode = function(
coder,
apiCustomCode
) {
this.coder = coder;
this.coder.isNotCodeMirrorThrow();
if (GameLib.Utils.UndefinedOrNull(apiCustomCode)) {
apiCustomCode = {};
}
@ -93,22 +88,29 @@ GameLib.D3.CustomCode.prototype.toApiObject = function() {
/**
* Converts from an Object CustomCode to a GameLib.D3.CustomCode
* @param coder GameLib.D3.Coder
* @param objectCustomCode Object
* @returns {GameLib.D3.CustomCode}
* @constructor
*/
GameLib.D3.CustomCode.FromObject = function(coder, objectCustomCode) {
GameLib.D3.CustomCode.FromObject = function(objectCustomCode) {
var apiCustomCode = GameLib.D3.API.CustomCode.FromObject(objectCustomCode);
return new GameLib.D3.CustomCode(
coder,
apiCustomCode
);
};
GameLib.D3.CustomCode.prototype.launchEditor = function(){
this.editor = this.coder.instance(
GameLib.Event.Emit(
GameLib.Event.GET_CODER_IMPLEMENTATION,
null,
function(coder) {
this.coder = coder;
this.coder.isNotCodeMirrorThrow();
}.bind(this)
);
this.editor = this.coder.instance(
document.body,
{
value : this.code,

View File

@ -1,8 +1,6 @@
/**
* Storage System takes care loading and linking components and dependencies
* @param graphics
* @param physics
* @param coder
* @param apiSystem GameLib.API.System
* @param token
* @param apiUploadUrl
@ -16,8 +14,6 @@
*/
GameLib.System.Storage = function(
graphics,
physics,
coder,
apiSystem,
token,
apiUploadUrl,
@ -28,15 +24,6 @@ GameLib.System.Storage = function(
onComponentProgress,
onComponentError
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
this.physics = physics;
this.physics.isNotCannonThrow();
this.coder = coder;
this.coder.isNotCodeMirrorThrow();
GameLib.System.call(
this,
apiSystem
@ -101,7 +88,40 @@ GameLib.System.Storage.prototype.start = function() {
GameLib.System.prototype.start.call(this);
this.loginSubscription = this.subscribe(
GameLib.Event.Emit(
GameLib.Event.GET_GRAPHICS_IMPLEMENTATION,
null,
function(graphics) {
this.graphics = graphics;
}.bind(this),
function() {
this.graphics = null;
}.bind(this)
);
GameLib.Event.Emit(
GameLib.Event.GET_PHYSICS_IMPLEMENTATION,
null,
function(physics) {
this.physics = physics;
}.bind(this),
function() {
this.physics = null;
}.bind(this)
);
GameLib.Event.Emit(
GameLib.Event.GET_CODER_IMPLEMENTATION,
null,
function(coder) {
this.coder = coder;
}.bind(this),
function() {
this.coder = null;
}.bind(this)
);
this.loginSubscription = this.subscribe(
GameLib.Event.LOGGED_IN,
function(data) {
this.token = data.token;
@ -400,24 +420,41 @@ GameLib.System.Storage.prototype.loadComponent = function(apiUrl, toProcess, inc
} else {
try {
runtimeComponent = fn(component);
} catch (error) {
try {
runtimeComponent = fn(__system.coder, component);
} catch (error) {
if (__system.coder) {
try {
runtimeComponent = fn(__system.coder, component);
} catch (error) {
}
}
if (!runtimeComponent && __system.graphics) {
try {
runtimeComponent = fn(__system.graphics, component);
} catch (error) {
try {
runtimeComponent = fn(__system.physics, component);
} catch (error) {
/**
* ok - we don't cannot create this component
*/
}
}
}
if (!runtimeComponent && __system.physics) {
try {
runtimeComponent = fn(__system.physics, component);
} catch (error) {
/**
* ok - we don't cannot create this component
*/
}
}
}
if (!runtimeComponent) {
if (clientErrorCallback) {
clientErrorCallback('Could not create a runtime component: ' + component.name);