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