Issue loading gltf with webpack

1. A concise explanation of the problem you’re experiencing.

Hi,

I’m using webpack and cesium. I’m getting the error visible on the attached screenshot.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

var Cesium = require('cesium/Cesium');
require('./css/main.css');
require('cesium/Widgets/widgets.css');

var viewer = new Cesium.Viewer('cesiumContainer');

var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
    Cesium.Cartesian3.fromDegrees(-75.62898254394531, 40.02804946899414, 2000.0));

var model = viewer.scene.primitives.add(Cesium.Model.fromGltf({
    url : 'data/Model2.glb',
    modelMatrix : modelMatrix,
    scale : 20000.0
}));

viewer.zoomTo(model);

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

4. The Cesium version you’re using, your operating system and browser.

Cesium 1.60

MacOS

Firefox

This is actually not a problem not an issue with webpack. You’ll see the same error if you try it in Sandcastle:

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(

Cesium.Cartesian3.fromDegrees(-75.62898254394531, 40.02804946899414, 2000.0));

var model = viewer.scene.primitives.add(Cesium.Model.fromGltf({

url : '../../SampleData/models/CesiumAir/Cesium_Air.glb',

modelMatrix : modelMatrix,

scale : 20000.0

}));

viewer.zoomTo(model);

``

The problem is the viewer.zoomTo method does not take a model. You could try passing in the position of the model and offset, with the viewer.camera.flyTo or viewer.camera.zoomTo methods, or use an Entity which will allow you to just do viewer.zoomTo(model) like in this example:

https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=3D%20Models.html

Let me know if that helps.

Thanks, I thought that viewer.zooTo was equivalent to viewer.camera.zoomTo. Thanks for the feedback !

Glad to hear that worked!

What kind of project are you working on?

Mostly on 3D landscapes visualization.