当我尝试导入 OrbitControls.js 时,出现以下内容:
我得到了Cannot use import statement outside a module
error
所以,我使用:
<script type="module" src="OrbitControls.js"></script
>
但这次我得到:
ReferenceError: OrbitControls is not defined
HTML 正文:
<body>
<div id="page-wrapper">
<h1>Open Spaceport Container (.drc):</h1>
<div>
<input type="file" id="fileInput">
</div>
</div>
<div>
<pre id="decoderType"><pre>
</div>
<div>
<pre id="fileDisplayArea"><pre>
</div>
<script src="https://cdn.rawgit.com/mrdoob/three.js/dev/build/three.min.js"></script>
<script src="DRACOLoader.js"></script>
<script src="geometry_helper.js"></script>
<script type="module" src="OrbitControls.js"></script>
<script>
"use strict"
// Configure decoder and create loader.
var textureLoader = new THREE.TextureLoader();
const loadManager = new THREE.LoadingManager();
...
您将 ES6 模块与无效的非模块代码混合在一起。这样做:
<script type="module">
import * as THREE from 'https://cdn.jsdelivr.net/npm/[email protected] /cdn-cgi/l/email-protection/build/three.module.js';
import { DRACOLoader } from 'https://cdn.jsdelivr.net/npm/[email protected] /cdn-cgi/l/email-protection/examples/jsm/loaders/DRACOLoader.js';
import { OrbitControls } from 'https://cdn.jsdelivr.net/npm/[email protected] /cdn-cgi/l/email-protection/examples/jsm/controls/OrbitControls.js';
// your actual app code
// Configure decoder and create loader.
const manager = new THREE.LoadingManager();
const textureLoader = new THREE.TextureLoader(manager);
</script>
我建议你转换你的自定义geometry_helper.js
也可以连接到 ES6 模块。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)