From e1699c4851f6ca397cd0ad1ff63f32c737654836 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Wed, 02 Apr 2025 19:14:54 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
src/utils/cesium/ImageTrailMaterial.js | 144 +++++++++++++++++++++++-------------------------
1 files changed, 69 insertions(+), 75 deletions(-)
diff --git a/src/utils/cesium/ImageTrailMaterial.js b/src/utils/cesium/ImageTrailMaterial.js
index 1e1092c..272ed12 100644
--- a/src/utils/cesium/ImageTrailMaterial.js
+++ b/src/utils/cesium/ImageTrailMaterial.js
@@ -1,85 +1,80 @@
-import * as Cesium from 'cesium';
+import * as Cesium from 'cesium'
/**
* 定义Cesium材质对象
*/
class ImageTrailMaterial {
- constructor(options = {}) {
- this._definitionChanged = new Cesium.Event();
- this._color = void 0;
- this._colorSubscription = void 0;
- this._speed = void 0;
- this._speedSubscription = void 0;
- this._image = void 0;
- this._imageSubscription = void 0;
- this._repeat = void 0;
- this._repeatSubscription = void 0;
- this.color = options.color || Cesium.Color.fromBytes(0, 0, 255, 255);
- this.speed = options.speed || 1;
- this.image = options.image;
- this.repeat = new Cesium.Cartesian2(
- options.repeat?.x || 1,
- options.repeat?.y || 1,
- );
- }
+ constructor(options = {}) {
+ this._definitionChanged = new Cesium.Event()
+ this._color = void 0
+ this._colorSubscription = void 0
+ this._speed = void 0
+ this._speedSubscription = void 0
+ this._image = void 0
+ this._imageSubscription = void 0
+ this._repeat = void 0
+ this._repeatSubscription = void 0
+ this.color = options.color || Cesium.Color.fromBytes(0, 0, 255, 255)
+ this.speed = options.speed || 1
+ this.image = options.image
+ this.repeat = new Cesium.Cartesian2(options.repeat?.x || 1, options.repeat?.y || 1)
+ }
- get isConstant() {
- return false;
- }
+ get isConstant() {
+ return false
+ }
- get definitionChanged() {
- return this._definitionChanged;
- }
+ get definitionChanged() {
+ return this._definitionChanged
+ }
- getType() {
- return Cesium.Material.ImageTrailMaterialType;
- }
+ getType() {
+ return Cesium.Material.ImageTrailMaterialType
+ }
- getValue(time, result) {
- if (!result) {
- result = {};
- }
- result.color = Cesium.Property.getValueOrUndefined(this._color, time);
- result.image = Cesium.Property.getValueOrUndefined(this._image, time);
- result.repeat = Cesium.Property.getValueOrUndefined(this._repeat, time);
- result.speed = this._speed;
- return result;
- }
+ getValue(time, result) {
+ if (!result) {
+ result = {}
+ }
+ result.color = Cesium.Property.getValueOrUndefined(this._color, time)
+ result.image = Cesium.Property.getValueOrUndefined(this._image, time)
+ result.repeat = Cesium.Property.getValueOrUndefined(this._repeat, time)
+ result.speed = this._speed
+ return result
+ }
- equals(other) {
- return (
- this === other ||
- (other instanceof ImageTrailMaterial &&
- Cesium.Property.equals(this._color, other._color) &&
- Cesium.Property.equals(this._image, other._image) &&
- Cesium.Property.equals(this._repeat, other._repeat) &&
- Cesium.Property.equals(this._speed, other._speed))
- );
- }
+ equals(other) {
+ return (
+ this === other ||
+ (other instanceof ImageTrailMaterial &&
+ Cesium.Property.equals(this._color, other._color) &&
+ Cesium.Property.equals(this._image, other._image) &&
+ Cesium.Property.equals(this._repeat, other._repeat) &&
+ Cesium.Property.equals(this._speed, other._speed))
+ )
+ }
}
Object.defineProperties(ImageTrailMaterial.prototype, {
- color: Cesium.createPropertyDescriptor('color'),
- speed: Cesium.createPropertyDescriptor('speed'),
- image: Cesium.createPropertyDescriptor('image'),
- repeat: Cesium.createPropertyDescriptor('repeat'),
-});
+ color: Cesium.createPropertyDescriptor('color'),
+ speed: Cesium.createPropertyDescriptor('speed'),
+ image: Cesium.createPropertyDescriptor('image'),
+ repeat: Cesium.createPropertyDescriptor('repeat'),
+})
//材质类型
-Cesium.Material.ImageTrailMaterialType = 'PolylineImageTrail';
+Cesium.Material.ImageTrailMaterialType = 'PolylineImageTrail'
//添加材质到缓冲区中
-Cesium.Material._materialCache.addMaterial(
- Cesium.Material.ImageTrailMaterialType,
- {
- fabric: {
- type: Cesium.Material.ImageTrailMaterialType,
- //uniform变量
- uniforms: {
- color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
- image: Cesium.Material.DefaultImageId,
- speed: 1,
- repeat: new Cesium.Cartesian2(1, 1),
- },
- //
- source: `
+Cesium.Material._materialCache.addMaterial(Cesium.Material.ImageTrailMaterialType, {
+ fabric: {
+ type: Cesium.Material.ImageTrailMaterialType,
+ //uniform变量
+ uniforms: {
+ color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
+ image: Cesium.Material.DefaultImageId,
+ speed: 1,
+ repeat: new Cesium.Cartesian2(1, 1),
+ },
+ //
+ source: `
uniform sampler2D image;
uniform float speed;
uniform vec4 color;
@@ -95,13 +90,12 @@
return material;
}
`,
- },
- translucent: function () {
- return true;
- },
- },
-);
-export default ImageTrailMaterial;
+ },
+ translucent: function () {
+ return true
+ },
+})
+export default ImageTrailMaterial
//之前的航线材质编写
// source: `
--
Gitblit v1.9.3