@tsparticles/editor
Version:
tsParticles Configuration Editor
90 lines (89 loc) • 2.78 kB
JavaScript
import { DestroyType, StartValueType } from "@tsparticles/engine";
import { EditorType } from "object-gui";
import { EditorBase } from "../../../../EditorBase";
export class OpacityOptionsEditor extends EditorBase {
constructor(particles) {
super(particles);
}
addToGroup(parent, options) {
this.group = parent.addGroup("opacity", "Opacity", true, options);
this.options = this.group.data;
this.addAnimation();
this.addRandom();
this.addProperties();
}
addAnimation() {
const group = this.group.addGroup("animation", "Animation");
group
.addProperty("destroy", "Destroy", EditorType.select)
.change(() => {
void this.particles().refresh();
})
.addItems([
{
value: DestroyType.max,
},
{
value: DestroyType.min,
},
{
value: DestroyType.none,
},
]);
group.addProperty("enable", "Enable", EditorType.boolean).change(() => {
void this.particles().refresh();
});
group
.addProperty("minimumValue", "Minimum Value", EditorType.number)
.change(() => {
void this.particles().refresh();
})
.min(0)
.max(0)
.step(0.01);
group
.addProperty("speed", "Speed", EditorType.number)
.change(() => {
void this.particles().refresh();
})
.step(0.01);
group
.addProperty("startValue", "Start Value", EditorType.select)
.change(() => {
void this.particles().refresh();
})
.addItems([
{
value: StartValueType.max,
},
{
value: StartValueType.min,
},
{
value: StartValueType.random,
},
]);
group.addProperty("sync", "Sync", EditorType.boolean).change(() => {
void this.particles().refresh();
});
}
addProperties() {
this.group
.addProperty("value", "Value", EditorType.number)
.change(() => {
void this.particles().refresh();
})
.min(0)
.max(1)
.step(0.01);
}
addRandom() {
const group = this.group.addGroup("random", "Random");
group.addProperty("enable", "Enable", EditorType.boolean).change(() => {
void this.particles().refresh();
});
group.addProperty("minimumValue", "Minimum Value", EditorType.number).change(() => {
void this.particles().refresh();
});
}
}