1 github下载three.js源码
2 源码目录随便创建一个html
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - glTF 2.0 - compressed</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<body>
<input type="file" id="files" />
<script type="module">
import {GLTFLoader} from './examples/jsm/loaders/GLTFLoader.js';
document.getElementById("files").addEventListener("change",event=>{
const loader = new GLTFLoader();
var reader = new FileReader();
reader.readAsArrayBuffer(event.currentTarget.files[0]);
reader.onload = function () {
loader.parse(this.result,"",function ( gltf ) {
console.log(gltf)
},function ( err ){
console.log(err)
})
console.log(this.result);
}
})
</script>
</body>
</html>
3 启动three.js 模型读取成功后参照官方教程添加到页面