How to load a gltf model to Three.js?

落爺英雄遲暮 提交于 2019-12-08 18:48:36

问题


I decided to try out gltf format for rendering models in Three.js and I'm using this converter (http://cesiumjs.org/convertmodel.html) to convert the model from Collada to GlTF. It spits out a *.gltf file, however in the examples in Three.js they pass a *.json file. How can I load the *.gltf file or how can I get the proper set of files to load? Thanks


回答1:


You can use THREE.glTFLoader which can be found in the examples/js/loaders directory.

For a demo, see http://threejs.org/examples/webgl_loader_gltf.html.

three.js r.95




回答2:


The gltf file is a valid json file as far as I understand it. I opened a file converted from collada to gltf and it is just plain json. I put it also through the validator at JSONLint. I would suggest to change the file ending from .gltf to .json .



来源:https://stackoverflow.com/questions/25391529/how-to-load-a-gltf-model-to-three-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!