threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UndoManagerPlugin.md 1.5KB

11 miesięcy temu
1234567891011121314151617181920212223242526272829303132333435363738
  1. ---
  2. prev:
  3. text: 'MeshOptSimplifyModifierPlugin'
  4. link: './MeshOptSimplifyModifierPlugin'
  5. next: false
  6. ---
  7. # UndoManagerPlugin
  8. [//]: # (todo: image)
  9. [Example](https://threepipe.org/examples/#transform-controls-plugin/) —
  10. [Source Code](https://github.com/repalash/threepipe/blob/master/src/plugins/rendering/UndoManagerPlugin.ts) —
  11. [API Reference](https://threepipe.org/docs/classes/UndoManagerPlugin.html)
  12. UndoManagerPlugin adds support for undo/redo operations in the viewer.
  13. It can be used to manage the history of changes made to the scene, objects, materials, etc.
  14. It uses the [`JSUndoManager`](https://github.com/repalash/ts-browser-helpers/blob/master/src/JSUndoManager.ts)(from [ts-browser-helpers](https://repalash.com/ts-browser-helpers)) to maintain a common undo/redo history across the viewer and other plugins.
  15. The plugin is used automatically by `TweakpaneUiPlugin`, `BlueprintJsUiPlugin`, `PickingPlugin`, `TransformControlsPlugin`, and other plugins that support undo/redo operations.
  16. It is not _required_ to be added to the viewer explicitly when using any of the UI plugins, but can be added if you want to use it directly.
  17. ```typescript
  18. viewer.addPlugin(UndoManagerPlugin)
  19. let undoManager: JSUndoManager | undefined
  20. // listen for plugin to be added/removed/changed
  21. viewer.forPlugin<UndoManagerPlugin>('UndoManagerPlugin', (um)=> {
  22. undoManager = um.undoManager
  23. }, ()=> undoManager = undefined)
  24. // on button click
  25. undoManager.record({
  26. // my command
  27. })
  28. ```