PolylineTrailMaterialProperty源码
时间: 2023-07-05 13:30:50 浏览: 37
以下是 `PolylineTrailMaterialProperty` 的源代码,摘自 Cesium.js 的源代码:
```javascript
function PolylineTrailMaterialProperty(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
this._definitionChanged = new Event();
this._color = undefined;
this._colorSubscription = undefined;
this.color = options.color;
this.duration = defaultValue(options.duration, 1000);
this.trailLength = defaultValue(options.trailLength, 0.2);
}
defineProperties(PolylineTrailMaterialProperty.prototype, {
isConstant: {
get: function() {
return false;
}
},
definitionChanged: {
get: function() {
return this._definitionChanged;
}
},
color: {
get: function() {
return this._color;
},
set: function(value) {
var oldValue = this._color;
if (!Color.equals(oldValue, value)) {
this._color = value;
this._colorSubscription = undefined;
this._definitionChanged.raiseEvent(this);
}
}
}
});
PolylineTrailMaterialProperty.prototype.getType = function(time) {
return "PolylineTrail";
};
PolylineTrailMaterialProperty.prototype.getValue = function(time, result) {
if (!defined(result)) {
result = {};
}
result.color = Color.clone(
this._color,
defined(result.color) ? result.color : new Color()
);
result.image = PolylineTrailLink.getLink(this.duration, this.trailLength);
result.time = (((time.secondsOfDay - (time.secondsOfDay % this.duration)) /
this.duration) * this.duration);
return result;
};
PolylineTrailMaterialProperty.prototype.equals = function(other) {
return (
this === other ||
(other instanceof PolylineTrailMaterialProperty &&
Color.equals(this._color, other._color) &&
this.duration === other.duration &&
this.trailLength === other.trailLength)
);
};
```
上述代码定义了 `PolylineTrailMaterialProperty` 类,该类继承自 `MaterialProperty` 类。在构造函数中,`options` 参数包含了拖尾材质的颜色、持续时间和拖尾长度。`PolylineTrailMaterialProperty` 重写了 `getType` 和 `getValue` 方法,用于获取材质类型和材质参数。`equals` 方法用于判断两个材质属性是否相等。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)