particle system updates
parent
ed82c3d787
commit
3a2b045c2e
|
@ -31,7 +31,7 @@ GameLib.Event.LOGGED_IN = 0xd;
|
||||||
GameLib.Event.COMPONENT_CREATED = 0xe;
|
GameLib.Event.COMPONENT_CREATED = 0xe;
|
||||||
GameLib.Event.COMPONENT_CLONED = 0xf;
|
GameLib.Event.COMPONENT_CLONED = 0xf;
|
||||||
GameLib.Event.TEXTURE_ANIMATED_CHANGE = 0x10;
|
GameLib.Event.TEXTURE_ANIMATED_CHANGE = 0x10;
|
||||||
//GameLib.Event.PHYSICS_WORLD_INSTANCE_CREATED = 0x11;
|
GameLib.Event.ANIMATE_TEXTURE_INSTANCE = 0x11;
|
||||||
//GameLib.Event.RIGID_BODY_INSTANCE_CREATED = 0x12;
|
//GameLib.Event.RIGID_BODY_INSTANCE_CREATED = 0x12;
|
||||||
//GameLib.Event.TEXTURE_INSTANCE_CREATED = 0x13;
|
//GameLib.Event.TEXTURE_INSTANCE_CREATED = 0x13;
|
||||||
GameLib.Event.TEXTURE_INSTANCE_UPDATED = 0x14;
|
GameLib.Event.TEXTURE_INSTANCE_UPDATED = 0x14;
|
||||||
|
@ -137,8 +137,8 @@ GameLib.Event.GetEventName = function(number) {
|
||||||
case 0xd : return 'logged_in';
|
case 0xd : return 'logged_in';
|
||||||
case 0xe : return 'component_created';
|
case 0xe : return 'component_created';
|
||||||
case 0xf : return 'component_cloned';
|
case 0xf : return 'component_cloned';
|
||||||
case 0x10 : return 'texture_animated_change';//'scene_object_instance_created';
|
case 0x10 : return 'texture_animated_change';
|
||||||
case 0x11 : return 'unused';//'world_instance_created';
|
case 0x11 : return 'animate_texture_instance';
|
||||||
case 0x12 : return 'unused';//'rigid_body_instance_created';
|
case 0x12 : return 'unused';//'rigid_body_instance_created';
|
||||||
case 0x13 : return 'unused';//'texture_instance_created';
|
case 0x13 : return 'unused';//'texture_instance_created';
|
||||||
case 0x14 : return 'texture_instance_updated';
|
case 0x14 : return 'texture_instance_updated';
|
||||||
|
|
|
@ -44,7 +44,8 @@ GameLib.D3.API.Mesh = function(
|
||||||
parentEntity,
|
parentEntity,
|
||||||
renderOrder,
|
renderOrder,
|
||||||
isBufferMesh,
|
isBufferMesh,
|
||||||
useQuaternion
|
useQuaternion,
|
||||||
|
visible
|
||||||
) {
|
) {
|
||||||
if (GameLib.Utils.UndefinedOrNull(id)) {
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||||||
id = GameLib.Utils.RandomId();
|
id = GameLib.Utils.RandomId();
|
||||||
|
@ -150,6 +151,11 @@ GameLib.D3.API.Mesh = function(
|
||||||
useQuaternion = true;
|
useQuaternion = true;
|
||||||
}
|
}
|
||||||
this.useQuaternion = useQuaternion;
|
this.useQuaternion = useQuaternion;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(visible)) {
|
||||||
|
visible = true;
|
||||||
|
}
|
||||||
|
this.visible = visible;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.Mesh.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.D3.API.Mesh.prototype = Object.create(GameLib.Component.prototype);
|
||||||
|
@ -252,6 +258,7 @@ GameLib.D3.API.Mesh.FromObject = function (objectMesh){
|
||||||
objectMesh.parentEntity,
|
objectMesh.parentEntity,
|
||||||
objectMesh.renderOrder,
|
objectMesh.renderOrder,
|
||||||
objectMesh.isBufferMesh,
|
objectMesh.isBufferMesh,
|
||||||
objectMesh.useQuaternion
|
objectMesh.useQuaternion,
|
||||||
|
objectMesh.visible
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,7 +41,8 @@ GameLib.D3.Mesh = function (
|
||||||
apiMesh.parentEntity,
|
apiMesh.parentEntity,
|
||||||
apiMesh.renderOrder,
|
apiMesh.renderOrder,
|
||||||
apiMesh.isBufferMesh,
|
apiMesh.isBufferMesh,
|
||||||
apiMesh.useQuaternion
|
apiMesh.useQuaternion,
|
||||||
|
apiMesh.visible
|
||||||
);
|
);
|
||||||
|
|
||||||
this.faces = this.faces.map(
|
this.faces = this.faces.map(
|
||||||
|
@ -553,6 +554,8 @@ GameLib.D3.Mesh.prototype.createInstance = function() {
|
||||||
|
|
||||||
this.instance.renderOrder = this.renderOrder;
|
this.instance.renderOrder = this.renderOrder;
|
||||||
|
|
||||||
|
this.instance.visible = this.visible;
|
||||||
|
|
||||||
GameLib.Component.prototype.createInstance.call(this);
|
GameLib.Component.prototype.createInstance.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -615,6 +618,10 @@ GameLib.D3.Mesh.prototype.updateInstance = function(property) {
|
||||||
this.removeHelper();
|
this.removeHelper();
|
||||||
this.createHelper();
|
this.createHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (property === 'visible') {
|
||||||
|
this.instance.visible = this.visible;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1041,7 +1048,8 @@ GameLib.D3.Mesh.prototype.toApiObject = function() {
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity),
|
GameLib.Utils.IdOrNull(this.parentEntity),
|
||||||
this.renderOrder,
|
this.renderOrder,
|
||||||
this.isBufferMesh,
|
this.isBufferMesh,
|
||||||
this.useQuaternion
|
this.useQuaternion,
|
||||||
|
this.visible
|
||||||
);
|
);
|
||||||
|
|
||||||
return apiMesh;
|
return apiMesh;
|
||||||
|
|
|
@ -73,7 +73,7 @@ GameLib.D3.Mesh.Box.prototype.createInstance = function() {
|
||||||
this.instance.userData.depth = this.depth;
|
this.instance.userData.depth = this.depth;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Mesh.Box.prototype.updateInstance = function() {
|
GameLib.D3.Mesh.Box.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.instance.userData.width !== this.width ||
|
this.instance.userData.width !== this.width ||
|
||||||
|
@ -97,7 +97,7 @@ GameLib.D3.Mesh.Box.prototype.updateInstance = function() {
|
||||||
this.instance.geometry = geometry;
|
this.instance.geometry = geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.updateInstance.call(this);
|
GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ GameLib.D3.Mesh.Cylinder.prototype.createInstance = function() {
|
||||||
this.instance.userData.thetaLength = this.thetaLength;
|
this.instance.userData.thetaLength = this.thetaLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Mesh.Cylinder.prototype.updateInstance = function() {
|
GameLib.D3.Mesh.Cylinder.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.instance.userData.radiusTop !== this.radiusTop ||
|
this.instance.userData.radiusTop !== this.radiusTop ||
|
||||||
|
@ -156,7 +156,7 @@ GameLib.D3.Mesh.Cylinder.prototype.updateInstance = function() {
|
||||||
this.instance.geometry = geometry;
|
this.instance.geometry = geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.updateInstance.call(this);
|
GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -57,11 +57,11 @@ GameLib.D3.Mesh.Line.prototype.createInstance = function() {
|
||||||
this.instance.userData.lineWidth = this.lineWidth;
|
this.instance.userData.lineWidth = this.lineWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Mesh.Line.prototype.updateInstance = function() {
|
GameLib.D3.Mesh.Line.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
this.instance.linewidth = this.lineWidth;
|
this.instance.linewidth = this.lineWidth;
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.updateInstance.call(this);
|
GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ GameLib.D3.Mesh.Plane.prototype.createInstance = function() {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Mesh.Plane.prototype.updateInstance = function() {
|
GameLib.D3.Mesh.Plane.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
var geometry = null;
|
var geometry = null;
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ GameLib.D3.Mesh.Plane.prototype.updateInstance = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.updateInstance.call(this);
|
GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -73,7 +73,7 @@ GameLib.D3.Mesh.Sphere.prototype.createInstance = function() {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Mesh.Sphere.prototype.updateInstance = function() {
|
GameLib.D3.Mesh.Sphere.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.instance.userData.widthSegments !== this.widthSegments ||
|
this.instance.userData.widthSegments !== this.widthSegments ||
|
||||||
|
@ -98,7 +98,7 @@ GameLib.D3.Mesh.Sphere.prototype.updateInstance = function() {
|
||||||
this.instance.geometry = geometry;
|
this.instance.geometry = geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.updateInstance.call(this);
|
GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ GameLib.D3.Mesh.Text.prototype.createInstance = function() {
|
||||||
this.instance.userData.bevelSegments = this.bevelSegments;
|
this.instance.userData.bevelSegments = this.bevelSegments;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.Mesh.Text.prototype.updateInstance = function() {
|
GameLib.D3.Mesh.Text.prototype.updateInstance = function(property) {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.instance.userData.text !== this.text ||
|
this.instance.userData.text !== this.text ||
|
||||||
|
@ -175,7 +175,7 @@ GameLib.D3.Mesh.Text.prototype.updateInstance = function() {
|
||||||
this.instance.geometry = geometry;
|
this.instance.geometry = geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.Mesh.prototype.updateInstance.call(this);
|
GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,8 @@ GameLib.D3.Particle.SCALE_TYPE_CONSTANT = 0x1;
|
||||||
GameLib.D3.Particle.SCALE_TYPE_LINEAR = 0x2;
|
GameLib.D3.Particle.SCALE_TYPE_LINEAR = 0x2;
|
||||||
GameLib.D3.Particle.SCALE_TYPE_EXPONENTIAL = 0x3;
|
GameLib.D3.Particle.SCALE_TYPE_EXPONENTIAL = 0x3;
|
||||||
GameLib.D3.Particle.SCALE_TYPE_RANDOM = 0x4;
|
GameLib.D3.Particle.SCALE_TYPE_RANDOM = 0x4;
|
||||||
GameLib.D3.Particle.SCALE_TYPE_FUNCTION = 0x5;
|
GameLib.D3.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y = 0x6;
|
||||||
|
GameLib.D3.Particle.SCALE_TYPE_FUNCTION = 0x7;
|
||||||
|
|
||||||
GameLib.D3.Particle.ROTATION_TYPE_CONSTANT = 0x1;
|
GameLib.D3.Particle.ROTATION_TYPE_CONSTANT = 0x1;
|
||||||
GameLib.D3.Particle.ROTATION_TYPE_RANDOM = 0x2;
|
GameLib.D3.Particle.ROTATION_TYPE_RANDOM = 0x2;
|
||||||
|
@ -147,32 +148,31 @@ GameLib.D3.Particle.prototype.createInstance = function() {
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Particle.prototype.updateInstance = function(property) {
|
GameLib.D3.Particle.prototype.updateInstance = function(property) {
|
||||||
console.log('Update Particle Property : ' + property);
|
console.log('Update Particle Property : ' + property);
|
||||||
|
|
||||||
|
if (this.scaleType === GameLib.D3.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y) {
|
||||||
|
console.log(property);
|
||||||
|
// this.scale.y = this.scale.x;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones a particle - this only clones 3rd party instances, so we have less overhead of creating these types of objects
|
* Clones a particle - this only clones 3rd party instances, so we have less overhead of creating these types of objects
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Particle.prototype.clone = function(camera) {
|
// GameLib.D3.Particle.prototype.clone = function() {
|
||||||
|
//
|
||||||
var position = camera.instance.position.clone();
|
// var clone = GameLib.Component.prototype.clone.call(this);
|
||||||
var lookAt = camera.lookAt.instance.clone();
|
//
|
||||||
|
// clone.mesh = this.mesh.clone();
|
||||||
var direction = lookAt.sub(position).negate();
|
//
|
||||||
|
// return clone;
|
||||||
this.instance.visible = false;
|
// //var material = this.mesh.materials[0].clone();
|
||||||
|
//
|
||||||
var instance = this.instance.clone();
|
// //var texture = material.diffuseMap.clone();
|
||||||
instance.visible = true;
|
//
|
||||||
|
// //this.mesh.materials =
|
||||||
instance.lookAt(direction);
|
//
|
||||||
|
// };
|
||||||
instance.userData.direction = this.direction.instance.clone();
|
|
||||||
instance.userData.elapsed = 0;
|
|
||||||
instance.userData.lifeTime = this.lifeTime;
|
|
||||||
this.mesh.parentScene.instance.add(instance);
|
|
||||||
return instance;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a GameLib.D3.Particle to a new GameLib.D3.API.Particle
|
* Converts a GameLib.D3.Particle to a new GameLib.D3.API.Particle
|
||||||
|
|
|
@ -481,6 +481,8 @@ GameLib.D3.Scene.prototype.addClone = function(component) {
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.Utils.PushUnique(this.clones, component);
|
GameLib.Utils.PushUnique(this.clones, component);
|
||||||
|
|
||||||
|
component.parentScene = this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,17 @@ GameLib.System.Animation = function(
|
||||||
this.latest = {};
|
this.latest = {};
|
||||||
this.textures = {};
|
this.textures = {};
|
||||||
this.textureIds = [];
|
this.textureIds = [];
|
||||||
|
|
||||||
|
this.animationMeshAddedSubscription = null;
|
||||||
|
this.animationMeshRemovedSubscription = null;
|
||||||
|
this.instanceCreatedSubscription = null;
|
||||||
|
this.removeComponentSubscription = null;
|
||||||
|
this.textureAnimatedSubscription = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sometimes we want to animate texture instances directly, without the overhead of a GameLib.Texture
|
||||||
|
*/
|
||||||
|
this.animateTextureInstanceSubscription = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.Animation.prototype = Object.create(GameLib.System.prototype);
|
GameLib.System.Animation.prototype = Object.create(GameLib.System.prototype);
|
||||||
|
@ -67,6 +78,11 @@ GameLib.System.Animation.prototype.start = function() {
|
||||||
GameLib.Event.TEXTURE_ANIMATED_CHANGE,
|
GameLib.Event.TEXTURE_ANIMATED_CHANGE,
|
||||||
this.textureAnimatedChange.bind(this)
|
this.textureAnimatedChange.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.animateTextureInstanceSubscription = GameLib.Event.Subscribe(
|
||||||
|
GameLib.Event.ANIMATE_TEXTURE_INSTANCE,
|
||||||
|
this.animateTextureInstance.bind(this)
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.Animation.prototype.instanceCreated = function(data) {
|
GameLib.System.Animation.prototype.instanceCreated = function(data) {
|
||||||
|
@ -137,6 +153,32 @@ GameLib.System.Animation.prototype.textureAnimatedChange = function(data) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This adds a texture instance directly on our textures to be animated - to bypass our GameLib component and linking
|
||||||
|
* system, which adds too much overhead for managing textures
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
GameLib.System.Animation.prototype.animateTextureInstance = function(data) {
|
||||||
|
|
||||||
|
if (data.texture.repeat.x > 1 || data.texture.repeat.x < 0) {
|
||||||
|
console.warn('cannot animate a texture with repeat.x greater than 1 or less than 0');
|
||||||
|
data.texture.userData.animated = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.texture.repeat.y > 1 || data.texture.repeat.y < 0) {
|
||||||
|
console.warn('cannot animate a texture with repeat.y greater than 1 or less than 0');
|
||||||
|
data.texture.userData.animated = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.texture.userData.animated = true;
|
||||||
|
|
||||||
|
this.textures[data.texture.id] = data.texture;
|
||||||
|
this.textureIds = Object.keys(this.textures);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
GameLib.System.Animation.prototype.beforeRender = function(data) {
|
GameLib.System.Animation.prototype.beforeRender = function(data) {
|
||||||
|
|
||||||
if (this.paused) {
|
if (this.paused) {
|
||||||
|
@ -231,15 +273,21 @@ GameLib.System.Animation.prototype.beforeRender = function(data) {
|
||||||
|
|
||||||
var texture = this.textures[textureId];
|
var texture = this.textures[textureId];
|
||||||
|
|
||||||
if (texture.reverseAnimation) {
|
if (texture.reverseAnimation || (texture.userData && texture.userData.reverseAnimation)) {
|
||||||
|
|
||||||
if (texture.forward) {
|
if (texture.forward === true || (texture.userData && texture.userData.forward === true)) {
|
||||||
texture.offset.x += texture.repeat.x;
|
texture.offset.x += texture.repeat.x;
|
||||||
if (texture.offset.x >= (1 - texture.repeat.x)) {
|
if (texture.offset.x >= (1 - texture.repeat.x)) {
|
||||||
if (texture.offset.y >= (1 - texture.repeat.y)) {
|
if (texture.offset.y >= (1 - texture.repeat.y)) {
|
||||||
texture.offset.x = (1 - texture.repeat.x);
|
texture.offset.x = (1 - texture.repeat.x);
|
||||||
texture.offset.y = (1 - texture.repeat.y);
|
texture.offset.y = (1 - texture.repeat.y);
|
||||||
texture.forward = false;
|
|
||||||
|
if (texture.userData) {
|
||||||
|
texture.userData.forward = false;
|
||||||
|
} else {
|
||||||
|
texture.forward = false;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
texture.offset.x = 0;
|
texture.offset.x = 0;
|
||||||
texture.offset.y += texture.repeat.y;
|
texture.offset.y += texture.repeat.y;
|
||||||
|
@ -247,14 +295,18 @@ GameLib.System.Animation.prototype.beforeRender = function(data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!texture.forward) {
|
if (texture.forward === false || (texture.userData && texture.userData.forward === false)) {
|
||||||
texture.offset.x -= texture.repeat.x;
|
texture.offset.x -= texture.repeat.x;
|
||||||
if (texture.offset.x <= 0) {
|
if (texture.offset.x <= 0) {
|
||||||
texture.offset.x = 0;
|
texture.offset.x = 0;
|
||||||
if (texture.offset.y < texture.repeat.y) {
|
if (texture.offset.y < texture.repeat.y) {
|
||||||
texture.offset.x = texture.repeat.x;
|
texture.offset.x = texture.repeat.x;
|
||||||
texture.offset.y = 0;
|
texture.offset.y = 0;
|
||||||
texture.forward = true;
|
if (texture.userData) {
|
||||||
|
texture.userData.forward = true;
|
||||||
|
} else {
|
||||||
|
texture.forward = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
texture.offset.x = (1 - texture.repeat.x);
|
texture.offset.x = (1 - texture.repeat.x);
|
||||||
texture.offset.y -= texture.repeat.y;
|
texture.offset.y -= texture.repeat.y;
|
||||||
|
@ -278,7 +330,9 @@ GameLib.System.Animation.prototype.beforeRender = function(data) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
texture.updateInstance('offset');
|
if (!texture.userData) {
|
||||||
|
texture.updateInstance('offset');
|
||||||
|
}
|
||||||
|
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
)
|
)
|
||||||
|
@ -1083,5 +1137,7 @@ GameLib.System.Animation.prototype.stop = function() {
|
||||||
this.removeComponentSubscription.remove();
|
this.removeComponentSubscription.remove();
|
||||||
|
|
||||||
this.textureAnimatedSubscription.remove();
|
this.textureAnimatedSubscription.remove();
|
||||||
|
|
||||||
|
this.animateTextureInstanceSubscription.remove();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -748,6 +748,7 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
'linear': GameLib.D3.Particle.SCALE_TYPE_LINEAR,
|
'linear': GameLib.D3.Particle.SCALE_TYPE_LINEAR,
|
||||||
'exponential': GameLib.D3.Particle.SCALE_TYPE_EXPONENTIAL,
|
'exponential': GameLib.D3.Particle.SCALE_TYPE_EXPONENTIAL,
|
||||||
'random': GameLib.D3.Particle.SCALE_TYPE_RANDOM,
|
'random': GameLib.D3.Particle.SCALE_TYPE_RANDOM,
|
||||||
|
'random (x = y)': GameLib.D3.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y,
|
||||||
'function': GameLib.D3.Particle.SCALE_TYPE_FUNCTION
|
'function': GameLib.D3.Particle.SCALE_TYPE_FUNCTION
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -525,6 +525,10 @@ GameLib.System.Linking.prototype.removeComponent = function(data) {
|
||||||
if (component instanceof GameLib.Entity) {
|
if (component instanceof GameLib.Entity) {
|
||||||
GameLib.EntityManager.Instance.removeEntity(component);
|
GameLib.EntityManager.Instance.removeEntity(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (component instanceof GameLib.D3.Particle) {
|
||||||
|
// // component.mesh.parentScene.removeObject(component.mesh);
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.Linking.prototype.imageChanged = function(data) {
|
GameLib.System.Linking.prototype.imageChanged = function(data) {
|
||||||
|
@ -560,15 +564,15 @@ GameLib.System.Linking.prototype.arrayItemAdded = function(data) {
|
||||||
|
|
||||||
GameLib.System.Linking.prototype.instanceCloned = function(data) {
|
GameLib.System.Linking.prototype.instanceCloned = function(data) {
|
||||||
|
|
||||||
if (data.component instanceof GameLib.D3.Particle) {
|
// if (data.component instanceof GameLib.D3.Particle) {
|
||||||
|
//
|
||||||
var mesh = data.component.mesh;
|
// var mesh = data.component.mesh;
|
||||||
|
//
|
||||||
if (mesh.parentScene && mesh.parentScene.instance) {
|
// if (mesh.parentScene && mesh.parentScene.instance) {
|
||||||
data.instance.userData.scene = mesh.parentScene.instance;
|
// data.instance.userData.scene = mesh.parentScene.instance;
|
||||||
mesh.parentScene.instance.add(data.instance);
|
// mesh.parentScene.instance.add(data.instance);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -126,10 +126,19 @@ GameLib.System.Particle.prototype.beforeRender = function(data) {
|
||||||
particle.position.y += particle.userData.direction.y * data.delta * particle.userData.speed;
|
particle.position.y += particle.userData.direction.y * data.delta * particle.userData.speed;
|
||||||
particle.position.z += particle.userData.direction.z * data.delta * particle.userData.speed;
|
particle.position.z += particle.userData.direction.z * data.delta * particle.userData.speed;
|
||||||
|
|
||||||
|
particle.scale.x += particle.userData.scale.x * data.delta;
|
||||||
|
particle.scale.y += particle.userData.scale.x * data.delta;
|
||||||
|
particle.scale.z += particle.userData.scale.x * data.delta;
|
||||||
|
|
||||||
particle.quaternion.copy(particleEngine.camera.instance.quaternion);
|
particle.quaternion.copy(particleEngine.camera.instance.quaternion);
|
||||||
|
|
||||||
|
particle.material.opacity -= 0.033333;
|
||||||
|
|
||||||
particle.userData.elapsed += data.delta;
|
particle.userData.elapsed += data.delta;
|
||||||
if (particle.userData.elapsed > particle.userData.lifeTime) {
|
if (
|
||||||
|
particle.userData.elapsed > particle.userData.lifeTime ||
|
||||||
|
particle.material.opacity < 0
|
||||||
|
) {
|
||||||
particle.userData.scene.remove(particle);
|
particle.userData.scene.remove(particle);
|
||||||
} else {
|
} else {
|
||||||
result.push(particle);
|
result.push(particle);
|
||||||
|
@ -146,14 +155,119 @@ GameLib.System.Particle.prototype.beforeRender = function(data) {
|
||||||
|
|
||||||
particleEngine.elapsed = 0;
|
particleEngine.elapsed = 0;
|
||||||
|
|
||||||
var particleInstance = particleEngine.templateParticle.cloneInstance();
|
var particle = particleEngine.templateParticle;
|
||||||
|
|
||||||
//particleEngine.templateParticle.parentScene.instance.add(particleInstance);
|
var particleInstance = particle.cloneInstance();
|
||||||
|
|
||||||
|
particleInstance.visible = true;
|
||||||
|
|
||||||
|
// var texture = particleEngine.templateParticle.mesh.materials[0].diffuseMap.clone();
|
||||||
|
//
|
||||||
|
// texture.offset.x = 0;
|
||||||
|
// texture.offset.y = 0;
|
||||||
|
// texture.updateInstance('offset');
|
||||||
|
//
|
||||||
|
// var material = particleEngine.templateParticle.mesh.materials[0].instance.clone();
|
||||||
|
//
|
||||||
|
// material.map = texture.instance;
|
||||||
|
//
|
||||||
|
// particleInstance.material = material;
|
||||||
|
|
||||||
|
|
||||||
|
// var texture = .clone();
|
||||||
|
//image.instance);
|
||||||
|
|
||||||
|
// texture.repeat.x = particleEngine.templateParticle.mesh.materials[0].diffuseMap.repeat.x;
|
||||||
|
// texture.repeat.y = particleEngine.templateParticle.mesh.materials[0].diffuseMap.repeat.y;
|
||||||
|
|
||||||
|
// texture.offset.x = particleEngine.templateParticle.mesh.materials[0].diffuseMap.offset.x;
|
||||||
|
// texture.offset.y = particleEngine.templateParticle.mesh.materials[0].diffuseMap.offset.y;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ok - here we have a problem - we cannot reliably clone textures without a call to texture.needsUpdate,
|
||||||
|
* which recompiles the shader and slows down the particle system - dramatically
|
||||||
|
* @type {THREE.MeshBasicMaterial}
|
||||||
|
*/
|
||||||
|
|
||||||
|
particleInstance.material = new THREE.MeshBasicMaterial(
|
||||||
|
{
|
||||||
|
map : particle.mesh.materials[0].diffuseMap.instance,
|
||||||
|
transparent : true,
|
||||||
|
opacity : 1.0,
|
||||||
|
depthWrite : false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (particle.positionOffsetType === GameLib.D3.Particle.POSITION_OFFSET_TYPE_CONSTANT) {
|
||||||
|
particleInstance.position.x += particle.positionOffset.x;
|
||||||
|
particleInstance.position.y += particle.positionOffset.y;
|
||||||
|
particleInstance.position.z += particle.positionOffset.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
var add = 1;
|
||||||
|
|
||||||
|
if (particle.positionOffsetType === GameLib.D3.Particle.POSITION_OFFSET_TYPE_RANDOM) {
|
||||||
|
|
||||||
|
add = GameLib.Utils.GetRandomIntInclusive(1,2);
|
||||||
|
|
||||||
|
if (add === 1) {
|
||||||
|
particleInstance.position.x += Math.random() * particle.positionOffset.x;
|
||||||
|
particleInstance.position.y += Math.random() * particle.positionOffset.y;
|
||||||
|
particleInstance.position.z += Math.random() * particle.positionOffset.z;
|
||||||
|
} else {
|
||||||
|
particleInstance.position.x -= Math.random() * particle.positionOffset.x;
|
||||||
|
particleInstance.position.y -= Math.random() * particle.positionOffset.y;
|
||||||
|
particleInstance.position.z -= Math.random() * particle.positionOffset.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (particle.scaleType === GameLib.D3.Particle.SCALE_TYPE_CONSTANT) {
|
||||||
|
particleInstance.scale.x = particle.scale.x;
|
||||||
|
particleInstance.scale.y = particle.scale.y;
|
||||||
|
particleInstance.scale.z = particle.scale.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (particle.scaleType === GameLib.D3.Particle.SCALE_TYPE_RANDOM) {
|
||||||
|
|
||||||
|
add = GameLib.Utils.GetRandomIntInclusive(1,2);
|
||||||
|
|
||||||
|
if (add === 1) {
|
||||||
|
particleInstance.scale.x += Math.random() * particle.scale.x;
|
||||||
|
particleInstance.scale.y += Math.random() * particle.scale.y;
|
||||||
|
particleInstance.scale.z += Math.random() * particle.scale.z;
|
||||||
|
} else {
|
||||||
|
particleInstance.scale.x -= Math.random() * particle.scale.x;
|
||||||
|
particleInstance.scale.y -= Math.random() * particle.scale.y;
|
||||||
|
particleInstance.scale.z -= Math.random() * particle.scale.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (particle.scaleType === GameLib.D3.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y) {
|
||||||
|
|
||||||
|
add = GameLib.Utils.GetRandomIntInclusive(1,2);
|
||||||
|
|
||||||
|
var factor = Math.random() * particle.scale.x;
|
||||||
|
|
||||||
|
if (add === 1) {
|
||||||
|
particleInstance.scale.x += factor;
|
||||||
|
particleInstance.scale.y += factor;
|
||||||
|
particleInstance.scale.z += Math.random() * particle.scale.z;
|
||||||
|
} else {
|
||||||
|
particleInstance.scale.x -= factor;
|
||||||
|
particleInstance.scale.y -= factor;
|
||||||
|
particleInstance.scale.z -= Math.random() * particle.scale.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
particleInstance.userData.direction = particle.direction.clone();
|
||||||
|
particleInstance.userData.scale = particle.scale.clone();
|
||||||
|
particleInstance.userData.lifeTime = particle.lifeTime;
|
||||||
|
particleInstance.userData.speed = particle.speed;
|
||||||
|
particleInstance.userData.scene = particle.mesh.parentScene.instance;
|
||||||
|
|
||||||
particleInstance.userData.direction = particleEngine.direction.instance.clone();
|
|
||||||
particleInstance.userData.elapsed = 0;
|
particleInstance.userData.elapsed = 0;
|
||||||
particleInstance.userData.lifeTime = particleEngine.templateParticle.lifeTime;
|
|
||||||
particleInstance.userData.speed = particleEngine.templateParticle.speed;
|
particleInstance.userData.scene.add(particleInstance);
|
||||||
|
|
||||||
particleEngine.particles.push(particleInstance);
|
particleEngine.particles.push(particleInstance);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue