Time is an argument, so speed scales it and a prewarm offsets it (#87)
game-maker / suite (push) Successful in 9m48s
game-maker / suite (push) Successful in 9m48s
Speed and Prewarm are not state and not a second loop: both are arithmetic on the clock argument the field already passes to every particle formula. fieldTime = elapsed * timeScale + prewarmOffset, a pure rule next to liveRange, called at the one place ParticleField.sync forms its time, so preview and world inherit it together. Prewarm offsets by one lifetime because that is the smallest offset which fills a continuous emitter; a burst is dead at time >= lifetime, so the same offset would skip it entirely and it is suppressed there. The tab's slider counts wall-clock seconds, so its span divides by the scale. A missing row falls back to 1 / off, so old project files need no migration. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fbb2d157f0
commit
8ae20d044f
8 files changed
+191
-10
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import type { Asset, ParticlesAsset } from '../../core/model/Asset';
|
||||
import { LIFETIME_KEY } from '../../core/properties/particles';
|
||||
import { LIFETIME_KEY, TIME_SCALE_KEY } from '../../core/properties/particles';
|
||||
import { defaultsFor } from '../../core/properties/PropertySchema';
|
||||
import { particleLibrary } from '../../viewport/ParticleLibrary';
|
||||
import { Button, clamp, HStack, Label, Slider, Spacer, Splitter, Theme, VStack, type Widget } from '../../ui';
|
||||
@@ -151,10 +151,15 @@ export class ParticlesEditor extends AssetTabEditor<ParticlesAsset, GraphCanvas>
|
||||
this.syncSpan(asset);
|
||||
}
|
||||
|
||||
/** The slider covers three of the asset's own lifetimes, so a particle's whole arc fits. */
|
||||
/**
|
||||
* The slider covers three of the asset's own lifetimes, so a particle's whole arc fits – counted
|
||||
* in the seconds the slider is in, which a time scale of 2 makes half as many.
|
||||
*/
|
||||
private syncSpan(asset: ParticlesAsset | null): void {
|
||||
const lifetime = Number(asset?.props[LIFETIME_KEY] ?? defaultsFor('particles')[LIFETIME_KEY] ?? 1);
|
||||
const span = Math.max(MIN_SPAN, lifetime * SPAN_LIFETIMES);
|
||||
const props = { ...defaultsFor('particles'), ...asset?.props };
|
||||
const lifetime = Number(props[LIFETIME_KEY] ?? 1);
|
||||
const scale = Number(props[TIME_SCALE_KEY]);
|
||||
const span = Math.max(MIN_SPAN, (lifetime * SPAN_LIFETIMES) / (scale > 0 ? scale : 1));
|
||||
if (span === this.span) return;
|
||||
this.span = span;
|
||||
this.slider.setRange(0, span);
|
||||
|
||||
Reference in new issue
Block a user