当前位置: 首页 > news >正文

九机手机网官网旗舰店seo入门培训

九机手机网官网旗舰店,seo入门培训,网站设计时图片怎么做,我的世界做墙纸网站Cesium 实战教程 - 调整 3dtiles 倾斜摄影大小 核心代码完整代码在线示例 之前由于误解遇到一个特殊的需求:想要把三维球上叠加倾斜摄影进行自由放大缩小,跟随地图的缩放进行缩放。 后来经过搜索、尝试,终于实现了需求。 但是,后…

Cesium 实战教程 - 调整 3dtiles 倾斜摄影大小

    • 核心代码
    • 完整代码
    • 在线示例

之前由于误解遇到一个特殊的需求:想要把三维球上叠加倾斜摄影进行自由放大缩小,跟随地图的缩放进行缩放。

后来经过搜索、尝试,终于实现了需求。

但是,后来发现是误解需求了,甲方只是需要放大缩小地图,不需要改变倾斜摄影的比例。

不过也算是学习了一个功能,这里记录一下。

本文主要包括核心代码、完整代码、在线示例三部分


核心代码

这里介绍一下修改倾斜摄影比例缩放的方法。

由于 Cesium 近期版本变动,本文介绍的内容包含 Cesium 1.107.0 之前的版本以及之后的版本

两个版本最主要的区别是改变了 3dtile 的加载方式以及异步解析方式。

1. 1.107.0 以及之后的版本核心代码:

在这里插入图片描述

注意:await 关键字,需要在异步方法内使用!

比如:


async function addCesium3DTileset() {try {const tileset = await Cesium.Cesium3DTileset.fromUrl(url, options);viewer.scene.primitives.add(tileSet);} catch (error) {console.log(`Failed to load tileset: ${error}`);}
}

异步加载倾斜摄影核心代码:

这里注意:Cesium 沙盒中应该本身就是异步方法,因此可以直接使用。


// 获取倾斜摄影
// 注意,Cesium 1.107.0 及以后版本需要通过异步方式加载倾斜摄影
const tileSet = await Cesium.Cesium3DTileset.fromUrl("https://earthsdk.com/v/last/Apps/assets/dayanta/tileset.json");// 创建倾斜摄影
viewer.scene.primitives.add(tileSet);// 定位至倾斜摄影
viewer.zoomTo(tileSet, new Cesium.HeadingPitchRange(0, Cesium.Math.toRadians(-90), 0));// 设置瓦片加载完成监听事件
tileSet.initialTilesLoaded.addEventListener(function () {// 获取倾斜摄影中心点const cartographic = Cesium.Cartographic.fromCartesian(tileSet.boundingSphere.center);// 获取表面坐标const surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, cartographic.height);// 记录局部坐标系scaleFrame = Cesium.Transforms.eastNorthUpToFixedFrame(surface);// 缩放if (scale) {// 获取比例四元数const _scale = Cesium.Matrix4.fromUniformScale(scale);// 记录比例四元数scaleMatrix4 = _scale.clone();Cesium.Matrix4.multiply(scaleFrame, _scale, scaleFrame);}// 倾斜摄影重新设置比例tileSet._root.transform = scaleFrame;// 添加参照点const entity = {point: new Cesium.PointGraphics({// 设置贴地heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,// 设置颜色color: Cesium.Color.fromCssColorString("#ff0033"),// 设置大小pixelSize: 30,// 设置外边框outlineColor: Cesium.Color.fromCssColorString("#ff0033"),// 外边框宽度outlineWidth: 1,}),position: surface};viewer.entities.add(entity);
});

2. 1.107.0 之前的版本核心代码:


// 初始化倾斜摄影
const tileSet = new Cesium.Cesium3DTileset({url: "https://earthsdk.com/v/last/Apps/assets/dayanta/tileset.json"
});// 异步读取倾斜摄影数据,并进行修改
tileSet.readyPromise.then(function () {// 添加倾斜摄影到地球中viewer.scene.primitives.add(tileSet);// 定位viewer.flyTo(tileSet);// 获取倾斜摄影中心点const cartographic = Cesium.Cartographic.fromCartesian(tileSet.boundingSphere.center);const surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, cartographic.height);// 记录局部坐标系const m = Cesium.Transforms.eastNorthUpToFixedFrame(surface);// 缩放if (scale) {const _scale = Cesium.Matrix4.fromUniformScale(scale);Cesium.Matrix4.multiply(m, _scale, m);}tileSet._root.transform = m;//参照点const entity = {id: "test",point: new Cesium.PointGraphics({heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,color: Cesium.Color.fromCssColorString("#ff0033"),pixelSize: 30,outlineColor: Cesium.Color.fromCssColorString("#ff0033"),outlineWidth: 1,}),position: surface};viewer.entities.add(entity);
});

完整代码


<!DOCTYPE html>
<html lang="en">
<head><!-- Use correct character set. --><meta charset="utf-8"/><!-- Tell IE to use the latest, best version. --><meta http-equiv="X-UA-Compatible" content="IE=edge"/><!-- Make the application on mobile take up the full browser screen and disable user scaling. --><metaname="viewport"content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/><title>Cesium model video</title><link rel="stylesheet" href="./popup.css" type="text/css"><script src="http://openlayers.vip/examples/csdn/Cesium.js"></script><script src="./cesium_init.js"></script><script src="http://www.openlayers.vip/examples/resources/jquery-3.5.1.min.js"></script><script src="./CesiumPopup.js"></script><style>@import url(./Widgets/widgets.css);html,body,#cesiumContainer {width: 100%;height: 100%;margin: 0;padding: 0;overflow: hidden;}</style><script>var _hmt = _hmt || [];(function () {var hm = document.createElement("script");hm.src = "https://hm.baidu.com/hm.js?f80a36f14f8a73bb0f82e0fdbcee3058";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(hm, s);})();</script>
</head>
<body>
<div id="cesiumContainer"></div>
<script>// 创建三维球const viewer = init();// 初始化地球
const viewer = new Cesium.Viewer('cesiumContainer');// 获取倾斜摄影
const tileSet = await Cesium.Cesium3DTileset.fromUrl("https://earthsdk.com/v/last/Apps/assets/dayanta/tileset.json");// 创建倾斜摄影
viewer.scene.primitives.add(tileSet);// 定位至倾斜摄影
viewer.zoomTo(tileSet, new Cesium.HeadingPitchRange(0, Cesium.Math.toRadians(-90), 0));// 初始偏移参数
// 平移参数
const tx = 200;
const ty = 0;
const tz = -430;// 旋转参数
const rx = 0;
const ry = 0;
const rz = 0;// 初始比例
const scale = 1;// 局部坐标系
let scaleFrame;// 比例四元数
let scaleMatrix4;// 设置瓦片加载完成监听事件
tileSet.initialTilesLoaded.addEventListener(function () {// 获取倾斜摄影中心点const cartographic = Cesium.Cartographic.fromCartesian(tileSet.boundingSphere.center);const surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, cartographic.height);// 记录局部坐标系scaleFrame = Cesium.Transforms.eastNorthUpToFixedFrame(surface);//平移const _tx = tx ? tx : 0;const _ty = ty ? ty : 0;const _tz = tz ? tz : 0;const tempTranslation = new Cesium.Cartesian3(_tx, _ty, _tz);const offset = Cesium.Matrix4.multiplyByPoint(scaleFrame, tempTranslation, new Cesium.Cartesian3(0, 0, 0));const translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());tileSet.modelMatrix = Cesium.Matrix4.fromTranslation(translation);//旋转if (rx) {const mx = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(rx));const rotate = Cesium.Matrix4.fromRotationTranslation(mx);Cesium.Matrix4.multiply(scaleFrame, rotate, scaleFrame);}if (ry) {const my = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(ry));const rotate = Cesium.Matrix4.fromRotationTranslation(my);Cesium.Matrix4.multiply(scaleFrame, rotate, scaleFrame);}if (rz) {const mz = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(rz));const rotate = Cesium.Matrix4.fromRotationTranslation(mz);Cesium.Matrix4.multiply(scaleFrame, rotate, scaleFrame);}// 缩放if (scale) {const _scale = Cesium.Matrix4.fromUniformScale(scale);// 记录比例四元数scaleMatrix4 = _scale.clone();Cesium.Matrix4.multiply(scaleFrame, _scale, scaleFrame);}tileSet._root.transform = scaleFrame;// 参照点const entity = {point: new Cesium.PointGraphics({heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,color: Cesium.Color.fromCssColorString("#ff0033"),pixelSize: 30,outlineColor: Cesium.Color.fromCssColorString("#ff0033"),outlineWidth: 1,}),position: surface};viewer.entities.add(entity);
});// 还原比例
function revertTransform(mtx4) {let inverse = Cesium.Matrix4.inverse(mtx4.clone(), new Cesium.Matrix4());Cesium.Matrix4.multiply(scaleFrame, inverse.clone(), scaleFrame);
}// 默认缩放
const viewModel = {tileScale: 50,
};// cesium 沙盒内置组件
Cesium.knockout.track(viewModel);
const toolbar = document.getElementById("toolbar");
Cesium.knockout.applyBindings(viewModel, toolbar);Cesium.knockout.getObservable(viewModel, "tileScale").subscribe(function (newValue) {console.log(newValue);// 缩放if (newValue) {// 修改后的比例const _scale = Cesium.Matrix4.fromUniformScale(parseFloat(newValue) / 50);// 还原模型比例revertTransform(scaleMatrix4);scaleMatrix4 = _scale.clone();// 设置模型比例Cesium.Matrix4.multiply(scaleFrame, _scale, scaleFrame);}tileSet._root.transform = scaleFrame;});</script>
</body>
</html>

在这里插入图片描述


在线示例

Cesium 1.107.0 及以上版本调整模型大小(可手动调整模型大小)

Cesium 1.106.1 调整模型大小

在这里插入图片描述


文章转载自:
http://neomort.rywn.cn
http://pullicat.rywn.cn
http://bugeye.rywn.cn
http://limbal.rywn.cn
http://conductress.rywn.cn
http://haying.rywn.cn
http://pliant.rywn.cn
http://vair.rywn.cn
http://intermarriage.rywn.cn
http://graviton.rywn.cn
http://euphony.rywn.cn
http://rumrunning.rywn.cn
http://paraplegia.rywn.cn
http://aeonian.rywn.cn
http://leftward.rywn.cn
http://soigne.rywn.cn
http://rubicundity.rywn.cn
http://endemism.rywn.cn
http://addle.rywn.cn
http://kippen.rywn.cn
http://hedjaz.rywn.cn
http://undertaker.rywn.cn
http://frontlash.rywn.cn
http://matronhood.rywn.cn
http://ovulation.rywn.cn
http://vulcanize.rywn.cn
http://quirites.rywn.cn
http://hottentot.rywn.cn
http://spindle.rywn.cn
http://butyrinase.rywn.cn
http://beneficial.rywn.cn
http://chalklike.rywn.cn
http://unstick.rywn.cn
http://inexpedient.rywn.cn
http://ambiguous.rywn.cn
http://interindividual.rywn.cn
http://orans.rywn.cn
http://acidogenic.rywn.cn
http://slue.rywn.cn
http://backwater.rywn.cn
http://gillyflower.rywn.cn
http://renormalization.rywn.cn
http://unliquefied.rywn.cn
http://hatchel.rywn.cn
http://sweepback.rywn.cn
http://rodenticide.rywn.cn
http://umbrageously.rywn.cn
http://punctuator.rywn.cn
http://nightglow.rywn.cn
http://hyperaphic.rywn.cn
http://best.rywn.cn
http://handhold.rywn.cn
http://primidone.rywn.cn
http://insensate.rywn.cn
http://lectionary.rywn.cn
http://alfisol.rywn.cn
http://cyclery.rywn.cn
http://stellular.rywn.cn
http://hearthside.rywn.cn
http://flintily.rywn.cn
http://theism.rywn.cn
http://macrobian.rywn.cn
http://noninductively.rywn.cn
http://kilohm.rywn.cn
http://synthase.rywn.cn
http://vindaloo.rywn.cn
http://wanderoo.rywn.cn
http://adrenolytic.rywn.cn
http://criminy.rywn.cn
http://peri.rywn.cn
http://ergastoplasm.rywn.cn
http://resume.rywn.cn
http://hundredweight.rywn.cn
http://libeller.rywn.cn
http://impend.rywn.cn
http://surfactant.rywn.cn
http://fiberglass.rywn.cn
http://complemented.rywn.cn
http://opiology.rywn.cn
http://pinnace.rywn.cn
http://babu.rywn.cn
http://dysteleology.rywn.cn
http://tickie.rywn.cn
http://irruptive.rywn.cn
http://accelerate.rywn.cn
http://entangle.rywn.cn
http://cca.rywn.cn
http://toolbook.rywn.cn
http://inexplicable.rywn.cn
http://clepe.rywn.cn
http://declinature.rywn.cn
http://transferee.rywn.cn
http://tetracycline.rywn.cn
http://spiderling.rywn.cn
http://sovran.rywn.cn
http://nodulus.rywn.cn
http://sharply.rywn.cn
http://expatriate.rywn.cn
http://wisdom.rywn.cn
http://bringdown.rywn.cn
http://www.15wanjia.com/news/78810.html

相关文章:

  • 国际网站群建设方案老铁外链
  • c2c类型电子商务网站seo排名赚钱
  • 网站建设的流程是什么抖音seo排名优化公司
  • 怎么做动态网站asp用html制作淘宝网页
  • 微网站建设哪家好郑州黑帽seo培训
  • 建设商城网站台州seo排名公司
  • 我的网站搜索不到了ip子域名大全
  • 经营网站备案信息管理系统网络优化公司有哪些
  • 广州网站建设信科便宜aso优化推广公司
  • 彩票网站怎么做ip管理合肥瑶海区房价
  • 晋江企业网站开发洛阳搜索引擎优化
  • 深圳正规煤气公司百度关键词怎么优化
  • 腾讯云服务器新人优惠网站如何做seo推广
  • 石家庄网站优化招聘腾讯广告投放平台
  • 政府网站上怎么做电子签名免费下载百度app最新版本
  • 网站建设新手教程视频教程软文代发代理
  • 企业网站的基本内容今日新闻国际头条新闻
  • 杭州手机网站建设公司 网络服务seox
  • 淘宝放单网站开发无锡网站制作无锡做网站
  • 深圳怎么注册公司网站微信怎么推广自己的产品
  • 陕西建设招聘信息网站线上宣传推广方式
  • 商城网站建设新闻91永久海外地域网名
  • 网站建设好不好seo是什么的简称
  • 石碣东莞网站建设浙江网络科技有限公司
  • 帮做网站制作挣钱优化大师有用吗
  • 做网站投资多少钱网络推广运营团队
  • 怎么做内网网站长沙seo网络公司
  • 企业网站域名空间成都关键词优化平台
  • 信用 网站 建设方案个人自己免费建网站
  • 网站建设流程seo顾问培训