UNPKG

awv3

Version:
91 lines (72 loc) 2.38 kB
import _extends from "@babel/runtime/helpers/extends"; import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; var _class, _temp; import * as THREE from 'three'; import React from 'react'; import PropTypes from 'prop-types'; import Plugin from '../../session/plugin'; import Graphics from './graphics'; import Object3 from '../../three/object3'; var Root = (_temp = _class = /*#__PURE__*/ function (_React$Component) { _inheritsLoose(Root, _React$Component); function Root(props, context) { var _this$pool$view$on; var _this; _this = _React$Component.call(this) || this; _this.fsrtPoint = props.fsrtPoint; _this.scndPoint = props.scndPoint; _this.pool = context.plugin.pool; _this.session = session; _this.pool.view.on((_this$pool$view$on = {}, _this$pool$view$on[Object3.Events.Lifecycle.Updated] = _this.onUpdated.bind(_assertThisInitialized(_this)), _this$pool$view$on), { sync: true }); return _this; } var _proto = Root.prototype; _proto.onUpdated = function onUpdated() { var pool = this.session.pool; pool.updateBounds(); this.fsrtPoint = pool.bounds.box.min; this.scndPoint = pool.bounds.box.max; this.componentWillUnmount(); this.componentWillMount(); }; _proto.componentWillMount = function componentWillMount() { this.graphics = new Graphics(this, this.fsrtPoint, this.scndPoint); this.pool.add(this.graphics); }; _proto.componentWillUnmount = function componentWillUnmount() { this.graphics && this.graphics.destroy(); }; _proto.render = function render() { return React.createElement("group", { format: "Table" }); }; return Root; }(React.Component), Object.defineProperty(_class, "contextTypes", { configurable: true, enumerable: true, writable: true, value: { session: PropTypes.object, plugin: PropTypes.object } }), _temp); var _default = /*#__PURE__*/ function (_Plugin) { _inheritsLoose(_default, _Plugin); function _default(session, args) { return _Plugin.call(this, session, _extends({}, args)) || this; } var _proto2 = _default.prototype; _proto2.render = function render() { return React.createElement(Root, this.props); }; return _default; }(Plugin); export { _default as default };