maplibre / maplibre-gl-js

MapLibre GL JS - Interactive vector tile maps in the browser
https://maplibre.org/maplibre-gl-js/docs/
Other
6.29k stars 685 forks source link

support loading B3DM format data #2758

Open qlanto224 opened 1 year ago

qlanto224 commented 1 year ago

hello, when I want load B3DM with map, but tips: deck: initialization of ScenegraphLayer({id: 'ceshi-3d-scenegraph-http://localhost:5173/static/20230628/Tile_-3340_9261_0000/Tile_-3340_9261_0000_-0001_0007.b3dm'}): Cannot convert undefined or null to object;

but I use mapbox-gl , it is right.

so , plan to support data like B3DM?

thank you.

qlanto224 commented 1 year ago

maplibre-gl version:3.1.0. this my code:

import maplibregl from "maplibre-gl";
//@ts-ignore
import { Tile3DLayer } from "@deck.gl/geo-layers";
import { Tiles3DLoader } from "@loaders.gl/3d-tiles";
import {Matrix4} from "math.gl"
//@ts-ignore
import { MapboxLayer } from "@deck.gl/mapbox";
const dataUrl = "/static/20230628/tileset.json";
  let layer = new MapboxLayer({
    id: "test-3d",
    type: Tile3DLayer,
    data: dataUrl,
    loader: Tiles3DLoader,
    onTileError: (err) => {
      console.log(err);
    },
    onTilesetLoad: (tileset) => {
      tileset.setProps({ maximumScreenSpaceError: 1 });
      const { cartographicCenter, zoom } = tileset;
      layer.viewState = {
        center: cartographicCenter,
        zoom,
      };

      let mdMtx = new Matrix4().makeTranslation(1, 1, -200);
      tileset.modelMatrix = mdMtx;
      map.jumpTo(layer.viewState);
    },
  });
  map.addLayer(layer);
HarelM commented 1 year ago

The current examples we have are with gltf files. I'm not an expert of 3D formats, but if you can convert from b3dm to gltf your might be able to use the existing examples.

Cc @Pessimistress

qlanto224 commented 1 year ago

The current examples we have are with gltf files. I'm not an expert of 3D formats, but if you can convert from b3dm to gltf your might be able to use the existing examples.

Cc @Pessimistress

sure , gftf is ok , but i have to use b3dm, find mapbox can load b3dm