1, 安装插件
npm install three --save
2, 在main.js中设置一下,将three.js挂载到vue上:
import Vue from 'vue'
import * as Three from "three";
Vue.prototype.$three = Three;
页面中使用:
// 1,创建场景对象
this.scene = new this.$three.Scene();
// 创建缓存几何体对象
this.geomery = new this.$three.BufferGeometry();
// 创建环境光对象
this.light = new this.$three.AmbientLight( 0xffffff );
this.scene.add(this.light);