Skip to content

Commit

Permalink
Use all meshes from the OBJLoader and fix undefined global in the new…
Browse files Browse the repository at this point in the history
… rollup environment. Fixes google-ar#57
  • Loading branch information
jsantell committed Nov 20, 2017
1 parent fd3bf42 commit 054ad8b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 10 deletions.
43 changes: 43 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"babel-core": "^6.24.1",
"babel-eslint": "^8.0.1",
"babel-loader": "^7.0.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-env": "^1.6.1",
"base64-image-loader": "^1.2.0",
"babel-plugin-external-helpers": "^6.22.0",
"eslint": "^4.5.0",
"eslint-config-google": "^0.9.1",
"glsl-y-hsv": "^1.0.0",
Expand All @@ -33,6 +33,7 @@
"rollup-plugin-commonjs": "^8.2.1",
"rollup-plugin-glsl": "^1.1.0",
"rollup-plugin-json": "^2.3.0",
"rollup-plugin-node-globals": "^1.1.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^2.0.1"
},
Expand Down
2 changes: 2 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const cleanup = require('rollup-plugin-cleanup');
const babel = require('rollup-plugin-babel');
const glsl = require('rollup-plugin-glsl');
const uglify = require('rollup-plugin-uglify');
const globals = require('rollup-plugin-node-globals');
const banner = fs.readFileSync(path.join(__dirname, 'licenses.txt'));

export default {
Expand Down Expand Up @@ -49,6 +50,7 @@ export default {
plugins: ['external-helpers'],
exclude: 'node_modules/**',
}),
globals(),
resolve(),
commonjs(),
cleanup(),
Expand Down
9 changes: 1 addition & 8 deletions src/ARUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import { Color, Matrix4, Quaternion, Vector3, Math as Math3 } from 'three';
import { Color, Matrix4, Quaternion, Vector3 } from 'three';

import { loadMtl, loadObj } from './loaders';

Expand Down Expand Up @@ -113,13 +113,6 @@ ARUtils.loadBlocksModel = (objPath, mtlPath) => new Promise((resolve, reject) =>
materialCreator.preload();
}
return loadObj(objPath, materialCreator);
}).then(obj => {
const model = obj.children[0];
model.geometry.applyMatrix(
new Matrix4().makeRotationY(Math3.degToRad(-90))
);

return model;
}).then(resolve, reject);
});
export const loadBlocksModel = ARUtils.loadBlocksModel;
Expand Down
2 changes: 1 addition & 1 deletion src/loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const loadObj = (objPath, materialCreator) => new Promise((resolve, rejec
export const loadMtl = mtlPath => new Promise((resolve, reject) => {
const loader = new global.THREE.MTLLoader();

loader.setTexturePath(mtlPath.substring(0, mtlPath.lastIndexOf('/') + 1));
loader.setTexturePath(mtlPath.substr(0, mtlPath.lastIndexOf('/') + 1));
// remaps ka, kd, & ks values of 0,0,0 -> 1,1,1
loader.setMaterialOptions({ ignoreZeroRGBs: true });

Expand Down

0 comments on commit 054ad8b

Please sign in to comment.