Skip to main content
Question

importing threejs orbitcontrol module

  • September 9, 2024
  • 0 replies
  • 44 views

_Eric

Hi for the life of me I can’t figure out how to properly import threejs orbitcontrols. I consistently get the error:

Failed to resolve module specifier “three-orbit-controls”. Relative references must start with either “/”, “./”, or “…/”.

I installed with npm, three-orbit-controls is in my node_modules folder and it is listed as a dependency. Here’s how I’m calling it in my project:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Three.js Viewer</title>
    <style>
        body { margin: 0; }
        #threejs-container { width: 100%; height: 100vh; }
    </style>
</head>
<body>
    <div id="threejs-container"></div>
    <script type="module">
        import * as THREE from 'https://unpkg.com/three@0.132.2/build/three.module.js';
        import { OrbitControls } from 'three-orbit-controls';
        // rest of code

Any help here would be so so helpful

This topic has been closed for replies.

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings