I want to view mesh data in Cesium serving file from my local disk, make my own ‘server’ but I don’t know how. Here is what I tried to do.
I have this catalog structure:
server.py
templates
-index.html
static
-b3dm files
-tileset.json
This is server.py file:
from flask import Flask, render_template, current_app
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route("/tileset")
def tileset():
return current_app.send_static_file('tileset.json')
if __name__ == '__main__':
app.run(debug=True)
This is part from index.html:
<div id="cesiumContainer"></div>
<script type="module">
Cesium.Ion.defaultAccessToken = 'token';
const viewer = new Cesium.Viewer('cesiumContainer');
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(21.025, 52.270, 500)
});
var tileset = viewer.scene.primitives.add(
new Cesium.Cesium3DTileset({
url: "http://127.0.0.1:5000/tileset"
})
);
</script>
Under http://127.0.0.1:5000/tileset json file displays correctly in the browser but mesh data doesn’t load in cesium viewer under index at http://127.0.0.1:5000.
Maybe I’m missing the whole point of how server should work, please correcr me if I’m wrong.
Why Flask? Because I’m somehow familiar with Python and I don’nt have permissions to install other software on my work computer.