当前位置:网站首页>【cesium】Load and locate 3D Tileset
【cesium】Load and locate 3D Tileset
2022-08-05 04:53:00 【Gu Bird】
一. 介绍
首页加载 3D Tileset 模型,Then by converting the coordinates and positioning to the specified position.
二. 效果

三. 实现
// index.vue
<template>
<div class="viewer">
<vc-viewer @ready="ready">
<vc-layer-imagery>
<vc-provider-imagery-tianditu
protocol="http"
map-style="img_w"
token="436ce7e50d27eede2f2929307e6b33c0"
:projectionTransforms="projectionTransforms"
></vc-provider-imagery-tianditu>
</vc-layer-imagery>
</vc-viewer>
</div>
</template>
<script>
import {
update3dtilesMaxtrix } from "../utils";
export default {
data() {
return {
mapStyle: "6",
ltype: "0",
projectionTransforms: {
from: "WGS84", to: "GCJ02" }
};
},
methods: {
// 地图初始化
ready(cesiumInstance) {
const {
Cesium, viewer } = cesiumInstance;
window.$cesiumInstance = cesiumInstance;
window.Cesium = Cesium;
window.viewer = viewer;
this.loadTile();
},
// 加载 3dtiles 模型
loadTile() {
const {
Cesium, viewer } = window.$cesiumInstance;
const scene = viewer.scene; // 创建场景
// 向集合添加一个原语.
const tileset = scene.primitives.add(
new Cesium.Cesium3DTileset({
url: "http://192.168.0.1/sppmodel/1/tileset.json", // 还可以是json、http链接等,use your own address
dynamicScreenSpaceError: true,
cullWithChildrenBounds: false,
skipLevels: 0,
maximumScreenSpaceError: 0
})
);
tileset.readyPromise
.then(function (tileset) {
// 坐标转换和定位
let params = {
tx: 117.227267, //模型中心X轴坐标(经度,单位:十进制度)
ty: 31.820567, //模型中心Y轴坐标(纬度,单位:十进制度)
tz: 0, //模型中心Z轴坐标(高程,单位:米)
rx: 0, //X轴(经度)方向旋转角度(单位:度)
ry: 0, //Y轴(纬度)方向旋转角度(单位:度)
rz: 0, //Z轴(高程)方向旋转角度(单位:度)
};
update3dtilesMaxtrix(tileset, params);
const default_headingPitchRange = new Cesium.HeadingPitchRange(0.3, -0.2, tileset.boundingSphere.radius * 2.0);
viewer.flyTo(tileset, {
offset: default_headingPitchRange, });
})
.catch(function (error) {
console.log(error);
});
},
},
};
</script>
<style>
.viewer {
width: 100%;
height: 100%;
}
</style>
// update3dtilesMaxtrix.js
// let params = {
// tx: 120.257, //模型中心X轴坐标(经度,单位:十进制度)
// ty: 31.226, //模型中心Y轴坐标(纬度,单位:十进制度)
// tz: 2800, //模型中心Z轴坐标(高程,单位:米)
// rx: 0, //X轴(经度)方向旋转角度(单位:度)
// ry: 0, //Y轴(纬度)方向旋转角度(单位:度)
// rz: -1 //Z轴(高程)方向旋转角度(单位:度)
// };
export const update3dtilesMaxtrix = function (tileset, params) {
//旋转
let Cesium = window.Cesium
let mx = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(params.rx));
let my = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(params.ry));
let mz = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(params.rz));
let rotationX = Cesium.Matrix4.fromRotationTranslation(mx);
let rotationY = Cesium.Matrix4.fromRotationTranslation(my);
let rotationZ = Cesium.Matrix4.fromRotationTranslation(mz);
//平移
let position = Cesium.Cartesian3.fromDegrees(params.tx, params.ty, params.tz);
let m = Cesium.Transforms.eastNorthUpToFixedFrame(position);
let scale = Cesium.Matrix4.fromUniformScale(0.85);
// //缩放
Cesium.Matrix4.multiply(m, scale, m);
//旋转、平移矩阵相乘
Cesium.Matrix4.multiply(m, rotationX, m);
Cesium.Matrix4.multiply(m, rotationY, m);
Cesium.Matrix4.multiply(m, rotationZ, m);
//赋值给tileset
tileset._root.transform = m;
// return m;
}
边栏推荐
- upload upload pictures to Tencent cloud, how to upload pictures
- 【informix】解决启动报错大全,以及解决办法
- Cron(Crontab)--使用/教程/实例
- 浅析主流跨端技术方案
- Flutter learning - the beginning
- how to measure distance from point to face in creo
- University Physics---Particle Kinematics
- 【cesium】3D Tileset 模型加载并与模型树关联
- upload上传图片到腾讯云,如何上传图片
- MySQL Foundation (1) - Basic Cognition and Operation
猜你喜欢

雷克萨斯lm的安全性到底体现在哪里?一起来看看吧
![[CISCN2019 South China Division]Web11](/img/15/843334fec0a5cc8cfaba92aab938db.png)
[CISCN2019 South China Division]Web11

The production method of the powered small sailboat is simple, the production method of the electric small sailboat

Detailed explanation of Mysql's undo log

Flutter learning three-Flutter basic structure and principle

Visibility of multi-column attribute column elements: display, visibility, opacity, vertical alignment: vertical-align, z-index The larger it is, the more it will be displayed on the upper layer

Day019 Method overriding and introduction of related classes

ansible各个模块详解

【cesium】3D Tileset 模型加载并与模型树关联

工业级远距离无线传输装置的功能有哪些?
随机推荐
bytebuffer 使用demo
Mvi架构浅析
uboot enable debug printing information
机器学习概述
What is ASEMI photovoltaic diode, the role of photovoltaic diode
[MRCTF2020] PYWebsite
【学生毕业设计】基于web学生信息管理系统网站的设计与实现(13个页面)
After controlling the export file in MySQL, it becomes \N. Is there any solution?
【学习笔记之菜Dog学C】动态内存管理之经典笔试题
Day019 方法重写与相关类的介绍
Flutter Learning 4 - Basic UI Components
【cesium】3D Tileset 模型加载并与模型树关联
Detailed explanation of Mysql's undo log
Cryptography Series: PEM and PKCS7, PKCS8, PKCS12
write the story about us
【informix】解决启动报错大全,以及解决办法
ansible各个模块详解
Develop your own node package
mysql数据库表什么字段类型的存储长度最大?
The solution to the failure to read channel information when dedecms generates a message in the background