threejs官网:
https://threejs.org/
使用cdn引入threejs
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@v0.149.0/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@v0.149.0/examples/jsm/"
}
}
</script>
// 导入THREE和控制器
import * as THREE from 'three';
import {
OrbitControls } from 'three/addons/controls/OrbitControls.js';
// 创建场景
const scene = new THREE.Scene();
// 设置背景色,16进制
// scene.background = new THREE.Color(0xffffff);
// 设置背景图片,需要6个图片,setPath为图片文件夹地址,load填写具体文件名,必须为正方形图片,否则报错
scene.background = new