Cesium|xt3d模型热力图

Cesium|xt3d模型热力图

效果

在这里插入图片描述

代码

 <!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>cesium|xt3d</title>
    <!-- 引入Cesium -->
    <script src="https://unpkg.com/cesium@1.84.0/Build/Cesium/Cesium.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/cesium@1.84.0/Build/Cesium/Widgets/widgets.css">

    <script src="http://www.xt3d.cn/libs/heatmap.min.js"></script>

    <!--  引入xt3d -->
    <script src="http://www.xt3d.cn/xt3dlib/xt3d.min.js"></script>
    <style>
        html,
        body,
        #map3d {
            width: 100%;
            height: 100%;
            margin: 0px;
            padding: 0px;
        }
    </style>
</head>

<body>
    <div id="map3d"></div>

    <script>
        let xt3dInit = {
            init(el) {
                this.initViewer(el);
                this.load3dtiles();
                this.initHeatMap();
            },

            //初始化viewer
            initViewer(el) {
                this.viewer = new Cesium.Viewer(el, {
                    infoBox: false,
                    selectionIndicator: false,
                    navigation: false,
                    animation: false,
                    shouldAnimate: false,
                    timeline: false,
                    baseLayerPicker: false,
                    geocoder: false,
                    homeButton: false,
                    sceneModePicker: false,
                    navigationHelpButton: false,
                    imageryProvider: new Cesium.UrlTemplateImageryProvider({
                        url: "https://t7.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=tdtTk"
                    })
                });

            },

            initHeatMap() {
                var data = [{
                    x: 106.4539017008,
                    y: 29.5027558947,
                    z: 1, // Math.random()
                }, {
                    x: 106.4551132292,
                    y: 29.5034262296,
                    z: 1 // Math.random()
                }, {
                    x: 106.4560860455,
                    y: 29.5029204495,
                    z: Math.random()
                }, {
                    x: 106.4567780225,
                    y: 29.5054223234,
                    z: Math.random()
                }, {
                    x: 106.4565609600,
                    y: 29.5069330499,
                    z: Math.random()
                }, {
                    x: 106.4561247201,
                    y: 29.5065141442,
                    z: Math.random()
                }]

                let bbox = [106.4519988952, 29.5021084567, 106.4590407287, 29.5092024712];
                let heatmap = new xt3d.TilesetPlugin.Heatmap(
                    this.viewer,
                    data,
                    bbox
                )
            },


            //加载3dtiles数据
            load3dtiles() {
                var tileset = this.viewer.scene.primitives.add(
                    new Cesium.Cesium3DTileset({
                        url: "http://www.xt3d.cn/data/offset_3dtiles/tileset.json",
                    })
                );

                tileset.readyPromise
                    .then(tileset => {
                        this.viewer.zoomTo(
                            tileset,
                        );
                        xt3d.TilesetPlugin.setTilesetHeight(tileset, 55);
                    })
                    .otherwise(function(error) {
                        console.log(error);
                    });
            },


            destroy() {
                this.viewer.entities.removeAll();
                this.viewer.imageryLayers.removeAll(true);
                this.viewer.destroy();
            }
        }

        xt3dInit.init("map3d");
    </script>
</body>

</html>

预览地址

xt3d 在线预览地址

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
esium|xt3d是一个开源的JavaScript库,用于在Web上创建交互性的3D场景。它基于ES6模块化的编写方式,通过使用WebGL技术来实现3D渲染。 esium|xt3d源码主要包含了各种类和方法,用于创建和管理3D场景中的对象,例如模型、光照、相机等。其中最核心的类是Scene、Renderer和Object3D。 Scene类是整个场景的容器,它可以添加和移除各种对象,控制场景的渲染和交互行为。Renderer类是用于将场景中的对象渲染到屏幕上,并处理窗口大小变化、鼠标事件等交互操作。Object3D类是所有3D对象的基类,包含了基本的位置、旋转和缩放等属性,以及一些常用的方法,如添加子对象、更新变换等。 esium|xt3d还提供了丰富的材质和光照效果,可以让用户在场景中显示不同的表面材质、漫反射和镜面反射等效果。它还支持基本的几何形状生成,如立方体、球体等,并提供了模型导入和导出的功能,使得用户可以方便地使用自定义的3D模型。 esium|xt3d源码的设计和编写遵循了面向对象的原则,通过类和方法的封装使得代码结构清晰易懂。它还考虑了性能优化的问题,提供了一些机制来减少重复计算和提高渲染效率。 综上所述,esium|xt3d是一个功能强大的JavaScript库,通过使用WebGL技术实现了在Web上创建交互性的3D场景。它的源码设计清晰易懂,提供了丰富的功能和效果,使得用户可以方便地开发出高质量的3D应用程序。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xt3d

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值