Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when viewing tiles #9273

Open
Osurac529 opened this issue Dec 9, 2020 · 3 comments · Fixed by #9271
Open

Crash when viewing tiles #9273

Osurac529 opened this issue Dec 9, 2020 · 3 comments · Fixed by #9271

Comments

@Osurac529
Copy link

Osurac529 commented Dec 9, 2020

I am getting this error using 1.73 when viewing tiles, have not tried a newer version but the end of the stack trace seems to look the same as the current code in github master. I believe the problem is related to this line of code and that 'command' is undefined:

var derivedCommands = command.derivedCommands.tileset;

TypeError: Cannot read property 'derivedCommands' of undefined

TypeError: Cannot read property 'derivedCommands' of undefined
at Cesium3DTileBatchTable.addDerivedCommands (http://localhost:8080/node_modules/cesium/Build/CesiumUnminified/Cesium.js:126807:37)
at Batched3DModel3DTileContent.update (http://localhost:8080/node_modules/cesium/Build/CesiumUnminified/Cesium.js:149720:24)
at Cesium3DTile.process (http://localhost:8080/node_modules/cesium/Build/CesiumUnminified/Cesium.js:175245:19)
at processTiles (http://localhost:8080/node_modules/cesium/Build/CesiumUnminified/Cesium.js:177942:16)
at Cesium3DTileset.prePassesUpdate (http://localhost:8080/node_modules/cesium/Build/CesiumUnminified/Cesium.js:177803:5)
at PrimitiveCollection.prePassesUpdate (http://localhost:8080/node_modules/cesium/Build/CesiumUnminified/Cesium.js:194115:19)
at prePassesUpdate (http://localhost:8080/node_modules/cesium/Build/CesiumUnminified/Cesium.js:280355:16)
at tryAndCatchError (http://localhost:8080/node_modules/cesium/Build/CesiumUnminified/Cesium.js:280452:7)
at Scene.render (http://localhost:8080/node_modules/cesium/Build/CesiumUnminified/Cesium.js:280521:5)
at CesiumWidget.render (http://localhost:8080/node_modules/cesium/Build/CesiumUnminified/Cesium.js:294542:19)

Here is an example tileset that causes the problem:
https://drive.google.com/file/d/1V0YqM08jo_8Q_zhnQ9J1R5myu84Ouf3o/view?usp=sharing

Load the tileset into cesium, look at it top down, use the 3D Tiles Inspector and set the Maximum Screen Space Error to zero and the error will occur.

@Osurac529
Copy link
Author

This is the same as #9278, it makes sense because I also disabled backface culling and it started happening, I want to say more, it did happen without that change but much less frequently.

@lilleyse
Copy link
Contributor

@Osurac529 I created a sandcastle based on your steps but I wasn't able to trigger the problem. Hopefully you can confirm whether #9278 fixes the problems.

var viewer = new Cesium.Viewer('cesiumContainer', {
  //terrainProvider: Cesium.createWorldTerrain()
});

var tileset = new Cesium.Cesium3DTileset({
  url: 'http://localhost:8002/static/Desktop/tiles/tileset_geographic.json',
  backFaceCulling: false
});

tileset.readyPromise.then(function() {
    viewer.zoomTo(tileset);    
});

viewer.scene.primitives.add(tileset);

viewer.extend(Cesium.viewerCesium3DTilesInspectorMixin);
var inspectorViewModel = viewer.cesium3DTilesInspector.viewModel;
@Osurac529
Copy link
Author

Osurac529 commented Jan 6, 2021

I tried 1.77 and I am still getting the same error. I didn't include the code in my original post which will help. It definitely has to do with setting backFaceCulling to false. Here is the code:

`var viewer = new Cesium.Viewer('cesiumContainer', {
scene3DOnly: true,
selectionIndicator: false,
baseLayerPicker: false,
timeline: false,
infoBox: false,
animation: false
//globe: false
});

viewer.imageryLayers.removeAll(false);

var showGlobeImagery = false;
var showGlobeTerrain = true;

if (showGlobeImagery)
{
  // add imagery
  viewer.imageryLayers.addImageryProvider(new Cesium.createWorldImagery({
    style : Cesium.IonWorldImageryStyle.AERIAL_WITH_LABELS}));
}

// Load Cesium World Terrain
if (showGlobeTerrain)
{
  viewer.terrainProvider = Cesium.createWorldTerrain({
    requestWaterMask : true, // required for water effects
    requestVertexNormals : true // required for terrain lighting
  });

  // Enable depth testing so things behind the terrain disappear.
  viewer.scene.globe.depthTestAgainstTerrain = true;
}

viewer.extend(Cesium.viewerCesium3DTilesInspectorMixin);
var inspectorViewModel = viewer.cesium3DTilesInspector.viewModel;

var tileset = new Cesium.Cesium3DTileset({ url: "http://localhost:8080/Source/SampleData/tileset_geographic.json",
                                           backFaceCulling: false });

var tileSetEventListener = function() {
    tileset.allTilesLoaded.removeEventListener(tileSetEventListener);
    console.log('All tiles are loaded');
    
    // Adjust a tileset's height from the globe's surface.
    var heightOffset = 40.0;
    var boundingSphere = tileset.boundingSphere;
    var cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center);
    var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
    var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, heightOffset);
    var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
    tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);

    inspectorViewModel.performance = true;
    inspectorViewModel.picking = false;
    inspectorViewModel.showBoundingVolumes = true;
    inspectorViewModel.maximumScreenSpaceError = 36;        
    inspectorViewModel.toggleLogging();
}

tileset.allTilesLoaded.addEventListener(tileSetEventListener);

inspectorViewModel.tileset = tileset;
viewer.scene.primitives.add(tileset);

tileset.readyPromise.then(function(tileset) {
    var boundingSphere = tileset.boundingSphere;
    var range = 2 * boundingSphere.radius;
    viewer.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0, -2.0, range));
    viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
}).otherwise(function(error) {
    throw(error);
});

var scene = viewer.scene;
var canvas = viewer.canvas;
if (!scene.pickPositionSupported) {
    window.alert("This browser does not support pickPosition.");
}

var entity = viewer.entities.add({
    label: {
      show: false,
      showBackground: true,
      font: "14px monospace",
      horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
      verticalOrigin: Cesium.VerticalOrigin.TOP,
      pixelOffset: new Cesium.Cartesian2(15, 0),
    },
  });

  // Mouse over the globe to see the cartographic position
  var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
  handler.setInputAction(function (movement) {
    var cartesian = viewer.camera.pickEllipsoid(
      movement.endPosition,
      scene.globe.ellipsoid
    );
    if (cartesian) {
      var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
      var longitudeString = Cesium.Math.toDegrees(
        cartographic.longitude
      ).toFixed(15);
      var latitudeString = Cesium.Math.toDegrees(
        cartographic.latitude
      ).toFixed(15);

      entity.position = cartesian;
      entity.label.show = true;
      entity.label.text =
        "Lon: " +
       // ("   " + longitudeString).slice(-7) +
        ("   " + longitudeString) +
        "\u00B0" +
        "\nLat: " +
        //("   " + latitudeString).slice(-7) +
        ("   " + latitudeString) +
        "\u00B0";
    } else {
      entity.label.show = false;
    }
  }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

  canvas.setAttribute("tabindex", "0"); // needed to put focus on the canvas
  canvas.onclick = function () {
    canvas.focus();
  };`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment