2017-01-11 16:09:06 +01:00
|
|
|
/**
|
|
|
|
* Viewport Runtime
|
|
|
|
* @param graphics GameLib.D3.Graphics
|
|
|
|
* @param apiViewport GameLib.D3.API.Viewport
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.Viewport = function (
|
|
|
|
graphics,
|
2017-02-21 18:55:18 +01:00
|
|
|
apiViewport
|
2017-01-11 16:09:06 +01:00
|
|
|
) {
|
|
|
|
|
|
|
|
this.graphics = graphics;
|
|
|
|
this.graphics.isNotThreeThrow();
|
2017-01-17 13:24:45 +01:00
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(apiViewport)) {
|
|
|
|
apiViewport = {};
|
|
|
|
}
|
|
|
|
|
2017-05-11 04:48:02 +02:00
|
|
|
if (apiViewport instanceof GameLib.D3.Viewport) {
|
|
|
|
return apiViewport;
|
|
|
|
}
|
|
|
|
|
2017-01-11 16:09:06 +01:00
|
|
|
GameLib.D3.API.Viewport.call(
|
|
|
|
this,
|
|
|
|
apiViewport.id,
|
|
|
|
apiViewport.name,
|
|
|
|
apiViewport.width,
|
|
|
|
apiViewport.height,
|
|
|
|
apiViewport.x,
|
|
|
|
apiViewport.y,
|
2017-06-06 11:25:02 +02:00
|
|
|
apiViewport.scenes,
|
2017-01-11 16:09:06 +01:00
|
|
|
apiViewport.parentEntity
|
|
|
|
);
|
|
|
|
|
2017-06-16 15:49:53 +02:00
|
|
|
GameLib.Component.call(
|
|
|
|
this,
|
|
|
|
GameLib.Component.COMPONENT_VIEWPORT,
|
|
|
|
{
|
|
|
|
'scenes' : [GameLib.D3.Scene]
|
|
|
|
}
|
|
|
|
);
|
2017-01-11 16:09:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
GameLib.D3.Viewport.prototype = Object.create(GameLib.D3.API.Viewport.prototype);
|
|
|
|
GameLib.D3.Viewport.prototype.constructor = GameLib.D3.Viewport;
|
|
|
|
|
2017-01-13 16:19:51 +01:00
|
|
|
//GameLib.D3.Viewport.VIEWPORT_TYPE_GAME = 0x1;
|
|
|
|
|
2017-01-11 16:09:06 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param update
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
|
|
|
GameLib.D3.Viewport.prototype.createInstance = function(update) {
|
|
|
|
|
|
|
|
var instance = null;
|
|
|
|
|
|
|
|
if (update) {
|
|
|
|
instance = this.instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
return instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
GameLib.D3.Viewport.prototype.updateInstance = function() {
|
|
|
|
this.instance = this.createInstance(true);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GameLib.D3.Viewport to GameLib.D3.API.Viewport
|
|
|
|
* @returns {GameLib.D3.API.Viewport}
|
|
|
|
*/
|
2017-05-16 14:51:57 +02:00
|
|
|
GameLib.D3.Viewport.prototype.toApiObject = function() {
|
2017-01-11 16:09:06 +01:00
|
|
|
|
|
|
|
var apiViewport = new GameLib.D3.API.Viewport(
|
|
|
|
this.id,
|
|
|
|
this.name,
|
|
|
|
this.width,
|
|
|
|
this.height,
|
|
|
|
this.x,
|
|
|
|
this.y,
|
2017-06-06 11:25:02 +02:00
|
|
|
this.scenes.map(function(scene){
|
|
|
|
return GameLib.Utils.IdOrNull(scene);
|
|
|
|
}),
|
2017-01-11 16:09:06 +01:00
|
|
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
|
|
|
);
|
|
|
|
|
|
|
|
return apiViewport;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GameLib.D3.Viewport from Object Viewport
|
|
|
|
* @param graphics
|
|
|
|
* @param objectComponent
|
|
|
|
* @returns {GameLib.D3.Viewport}
|
|
|
|
* @constructor
|
|
|
|
*/
|
2017-06-14 14:21:57 +02:00
|
|
|
GameLib.D3.Viewport.FromObject = function(graphics, objectComponent) {
|
2017-01-11 16:09:06 +01:00
|
|
|
|
2017-06-14 14:21:57 +02:00
|
|
|
var apiViewport = GameLib.D3.API.Viewport.FromObject(objectComponent);
|
2017-01-11 16:09:06 +01:00
|
|
|
|
|
|
|
return new GameLib.D3.Viewport(
|
|
|
|
graphics,
|
|
|
|
apiViewport
|
|
|
|
);
|
|
|
|
};
|