Cesium 与 Babylon.js 可视化 复制一个模型
2023-04-18 15:01:24 时间
我决定不从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 material = new BABYLON.StandardMaterial("material", scene);
- material.diffuseColor = new BABYLON.Color3(0, 1, 0);
- material.backFaceCulling = false;
- //texture
- const roofMat = new BABYLON.StandardMaterial("roofMat", scene);
- roofMat.diffuseTexture = new BABYLON.Texture("https://assets.babylonjs.com/environments/roof.jpg");
- const boxMat = new BABYLON.StandardMaterial("boxMat");
- boxMat.diffuseTexture = new BABYLON.Texture("https://assets.babylonjs.com/environments/cubehouse.png")
- const faceUV = [];
- faceUV[0] = new BABYLON.Vector4(0.5, 0.0, 0.75, 1.0); //rear face
- faceUV[1] = new BABYLON.Vector4(0.0, 0.0, 0.25, 1.0); //front face
- faceUV[2] = new BABYLON.Vector4(0.25, 0, 0.5, 1.0); //right side
- faceUV[3] = new BABYLON.Vector4(0.75, 0, 1.0, 1.0); //left side
- const box = BABYLON.MeshBuilder.CreateBox("box", {
- faceUV: faceUV, wrap: true, sideOrientation:2,
- size: 100
- }, scene);
- box.material = boxMat;
- box.position.y = 40;
- // BabylonMapManager.addToMap(box,[113.87629508972168, 22.544824222364753, 100]);
- const roof = BABYLON.MeshBuilder.CreateCylinder("roof", {
- sideOrientation:2,
- diameter: 130, height: 120, tessellation: 3
- },
- scene);
- roof.material = roofMat;
相关文章
- 硬核编程技术助力疫情防控,编程教育的下一个趋势是什么?
- 您真的需要Kubernetes吗?
- 从未如此简单:5分钟搞懂 HTTP 缓存机制
- 2020年及以后的8个重要软件开发趋势
- 常见的软件漏洞以及如何避免这些问题
- 开发API时需要关注的十三项指标
- 什么是2038问题?
- 想跳槽进大厂?这份面试题集锦你该看看了
- 与程序员相关的CPU缓存知识
- 精通那么多技术,为何还是写出一堆“屎山”?
- K8S集群入门:运行一个应用程序究竟需要多少集群?
- 下一个10年,前端开源领域技术展望
- 如何快速构建优异的React搜索体验
- 软件工程师的衰落与程序员的崛起
- 程序员如何优化自己的职业程序?
- VS Code调试太难?这款可视化代码调试工具值得拥有
- 教你这6个小技巧,让你在GitHub上快速找到你想要的资源
- IT 人,如何构建自己的时间管理系统?
- 这个烂代码法则居然在Github上火了
- Github终于对印度“下手”了!