[Cesium for Supermap] 加载3dTiles,点击获取属性

代码:

javascript 复制代码
        // 设为椭球
        var obj = [6378137.0, 6378137.0, 6356752.3142451793];
        Cesium.Ellipsoid.WGS84 = Object.freeze(new Cesium.Ellipsoid(obj[0], obj[1], obj[2]));

        var viewer = new Cesium.Viewer('cesiumContainer');
        var scene = viewer.scene
        scene.lightSource.ambientLightColor = new Cesium.Color(0.65, 0.65, 0.65, 1);

        var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
            url: 'http://10.90.3.116:8999/3dTiles/995ab8c02e114841b758259df5305492/tileset.json'
        }));

        // 定位
        tileset.readyPromise.then(function () {
            var boundingSphere = tileset.boundingSphere;
            viewer.camera.viewBoundingSphere(boundingSphere, new Cesium.HeadingPitchRange(0.0, -0.5, boundingSphere.radius));
            viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
        }).otherwise(function (error) {
            throw(error);
        });

        // 监听鼠标点击事件
        viewer.screenSpaceEventHandler.setInputAction(function(click) {
            // 使用ray和场景进行交互检测
            var pickedFeature = viewer.scene.pick(click.position);

            // 检查是否点击了模型
            if (Cesium.defined(pickedFeature) && pickedFeature instanceof Cesium.Cesium3DTileFeature) {
                // 获取点击的模型的属性
                var attribute = pickedFeature.getProperty('buildid');
                console.log('buildid:', attribute);
            }
        }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
相关推荐
supermapsupport19 天前
SuperMap GIS基础产品FAQ集锦(20240826)
java·gis·webgl·supermap·webgis
supermapsupport1 个月前
SuperMap GIS基础产品FAQ集锦(20240805)
javascript·gis·webgl·supermap·webgis·gpa·处理自动化
supermapsupport2 个月前
SuperMap GIS基础产品FAQ集锦(202406)
java·javascript·gis·webgl·supermap·webgis
xiangshangdemayi3 个月前
Cesium源码解析六(3dtiles属性获取、建筑物距离计算、建筑物着色及其原理分析)
距离·cesium·原理·属性·3dtiles·建筑物·着色
supermapsupport3 个月前
SuperMap GIS基础产品FAQ集锦(20240603)
gis·webgl·supermap·webgis·iobject java
大势智慧3 个月前
DasViewer V3.3全新升级 | 新增点云数据浏览、点云关联全景照片、3DTiles在线数据浏览...
3d·三维建模·三维重建·3dtiles·三维模型·激光点云·点云流量
supermapsupport4 个月前
SuperMap GIS基础产品FAQ集锦(20240527)
数据库·gis·supermap·webgis·云gis
sky.....5 个月前
3DTiles生产流程与规范
3d·3dtiles
MagicUrban8 个月前
三维地下管线建模工具MagicPipe3D V3.3发布
obj·3dtiles·地下管网·3d 建模·管线