UNPKG

@realsee/dnalogel

Version:
94 lines (93 loc) 3.07 kB
var f = Object.defineProperty; var u = Object.getOwnPropertySymbols; var b = Object.prototype.hasOwnProperty, g = Object.prototype.propertyIsEnumerable; var c = (s, t, e) => t in s ? f(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, d = (s, t) => { for (var e in t || (t = {})) b.call(t, e) && c(s, e, t[e]); if (u) for (var e of u(t)) g.call(t, e) && c(s, e, t[e]); return s; }; var r = (s, t, e) => (c(s, typeof t != "symbol" ? t + "" : t, e), e); import { hotkeys as p } from "../../../vendor/hotkeys-js/dist/hotkeys.esm.js"; import { Sculpt as n } from "../../index.js"; import { IObject3D as m } from "../../../shared-utils/three/IObject3D.js"; import { toArray as y } from "../../../shared-utils/util.js"; const a = /* @__PURE__ */ new Map(); class A extends m { constructor(e, o) { super(); r(this, "name", "Sculpt"); r(this, "isSculptObject", !0); r(this, "draggable"); /** * @description 是否被选中 */ r(this, "selected"); /** * @description 配置 */ r(this, "config"); r(this, "editor"); r(this, "on", (e, o, i) => n.modules.fiveDomEvents.addEventListener(this, e, o, i)); r(this, "off", (...e) => n.modules.fiveDomEvents.removeEventListener(this, ...e)); e != null && e.id && (this.uuid = e.id), this.config = d({ canEdit: !0, occlusionVisibility: !0 }, o), e != null && e.style && (e.style.occlusionVisibility = this.config.occlusionVisibility), this.config.canEdit && (p("backspace, delete", () => { this.selected && this.delete(); }), this.on("click", () => { var l, h; if (this.pointSelector.enabled) return; let i = a.get(this.parent.uuid); i && (i.selected = !1, i.unhighlight(), (l = i.editor) == null || l.disable()), a.set(this.parent.uuid, this), this.selected = !0, this.highlight(), (h = this.editor) == null || h.enable(); }), p("esc", () => { var i; this.selected = !1, this.unhighlight(), !this.pointSelector.enabled && ((i = this.editor) == null || i.disable()); })); } get baseData() { return { id: this.uuid, type: this.type }; } get pointSelector() { return n.modules.pointSelector; } /** * @description 停止创建当前物体,等同于`esc` */ stopCreating() { n.modules.pointSelector.disable(); } /** * @description 从场景中删除当前物体 */ delete() { var e; this.removeFromParent(), (e = this.editor) == null || e.disable(); } /** * @description 高亮当前物体 */ highlight() { } /** * @description 取消高亮当前物体 */ unhighlight() { } applyObjectMatrixWorld(e) { const o = y(e); this.updateMatrixWorld(); const i = o.map((l) => this.localToWorld(l.clone())); return Array.isArray(e) ? i : i[0]; } applyObjectQuaternion(e) { const o = this.quaternion.clone(); return Array.isArray(e) ? e.map((i) => i.clone().applyQuaternion(o)) : e.clone().applyQuaternion(o); } } export { A as BaseObject };