• Mapbox 与 Babylon.js 可视化 使车动起来


    我决定不从Babylonjs 基础来讲了 直接整合mapbox与babylonjs可视化来讲

    我整合一个类库 后续不断更新中

    • npm i @haibalai/mapbox-babylonjs

     

    初始化mapbox-babylonjs 类库, map 是mapbox.gl 的map 对象

    • import { BabylonMapManager } from "@haibalai/mapbox-babylonjs";
    • BabylonMapManager.init(map);

     

    添加正方体

    • import { BabylonMapManager } from "@haibalai/mapbox-babylonjs";
    • let map = MapManager.getMap(this.mapId);
    • let scene = BabylonMapManager.getScene(map);
    • const outline = [
    • new BABYLON.Vector3(-0.3, 0, -0.1),
    • new BABYLON.Vector3(0.2, 0, -0.1),
    • ]
    • //curved front
    • for (let i = 0; i < 20; i++) {
    • outline.push(new BABYLON.Vector3(0.2 * Math.cos(i * Math.PI / 40), 0, 0.2 * Math.sin(i * Math.PI / 40) - 0.1));
    • }
    • //top
    • outline.push(new BABYLON.Vector3(0, 0, 0.1));
    • outline.push(new BABYLON.Vector3(-0.3, 0, 0.1));
    • //back formed automatically
    • const car = BABYLON.MeshBuilder.ExtrudePolygon("car", {sideOrientation: 1, shape: outline, depth: 0.2}, scene);
    • BabylonMapManager.addToMap(car,[113.87629508972168, 22.544824222364753, 10]);
    • car.scaling.x = 200;
    • car.scaling.y = 200;
    • car.scaling.z = 200;
    • car.rotation = new BABYLON.Vector3(-Math.PI/2,0,0);
    • const carMat = new BABYLON.StandardMaterial("carMat");
    • carMat.diffuseTexture = new BABYLON.Texture("");
    • car.material = carMat;
    • const wheelMat = new BABYLON.StandardMaterial("wheelMat");

    Mapbox 与 Babylon.js 可视化 使车动起来 - 小专栏

  • 相关阅读:
    REHの个人主页
    多项式基础学习笔记(2)
    多项式基础学习笔记(1)
    FFT & NTT 学习笔记
    LCT学习笔记
    莫队学习笔记
    SAM 学习笔记
    网络流学习笔记
    关于魔术球贪心做法的证明
    【题解】异或粽子&加强版
  • 原文地址:https://www.cnblogs.com/haibalai/p/16918885.html
Copyright © 2020-2023  润新知