From 2b783e2889a13370c019fdbda9a8b5a95ed667d3 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Sun, 12 Nov 2017 00:46:30 +0100 Subject: [PATCH] beter type checking --- src/slicer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/slicer.js b/src/slicer.js index 667737e..4d3b8af 100644 --- a/src/slicer.js +++ b/src/slicer.js @@ -3,7 +3,7 @@ import slice from './sliceActions/slice.js'; import SlicerWorker from './slicer.worker.js'; export function sliceMesh(settings, mesh, sync = false, onProgress) { - if (typeof mesh === 'undefined' || !mesh.isMesh) { + if (!mesh || !mesh.isMesh) { throw new Error('Provided mesh is not intance of THREE.Mesh'); } @@ -13,7 +13,7 @@ export function sliceMesh(settings, mesh, sync = false, onProgress) { } export function sliceGeometry(settings, geometry, matrix, sync = false, onProgress) { - if (typeof geometry === 'undefined') { + if (!geometry) { throw new Error('Missing required geometry argument'); } else if (geometry.isBufferGeometry) { geometry = new THREE.Geometry().fromBufferGeometry(geometry); @@ -27,7 +27,7 @@ export function sliceGeometry(settings, geometry, matrix, sync = false, onProgre throw new Error('Geometry does not contain any data'); } - if (matrix) { + if (matrix && matrix.isMatrix4) { geometry.applyMatrix(matrix); }