上海专业网站建设报价单,怎么给自己的网站设置关键词,杭州网站的特点,上海建设网站服务本系列为自己基于cesium写的一套插件具体实现。 这里是根据Cesium提供的CustomShader来实现的。
在CustomShader的vertexShaderText里#xff0c;需要定义vertexMain函数#xff0c;例如下#xff1a;
struct VertexInput {Attributes attributes;FeatureIds featureIds;… 本系列为自己基于cesium写的一套插件具体实现。 这里是根据Cesium提供的CustomShader来实现的。
在CustomShader的vertexShaderText里需要定义vertexMain函数例如下
struct VertexInput {Attributes attributes;FeatureIds featureIds;Metadata metadata;MetadataClass metadataClass;MetadataStatistics metadataStatistics;
};
struct czm_modelVertexOutput {vec3 positionMC;float pointSize;
};
void vertexMain(VertexInput vsInput, inout czm_modelVertexOutput vsOutput) {}我们可以从vsInput中获得该顶点的模型局部坐标。如果我们要实现压平最好是在ENU坐标下来进行修改顶点坐标的高度。所以我们要实现的逻辑就是将顶点坐标转成ENU坐标 ----- 判断是否在多边形范围内 ----- 若是则修改高度 ----- 转回模型坐标。
将顶点坐标转成ENU坐标
// 计算u_tileset_worldToLocalMatrix
const origin tileset.boundingSphere.center;
const matrix Cesium.Transforms.eastNorthUpToFixedFrame(origin);
u_tileset_worldToLocalMatrix Cesium.Matrix4.inverse(matrix, new Cesium.Matrix4())vec3 modelMC vsInput.attributes.positionMC;
vec4 tileset_local_position u_tileset_worldToLocalMatrix * czm_model * vec4(modelMC, 1.0);判断是否在多边形范围内 我们转成ENU坐标后其实可以在EN平面上去进行判断。将多边形的经纬度点都转成ENU坐标只取xy值然后跟该顶点进行平面判断。
转回模型坐标
if(isPointInPolygon(position2D)) {vec4 tileset_local_position_transformed vec4(tileset_local_position.x, tileset_local_position.y, ground_z, 1.0);vec4 model_local_position_transformed czm_inverseModel * u_tileset_localToWorldMatrix * tileset_local_position_transformed;vsOutput.positionMC.xy model_local_position_transformed.xy;vsOutput.positionMC.z model_local_position_transformed.z modelMC.z*0.002;return;
}最后再将customShader赋给3dtiles对象即可。
palaceTileset.customShader flatCustomShader;