parent particle engine
parent
3c67d28eff
commit
3f8bec4c8e
|
@ -21,7 +21,7 @@
|
||||||
* @param scaleType
|
* @param scaleType
|
||||||
* @param rotationType
|
* @param rotationType
|
||||||
* @param rotationFn
|
* @param rotationFn
|
||||||
* @param parentEngine
|
* @param parentParticleEngine
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
@ -47,7 +47,7 @@ GameLib.D3.API.Particle = function(
|
||||||
rotationType,
|
rotationType,
|
||||||
rotation,
|
rotation,
|
||||||
rotationFn,
|
rotationFn,
|
||||||
parentEngine,
|
parentParticleEngine,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -156,10 +156,10 @@ GameLib.D3.API.Particle = function(
|
||||||
}
|
}
|
||||||
this.rotationFn = rotationFn;
|
this.rotationFn = rotationFn;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(parentEngine)) {
|
if (GameLib.Utils.UndefinedOrNull(parentParticleEngine)) {
|
||||||
parentEngine = null;
|
parentParticleEngine = null;
|
||||||
}
|
}
|
||||||
this.parentEngine = parentEngine;
|
this.parentParticleEngine = parentParticleEngine;
|
||||||
|
|
||||||
GameLib.API.Component.call(
|
GameLib.API.Component.call(
|
||||||
this,
|
this,
|
||||||
|
@ -209,7 +209,7 @@ GameLib.D3.API.Particle.FromObject = function(objectParticle) {
|
||||||
objectParticle.rotationType,
|
objectParticle.rotationType,
|
||||||
GameLib.API.Vector3.FromObject(objectParticle.rotation),
|
GameLib.API.Vector3.FromObject(objectParticle.rotation),
|
||||||
objectParticle.rotationFn,
|
objectParticle.rotationFn,
|
||||||
objectParticle.parentEngine,
|
objectParticle.parentParticleEngine,
|
||||||
objectParticle.parentEntity
|
objectParticle.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -32,27 +32,17 @@ GameLib.D3.ParticleEngine = function(
|
||||||
apiParticleEngine.parentEntity
|
apiParticleEngine.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.position instanceof GameLib.API.Vector3) {
|
|
||||||
this.position = new GameLib.Vector3(
|
this.position = new GameLib.Vector3(
|
||||||
graphics,
|
graphics,
|
||||||
this.position,
|
this.position,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
console.warn('position not instance of API.Vector3');
|
|
||||||
throw new Error('position not instance of API.Vector3');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.direction instanceof GameLib.API.Vector3) {
|
|
||||||
this.direction = new GameLib.Vector3(
|
this.direction = new GameLib.Vector3(
|
||||||
graphics,
|
graphics,
|
||||||
this.direction,
|
this.direction,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
console.warn('direction not instance of API.Vector3');
|
|
||||||
throw new Error('direction not instance of API.Vector3');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.camera instanceof GameLib.D3.API.Camera) {
|
if (this.camera instanceof GameLib.D3.API.Camera) {
|
||||||
this.camera = new GameLib.D3.Camera(
|
this.camera = new GameLib.D3.Camera(
|
||||||
|
|
|
@ -39,7 +39,7 @@ GameLib.D3.Particle = function(
|
||||||
apiParticle.rotationType,
|
apiParticle.rotationType,
|
||||||
apiParticle.rotation,
|
apiParticle.rotation,
|
||||||
apiParticle.rotationFn,
|
apiParticle.rotationFn,
|
||||||
apiParticle.parentEngine,
|
apiParticle.parentParticleEngine,
|
||||||
apiParticle.parentEntity
|
apiParticle.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -50,55 +50,35 @@ GameLib.D3.Particle = function(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.positionOffset instanceof GameLib.API.Vector3) {
|
|
||||||
this.positionOffset = new GameLib.Vector3(
|
this.positionOffset = new GameLib.Vector3(
|
||||||
graphics,
|
graphics,
|
||||||
this.positionOffset,
|
this.positionOffset,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
console.warn('positionOffset not instance of API.Vector3');
|
|
||||||
throw new Error('positionOffset not instance of API.Vector3');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.direction instanceof GameLib.API.Vector3) {
|
|
||||||
this.direction = new GameLib.Vector3(
|
this.direction = new GameLib.Vector3(
|
||||||
graphics,
|
graphics,
|
||||||
this.direction,
|
this.direction,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
console.warn('direction not instance of API.Vector3');
|
|
||||||
throw new Error('direction not instance of API.Vector3');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.scale instanceof GameLib.API.Vector3) {
|
|
||||||
this.scale = new GameLib.Vector3(
|
this.scale = new GameLib.Vector3(
|
||||||
graphics,
|
graphics,
|
||||||
this.scale,
|
this.scale,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
console.warn('scale not instance of API.Vector3');
|
|
||||||
throw new Error('scale not instance of API.Vector3');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.rotation instanceof GameLib.API.Vector3) {
|
|
||||||
this.rotation = new GameLib.Vector3(
|
this.rotation = new GameLib.Vector3(
|
||||||
graphics,
|
graphics,
|
||||||
this.rotation,
|
this.rotation,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
console.warn('rotation not instance of API.Vector3');
|
|
||||||
throw new Error('rotation not instance of API.Vector3');
|
|
||||||
}
|
|
||||||
|
|
||||||
GameLib.Component.call(
|
GameLib.Component.call(
|
||||||
this,
|
this,
|
||||||
{
|
{
|
||||||
mesh : GameLib.D3.Mesh,
|
mesh : GameLib.D3.Mesh,
|
||||||
parentEngine : GameLib.D3.ParticleEngine
|
parentParticleEngine : GameLib.D3.ParticleEngine
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -198,7 +178,7 @@ GameLib.D3.Particle.prototype.cloneInstance = function() {
|
||||||
|
|
||||||
var clone = GameLib.Component.prototype.cloneInstance.call(this);
|
var clone = GameLib.Component.prototype.cloneInstance.call(this);
|
||||||
|
|
||||||
clone.position = this.parentEngine.position.instance.clone();
|
clone.position = this.parentParticleEngine.position.instance.clone();
|
||||||
|
|
||||||
clone.material = this.mesh.materials[0].instance.clone();
|
clone.material = this.mesh.materials[0].instance.clone();
|
||||||
|
|
||||||
|
@ -365,7 +345,7 @@ GameLib.D3.Particle.prototype.toApiObject = function() {
|
||||||
this.rotationType,
|
this.rotationType,
|
||||||
this.rotation.toApiObject(),
|
this.rotation.toApiObject(),
|
||||||
this.rotationFn,
|
this.rotationFn,
|
||||||
GameLib.Utils.IdOrNull(this.parentEngine),
|
GameLib.Utils.IdOrNull(this.parentParticleEngine),
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,10 @@ GameLib.EntityManager.prototype.createInstance = function() {
|
||||||
GameLib.Component.prototype.createInstance.call(this);
|
GameLib.Component.prototype.createInstance.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.EntityManager.prototype.updateInstance = function() {
|
||||||
|
console.log('todo: entitymanager updateInstance()')
|
||||||
|
};
|
||||||
|
|
||||||
GameLib.EntityManager.prototype.instanceCreated = function(data) {
|
GameLib.EntityManager.prototype.instanceCreated = function(data) {
|
||||||
if (data.component instanceof GameLib.Entity) {
|
if (data.component instanceof GameLib.Entity) {
|
||||||
this.addEntity(data.component);
|
this.addEntity(data.component);
|
||||||
|
|
|
@ -410,18 +410,23 @@ GameLib.System.Input.prototype.registerMouseControls = function(mouseControl) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: change the input mode so that when in 'edit' mode - editor controls take effect only, otherwise the normal
|
||||||
|
* TODO: keyboard / mouse /touch controls are in effect
|
||||||
|
* @param editorControl
|
||||||
|
*/
|
||||||
GameLib.System.Input.prototype.registerEditorControls = function(editorControl) {
|
GameLib.System.Input.prototype.registerEditorControls = function(editorControl) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If we already have mouse controls, we don't want to add another event listener onto the DOM
|
* In the 'Flammentraum' example, we need the mouse controls
|
||||||
*/
|
*/
|
||||||
this.mouseControls.map(
|
// this.mouseControls.map(
|
||||||
function(mouseControl) {
|
// function(mouseControl) {
|
||||||
if (mouseControl.domElement.instance === editorControl.domElement.instance) {
|
// if (mouseControl.domElement.instance === editorControl.domElement.instance) {
|
||||||
this.deRegisterMouseControls(mouseControl);
|
// this.deRegisterMouseControls(mouseControl);
|
||||||
}
|
// }
|
||||||
}.bind(this)
|
// }.bind(this)
|
||||||
);
|
// );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If we already have keyboard controls, we don't want to add another event listener onto the DOM
|
* If we already have keyboard controls, we don't want to add another event listener onto the DOM
|
||||||
|
|
|
@ -669,13 +669,13 @@ GameLib.System.Linking.prototype.instanceCreated = function(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
data.component.parentEngine &&
|
data.component.parentParticleEngine &&
|
||||||
typeof data.component.parentEngine === 'string'
|
typeof data.component.parentParticleEngine === 'string'
|
||||||
) {
|
) {
|
||||||
GameLib.EntityManager.Instance.queryComponents(GameLib.Component.PARTICLE_ENGINE).map(
|
GameLib.EntityManager.Instance.queryComponents(GameLib.Component.PARTICLE_ENGINE).map(
|
||||||
function (particleEngine) {
|
function (particleEngine) {
|
||||||
if (data.component.parentEngine === particleEngine.id) {
|
if (data.component.parentParticleEngine === particleEngine.id) {
|
||||||
data.component.parentEngine = particleEngine;
|
data.component.parentParticleEngine = particleEngine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,9 +6,6 @@
|
||||||
* @param onImageLoaded
|
* @param onImageLoaded
|
||||||
* @param onImageProgress
|
* @param onImageProgress
|
||||||
* @param onImageError
|
* @param onImageError
|
||||||
* @param onComponentLoaded
|
|
||||||
* @param onComponentProgress
|
|
||||||
* @param onComponentError
|
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.System.Storage = function(
|
GameLib.System.Storage = function(
|
||||||
|
@ -17,10 +14,7 @@ GameLib.System.Storage = function(
|
||||||
apiUploadUrl,
|
apiUploadUrl,
|
||||||
onImageLoaded,
|
onImageLoaded,
|
||||||
onImageProgress,
|
onImageProgress,
|
||||||
onImageError,
|
onImageError
|
||||||
onComponentLoaded,
|
|
||||||
onComponentProgress,
|
|
||||||
onComponentError
|
|
||||||
) {
|
) {
|
||||||
GameLib.System.call(
|
GameLib.System.call(
|
||||||
this,
|
this,
|
||||||
|
@ -53,21 +47,6 @@ GameLib.System.Storage = function(
|
||||||
}
|
}
|
||||||
this.onImageError = onImageError;
|
this.onImageError = onImageError;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(onComponentLoaded)) {
|
|
||||||
onComponentLoaded = null;
|
|
||||||
}
|
|
||||||
this.onComponentLoaded = onComponentLoaded;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(onComponentProgress)) {
|
|
||||||
onComponentProgress = null;
|
|
||||||
}
|
|
||||||
this.onComponentProgress = onComponentProgress;
|
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(onComponentError)) {
|
|
||||||
onComponentError = null;
|
|
||||||
}
|
|
||||||
this.onComponentError = onComponentError;
|
|
||||||
|
|
||||||
this.loaded = [];
|
this.loaded = [];
|
||||||
this.loading = [];
|
this.loading = [];
|
||||||
this.failed = [];
|
this.failed = [];
|
||||||
|
@ -301,10 +280,6 @@ GameLib.System.Storage.prototype.createRuntimeObject = function(responseText, cl
|
||||||
var object = JSON.parse(responseText);
|
var object = JSON.parse(responseText);
|
||||||
} catch (errorObject) {
|
} catch (errorObject) {
|
||||||
|
|
||||||
if (this.onComponentError) {
|
|
||||||
this.onComponentError(errorObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clientErrorCallback) {
|
if (clientErrorCallback) {
|
||||||
clientErrorCallback({
|
clientErrorCallback({
|
||||||
message : errorObject.message || 'JSON parse error'
|
message : errorObject.message || 'JSON parse error'
|
||||||
|
@ -321,10 +296,6 @@ GameLib.System.Storage.prototype.createRuntimeObject = function(responseText, cl
|
||||||
|
|
||||||
if (object.result !== 'success') {
|
if (object.result !== 'success') {
|
||||||
|
|
||||||
if (this.onComponentError) {
|
|
||||||
this.onComponentError(id, object);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clientErrorCallback) {
|
if (clientErrorCallback) {
|
||||||
clientErrorCallback({
|
clientErrorCallback({
|
||||||
message : object.message || 'Server load error'
|
message : object.message || 'Server load error'
|
||||||
|
@ -528,10 +499,6 @@ GameLib.System.Storage.prototype.loadComponent = function(apiUrl, toProcess, inc
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (__system.onComponentLoaded) {
|
|
||||||
__system.onComponentLoaded(runtimeComponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__system.loading.length === __system.loaded.length) {
|
if (__system.loading.length === __system.loaded.length) {
|
||||||
|
|
||||||
console.log('loaded ' + __system.loaded.length + ' components');
|
console.log('loaded ' + __system.loaded.length + ' components');
|
||||||
|
@ -552,33 +519,12 @@ GameLib.System.Storage.prototype.loadComponent = function(apiUrl, toProcess, inc
|
||||||
|
|
||||||
}(this);
|
}(this);
|
||||||
|
|
||||||
xhr.onprogress = function(__id) {
|
|
||||||
return function (progressEvent) {
|
|
||||||
|
|
||||||
var progress = 0;
|
|
||||||
|
|
||||||
if (progressEvent.total !== 0) {
|
|
||||||
progress = Math.round(Number(progressEvent.loaded / progressEvent.total) * 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.onComponentProgress) {
|
|
||||||
this.onComponentProgress(__id, progress)
|
|
||||||
}
|
|
||||||
}.bind(this);
|
|
||||||
}(id);
|
|
||||||
|
|
||||||
xhr.onerror = function(__id) {
|
xhr.onerror = function(__id) {
|
||||||
return function (error) {
|
return function (error) {
|
||||||
console.warn('component load failed for component ID ' + __id);
|
console.warn('component load failed for component ID ' + __id);
|
||||||
|
|
||||||
if (this.onComponentError) {
|
|
||||||
this.onComponentError(__id, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clientErrorCallback) {
|
if (clientErrorCallback) {
|
||||||
clientErrorCallback({
|
clientErrorCallback(error || {message:'xhr failure'})
|
||||||
message : 'xhr request failure'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
}(id);
|
}(id);
|
||||||
|
|
Loading…
Reference in New Issue