Hello I am new to Three.js and I wanted to make a project with a 3D Torus in the background. I am following a beginners tutorial but I notice that when I open index.html it is only a white screen. Not even the canvas is showing. Here is my index.html code:
Consider Chrome Devtools Console your best new friend. In 99% of cases it will explain you precisely what is wrong.
In this case the “wrong” is the typo in MeshStandardMaterial (As long as you have the <canvas width="some-width" height="some-height /> also set - besides the typo it does seem to work correctly.)
I did change the typo, however, the canvas still doesn’t show. It does reflect as an HTML object on the developer tools, however, I don’t think it understands it’s a canvas. It is still just a white screen and is not showing anything.
Your code copied to codepen works - so, assuming you’re still using the code from the earlier post with just the typo fixed, it should be alright.
Take a look into devtools if there are any errors, use console.log to check if values of your variables are correct, also be sure to check if the canvas has a set width and height.
as @mjurczyk noticed you misspelled the name of the material, also point light helper doesn’t accept color as a parameter and you can’t import CSS files using import statement in JavaScript modules.
So, if it opens fine in an online compiler, then why doesn’t it open on my index.html file on the browser? Should I have downloaded something beforehand? If I host the webpage will it work?