load local 3dtiles

my code:

  <div id="cesiumContainer" style="width: 100%; height: 100vh;"></div>
    <script type="module">
        Cesium.Ion.defaultAccessToken = 'aaa';

        // Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
        var viewer = new Cesium.Viewer('cesiumContainer');

        // Fly the camera to San Francisco at the given longitude, latitude, and height.
        viewer.camera.flyTo({
            destination: Cesium.Cartesian3.fromDegrees(106.56901, 29.5139, 5000),
            orientation: {
                heading: Cesium.Math.toRadians(0.0),
                pitch: Cesium.Math.toRadians(-40.0),
            }
        });

        var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
            url: 'mydata/3dtiles/tileset'
        }));

    </script>
    </div>

image

I want to load a local 3dtiles file, but it never works. The Chrome browser does not report an error, and the data can be displayed when it is published to Cesium ion. I don’t know why. A similar loading method can load a json file successfully. There should be no problem with the path, and the data is only about 1.5M. who can help me solve this problem,thank you.

Hi @yh_j, welcome to the community!

Most browsers do not allow you to load files from the local filesystem–this is to prevent malicious websites from accessing data on your computer.

You can make your local data available to the browser by starting a local server. Here is a previous thread with links to more information about how to set up a local server.

Hi @yh_j, we also have this guide covering how to serve 3D TIles and other common geospatial data formats which can be consumed by CesiumJS locally & offline during the development process.