question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trying to ExpoTHREE.loadObjAsync | Can't find variable: THREE

See original GitHub issue

As soon as I try to run this line of code:

const mesh = await ExpoTHREE.loadObjAsync({asset: require(‘…/assets/models/head.obj’)});

My app starts complaining about this. Everything else is fine. I’ve already got a cube spinning no problem. I’ve dug into this a lot, but it looks like the OBJLoader.js file is complaining that it can’t find THREE.

image

Is it right that we’re using a file out of the examples folder of three?

what about the seperate package of three-obj-loader? Is that needed?

Can't find variable: THREE


<unknown>
    OBJLoader.js:5:6
loadModuleImplementation
    require.js:331:6
guardedLoadModule
    require.js:197:45
loadObjAsync$
    loadModelsAsync.js:48:15
tryCatch
    runtime.js:45:44
invoke
    runtime.js:271:30
tryCatch
    runtime.js:45:44
invoke
    runtime.js:135:28
<unknown>
    runtime.js:145:19
tryCallOne
    core.js:37:14
<unknown>
    core.js:123:25
_callTimer
    JSTimers.js:152:14
_callImmediatesPass
    JSTimers.js:200:17
callImmediates
    JSTimers.js:473:30
__callImmediates
    MessageQueue.js:337:6
<unknown>
    MessageQueue.js:135:6
__guard
    MessageQueue.js:314:10
flushedQueue
    MessageQueue.js:134:17

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
chrisbarrycommented, Aug 9, 2019

I installed three-obj-loader

var OBJLoader = require(‘three-obj-loader’); OBJLoader(THREE);

And put this at the top of the file, now it’s working no problem?

Any ideas?

1reaction
bberakcommented, Aug 10, 2019

For others getting the can't find variable: THREE problem, add the following lines near the beginning of your program:

import { THREE } from "expo-three";

global.THREE = THREE;

A lot of the code in ThreeJS relies on a global THREE variable (unfortunately).

Read more comments on GitHub >

github_iconTop Results From Across the Web

0 - Stack Overflow
Absolutely a beginner in three.js not sure what causes the two errors. Errors: 1. Can't find variable: THREE line 21:31 frame.html 2. import ......
Read more >
Can't Load Obj Model With Textures Using Expo-Three
I'm trying to load OBJ model with MTL and textures using expothree. The issue is that model is loading without textures and it...
Read more >
expo-three - npm
Welcome to Expo & Three.JS. Tools for using three.js to create universal 3D experiences | Try it in the browser! GitHub Actions status....
Read more >
Three.js Part 8: Loading Models - YouTube
An updated version of export/import workflows between Blender and three.js can be found ...
Read more >
How to Import a 3D Blender Object into a Three.js Project as a ...
Navigate to wherever you want to save the file, and hit the “Export glTF 2.0 binary” button.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found