地球几何体材质。

This commit is contained in:
tengge1 2019-03-18 19:52:27 +08:00
parent 3443ac64cf
commit 12e30210ff
5 changed files with 39 additions and 2 deletions

View File

@ -1,9 +1,12 @@
import GlobeGeometry from './GlobeGeometry';
import GlobeMaterial from './GlobeMaterial';
/**
* 地球
*/
function Globe() {
var geometry = new THREE.BoxBufferGeometry(1, 1, 1);
var material = new THREE.MeshBasicMaterial();
var geometry = new GlobeGeometry();
var material = new GlobeMaterial();
THREE.Mesh.call(this, geometry, material);

View File

@ -0,0 +1,11 @@
/**
* 地球几何体
*/
function GlobeGeometry() {
THREE.PlaneBufferGeometry.call(this, 1, 1, 256, 256);
}
GlobeGeometry.prototype = Object.create(THREE.PlaneBufferGeometry.prototype);
GlobeGeometry.prototype.constructor = GlobeGeometry;
export default GlobeGeometry;

View File

@ -0,0 +1,17 @@
import GlobeVertex from './shader/globe_vertex.glsl';
import GlobeFragment from './shader/globe_fragment.glsl';
/**
* 地球材质
*/
function GlobeMaterial() {
THREE.ShaderMaterial.call(this, {
vertexShader: GlobeVertex,
fragmentShader: GlobeFragment
});
}
GlobeMaterial.prototype = Object.create(THREE.ShaderMaterial.prototype);
GlobeMaterial.prototype.constructor = GlobeMaterial;
export default GlobeMaterial;

View File

@ -0,0 +1,3 @@
void main() {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

View File

@ -0,0 +1,3 @@
void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}