# ReferenceError: loadModel is not defined

**URL:** <https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877>\
**Category:** Coding Questions\
**Created:** [January 5, 2020, 1:35pm UTC](https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877 "2020-01-05T13:35:31Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![micheal](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@micheal](https://discourse.processing.org/u/micheal)\
**Post date:** [January 5, 2020, 1:35pm UTC](https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877/1 "2020-01-05T13:35:31Z")

</div>

Hi there  
I’m a new user of p5js and loving learning what’s possible!  
Can I get some advice please about the loadModel function?

I’m getting the error in console.log:  
“ReferenceError: loadModel is not defined”  
I can’t see where I’m going wrong, or how I’m deviating from the octahedron example at [https://p5js.org/reference/#/p5/loadModel](https://p5js.org/reference/#/p5/loadModel).  
Only change is that I’ve downloaded a simple ships hull .obj file and using that instead.

Do I need an additional line in the index.html file for loadModel to be available? I.e., something along the lines of…  
src=“libraries/p5.XXX???.js” type=“text/javascript”

Thanks!

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 5, 2020, 1:48pm UTC](https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877/2 "2020-01-05T13:48:11Z")

</div>

if you just link to your  
[https://editor.p5js.org/](https://editor.p5js.org/)  
project we not need to ask you for code of .js or .html

* * *

also there might be that  
hull.obj is there / and in the correct path? suggest  
“assets/hull.obj”  
there might be also from inthere be called a other file AND that might be missing  
“assets/?.mtl”

---

<div class="post-metadata">

**Author:** ![micheal](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@micheal](https://discourse.processing.org/u/micheal)\
**Post date:** [January 5, 2020, 2:17pm UTC](https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877/3 "2020-01-05T14:17:32Z")

</div>

Thanks kll! Good suggestion re [editor.p5js.org](http://editor.p5js.org), I wasn’t aware of this.  
I am using sublimetext 2 but have copied my code here also:  
[https://editor.p5js.org/micheal.ocathain/sketches/kM26r6njZ](https://editor.p5js.org/micheal.ocathain/sketches/kM26r6njZ)

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 5, 2020, 2:19pm UTC](https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877/4 "2020-01-05T14:19:36Z")

</div>

well, there is no  
“octahendron.obj”  
and i suggested you use a sub dir  
“assets/octahendron.obj”  
you make first and then upload that obj file

* * *

also did you read that file?  
does it need/load a ?.mtl file ( at the end )

---

<div class="post-metadata">

**Author:** ![micheal](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@micheal](https://discourse.processing.org/u/micheal)\
**Post date:** [January 5, 2020, 2:25pm UTC](https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877/5 "2020-01-05T14:25:01Z")

</div>

Thank you kll!  
It is working online now.

Using sublimetext2, I had the .obj file in the same directory as my index.html and sketch.js. Is there something else I need to do?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 5, 2020, 2:33pm UTC](https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877/6 "2020-01-05T14:33:34Z")

</div>

it looks like it works now,

- why have that 3 same objects ? from the .obj?

- why not used sub dir as i suggested

- when use stroke see that mesh lines, is that how you constructed that model?

- can use

```auto
setup() {
//..
  fill(); 
  noStroke();
}
 

```

but actually see less.

- better a operational 3D view  
instead that rotation thing…

---

<div class="post-metadata">

**Author:** ![micheal](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@micheal](https://discourse.processing.org/u/micheal)\
**Post date:** [January 5, 2020, 2:41pm UTC](https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877/7 "2020-01-05T14:41:14Z")

</div>

Oh yes, I agree with all your points.  
The model is actually three hulls!  
And yes, I’ll definitely use fill() and noStroke(), and also the /assets directory.

However, I’m wondering why it still doesn’t work locally on my laptop using sublimetext2. I downloaded the code that works as a zip file, but it is throwing an error in the console.log:  
+++++  
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///Users/cex/Documents/Processing/course%20-%20Heavy%20Lift/module%202/loadhull\_test/working%20on%[20p5js.org/3d-model.obj](http://20p5js.org/3d-model.obj). (Reason: CORS request not http).

TypeError: NetworkError when attempting to fetch resource. 2 [p5.js:78248:25](file:///Users/cex/Documents/Processing/course%20-%20Heavy%20Lift/module%202/loadhull\_test/working%20on%[20p5js.org/p5.js](http://20p5js.org/p5.js))  
+++++

I feel I’m missing something basic!!!

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 5, 2020, 2:48pm UTC](https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877/8 "2020-01-05T14:48:00Z")

</div>

-a- my operation version  
[https://editor.p5js.org/kll/sketches/Pags5nTVj](https://editor.p5js.org/kll/sketches/Pags5nTVj)

-b- with the other editor you are on your own  
a translate of the download to even  
PDE / mode p5.js  
is some work.

a direct run of of the download and unzip ( and double click index.html )  
is also not working until you have some kind of server mode  
( as file handling is involved / simple drawing are possible )

for chrome browser i use

> **[Web Server for Chrome](https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb)**
>
> A Web Server for Chrome, serves web pages from a local folder over the network, using HTTP. Runs offline.

-c- CORS and browser is a extra subject, search this forum  
for firefox i use

```auto
# CORS Everywhere
Bypass CORS restrictions by altering http responses.

```

---

<div class="post-metadata">

**Author:** ![micheal](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@micheal](https://discourse.processing.org/u/micheal)\
**Post date:** [January 5, 2020, 2:53pm UTC](https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877/9 "2020-01-05T14:53:55Z")

</div>

a - VERY nice kll, thanks! I like your navigation controls a lot, brilliant! And the fill() etc works great!

b - so do you generally just work online. One of the reasons I changed to local was to separate functions into different files on different tabs. Can you do this with [editor.p5js.org](http://editor.p5js.org)?

---

<div class="post-metadata">

**Author:** ![micheal](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@micheal](https://discourse.processing.org/u/micheal)\
**Post date:** [January 5, 2020, 2:56pm UTC](https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877/10 "2020-01-05T14:56:31Z")

</div>

Also thanks for the web server for Chrome and Firefox tips!

I have node installed - would this be a route to getting a local server mode set up?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 5, 2020, 3:03pm UTC](https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877/11 "2020-01-05T15:03:22Z")

</div>

> [@micheal](#):
>
> node

why not, i would call it a extra project and  
i would use it to have finished projects online available…  
++ i use Raspberry Pi for it /  
also you better have a main page with links to the p5.js …projects

but not for development  
( there i use online editor or PDE / p5.js mode )

---

<div class="post-metadata">

**Author:** ![micheal](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@micheal](https://discourse.processing.org/u/micheal)\
**Post date:** [January 5, 2020, 5:51pm UTC](https://discourse.processing.org/t/referenceerror-loadmodel-is-not-defined/16877/12 "2020-01-05T17:51:37Z")

</div>

oh great! I have done some coding on RPi but not yet with Processing. I’ll keep that in mind!

Thanks for all your help!!
