Particle effect is broken after loading from file

i saved particles to file by “save to file” button and got next json.

{
“name”: “particles”,
“id”: “particles”,
“capacity”: 100000,
“disposeOnStop”: false,
“manualEmitCount”: -1,
“emitterId”: “particleEmitter”,
“particleEmitterType”: {
“type”: “SphereDirectedParticleEmitter”,
“radius”: 3,
“radiusRange”: 1,
“directionRandomizer”: 0,
“direction1”: [
-100,
-1,
1
],
“direction2”: [
1,
1,
1
]
},
“texture”: {
“tags”: null,
“url”: “https://doc.babylonjs.com/img/how_to/Particles/Flare.png”,
“uOffset”: 0,
“vOffset”: 0,
“uScale”: 1,
“vScale”: 1,
“uAng”: 0,
“vAng”: 0,
“wAng”: 0,
“uRotationCenter”: 0.5,
“vRotationCenter”: 0.5,
“wRotationCenter”: 0.5,
“homogeneousRotationInUVTransform”: false,
“isBlocking”: true,
“name”: “https://doc.babylonjs.com/img/how_to/Particles/Flare.png”,
“hasAlpha”: false,
“getAlphaFromRGB”: false,
“level”: 1,
“coordinatesIndex”: 0,
“optimizeUVAllocation”: true,
“coordinatesMode”: 0,
“wrapU”: 1,
“wrapV”: 1,
“wrapR”: 1,
“anisotropicFilteringLevel”: 4,
“isCube”: false,
“is3D”: false,
“is2DArray”: false,
“gammaSpace”: true,
“invertZ”: false,
“lodLevelInAlpha”: false,
“lodGenerationOffset”: 0,
“lodGenerationScale”: 0,
“linearSpecularLOD”: false,
“isRenderTarget”: false,
“animations”: ,
“invertY”: true,
“samplingMode”: 3,
“_useSRGBBuffer”: false,
“internalTextureLabel”: “https://doc.babylonjs.com/img/how_to/Particles/Flare.png”,
“noMipmap”: false
},
“isLocal”: true,
“animations”: ,
“beginAnimationOnStart”: false,
“beginAnimationFrom”: 0,
“beginAnimationTo”: 60,
“beginAnimationLoop”: false,
“startDelay”: 0,
“renderingGroupId”: 0,
“isBillboardBased”: true,
“billboardMode”: 7,
“minAngularSpeed”: 0,
“maxAngularSpeed”: 0,
“minSize”: 0.01,
“maxSize”: 0.2,
“minScaleX”: 3.1,
“maxScaleX”: 5,
“minScaleY”: 3.1,
“maxScaleY”: 5,
“minEmitPower”: 0.1,
“maxEmitPower”: 0.3,
“minLifeTime”: 1.2,
“maxLifeTime”: 1.3,
“emitRate”: 5000,
“gravity”: [
0,
0,
0
],
“noiseStrength”: [
10,
10,
10
],
“color1”: [
0.22745098039215686,
0.34901960784313724,
0.5215686274509804,
1
],
“color2”: [
0.5372549019607843,
0.6862745098039216,
0.8784313725490196,
1
],
“colorDead”: [
0.5372549019607843,
0.6862745098039216,
0.8784313725490196,
1
],
“updateSpeed”: 0.005,
“targetStopDuration”: 0,
“blendMode”: 0,
“preWarmCycles”: 0,
“preWarmStepOffset”: 1,
“minInitialRotation”: 0,
“maxInitialRotation”: 0,
“startSpriteCellID”: 0,
“spriteCellLoop”: true,
“endSpriteCellID”: 0,
“spriteCellChangeSpeed”: 1,
“spriteCellWidth”: 0,
“spriteCellHeight”: 0,
“spriteRandomStartCell”: false,
“isAnimationSheetEnabled”: false,
“useLogarithmicDepth”: false,
“textureMask”: [
1,
1,
1,
1
],
“customShader”: null,
“preventAutoStart”: false,
“worldOffset”: [
0,
0,
0
]
}

when i loading this file using ParticleHelper.ParseFromFileAsync method i see that particle is broken. i found out that if i add line

createDirectedSphereEmitter(3, new BABYLON.Vector3(-1, -1, 100), new BABYLON.Vector3(1, 1, 100));

particle effect is in expected state. It means that save button doesn’t save correctly emitter part. Moreover when i check file

direction1 and direction2 have wrong values from what was in constructor of emitter. But even if i change them in file to correct values (-1, -1, 100) (1, 1, 100) particle effect is still broken. looks like this values doesn’t work at all because nothing change when i change them to any values

Could you please check?

cc @AlitarSemiramis

Looking.

Great catch! This will fix the issue when deserializing direction1 and direction2. Tried your PG locally and it works well with the fix:

Fixing bug deserializing vectors for particles by VicenteCartas · Pull Request #17942 · BabylonJS/Babylon.js

2 Likes

Hey, did you check serializing part? Saved file have incorrect values

1 Like

Good point, let me double check as visually they look correct.

they don’t

In your playground, you are updating direction1 and direction2 later on.

If you remove that code, then your constructor values appear in the .json:

1 Like