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>
85 lines (70 loc) • 2.67 kB
JavaScript
;
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"); } }
/**
* @module helpers/x/mesh
*/
var _class = function () {
function _class() {
_classCallCheck(this, _class);
this._file = null;
this._3jsVTK_loader = new THREE.VTKLoader();
this._mesh = null;
this._materialColor = 0xE91E63;
this._RAStoLPS = null;
this._material = new THREE.MeshLambertMaterial({
shading: THREE.SmoothShading,
color: this._materialColor,
side: THREE.DoubleSide });
}
// accessor properties
_createClass(_class, [{
key: "load",
// load function
value: function load() {
var _this = this;
if (this.file) {
return new Promise(function (resolve, reject) {
_this._3jsVTK_loader.load(_this.file, function (geometry) {
geometry.computeVertexNormals();
_this._mesh = new THREE.Mesh(geometry, _this._material);
_this._RAStoLPS = new THREE.Matrix4();
_this._RAStoLPS.set(-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
_this._mesh.applyMatrix(_this._RAStoLPS);
// resolve the promise and return the mesh
resolve(_this._mesh);
}, function () {}, function (error) {
console.log(error);
reject({
message: "Couldn't load file: " + _this.file + ".",
error: error
});
});
});
}
return Promise.reject({ message: "File is not defined: " + this.file + "." });
}
}, {
key: "file",
get: function get() {
return this._file;
},
set: function set(fname) {
this._file = fname;
}
}, {
key: "materialColor",
get: function get() {
return this._materialColor;
},
set: function set(color) {
this._materialColor = color;
}
}]);
return _class;
}();
exports.default = _class;
module.exports = exports["default"];