i have error when i tried use submesh by cloned mesh as emiter for particleSystem.
other view
code to create particleSystem (yellow particleSystem)
setTurbines(){
// console.log( this.mesh._children );
// return;
// //obtener las turbinas de mi mesh...
if( utils.ships[this.ship].mode_turbine == "single" ){
//a single turbine
this.turbine_center ={};
}else{
for(let _k =0; _k < 3; _k+=1){
for(let _u=0; _u < scene.meshes.length;_u+=1){
// console.log( scene.meshes[_u].name+", mi ship "+this.ship );
if( scene.meshes[_u].name.includes(this.nombre+"_sh."+this.ship+"_turbina") & (this.turbines[_k] == null | this.turbines[_k] == undefined) ){
//navee
console.log( "AAAA" );
if( !this.ids.includes( scene.meshes[_u].name) ){
this.ids.push( scene.meshes[_u].name);
this.turbines_index.push(scene.meshes[_u].name);
console.log( this.ids );
this.turbines[_k] = new BABYLON.ParticleSystem("particle_"+this.nombre+"-"+scene.meshes[_u].name, 500, scene);
console.log( _k+"up turbinaa "+ scene.meshes[_u].name);
//
//Texture of each particle
this.turbines[_k].particleTexture = new BABYLON.Texture("/textures/flare.png", scene);
this.turbines[_k].emitter = scene.meshes[_u];
// console.log( this.turbines[_k].emitter );
// this.turbines[_k].worldOffset = new BABYLON.Vector3(-2, 0, 0);
this.turbines[_k].minEmitBox = new BABYLON.Vector3(-0.1, 0, 0); // Starting all from
this.turbines[_k].maxEmitBox = new BABYLON.Vector3(0.1, 0, 0); // To...
// Colors of all particles
this.turbines[_k].color1 = new BABYLON.Color4(0.7, 0.0, 0.0, 1.0);
this.turbines[_k].color2 = new BABYLON.Color4(0.2, 0.0, 0.0, 1.0);
this.turbines[_k].colorDead = new BABYLON.Color4(0.2, 0.2, 0.2, 0.0);
// Size of each particle (random between...
this.turbines[_k].minSize = 0.3;
this.turbines[_k].maxSize = 0.8;
// Life time of each particle (random between...
this.turbines[_k].minLifeTime = 0.2;
this.turbines[_k].maxLifeTime = 0.4;
// Emission rate
this.turbines[_k].emitRate = 50;
// Blend mode : BLENDMODE_ONEONE, or BLENDMODE_STANDARD
this.turbines[_k].blendMode = BABYLON.ParticleSystem.BLENDMODE_ONEONE;
// Set the gravity of all particles
this.turbines[_k].gravity = new BABYLON.Vector3(0, -10, 0);
// Direction of each particle after it has been emitted
this.turbines[_k].direction1 = new BABYLON.Vector3(0, 5, 0);
this.turbines[_k].direction2 = new BABYLON.Vector3(0, 5, 0);
// Angular speed, in radians
this.turbines[_k].minAngularSpeed = 0;
this.turbines[_k].maxAngularSpeed = Math.PI;
// Speed
this.turbines[_k].minEmitPower = 1;
this.turbines[_k].maxEmitPower = 3;
this.turbines[_k].updateSpeed = 0.01;
this.turbines[_k].isLocal = true;
this.turbines[_k].isVisible=true;
// Start the particle system
this.turbines[_k].start();
}
}
}
}
}
}
above: iterate over all meshes by scene, qhen i find appropiatte mesh, u tried to use as emitter.
when i see thap position is bad, in update i tried this (blue particleSystem) :
update(){
//actualizacion de posicion de turbina emiter
if( game.key != "" ){
// let matrix = this.mesh.computeWorldMatrix(true); // force calculation of world matrix
// let local_pos = new BABYLON.Vector3(0,0,-3); //top middle of box relative to box
// let global_pos = BABYLON.Vector3.TransformCoordinates(local_pos, matrix); //calculate world position
// console.log( global_pos );
// this.turbines[0].emitter = global_pos;
scene.meshes.forEach(_mesh => {
// console.log( m.name );
this.turbines_index.forEach(_name =>{
if( _mesh.name == _name ){
//
switch(this.ship){
case "raptor":
let matrix = _mesh.computeWorldMatrix(true); // force calculation of world matrix
let local_pos = new BABYLON.Vector3(0.46,1.2,0.1);
let global_pos = BABYLON.Vector3.TransformCoordinates(local_pos, matrix);
// console.log( global_pos );
this.turbines[0].emitter = global_pos;
this.turbines[0].isLocal = true;
this.turbines[0].gravity = new BABYLON.Vector3(0, 0, -0);
this.turbines[0].direction1 = new BABYLON.Vector3(0, 0, 5);
this.turbines[0].direction2 = new BABYLON.Vector3(0, 0, 5);
this.turbines[0].minAngularSpeed = 0;
this.turbines[0].maxAngularSpeed = Math.PI;
// Speed
this.turbines[0].minEmitPower = 10;
this.turbines[0].maxEmitPower = 30;
// local_pos = new BABYLON.Vector3(-0.46,1.2,0);
// global_pos = BABYLON.Vector3.TransformCoordinates(local_pos, matrix);
// this.turbines[1].emitter = global_pos;
// this.turbines[1].gravity = new BABYLON.Vector3(0, -10, 0);
// this.turbines[1].direction1 = new BABYLON.Vector3(0, 0, 0);
// this.turbines[1].direction2 = new BABYLON.Vector3(0, 0, 0);
break;
}
// let local_pos = _mesh.position; //top middle of box relative to box
}
});
});
}
}//end of method
NOTE: previously I have achieved it but with a mesh, NOT with an instance or clone of a mesh
NOTE 2 : this
this.turbines[0].isLocal = true;
and
this.turbines[0].isLocal = false;
tested in update method