1.实现效果


2.代码
1.npm安装three.js
npm install three
2.引入three.js
import * as THREE from 'three'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
3.初始化模型
init(val) {
this.container = document.querySelector('.container')
// 初始场景
this.scene = new THREE.Scene()
// 初始化相机
this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
// 相机位置
this.camera.position.z = 5
// 初始化渲染器
this.renderer = new THREE.WebGLRenderer()
this.renderer.setSize(window.innerWidth, windo