From 77e9f020076bc8e4ff98bb0ff4e95dd0b1509541 Mon Sep 17 00:00:00 2001 From: Jordan Santell Date: Fri, 6 Oct 2017 16:03:53 -0700 Subject: [PATCH] Fail when using global THREE in linting and fix outstanding THREE issues --- .eslintrc | 2 +- src/ARPlanes.js | 3 ++- src/ARUtils.js | 2 +- src/index.js | 1 - src/loaders.js | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.eslintrc b/.eslintrc index 59d3a13..cf32b2b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -11,7 +11,7 @@ "es6": true }, "globals": { - "THREE": false, + "global": false, "VRFrameData": false }, "parserOptions": { diff --git a/src/ARPlanes.js b/src/ARPlanes.js index a57ebb2..d6fbe2b 100644 --- a/src/ARPlanes.js +++ b/src/ARPlanes.js @@ -21,6 +21,7 @@ import { Geometry, Vector3, Face3, + Mesh, } from 'three'; import { getRandomPaletteColor } from './ARUtils'; @@ -159,7 +160,7 @@ class ARPlanes extends Object3D { this.materialMap.set(id, material); } - const plane = new THREE.Mesh(geo, material); + const plane = new Mesh(geo, material); planeObj.add(plane); } diff --git a/src/ARUtils.js b/src/ARUtils.js index 6728698..64e1855 100644 --- a/src/ARUtils.js +++ b/src/ARUtils.js @@ -93,7 +93,7 @@ export const getARDisplay = ARUtils.getARDisplay; * @return {THREE.Mesh} */ ARUtils.loadBlocksModel = (objPath, mtlPath) => new Promise((resolve, reject) => { - if (!THREE.OBJLoader || !THREE.MTLLoader) { + if (!global.THREE || !global.THREE.OBJLoader || !global.THREE.MTLLoader) { reject(new Error('Must include THREE.OBJLoader and THREE.MTLLoader')); return; } diff --git a/src/index.js b/src/index.js index 95e90a9..073c4f9 100644 --- a/src/index.js +++ b/src/index.js @@ -14,7 +14,6 @@ */ /* eslint no-unused-vars: "off" */ -/* eslint no-undef: "off" */ import ARDebug from './ARDebug'; import ARPerspectiveCamera from './ARPerspectiveCamera'; import ARReticle from './ARReticle'; diff --git a/src/loaders.js b/src/loaders.js index 3781d66..3f16883 100644 --- a/src/loaders.js +++ b/src/loaders.js @@ -21,7 +21,7 @@ const noop = function() {}; export const loadObj = (objPath, materials) => new Promise((resolve, reject) => { - const loader = new THREE.OBJLoader(); + const loader = new global.THREE.OBJLoader(); if (materials) { loader.setMaterials(materials); @@ -31,7 +31,7 @@ export const loadObj = (objPath, materials) => new Promise((resolve, reject) => }); export const loadMtl = mtlPath => new Promise((resolve, reject) => { - const loader = new THREE.MTLLoader(); + const loader = new global.THREE.MTLLoader(); const pathChunks = mtlPath.split('/'); if (pathChunks.length >= 2) {