From 12e30210ff90bb74c3dc48bc845088f00e3a718e Mon Sep 17 00:00:00 2001 From: tengge1 <930372551@qq.com> Date: Mon, 18 Mar 2019 19:52:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E7=90=83=E5=87=A0=E4=BD=95=E4=BD=93?= =?UTF-8?q?=E6=9D=90=E8=B4=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShadowEditor.Web/src/gis/Globe.js | 7 +++++-- ShadowEditor.Web/src/gis/GlobeGeometry.js | 11 +++++++++++ ShadowEditor.Web/src/gis/GlobeMaterial.js | 17 +++++++++++++++++ .../src/gis/shader/globe_fragment.glsl | 3 +++ .../src/gis/shader/globe_vertex.glsl | 3 +++ 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 ShadowEditor.Web/src/gis/GlobeGeometry.js create mode 100644 ShadowEditor.Web/src/gis/GlobeMaterial.js create mode 100644 ShadowEditor.Web/src/gis/shader/globe_fragment.glsl create mode 100644 ShadowEditor.Web/src/gis/shader/globe_vertex.glsl diff --git a/ShadowEditor.Web/src/gis/Globe.js b/ShadowEditor.Web/src/gis/Globe.js index 3a892c49..27ae82f6 100644 --- a/ShadowEditor.Web/src/gis/Globe.js +++ b/ShadowEditor.Web/src/gis/Globe.js @@ -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); diff --git a/ShadowEditor.Web/src/gis/GlobeGeometry.js b/ShadowEditor.Web/src/gis/GlobeGeometry.js new file mode 100644 index 00000000..ff11c150 --- /dev/null +++ b/ShadowEditor.Web/src/gis/GlobeGeometry.js @@ -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; \ No newline at end of file diff --git a/ShadowEditor.Web/src/gis/GlobeMaterial.js b/ShadowEditor.Web/src/gis/GlobeMaterial.js new file mode 100644 index 00000000..0bde6da8 --- /dev/null +++ b/ShadowEditor.Web/src/gis/GlobeMaterial.js @@ -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; \ No newline at end of file diff --git a/ShadowEditor.Web/src/gis/shader/globe_fragment.glsl b/ShadowEditor.Web/src/gis/shader/globe_fragment.glsl new file mode 100644 index 00000000..361b6366 --- /dev/null +++ b/ShadowEditor.Web/src/gis/shader/globe_fragment.glsl @@ -0,0 +1,3 @@ +void main() { + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} \ No newline at end of file diff --git a/ShadowEditor.Web/src/gis/shader/globe_vertex.glsl b/ShadowEditor.Web/src/gis/shader/globe_vertex.glsl new file mode 100644 index 00000000..ddce5e7e --- /dev/null +++ b/ShadowEditor.Web/src/gis/shader/globe_vertex.glsl @@ -0,0 +1,3 @@ +void main() { + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +} \ No newline at end of file