diff --git a/ShadowEditor.Web/index.html b/ShadowEditor.Web/index.html index 3383c2cf..92b63b1a 100644 --- a/ShadowEditor.Web/index.html +++ b/ShadowEditor.Web/index.html @@ -26,6 +26,7 @@ + diff --git a/ShadowEditor.Web/src/editor/menubar/ComponentMenu.js b/ShadowEditor.Web/src/editor/menubar/ComponentMenu.js index a0a586d1..77f3cb85 100644 --- a/ShadowEditor.Web/src/editor/menubar/ComponentMenu.js +++ b/ShadowEditor.Web/src/editor/menubar/ComponentMenu.js @@ -169,7 +169,7 @@ ComponentMenu.prototype.onAddCloth = function () { // ----------------------------- 地球 -------------------------------------- ComponentMenu.prototype.onAddEarth = function () { - var globe = new Globe(); + var globe = new Globe(this.app); this.app.editor.execute(new AddObjectCommand(globe)); }; diff --git a/ShadowEditor.Web/src/gis/Globe.js b/ShadowEditor.Web/src/gis/Globe.js index 27ae82f6..6029c672 100644 --- a/ShadowEditor.Web/src/gis/Globe.js +++ b/ShadowEditor.Web/src/gis/Globe.js @@ -3,8 +3,13 @@ import GlobeMaterial from './GlobeMaterial'; /** * 地球 + * @param {*} app */ -function Globe() { +function Globe(app) { + var lon = 0; + var lat = 0; + var zoom = 1; + var geometry = new GlobeGeometry(); var material = new GlobeMaterial(); diff --git a/ShadowEditor.Web/src/gis/GlobeGeometry.js b/ShadowEditor.Web/src/gis/GlobeGeometry.js index ff11c150..55c4a27e 100644 --- a/ShadowEditor.Web/src/gis/GlobeGeometry.js +++ b/ShadowEditor.Web/src/gis/GlobeGeometry.js @@ -2,10 +2,26 @@ * 地球几何体 */ function GlobeGeometry() { - THREE.PlaneBufferGeometry.call(this, 1, 1, 256, 256); + THREE.InstancedBufferGeometry.call(this); + + this.maxInstancedCount = 4; + + var geometry = new THREE.PlaneBufferGeometry(1, 1); + + this.addAttribute('position', geometry.attributes.position); + this.addAttribute('normal', geometry.attributes.normal); + this.addAttribute('uv', geometry.attributes.uv); + + var offsets = []; + + for (var i = 0; i < 4; i++) { + offsets.push(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5); + } + + this.addAttribute('offset', new THREE.InstancedBufferAttribute(new Float32Array(offsets), 3)); } -GlobeGeometry.prototype = Object.create(THREE.PlaneBufferGeometry.prototype); +GlobeGeometry.prototype = Object.create(THREE.InstancedBufferGeometry.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 index 0bde6da8..52a0453d 100644 --- a/ShadowEditor.Web/src/gis/GlobeMaterial.js +++ b/ShadowEditor.Web/src/gis/GlobeMaterial.js @@ -5,13 +5,13 @@ import GlobeFragment from './shader/globe_fragment.glsl'; * 地球材质 */ function GlobeMaterial() { - THREE.ShaderMaterial.call(this, { + THREE.RawShaderMaterial.call(this, { vertexShader: GlobeVertex, fragmentShader: GlobeFragment }); } -GlobeMaterial.prototype = Object.create(THREE.ShaderMaterial.prototype); +GlobeMaterial.prototype = Object.create(THREE.RawShaderMaterial.prototype); GlobeMaterial.prototype.constructor = GlobeMaterial; export default GlobeMaterial; \ No newline at end of file diff --git a/ShadowEditor.Web/src/gis/layer/BingLayer.js b/ShadowEditor.Web/src/gis/layer/BingLayer.js new file mode 100644 index 00000000..4ba963dc --- /dev/null +++ b/ShadowEditor.Web/src/gis/layer/BingLayer.js @@ -0,0 +1,10 @@ +import Layer from './Layer'; + +function BingLayer() { + Layer.call(this); +} + +BingLayer.prototype = Object.create(Layer.prototype); +BingLayer.prototype.constructor = BingLayer; + +export default BingLayer; \ No newline at end of file diff --git a/ShadowEditor.Web/src/gis/layer/Layer.js b/ShadowEditor.Web/src/gis/layer/Layer.js new file mode 100644 index 00000000..1c023b93 --- /dev/null +++ b/ShadowEditor.Web/src/gis/layer/Layer.js @@ -0,0 +1,11 @@ +var ID = -1; + +/** + * 层 + */ +function Layer() { + this.id = `${this.constructor.name}${ID--}`; + this.name = `Layer`; +} + +export default Layer; \ 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 index ddce5e7e..2ed9dbda 100644 --- a/ShadowEditor.Web/src/gis/shader/globe_vertex.glsl +++ b/ShadowEditor.Web/src/gis/shader/globe_vertex.glsl @@ -1,3 +1,11 @@ +uniform mat4 modelViewMatrix; +uniform mat4 projectionMatrix; + +attribute vec3 position; +attribute vec3 normal; +attribute vec3 uv; +attribute vec3 offset; + void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } \ No newline at end of file diff --git a/ShadowEditor.Web/src/gis/tile/TileGrid.js b/ShadowEditor.Web/src/gis/tile/TileGrid.js deleted file mode 100644 index 9272952d..00000000 --- a/ShadowEditor.Web/src/gis/tile/TileGrid.js +++ /dev/null @@ -1,5 +0,0 @@ -function TileGrid() { - -} - -export default TileGrid; \ No newline at end of file diff --git a/ShadowEditor.Web/src/gis/tile/Tiles.js b/ShadowEditor.Web/src/gis/tile/Tiles.js new file mode 100644 index 00000000..bb751224 --- /dev/null +++ b/ShadowEditor.Web/src/gis/tile/Tiles.js @@ -0,0 +1,5 @@ +function Tiles() { + +} + +export default Tiles; \ No newline at end of file diff --git a/ShadowEditor.Web/view.html b/ShadowEditor.Web/view.html index 10f10efb..c227e8b9 100644 --- a/ShadowEditor.Web/view.html +++ b/ShadowEditor.Web/view.html @@ -38,6 +38,7 @@ +