Javascript 如何将3D模型加载到三个JS(JSON格式)

Javascript 如何将3D模型加载到三个JS(JSON格式),javascript,html,three.js,3d,gpu,Javascript,Html,Three.js,3d,Gpu,我需要导入一个JSON文件,其中包含关于三个JS的3D模型的信息。 我有三个JS的锅炉代码,我还有一个加载器函数: const loader = new THREE.ObjectLoader(); loader.load( // resource URL "modell.json", // onLoad callback // Here the loaded data is assumed to be an object funct

我需要导入一个JSON文件,其中包含关于三个JS的3D模型的信息。 我有三个JS的锅炉代码,我还有一个加载器函数:

const loader = new THREE.ObjectLoader();

loader.load(
    // resource URL
    "modell.json",

    // onLoad callback
    // Here the loaded data is assumed to be an object
    function ( obj ) {
        // Add the loaded object to the scene
        scene.add( obj );
        console.log(scene)
    },

    // onProgress callback
    function ( xhr ) {
        console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
    },

    // onError callback
    function ( err ) {
        console.error( 'An error happened' );
    }
);
运行这段代码时,我没有收到任何错误或警告,但是模型没有显示

JSON文件的内容(如果需要):

{
    "metadata": {
        "version": 4.4,
        "generator": "io_three",
        "type": "Object"
    },
    "animations": [{
        "fps": 29,
        "tracks": [],
        "name": "default"
    }],
    "images": [],
    "textures": [],
    "geometries": [{
        "uuid": "EC53DCE4-C690-3888-9701-2800E0AFBE11",
        "data": {
            "skinWeights": [],
            "influencesPerVertex": 2,
            "normals": [],
            "vertices": [],
            "skinIndices": [],
            "faces": [],
            "metadata": {
                "version": 3,
                "generator": "io_three",
                "bones": 0,
                "uvs": 0,
                "normals": 0,
                "morphTargets": 0,
                "materials": 0,
                "vertices": 0
            },
            "animations": [],
            "morphTargets": [],
            "name": "defaultGeometry",
            "bones": [],
            "uvs": []
        },
        "materials": [],
        "type": "Geometry"
    }],
    "materials": [{
        "uuid": "7F7EA3D4-7ACA-326E-BEE4-3EA415B8E912",
        "blending": "NormalBlending",
        "type": "MeshPhongMaterial",
        "shininess": 50,
        "emissive": 0,
        "specular": 131586,
        "color": 8355711,
        "ambient": 8355711,
        "depthTest": true,
        "depthWrite": true,
        "vertexColors": false,
        "name": "armadillo_default"
    }],
    "object": {
        "uuid": "A4515F76-5125-492C-9CF8-7B3B0E15D8BE",
        "children": [{
            "name": "armadillo2",
            "uuid": "8AD86B53-F2E6-3978-A91C-657CCBEC6D8E",
            "matrix": [-1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1],
            "visible": true,
            "type": "Object",
            "children": [{
                "name": "default",
                "uuid": "E918B3CA-7846-3104-8C4D-FEB016A9E618",
                "matrix": [0.972172,0,0,0,0,-0,-0.972172,0,0,0.972172,-0,0,-0.015785,0.021605,0,1],
                "visible": false,
                "type": "Mesh",
                "material": "7F7EA3D4-7ACA-326E-BEE4-3EA415B8E912",
                "castShadow": true,
                "receiveShadow": true,
                "geometry": "EC53DCE4-C690-3888-9701-2800E0AFBE11"
            }]
        }],
        "matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
        "type": "Scene"
    }
}

我该怎么做才能使我的模型显示在页面上。

恐怕您的JSON文件使用了过时的JSON格式,无法再加载了。您必须返回到
r98
加载JSON,然后使用
Scene.toJSON()
再次导出它。生成的JSON是对象/场景格式4,可以再次使用最新的
ObjectLoader
加载该格式。

是否可以使用创建?