@onerjs/core 8.49.4 → 8.49.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,6 +30,15 @@ import { CreateConeEmitter, CreateCylinderEmitter, CreateDirectedCylinderEmitter
30
30
  * @see https://www.babylonjs-playground.com/#PU4WYI#4
31
31
  */
32
32
  export class GPUParticleSystem extends BaseParticleSystem {
33
+ /**
34
+ * Whether the particle buffer needs to store the initial emission direction.
35
+ * True when particles are not billboarded (they orient by direction) or when
36
+ * using stretched-local billboard mode (stretches along initial direction).
37
+ * @internal
38
+ */
39
+ get _needsInitialDirection() {
40
+ return !this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED_LOCAL;
41
+ }
33
42
  /**
34
43
  * Gets a boolean indicating if the GPU particles can be rendered on current browser
35
44
  */
@@ -909,7 +918,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
909
918
  renderVertexBuffers["life"] = renderBuffer.createVertexBuffer("life", offset, 1, this._attributesStrideSize, true);
910
919
  offset += 1;
911
920
  offset += 4; // seed
912
- if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
921
+ if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED_LOCAL) {
913
922
  renderVertexBuffers["direction"] = renderBuffer.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
914
923
  }
915
924
  offset += 3; // direction
@@ -926,7 +935,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
926
935
  renderVertexBuffers["color"] = renderBuffer.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
927
936
  offset += 4;
928
937
  }
929
- if (!this._isBillboardBased) {
938
+ if (this._needsInitialDirection) {
930
939
  renderVertexBuffers["initialDirection"] = renderBuffer.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
931
940
  offset += 3;
932
941
  if (this._platform.alignDataInBuffer) {
@@ -982,7 +991,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
982
991
  this._attributesStrideSize += 1;
983
992
  }
984
993
  }
985
- if (!this.isBillboardBased) {
994
+ if (this._needsInitialDirection) {
986
995
  this._attributesStrideSize += 3;
987
996
  if (this._platform.alignDataInBuffer) {
988
997
  this._attributesStrideSize += 1;
@@ -1064,7 +1073,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
1064
1073
  data.push(0.0);
1065
1074
  offset += 4;
1066
1075
  }
1067
- if (!this.isBillboardBased) {
1076
+ if (this._needsInitialDirection) {
1068
1077
  // initialDirection
1069
1078
  data.push(0.0);
1070
1079
  data.push(0.0);
@@ -1145,7 +1154,11 @@ export class GPUParticleSystem extends BaseParticleSystem {
1145
1154
  this._createDragGradientTexture();
1146
1155
  let defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
1147
1156
  if (this._isBillboardBased) {
1148
- defines += "\n#define BILLBOARD";
1157
+ // Stretched local needs initialDirection in the buffer, which requires !BILLBOARD in the update shader.
1158
+ // The render shader still uses BILLBOARD — that's handled separately in fillDefines().
1159
+ if (this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED_LOCAL) {
1160
+ defines += "\n#define BILLBOARD";
1161
+ }
1149
1162
  }
1150
1163
  if (this._colorGradientsTexture) {
1151
1164
  defines += "\n#define COLORGRADIENTS";
@@ -1232,7 +1245,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
1232
1245
  /**
1233
1246
  * @internal
1234
1247
  */
1235
- static _GetAttributeNamesOrOptions(hasColorGradients = false, isAnimationSheetEnabled = false, isBillboardBased = false, isBillboardStretched = false) {
1248
+ static _GetAttributeNamesOrOptions(hasColorGradients = false, isAnimationSheetEnabled = false, isBillboardBased = false, isBillboardStretched = false, isBillboardStretchedLocal = false) {
1236
1249
  const attributeNamesOrOptions = [VertexBuffer.PositionKind, "age", "life", "size", "angle"];
1237
1250
  if (!hasColorGradients) {
1238
1251
  attributeNamesOrOptions.push(VertexBuffer.ColorKind);
@@ -1240,7 +1253,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
1240
1253
  if (isAnimationSheetEnabled) {
1241
1254
  attributeNamesOrOptions.push("cellIndex");
1242
1255
  }
1243
- if (!isBillboardBased) {
1256
+ if (!isBillboardBased || isBillboardStretchedLocal) {
1244
1257
  attributeNamesOrOptions.push("initialDirection");
1245
1258
  }
1246
1259
  if (isBillboardStretched) {
@@ -1298,6 +1311,10 @@ export class GPUParticleSystem extends BaseParticleSystem {
1298
1311
  case ParticleSystem.BILLBOARDMODE_STRETCHED:
1299
1312
  defines.push("#define BILLBOARDSTRETCHED");
1300
1313
  break;
1314
+ case ParticleSystem.BILLBOARDMODE_STRETCHED_LOCAL:
1315
+ defines.push("#define BILLBOARDSTRETCHED");
1316
+ defines.push("#define BILLBOARDSTRETCHED_LOCAL");
1317
+ break;
1301
1318
  case ParticleSystem.BILLBOARDMODE_ALL:
1302
1319
  defines.push("#define BILLBOARDMODE_ALL");
1303
1320
  break;
@@ -1326,7 +1343,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
1326
1343
  * @param samplers Samplers array to fill
1327
1344
  */
1328
1345
  fillUniformsAttributesAndSamplerNames(uniforms, attributes, samplers) {
1329
- attributes.push(...GPUParticleSystem._GetAttributeNamesOrOptions(!!this._colorGradientsTexture, this._isAnimationSheetEnabled, this._isBillboardBased, this._isBillboardBased && this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED));
1346
+ attributes.push(...GPUParticleSystem._GetAttributeNamesOrOptions(!!this._colorGradientsTexture, this._isAnimationSheetEnabled, this._isBillboardBased, this._isBillboardBased && (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED_LOCAL), this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED_LOCAL));
1330
1347
  uniforms.push(...GPUParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled, this.useLogarithmicDepth, this.applyFog));
1331
1348
  samplers.push("diffuseSampler", "colorGradientSampler");
1332
1349
  if (this._imageProcessingConfiguration) {