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>
116 lines (96 loc) • 3.91 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"); } }
/**
* Validate basic structures.
*
* @example
* //Returns true
* VJS.Core.Validators.matrix4(new THREE.Matrix4());
*
* //Returns false
* VJS.Core.Validators.matrix4(new THREE.Vector3());
*
* @module core/validators
*/
var Validators = function () {
function Validators() {
_classCallCheck(this, Validators);
}
_createClass(Validators, null, [{
key: 'matrix4',
/**
* Validates a matrix as a THREEJS.Matrix4
* link
* @param {Object} objectToTest - The object to be tested.
* @return {boolean} True if valid Matrix4, false if NOT.
*/
value: function matrix4(objectToTest) {
if (!(objectToTest !== null && typeof objectToTest !== 'undefined' && objectToTest.hasOwnProperty('elements') && objectToTest.elements.length === 16 && typeof objectToTest.identity === 'function' && typeof objectToTest.copy === 'function' && typeof objectToTest.determinant === 'function')) {
return false;
}
return true;
}
/**
* Validates a vector as a THREEJS.Vector3
* @param {Object} objectToTest - The object to be tested.
* @return {boolean} True if valid Vector3, false if NOT.
*/
}, {
key: 'vector3',
value: function vector3(objectToTest) {
if (!(objectToTest !== null && typeof objectToTest !== 'undefined' && objectToTest.hasOwnProperty('x') && objectToTest.hasOwnProperty('y') && objectToTest.hasOwnProperty('z') && !objectToTest.hasOwnProperty('w'))) {
return false;
}
return true;
}
/**
* Validates a box.
*
* @example
* // a box is defined as
* let box = {
* center: THREE.Vector3,
* halfDimensions: THREE.Vector3
* }
*
* @param {Object} objectToTest - The object to be tested.
* @return {boolean} True if valid box, false if NOT.
*/
}, {
key: 'box',
value: function box(objectToTest) {
if (!(objectToTest !== null && typeof objectToTest !== 'undefined' && objectToTest.hasOwnProperty('center') && this.vector3(objectToTest.center) && objectToTest.hasOwnProperty('halfDimensions') && this.vector3(objectToTest.halfDimensions) && objectToTest.halfDimensions.x >= 0 && objectToTest.halfDimensions.y >= 0 && objectToTest.halfDimensions.z >= 0)) {
return false;
}
return true;
}
/**
* Validates a ray.
*
* @example
* // a ray is defined as
* let ray = {
* postion: THREE.Vector3,
* direction: THREE.Vector3
* }
*
* @param {Object} objectToTest - The object to be tested.
* @return {boolean} True if valid ray, false if NOT.
*/
}, {
key: 'ray',
value: function ray(objectToTest) {
if (!(objectToTest !== null && typeof objectToTest !== 'undefined' && objectToTest.hasOwnProperty('position') && this.vector3(objectToTest.position) && objectToTest.hasOwnProperty('direction') && this.vector3(objectToTest.direction))) {
return false;
}
return true;
}
}]);
return Validators;
}();
exports.default = Validators;
module.exports = exports['default'];