UNPKG

threepipe

Version:

A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.

44 lines 2 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { AViewerPluginSync } from '../../viewer'; import { getUrlQueryParam, JSUndoManager, onChange } from 'ts-browser-helpers'; // @uiPanelContainer('Undo Manager') export class UndoManagerPlugin extends AViewerPluginSync { constructor(enabled = true, limit = 1000) { super(); // @uiToggle() this.enabled = true; this.limit = 1000; this.toJSON = undefined; this.enabled = enabled; this.limit = limit; } _refresh() { if (!this.undoManager) return; this.undoManager.enabled = this.enabled; this.undoManager.limit = this.limit; this.undoManager.options.debug = this._viewer?.debug || this.undoManager.options.debug; } onAdded(viewer) { super.onAdded(viewer); this.undoManager = new JSUndoManager({ bindHotKeys: true, limit: this.limit, debug: viewer.debug || getUrlQueryParam('debugUndo') !== null, hotKeyRoot: document }); } onRemove(viewer) { this.undoManager?.dispose(); this.undoManager = undefined; super.onRemove(viewer); } } UndoManagerPlugin.PluginType = 'UndoManagerPlugin'; __decorate([ onChange(UndoManagerPlugin.prototype._refresh) ], UndoManagerPlugin.prototype, "enabled", void 0); __decorate([ onChange(UndoManagerPlugin.prototype._refresh) ], UndoManagerPlugin.prototype, "limit", void 0); //# sourceMappingURL=UndoManagerPlugin.js.map