THREE is not defined

I always get the error THREE is not defined, I have not found any solution yet.
I’ve attached the three.js library in the script tag. I don’t know what seems to be the problem.

I’ve tried

loadScripts(["js/vendor/three/three.js"], function() {
    console.log( THREE );
});

screenshots:

Where does this function come from?

Please include the entire code that reproduces your problem, copying a tiny snippet is not enough to help you.

Thank you for u reply, one moment.

loadScripts => THREE is not defined in .js file

Im working with this tutorial: https://discoverthreejs.com/book/1-first-steps/6-shapes-transformations/

Folder:

I fix’ed it:
I had: (color with small c)

scene.background = new THREE.clolor( ‘skyblue’ )
fix:
scene.background = new THREE.Clolor( ‘skyblue’ )

But why is there such a big impact? I mean THREE is still defined right?

Holy “”"" u are the creator of this book :hushed:

U are awesome I love it, can’t wait to see the full release :wink: I started Coding (JavaScript) last week and ur book really helped me Thx <3

Question: In the Chapter (GETTING CREATIVE WITH SHAPES AND TRANSFORMATIONS) should I edit the file I already have or should I create a completely new document? Like I did now?

Holy “”"" u are the creator of this book :hushed:

Haha! Thank you :grin:

OK, your code is generally fine, but there are lots of misspellings:

  1. styles folder should be ‘styles’ folder.
  2. PerscpectiveCameraPerspectiveCamera
  3. faltShadingflatShading

I know this because I use VSCode as an editor, and I’ve installed a spell checker extension so that those words were immediately highlighted.

It won’t help you if you forget a capital letter though, like colorColor. Then you get an error.

should I edit the file I already have or should I create a completely new document? Like I did now?

You can create a new file like you did now, that’s fine.

However, for the next chapter that won’t work, since you need to load models. Then you need to run a HTTP server. I use http-server, and there’s more info about this on the How to run things locally page.

That’s awesome, thank you for ur recommendation, I already downloaded VScode and the spell checker, that’s awesome! My spelling is not really good so this is perfect for me. I also corrected my spellings so I think I’m good to go. :relaxed:

First I was wondering why I can’t see the blue background, do I need a render engine for the background?

instead of using an HTTP server could I change the origin policy on my browser alternatively?

u mentioned some forums like this one here, is there a way to find u on discord? I am already in some really pleasant forums but I would really appreciate a Mentor *)

There are ways of configuring your browser to load it, but I’m not going to recommend any because it breaks the security on your computer and then people could steal your info. It’s best to use a HTTP server.

First I was wondering why I can’t see the blue background, do I need a render engine for the background?

The script you sent me only has about half as many lines as the example in the book. Try adding the rest.

I finished the script:) and I didn’t saw any information about the render in the chapter. do I need to add one on my own?

Try using THREE.Color instead of THREE.Clolor. Cloror is a type of cleaner, like clorox.

1 Like