docs(Installation): import OrbitControls from Skypack CDN is not working
See original GitHub issueDescribe the bug
Try using the OrbitControls
from Skypack CDN according to the installation section but not working now.
Seems after #23255 merged, it also needs to use import maps
before importing modules in examples.
And also I found the Skypack CDN will still try to export the default even though a js module has no default export.
After I tried, I solved these two problems with the following code:
<script type="importmap">
{
"imports": {
"three": "https://cdn.skypack.dev/three"
}
}
</script>
<script type="module">
// Find the latest version by visiting https://cdn.skypack.dev/three.
import { OrbitControls } from 'https://unpkg.com/three/examples/jsm/controls/OrbitControls.js';
const controls = new OrbitControls( camera, renderer.domElement );
</script>
I think the related docs can be updated to this, what do you think? But in my solution, I’m using two different CDNs. In case Skypack is currently unavailable, I wonder if we can switch all to unpkg (https://unpkg.com/three/build/three.module.js
)?
To Reproduce
Steps to reproduce the behavior:
- Create a new pen from https://codepen.io
- Paste below code
Code
<script type="module">
// Find the latest version by visiting https://cdn.skypack.dev/three.
import { OrbitControls } from 'https://cdn.skypack.dev/three/examples/jsm/controls/OrbitControls.js';
const controls = new OrbitControls( camera, renderer.domElement );
</script>
Expected behavior
Successful import.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Uncaught TypeError when accessing OrbitControls ... - GitHub
This appears to be a temporary problem with the Skypack CDN, and is reported on their status page here: https://status.skypack.dev/.
Read more >npm:three-orbit-controls - Skypack.dev
Git clone, npm install and then run npm start to spin up a development server. Open localhost:9966 in your browser to see the...
Read more >three.js / OrbitControls is not defined - Stack Overflow
You are mixing ES6 module with non-module code which is not valid. Do it like so: <script type="module"> import * as THREE from ......
Read more >Installation – three.js docs
Addons do not need to be installed separately, but do need to be imported separately. If three.js was installed with npm, you can...
Read more >THREE.js orbit controls - Anvil Works
And then amend the import statement to be what we want. <script type="module"> import {OrbitControls} from 'https://cdn.skypack.dev/@three-ts/ ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Should we just change the links to use https://unpkg.com/ instead?
This is a bug with skypack-cdn: https://github.com/skypackjs/skypack-cdn/issues/263