【发布时间】:2020-11-01 03:35:03
【问题描述】:
我偶然发现了将对象加载到 three.js 视口中的问题。教程显示需要使用 THREE.ObjectLoader()。就我而言,ObjectLoader 在几个版本前已被删除。正确加载模型的方式是什么,或者我应该使用什么加载器(和文件格式)? 我试过 GLTFLoader
import * as THREE from "https://cdn.jsdelivr.net/npm/three@0.114/build/three.module.js";
import { OrbitControls } from "https://cdn.jsdelivr.net/npm/three@0.114/examples/jsm/controls/OrbitControls.js";
import { GLTFLoader } from 'https://cdn.jsdelivr.net/npm/three@0.114.0/examples/jsm/loaders/GLTFLoader.js';
...
let loader = new GLTFLoader();
loader.load('./models/object.gltf',
(obj) => {
scene.add(obj);
}
);
它抛出了我 three.module.js:5562 THREE.Object3D.add: object not an instance of THREE.Object3D. CDN 加载器可以在这里找到 - https://cdn.jsdelivr.net/npm/three@0.114.0/examples/jsm/loaders/
更新:如何使用 ObjectLoader 导入数据?
import * as THREE from "https://cdn.jsdelivr.net/npm/three@0.114/build/three.module.js";
import { OrbitControls } from "https://cdn.jsdelivr.net/npm/three@0.114/examples/jsm/controls/OrbitControls.js;
...
let loader = new THREE.ObjectLoader();
loader.load('./models/object.json',
(obj) => {
scene.add(obj);
}
);
/* throws
three.module.js:39957 THREE.ObjectLoader: Loading "Geometry"
is not supported anymore
*/
【问题讨论】:
标签: three.js