cesium 车流_vue中cesium自定义材料之流动线条效果

论坛 期权论坛 期权     
选择匿名的用户   2021-5-17 00:31   8771   0

import Cesium from 'cesium/Cesium'

/*流动纹理线

color 颜色

duration 持续时间 毫秒*/

functionPolylineTrailLinkMaterialProperty (color, duration) {this._definitionChanged = newCesium.Event()this._color =undefinedthis._colorSubscription =undefinedthis.color =colorthis.duration =durationthis._time = newDate().getTime()

}

Cesium.defineProperties(PolylineTrailLinkMaterialProperty.prototype, {

isConstant: {

get:function() {return false}

},

definitionChanged: {

get:function() {return this._definitionChanged

}

},

color: Cesium.createPropertyDescriptor('color')

})

PolylineTrailLinkMaterialProperty.prototype.getType= function(time) {return 'PolylineTrailLink'}

PolylineTrailLinkMaterialProperty.prototype.getValue= function(time, result) {//debugger

if (!Cesium.defined(result)) {

result={}

}

result.color=Cesium.Property.getValueOrClonedDefault(this._color,

time,

Cesium.Color.WHITE,

result.color

)

result.image=Cesium.Material.PolylineTrailLinkImage

result.time=((new Date().getTime() - this._time) % this.duration) / this.durationreturnresult

}

PolylineTrailLinkMaterialProperty.prototype.equals= function(other) {return(this === other ||(otherinstanceof PolylineTrailLinkMaterialProperty &&Property.equals(this._color, other._color))

)

}

Cesium.PolylineTrailLinkMaterialProperty=PolylineTrailLinkMaterialProperty

Cesium.Material.PolylineTrailLinkType= 'PolylineTrailLink'Cesium.Material.PolylineTrailLinkImage= require('../assets/layout/cable.png')

Cesium.Material.PolylineTrailLinkSource=

'czm_material czm_getMaterial(czm_materialInput materialInput)\n\

{\n\

czm_material material = czm_getDefaultMaterial(materialInput);\n\

vec2 st = materialInput.st;\n\

vec4 colorImage = texture2D(image, vec2(fract(st.s - time), st.t));\n\

material.alpha = colorImage.a * color.a;\n\

material.diffuse = (colorImage.rgb+color.rgb)/2.0;\n\

return material;\n\

}'Cesium.Material._materialCache.addMaterial(

Cesium.Material.PolylineTrailLinkType,

{

fabric: {

type: Cesium.Material.PolylineTrailLinkType,

uniforms: {

color:new Cesium.Color(1.0, 0.0, 0.0, 0.5),

image: Cesium.Material.PolylineTrailLinkImage,

time:0},

source: Cesium.Material.PolylineTrailLinkSource

},

translucent:function(material) {return true}

}

)

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP