Last active
December 14, 2020 10:12
-
-
Save wewindy/8fe2a4fec58e92089b14ba89d426333b to your computer and use it in GitHub Desktop.
showPrimitiveShader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Need Cesium.js 1.7x environment. | |
*/ | |
var viewer = new Cesium.Viewer("cesiumContainer"); | |
viewer.scene.globe.depthTestAgainstTerrain = true; | |
viewer.camera.setView({ | |
destination : new Cesium.Cartesian3(-2644963.9889313546, 5763731.142118295, 2199400.7089496767), //世界坐标系下的一个坐标点 | |
orientation : {//旋转角度 | |
heading :6.075, | |
pitch :-0.727, | |
roll : 6.283 | |
} | |
}); | |
const extrudedPolygon = new Cesium.PolygonGeometry({ | |
polygonHierarchy : new Cesium.PolygonHierarchy( | |
Cesium.Cartesian3.fromDegreesArray([ | |
112.41726298378288, 23.290411251106182, | |
113.67072522399741, 23.560312361463682, | |
114.09370956893551, 22.590768298743153, | |
112.83803246418894, 22.285610818885644 | |
]) | |
), | |
extrudedHeight: 3000 | |
}); | |
const instance = new Cesium.GeometryInstance({ | |
geometry: extrudedPolygon, | |
id: 'box with height' | |
}); | |
const m = new Cesium.Material({ | |
fabric: { | |
type: 'Color', | |
uniforms: { | |
color: new Cesium.Color(216 / 255.0, 170 / 255.0, 208 / 255.0).withAlpha(0.618), | |
}, | |
} | |
}); | |
const aper = new Cesium.MaterialAppearance({ | |
material : m, | |
}); | |
var p = viewer.scene.primitives.add(new Cesium.Primitive({ | |
geometryInstances: instance, | |
appearance: aper, | |
releaseGeometryInstances: false, | |
compressVertices: false, | |
})); | |
// p.readyPromise.then(v => console.log(v)); | |
const vs = aper.vertexShaderSource; | |
const fs = aper.fragmentShaderSource; | |
const fs2 = aper.getFragmentShaderSource(); | |
console.log(`// 顶点着色器: | |
${vs}`); | |
console.log(`// 片元着色器: | |
${fs}`); | |
console.log(`// 片元着色器2: | |
${fs2}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
console log: