06.Cesium快速上手-Primitive图元的讲解

Primitive

结构图解:
在这里插入图片描述
在这里插入图片描述

图元表示 Scene 中的几何图形。几何图形可以来自单个 GeometryInstance
例子1:
在这里插入图片描述

// Create the viewer.
const viewer = new Cesium.Viewer("cesiumContainer");
const scene = viewer.scene;// Draw a red box and position it on the globe surface.const dimensions = new Cesium.Cartesian3(400000.0, 300000.0, 500000.0);
// Box geometries are initially centered on the origin.
// We can use a model matrix to position the box on the
// globe surface.
const positionOnEllipsoid = Cesium.Cartesian3.fromDegrees(-105.0, 45.0);
const boxModelMatrix = Cesium.Matrix4.multiplyByTranslation(Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid),new Cesium.Cartesian3(0.0, 0.0, dimensions.z * 0.5),new Cesium.Matrix4()
);// 1.创建一个几何体
const boxGeometry = Cesium.BoxGeometry.fromDimensions({vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,dimensions: dimensions,
});
// Create a geometry instance using the geometry
// and model matrix created above.
const boxGeometryInstance = new Cesium.GeometryInstance({geometry: boxGeometry,modelMatrix: boxModelMatrix,attributes: {color: Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5)),},
});
// Add the geometry instance to primitives.
scene.primitives.add(new Cesium.Primitive({geometryInstances: boxGeometryInstance,//渲染样式appearance: new Cesium.PerInstanceColorAppearance({closed: true,}),})
);

例子2:创建一个圆形几何体
在这里插入图片描述

// Example 1: Draw a red circle on the globe surface.// Create the circle geometry.
let circleGeometry = new Cesium.CircleGeometry({center: Cesium.Cartesian3.fromDegrees(-95.0, 43.0),radius: 250000.0,vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
});
// Create a geometry instance using the circle geometry
// created above. We can also specify a color attribute,
// in this case, we're creating a translucent red color.
const redCircleInstance = new Cesium.GeometryInstance({geometry: circleGeometry,attributes: {color: Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5)),},
});
// Add the geometry instance to primitives.
scene.primitives.add(new Cesium.Primitive({geometryInstances: redCircleInstance,appearance: new Cesium.PerInstanceColorAppearance({closed: true,}),})
);

例子3:创建一个边线几何体
在这里插入图片描述

// Create the viewer.
const viewer = new Cesium.Viewer("cesiumContainer");
const scene = viewer.scene;// Draw the outline of a box.const dimensions = new Cesium.Cartesian3(400000.0, 400000.0, 400000.0);// Box geometries are initially centered on the origin.
// We can use a model matrix to position the box on the
// globe surface.
const positionOnEllipsoid = Cesium.Cartesian3.fromDegrees(-106.0, 45.0);
const boxModelMatrix = Cesium.Matrix4.multiplyByTranslation(Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid),new Cesium.Cartesian3(0.0, 0.0, dimensions.z * 0.5),new Cesium.Matrix4()
);// Create a box outline geometry.
const boxOutlineGeometry = Cesium.BoxOutlineGeometry.fromDimensions({dimensions: dimensions,
});// Create a geometry instance using the geometry
// and model matrix created above.
const boxOutlineInstance = new Cesium.GeometryInstance({geometry: boxOutlineGeometry,modelMatrix: boxModelMatrix,attributes: {color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.WHITE),},
});// Add the geometry instance to primitives.
scene.primitives.add(new Cesium.Primitive({geometryInstances: boxOutlineInstance,appearance: new Cesium.PerInstanceColorAppearance({flat: true,renderState: {lineWidth: Math.min(2.0, scene.maximumAliasedLineWidth),},}),})
);

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/651973.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

SpringCloud系列(18)--将服务提供者Provider注册进Consul

前言:在上一章节中我们把服务消费者Consumer注册进了Zookeeper,并且成功通过服务消费者Consumer调用了服务提供者Provider,而本章节则是关于如何将服务提供者Provider注册进Consul里 准备环境: 先安装Consul,如果没有…

【系统架构师】-选择题(四)

1、“41”视图 ①逻辑视图(Logical View),设计的对象模型(使用面向对象的设计方法时)。 ②过程视图(Process View),捕捉设计的并发和同步特征。系统集成师 ③物理视图(Physical View),描述了软件到硬件的映射,反映了分布式特性。系…

星尘智能 AI 机器人 S1——国产机器人的巅峰之作

AI智能机器人真的太炸裂了 国产科技威武-CSDN直播AI智能机器人真的太炸裂了 国产科技威武https://live.csdn.net/v/382519 最近发现了一个国产的机器人,真的让人惊叹不已!它就是星尘智能 AI 机器人 S1! 这个机器人简直太牛逼了!…

比 PSD.js 更强的下一代 PSD 解析器,支持 WebAssembly

比 PSD.js 更强的下一代 PSD 解析器,支持 WebAssembly 1.什么是 webtoon/ps webtoon/ps 是 Typescript 中轻量级 Adobe Photoshop .psd/.psb 文件解析器,对 Web 浏览器和 NodeJS 环境提供支持,且做到零依赖。 Fast zero-dependency PSD par…

Windows上在DLL中嵌入自定义/XML文件

Windows上在DLL中嵌入自定义文件(如:xml文件) 1、前言 最近都在开发适配Genicam项目,在开发CTI(Windows上可以看作DLL)时发现需要将多个XML文件嵌入到DLL文件中方便内部代码调用。 2、前期准备 一个xml…

StarRocks x Paimon 构建极速实时湖仓分析架构实践

Paimon 介绍 Apache Paimon 是新一代的湖格式,可以使用 Flink 和 Spark 构建实时 Lakehouse 架构,以进行流式处理和批处理操作。Paimon 创新性地使用 LSM(日志结构合并树)结构,将实时流式更新引入 Lakehouse 架构中。 …

ChatGPT/GLM API使用

模型幻觉问题 在自然语言处理领域,幻觉(Hallucination)被定义为生成的内容与提供的源内容无关或不忠实,具体而言,是一种虚假的感知,但在表面上却似乎是真实的。产生背景 检索增强生成(RAG&…

QT入门:计算圆面积的QT开始以及日历相关

QT入门:计算圆面积的QT开始以及日历相关 使用的工具为Qt creator 如图所示的为Qt的一个基本目录,首先打开mainwindow.ui进行设计,首先是讲解日历的,可以完全不用写代码,只在mainwindow.ui即可实现。 这是最后的一个成…

JRT质控打印

最近客户端打磨完了,又来推进质控了。之前演示的打印都是Demo示例,这次真正的写质控图的打印,数据就是质控数据录入界面录入的数据。其中质控图打印应该算最复杂的类型了。涉及JS的绘图,打印表格等,表格比较简单、还没…

DRF学习之DRF初识

一.Web应用两种开发模式 1、前后端不分离模式 也叫前后端混合开发模式, 需要后端写模板语言(DTL), 返回的是HTML页面,比如有BBS项目,图书管理系统。 在前后端不分离的项目中,模板渲染通常是在后端完成的。这种项目结构中,后端负…

力扣118. 杨辉三角

Problem: 118. 杨辉三角 文章目录 题目描述思路复杂度Code 题目描述 思路 1.初始化状态:将创建的二维数组dp的第一列和主对角线上元素设为1; 2.状态的转移:从第一行、列起始,dp[i][j] dp[i - 1][j - 1] dp[i - 1][j] 复杂度 时…

FORM调用标准AP\AR\GL\FA界面

EBS FORM客户化界面有时候数据需要追溯打开AP\AR\GL\FA等界面: 一种打开日记账的方式: PROCEDURE SHOW_JOURNAL ISparent_form_id FormModule;child_form_id FormModule; BEGINclose_jrn;parent_form_id : FIND_FORM(:SYSTEM.CURRENT_FORM);COPY(TO…