@openglobus/og 0.11.2 → 0.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -13
- package/src/og/Clock.js +10 -10
- package/src/og/Events.js +8 -6
- package/src/og/Extent.js +82 -41
- package/src/og/Globe.js +25 -13
- package/src/og/ImageCanvas.js +22 -16
- package/src/og/LonLat.js +16 -13
- package/src/og/Popup.js +21 -14
- package/src/og/QueueArray.js +6 -2
- package/src/og/Rectangle.js +11 -6
- package/src/og/Stack.js +5 -2
- package/src/og/ajax.js +21 -33
- package/src/og/astro/astro.js +5 -5
- package/src/og/astro/earth.js +22 -16
- package/src/og/astro/jd.js +23 -18
- package/src/og/astro/orbit.js +13 -11
- package/src/og/astro/rotation.js +17 -8
- package/src/og/bv/Box.js +7 -3
- package/src/og/bv/Sphere.js +14 -11
- package/src/og/camera/Camera.js +51 -54
- package/src/og/camera/Frustum.js +29 -18
- package/src/og/camera/PlanetCamera.js +32 -23
- package/src/og/control/CompassButton.js +5 -1
- package/src/og/control/Control.js +12 -10
- package/src/og/control/DebugInfo.js +4 -1
- package/src/og/control/EarthCoordinates.js +54 -33
- package/src/og/control/KeyboardNavigation.js +10 -10
- package/src/og/control/LayerSwitcher.js +22 -21
- package/src/og/control/Lighting.js +34 -3
- package/src/og/control/MouseNavigation.js +1 -1
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/SegmentBoundVisualization.js +6 -7
- package/src/og/control/ShowFps.js +13 -8
- package/src/og/control/SimpleNavigation.js +6 -8
- package/src/og/control/Sun.js +25 -15
- package/src/og/control/ToggleWireframe.js +4 -4
- package/src/og/control/TouchNavigation.js +44 -33
- package/src/og/control/ZoomControl.js +41 -25
- package/src/og/ellipsoid/Ellipsoid.js +162 -66
- package/src/og/ellipsoid/wgs84.js +4 -4
- package/src/og/entity/BaseBillboard.js +100 -56
- package/src/og/entity/Billboard.js +14 -10
- package/src/og/entity/BillboardHandler.js +317 -60
- package/src/og/entity/Entity.js +100 -68
- package/src/og/entity/EntityCollection.js +70 -47
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/Geometry.js +27 -24
- package/src/og/entity/GeometryHandler.js +596 -124
- package/src/og/entity/Label.js +80 -49
- package/src/og/entity/LabelHandler.js +45 -244
- package/src/og/entity/LabelWorker.js +218 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +80 -32
- package/src/og/entity/PointCloudHandler.js +8 -8
- package/src/og/entity/Polyline.js +16 -16
- package/src/og/entity/Ray.js +60 -27
- package/src/og/entity/Strip.js +77 -48
- package/src/og/entity/StripHandler.js +26 -26
- package/src/og/entity/index.js +8 -16
- package/src/og/layer/BaseGeoImage.js +54 -23
- package/src/og/layer/CanvasTiles.js +24 -24
- package/src/og/layer/GeoImage.js +9 -9
- package/src/og/layer/GeoVideo.js +3 -3
- package/src/og/layer/KML.js +63 -37
- package/src/og/layer/Layer.js +44 -21
- package/src/og/layer/Material.js +23 -20
- package/src/og/layer/Vector.js +114 -68
- package/src/og/layer/WMS.js +34 -17
- package/src/og/layer/XYZ.js +48 -46
- package/src/og/light/LightSource.js +46 -39
- package/src/og/math/Mat3.js +34 -22
- package/src/og/math/Mat4.js +603 -459
- package/src/og/math/Plane.js +21 -20
- package/src/og/math/Quat.js +182 -139
- package/src/og/math/Ray.js +38 -33
- package/src/og/math/Vec2.js +85 -75
- package/src/og/math/Vec3.js +142 -112
- package/src/og/math/Vec4.js +27 -31
- package/src/og/math/coder.js +10 -10
- package/src/og/math.js +12 -12
- package/src/og/proj/EPSG3857.js +4 -4
- package/src/og/proj/EPSG4326.js +4 -4
- package/src/og/proj/Proj.js +4 -6
- package/src/og/quadTree/Node.js +8 -8
- package/src/og/renderer/Renderer.js +59 -52
- package/src/og/renderer/RendererEvents.js +50 -27
- package/src/og/scene/BaseNode.js +7 -8
- package/src/og/scene/Planet.js +102 -103
- package/src/og/scene/RenderNode.js +28 -21
- package/src/og/segment/Segment.js +26 -21
- package/src/og/segment/SegmentLonLat.js +5 -5
- package/src/og/shaders/drawnode.js +135 -142
- package/src/og/shaders/geoObject.js +211 -0
- package/src/og/shaders/pointCloud.js +41 -41
- package/src/og/shaders/shape.js +12 -18
- package/src/og/shaders/skybox.js +36 -36
- package/src/og/shaders/toneMapping.js +1 -0
- package/src/og/shapes/BaseShape.js +126 -54
- package/src/og/shapes/Icosphere.js +29 -14
- package/src/og/shapes/Sphere.js +12 -15
- package/src/og/terrain/BilTerrain.js +1 -0
- package/src/og/terrain/EmptyTerrain.js +2 -2
- package/src/og/terrain/GlobusTerrain.js +9 -9
- package/src/og/utils/FontAtlas.js +6 -2
- package/src/og/utils/TextureAtlas.js +22 -24
- package/src/og/utils/VectorTileCreator.js +1 -3
- package/src/og/utils/shared.js +16 -16
- package/src/og/webgl/Framebuffer.js +88 -40
- package/src/og/webgl/Handler.js +243 -169
- package/src/og/webgl/Multisample.js +47 -19
- package/src/og/webgl/Program.js +79 -34
- package/src/og/webgl/ProgramController.js +17 -13
- package/src/og/webgl/callbacks.js +8 -8
- package/src/og/inherits.js +0 -8
- package/src/og/utils/polylabel.js +0 -176
- package/types/Clock.d.ts +0 -90
- package/types/Deferred.d.ts +0 -6
- package/types/Events.d.ts +0 -73
- package/types/Extent.d.ts +0 -166
- package/types/Globe.d.ts +0 -75
- package/types/ImageCanvas.d.ts +0 -121
- package/types/Lock.d.ts +0 -12
- package/types/LonLat.d.ts +0 -108
- package/types/Popup.d.ts +0 -38
- package/types/QueueArray.d.ts +0 -15
- package/types/Rectangle.d.ts +0 -74
- package/types/Stack.d.ts +0 -15
- package/types/ajax.d.ts +0 -24
- package/types/arial.d.ts +0 -48
- package/types/astro/astro.d.ts +0 -38
- package/types/astro/earth.d.ts +0 -6
- package/types/astro/jd.d.ts +0 -254
- package/types/bv/Box.d.ts +0 -25
- package/types/bv/Sphere.d.ts +0 -38
- package/types/bv/index.d.ts +0 -3
- package/types/camera/Camera.d.ts +0 -303
- package/types/camera/Frustum.d.ts +0 -129
- package/types/camera/PlanetCamera.d.ts +0 -223
- package/types/camera/index.d.ts +0 -3
- package/types/cons.d.ts +0 -40
- package/types/control/CompassButton.d.ts +0 -18
- package/types/control/Control.d.ts +0 -101
- package/types/control/DebugInfo.d.ts +0 -16
- package/types/control/EarthCoordinates.d.ts +0 -47
- package/types/control/EarthNavigation.d.ts +0 -42
- package/types/control/GeoImageDragControl.d.ts +0 -6
- package/types/control/KeyboardNavigation.d.ts +0 -22
- package/types/control/LayerSwitcher.d.ts +0 -23
- package/types/control/Lighting.d.ts +0 -16
- package/types/control/MouseNavigation.d.ts +0 -51
- package/types/control/ScaleControl.d.ts +0 -22
- package/types/control/ShowFps.d.ts +0 -12
- package/types/control/SimpleNavigation.d.ts +0 -28
- package/types/control/Sun.d.ts +0 -52
- package/types/control/ToggleWireframe.d.ts +0 -12
- package/types/control/TouchNavigation.d.ts +0 -50
- package/types/control/ZoomControl.d.ts +0 -28
- package/types/control/index.d.ts +0 -17
- package/types/ellipsoid/Ellipsoid.d.ts +0 -142
- package/types/ellipsoid/index.d.ts +0 -3
- package/types/ellipsoid/wgs84.d.ts +0 -5
- package/types/entity/BaseBillboard.d.ts +0 -208
- package/types/entity/Billboard.d.ts +0 -94
- package/types/entity/BillboardHandler.d.ts +0 -74
- package/types/entity/Entity.d.ts +0 -331
- package/types/entity/EntityCollection.d.ts +0 -303
- package/types/entity/Geometry.d.ts +0 -73
- package/types/entity/GeometryHandler.d.ts +0 -76
- package/types/entity/Label.d.ts +0 -194
- package/types/entity/LabelHandler.d.ts +0 -24
- package/types/entity/PointCloud.d.ts +0 -174
- package/types/entity/PointCloudHandler.d.ts +0 -38
- package/types/entity/Polyline.d.ts +0 -304
- package/types/entity/PolylineHandler.d.ts +0 -18
- package/types/entity/Ray.d.ts +0 -123
- package/types/entity/RayHandler.d.ts +0 -67
- package/types/entity/ShapeHandler.d.ts +0 -22
- package/types/entity/Strip.d.ts +0 -118
- package/types/entity/StripHandler.d.ts +0 -38
- package/types/entity/index.d.ts +0 -8
- package/types/index.core.d.ts +0 -65
- package/types/index.d.ts +0 -45
- package/types/index.webgl.d.ts +0 -7
- package/types/inherits.d.ts +0 -4
- package/types/input/KeyboardHandler.d.ts +0 -10
- package/types/input/MouseHandler.d.ts +0 -5
- package/types/input/TouchHandler.d.ts +0 -5
- package/types/input/input.d.ts +0 -34
- package/types/layer/BaseGeoImage.d.ts +0 -107
- package/types/layer/CanvasTiles.d.ts +0 -75
- package/types/layer/GeoImage.d.ts +0 -65
- package/types/layer/GeoTexture2d.d.ts +0 -8
- package/types/layer/GeoVideo.d.ts +0 -80
- package/types/layer/KML.d.ts +0 -58
- package/types/layer/Layer.d.ts +0 -321
- package/types/layer/Material.d.ts +0 -48
- package/types/layer/Vector.d.ts +0 -228
- package/types/layer/WMS.d.ts +0 -66
- package/types/layer/XYZ.d.ts +0 -130
- package/types/layer/index.d.ts +0 -10
- package/types/light/LightSource.d.ts +0 -177
- package/types/math/Line2.d.ts +0 -11
- package/types/math/Line3.d.ts +0 -10
- package/types/math/Mat3.d.ts +0 -63
- package/types/math/Mat4.d.ts +0 -173
- package/types/math/Plane.d.ts +0 -17
- package/types/math/Quat.d.ts +0 -376
- package/types/math/Ray.d.ts +0 -81
- package/types/math/Vec2.d.ts +0 -308
- package/types/math/Vec3.d.ts +0 -459
- package/types/math/Vec4.d.ts +0 -161
- package/types/math/coder.d.ts +0 -42
- package/types/math/index.d.ts +0 -11
- package/types/math.d.ts +0 -261
- package/types/mercator.d.ts +0 -92
- package/types/proj/EPSG3857.d.ts +0 -5
- package/types/proj/EPSG4326.d.ts +0 -5
- package/types/proj/Proj.d.ts +0 -42
- package/types/quadTree/EntityCollectionNode.d.ts +0 -34
- package/types/quadTree/Node.d.ts +0 -61
- package/types/quadTree/quadTree.d.ts +0 -40
- package/types/renderer/Renderer.d.ts +0 -296
- package/types/renderer/RendererEvents.d.ts +0 -230
- package/types/res/images.d.ts +0 -3
- package/types/scene/Axes.d.ts +0 -11
- package/types/scene/BaseNode.d.ts +0 -60
- package/types/scene/Planet.d.ts +0 -574
- package/types/scene/RenderNode.d.ts +0 -143
- package/types/scene/SkyBox.d.ts +0 -10
- package/types/scene/index.d.ts +0 -4
- package/types/segment/Segment.d.ts +0 -271
- package/types/segment/SegmentLonLat.d.ts +0 -62
- package/types/segment/segmentHelper.d.ts +0 -13
- package/types/shaders/billboard.d.ts +0 -3
- package/types/shaders/depth.d.ts +0 -2
- package/types/shaders/drawnode.d.ts +0 -7
- package/types/shaders/label.d.ts +0 -4
- package/types/shaders/pointCloud.d.ts +0 -2
- package/types/shaders/polyline.d.ts +0 -3
- package/types/shaders/ray.d.ts +0 -2
- package/types/shaders/screenFrame.d.ts +0 -2
- package/types/shaders/shape.d.ts +0 -4
- package/types/shaders/skybox.d.ts +0 -2
- package/types/shaders/toneMapping.d.ts +0 -2
- package/types/shapes/BaseShape.d.ts +0 -247
- package/types/shapes/Sphere.d.ts +0 -41
- package/types/terrain/BilTerrain.d.ts +0 -8
- package/types/terrain/EmptyTerrain.d.ts +0 -72
- package/types/terrain/Geoid.d.ts +0 -26
- package/types/terrain/GlobusTerrain.d.ts +0 -153
- package/types/terrain/MapboxTerrain.d.ts +0 -8
- package/types/terrain/index.d.ts +0 -5
- package/types/utils/FontAtlas.d.ts +0 -14
- package/types/utils/GeoImageCreator.d.ts +0 -30
- package/types/utils/ImagesCacheManager.d.ts +0 -10
- package/types/utils/Loader.d.ts +0 -25
- package/types/utils/NormalMapCreator.d.ts +0 -39
- package/types/utils/PlainSegmentWorker.d.ts +0 -10
- package/types/utils/TerrainWorker.d.ts +0 -9
- package/types/utils/TextureAtlas.d.ts +0 -111
- package/types/utils/VectorTileCreator.d.ts +0 -16
- package/types/utils/colorTable.d.ts +0 -143
- package/types/utils/earcut.d.ts +0 -6
- package/types/utils/shared.d.ts +0 -230
- package/types/webgl/Framebuffer.d.ts +0 -135
- package/types/webgl/Handler.d.ts +0 -372
- package/types/webgl/Multisample.d.ts +0 -89
- package/types/webgl/Program.d.ts +0 -155
- package/types/webgl/ProgramController.d.ts +0 -84
- package/types/webgl/callbacks.d.ts +0 -1
- package/types/webgl/index.d.ts +0 -6
- package/types/webgl/types.d.ts +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
import { BaseNode } from
|
|
4
|
-
import { Events } from
|
|
3
|
+
import { BaseNode } from "./BaseNode.js";
|
|
4
|
+
import { Events } from "../Events.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Render node is a logical part of a render mechanism. Represents scene rendering.
|
|
@@ -10,7 +10,7 @@ import { Events } from '../Events.js';
|
|
|
10
10
|
* There are collections of ligh sources, entities and so on in the node.
|
|
11
11
|
* Access to the node is renderer.renderNodes["Earth"]
|
|
12
12
|
* @class
|
|
13
|
-
* @extends {
|
|
13
|
+
* @extends {RenderNode}
|
|
14
14
|
* @param {string} name - Node name.
|
|
15
15
|
*/
|
|
16
16
|
class RenderNode extends BaseNode {
|
|
@@ -20,7 +20,7 @@ class RenderNode extends BaseNode {
|
|
|
20
20
|
/**
|
|
21
21
|
* Renderer that calls frame() callback.
|
|
22
22
|
* @public
|
|
23
|
-
* @type {
|
|
23
|
+
* @type {Renderer}
|
|
24
24
|
*/
|
|
25
25
|
this.renderer = null;
|
|
26
26
|
|
|
@@ -43,7 +43,7 @@ class RenderNode extends BaseNode {
|
|
|
43
43
|
/**
|
|
44
44
|
* Point light array.
|
|
45
45
|
* @private
|
|
46
|
-
* @type {Array.<
|
|
46
|
+
* @type {Array.<LightSource>}
|
|
47
47
|
*/
|
|
48
48
|
this._lights = [];
|
|
49
49
|
this._lightsTransformedPositions = [];
|
|
@@ -54,7 +54,7 @@ class RenderNode extends BaseNode {
|
|
|
54
54
|
/**
|
|
55
55
|
* Entity collection array.
|
|
56
56
|
* @public
|
|
57
|
-
* @type {Array.<
|
|
57
|
+
* @type {Array.<EntityCollection>}
|
|
58
58
|
*/
|
|
59
59
|
this.entityCollections = [];
|
|
60
60
|
|
|
@@ -66,7 +66,7 @@ class RenderNode extends BaseNode {
|
|
|
66
66
|
/**
|
|
67
67
|
* Adds node to the current hierarchy.
|
|
68
68
|
* @public
|
|
69
|
-
* @type {
|
|
69
|
+
* @type {RenderNode}
|
|
70
70
|
*/
|
|
71
71
|
addNode(node) {
|
|
72
72
|
super.addNode(node);
|
|
@@ -76,7 +76,7 @@ class RenderNode extends BaseNode {
|
|
|
76
76
|
/**
|
|
77
77
|
* Assign render node with renderer.
|
|
78
78
|
* @public
|
|
79
|
-
* @param {
|
|
79
|
+
* @param {Renderer} renderer - Redner node's renderer.
|
|
80
80
|
*/
|
|
81
81
|
assign(renderer) {
|
|
82
82
|
this.renderer = renderer;
|
|
@@ -98,8 +98,7 @@ class RenderNode extends BaseNode {
|
|
|
98
98
|
n = this.name;
|
|
99
99
|
|
|
100
100
|
if (r) {
|
|
101
|
-
if (r.renderNodes[n] &&
|
|
102
|
-
r.renderNodes[n].isEqual(this)) {
|
|
101
|
+
if (r.renderNodes[n] && r.renderNodes[n].isEqual(this)) {
|
|
103
102
|
r.renderNodes[n] = null;
|
|
104
103
|
delete r.renderNodes[n];
|
|
105
104
|
}
|
|
@@ -119,9 +118,9 @@ class RenderNode extends BaseNode {
|
|
|
119
118
|
/**
|
|
120
119
|
* Adds entity collection.
|
|
121
120
|
* @public
|
|
122
|
-
* @param {
|
|
121
|
+
* @param {EntityCollection} entityCollection - Entity collection.
|
|
123
122
|
* @param {boolean} [isHidden] - If it's true that this collection has specific rendering.
|
|
124
|
-
* @returns {
|
|
123
|
+
* @returns {RenderNode} -
|
|
125
124
|
*/
|
|
126
125
|
addEntityCollection(entityCollection, isHidden) {
|
|
127
126
|
entityCollection.addTo(this, isHidden);
|
|
@@ -131,7 +130,7 @@ class RenderNode extends BaseNode {
|
|
|
131
130
|
/**
|
|
132
131
|
* Removes entity collection.
|
|
133
132
|
* @public
|
|
134
|
-
* @param {
|
|
133
|
+
* @param {EntityCollection} entityCollection - Entity collection for remove.
|
|
135
134
|
*/
|
|
136
135
|
removeEntityCollection(entityCollection) {
|
|
137
136
|
entityCollection.remove();
|
|
@@ -140,8 +139,8 @@ class RenderNode extends BaseNode {
|
|
|
140
139
|
/**
|
|
141
140
|
* Adds point light source.
|
|
142
141
|
* @public
|
|
143
|
-
* @param {
|
|
144
|
-
* @returns {
|
|
142
|
+
* @param {LightSource} light - Light source.
|
|
143
|
+
* @returns {RenderNode}
|
|
145
144
|
*/
|
|
146
145
|
addLight(light) {
|
|
147
146
|
light.addTo(this);
|
|
@@ -152,7 +151,7 @@ class RenderNode extends BaseNode {
|
|
|
152
151
|
* Gets light object by its name.
|
|
153
152
|
* @public
|
|
154
153
|
* @param {string} name - Point light name.
|
|
155
|
-
* @returns {
|
|
154
|
+
* @returns {LightSource}
|
|
156
155
|
*/
|
|
157
156
|
getLightByName(name) {
|
|
158
157
|
var li = this._lightsNames.indexOf(name);
|
|
@@ -162,7 +161,7 @@ class RenderNode extends BaseNode {
|
|
|
162
161
|
/**
|
|
163
162
|
* Removes light source.
|
|
164
163
|
* @public
|
|
165
|
-
* @param {
|
|
164
|
+
* @param {LightSource} light - Light source object.
|
|
166
165
|
*/
|
|
167
166
|
removeLight(light) {
|
|
168
167
|
light.remove();
|
|
@@ -195,7 +194,10 @@ class RenderNode extends BaseNode {
|
|
|
195
194
|
|
|
196
195
|
if (this.renderer) {
|
|
197
196
|
if (this._isActive && this._pickingId === -1) {
|
|
198
|
-
this._pickingId = this.renderer.addPickingCallback(
|
|
197
|
+
this._pickingId = this.renderer.addPickingCallback(
|
|
198
|
+
this,
|
|
199
|
+
this._entityCollectionPickingCallback
|
|
200
|
+
);
|
|
199
201
|
} else if (!this._isActive && this._pickingId !== -1) {
|
|
200
202
|
this.renderer.removePickingCallback(this._pickingId);
|
|
201
203
|
this._pickingId = -1;
|
|
@@ -277,7 +279,6 @@ class RenderNode extends BaseNode {
|
|
|
277
279
|
*/
|
|
278
280
|
drawPickingEntityCollections(ec) {
|
|
279
281
|
if (ec.length) {
|
|
280
|
-
|
|
281
282
|
var gl = this.renderer.handler.gl;
|
|
282
283
|
|
|
283
284
|
gl.disable(gl.CULL_FACE);
|
|
@@ -292,6 +293,12 @@ class RenderNode extends BaseNode {
|
|
|
292
293
|
ec[i]._fadingOpacity && ec[i].billboardHandler.drawPicking();
|
|
293
294
|
}
|
|
294
295
|
|
|
296
|
+
// geoObject pass
|
|
297
|
+
i = ec.length;
|
|
298
|
+
while (i--) {
|
|
299
|
+
ec[i]._fadingOpacity && ec[i].geoObjectHandler.drawPicking();
|
|
300
|
+
}
|
|
301
|
+
|
|
295
302
|
// label pass
|
|
296
303
|
i = ec.length;
|
|
297
304
|
while (i--) {
|
|
@@ -344,4 +351,4 @@ class RenderNode extends BaseNode {
|
|
|
344
351
|
}
|
|
345
352
|
}
|
|
346
353
|
|
|
347
|
-
export { RenderNode };
|
|
354
|
+
export { RenderNode };
|
|
@@ -11,6 +11,7 @@ import { Sphere } from "../bv/Sphere.js";
|
|
|
11
11
|
import { Box } from "../bv/Box.js";
|
|
12
12
|
import { Vec3 } from "../math/Vec3.js";
|
|
13
13
|
import * as segmentHelper from "../segment/segmentHelper.js";
|
|
14
|
+
import { getMatrixSubArray } from "../utils/shared.js";
|
|
14
15
|
|
|
15
16
|
export const MAX_NORMAL_ZOOM = 7;
|
|
16
17
|
|
|
@@ -58,15 +59,15 @@ window.BBSC = 100;
|
|
|
58
59
|
/**
|
|
59
60
|
* Planet segment Web Mercator tile class that stored and rendered with quad tree.
|
|
60
61
|
* @class
|
|
61
|
-
* @param {
|
|
62
|
-
* @param {
|
|
62
|
+
* @param {quadTree.Node} node - Segment node.
|
|
63
|
+
* @param {Planet} planet - Current planet scene.
|
|
63
64
|
* @param {Number} tileZoom - Zoom index.
|
|
64
|
-
* @param {
|
|
65
|
+
* @param {Extent} extent - Segment extent.
|
|
65
66
|
*/
|
|
66
67
|
class Segment {
|
|
67
68
|
/**
|
|
68
69
|
* @param {quadTree.Node} node - Segment node.
|
|
69
|
-
* @param {
|
|
70
|
+
* @param {Planet} planet - Current planet scene.
|
|
70
71
|
* @param {number} tileZoom - Zoom index.
|
|
71
72
|
* @param {Extent} extent - Segment extent.
|
|
72
73
|
*/
|
|
@@ -79,25 +80,25 @@ class Segment {
|
|
|
79
80
|
|
|
80
81
|
/**
|
|
81
82
|
* Quad tree node of the segment.
|
|
82
|
-
* @type {
|
|
83
|
+
* @type {quadTree.Node}
|
|
83
84
|
*/
|
|
84
85
|
this.node = node;
|
|
85
86
|
|
|
86
87
|
/**
|
|
87
88
|
* Planet pointer.
|
|
88
|
-
* @type {
|
|
89
|
+
* @type {Planet}
|
|
89
90
|
*/
|
|
90
91
|
this.planet = planet;
|
|
91
92
|
|
|
92
93
|
/**
|
|
93
94
|
* WebGl handler pointer.
|
|
94
|
-
* @type {
|
|
95
|
+
* @type {Handler}
|
|
95
96
|
*/
|
|
96
97
|
this.handler = planet.renderer.handler;
|
|
97
98
|
|
|
98
99
|
/**
|
|
99
100
|
* Segment bounding sphere
|
|
100
|
-
* @type {
|
|
101
|
+
* @type {Sphere}
|
|
101
102
|
*/
|
|
102
103
|
this.bsphere = new Sphere();
|
|
103
104
|
|
|
@@ -105,7 +106,7 @@ class Segment {
|
|
|
105
106
|
|
|
106
107
|
/**
|
|
107
108
|
* Segment bounding box.
|
|
108
|
-
* @type {
|
|
109
|
+
* @type {Box}
|
|
109
110
|
*/
|
|
110
111
|
this.bbox = new Box();
|
|
111
112
|
|
|
@@ -116,7 +117,7 @@ class Segment {
|
|
|
116
117
|
|
|
117
118
|
/**
|
|
118
119
|
* Geographical extent.
|
|
119
|
-
* @type {
|
|
120
|
+
* @type {Extent}
|
|
120
121
|
*/
|
|
121
122
|
this._extent = extent;
|
|
122
123
|
|
|
@@ -162,7 +163,7 @@ class Segment {
|
|
|
162
163
|
|
|
163
164
|
/**
|
|
164
165
|
* Texture materials array.
|
|
165
|
-
* @type {Array.<
|
|
166
|
+
* @type {Array.<planetSegment.Material>}
|
|
166
167
|
*/
|
|
167
168
|
this.materials = [];
|
|
168
169
|
|
|
@@ -252,7 +253,7 @@ class Segment {
|
|
|
252
253
|
/**
|
|
253
254
|
* Returns that segment good for rendering with camera by current lod ratio.
|
|
254
255
|
* @public
|
|
255
|
-
* @param {
|
|
256
|
+
* @param {Camera} camera - Camera object.
|
|
256
257
|
* @returns {boolean} -
|
|
257
258
|
*/
|
|
258
259
|
acceptForRendering(camera) {
|
|
@@ -265,10 +266,10 @@ class Segment {
|
|
|
265
266
|
/**
|
|
266
267
|
* Returns entity terrain point.
|
|
267
268
|
* @public
|
|
268
|
-
* @param {
|
|
269
|
-
* @param {
|
|
270
|
-
* @param {
|
|
271
|
-
* @returns {
|
|
269
|
+
* @param {Entity} entity - Entity.
|
|
270
|
+
* @param {Vec3} res - Point coordinates.
|
|
271
|
+
* @param {Vec3} [normal] - Terrain point normal.
|
|
272
|
+
* @returns {Vec3} -
|
|
272
273
|
*/
|
|
273
274
|
getEntityTerrainPoint(entity, res, normal) {
|
|
274
275
|
return this.getTerrainPoint(entity._cartesian, entity._lonlatMerc, res, normal);
|
|
@@ -281,10 +282,10 @@ class Segment {
|
|
|
281
282
|
/**
|
|
282
283
|
* Returns distance from object to terrain coordinates and terrain point that calculates out in the res parameter.
|
|
283
284
|
* @public
|
|
284
|
-
* @param {
|
|
285
|
+
* @param {Vec3} xyz - Cartesian object position.
|
|
285
286
|
* @param {LonLat} insideSegmentPosition - Geodetic object position.
|
|
286
|
-
* @param {
|
|
287
|
-
* @param {
|
|
287
|
+
* @param {Vec3} [res] - Result cartesian coordiantes on the terrain.
|
|
288
|
+
* @param {Vec3} [normal] - Terrain point normal.
|
|
288
289
|
* @returns {number} -
|
|
289
290
|
*/
|
|
290
291
|
getTerrainPoint(xyz, insideSegmentPosition, res, normal) {
|
|
@@ -375,6 +376,10 @@ class Segment {
|
|
|
375
376
|
return lonlat.forwardMercator();
|
|
376
377
|
}
|
|
377
378
|
|
|
379
|
+
/**
|
|
380
|
+
*
|
|
381
|
+
* @param {boolean} forceLoading
|
|
382
|
+
*/
|
|
378
383
|
loadTerrain(forceLoading) {
|
|
379
384
|
if (this.tileZoom < this.planet.terrain.minZoom) {
|
|
380
385
|
this.terrainIsLoading = true;
|
|
@@ -1434,8 +1439,8 @@ class Segment {
|
|
|
1434
1439
|
/**
|
|
1435
1440
|
* Gets specific layer material.
|
|
1436
1441
|
* @public
|
|
1437
|
-
* @param {
|
|
1438
|
-
* @returns {
|
|
1442
|
+
* @param {Layer} layer - Layer object.
|
|
1443
|
+
* @returns {planetSegment.Material} - Segment material.
|
|
1439
1444
|
*/
|
|
1440
1445
|
getMaterialByLayer(layer) {
|
|
1441
1446
|
return this.materials[layer._id];
|
|
@@ -19,16 +19,16 @@ let _tempHigh = new Vec3(),
|
|
|
19
19
|
/**
|
|
20
20
|
* Planet segment Web Mercator tile class that stored and rendered with quad tree.
|
|
21
21
|
* @class
|
|
22
|
-
* @extends {
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {
|
|
22
|
+
* @extends {Segment}
|
|
23
|
+
* @param {quadNode.Node} node - Quad tree segment node.
|
|
24
|
+
* @param {Planet} planet - Scene planet.
|
|
25
25
|
* @param {Number} tileZoom - Segment tile zoom index.
|
|
26
|
-
* @param {
|
|
26
|
+
* @param {Extent} extent - Segment WGS84 extent.
|
|
27
27
|
*/
|
|
28
28
|
class SegmentLonLat extends Segment {
|
|
29
29
|
/**
|
|
30
30
|
* @param {quadTree.Node} node - Segment node.
|
|
31
|
-
* @param {
|
|
31
|
+
* @param {Planet} planet - Current planet scene.
|
|
32
32
|
* @param {number} tileZoom - Zoom index.
|
|
33
33
|
* @param {Extent} extent - Segment extent.
|
|
34
34
|
*/
|
|
@@ -5,9 +5,17 @@
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
7
|
import { Program } from "../webgl/Program.js";
|
|
8
|
+
|
|
9
|
+
// REMEMBER!
|
|
10
|
+
// src*(1)+dest*(1-src.alpha)
|
|
11
|
+
// glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
|
12
|
+
// src*(src.alpha)+dest*(1-src.alpha)
|
|
13
|
+
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
8
14
|
|
|
9
15
|
const CORNERS = `const vec2 BOTTOMLEFT = vec2(-0.01);
|
|
10
|
-
const vec2 TOPRIGHT = vec2(1.01);`;
|
|
16
|
+
const vec2 TOPRIGHT = vec2(1.01);`;
|
|
17
|
+
|
|
18
|
+
const NIGHT = `const vec3 nightStep = 10.0 * vec3(0.58, 0.48, 0.25);`;
|
|
11
19
|
|
|
12
20
|
export function drawnode_screen_nl() {
|
|
13
21
|
return new Program("drawnode_screen_nl", {
|
|
@@ -66,42 +74,48 @@ export function drawnode_screen_nl() {
|
|
|
66
74
|
uniform sampler2D defaultTexture;
|
|
67
75
|
uniform sampler2D samplerArr[5];
|
|
68
76
|
uniform int samplerCount;
|
|
69
|
-
varying vec2 vTextureCoord;
|
|
77
|
+
varying vec2 vTextureCoord;
|
|
78
|
+
|
|
70
79
|
/* return 1 if v inside the box, return 0 otherwise */
|
|
71
80
|
float insideBox(vec2 v, vec2 bottomLeft, vec2 topRight) {
|
|
72
81
|
vec2 s = step(bottomLeft, v) - step(topRight, v);
|
|
73
82
|
return s.x * s.y;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
${CORNERS}
|
|
86
|
+
|
|
87
|
+
void blend(
|
|
88
|
+
out vec4 prevColor,
|
|
89
|
+
in sampler2D sampler,
|
|
90
|
+
in vec4 tileOffset,
|
|
91
|
+
in vec4 visibleExtentOffset,
|
|
92
|
+
in vec4 transparentColor)
|
|
93
|
+
{
|
|
94
|
+
vec4 t = texture2D( sampler, tileOffset.xy + vTextureCoord.xy * tileOffset.zw );
|
|
95
|
+
|
|
96
|
+
float emptiness = smoothstep(0.35, 0.5, distance( t.rgb, transparentColor.rgb )) *
|
|
97
|
+
insideBox(visibleExtentOffset.xy + vTextureCoord.xy * visibleExtentOffset.zw, BOTTOMLEFT, TOPRIGHT);
|
|
98
|
+
|
|
99
|
+
prevColor = prevColor * (1.0 - t.a * transparentColor.a * emptiness) + vec4(t.rgb, t.a) * transparentColor.a * emptiness;
|
|
74
100
|
}
|
|
75
101
|
|
|
76
|
-
${CORNERS}
|
|
77
|
-
|
|
78
102
|
void main(void) {
|
|
79
103
|
gl_FragColor = texture2D( defaultTexture, vTextureCoord );
|
|
80
|
-
if( samplerCount == 0 ) return;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if( samplerCount == 3 ) return;
|
|
96
|
-
|
|
97
|
-
t = texture2D( samplerArr[3], tileOffsetArr[3].xy + vTextureCoord * tileOffsetArr[3].zw ) * insideBox(visibleExtentOffsetArr[3].xy + vTextureCoord * visibleExtentOffsetArr[3].zw, BOTTOMLEFT, TOPRIGHT);
|
|
98
|
-
emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[3].rgb ));
|
|
99
|
-
gl_FragColor = mix( gl_FragColor, vec4(t.rgb, 1.0), transparentColorArr[3].a * t.a * emptiness);
|
|
100
|
-
if( samplerCount == 4 ) return;
|
|
101
|
-
|
|
102
|
-
t = texture2D( samplerArr[4], tileOffsetArr[4].xy + vTextureCoord * tileOffsetArr[4].zw ) * insideBox(visibleExtentOffsetArr[4].xy + vTextureCoord * visibleExtentOffsetArr[4].zw, BOTTOMLEFT, TOPRIGHT);
|
|
103
|
-
emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[4].rgb ));
|
|
104
|
-
gl_FragColor = mix( gl_FragColor, vec4(t.rgb, 1.0), transparentColorArr[4].a * t.a * emptiness);
|
|
104
|
+
if( samplerCount == 0 ) return;
|
|
105
|
+
|
|
106
|
+
blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], visibleExtentOffsetArr[0], transparentColorArr[0]);
|
|
107
|
+
if( samplerCount == 1 ) return;
|
|
108
|
+
|
|
109
|
+
blend(gl_FragColor, samplerArr[1], tileOffsetArr[1], visibleExtentOffsetArr[1], transparentColorArr[1]);
|
|
110
|
+
if( samplerCount == 2 ) return;
|
|
111
|
+
|
|
112
|
+
blend(gl_FragColor, samplerArr[2], tileOffsetArr[2], visibleExtentOffsetArr[2], transparentColorArr[2]);
|
|
113
|
+
if( samplerCount == 3 ) return;
|
|
114
|
+
|
|
115
|
+
blend(gl_FragColor, samplerArr[3], tileOffsetArr[3], visibleExtentOffsetArr[3], transparentColorArr[3]);
|
|
116
|
+
if( samplerCount == 4 ) return;
|
|
117
|
+
|
|
118
|
+
blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], visibleExtentOffsetArr[4], transparentColorArr[4]);
|
|
105
119
|
}`
|
|
106
120
|
});
|
|
107
121
|
}
|
|
@@ -209,9 +223,24 @@ export function drawnode_screen_wl() {
|
|
|
209
223
|
return s.x * s.y;
|
|
210
224
|
}
|
|
211
225
|
|
|
212
|
-
${CORNERS}
|
|
213
|
-
|
|
214
|
-
|
|
226
|
+
${CORNERS}
|
|
227
|
+
|
|
228
|
+
${NIGHT}
|
|
229
|
+
|
|
230
|
+
void blend(
|
|
231
|
+
out vec4 prevColor,
|
|
232
|
+
in sampler2D sampler,
|
|
233
|
+
in vec4 tileOffset,
|
|
234
|
+
in vec4 visibleExtentOffset,
|
|
235
|
+
in vec4 transparentColor)
|
|
236
|
+
{
|
|
237
|
+
vec4 t = texture2D( sampler, tileOffset.xy + vTextureCoord.xy * tileOffset.zw );
|
|
238
|
+
|
|
239
|
+
float emptiness = smoothstep(0.35, 0.5, distance( t.rgb, transparentColor.rgb )) *
|
|
240
|
+
insideBox(visibleExtentOffset.xy + vTextureCoord.xy * visibleExtentOffset.zw, BOTTOMLEFT, TOPRIGHT);
|
|
241
|
+
|
|
242
|
+
prevColor = prevColor * (1.0 - t.a * transparentColor.a * emptiness) + vec4(t.rgb, t.a) * transparentColor.a * emptiness;
|
|
243
|
+
}
|
|
215
244
|
|
|
216
245
|
void main(void) {
|
|
217
246
|
|
|
@@ -236,54 +265,24 @@ export function drawnode_screen_wl() {
|
|
|
236
265
|
gl_FragColor = vec4(t.rgb * lightWeighting + night + spec, t.a);
|
|
237
266
|
if( samplerCount == 0 ) return;
|
|
238
267
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
if( samplerCount == 2 ) return;
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
spec = specularMaterial[3].rgb * pow( reflection, specularMaterial[3].w);
|
|
262
|
-
lightWeighting = ambientMaterial[3] + diffuseMaterial[3] * diffuseLightWeighting + spec;
|
|
263
|
-
|
|
264
|
-
t = texture2D( samplerArr[2], tileOffsetArr[2].xy + vTextureCoord.xy * tileOffsetArr[2].zw ) * insideBox(visibleExtentOffsetArr[2].xy + vTextureCoord.xy * visibleExtentOffsetArr[2].zw, BOTTOMLEFT, TOPRIGHT);
|
|
265
|
-
emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[2].rgb ));
|
|
266
|
-
gl_FragColor = mix( gl_FragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[2].a * t.a * emptiness);
|
|
267
|
-
if( samplerCount == 3 ) return;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
spec = specularMaterial[4].rgb * pow( reflection, specularMaterial[4].w);
|
|
272
|
-
lightWeighting = ambientMaterial[4] + diffuseMaterial[4] * diffuseLightWeighting + spec;
|
|
273
|
-
|
|
274
|
-
t = texture2D( samplerArr[3], tileOffsetArr[3].xy + vTextureCoord.xy * tileOffsetArr[3].zw ) * insideBox(visibleExtentOffsetArr[3].xy + vTextureCoord.xy * visibleExtentOffsetArr[3].zw, BOTTOMLEFT, TOPRIGHT);
|
|
275
|
-
emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[3].rgb ));
|
|
276
|
-
gl_FragColor = mix( gl_FragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[3].a * t.a * emptiness);
|
|
277
|
-
if( samplerCount == 4 ) return;
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
spec = specularMaterial[5].rgb * pow( reflection, specularMaterial[5].w);
|
|
282
|
-
lightWeighting = ambientMaterial[5] + diffuseMaterial[5] * diffuseLightWeighting + spec;
|
|
283
|
-
|
|
284
|
-
t = texture2D( samplerArr[4], tileOffsetArr[4].xy + vTextureCoord.xy * tileOffsetArr[4].zw ) * insideBox(visibleExtentOffsetArr[4].xy + vTextureCoord.xy * visibleExtentOffsetArr[4].zw, BOTTOMLEFT, TOPRIGHT);
|
|
285
|
-
emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[4].rgb ));
|
|
286
|
-
gl_FragColor = mix( gl_FragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[4].a * t.a * emptiness);
|
|
268
|
+
blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], visibleExtentOffsetArr[0], transparentColorArr[0],
|
|
269
|
+
specularMaterial[1], ambientMaterial[1], diffuseMaterial[1]);
|
|
270
|
+
if( samplerCount == 1 ) return;
|
|
271
|
+
|
|
272
|
+
blend(gl_FragColor, samplerArr[1], tileOffsetArr[1], visibleExtentOffsetArr[1], transparentColorArr[1],
|
|
273
|
+
specularMaterial[2], ambientMaterial[2], diffuseMaterial[2]);
|
|
274
|
+
if( samplerCount == 2 ) return;
|
|
275
|
+
|
|
276
|
+
blend(gl_FragColor, samplerArr[2], tileOffsetArr[2], visibleExtentOffsetArr[2], transparentColorArr[2],
|
|
277
|
+
specularMaterial[3], ambientMaterial[3], diffuseMaterial[3]);
|
|
278
|
+
if( samplerCount == 3 ) return;
|
|
279
|
+
|
|
280
|
+
blend(gl_FragColor, samplerArr[3], tileOffsetArr[3], visibleExtentOffsetArr[3], transparentColorArr[3],
|
|
281
|
+
specularMaterial[4], ambientMaterial[4], diffuseMaterial[4]);
|
|
282
|
+
if( samplerCount == 4 ) return;
|
|
283
|
+
|
|
284
|
+
blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], visibleExtentOffsetArr[4], transparentColorArr[4],
|
|
285
|
+
specularMaterial[5], ambientMaterial[5], diffuseMaterial[5]);
|
|
287
286
|
}`
|
|
288
287
|
});
|
|
289
288
|
}
|
|
@@ -321,7 +320,7 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
321
320
|
aTextureCoord: "vec2"
|
|
322
321
|
},
|
|
323
322
|
|
|
324
|
-
vertexShader: `#version 300 es
|
|
323
|
+
vertexShader: `#version 300 es
|
|
325
324
|
|
|
326
325
|
in vec3 aVertexPositionHigh;
|
|
327
326
|
in vec3 aVertexPositionLow;
|
|
@@ -387,7 +386,12 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
387
386
|
in vec4 vTextureCoord;
|
|
388
387
|
in vec2 vGlobalTextureCoord;
|
|
389
388
|
in vec4 v_vertex;
|
|
390
|
-
in float v_height;
|
|
389
|
+
in float v_height;
|
|
390
|
+
|
|
391
|
+
float shininess;
|
|
392
|
+
float reflection;
|
|
393
|
+
float diffuseLightWeighting;
|
|
394
|
+
vec3 night;
|
|
391
395
|
|
|
392
396
|
layout(location = 0) out vec4 fragColor;
|
|
393
397
|
|
|
@@ -399,7 +403,28 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
399
403
|
|
|
400
404
|
${CORNERS}
|
|
401
405
|
|
|
402
|
-
|
|
406
|
+
${NIGHT}
|
|
407
|
+
|
|
408
|
+
void blend(
|
|
409
|
+
out vec4 dest,
|
|
410
|
+
in sampler2D sampler,
|
|
411
|
+
in vec4 tileOffset,
|
|
412
|
+
in vec4 visibleExtentOffset,
|
|
413
|
+
in vec4 transparentColor,
|
|
414
|
+
in vec4 specular,
|
|
415
|
+
in vec3 ambient,
|
|
416
|
+
in vec3 diffuse)
|
|
417
|
+
{
|
|
418
|
+
vec3 spec = specular.rgb * pow(reflection, specular.w) * (1.0 + shininess);
|
|
419
|
+
vec3 lightWeighting = ambient + diffuse * diffuseLightWeighting + spec;
|
|
420
|
+
|
|
421
|
+
vec4 src = texture( sampler, tileOffset.xy + vTextureCoord.xy * tileOffset.zw );
|
|
422
|
+
|
|
423
|
+
float emptiness = smoothstep(0.35, 0.5, distance( src.rgb, transparentColor.rgb )) *
|
|
424
|
+
insideBox(visibleExtentOffset.xy + vTextureCoord.xy * visibleExtentOffset.zw, BOTTOMLEFT, TOPRIGHT);
|
|
425
|
+
|
|
426
|
+
dest = dest * (1.0 - src.a * transparentColor.a * emptiness) + vec4(src.rgb * lightWeighting + night + spec * src.a, src.a) * transparentColor.a * emptiness;
|
|
427
|
+
}
|
|
403
428
|
|
|
404
429
|
void main(void) {
|
|
405
430
|
|
|
@@ -408,70 +433,38 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
408
433
|
vec3 lightDirection = normalize(lightsPositions[0].xyz - v_vertex.xyz * lightsPositions[0].w);
|
|
409
434
|
vec3 eyeDirection = normalize(-v_vertex.xyz);
|
|
410
435
|
vec3 reflectionDirection = reflect(-lightDirection, normal);
|
|
411
|
-
vec4 nightImageColor = texture( nightTexture, vGlobalTextureCoord.st );
|
|
412
|
-
float shininess = texture( specularTexture, vGlobalTextureCoord.st ).r * 255.0 * overGround;
|
|
413
|
-
float reflection = max( dot(reflectionDirection, eyeDirection), 0.0);
|
|
414
|
-
float diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
|
|
415
|
-
vec3 night = nightStep * (0.3 - diffuseLightWeighting) * nightImageColor.rgb;
|
|
416
|
-
night *= overGround * step(0.0, night);
|
|
417
|
-
|
|
418
|
-
|
|
436
|
+
vec4 nightImageColor = texture( nightTexture, vGlobalTextureCoord.st );
|
|
419
437
|
|
|
438
|
+
shininess = texture( specularTexture, vGlobalTextureCoord.st ).r * 255.0 * overGround;
|
|
439
|
+
reflection = max( dot(reflectionDirection, eyeDirection), 0.0);
|
|
440
|
+
diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
|
|
441
|
+
night = nightStep * (.18 - diffuseLightWeighting * 3.0) * nightImageColor.rgb;
|
|
442
|
+
night *= overGround * step(0.0, night);
|
|
443
|
+
|
|
420
444
|
vec3 spec = specularMaterial[0].rgb * pow( reflection, specularMaterial[0].w) * shininess;
|
|
421
445
|
vec3 lightWeighting = ambientMaterial[0] + diffuseMaterial[0] * diffuseLightWeighting + spec;
|
|
422
|
-
|
|
423
446
|
vec4 t = texture( defaultTexture, vTextureCoord.xy );
|
|
424
447
|
fragColor = vec4(t.rgb * lightWeighting + night + spec, t.a);
|
|
425
|
-
if( samplerCount == 0 ) return;
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
if( samplerCount == 2 ) return;
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
spec = specularMaterial[3].rgb * pow( reflection, specularMaterial[3].w);
|
|
450
|
-
lightWeighting = ambientMaterial[3] + diffuseMaterial[3] * diffuseLightWeighting + spec;
|
|
451
|
-
|
|
452
|
-
t = texture( samplerArr[2], tileOffsetArr[2].xy + vTextureCoord.xy * tileOffsetArr[2].zw ) * insideBox(visibleExtentOffsetArr[2].xy + vTextureCoord.xy * visibleExtentOffsetArr[2].zw, BOTTOMLEFT, TOPRIGHT);
|
|
453
|
-
emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[2].rgb ));
|
|
454
|
-
fragColor = mix( fragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[2].a * t.a * emptiness);
|
|
455
|
-
if( samplerCount == 3 ) return;
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
spec = specularMaterial[4].rgb * pow( reflection, specularMaterial[4].w);
|
|
460
|
-
lightWeighting = ambientMaterial[4] + diffuseMaterial[4] * diffuseLightWeighting + spec;
|
|
461
|
-
|
|
462
|
-
t = texture( samplerArr[3], tileOffsetArr[3].xy + vTextureCoord.xy * tileOffsetArr[3].zw ) * insideBox(visibleExtentOffsetArr[3].xy + vTextureCoord.xy * visibleExtentOffsetArr[3].zw, BOTTOMLEFT, TOPRIGHT);
|
|
463
|
-
emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[3].rgb ));
|
|
464
|
-
fragColor = mix( fragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[3].a * t.a * emptiness);
|
|
465
|
-
if( samplerCount == 4 ) return;
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
spec = specularMaterial[5].rgb * pow( reflection, specularMaterial[5].w);
|
|
470
|
-
lightWeighting = ambientMaterial[5] + diffuseMaterial[5] * diffuseLightWeighting + spec;
|
|
471
|
-
|
|
472
|
-
t = texture( samplerArr[4], tileOffsetArr[4].xy + vTextureCoord.xy * tileOffsetArr[4].zw ) * insideBox(visibleExtentOffsetArr[4].xy + vTextureCoord.xy * visibleExtentOffsetArr[4].zw, BOTTOMLEFT, TOPRIGHT);
|
|
473
|
-
emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[4].rgb ));
|
|
474
|
-
fragColor = mix( fragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[4].a * t.a * emptiness);
|
|
448
|
+
if( samplerCount == 0 ) return;
|
|
449
|
+
|
|
450
|
+
blend(fragColor, samplerArr[0], tileOffsetArr[0], visibleExtentOffsetArr[0], transparentColorArr[0],
|
|
451
|
+
specularMaterial[1], ambientMaterial[1], diffuseMaterial[1]);
|
|
452
|
+
if( samplerCount == 1 ) return;
|
|
453
|
+
|
|
454
|
+
blend(fragColor, samplerArr[1], tileOffsetArr[1], visibleExtentOffsetArr[1], transparentColorArr[1],
|
|
455
|
+
specularMaterial[2], ambientMaterial[2], diffuseMaterial[2]);
|
|
456
|
+
if( samplerCount == 2 ) return;
|
|
457
|
+
|
|
458
|
+
blend(fragColor, samplerArr[2], tileOffsetArr[2], visibleExtentOffsetArr[2], transparentColorArr[2],
|
|
459
|
+
specularMaterial[3], ambientMaterial[3], diffuseMaterial[3]);
|
|
460
|
+
if( samplerCount == 3 ) return;
|
|
461
|
+
|
|
462
|
+
blend(fragColor, samplerArr[3], tileOffsetArr[3], visibleExtentOffsetArr[3], transparentColorArr[3],
|
|
463
|
+
specularMaterial[4], ambientMaterial[4], diffuseMaterial[4]);
|
|
464
|
+
if( samplerCount == 4 ) return;
|
|
465
|
+
|
|
466
|
+
blend(fragColor, samplerArr[4], tileOffsetArr[4], visibleExtentOffsetArr[4], transparentColorArr[4],
|
|
467
|
+
specularMaterial[5], ambientMaterial[5], diffuseMaterial[5]);
|
|
475
468
|
}`
|
|
476
469
|
});
|
|
477
470
|
}
|