Answer the question
In order to leave comments, you need to log in
Threejs not working locally?
On LAN, when opening index, nothing is a white screen, everything is fine on the host.
Answer the question
In order to leave comments, you need to log in
You need to understand that your script most likely receives data from somewhere, if you launched the page, then the console clearly wrote to you why you can’t use local files. So everything works, but you have an error. The node has a local server for these purposes.
greenline111
The essence of your mistake: the browser does not understand your js.
You have a choice, though not much:
1. Include Webpack, Gulp + Babel, Browserify + Babel or something else that builds your project correctly.
2. Change your code like this:
<!DOCTYPE html>
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
</head>
<body>
<canvas id="app"></canvas>
<script src="src/three.js"></script>
<script src="src/index.js"></script>
</body>
</html>
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question