Image namespace fix

beta.r3js.org
-=yb4f310 2017-12-02 12:11:14 +01:00
parent 5506d73e56
commit e9ac1c9c9e
15 changed files with 44 additions and 49 deletions

View File

@ -410,8 +410,8 @@ GameLib.Component.GetComponentInfo = function(number) {
runtime : GameLib.Component.GUI_RUNTIME runtime : GameLib.Component.GUI_RUNTIME
}; };
case 0x1f : return { case 0x1f : return {
name : 'GameLib.D3.Image', name : 'GameLib.Image',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME
}; };
case 0x20 : return { case 0x20 : return {
name : 'GameLib.Entity', name : 'GameLib.Entity',

View File

@ -10,7 +10,7 @@
* @param parentEntity GameLib.Entity * @param parentEntity GameLib.Entity
* @constructor * @constructor
*/ */
GameLib.D3.API.Image = function( GameLib.API.Image = function(
id, id,
name, name,
fileName, fileName,
@ -74,16 +74,16 @@ GameLib.D3.API.Image = function(
this.parentEntity = parentEntity; this.parentEntity = parentEntity;
}; };
GameLib.D3.API.Image.prototype = Object.create(GameLib.Component.prototype); GameLib.API.Image.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Image.prototype.constructor = GameLib.D3.API.Image; GameLib.API.Image.prototype.constructor = GameLib.API.Image;
/** /**
* Returns an API light from an Object light * Returns an API light from an Object light
* @constructor * @constructor
* @param objectImage * @param objectImage
*/ */
GameLib.D3.API.Image.FromObject = function(objectImage) { GameLib.API.Image.FromObject = function(objectImage) {
return new GameLib.D3.API.Image( return new GameLib.API.Image(
objectImage.id, objectImage.id,
objectImage.name, objectImage.name,
objectImage.fileName, objectImage.fileName,

View File

@ -173,7 +173,7 @@ GameLib.D3.API.Scene.FromObject = function(objectScene) {
apiImages = objectScene.images.map( apiImages = objectScene.images.map(
function(objectImage) { function(objectImage) {
if (objectImage instanceof Object) { if (objectImage instanceof Object) {
return GameLib.D3.API.Image.FromObject(objectImage) return GameLib.API.Image.FromObject(objectImage)
} else { } else {
return objectImage; return objectImage;
} }

View File

@ -37,6 +37,14 @@ GameLib.D3.Broadphase = function (
GameLib.D3.Broadphase.prototype = Object.create(GameLib.D3.API.Broadphase.prototype); GameLib.D3.Broadphase.prototype = Object.create(GameLib.D3.API.Broadphase.prototype);
GameLib.D3.Broadphase.prototype.constructor = GameLib.D3.Broadphase; GameLib.D3.Broadphase.prototype.constructor = GameLib.D3.Broadphase;
/**
* Broadphase Types
* @type {number}
*/
GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE = 0x1;
GameLib.D3.Broadphase.BROADPHASE_TYPE_GRID = 0x2;
GameLib.D3.Broadphase.BROADPHASE_TYPE_SAP = 0x3;
/** /**
* *
* @returns {*} * @returns {*}
@ -112,12 +120,4 @@ GameLib.D3.Broadphase.FromObject = function(graphics, objectComponent) {
graphics, graphics,
apiBroadphase apiBroadphase
); );
}; };
/**
* Broadphase Types
* @type {number}
*/
GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE = 0x1;
GameLib.D3.Broadphase.BROADPHASE_TYPE_GRID = 0x2;
GameLib.D3.Broadphase.BROADPHASE_TYPE_SAP = 0x3;

View File

@ -114,9 +114,9 @@ GameLib.D3.Scene = function (
this.images = this.images.map( this.images = this.images.map(
function(apiImage) { function(apiImage) {
if (apiImage instanceof GameLib.D3.API.Image) { if (apiImage instanceof GameLib.API.Image) {
var image = new GameLib.D3.Image( var image = new GameLib.Image(
this.graphics, this.graphics,
apiImage apiImage
); );
@ -173,7 +173,7 @@ GameLib.D3.Scene = function (
'lights' : [GameLib.D3.Light], 'lights' : [GameLib.D3.Light],
'textures' : [GameLib.D3.Texture], 'textures' : [GameLib.D3.Texture],
'materials' : [GameLib.D3.Material], 'materials' : [GameLib.D3.Material],
'images' : [GameLib.D3.Image], 'images' : [GameLib.Image],
'fog' : GameLib.D3.Fog, 'fog' : GameLib.D3.Fog,
'renderCamera' : GameLib.D3.Camera 'renderCamera' : GameLib.D3.Camera
} }

View File

@ -63,8 +63,8 @@ GameLib.D3.Texture = function(
this this
); );
if (this.image instanceof GameLib.D3.API.Image) { if (this.image instanceof GameLib.API.Image) {
this.image = new GameLib.D3.Image( this.image = new GameLib.Image(
this.graphics, this.graphics,
this.image this.image
); );
@ -72,8 +72,8 @@ GameLib.D3.Texture = function(
this.images = this.images.map( this.images = this.images.map(
function(image) { function(image) {
if (image instanceof GameLib.D3.API.Image) { if (image instanceof GameLib.API.Image) {
return new GameLib.D3.Image( return new GameLib.Image(
this.graphics, this.graphics,
image image
); );
@ -94,8 +94,8 @@ GameLib.D3.Texture = function(
this, this,
GameLib.Component.COMPONENT_TEXTURE, GameLib.Component.COMPONENT_TEXTURE,
{ {
'image' : GameLib.D3.Image, 'image' : GameLib.Image,
'images' : [GameLib.D3.Image], 'images' : [GameLib.Image],
'canvas' : GameLib.Canvas 'canvas' : GameLib.Canvas
} }
); );

View File

@ -4,22 +4,19 @@
* @param graphics * @param graphics
* @param apiImage * @param apiImage
*/ */
GameLib.D3.Image = function( GameLib.Image = function(
graphics,
apiImage apiImage
) { ) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiImage)) { if (GameLib.Utils.UndefinedOrNull(apiImage)) {
apiImage = {}; apiImage = {};
} }
if (apiImage instanceof GameLib.D3.Image) { if (apiImage instanceof GameLib.Image) {
return apiImage; return apiImage;
} }
GameLib.D3.API.Image.call( GameLib.API.Image.call(
this, this,
apiImage.id, apiImage.id,
apiImage.name, apiImage.name,
@ -38,14 +35,14 @@ GameLib.D3.Image = function(
}; };
GameLib.D3.Image.prototype = Object.create(GameLib.D3.API.Image.prototype); GameLib.Image.prototype = Object.create(GameLib.API.Image.prototype);
GameLib.D3.Image.prototype.constructor = GameLib.D3.Image; GameLib.Image.prototype.constructor = GameLib.Image;
/** /**
* Creates an image instance * Creates an image instance
* @returns {*} * @returns {*}
*/ */
GameLib.D3.Image.prototype.createInstance = function() { GameLib.Image.prototype.createInstance = function() {
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.LOAD_IMAGE, GameLib.Event.LOAD_IMAGE,
@ -68,7 +65,7 @@ GameLib.D3.Image.prototype.createInstance = function() {
/** /**
* Updates the instance with the current state * Updates the instance with the current state
*/ */
GameLib.D3.Image.prototype.updateInstance = function(property) { GameLib.Image.prototype.updateInstance = function(property) {
if (GameLib.Utils.UndefinedOrNull(property)) { if (GameLib.Utils.UndefinedOrNull(property)) {
console.warn('unknown property update for Image: ' + property); console.warn('unknown property update for Image: ' + property);
@ -85,11 +82,11 @@ GameLib.D3.Image.prototype.updateInstance = function(property) {
/** /**
* *
* @returns {GameLib.D3.API.Image} * @returns {GameLib.API.Image}
*/ */
GameLib.D3.Image.prototype.toApiObject = function() { GameLib.Image.prototype.toApiObject = function() {
var apiImage = new GameLib.D3.API.Image( var apiImage = new GameLib.API.Image(
this.id, this.id,
this.name, this.name,
this.fileName, this.fileName,
@ -104,14 +101,12 @@ GameLib.D3.Image.prototype.toApiObject = function() {
}; };
/** /**
* @param graphics
* @param objectImage * @param objectImage
* @returns {GameLib.D3.Image} * @returns {GameLib.Image}
* @constructor * @constructor
*/ */
GameLib.D3.Image.FromObject = function(graphics, objectImage) { GameLib.Image.FromObject = function(objectImage) {
return new GameLib.D3.Image( return new GameLib.Image(
graphics, GameLib.API.Image.FromObject(objectImage)
GameLib.D3.API.Image.FromObject(objectImage)
); );
}; };

View File

@ -811,8 +811,8 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
property, property,
{ {
'naive': GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE, 'naive': GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE,
'grid': GameLib.D3.Image.BROADPHASE_TYPE_GRID, 'grid': GameLib.D3.Broadphase.BROADPHASE_TYPE_GRID,
'sap': GameLib.D3.Image.BROADPHASE_TYPE_SAP 'sap': GameLib.D3.Broadphase.BROADPHASE_TYPE_SAP
} }
) )
); );

View File

@ -580,7 +580,7 @@ GameLib.System.Linking.prototype.instanceCreated = function(data) {
this.resolveDependencies(data.component); this.resolveDependencies(data.component);
if (data.component instanceof GameLib.D3.Image) { if (data.component instanceof GameLib.Image) {
/** /**
* Find all textures which use this image * Find all textures which use this image
*/ */

View File

@ -710,7 +710,7 @@ GameLib.System.Storage.prototype.fetchComponents = function(data, clientCallback
*/ */
GameLib.System.Storage.prototype.imageUploadComplete = function(data) { GameLib.System.Storage.prototype.imageUploadComplete = function(data) {
var runtimeImages = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Image); var runtimeImages = GameLib.EntityManager.Instance.queryComponents(GameLib.Image);
/** /**
* Process all images - we have to load them in addition to creating their runtime components * Process all images - we have to load them in addition to creating their runtime components