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 * Creates a Animation object
* @param coder
* @param apiAnimation GameLib.D3.API.Animation * @param apiAnimation GameLib.D3.API.Animation
* @constructor * @constructor
*/ */
GameLib.D3.Animation = function( GameLib.D3.Animation = function(
coder,
apiAnimation apiAnimation
) { ) {
this.coder = coder;
this.coder.isNotCodeMirrorThrow();
if (GameLib.Utils.UndefinedOrNull(apiAnimation)) { if (GameLib.Utils.UndefinedOrNull(apiAnimation)) {
apiAnimation = {}; apiAnimation = {};
} }
@ -182,21 +177,28 @@ GameLib.D3.Animation.prototype.toApiObject = function() {
/** /**
* Converts from an Object Animation to a GameLib.D3.Animation * Converts from an Object Animation to a GameLib.D3.Animation
* @param coder GameLib.D3.Coder
* @param objectAnimation Object * @param objectAnimation Object
* @returns {GameLib.D3.Animation} * @returns {GameLib.D3.Animation}
* @constructor * @constructor
*/ */
GameLib.D3.Animation.FromObject = function(coder, objectAnimation) { GameLib.D3.Animation.FromObject = function(objectAnimation) {
var apiAnimation = GameLib.D3.API.Animation.FromObject(objectAnimation); var apiAnimation = GameLib.D3.API.Animation.FromObject(objectAnimation);
return new GameLib.D3.Animation( return new GameLib.D3.Animation(
coder,
apiAnimation apiAnimation
); );
}; };
GameLib.D3.Animation.prototype.launchEditor = function(){ 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; var property = null;
if (this.functionType === GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_ROTATION) { if (this.functionType === GameLib.D3.Animation.ANIMATION_FUNCTION_TYPE_ROTATION) {

View File

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

View File

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