Cesium Geometry 说明


Cesium
1.Geometry new Cesium.Geometry(options)

(1)parmas 对象{attributes:{},primitiveType:PrimitiveType.TRIANGLES,indices:new Uint16Array([0, 1, 2...]),boundingSphere:Cesium.BoundingSphere.fromVertices(positions)}
indices:可选索引数据,用于确定几何图元中的图元。根据点确定图元个数,boundingSphere包围几何的边界球
可以使用GeometryPipeline中的函数进行转换和优化。
(2)GeometryAttributes 获取Geometry参数中 attributes 对象中的成员
a.bitangent 双切线
b.color 颜色
c.normal 法向量 通常用于照明
d.position 坐标
e.st 2D纹理坐标属性。
d.tangent 切线

(3)GeometryAttribute 获取GeometryAttributes 成员中的成员
a.componentDatatype 数据类型 eg:Cesium.ComponentDatatype.FLOAT
b.componentsPerAttribute 1到4之间的数字,用于定义属性中的组件数。几个数一组
c.normalize 当true和componentDatatype是整数格式时,指示当以浮点访问时,组件应被映射到范围[0,1](无符号)或[-1,1(签名))。
d.values 存储在类型化数组中的属性的值
代码示例如下:
var attributes1 = {
position: new Cesium.GeometryAttribute({
componentDatatype: Cesium.ComponentDatatype.DOUBLE,
componentsPerAttribute: 3,
values: positions
}),
color: new Cesium.GeometryAttribute({
componentDatatype: Cesium.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute: 4,
normalize: true,
values: colors
}),
normal:new Cesium.GeometryAttribute({
componentDatatype: Cesium.ComponentDatatype.DOUBLE,
componentsPerAttribute: 3,
normalize: true,
values: values
})
};
var indicesArr = [];
for (var i = 0; i < positions.length / 3; i++) {
indicesArr.push(i);
}
var geometry = new Cesium.Geometry({
attributes: new Cesium.GeometryAttributes(attributes1),
indices: new Uint16Array(indicesArr),
primitiveType: Cesium.PrimitiveType.TRIANGLE,
boundingSphere: Cesium.BoundingSphere.fromVertices(positions)
});
(3) GeometryPipeline()

a. Cesium.GeometryPipeline.compressVertices(geometry) → Geometry
b. Cesium.GeometryPipeline.computeNormal(geometry) → Geometry 计算法向量 通过对入射到顶点的所有三角形的法线进行平均,计算包含TRIANGLES的几何图形的每顶点法线。 结果是添加到几何的新的普通属性。 这采用逆时针缠绕顺序。
c.Cesium.GeometryPipeline.computeTangentAndBitangent(geometry) → Geometry 计算切线和双切线
d. Cesium.GeometryPipeline.createAttributeLocations(geometry) → Object 创建将属性名称映射到唯一位置(索引)的对象,用于匹配顶点属性和着色器程序。
e.Cesium.GeometryPipeline.createLineSegmentsForVectors(geometry, attributeName, length) return 一个新的Geometry实例,带有向量的线段
f. Cesium.GeometryPipeline.encodeAttribute (geometry,attributeName,attributeHighName,attributeLowName)
eg:geometry = Cesium.GeometryPipeline.encodeAttribute(geometry, 'position3D', 'position3DHigh', 'position3DLow');

2. new Cesium.GeometryInstance(options)允许一个Geometry对象在几个不同的位置进行位置,并且是唯一的。例如,BoxGeometry可以多次实例化,每次都有不同modelMatrix的改变位置,旋转和缩放。
GeometryInstanceAttribute 是GeometryInstance 成员 attribute 的对象。


3. GeometryUpdater GeometryVisualizer


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM