Intenté importar OrbitControls pero no funciona.
Importé three.js y luego intenté importar OrbitControls pero no funciona. Importé three.js en el cuerpo del html con este script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/104/three.js" NOTA: tengo una escena, una cámara y un renderizador, pero no puedo publicar esta publicación con ellos aquí
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="Css/master.css"> </head> <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/104/three.js"></script> <script src="Main.js"></script> </body> </html> ***Main.js*** import { OrbitControls } from 'three/example/jsm/controls/OrbitControls'; const controls = new OrbitControls(camera, renderer.domElement); function animate(){ requestAnimationFrame(animate); torus.rotation.x +=0.01; torus.rotation.y +=0.01; torus.rotation.z +=0.01; controls.update(); renderer.render(scene,camera); } animate()Está utilizando la versión jsm de OrbitControls, lo que significa que necesita un módulo para el archivo Javascript. Cambio:
<script src="Main.js"></script>
a
<script type="module" src="Main.js"></script>
Eso debería hacer el truco.