
通过 unpkg 引入 three.js
您希望通过 unpkg 在没有任何前端框架的情况下导入 three.js。然而,在您的代码中,您在 main.js 中无法识别 THREE。
出现此错误是因为您尚未在 index.html 中正确导入 THREE 模块。要解决此问题,请进行以下更改:
使用 importmap 引入 three.js 模块:
index.html
或者,直接在
index.html
现在,您可以在 main.js 中通过以下方式访问 THREE:
main.js
console.log("Hello Three.js");
console.log("js" + THREE);
const scene = new THREE.Scene();










