1
votes

I am trying to put my .gltf model into a database. I built a restful API to get it from the database. But when I put the URL into Cesium's framework, an error occurs. The error is shown below.

enter image description here

      Sandcastle.addToolbarButton('models', function () {
    // eslint-disable-next-line
    var model = viewer.scene.primitives.add(Cesium.Model.fromGltf({
      id: 'house',
      url: 'http://127.0.0.1:8000/test',
      // url: gltf_data,
      modelMatrix: modelMatrix,
      scale: 0.1
    }))
  }, 'singleModel')

front end javascript code

class Test(flask_restful.Resource):
def get(self):
    client = MongoClient()

    db = client['test']
    fs = gridfs.GridFS(db)
    for x in fs.find():
        data = x.read()
        break
    data = data.decode('utf-8')
    # file = fs.find_one()
    return jsonify(data)

server end python code

1
Can you share the code that loads this model into Cesium? It looks like you may need to call JSON.parse() to turn the string into an object.emackey
that's the server end & front end code above. @emackeyKingsley.Kwong

1 Answers

0
votes

I fix out by myself, i forget to translate the string to json object, i added a json.loads(data) at server end's code. it runs. Thanks @emackey you give me an advise