Browse Source

add filterColor

tags/3.0.0
Caven Chen 2 years ago
parent
commit
65f2cab866
2 changed files with 15 additions and 22 deletions
  1. 3
    22
      src/index.js
  2. 12
    0
      src/modules/option/ViewerOption.js

+ 3
- 22
src/index.js View File

@@ -6,7 +6,6 @@ import { getLib, registerLib } from './global-api/lib-utils.js'
export { registerLib, getLib } from './global-api/lib-utils.js'

let _baseUrl = './libs/dc-sdk/resources/'
let _accessToken = ''

export const config = {
set baseUrl(baseUrl) {
@@ -15,21 +14,12 @@ export const config = {
get baseUrl() {
return _baseUrl
},
set accessToken(accessToken) {
_accessToken = accessToken
},
get accessToken() {
return _accessToken
},
}

export function ready(options = {}) {
if (options['baseUrl']) {
this.config.baseUrl = options['baseUrl']
}
if (options['accessToken']) {
this.config.accessToken = options['accessToken']
}

if (options['Cesium']) {
registerLib('Cesium', options['Cesium'])
@@ -41,10 +31,6 @@ export function ready(options = {}) {
registerLib('echarts', options['echarts'])
}

// if (options['turf']) {
// registerLib('turf', options['turf'])
// }

this['__cmdOut'] && this['__cmdOut']()

return new Promise((resolve, reject) => {
@@ -66,9 +52,9 @@ export function ready(options = {}) {
})
// register math module
if (this['Math']) {
const funcs = require('./modules/math')
Object.keys(funcs).forEach((key) => {
this['Math'][key] = funcs[key]
const maths = require('./modules/math')
Object.keys(maths).forEach((key) => {
this['Math'][key] = maths[key]
})
}
// register chart module
@@ -78,11 +64,6 @@ export function ready(options = {}) {
this[key] = modules[key]
})
}
// register turf module
if (getLib('turf')) {
// todo
}

resolve()
}).catch((e) => {
throw new Error(e.message)

+ 12
- 0
src/modules/option/ViewerOption.js View File

@@ -120,6 +120,18 @@ class ViewerOption {
globeOption?.translucency?.frontFaceAlphaByDistance,
})

if (globeOption?.filterColor) {
let shaderSource =
this._viewer.scene.globe._surfaceShaderSet.baseFragmentShaderSource
let globeFS = shaderSource.sources.pop()
shaderSource.sources.push(
globeFS.replace(
'out_FragColor = finalColor;',
`out_FragColor = finalColor * vec4${globeOption.filterColor.toString()};`
)
)
}

return this
}


Loading…
Cancel
Save