UNPKG

@realsee/dnalogel

Version:
50 lines (49 loc) 1.93 kB
var d = Object.defineProperty; var l = (r, t, e) => t in r ? d(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e; var n = (r, t, e) => (l(r, typeof t != "symbol" ? t + "" : t, e), e); import { CSS3DRenderer as p } from "three/examples/jsm/renderers/CSS3DRenderer"; import h from "../getAllCSS3DObject.js"; import u from "../createResizeObserver.js"; import "../../../shared-utils/util.js"; import "../even.js"; class F extends p { constructor() { super(); n(this, "wrapper"); n(this, "requestAnimationFrameId"); n(this, "resizeDisoper"); this.domElement.style.position = "absolute", this.domElement.style.top = "0", this.domElement.style.left = "0", this.domElement.style.userSelect = "none", this.domElement.style.pointerEvents = "none"; } setWrapper(e) { if (!e) throw new Error("CSS3DRenderer: wrapper is required"); if (e.contains(this.domElement)) return; const i = this.wrapper; return i && i.contains(this.domElement) && this.domElement.remove(), this.appendToElement(e), this.wrapper = e, this; } appendToElement(e) { e.appendChild(this.domElement); const i = (m, a) => this.setSize(m, a), { observe: s, unobserve: o } = u(e, i, !0); s(), this.resizeDisoper = o, this.wrapper = e; } renderEveryFrame(e, i) { if (this.wrapper || console.warn("wrapper is not find, creating a html element and call setWrapper(wrapper)", this, e), this.requestAnimationFrameId) return; const s = () => { this.requestAnimationFrameId = requestAnimationFrame(s), e.visible && h(e).length !== 0 && this.render(e, i); }; s(); } stopRender() { this.requestAnimationFrameId && cancelAnimationFrame(this.requestAnimationFrameId); } dispose() { var e; this.stopRender(), (e = this.resizeDisoper) == null || e.call(this), this.domElement.remove(); } } export { F as ICSS3DRenderer, F as default };