Skip to content

Commit b1aa4e4

Browse files
committed
fix(shared): 🐛 compatible with GLSL 1.00 syntax
1 parent a25b3a9 commit b1aa4e4

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/shared/extends/materials/MaterialExtend.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,29 @@
33
* @Date: 2023-08-18 00:56:13
44
* @Description: Do not edit
55
* @LastEditors: zouyaoji 370681295@qq.com
6-
* @LastEditTime: 2023-08-18 01:15:38
6+
* @LastEditTime: 2023-10-31 19:38:24
77
* @FilePath: \vue-cesium\packages\shared\extends\materials\MaterialExtend.ts
88
*/
99

1010
import { VcCircleWaveMaterial, VcLineFlowMaterial } from '@vue-cesium/shared/shaders/materials'
1111

1212
let isExtended = false
1313
export default class MaterialExtend {
14-
static extend(viewer?: Cesium.Viewer) {
14+
static extend(viewer: Cesium.Viewer) {
1515
if (isExtended) {
1616
return
1717
}
1818

1919
const { Material, Color, Cartesian2 } = Cesium
20+
const webgl2 = (viewer as any).context?.webgl2
21+
22+
let shaderSourceTextVcLine = VcLineFlowMaterial
23+
let shaderSourceTextVcCircle = VcCircleWaveMaterial
24+
25+
if (!webgl2) {
26+
shaderSourceTextVcLine = shaderSourceTextVcLine.replace(/texture\(/g, 'texture2D(')
27+
shaderSourceTextVcCircle = shaderSourceTextVcCircle.replace(/texture\(/g, 'texture2D(')
28+
}
2029

2130
/**
2231
* Gets the name of the VcCircleWave material.
@@ -33,7 +42,7 @@ export default class MaterialExtend {
3342
count: 1,
3443
gradient: 0.1
3544
},
36-
source: VcCircleWaveMaterial
45+
source: shaderSourceTextVcCircle
3746
},
3847
translucent() {
3948
return true
@@ -62,7 +71,7 @@ export default class MaterialExtend {
6271
color2: new Color(1, 1, 1),
6372
globalAlpha: 1
6473
},
65-
source: VcLineFlowMaterial
74+
source: shaderSourceTextVcLine
6675
},
6776
translucent() {
6877
return true

0 commit comments

Comments
 (0)