UNPKG

ami-cjs.js

Version:

<p align="center"> <img src="https://cloud.githubusercontent.com/assets/214063/23213764/78ade038-f90c-11e6-8208-4fcade5f3832.png" width="60%"> </p>

118 lines (93 loc) 4.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @module helpers/boundingbox */ var HelpersBoundingBox = function (_THREE$Object3D) { _inherits(HelpersBoundingBox, _THREE$Object3D); function HelpersBoundingBox(stack) { _classCallCheck(this, HelpersBoundingBox); // private vars var _this = _possibleConstructorReturn(this, (HelpersBoundingBox.__proto__ || Object.getPrototypeOf(HelpersBoundingBox)).call(this)); // _this._stack = stack; _this._visible = true; _this._color = 0xFFFFFF; _this._material = null; _this._geometry = null; _this._mesh = null; // create object _this._create(); return _this; } // getters/setters _createClass(HelpersBoundingBox, [{ key: "_create", // private methods value: function _create() { // Convenience vars var dimensions = this._stack.dimensionsIJK; var halfDimensions = this._stack.halfDimensionsIJK; var offset = new THREE.Vector3(-0.5, -0.5, -0.5); // Geometry this._geometry = new THREE.BoxGeometry(dimensions.x, dimensions.y, dimensions.z); // position bbox in image space this._geometry.applyMatrix(new THREE.Matrix4().makeTranslation(halfDimensions.x + offset.x, halfDimensions.y + offset.y, halfDimensions.z + offset.z)); // Mesh var boxMesh = new THREE.Mesh(this._geometry, new THREE.MeshBasicMaterial(0xff0000)); this._mesh = new THREE.BoxHelper(boxMesh, this._color); // Material this._material = this._mesh.material; // position bbox in world space this._mesh.applyMatrix(this._stack.ijk2LPS); this._mesh.visible = this._visible; // and add it! this.add(this._mesh); } }, { key: "_update", value: function _update() { // update slice if (this._mesh) { this.remove(this._mesh); this._mesh.geometry.dispose(); this._mesh.geometry = null; this._mesh.material.dispose(); this._mesh.material = null; this._mesh = null; } this._create(); } }, { key: "visible", set: function set(visible) { this._visible = visible; if (this._mesh) { this._mesh.visible = this._visible; } }, get: function get() { return this._visible; } }, { key: "color", set: function set(color) { this._color = color; if (this._material) { this._material.color.set(this._color); } }, get: function get() { return this._color; } }]); return HelpersBoundingBox; }(THREE.Object3D); exports.default = HelpersBoundingBox; module.exports = exports["default"];