Failed to resolve module specifier "three". Relative references must start with either "/", "./", or "../".

 

<script type="module">
    import * as THREE from './build/three.module.js'
	import { PointerLockControls } from './jsm/controls/PointerLockControls.js'
</script>

通过type="module"引入three.js可能会引起该报错

可以加上以下代码解决

	<script type="importmap">
		{
			"imports": {
				"three": "./build/three.module.js"
			}
		}
	</script>

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐