dayjournal / itowns-starter

Start iTowns easily. [iTowns, Vite]
https://dayjournal.github.io/itowns-starter
MIT License
6 stars 3 forks source link

error while loading tileset #2

Closed PerspectivesLab closed 8 months ago

PerspectivesLab commented 1 year ago

hi, i am trying to follow up with itowns and load a tileset:

const extensions = new itowns.C3DTExtensions();
extensions.registerExtension('3DTILES_batch_table_hierarchy', {
  [itowns.C3DTilesTypes.batchtable]:
    itowns.C3DTBatchTableHierarchyExtension,
});

// Create the 3D Tiles layer
const $3dTilesLayerDiscreteLOD = new itowns.C3DTilesLayer(
  "IDS",
  {
    name: `BTHierarchy`,
    source: new itowns.C3DTilesSource({
      url: `https://dataset-dl.liris.cnrs.fr/three-d-tiles-lyon-metropolis/2015/Lyon-1_2015/tileset.json`,
      crs: 'EPSG:4978', //
    }),
    registeredExtensions: extensions,
    onTileContentLoaded(tileContent) {
      if ($3dTilesLayerDiscreteLOD.renderData) {
        console.log('Loaded tile from asset ', $3dTilesLayerDiscreteLOD.renderData.name);
      }

    },
  },
  view,
);

 view.addLayer(   $3dTilesLayerDiscreteLOD );  

but the error is raised: Uncaught TypeError: Cannot read properties of undefined (reading 'children')

do you have clue if loading tiles with itowns + vite is doable ? thx

dayjournal commented 8 months ago

Hi @PerspectivesLab, I ran it with this sample code, and it displayed the data. Try it with this code. Ensure your tileset.json is correct and there are no problems with the code.

const $3dTilesLayerDiscreteLOD = new itowns.C3DTilesLayer('3d-tiles-discrete-lod', {
    name: 'DiscreteLOD',
    sseThreshold: 0.05,
    source: new itowns.C3DTilesSource({
        url: 'https://raw.githubusercontent.com/CesiumGS/3d-tiles-samples/master/1.0/TilesetWithDiscreteLOD/tileset.json',
    }),
}, view);

itowns.View.prototype.addLayer.call(view, $3dTilesLayerDiscreteLOD);

https://github.com/iTowns/itowns/blob/master/examples/3dtiles_basic.html#L46

スクリーンショット 2024-02-19 15 12 20