Cesium 与 Babylon.js 可视化 给车添加轮子

  • 阿里云国际版折扣https://www.yundadi.com

  • 阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6


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

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

    npm i @haibalai/cesium-babylonjs
    初始化cesium-babylonjs 类库, viewer 是 Cesium 的 viewer对象
    import { BabylonMapManager } from “@haibalai/cesium-babylonjs”;
    BabylonMapManager.init(viewer);添加正方体
    import { BabylonMapManager } from “@haibalai/cesium-babylonjs”;
    let scene = BabylonMapManager.getScene(viewer);
    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: 2, 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);
    car.addRotation(-Math.PI / 2, 0, 0);
    const wheelRB = BABYLON.MeshBuilder.CreateCylinder(“wheelRB”, {diameter: 0.125, height: 0.05})
    wheelRB.parent = car;
    wheelRB.position.z = -0.1;
    Cesium 与 Babylon.js 可视化 给车添加轮子 - 小专栏


  • 阿里云国际版折扣https://www.yundadi.com

  • 阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6