Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added motion options to editor
- Loading branch information
1 parent
c1da926
commit 80a30a7
Showing
3 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
core/editor/src/Sections/Options/Motion/MotionOptionsEditor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { Container } from "tsparticles/dist/Core/Container"; | ||
import { EditorGroup, EditorType } from "object-gui"; | ||
import { EditorBase } from "../../../EditorBase"; | ||
import type { IMotion } from "tsparticles/dist/Options/Interfaces/Motion/IMotion"; | ||
|
||
export class MotionOptionsEditor extends EditorBase { | ||
private group!: EditorGroup; | ||
private options!: IMotion; | ||
|
||
constructor(particles: Container) { | ||
super(particles); | ||
} | ||
|
||
public addToGroup(parent: EditorGroup): void { | ||
this.group = parent.addGroup("motion", "Motion"); | ||
this.options = this.group.data as IMotion; | ||
|
||
this.addReduce(); | ||
this.addProperties(); | ||
} | ||
|
||
private addReduce(): void { | ||
const particles = this.particles; | ||
const coverGroup = this.group.addGroup("reduce", "Reduce"); | ||
|
||
coverGroup | ||
.addProperty("factor", "Factor", EditorType.number) | ||
.change(async () => { | ||
await particles.refresh(); | ||
}) | ||
.step(1); | ||
|
||
coverGroup.addProperty("value", "Value", EditorType.boolean).change(async () => { | ||
await particles.refresh(); | ||
}); | ||
} | ||
|
||
private addProperties(): void { | ||
const particles = this.particles; | ||
|
||
this.group.addProperty("disable", "Disable", EditorType.boolean).change(async () => { | ||
await particles.refresh(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters