@onerjs/core 8.48.9 → 8.49.1
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.
- package/Animations/animation.d.ts +9 -0
- package/Animations/animation.js +9 -0
- package/Animations/animation.js.map +1 -1
- package/Animations/runtimeAnimation.js +28 -0
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +2 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/Layers/thinEffectLayer.js +8 -1
- package/Layers/thinEffectLayer.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.js +8 -5
- package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +26 -0
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +2 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +3 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Maths/math.vector.d.ts +1 -1
- package/Maths/math.vector.js +3 -3
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingCompoundMesh.d.ts +18 -4
- package/Meshes/GaussianSplatting/gaussianSplattingCompoundMesh.js +29 -4
- package/Meshes/GaussianSplatting/gaussianSplattingCompoundMesh.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +48 -8
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +276 -26
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.d.ts +2 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js +6 -2
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.d.ts +61 -7
- package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.js +94 -11
- package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +15 -0
- package/Meshes/mesh.js +40 -1
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/transformNode.js +28 -5
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/sceneSerializer.js +2 -1
- package/Misc/sceneSerializer.js.map +1 -1
- package/Misc/tools.js +1 -1
- package/Misc/tools.js.map +1 -1
- package/Particles/baseParticleSystem.d.ts +14 -0
- package/Particles/baseParticleSystem.js +23 -0
- package/Particles/baseParticleSystem.js.map +1 -1
- package/Particles/computeShaderParticleSystem.js +6 -0
- package/Particles/computeShaderParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +29 -18
- package/Particles/gpuParticleSystem.js +139 -31
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +0 -14
- package/Particles/thinParticleSystem.js +0 -23
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Particles/webgl2ParticleSystem.d.ts +1 -0
- package/Particles/webgl2ParticleSystem.js +9 -0
- package/Particles/webgl2ParticleSystem.js.map +1 -1
- package/Shaders/gpuUpdateParticles.vertex.js +12 -0
- package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js +15 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
- package/package.json +1 -1
|
@@ -286,6 +286,28 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
286
286
|
this._stopped = false;
|
|
287
287
|
this._actualFrame = 0;
|
|
288
288
|
this._preWarmDone = false;
|
|
289
|
+
// Reset emit gradient so it acts the same on every start
|
|
290
|
+
if (this._emitRateGradients) {
|
|
291
|
+
if (this._emitRateGradients.length > 0) {
|
|
292
|
+
this._currentEmitRateGradient = this._emitRateGradients[0];
|
|
293
|
+
this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
|
|
294
|
+
this._currentEmitRate2 = this._currentEmitRate1;
|
|
295
|
+
}
|
|
296
|
+
if (this._emitRateGradients.length > 1) {
|
|
297
|
+
this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Reset start size gradient so it acts the same on every start
|
|
301
|
+
if (this._startSizeGradients) {
|
|
302
|
+
if (this._startSizeGradients.length > 0) {
|
|
303
|
+
this._currentStartSizeGradient = this._startSizeGradients[0];
|
|
304
|
+
this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
|
|
305
|
+
this._currentStartSize2 = this._currentStartSize1;
|
|
306
|
+
}
|
|
307
|
+
if (this._startSizeGradients.length > 1) {
|
|
308
|
+
this._currentStartSize2 = this._startSizeGradients[1].getFactor();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
289
311
|
// Animations
|
|
290
312
|
if (this.beginAnimationOnStart && this.animations && this.animations.length > 0 && this._scene) {
|
|
291
313
|
this._scene.beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
|
|
@@ -584,35 +606,34 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
584
606
|
return this;
|
|
585
607
|
}
|
|
586
608
|
/**
|
|
587
|
-
*
|
|
588
|
-
* @
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
// Do nothing as emit rate is not supported by GPUParticleSystem
|
|
592
|
-
return this;
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* Not supported by GPUParticleSystem
|
|
596
|
-
* @returns the current particle system
|
|
597
|
-
*/
|
|
598
|
-
removeEmitRateGradient() {
|
|
599
|
-
// Do nothing as emit rate is not supported by GPUParticleSystem
|
|
600
|
-
return this;
|
|
601
|
-
}
|
|
602
|
-
/**
|
|
603
|
-
* Not supported by GPUParticleSystem
|
|
609
|
+
* Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
|
|
610
|
+
* @param gradient defines the gradient to use (between 0 and 1)
|
|
611
|
+
* @param factor defines the start size factor to affect to the specified gradient
|
|
612
|
+
* @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
|
|
604
613
|
* @returns the current particle system
|
|
605
614
|
*/
|
|
606
|
-
addStartSizeGradient() {
|
|
607
|
-
|
|
615
|
+
addStartSizeGradient(gradient, factor, factor2) {
|
|
616
|
+
if (!this._startSizeGradients) {
|
|
617
|
+
this._startSizeGradients = [];
|
|
618
|
+
}
|
|
619
|
+
const hadGradients = this._startSizeGradients.length > 0;
|
|
620
|
+
this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
|
|
621
|
+
if (!hadGradients) {
|
|
622
|
+
this._resetEffect();
|
|
623
|
+
}
|
|
608
624
|
return this;
|
|
609
625
|
}
|
|
610
626
|
/**
|
|
611
|
-
*
|
|
627
|
+
* Remove a specific start size gradient
|
|
628
|
+
* @param gradient defines the gradient to remove
|
|
612
629
|
* @returns the current particle system
|
|
613
630
|
*/
|
|
614
|
-
removeStartSizeGradient() {
|
|
615
|
-
|
|
631
|
+
removeStartSizeGradient(gradient) {
|
|
632
|
+
const hadGradients = this._startSizeGradients && this._startSizeGradients.length > 0;
|
|
633
|
+
this._removeFactorGradient(this._startSizeGradients, gradient);
|
|
634
|
+
if (hadGradients && (!this._startSizeGradients || this._startSizeGradients.length === 0)) {
|
|
635
|
+
this._resetEffect();
|
|
636
|
+
}
|
|
616
637
|
return this;
|
|
617
638
|
}
|
|
618
639
|
/**
|
|
@@ -683,19 +704,34 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
683
704
|
//Not supported by GPUParticleSystem
|
|
684
705
|
}
|
|
685
706
|
/**
|
|
686
|
-
*
|
|
707
|
+
* Adds a new life time gradient (please note that this will only work if you set the targetStopDuration property)
|
|
708
|
+
* @param gradient defines the gradient to use (between 0 and 1)
|
|
709
|
+
* @param factor defines the life time factor to affect to the specified gradient
|
|
710
|
+
* @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
|
|
687
711
|
* @returns the current particle system
|
|
688
712
|
*/
|
|
689
|
-
addLifeTimeGradient() {
|
|
690
|
-
|
|
713
|
+
addLifeTimeGradient(gradient, factor, factor2) {
|
|
714
|
+
if (!this._lifeTimeGradients) {
|
|
715
|
+
this._lifeTimeGradients = [];
|
|
716
|
+
}
|
|
717
|
+
const hadGradients = this._lifeTimeGradients.length > 0;
|
|
718
|
+
this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
|
|
719
|
+
if (!hadGradients) {
|
|
720
|
+
this._resetEffect();
|
|
721
|
+
}
|
|
691
722
|
return this;
|
|
692
723
|
}
|
|
693
724
|
/**
|
|
694
|
-
*
|
|
725
|
+
* Remove a specific life time gradient
|
|
726
|
+
* @param gradient defines the gradient to remove
|
|
695
727
|
* @returns the current particle system
|
|
696
728
|
*/
|
|
697
|
-
removeLifeTimeGradient() {
|
|
698
|
-
|
|
729
|
+
removeLifeTimeGradient(gradient) {
|
|
730
|
+
const hadGradients = this._lifeTimeGradients && this._lifeTimeGradients.length > 0;
|
|
731
|
+
this._removeFactorGradient(this._lifeTimeGradients, gradient);
|
|
732
|
+
if (hadGradients && (!this._lifeTimeGradients || this._lifeTimeGradients.length === 0)) {
|
|
733
|
+
this._resetEffect();
|
|
734
|
+
}
|
|
699
735
|
return this;
|
|
700
736
|
}
|
|
701
737
|
/**
|
|
@@ -729,6 +765,18 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
729
765
|
this._actualFrame = 0;
|
|
730
766
|
this._rawTextureWidth = 256;
|
|
731
767
|
this._rebuildingAfterContextLost = false;
|
|
768
|
+
// Emit rate gradient caching (mirrors ThinParticleSystem)
|
|
769
|
+
this._currentEmitRateGradient = null;
|
|
770
|
+
this._currentEmitRate1 = 0;
|
|
771
|
+
this._currentEmitRate2 = 0;
|
|
772
|
+
// Start size gradient caching (mirrors ThinParticleSystem)
|
|
773
|
+
this._currentStartSizeGradient = null;
|
|
774
|
+
this._currentStartSize1 = 0;
|
|
775
|
+
this._currentStartSize2 = 0;
|
|
776
|
+
this._startSizeGradientFactor = 1.0;
|
|
777
|
+
// Life time gradient factor range for per-particle randomization in shader
|
|
778
|
+
this._lifeTimeGradientMin = 1.0;
|
|
779
|
+
this._lifeTimeGradientMax = 1.0;
|
|
732
780
|
/**
|
|
733
781
|
* Specifies if the particle system should be serialized
|
|
734
782
|
*/
|
|
@@ -1081,6 +1129,12 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1081
1129
|
this._sourceBuffer = this._buffer0;
|
|
1082
1130
|
this._targetBuffer = this._buffer1;
|
|
1083
1131
|
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Forces the update effect to be recreated on the next render.
|
|
1134
|
+
*/
|
|
1135
|
+
_resetEffect() {
|
|
1136
|
+
this._cachedUpdateDefines = "";
|
|
1137
|
+
}
|
|
1084
1138
|
/** @internal */
|
|
1085
1139
|
_recreateUpdateEffect() {
|
|
1086
1140
|
this._createColorGradientTexture();
|
|
@@ -1133,6 +1187,12 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1133
1187
|
if (this._emitRateControl) {
|
|
1134
1188
|
defines += "\n#define EMITRATECTRL";
|
|
1135
1189
|
}
|
|
1190
|
+
if (this._startSizeGradients && this._startSizeGradients.length > 0) {
|
|
1191
|
+
defines += "\n#define STARTSIZEGRADIENTS";
|
|
1192
|
+
}
|
|
1193
|
+
if (this._lifeTimeGradients && this._lifeTimeGradients.length > 0) {
|
|
1194
|
+
defines += "\n#define LIFETIMEGRADIENTS";
|
|
1195
|
+
}
|
|
1136
1196
|
if (this._platform.isUpdateBufferCreated() && this._cachedUpdateDefines === defines) {
|
|
1137
1197
|
return this._platform.isUpdateBufferReady();
|
|
1138
1198
|
}
|
|
@@ -1491,6 +1551,12 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1491
1551
|
}
|
|
1492
1552
|
}
|
|
1493
1553
|
}
|
|
1554
|
+
if (this._startSizeGradients && this._startSizeGradients.length > 0) {
|
|
1555
|
+
this._updateBuffer.setFloat("startSizeGradientFactor", this._startSizeGradientFactor);
|
|
1556
|
+
}
|
|
1557
|
+
if (this._lifeTimeGradients && this._lifeTimeGradients.length > 0) {
|
|
1558
|
+
this._updateBuffer.setFloat2("lifeTimeGradientRange", this._lifeTimeGradientMin, this._lifeTimeGradientMax);
|
|
1559
|
+
}
|
|
1494
1560
|
this._platform.updateParticleBuffer(this._targetIndex, this._targetBuffer, this._currentActiveCount);
|
|
1495
1561
|
// Switch VAOs
|
|
1496
1562
|
this._targetIndex++;
|
|
@@ -1535,6 +1601,48 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1535
1601
|
}
|
|
1536
1602
|
// Get everything ready to render
|
|
1537
1603
|
this._initialize();
|
|
1604
|
+
// Compute effective emit rate, applying emit rate gradients if set
|
|
1605
|
+
let effectiveEmitRate = this.emitRate;
|
|
1606
|
+
if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
|
|
1607
|
+
const ratio = this._actualFrame / this.targetStopDuration;
|
|
1608
|
+
GradientHelper.GetCurrentGradient(ratio, this._emitRateGradients, (currentGradient, nextGradient, scale) => {
|
|
1609
|
+
if (currentGradient !== this._currentEmitRateGradient) {
|
|
1610
|
+
this._currentEmitRate1 = this._currentEmitRate2;
|
|
1611
|
+
this._currentEmitRate2 = nextGradient.getFactor();
|
|
1612
|
+
this._currentEmitRateGradient = currentGradient;
|
|
1613
|
+
}
|
|
1614
|
+
effectiveEmitRate = Lerp(this._currentEmitRate1, this._currentEmitRate2, scale);
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
// Compute start size and life time gradient factors for shader uniforms
|
|
1618
|
+
if (this.targetStopDuration) {
|
|
1619
|
+
const ratio = this._actualFrame / this.targetStopDuration;
|
|
1620
|
+
if (this._startSizeGradients && this._startSizeGradients.length > 0) {
|
|
1621
|
+
GradientHelper.GetCurrentGradient(ratio, this._startSizeGradients, (currentGradient, nextGradient, scale) => {
|
|
1622
|
+
if (currentGradient !== this._currentStartSizeGradient) {
|
|
1623
|
+
this._currentStartSize1 = this._currentStartSize2;
|
|
1624
|
+
this._currentStartSize2 = nextGradient.getFactor();
|
|
1625
|
+
this._currentStartSizeGradient = currentGradient;
|
|
1626
|
+
}
|
|
1627
|
+
this._startSizeGradientFactor = Lerp(this._currentStartSize1, this._currentStartSize2, scale);
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
else {
|
|
1631
|
+
this._startSizeGradientFactor = 1.0;
|
|
1632
|
+
}
|
|
1633
|
+
if (this._lifeTimeGradients && this._lifeTimeGradients.length > 0) {
|
|
1634
|
+
GradientHelper.GetCurrentGradient(ratio, this._lifeTimeGradients, (currentGradient, nextGradient, scale) => {
|
|
1635
|
+
const current = currentGradient;
|
|
1636
|
+
const next = nextGradient;
|
|
1637
|
+
this._lifeTimeGradientMin = Lerp(current.factor1, next.factor1, scale);
|
|
1638
|
+
this._lifeTimeGradientMax = Lerp(current.factor2 ?? current.factor1, next.factor2 ?? next.factor1, scale);
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
else {
|
|
1642
|
+
this._lifeTimeGradientMin = 1.0;
|
|
1643
|
+
this._lifeTimeGradientMax = 1.0;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1538
1646
|
if (this._emitRateControl) {
|
|
1539
1647
|
// Emit-rate-controlled mode: limits active particles to ~emitRate * maxLifeTime,
|
|
1540
1648
|
// matching CPU particle behavior with circular buffer recycling.
|
|
@@ -1544,7 +1652,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1544
1652
|
this.manualEmitCount = 0;
|
|
1545
1653
|
}
|
|
1546
1654
|
else if (!this._stopped) {
|
|
1547
|
-
this._accumulatedCount +=
|
|
1655
|
+
this._accumulatedCount += effectiveEmitRate * this._timeDelta;
|
|
1548
1656
|
}
|
|
1549
1657
|
// Convert accumulated fractional count into whole particles to emit this frame.
|
|
1550
1658
|
// The fractional remainder carries over to the next frame.
|
|
@@ -1559,7 +1667,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1559
1667
|
// When emitRate is 0 but manualEmitCount is used, the rate-based steady state
|
|
1560
1668
|
// would be 0, blocking buffer growth. Use newParticles as a floor so manual
|
|
1561
1669
|
// emissions can always allocate slots.
|
|
1562
|
-
const steadyStateCount = Math.min(Math.max(Math.ceil(
|
|
1670
|
+
const steadyStateCount = Math.min(Math.max(Math.ceil(effectiveEmitRate * this.maxLifeTime), newParticles), this._maxActiveParticleCount);
|
|
1563
1671
|
// During ramp-up, grow the active buffer size by adding new slots.
|
|
1564
1672
|
// Once _currentActiveCount reaches steadyStateCount, no new slots are added —
|
|
1565
1673
|
// existing slots are recycled instead (handled by _emitIndex below).
|
|
@@ -1588,7 +1696,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1588
1696
|
this.manualEmitCount = 0;
|
|
1589
1697
|
}
|
|
1590
1698
|
else {
|
|
1591
|
-
this._accumulatedCount +=
|
|
1699
|
+
this._accumulatedCount += effectiveEmitRate * this._timeDelta;
|
|
1592
1700
|
}
|
|
1593
1701
|
if (this._accumulatedCount >= 1) {
|
|
1594
1702
|
const intPart = this._accumulatedCount | 0;
|