我需要绘制尺寸固定的图像,我可以得到一个0~1坐标与materialInput.st,但我不知道如何得到一个0~分辨率坐标。那么,有什么内置的房产或其他方式来重新出售吗?
另一个问题是,当我放大到一定程度时,我的材料可能会按相机的方向像镜子一样伸展或包裹,我不知道这种情况。
最后一个是关于materialInput.positionToEyeEC的,我不能很好地理解这个属性。谁能更详细地谈谈这件事,或者举几个例子?
我的自定义材料属性代码在下面。
function SpotMaterialProperty(color) {
this._definitionChanged = new Cesium.Event()
this._color = undefined
this._colorSubscription = undefined
this._time = Date.now()
this.color = Cesium.defaultValue(color, Cesium.Color.WHITE)
}
Object.defineProperties(SpotMaterialProperty.prototype, {
isConstant: {
get: function () {
return false
}
},
definitionChanged: {
get: function () {
return this._definitionChanged
}
},
color: Cesium.createPropertyDescriptor('color')
})
SpotMaterialProperty.prototype.getType = function () {
return 'Spot'
}
SpotMaterialProperty.prototype.getValue = function (time, result) {
if (!Cesium.defined(result)) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.time = (Date.now() - this._time) / 1000
return result
}
SpotMaterialProperty.prototype.equals = function (other) {
return (
this === other || //
(other instanceof SpotMaterialProperty && Cesium.Property.equals(this._color, other._color))
)
}
Cesium.Material.SpotMaterialSource = `uniform float time;
uniform vec4 color;
czm_material czm_getMaterial (czm_materialInput materialInput) {
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 coord = materialInput.st.xy;
float size = 300.;
coord *= size;
vec4 f = color;
vec4 bg = vec4(f.rgb, f.a * .2);
float x = mod(floor(coord.x + time * .3), 2.);
float y = mod(floor(coord.y + time * .3), 2.);
f.a *= x * y * .5;
f += bg;
material.diffuse = f.rgb;
material.emission = f.rgb;
material.alpha = f.a;
return material;
}`
Cesium.Material.SpotType = 'Spot'
Cesium.SpotMaterialProperty = SpotMaterialProperty
Cesium.Material._materialCache.addMaterial(Cesium.Material.SpotType, {
fabric: {
type: Cesium.Material.SpotType,
uniforms: {
color: Cesium.Color.WHITE,
time: 0
},
source: Cesium.Material.SpotMaterialSource
},
translucent: function (material) {
return material.uniforms.color.alpha < 1.0
}
})谢谢你帮忙。
- 2021-9-3更新


这是另一种材料和图像在两个层次上,第二个是正常的,第一个是明显的变形。
发布于 2021-09-02 07:08:49
与所有铯实体属性一样,Property版本的目的是描述随着时间的推移,铯的定义是如何变化的。例如,一个MaterialProperty可以在一个时间间隔内指示一个实心颜色,在一个单独的时间间隔内表示一个条纹材料。实际的底层Material可能会被销毁,并由此在动画期间创建一个替换的。
这应该在即将发布的版本(1.16)中得到修正,您可以使用这段代码生成一个半透明的图像:
var viewer = new Cesium.Viewer('cesiumContainer');
viewer.entities.add({
rectangle: {
coordinates: Cesium.Rectangle.fromDegrees(-125,30,-110,40),
material: new Cesium.ImageMaterialProperty({
image: '../images/Cesium_Logo_Color.jpg',
alpha: 0.5
}),
}
});https://stackoverflow.com/questions/69025380
复制相似问题