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>
121 lines (100 loc) • 4.07 kB
JavaScript
'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; }
/** * Imports ***/
/**
* @module helpers/border
*/
var HelpersBorder = function (_THREE$Object3D) {
_inherits(HelpersBorder, _THREE$Object3D);
function HelpersBorder(helpersSlice) {
_classCallCheck(this, HelpersBorder);
var _this = _possibleConstructorReturn(this, (HelpersBorder.__proto__ || Object.getPrototypeOf(HelpersBorder)).call(this));
//
_this._helpersSlice = helpersSlice;
_this._visible = true;
_this._color = 0xff0000;
_this._material = null;
_this._geometry = null;
_this._mesh = null;
_this._create();
return _this;
}
_createClass(HelpersBorder, [{
key: '_create',
value: function _create() {
if (!this._material) {
this._material = new THREE.LineBasicMaterial({
color: this._color,
linewidth: 1
});
}
//
if (!this._helpersSlice.geometry.vertices) {
return;
}
this._geometry = new THREE.Geometry();
for (var i = 0; i < this._helpersSlice.geometry.vertices.length; i++) {
this._geometry.vertices.push(this._helpersSlice.geometry.vertices[i]);
}
this._geometry.vertices.push(this._helpersSlice.geometry.vertices[0]);
this._mesh = new THREE.Line(this._geometry, this._material);
if (this._helpersSlice.aabbSpace === 'IJK') {
this._mesh.applyMatrix(this._helpersSlice.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 = null;
}
this._create();
}
}, {
key: 'helpersSlice',
set: function set(helpersSlice) {
this._helpersSlice = helpersSlice;
this._update();
},
get: function get() {
return this._helpersSlice;
}
}, {
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 HelpersBorder;
}(THREE.Object3D);
exports.default = HelpersBorder;
module.exports = exports['default'];