使用three.js
项目中使用three.js
npm 下载
npm install --save three
在项目中引入three.js
引入three.js
// 1: 全部引入.
import * as THREE from 'three';
const scene = new THREE.Scene();
// 2: 引入部分.
import { Scene } from 'three';
const scene = new Scene();
注意:如果需要引入three中的GLTFLoader之类的需要这样
import {
GLTFLoader
} from 'three/examples/jsm/loaders/GLTFLoader.js'
这里的three为node_modules中的three
当前文件为npm下载的three.js集合文件