@tsparticles/editor
Version:
tsParticles Configuration Editor
68 lines (67 loc) • 2.58 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CollisionsOptionsEditor = void 0;
const engine_1 = require("@tsparticles/engine");
const object_gui_1 = require("object-gui");
const EditorBase_1 = require("../../../../EditorBase");
class CollisionsOptionsEditor extends EditorBase_1.EditorBase {
constructor(particles) {
super(particles);
}
addToGroup(parent) {
this.group = parent.addGroup("collisions", "Collisions");
this.options = this.group.data;
this.addBounce();
this.addOverlap();
this.addProperties();
}
addBounce() {
const group = this.group.addGroup("bounce", "Bounce");
this.addBounceFactor(group, "horizontal", "Horizontal");
this.addBounceFactor(group, "vertical", "Vertical");
}
addBounceFactor(parentGroup, name, title) {
const group = parentGroup.addGroup(name, title);
const randomGroup = group.addGroup("random", "Random");
randomGroup.addProperty("enable", "Enable", object_gui_1.EditorType.boolean).change(() => {
void this.particles().refresh();
});
randomGroup.addProperty("minimumValue", "Minimum Value", object_gui_1.EditorType.number).change(() => {
void this.particles().refresh();
});
group.addProperty("value", "Value", object_gui_1.EditorType.number).change(() => {
void this.particles().refresh();
});
}
addOverlap() {
const group = this.group.addGroup("overlap", "Overlap");
group.addProperty("enable", "Enable", object_gui_1.EditorType.boolean).change(() => {
void this.particles().refresh();
});
group.addProperty("retries", "Retries", object_gui_1.EditorType.number).change(() => {
void this.particles().refresh();
});
}
addProperties() {
this.group.addProperty("enable", "Enable", object_gui_1.EditorType.boolean).change(() => {
void this.particles().refresh();
});
this.group
.addProperty("mode", "Mode", object_gui_1.EditorType.select)
.change(() => {
void this.particles().refresh();
})
.addItems([
{
value: engine_1.CollisionMode.absorb,
},
{
value: engine_1.CollisionMode.bounce,
},
{
value: engine_1.CollisionMode.destroy,
},
]);
}
}
exports.CollisionsOptionsEditor = CollisionsOptionsEditor;