THREE is not defined (latest versions)

2 hours ago 1
ARTICLE AD BOX

I'm trying to get three.js working via CDN with this in my HTML as explained on their installation page

<script type="importmap"> { "imports": { "three": "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js" } } </script> <script type="module"> import * as THREE from 'three'; </script> <script> // Try to use it - get an error here const canvas = document.querySelector('#canvas'); const renderer = new THREE.WebGLRenderer({antialias: true, canvas}); </script>

I get "Uncaught ReferenceError: THREE is not defined" in the console when I do it.

There's no other messages and no errors under the "network" tab in the inspector.

What am I doing wrong?

Read Entire Article