1.在.html文件中引入three.js就像前端经常使用的jquery.js一样引入即可。我们可以先把threejs安装包下载到本地,引入即可
<!-- //引入three.js本地包 -->
<script type="importmap">
{
"imports": {
"three": "./three.js-master/build/three.module.js",
"three/addons/": "./three.js-master/examples/jsm/"
}
}
</script>
<script type="module">
import * as THREE from "three";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
</script>
2.http绝对地址远程加载
<!-- //引入three.js -->
<script src="http://www.yanhuangxueyuan.com/threejs/build/three.min.js"></script>
3.如果你采用的是Vue + threejs或React + threejs技术栈,直接通过npm命令行安装就行。
npm安装特定版本three.js(注意使用哪个版本,查文档就查对应版本
// 比如安装148版本
npm install three@0.148.0 --save
// 引入three.js
import * as THREE from 'three';
————————————————
版权声明:本文为CSDN博主「m0_69757621」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/m0_69757621/article/details/134051049