Skip to content

Commit

Permalink
fix(shared): 🐛 compatible with GLSL 1.00 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
zouyaoji committed Oct 31, 2023
1 parent a25b3a9 commit b1aa4e4
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/shared/extends/materials/MaterialExtend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@
* @Date: 2023-08-18 00:56:13
* @Description: Do not edit
* @LastEditors: zouyaoji 370681295@qq.com
* @LastEditTime: 2023-08-18 01:15:38
* @LastEditTime: 2023-10-31 19:38:24
* @FilePath: \vue-cesium\packages\shared\extends\materials\MaterialExtend.ts
*/

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

let isExtended = false
export default class MaterialExtend {
static extend(viewer?: Cesium.Viewer) {
static extend(viewer: Cesium.Viewer) {
if (isExtended) {
return
}

const { Material, Color, Cartesian2 } = Cesium
const webgl2 = (viewer as any).context?.webgl2

let shaderSourceTextVcLine = VcLineFlowMaterial
let shaderSourceTextVcCircle = VcCircleWaveMaterial

if (!webgl2) {
shaderSourceTextVcLine = shaderSourceTextVcLine.replace(/texture\(/g, 'texture2D(')
shaderSourceTextVcCircle = shaderSourceTextVcCircle.replace(/texture\(/g, 'texture2D(')
}

/**
* Gets the name of the VcCircleWave material.
Expand All @@ -33,7 +42,7 @@ export default class MaterialExtend {
count: 1,
gradient: 0.1
},
source: VcCircleWaveMaterial
source: shaderSourceTextVcCircle
},
translucent() {
return true
Expand Down Expand Up @@ -62,7 +71,7 @@ export default class MaterialExtend {
color2: new Color(1, 1, 1),
globalAlpha: 1
},
source: VcLineFlowMaterial
source: shaderSourceTextVcLine
},
translucent() {
return true
Expand Down

0 comments on commit b1aa4e4

Please sign in to comment.