threejs import json model

In fact, the current json model has two formats. One is the Geometry type and needs to be loaded by JSONLoader; the other is the Object type and needs to be loaded by ObjectLoader.

1. Geometry

var js_loader = new THREE.JSONLoader(manager);

js_loader.load('./models/hmj/frame001.json', function(geometry, materials) {
    var material = new THREE.MultiMaterial(materials);    // 多个纹理
    var mesh = new THREE.Mesh(geometry, material);
    mesh.scale.multiplyScalar(.06);
    scene.add(mesh);
}, onProgress, onError);

2. Object type

var object_loader = new THREE.ObjectLoader(manager);

object_loader.load('./models/teapot-claraio.json', function(object) {
    object.scale.multiplyScalar(5);
    scene.add(object);
});

Although the above two types of file formats all end in .json. But the data format inside is not the same.

Reference: https://www.jianshu.com/p/906072e60197

So, how to generate json data?

Export from bender? Or through what format converter? obj to json can be exported with blender, or other converters written by yourself: https://www.cnblogs.com/googlegis/p/13839857.html

https://www.zhihu.com/question/38739004

How to convert json format to obj in turn: https://threejs.org/editor/

Guess you like

Origin blog.csdn.net/nmj2008/article/details/113656394