mirror of
https://github.com/openglobus/openglobus.git
synced 2025-12-08 19:25:27 +00:00
refactoring
This commit is contained in:
parent
6ecf4ec030
commit
067920cee3
BIN
sandbox/osm/night.png
Normal file
BIN
sandbox/osm/night.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 234 KiB |
14
sandbox/osm/osm.html
Normal file
14
sandbox/osm/osm.html
Normal file
@ -0,0 +1,14 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>OpenStreetMap Base Layer</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script type="module" src="./osm.js"></script>
|
||||
<link rel="stylesheet" href="http://www.openglobus.org/og.css" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="earth" style="width:100%;height:100%"/>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
20
sandbox/osm/osm.js
Normal file
20
sandbox/osm/osm.js
Normal file
@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
import { Globe } from '../../src/og/Globe.js';
|
||||
import { XYZ } from '../../src/og/layer/XYZ.js';
|
||||
|
||||
let osm = new XYZ("OSM", {
|
||||
'specular': [0.0003, 0.00012, 0.00001],
|
||||
'shininess': 20,
|
||||
'diffuse': [0.89, 0.9, 0.83],
|
||||
'isBaseLayer': true,
|
||||
'url': "http://b.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||
'visibility': true,
|
||||
'attribution': 'Data @ OpenStreetMap contributors, ODbL'
|
||||
});
|
||||
|
||||
let globe = new Globe({
|
||||
'name': "Earth",
|
||||
'target': "earth",
|
||||
'layers': [osm]
|
||||
});
|
||||
BIN
sandbox/osm/spec.png
Normal file
BIN
sandbox/osm/spec.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 826 KiB |
@ -4,7 +4,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { EmptyTerrainProvider } from './terrainProvider/EmptyTerrainProvider';
|
||||
import { EmptyTerrainProvider } from './terrainProvider/EmptyTerrainProvider.js';
|
||||
import { Handler } from './webgl/Handler.js';
|
||||
import { Planet } from './scene/Planet.js';
|
||||
import { Renderer } from './renderer/Renderer.js';
|
||||
@ -13,7 +13,7 @@ import { wgs84 } from './ellipsoid/wgs84.js';
|
||||
import { EarthCoordinates } from './control/EarthCoordinates.js';
|
||||
import { MouseNavigation } from './control/MouseNavigation.js';
|
||||
import { TouchNavigation } from './control/TouchNavigation.js';
|
||||
import { Sun } from './control/sun.js';
|
||||
import { Sun } from './control/Sun.js';
|
||||
import { ZoomControl } from './control/ZoomControl.js';
|
||||
|
||||
/** @const {string} */
|
||||
@ -26,7 +26,7 @@ const PLANET_NAME_PREFIX = "globus_planet_";
|
||||
* @class
|
||||
*
|
||||
* @example <caption>Basic initialization</caption>
|
||||
* globus = new og.Globus({
|
||||
* globus = new og.Globe({
|
||||
* 'atmosphere': false,
|
||||
* 'target': 'globus',
|
||||
* 'name': 'Earth',
|
||||
@ -56,13 +56,13 @@ const PLANET_NAME_PREFIX = "globus_planet_";
|
||||
* @param {Array.<og.control.BaseControl>} [options.controls] - Renderer controls array.
|
||||
* @param {Array.<og.layer.Layer>} [options.layers] - Planet layers.
|
||||
* @param {og.Extent} [options.viewExtent] - Viewable starting extent.
|
||||
* @param {boolean} [options.autoActivate] - Globus rendering auto activation flag. True is default.
|
||||
* @param {boolean} [options.autoActivate] - Globe rendering auto activation flag. True is default.
|
||||
*/
|
||||
class Globus {
|
||||
class Globe {
|
||||
constructor(options) {
|
||||
|
||||
//Canvas creation.
|
||||
var _canvasId = CANVAS_ID_PREFIX + Globus._staticCounter++;
|
||||
var _canvasId = CANVAS_ID_PREFIX + Globe._staticCounter++;
|
||||
|
||||
this._canvas = document.createElement("canvas");
|
||||
this._canvas.id = _canvasId;
|
||||
@ -110,7 +110,7 @@ class Globus {
|
||||
* @private
|
||||
* @type {String}
|
||||
*/
|
||||
this._planetName = options.name ? options.name : PLANET_NAME_PREFIX + Globus._staticCounter;
|
||||
this._planetName = options.name ? options.name : PLANET_NAME_PREFIX + Globe._staticCounter;
|
||||
|
||||
if (options.atmosphere) {
|
||||
/**
|
||||
@ -181,7 +181,7 @@ class Globus {
|
||||
this._stopHandler = null;
|
||||
|
||||
//Run!
|
||||
if (isUndefined(options.autoActivate) || options.autoActivate) {
|
||||
if (Globe.isUndefined(options.autoActivate) || options.autoActivate) {
|
||||
this.fadeIn(500);
|
||||
this.renderer.start();
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ export function getSunPosition(jd) {
|
||||
|
||||
var theta = math.TWO_PI * (d * 24.0 / 23.9344694 - 259.853 / 360.0); // Siderial spin time
|
||||
|
||||
return math.Quaternion.yRotation(-theta).mulVec3(new Vec3(-yequat * astro.AU_TO_METERS,
|
||||
return Quat.yRotation(-theta).mulVec3(new Vec3(-yequat * astro.AU_TO_METERS,
|
||||
zequat * astro.AU_TO_METERS, -xequat * astro.AU_TO_METERS));
|
||||
|
||||
//Convert to RA and Decl
|
||||
|
||||
@ -43,8 +43,7 @@ class Camera {
|
||||
* @public
|
||||
* @type {og.Events}
|
||||
*/
|
||||
this.events = new Events();
|
||||
this.events.registerNames(EVENT_NAMES);
|
||||
this.events = new Events(EVENT_NAMES);
|
||||
|
||||
/**
|
||||
* Camera position.
|
||||
@ -162,7 +161,9 @@ class Camera {
|
||||
this._tanViewAngle_hrad = 0;
|
||||
this._tanViewAngle_hradOneByHeight = 0;
|
||||
|
||||
renderer && this.initialize(renderer, options);
|
||||
this.renderer = renderer;
|
||||
|
||||
renderer && this._initialize(options);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,19 +220,18 @@ class Camera {
|
||||
* @param {og.math.Vector3} [options.look] - Camera look position. Default (0,0,0)
|
||||
* @param {og.math.Vector3} [options.up] - Camera eye position. Default (0,1,0)
|
||||
*/
|
||||
initialize(renderer, options) {
|
||||
_initialize(options) {
|
||||
|
||||
this.renderer = renderer;
|
||||
this.setProjectionMatrix(
|
||||
options.viewAngle || defaultOptions.viewAngle,
|
||||
this._aspect || this.renderer.handler.getClientAspect(),
|
||||
options.near || defaultOptions.near,
|
||||
options.far || defaultOptions.far);
|
||||
|
||||
var d = defaultOptions;
|
||||
|
||||
this.setProjectionMatrix(options.viewAngle || d.viewAngle, this._aspect || renderer.handler.getClientAspect(),
|
||||
options.near || d.near, options.far || d.far);
|
||||
|
||||
this.set(options.eye || d.eye.clone(), options.look || d.look.clone(),
|
||||
options.up || d.up.clone());
|
||||
|
||||
this.update();
|
||||
this.set(
|
||||
options.eye || defaultOptions.eye.clone(),
|
||||
options.look || defaultOptions.look.clone(),
|
||||
options.up || defaultOptions.up.clone());
|
||||
}
|
||||
|
||||
getUp() {
|
||||
|
||||
@ -10,7 +10,7 @@ import { Camera } from './Camera.js';
|
||||
import { Vec3 } from '../math/Vec3.js';
|
||||
import { Key } from '../Lock.js';
|
||||
import { LonLat } from '../LonLat.js';
|
||||
import { Mat4 } from '../math/Mat3.js';
|
||||
import { Mat4 } from '../math/Mat4.js';
|
||||
import { Ray } from '../math/Ray.js';
|
||||
|
||||
/**
|
||||
|
||||
@ -129,7 +129,7 @@ class EarthCoordinates extends BaseControl {
|
||||
|
||||
_refresh(this._display);
|
||||
|
||||
centerDiv = document.createElement('div');
|
||||
let centerDiv = document.createElement('div');
|
||||
centerDiv.className = 'ogCenterIcon';
|
||||
centerDiv.innerHTML = '<svg width="12" height="12"><g><path stroke-width="1" stroke-opacity="1" d="M6 0L6 12M0 6L12 6" stroke="#009DFF"></path></g></svg>';
|
||||
this.renderer.div.appendChild(centerDiv);
|
||||
|
||||
@ -166,7 +166,7 @@ class MouseNavigation extends BaseControl {
|
||||
this.planet, this.stepsCount, this.distDiff, ms, event.wheelDelta > 0, ms.direction);
|
||||
}
|
||||
|
||||
oninit = function () {
|
||||
oninit() {
|
||||
this.activate();
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
import { BaseControl } from './BaseControl.js';
|
||||
import { print2d } from '../utils/utils.js';
|
||||
import { print2d } from '../utils/Shared.js';
|
||||
|
||||
/**
|
||||
* Frame per second(FPS) display control.
|
||||
@ -13,7 +13,7 @@ import { print2d } from '../utils/utils.js';
|
||||
* @extends {og.control.BaseControl}
|
||||
* @param {Object} [options] - Control options.
|
||||
*/
|
||||
class ShowFps {
|
||||
class ShowFps extends BaseControl {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { BaseControl } from './BaseControl';
|
||||
import { BaseControl } from './BaseControl.js';
|
||||
import { getSunPosition } from '../astro/earth.js';
|
||||
import { input } from '../input/input.js';
|
||||
import { LightSource } from '../light/LightSource.js';
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
'use strict';
|
||||
|
||||
import { BaseControl } from './BaseControl.js';
|
||||
import { Key } from '../Lock.js';
|
||||
import { MouseNavigation } from './MouseNavigation.js';
|
||||
import { Key } from './Lock.js';
|
||||
|
||||
|
||||
/**
|
||||
@ -118,3 +118,5 @@ class ZoomControl extends BaseControl {
|
||||
export function zoomControl(options) {
|
||||
return new ZoomControl(options);
|
||||
};
|
||||
|
||||
export { ZoomControl };
|
||||
|
||||
@ -595,7 +595,7 @@ class BillboardHandler {
|
||||
this._changedBuffers[TEXCOORD_BUFFER] = true;
|
||||
}
|
||||
|
||||
setVisibility = function (index, visibility) {
|
||||
setVisibility(index, visibility) {
|
||||
var vArr;
|
||||
if (visibility) {
|
||||
vArr = [-0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5];
|
||||
@ -661,7 +661,7 @@ class BillboardHandler {
|
||||
this._changedBuffers[ALIGNEDAXIS_BUFFER] = true;
|
||||
}
|
||||
|
||||
createPositionBuffer = function () {
|
||||
createPositionBuffer() {
|
||||
var h = this._renderer.handler;
|
||||
h.gl.deleteBuffer(this._positionBuffer);
|
||||
this._positionBuffer = h.createArrayBuffer(new Float32Array(this._positionArr), 4, this._positionArr.length / 4, h.gl.DYNAMIC_DRAW);
|
||||
|
||||
@ -7,14 +7,14 @@
|
||||
import * as mercator from '../mercator.js';
|
||||
import * as utils from '../utils/shared.js';
|
||||
import { Billboard } from './Billboard.js';
|
||||
import { Box } from '../shapes/Box.js';
|
||||
//import { Box } from '../shapes/Box.js';
|
||||
import { Extent } from '../Extent.js';
|
||||
import { Geometry } from './Geometry.js';
|
||||
import { Label } from './Label.js';
|
||||
import { LonLat } from '../LonLat.js';
|
||||
import { Polyline } from './Polyline.js';
|
||||
import { PointCloud } from './PointCloud.js';
|
||||
import { Sphere } from '../shapes/Sphere.js';
|
||||
//import { Sphere } from '../shapes/Sphere.js';
|
||||
import { Vec3 } from '../math/Vec3.js';
|
||||
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ class Geometry {
|
||||
this._counter = n;
|
||||
}
|
||||
|
||||
static getType = function (typeStr) {
|
||||
static getType(typeStr) {
|
||||
return GeometryType[typeStr.toUpperCase()];
|
||||
}
|
||||
|
||||
|
||||
@ -312,7 +312,7 @@ class Label extends BaseBillboard {
|
||||
* @public
|
||||
* @returns {og.math.Vector4}
|
||||
*/
|
||||
getOutlineColor = function () {
|
||||
getOutlineColor() {
|
||||
return this._outlineColor;
|
||||
}
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@ class LabelHandler extends BillboardHandler {
|
||||
this._changedBuffers[TEXCOORD_BUFFER] = true;
|
||||
}
|
||||
|
||||
setPositionArr = function (index, position) {
|
||||
setPositionArr(index, position) {
|
||||
var i = index * 24 * this._maxLetters;
|
||||
var a = this._positionArr, x = position.x, y = position.y, z = position.z;
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as shaders from '../shaderProgram/pointCloud.js';
|
||||
import * as shaders from '../shaders/pointCloud.js';
|
||||
|
||||
class PointCloudHandler {
|
||||
constructor(entityCollection) {
|
||||
|
||||
@ -761,7 +761,7 @@ class Polyline {
|
||||
* @param {number} b - Blue color.
|
||||
* @param {number} [a] - Opacity.
|
||||
*/
|
||||
setColor = function (r, g, b, a) {
|
||||
setColor(r, g, b, a) {
|
||||
this.color.x = r;
|
||||
this.color.y = g;
|
||||
this.color.z = b;
|
||||
@ -773,7 +773,7 @@ class Polyline {
|
||||
* @public
|
||||
* @param {og.math.Vector3} color - RGB color.
|
||||
*/
|
||||
setColor3v = function (color) {
|
||||
setColor3v(color) {
|
||||
this.color.x = color.x;
|
||||
this.color.y = color.y;
|
||||
this.color.z = color.z;
|
||||
@ -784,7 +784,7 @@ class Polyline {
|
||||
* @public
|
||||
* @param {og.math.Vector4} color - RGBA color.
|
||||
*/
|
||||
setColor4v = function (color) {
|
||||
setColor4v(color) {
|
||||
this.color.x = color.x;
|
||||
this.color.y = color.y;
|
||||
this.color.z = color.z;
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as shaders from '../shaderProgram/polyline.js';
|
||||
import * as shaders from '../shaders/polyline.js';
|
||||
|
||||
class PolylineHandler {
|
||||
constructor(entityCollection) {
|
||||
|
||||
@ -1,77 +1,90 @@
|
||||
goog.provide('og.ShapeHandler');
|
||||
/**
|
||||
* @module og/entity/ShapeHandler
|
||||
*/
|
||||
|
||||
goog.require('og.shape.BaseShape');
|
||||
goog.require('og.shape.Sphere');
|
||||
goog.require('og.shaderProgram.shape_wl');
|
||||
goog.require('og.shaderProgram.shape_nl');
|
||||
//goog.require('og.shaderProgram.shapePicking');
|
||||
'use strict';
|
||||
|
||||
og.ShapeHandler = function (entityCollection) {
|
||||
import * as shaders from '../shaders/shape.js';
|
||||
|
||||
/**
|
||||
* Picking rendering option.
|
||||
* @public
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.pickingEnabled = true;
|
||||
class ShapeHandler {
|
||||
constructor(entityCollection) {
|
||||
|
||||
this._entityCollection = entityCollection;
|
||||
/**
|
||||
* Picking rendering option.
|
||||
* @public
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.pickingEnabled = true;
|
||||
|
||||
this._renderer = null;
|
||||
this._entityCollection = entityCollection;
|
||||
|
||||
this._shapes = [];
|
||||
this._renderer = null;
|
||||
|
||||
this.__staticId = og.ShapeHandler.staticCounter++;
|
||||
};
|
||||
this._shapes = [];
|
||||
|
||||
og.ShapeHandler.staticCounter = 0;
|
||||
this.__staticId = ShapeHandler._staticCounter++;
|
||||
}
|
||||
|
||||
og.ShapeHandler.prototype._initShaderProgram = function () {
|
||||
if (this._renderer.handler) {
|
||||
if (!this._renderer.handler.shaderPrograms.shape_nl) {
|
||||
this._renderer.handler.addShaderProgram(og.shaderProgram.shape_nl());
|
||||
static get _staticCounter() {
|
||||
if (!this._counter && this._counter !== 0) {
|
||||
this._counter = 0;
|
||||
}
|
||||
if (!this._renderer.handler.shaderPrograms.shape_wl) {
|
||||
this._renderer.handler.addShaderProgram(og.shaderProgram.shape_wl());
|
||||
return this._counter;
|
||||
}
|
||||
|
||||
static set _staticCounter(n) {
|
||||
this._counter = n;
|
||||
}
|
||||
|
||||
_initShaderProgram() {
|
||||
if (this._renderer.handler) {
|
||||
if (!this._renderer.handler.shaderPrograms.shape_nl) {
|
||||
this._renderer.handler.addShaderProgram(shaders.shape_nl());
|
||||
}
|
||||
if (!this._renderer.handler.shaderPrograms.shape_wl) {
|
||||
this._renderer.handler.addShaderProgram(shaders.shape_wl());
|
||||
}
|
||||
//if (!this._renderer.handler.shaderPrograms.shapePicking) {
|
||||
// this._renderer.handler.addShaderProgram(shaders.shapePicking());
|
||||
//}
|
||||
}
|
||||
//if (!this._renderer.handler.shaderPrograms.shapePicking) {
|
||||
// this._renderer.handler.addShaderProgram(og.shaderProgram.shapePicking());
|
||||
//}
|
||||
}
|
||||
|
||||
setRenderNode(renderNode) {
|
||||
this._renderer = renderNode.renderer;
|
||||
this._initShaderProgram()
|
||||
for (var i = 0; i < this._shapes.length; i++) {
|
||||
this._shapes[i].setRenderNode(renderNode);
|
||||
}
|
||||
}
|
||||
|
||||
add(shape) {
|
||||
if (shape._handlerIndex == -1) {
|
||||
shape._handler = this;
|
||||
shape._handlerIndex = this._shapes.length;
|
||||
this._shapes.push(shape);
|
||||
this._entityCollection && this._entityCollection.renderNode && shape.setRenderNode(this._entityCollection.renderNode);
|
||||
}
|
||||
}
|
||||
|
||||
remove(shape) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
draw() {
|
||||
var i = this._shapes.length;
|
||||
while (i--) {
|
||||
this._shapes[i].draw();
|
||||
}
|
||||
}
|
||||
|
||||
drawPicking() {
|
||||
//TODO
|
||||
}
|
||||
|
||||
clear() {
|
||||
//TODO
|
||||
}
|
||||
};
|
||||
|
||||
og.ShapeHandler.prototype.setRenderNode = function (renderNode) {
|
||||
this._renderer = renderNode.renderer;
|
||||
this._initShaderProgram()
|
||||
for (var i = 0; i < this._shapes.length; i++) {
|
||||
this._shapes[i].setRenderNode(renderNode);
|
||||
}
|
||||
};
|
||||
|
||||
og.ShapeHandler.prototype.add = function (shape) {
|
||||
if (shape._handlerIndex == -1) {
|
||||
shape._handler = this;
|
||||
shape._handlerIndex = this._shapes.length;
|
||||
this._shapes.push(shape);
|
||||
this._entityCollection && this._entityCollection.renderNode && shape.setRenderNode(this._entityCollection.renderNode);
|
||||
}
|
||||
};
|
||||
|
||||
og.ShapeHandler.prototype.remove = function (shape) {
|
||||
|
||||
};
|
||||
|
||||
og.ShapeHandler.prototype.draw = function () {
|
||||
var i = this._shapes.length;
|
||||
while (i--) {
|
||||
this._shapes[i].draw();
|
||||
}
|
||||
};
|
||||
|
||||
og.ShapeHandler.prototype.drawPicking = function () {
|
||||
|
||||
};
|
||||
|
||||
og.ShapeHandler.prototype.clear = function () {
|
||||
|
||||
};
|
||||
export { ShapeHandler };
|
||||
@ -1,47 +0,0 @@
|
||||
/**
|
||||
* @module og/inheritance
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Inherit the prototype methods from one constructor into another.
|
||||
*
|
||||
* Usage:
|
||||
* <pre>
|
||||
* function ParentClass(a, b) { }
|
||||
* ParentClass.prototype.foo = function(a) { };
|
||||
*
|
||||
* function ChildClass(a, b, c) {
|
||||
* og.inheritance.base(this, a, b);
|
||||
* }
|
||||
* og.inheritance.extend(ChildClass, ParentClass);
|
||||
*
|
||||
* var child = new ChildClass('a', 'b', 'see');
|
||||
* child.foo(); // This works.
|
||||
* </pre>
|
||||
*
|
||||
* @param {!Function} Child - Child class.
|
||||
* @param {!Function} Parent - Parent class.
|
||||
*/
|
||||
export function extend(Child, Parent) {
|
||||
var F = function () { };
|
||||
F.prototype = Parent.prototype;
|
||||
Child.prototype = new F();
|
||||
Child.prototype.constructor = Child;
|
||||
Child.superclass = Parent.prototype;
|
||||
Child.superclass.constructor = Parent;
|
||||
};
|
||||
|
||||
/**
|
||||
* Call up to the superclass.
|
||||
*
|
||||
* This function only works if you use og.inheritance.extend to express inheritance
|
||||
* relationships between your classes.
|
||||
*
|
||||
* See {@link og.inheritance.extend}
|
||||
*/
|
||||
export function base(me) {
|
||||
var caller = arguments.callee.caller;
|
||||
caller.superclass.constructor.apply(me, Array.prototype.slice.call(arguments, 1));
|
||||
};
|
||||
8
src/og/inherits.js
Normal file
8
src/og/inherits.js
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* @module og/inherits
|
||||
*/
|
||||
|
||||
export function inherits(childCtor, parentCtor) {
|
||||
childCtor.prototype = Object.create(parentCtor.prototype);
|
||||
childCtor.prototype.constructor = childCtor;
|
||||
};
|
||||
@ -4,10 +4,11 @@
|
||||
|
||||
'use sctrict';
|
||||
|
||||
import * as utils from '../utils/utils.js';
|
||||
import * as utils from '../utils/shared.js';
|
||||
import * as mercator from '../mercator.js';
|
||||
import { Events } from '../Events.js';
|
||||
import { Extent } from '../Extent.js';
|
||||
import { LonLat } from '../LonLat.js';
|
||||
import { Material } from './Material.js';
|
||||
import { Vec3 } from '../math/Vec3.js';
|
||||
|
||||
|
||||
@ -152,11 +152,11 @@ class Vector extends Layer {
|
||||
|
||||
/** Creates collections tree*/
|
||||
this.setEntities(this._entities);
|
||||
};
|
||||
}
|
||||
|
||||
_bindPicking = function () {
|
||||
_bindPicking() {
|
||||
this._pickingColor.clear();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds layer to the planet.
|
||||
@ -185,7 +185,7 @@ class Vector extends Layer {
|
||||
* @public
|
||||
* @returns {Array.<og.Entity>}
|
||||
*/
|
||||
getEntities = function () {
|
||||
getEntities() {
|
||||
return [].concat(this._entities);
|
||||
}
|
||||
|
||||
@ -466,7 +466,7 @@ class Vector extends Layer {
|
||||
return this;
|
||||
}
|
||||
|
||||
_createEntityCollectionsTree = function (entitiesForTree) {
|
||||
_createEntityCollectionsTree(entitiesForTree) {
|
||||
if (this._planet) {
|
||||
this._entityCollectionsTree = new EntityCollectionNode(this, quadTree.NW, null, 0,
|
||||
Extent.createFromArray([-20037508.34, -20037508.34, 20037508.34, 20037508.34]), this._planet, 0);
|
||||
@ -479,7 +479,7 @@ class Vector extends Layer {
|
||||
this._entityCollectionsTreeNorth.buildTree(entitiesForTree);
|
||||
this._entityCollectionsTreeSouth.buildTree(entitiesForTree);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_bindEventsDefault(entityCollection) {
|
||||
var ve = this.events;
|
||||
|
||||
@ -7,8 +7,9 @@
|
||||
import * as mercator from '../mercator.js';
|
||||
import * as quadTree from '../quadTree/quadTree.js';
|
||||
import { EPSG3857 } from '../proj/EPSG3857.js';
|
||||
import { Extent } from '../Extent.js';
|
||||
import { Layer } from './Layer.js';
|
||||
import { stringTemplate } from '../utils/utils.js';
|
||||
import { stringTemplate } from '../utils/shared.js';
|
||||
import { LonLat } from '../LonLat.js';
|
||||
import { QueueArray } from '../QueueArray.js';
|
||||
|
||||
@ -47,7 +48,7 @@ class XYZ extends Layer {
|
||||
this.events.registerNames(EVENT_NAMES);
|
||||
|
||||
if (!options.extent) {
|
||||
this.setExtent(new og.Extent(new og.LonLat(-180.0, og.mercator.MIN_LAT), new LonLat(180.0, og.mercator.MAX_LAT)));
|
||||
this.setExtent(new Extent(new LonLat(-180.0, mercator.MIN_LAT), new LonLat(180.0, mercator.MAX_LAT)));
|
||||
}
|
||||
|
||||
this.transparentColor = options.transparentColor || [-1, -1, -1];
|
||||
|
||||
@ -50,7 +50,7 @@ class LightSource {
|
||||
* @protected
|
||||
* @type {og.math.Vector3}
|
||||
*/
|
||||
this._position = params.position || Vec3();
|
||||
this._position = params.position || new Vec3();
|
||||
|
||||
/**
|
||||
* True if the light is directional.
|
||||
|
||||
@ -395,7 +395,7 @@ Vec3.prototype.mulA = function (vec) {
|
||||
* @returns {og.math.Vec3}
|
||||
*/
|
||||
Vec3.prototype.mul = function (vec) {
|
||||
return new og.math.Vec3(this.x * vec.x, this.y * vec.y, this.z * vec.z);
|
||||
return new Vec3(this.x * vec.x, this.y * vec.y, this.z * vec.z);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
import * as math from '../math.js';
|
||||
import { Vec4 } from './Vec4';
|
||||
import { Vec4 } from './Vec4.js';
|
||||
|
||||
/**
|
||||
* Encode 32 bit float value to the RGBA vector.
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as math from '../math.js');
|
||||
import { Vec3 } from './Vec3.js');
|
||||
import * as math from '../math.js';
|
||||
import { Vec3 } from './Vec3.js';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -8,7 +8,8 @@ import * as quadTree from '../quadTree/quadTree.js';
|
||||
|
||||
let CURRENT_POWER = 0;
|
||||
|
||||
let textureCoordsTable = [];
|
||||
export let textureCoordsTable = [];
|
||||
|
||||
let centerIndexesTable = [];
|
||||
let skirtsIndexesTable = [];
|
||||
|
||||
|
||||
@ -4,17 +4,22 @@
|
||||
|
||||
'use sctrict';
|
||||
|
||||
import * as inheritance from '../inheritance.js';
|
||||
import * as math from '../math.js';
|
||||
import * as mercator from '../mercator.js';
|
||||
import * as quadTree from '../quadTree/quadTree.js';
|
||||
import { EPSG4326 } from '../proj/EPSG4326.js';
|
||||
import { Extent } from '../Extent.js';
|
||||
import { inherits } from '../inherits.js';
|
||||
import { Layer } from '../layer/Layer.js';
|
||||
import { LonLat } from '../LonLat.js';
|
||||
import { Segment } from './Segment.js';
|
||||
|
||||
|
||||
const _heightLat = 90.0 - mercator.MAX_LAT;
|
||||
const _maxPoleZoom = 7;
|
||||
const _pieceSize = _heightLat / Math.pow(2, _maxPoleZoom);
|
||||
|
||||
|
||||
/**
|
||||
* Planet segment Web Mercator tile class that stored and rendered with quad tree.
|
||||
* @class
|
||||
@ -26,16 +31,12 @@ import { Segment } from './Segment.js';
|
||||
*/
|
||||
const SegmentLonLat = function (node, planet, tileZoom, extent) {
|
||||
this._isNorth = false;
|
||||
og.inheritance.base(this, node, planet, tileZoom, extent);
|
||||
Segment.call(this, node, planet, tileZoom, extent);
|
||||
this._projection = EPSG4326;
|
||||
this._extentMerc = new Extent(extent.southWest.forwardMercatorEPS01(), extent.northEast.forwardMercatorEPS01());
|
||||
};
|
||||
|
||||
SegmentLonLat._heightLat = 90.0 - og.mercator.MAX_LAT;
|
||||
SegmentLonLat._maxPoleZoom = 7;
|
||||
SegmentLonLat._pieceSize = SegmentLonLat._heightLat / Math.pow(2, SegmentLonLat._maxPoleZoom);
|
||||
|
||||
inheritance.extend(SegmentLonLat, Segment);
|
||||
inherits(SegmentLonLat, Segment);
|
||||
|
||||
SegmentLonLat.prototype.projectNative = function (coords) {
|
||||
return coords;
|
||||
@ -51,11 +52,11 @@ SegmentLonLat.prototype.acceptForRendering = function (camera) {
|
||||
var lat = this._extent.northEast.lat;
|
||||
if (this._isNorth) {
|
||||
//north pole limits
|
||||
var Yz = Math.floor((90.0 - lat) / SegmentLonLat._pieceSize);
|
||||
var Yz = Math.floor((90.0 - lat) / _pieceSize);
|
||||
maxPoleZoom = Math.floor(Yz / 16) + 7;
|
||||
} else {
|
||||
//south pole limits
|
||||
var Yz = Math.floor((mercator.MIN_LAT - lat) / SegmentLonLat._pieceSize);
|
||||
var Yz = Math.floor((mercator.MIN_LAT - lat) / _pieceSize);
|
||||
maxPoleZoom = 12 - Math.floor(Yz / 16);
|
||||
}
|
||||
return Segment.prototype.acceptForRendering.call(this, camera) || this.tileZoom >= maxPoleZoom;
|
||||
|
||||
@ -1,130 +0,0 @@
|
||||
goog.provide('og.gmx.CheckVersion');
|
||||
|
||||
goog.require('og.ajax');
|
||||
|
||||
og.gmx.CheckVersion = function (planet) {
|
||||
|
||||
this._layerVersions = {};
|
||||
|
||||
this.hostUrl = "//maps.kosmosnimki.ru/";
|
||||
|
||||
this._layers = [];
|
||||
|
||||
this._r = null;
|
||||
|
||||
this._addLayer = function (layer) {
|
||||
this._layers.push(layer);
|
||||
};
|
||||
|
||||
this._removeLayer = function (layer) {
|
||||
var i = this._layers.length;
|
||||
while (i--) {
|
||||
if (layer.isEqual(this._layers[i])) {
|
||||
this._layers.splice(i, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
planet.events.on("layeradd", function (l) {
|
||||
if (l instanceof og.gmx.VectorLayer) {
|
||||
if (l._visibility) {
|
||||
this._addLayer(l);
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
|
||||
planet.events.on("layerremove", function (l) {
|
||||
if (l instanceof og.gmx.VectorLayer) {
|
||||
this._removeLayer(l);
|
||||
}
|
||||
}, this);
|
||||
|
||||
planet.events.on("layervisibilitychange", function (l) {
|
||||
if (l instanceof og.gmx.VectorLayer) {
|
||||
if (l._visibility) {
|
||||
this._addLayer(l);
|
||||
} else {
|
||||
this._removeLayer(l);
|
||||
}
|
||||
this._request();
|
||||
}
|
||||
}, this);
|
||||
|
||||
planet.camera.events.on("moveend", function () {
|
||||
this._request();
|
||||
}, this);
|
||||
|
||||
this._checkVersionSuccess = function (data, layersOrder) {
|
||||
var res = data.Result;
|
||||
for (var i = 0; i < layersOrder.length; i++) {
|
||||
layersOrder[i]._checkVersionSuccess(res[i]);
|
||||
}
|
||||
};
|
||||
|
||||
this.abort = function () {
|
||||
if (this._r) {
|
||||
this._r.abort();
|
||||
this._r = null;
|
||||
}
|
||||
};
|
||||
|
||||
this._request = function () {
|
||||
if (this._layers.length) {
|
||||
this._r && this._r.abort();
|
||||
var e = planet._viewExtentMerc;
|
||||
|
||||
if (e) {
|
||||
var zoom = planet.minCurrZoom,
|
||||
bbox = [e.southWest.lon, e.southWest.lat, e.northEast.lon, e.northEast.lat];
|
||||
|
||||
var layers = [],
|
||||
_layersOrder = [];
|
||||
for (var i = 0; i < this._layers.length; i++) {
|
||||
var li = this._layers[i];
|
||||
if (li._extentMerc.overlaps(e) && li._gmxProperties) {
|
||||
_layersOrder.push(li);
|
||||
var p = { "Name": li._layerId, "Version": li._gmxProperties.LayerVersion || -1 };
|
||||
if (li._gmxProperties.Temporal) {
|
||||
p.dateBegin = parseInt(li._beginDate.getTime() / 1000);
|
||||
p.dateEnd = parseInt(li._endDate.getTime() / 1000);
|
||||
}
|
||||
layers.push(p);
|
||||
}
|
||||
}
|
||||
|
||||
if (layers.length) {
|
||||
var that = this;
|
||||
this._r = og.ajax.request(this.hostUrl + "Layer/CheckVersion.ashx", {
|
||||
'type': "POST",
|
||||
'responseType': "json",
|
||||
'data': {
|
||||
'WrapStyle': "None",
|
||||
'bbox': bbox,
|
||||
'srs': "3857",
|
||||
'layers': layers,
|
||||
'zoom': zoom,
|
||||
'ftc': "osm"
|
||||
},
|
||||
'success': function (data) {
|
||||
that._r = null;
|
||||
that._checkVersionSuccess(data, _layersOrder);
|
||||
},
|
||||
'error': function (err) {
|
||||
that._r = null;
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.getLayers = function () {
|
||||
return this._layers;
|
||||
};
|
||||
|
||||
this.update = function () {
|
||||
this._request();
|
||||
};
|
||||
};
|
||||
@ -1,129 +0,0 @@
|
||||
goog.provide('og.gmx.Item');
|
||||
|
||||
goog.require('og.utils');
|
||||
|
||||
/**
|
||||
* Represents geomixer item. Stores item attributes.
|
||||
* @class
|
||||
* @param {Number} id - Geomixer item id like gmx_id.
|
||||
* @param {Object} options - Item additional options:
|
||||
* @param {Object} options.attributes - Item attributes.
|
||||
* @param {Object} options.style - Item rendering style.
|
||||
* @param {Number} options.version - Item version.
|
||||
*/
|
||||
og.gmx.Item = function (id, options) {
|
||||
options = options || {};
|
||||
|
||||
this.id = id;
|
||||
this.attributes = options.attributes || {};
|
||||
this.version = options.version || -1;
|
||||
|
||||
this._layer = null;
|
||||
this._style = options.style || {};
|
||||
|
||||
this._pickingColor = null;
|
||||
|
||||
this._pickingReady = false;
|
||||
|
||||
this._extent = null;
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.addTo = function (layer) {
|
||||
layer.addItem(this);
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.getExtent = function () {
|
||||
return this._extent.clone();
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.setStyle = function (style) {
|
||||
var s = this._style;
|
||||
for (var i in style) {
|
||||
s[i] = style[i];
|
||||
}
|
||||
this._layer && this._layer.updateItem(this);
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.bringToFront = function () {
|
||||
this._pickingReady = false;
|
||||
//
|
||||
//...
|
||||
//
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.setZIndex = function (zIndex) {
|
||||
this._pickingReady = false;
|
||||
this._style.zIndex = zIndex;
|
||||
this._layer && this._layer.updateItem(this);
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.setFillColor = function (r, g, b, a) {
|
||||
var c = this._style.fillColor;
|
||||
if (c.w === 0.0 && a !== 0.0 || c.w !== 0.0 && a === 0.0) {
|
||||
this._pickingReady = false;
|
||||
}
|
||||
c.x = r;
|
||||
c.y = g;
|
||||
c.z = b;
|
||||
(a !== null) && (c.w = a);
|
||||
this._layer && this._layer.updateItem(this);
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.setFillColor4v = function (color) {
|
||||
this.setFillColor(color.x, color.y, color.z, color.w);
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.setFillColorHTML = function (color) {
|
||||
var c = og.utils.htmlColorToRgba(color);
|
||||
this.setFillColor(c.x, c.y, c.z, c.w);
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.setLineColor = function (r, g, b, a) {
|
||||
var c = this._style.lineColor;
|
||||
if (c.w === 0.0 && a !== 0.0 || c.w !== 0.0 && a === 0.0) {
|
||||
this._pickingReady = false;
|
||||
}
|
||||
c.x = r;
|
||||
c.y = g;
|
||||
c.z = b;
|
||||
(a !== null) && (c.w = a);
|
||||
this._layer && this._layer.updateItem(this);
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.setLineColor4v = function (color) {
|
||||
this.setLineColor(color.x, color.y, color.z, color.w);
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.setLineColorHTML = function (color) {
|
||||
var c = og.utils.htmlColorToRgba(color);
|
||||
this.setLineColor(c.x, c.y, c.z, c.w);
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.setStrokeColor = function (r, g, b, a) {
|
||||
var c = this._style.strokeColor;
|
||||
if (c.w === 0.0 && a !== 0.0 || c.w !== 0.0 && a === 0.0) {
|
||||
this._pickingReady = false;
|
||||
}
|
||||
c.x = r;
|
||||
c.y = g;
|
||||
c.z = b;
|
||||
(a !== null) && (c.w = a);
|
||||
this._layer && this._layer.updateItem(this);
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.setStrokeColor4v = function (color) {
|
||||
this.setLineColor(color.x, color.y, color.z, color.w);
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.setStrokeColorHTML = function (color) {
|
||||
var c = og.utils.htmlColorToRgba(color);
|
||||
this.setStrokeColor(c.x, c.y, c.z, c.w);
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.setLineWidth = function (v) {
|
||||
this._style.lineWidth = v;
|
||||
};
|
||||
|
||||
og.gmx.Item.prototype.setStrokeWidth = function (v) {
|
||||
this._style.strokeWidth = v;
|
||||
};
|
||||
@ -1,29 +0,0 @@
|
||||
goog.provide('og.gmx.Material');
|
||||
|
||||
goog.require('og.inheritance');
|
||||
|
||||
og.gmx.Material = function (segment, layer) {
|
||||
og.inheritance.base(this, segment, layer);
|
||||
|
||||
this.fromTile = null;
|
||||
|
||||
this.sceneIsLoading = false;
|
||||
this.sceneExists = false;
|
||||
this.sceneReady = false;
|
||||
this.sceneTexture = null;
|
||||
};
|
||||
|
||||
og.inheritance.extend(og.gmx.Material, og.layer.Material);
|
||||
|
||||
|
||||
og.gmx.Material.applySceneBitmapImage = function (bitmapImage) {
|
||||
this.sceneTexture = this.segment.handler.createTexture(bitmapImage);
|
||||
this.sceneExists = true;
|
||||
this.sceneReady = true;
|
||||
this.sceneIsLoading = false;
|
||||
};
|
||||
|
||||
|
||||
og.gmx.Material.prototype.sceneNotExists = function () {
|
||||
this.sceneExists = false;
|
||||
};
|
||||
@ -1,42 +0,0 @@
|
||||
goog.provide('og.gmx.TileData');
|
||||
|
||||
goog.require('og.gmx.TileItem');
|
||||
goog.require('og.Extent');
|
||||
|
||||
/**
|
||||
* Represents geomixer vector tile data. Stores tile geometries and rendering data.
|
||||
* @class
|
||||
* @param {Object} data - Geomixer vector tile data:
|
||||
* @param {Array<Number,Number,Number,Number>} data.bbox - Bounding box.
|
||||
* @param {Boolean} data.isGeneralized - Whether tile geometries are simplified.
|
||||
* @param {Array<Array<Object>>} data.values - Tile items.
|
||||
* @param {Number} data.x - Tile index for X.
|
||||
* @param {Number} data.y - Tile index for Y.
|
||||
* @param {Number} data.z - Tile zoom level.
|
||||
* @param {Number} data.v - Tile version.
|
||||
*/
|
||||
og.gmx.TileData = function (data) {
|
||||
this.group = null;
|
||||
this.groupIndex = -1;
|
||||
this.isGeneralized = data.isGeneralized;
|
||||
this.bbox = data.bbox;
|
||||
this.x = data.x;
|
||||
this.y = data.y;
|
||||
this.z = data.z;
|
||||
this.version = data.v;
|
||||
this.level = data.level;
|
||||
this.span = data.span;
|
||||
this.tileItems = [];
|
||||
};
|
||||
|
||||
og.gmx.TileData.prototype.addTileItem = function (tileItem) {
|
||||
tileItem.tileData = this;
|
||||
tileItem.tileDataIndex = this.tileItems.length;
|
||||
this.tileItems.push(tileItem);
|
||||
};
|
||||
|
||||
og.gmx.TileData.prototype.addTileItems = function (tileItems) {
|
||||
for (var i = 0; i < tileItems.length; i++) {
|
||||
this.addTileItem(tileItems[i]);
|
||||
}
|
||||
};
|
||||
@ -1,39 +0,0 @@
|
||||
goog.provide('og.gmx.TileDataGroup');
|
||||
|
||||
/**
|
||||
* Represents geomixer vector tile data container or grouop. Stores tile datas and their items.
|
||||
*
|
||||
* @class
|
||||
* @param {og.gmx.VectorLayer} layer - Layer.
|
||||
* @param {og.Extent} extent - Tile geographical extent.
|
||||
*/
|
||||
og.gmx.TileDataGroup = function (layer, extent) {
|
||||
this.layer = layer;
|
||||
this.tileExtent = extent;
|
||||
this.tileDataArr = [];
|
||||
this.tileItemArr = [];
|
||||
};
|
||||
|
||||
og.gmx.TileDataGroup.prototype.addTileData = function (tileData) {
|
||||
tileData.group = this;
|
||||
tileData.groupIndex = this.tileDataArr.length;
|
||||
this.tileDataArr.push(tileData);
|
||||
};
|
||||
|
||||
og.gmx.TileDataGroup.prototype.removeTileData = function (tileData) {
|
||||
tileData.group = null;
|
||||
this.tileDataArr.splice(tileData.groupIndex, 1);
|
||||
tileData.groupIndex = -1;
|
||||
this.tileItemArr.length = 0;
|
||||
this.tileItemArr = [];
|
||||
for (var i = 0; i < this.tileDataArr.length; i++) {
|
||||
var ti = this.tileDataArr[i];
|
||||
for (var j = 0; j < ti.tileItems.length; j++) {
|
||||
this.addTileItem(ti.tileItems[j]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.TileDataGroup.prototype.addTileItem = function (tileItem) {
|
||||
this.tileItemArr.push(tileItem);
|
||||
};
|
||||
@ -1,177 +0,0 @@
|
||||
goog.provide('og.gmx.TileItem');
|
||||
|
||||
goog.require('og.mercator');
|
||||
goog.require('og.Extent');
|
||||
goog.require('og.math');
|
||||
|
||||
|
||||
og.gmx.TileItem = function (item, geometry) {
|
||||
|
||||
this.tileData = null;
|
||||
this.tileDataIndex = -1;
|
||||
|
||||
this.item = item;
|
||||
this.geometry = geometry;
|
||||
|
||||
//Polygon arrays
|
||||
this._polyVerticesMerc = [];
|
||||
this._polyIndexes = [];
|
||||
|
||||
//Line arrays
|
||||
this._lineVerticesMerc = [];
|
||||
this._lineOrders = [];
|
||||
this._lineIndexes = [];
|
||||
|
||||
//Point array
|
||||
//...
|
||||
|
||||
//Label array
|
||||
//...
|
||||
|
||||
//Buffers
|
||||
this._polyVerticesBufferMerc = null;
|
||||
this._polyIndexesBuffer = null;
|
||||
|
||||
this._lineVerticesBufferMerc = null;
|
||||
this._lineOrdersBuffer = null;
|
||||
this._lineIndexesBuffer = null;
|
||||
|
||||
this._ready = false;
|
||||
};
|
||||
|
||||
og.gmx.TileItem.prototype.createBuffers = function (handler, extent) {
|
||||
if (!this._ready) {
|
||||
this._createVertices(extent);
|
||||
this._createBuffers(handler);
|
||||
this._ready = true;
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.TileItem.chkOnEdge = function (p1, p2, ext) {
|
||||
if (p1[0] === p2[0] && (Math.abs(p1[0] - ext.northEast.lon) < 0.05 || Math.abs(p1[0] - ext.southWest.lon) < 0.05) ||
|
||||
p1[1] === p2[1] && (Math.abs(p1[1] - ext.northEast.lat) < 0.05 || Math.abs(p1[1] - ext.southWest.lat) < 0.05)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
og.gmx.TileItem.prototype._createVertices = function (extent) {
|
||||
|
||||
var geometry = this.geometry;
|
||||
|
||||
this._polyVerticesMerc = [];
|
||||
this._lineVerticesMerc = [];
|
||||
|
||||
if (!this.item._extent) {
|
||||
this.item._extent = new og.Extent(new og.LonLat(og.MAX_FLOAT, og.MAX_FLOAT), new og.LonLat(-og.MAX_FLOAT, -og.MAX_FLOAT));
|
||||
}
|
||||
|
||||
var ne = this.item._extent.northEast,
|
||||
sw = this.item._extent.southWest;
|
||||
|
||||
if (geometry.type.toLowerCase() === "polygon") {
|
||||
var coordinates = geometry.coordinates;
|
||||
|
||||
var data = og.utils.earcut.flatten(coordinates);
|
||||
var indexes = og.utils.earcut(data.vertices, data.holes, 2);
|
||||
|
||||
this._polyVerticesMerc = data.vertices;
|
||||
|
||||
this._polyIndexes = indexes;
|
||||
|
||||
for (var i = 0; i < coordinates.length; i++) {
|
||||
var ci = coordinates[i];
|
||||
var path = [];
|
||||
var startLine = false;
|
||||
var isClosed = true;
|
||||
for (var j = 0; j < ci.length; j++) {
|
||||
var p = ci[j];
|
||||
if (p[0] < sw.lon) sw.lon = p[0];
|
||||
if (p[0] > ne.lon) ne.lon = p[0];
|
||||
if (p[1] < sw.lat) sw.lat = p[1];
|
||||
if (p[1] > sw.lat) ne.lat = p[1];
|
||||
if (!og.gmx.TileItem.chkOnEdge(p, j < ci.length - 1 ? ci[j + 1] : ci[0], extent)) {
|
||||
startLine = true;
|
||||
path.push(p);
|
||||
} else if (startLine) {
|
||||
isClosed = false;
|
||||
startLine = false;
|
||||
path.push(p);
|
||||
og.gmx.VectorTileCreator.appendLineData([path], false, this._lineVerticesMerc, this._lineOrders, this._lineIndexes);
|
||||
path = [];
|
||||
}
|
||||
}
|
||||
if (path.length) {
|
||||
og.gmx.VectorTileCreator.appendLineData([path], isClosed, this._lineVerticesMerc, this._lineOrders, this._lineIndexes);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (geometry.type.toLowerCase() === "multipolygon") {
|
||||
|
||||
var coordinates = geometry.coordinates;
|
||||
var vertices = [],
|
||||
indexes = [];
|
||||
|
||||
for (var i = 0; i < coordinates.length; i++) {
|
||||
var cci = coordinates[i];
|
||||
var data = og.utils.earcut.flatten(cci);
|
||||
var dataIndexes = og.utils.earcut(data.vertices, data.holes, 2);
|
||||
|
||||
for (var j = 0; j < dataIndexes.length; j++) {
|
||||
indexes.push(dataIndexes[j] + vertices.length * 0.5);
|
||||
}
|
||||
|
||||
vertices.push.apply(vertices, data.vertices);
|
||||
|
||||
for (var ii = 0; ii < cci.length; ii++) {
|
||||
var ci = cci[ii];
|
||||
var path = [];
|
||||
var startLine = false;
|
||||
var isClosed = true;
|
||||
for (var j = 0; j < ci.length; j++) {
|
||||
var p = ci[j];
|
||||
if (p[0] < sw.lon) sw.lon = p[0];
|
||||
if (p[0] > ne.lon) ne.lon = p[0];
|
||||
if (p[1] < sw.lat) sw.lat = p[1];
|
||||
if (p[1] > sw.lat) ne.lat = p[1];
|
||||
if (!og.gmx.TileItem.chkOnEdge(p, j < ci.length - 1 ? ci[j + 1] : ci[0], extent)) {
|
||||
startLine = true;
|
||||
path.push(p);
|
||||
} else if (startLine) {
|
||||
isClosed = false;
|
||||
startLine = false;
|
||||
path.push(p);
|
||||
og.gmx.VectorTileCreator.appendLineData([path], false, this._lineVerticesMerc, this._lineOrders, this._lineIndexes);
|
||||
path = [];
|
||||
}
|
||||
}
|
||||
if (path.length) {
|
||||
og.gmx.VectorTileCreator.appendLineData([path], isClosed, this._lineVerticesMerc, this._lineOrders, this._lineIndexes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._polyVerticesMerc = vertices;
|
||||
this._polyIndexes = indexes;
|
||||
|
||||
} else if (geometry.type.toLowerCase() === "linestring") {
|
||||
//
|
||||
//TODO:extent
|
||||
//
|
||||
og.gmx.VectorTileCreator.appendLineData([geometry._coordinates], false, this._lineVerticesMerc, this._lineOrders, this._lineIndexes);
|
||||
} else if (geometry.type.toLowerCase() === "multilinestring") {
|
||||
//
|
||||
//TODO:extent
|
||||
//
|
||||
og.gmx.VectorTileCreator.appendLineData(geometry._coordinates, false, this._lineVerticesMerc, this._lineOrders, this._lineIndexes);
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.TileItem.prototype._createBuffers = function (h) {
|
||||
this._polyVerticesBufferMerc = h.createArrayBuffer(new Float32Array(this._polyVerticesMerc), 2, this._polyVerticesMerc.length / 2);
|
||||
this._polyIndexesBuffer = h.createElementArrayBuffer(new Uint32Array(this._polyIndexes), 1, this._polyIndexes.length);
|
||||
|
||||
this._lineVerticesBufferMerc = h.createArrayBuffer(new Float32Array(this._lineVerticesMerc), 2, this._lineVerticesMerc.length / 2);
|
||||
this._lineIndexesBuffer = h.createElementArrayBuffer(new Uint32Array(this._lineIndexes), 1, this._lineIndexes.length);
|
||||
this._lineOrdersBuffer = h.createArrayBuffer(new Float32Array(this._lineOrders), 1, this._lineOrders.length / 2);
|
||||
};
|
||||
@ -1,825 +0,0 @@
|
||||
goog.provide('og.gmx.VectorLayer');
|
||||
|
||||
goog.require('og.ajax');
|
||||
goog.require('og.utils');
|
||||
goog.require('og.inheritance');
|
||||
goog.require('og.layer.Layer');
|
||||
|
||||
goog.require('og.gmx.CheckVersion');
|
||||
goog.require('og.gmx.VectorTileCreator');
|
||||
goog.require('og.gmx.TileData');
|
||||
goog.require('og.gmx.TileDataGroup');
|
||||
goog.require('og.gmx.Item');
|
||||
goog.require('og.gmx.Material');
|
||||
goog.require('og.QueueArray');
|
||||
|
||||
/**
|
||||
* TODO: description
|
||||
* @class
|
||||
* @param {String} name - Layer user name.
|
||||
* @param {Object} options:
|
||||
* @extends {og.layer.Layer}
|
||||
*/
|
||||
og.gmx.VectorLayer = function (name, options) {
|
||||
options = options || {};
|
||||
|
||||
og.inheritance.base(this, name, options);
|
||||
|
||||
this.isVector = true;
|
||||
|
||||
this.hostUrl = options.hostUrl || "//maps.kosmosnimki.ru/";
|
||||
|
||||
this._pickingEnabled = options.pickingEnabled !== undefined ? options.pickingEnabled : true;
|
||||
|
||||
this._initialized = false;
|
||||
|
||||
this._layerId = options.layerId;
|
||||
|
||||
this._tileSenderUrlTemplate = '//maps.kosmosnimki.ru/TileSender.ashx?WrapStyle=None&ModeKey=tile&r=j&ftc=osm&srs=3857&LayerName={id}&z={z}&x={x}&y={y}&v={v}';
|
||||
|
||||
this._gmxProperties = null;
|
||||
|
||||
this._beginDate = options.beginDate || null;
|
||||
|
||||
this._endDate = options.endDate || null;
|
||||
|
||||
this._itemCache = {};
|
||||
|
||||
this._tileDataGroupCache = {};
|
||||
|
||||
this._tileDataCache = {};
|
||||
|
||||
this._tileVersions = {};
|
||||
|
||||
this._itemZIndexCounter = 0;
|
||||
|
||||
this._filterCallback = null;
|
||||
|
||||
this._filteredItems = {};
|
||||
|
||||
this._styleCallback = null;
|
||||
|
||||
this._styledItems = {};
|
||||
|
||||
this._updatedItemArr = [];
|
||||
this._updatedItems = {};
|
||||
|
||||
this._style = options.style || {};
|
||||
this._style.fillColor = og.utils.createColorRGBA(this._style.fillColor, new og.math.Vector4(0.19, 0.62, 0.85, 0.57));
|
||||
this._style.lineColor = og.utils.createColorRGBA(this._style.lineColor, new og.math.Vector4(0.19, 0.62, 0.85, 1));
|
||||
this._style.strokeColor = og.utils.createColorRGBA(this._style.strokeColor, new og.math.Vector4(1, 1, 1, 0.95));
|
||||
this._style.lineWidth = this._style.lineWidth || 5;
|
||||
this._style.strokeWidth = this._style.strokeWidth || 0;
|
||||
|
||||
this.events.registerNames(og.gmx.VectorLayer.EVENT_NAMES);
|
||||
|
||||
this._needRefresh = false;
|
||||
|
||||
this._tileDataGroupQueue = new og.QueueArray();
|
||||
|
||||
/**
|
||||
* Current loading tiles couter.
|
||||
* @protected
|
||||
* @type {number}
|
||||
*/
|
||||
this._vecCounter = 0;
|
||||
|
||||
/**
|
||||
* Tile pending queue that waiting for loading.
|
||||
* @protected
|
||||
* @type {Array.<og.planetSegment.Material>}
|
||||
*/
|
||||
this._vecPendingsQueue = new og.QueueArray();
|
||||
};
|
||||
|
||||
|
||||
og.gmx.VectorLayer.TileSenderUrlImagery = '//maps.kosmosnimki.ru/TileSender.ashx?ModeKey=tile&ftc=osm&x={x}8&y={y}&z={z}&srs=3857&LayerName={l}';
|
||||
og.gmx.VectorLayer.TileSenderUrlTemporal = '//maps.kosmosnimki.ru/TileSender.ashx?WrapStyle=None&ModeKey=tile&r=j&ftc=osm&srs=3857&LayerName={id}&z={z}&x={x}&y={y}&v={v}&Level={level}&Span={span}';
|
||||
og.gmx.VectorLayer.TileSenderUrl = '//maps.kosmosnimki.ru/TileSender.ashx?WrapStyle=None&ModeKey=tile&r=j&ftc=osm&srs=3857&LayerName={id}&z={z}&x={x}&y={y}&v={v}';
|
||||
|
||||
|
||||
og.inheritance.extend(og.gmx.VectorLayer, og.layer.Layer);
|
||||
|
||||
og.gmx.VectorLayer.EVENT_NAMES = [
|
||||
"draw",
|
||||
|
||||
/**
|
||||
* Triggered when current tile image has loaded before rendereing.
|
||||
* @event og.gmx.VectorLayer#load
|
||||
*/
|
||||
"load",
|
||||
|
||||
/**
|
||||
* Triggered when all tiles have loaded or loading has stopped.
|
||||
* @event og.gmx.VectorLayer#loadend
|
||||
*/
|
||||
"loadend"
|
||||
];
|
||||
|
||||
og.gmx.VectorLayer.__requestsCounter = 0;
|
||||
og.gmx.VectorLayer.MAX_REQUESTS = 15;
|
||||
|
||||
/**
|
||||
* Vector layer {@link og.gmx.VectorLayer} object factory.
|
||||
* @static
|
||||
* @param {String} name - Layer name.
|
||||
* @param {Object} options - Layer options.
|
||||
* @returns {og.gmx.VectorLayer} Returns vector layer.
|
||||
*/
|
||||
og.gmx.vectorLayer = function (name, options) {
|
||||
return new og.gmx.VectorLayer(name, options);
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._bindPicking = function () {
|
||||
this._pickingColor.clear();
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.createMaterial = function (segment) {
|
||||
return new og.gmx.Material(segment, this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds layer to the planet.
|
||||
* @public
|
||||
* @param {og.scene.RenderNode} planet - Planet scene.
|
||||
* @return {og.gmx.VectorLayer} - Returns og.gmx.VectorLayer instance.
|
||||
*/
|
||||
og.gmx.VectorLayer.prototype.addTo = function (planet) {
|
||||
|
||||
//Bind checkVersion to the planet
|
||||
if (!planet._gmxCheckVersion) {
|
||||
planet._gmxCheckVersion = new og.gmx.CheckVersion(planet);
|
||||
}
|
||||
|
||||
//Bind gmxVectorTileCreator to the planet
|
||||
if (!planet._gmxVectorTileCreator) {
|
||||
planet._gmxVectorTileCreator = new og.gmx.VectorTileCreator(planet);
|
||||
}
|
||||
|
||||
this._assignPlanet(planet);
|
||||
|
||||
if (this._visibility && !this._initialized) {
|
||||
this._initialize();
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes from planet.
|
||||
* @public
|
||||
* @returns {og.gmx.VectorLayer.Layer} -This layer.
|
||||
*/
|
||||
og.layer.Layer.prototype.remove = function () {
|
||||
og.layer.Layer.prototype.remove.call(this);
|
||||
this._planet && this._planet.events.off("draw", this._onRefreshNodes);
|
||||
this._initialized = false;
|
||||
return this;
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.getLayerInfo = function (hostUrl, layerId, proceedCallback, errorCallback) {
|
||||
og.ajax.request(hostUrl + "/rest/ver1/layers/" + layerId + "/info", {
|
||||
'type': "GET",
|
||||
'responseType': "json",
|
||||
'data': {
|
||||
'WrapStyle': "None"
|
||||
},
|
||||
'success': function (data) {
|
||||
proceedCallback && proceedCallback(data);
|
||||
},
|
||||
'error': function (err) {
|
||||
errorCallback && errorCallback(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.dateToEpoch = function (date) {
|
||||
var time = date.getTime();
|
||||
return time - time % 86400000;
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._initialize = function () {
|
||||
|
||||
this._initialized = true;
|
||||
|
||||
var p = this._planet;
|
||||
var that = this;
|
||||
|
||||
og.gmx.VectorLayer.getLayerInfo(this.hostUrl, this._layerId, function (data) {
|
||||
that._gmxProperties = data.properties;
|
||||
if (data.properties.Temporal) {
|
||||
var d = new Date();
|
||||
var currEpoch = og.gmx.VectorLayer.dateToEpoch(d);
|
||||
that._beginDate = that._beginDate || new Date(currEpoch);
|
||||
that._endDate = that._endDate || new Date(d.setTime(currEpoch + 24 * 60 * 60 * 1000));
|
||||
that._tileSenderUrlTemplate = og.gmx.VectorLayer.TileSenderUrlTemporal;
|
||||
that._tileImageryUrlTemplate = og.gmx.VectorLayer.TileSenderUrlImagery;
|
||||
} else {
|
||||
that._tileSenderUrlTemplate = og.gmx.VectorLayer.TileSenderUrl;
|
||||
}
|
||||
that.setExtent(og.Geometry.getExtent(data.geometry));
|
||||
p._gmxCheckVersion.update();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets layer visibility.
|
||||
* @public
|
||||
* @virtual
|
||||
* @param {boolean} visibility - Layer visibility.
|
||||
*/
|
||||
og.gmx.VectorLayer.prototype.setVisibility = function (visibility) {
|
||||
|
||||
og.layer.Layer.prototype.setVisibility.call(this, visibility);
|
||||
|
||||
if (visibility) {
|
||||
this._planet && this._planet.events.on("draw", this._onRefreshNodes, this);
|
||||
} else {
|
||||
this._planet && this._planet.events.off("draw", this._onRefreshNodes);
|
||||
}
|
||||
|
||||
if (this._visibility && !this._initialized) {
|
||||
this._initialize();
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._checkVersionSuccess = function (prop) {
|
||||
var to = prop.tilesOrder,
|
||||
ts = prop.tiles;
|
||||
var toSize = to.length;
|
||||
|
||||
var _X = to.indexOf("X"),
|
||||
_Y = to.indexOf("Y"),
|
||||
_Z = to.indexOf("Z"),
|
||||
_V = to.indexOf("V"),
|
||||
_LEVEL = to.indexOf("Level"),
|
||||
_SPAN = to.indexOf("Span");
|
||||
|
||||
var tv = this._tileVersions;
|
||||
for (var i = 0; i < ts.length; i += toSize) {
|
||||
var x = ts[i + _X],
|
||||
y = ts[i + _Y],
|
||||
z = ts[i + _Z],
|
||||
v = ts[i + _V],
|
||||
level = ts[i + _LEVEL],
|
||||
span = ts[i + _SPAN];
|
||||
|
||||
var tileIndex = og.layer.getTileIndex(x, y, z, level, span);
|
||||
if (tv[tileIndex] !== v) {
|
||||
this._tileVersions[tileIndex] = v;
|
||||
this._vecLoadTileData({
|
||||
'id': this._layerId,
|
||||
'x': x.toString(), 'y': y.toString(), 'z': z.toString(),
|
||||
'v': v.toString(), "level": level.toString(), "span": span.toString()
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.setFilter = function (filterCallback) {
|
||||
this._filterCallback = filterCallback;
|
||||
this.updateFilter();
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.removeFilter = function () {
|
||||
this._filterCallback = null;
|
||||
this.updateFilter();
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.getItemVisibility = function (item) {
|
||||
if (!this._filterCallback) {
|
||||
return true;
|
||||
}
|
||||
var visibility = this._filteredItems[item.id];
|
||||
if (visibility == null) {
|
||||
visibility = this._filteredItems[item.id] = this._filterCallback[item.id](item);
|
||||
}
|
||||
return visibility;
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.updateFilter = function () {
|
||||
this._filteredItems = {};
|
||||
//...TODO
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.setStyleHook = function (styleCallback) {
|
||||
this._styleCallback = styleCallback;
|
||||
this.updateStyle();
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.getItemStyle = function (item) {
|
||||
if (!this._styleCallback) {
|
||||
return item._style;
|
||||
}
|
||||
var style = this._styledItems[item.id];
|
||||
if (style == null) {
|
||||
style = this._styledItems[item.id] = this._styleCallback[item.id](item);
|
||||
}
|
||||
return style;
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.updateStyle = function () {
|
||||
this._styledItems = {};
|
||||
//...TODO
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._vecLoadTileData = function (t) {
|
||||
if (og.gmx.VectorLayer.__requestsCounter >= og.gmx.VectorLayer.MAX_REQUESTS && this._vecCounter) {
|
||||
this._vecPendingsQueue.push(t);
|
||||
} else {
|
||||
this._vecExec(t);
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._vecExec = function (t) {
|
||||
|
||||
var url = og.utils.stringTemplate(this._tileSenderUrlTemplate, t);
|
||||
|
||||
og.gmx.VectorLayer.__requestsCounter++;
|
||||
this._vecCounter++;
|
||||
|
||||
var that = this;
|
||||
og.ajax.request(url, {
|
||||
'type': "GET",
|
||||
'responseType': "text",
|
||||
'success': function (dataStr) {
|
||||
og.gmx.VectorLayer.__requestsCounter--;
|
||||
that._vecCounter--;
|
||||
|
||||
var data = JSON.parse(dataStr.substring(dataStr.indexOf('{'), dataStr.lastIndexOf('}') + 1));
|
||||
|
||||
that._handleTileData(t, data);
|
||||
|
||||
var e = that.events.load;
|
||||
if (e.handlers.length) {
|
||||
that.events.dispatch(e, data);
|
||||
}
|
||||
|
||||
that._vecDequeueRequest();
|
||||
},
|
||||
'error': function (err) {
|
||||
og.gmx.VectorLayer.__requestsCounter--;
|
||||
that._vecCounter--;
|
||||
|
||||
console.log(err);
|
||||
|
||||
that._vecDequeueRequest();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._vecDequeueRequest = function () {
|
||||
if (this._vecPendingsQueue.length) {
|
||||
if (og.gmx.VectorLayer.__requestsCounter < og.gmx.VectorLayer.MAX_REQUESTS) {
|
||||
var t = this._vecWhilePendings();
|
||||
if (t)
|
||||
this._vecExec.call(this, t);
|
||||
}
|
||||
} else if (this._vecCounter === 0) {
|
||||
var e = this.events.loadend;
|
||||
if (e.handlers.length) {
|
||||
this.events.dispatch(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._vecWhilePendings = function () {
|
||||
while (this._vecPendingsQueue.length) {
|
||||
return this._vecPendingsQueue.pop();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
og.gmx.VectorLayer.prototype.addItem = function (item) {
|
||||
if (!item._layer) {
|
||||
this._itemCache[item.id] = item;
|
||||
item._layer = this;
|
||||
if (this._planet) {
|
||||
this._planet.renderer.assignPickingColor(item);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._getAttributes = function (item) {
|
||||
var res = {},
|
||||
prop = this._gmxProperties;
|
||||
|
||||
var attrs = prop.attributes,
|
||||
types = prop.attrTypes;
|
||||
|
||||
for (var i = 0; i < attrs.length; i++) {
|
||||
res[attrs[i]] = og.utils.castType[types[i]](item[i + 1]);
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.getStyle = function () {
|
||||
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._handleTileData = function (t, data) {
|
||||
|
||||
var items = data.values,
|
||||
style = this._style,
|
||||
v = data.v;
|
||||
|
||||
var h = this._planet.renderer.handler;
|
||||
|
||||
var tileIndex = og.layer.getTileIndex(t.x, t.y, t.z),
|
||||
tileExtent = og.Extent.fromTile(t.x, t.y, t.z),
|
||||
cacheTileDataGroup = this._tileDataGroupCache[tileIndex];
|
||||
|
||||
if (!cacheTileDataGroup) {
|
||||
cacheTileDataGroup = this._tileDataGroupCache[tileIndex] = new og.gmx.TileDataGroup(this, tileExtent);
|
||||
}
|
||||
|
||||
var tileData = new og.gmx.TileData(data),
|
||||
tileDataCacheIndex = og.layer.getTileIndex(tileIndex, t.level, t.span);
|
||||
|
||||
var cacheTileData = this._tileDataCache[tileDataCacheIndex];
|
||||
|
||||
if (cacheTileData) {
|
||||
//Update tile version.Remove it before update.
|
||||
this._tileDataCache[tileDataCacheIndex] = tileData;
|
||||
cacheTileDataGroup.removeTileData(cacheTileData);
|
||||
}
|
||||
|
||||
cacheTileDataGroup.addTileData(tileData);
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
|
||||
var item = items[i],
|
||||
gmxId = item[0];
|
||||
|
||||
var cacheItem = this._itemCache[gmxId];
|
||||
|
||||
if (!cacheItem) {
|
||||
cacheItem = new og.gmx.Item(gmxId, {
|
||||
'attributes': this._getAttributes(item),
|
||||
'version': v,
|
||||
'style': {
|
||||
'fillColor': style.fillColor.clone(),
|
||||
'lineColor': style.lineColor.clone(),
|
||||
'strokeColor': style.strokeColor.clone(),
|
||||
'lineWidth': style.lineWidth,
|
||||
'strokeWidth': style.strokeWidth,
|
||||
'zIndex': this._itemZIndexCounter++
|
||||
}
|
||||
});
|
||||
|
||||
this.addItem(cacheItem);
|
||||
|
||||
} else if (cacheItem.version !== v) {
|
||||
cacheItem.version = v;
|
||||
cacheItem.attributes = this._getAttributes(item);
|
||||
|
||||
//TODO: Has to be tested
|
||||
cacheItem._extent = null;
|
||||
}
|
||||
|
||||
var ti = new og.gmx.TileItem(cacheItem, item[item.length - 1]);
|
||||
|
||||
ti.createBuffers(h, tileExtent);
|
||||
|
||||
tileData.addTileItem(ti);
|
||||
cacheTileDataGroup.addTileItem(ti);
|
||||
}
|
||||
|
||||
this._tileDataGroupQueue.push(cacheTileDataGroup);
|
||||
|
||||
this._needRefresh = true;
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._onRefreshNodes = function (p) {
|
||||
|
||||
print2d("l4", `_rNodes: ${this._planet._renderedNodes.length}`, 100, 25);
|
||||
print2d("l3", `zMinMax: ${this._planet.minCurrZoom}, ${this._planet.maxCurrZoom}`, 100, 50);
|
||||
print2d("l1", `loading: ${this._vecCounter}, ${this._vecPendingsQueue.length}`, 100, 100);
|
||||
print2d("l2", `drawing: ${this._planet._gmxVectorTileCreator._queue.length}`, 100, 150);
|
||||
|
||||
if (this._needRefresh && this._planet) {
|
||||
while (this._tileDataGroupQueue.length) {
|
||||
var t = this._tileDataGroupQueue.pop();
|
||||
this._refreshRecursevelyExtent(t.tileExtent, this._planet._quadTree);
|
||||
}
|
||||
this._needRefresh = false;
|
||||
}
|
||||
|
||||
//->
|
||||
//this.loadMaterial goes next.
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._refreshRecursevelyExtent = function (extent, treeNode) {
|
||||
var lid = this._id;
|
||||
for (var i = 0; i < treeNode.nodes.length; i++) {
|
||||
var ni = treeNode.nodes[i];
|
||||
if (extent.overlaps(ni.planetSegment._extent)) {
|
||||
this._refreshRecursevelyExtent(extent, ni);
|
||||
var m = ni.planetSegment.materials[lid];
|
||||
if (m) {
|
||||
if (m.segment.node.getState() !== og.quadTree.RENDERING) {
|
||||
m.layer.clearMaterial(m);
|
||||
} else {
|
||||
if (m.isReady) {
|
||||
m.isReady = false;
|
||||
m._updateTexture = m.texture;
|
||||
m._updatePickingMask = m.pickingMask;
|
||||
m.pickingReady = false;//m.pickingReady && item._pickingReady;
|
||||
}
|
||||
m.isLoading = false;
|
||||
m.fromTile = null;
|
||||
}
|
||||
//item._pickingReady = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Start to load tile material.
|
||||
* @public
|
||||
* @virtual
|
||||
* @param {og.planetSegment.Material} material - Current material.
|
||||
*/
|
||||
og.gmx.VectorLayer.prototype.loadMaterial = function (material) {
|
||||
|
||||
var seg = material.segment;
|
||||
|
||||
if (seg._projection.id !== og.proj.EPSG3857.id) {
|
||||
material.textureNotExists();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._isBaseLayer) {
|
||||
material.texture = seg._isNorth ? seg.planet.solidTextureOne : seg.planet.solidTextureTwo;
|
||||
} else {
|
||||
material.texture = seg.planet.transparentTexture;
|
||||
}
|
||||
|
||||
if (this._planet.layerLock.isFree()) {
|
||||
var tileDataGroup = this._getTileDataGroup(seg);
|
||||
if (tileDataGroup) {
|
||||
material.isReady = false;
|
||||
material.isLoading = true;
|
||||
material.fromTile = tileDataGroup;
|
||||
this._planet._gmxVectorTileCreator.add({
|
||||
'material': material,
|
||||
'fromTile': tileDataGroup
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
og.gmx.VectorLayer.prototype._getTileDataGroup = function (seg) {
|
||||
var tgc = this._tileDataGroupCache;
|
||||
var data = tgc[seg.tileIndex];
|
||||
if (data) {
|
||||
return data;
|
||||
} else {
|
||||
var pn = this._planet._quadTreeNodesCacheMerc[seg.tileIndex].parentNode;
|
||||
while (pn) {
|
||||
var ptc = tgc[pn.planetSegment.tileIndex];
|
||||
if (ptc) {
|
||||
return ptc;
|
||||
}
|
||||
pn = pn.parentNode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.getGmxProperties = function () {
|
||||
return this._gmxProperties;
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.applySceneTexture = function (tileItem, material) {
|
||||
|
||||
if (material.sceneIsReady) {
|
||||
return [0, 0, 1, 1];
|
||||
} else {
|
||||
|
||||
if (!material.sceneIsLoading) {
|
||||
|
||||
material.sceneIsLoading = true;
|
||||
|
||||
var url = og.utils.stringTemplate(this._tileImageryUrlTemplate, {
|
||||
'x': tileItem.tileData.x,
|
||||
'y': tileItem.tileData.y,
|
||||
'z': tileItem.tileData.z,
|
||||
'l': tileItem.item.attributes.GMX_RasterCatalogID
|
||||
});
|
||||
|
||||
p._imageBitmapLoader(ti.attributes.GMX_RasterCatalogID, (e) => {
|
||||
if (e.data.ok) {
|
||||
material.applySceneBitmapImage(e.data.bitmapImage);
|
||||
} else {
|
||||
material.sceneNotExists();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var segment = material.segment;
|
||||
var pn = segment.node,
|
||||
notEmpty = false;
|
||||
|
||||
var mId = this._id;
|
||||
var psegm = material;
|
||||
while (pn.parentNode) {
|
||||
if (psegm && psegm.sceneReady) {
|
||||
notEmpty = true;
|
||||
break;
|
||||
}
|
||||
pn = pn.parentNode;
|
||||
psegm = pn.planetSegment.materials[mId];
|
||||
}
|
||||
|
||||
if (notEmpty) {
|
||||
material.sceneTexture = psegm.sceneTexture;
|
||||
var dZ2 = 1.0 / (2 << (segment.tileZoom - pn.planetSegment.tileZoom - 1));
|
||||
return [
|
||||
segment.tileX * dZ2 - pn.planetSegment.tileX,
|
||||
segment.tileY * dZ2 - pn.planetSegment.tileY,
|
||||
dZ2,
|
||||
dZ2
|
||||
];
|
||||
} else {
|
||||
material.sceneTexture = segment.planet.transparentTexture;
|
||||
return [0, 0, 1, 1];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Abort exact material loading.
|
||||
* @public
|
||||
* @param {og.planetSegment.Material} material - Segment material.
|
||||
*/
|
||||
og.gmx.VectorLayer.prototype.abortMaterialLoading = function (material) {
|
||||
material.isLoading = false;
|
||||
material.isReady = false;
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.applyMaterial = function (material) {
|
||||
if (material.isReady) {
|
||||
return [0, 0, 1, 1];
|
||||
} else {
|
||||
|
||||
!material.isLoading && this.loadMaterial(material);
|
||||
|
||||
var segment = material.segment;
|
||||
var pn = segment.node,
|
||||
notEmpty = false;
|
||||
|
||||
var mId = this._id;
|
||||
var psegm = material;
|
||||
//var i = 0;
|
||||
while (pn.parentNode /*&& i < 2*/) {
|
||||
if (psegm && psegm.isReady) {
|
||||
notEmpty = true;
|
||||
break;
|
||||
}
|
||||
pn = pn.parentNode;
|
||||
psegm = pn.planetSegment.materials[mId];
|
||||
//i++;
|
||||
}
|
||||
|
||||
if (notEmpty) {
|
||||
material.appliedNodeId = pn.nodeId;
|
||||
material.texture = psegm.texture;
|
||||
material.pickingMask = psegm.pickingMask;
|
||||
var dZ2 = 1.0 / (2 << (segment.tileZoom - pn.planetSegment.tileZoom - 1));
|
||||
return [
|
||||
segment.tileX * dZ2 - pn.planetSegment.tileX,
|
||||
segment.tileY * dZ2 - pn.planetSegment.tileY,
|
||||
dZ2,
|
||||
dZ2
|
||||
];
|
||||
} else {
|
||||
if (material.textureExists && material._updateTexture) {
|
||||
material.texture = material._updateTexture;
|
||||
material.pickingMask = material._updatePickingMask;
|
||||
} else {
|
||||
material.texture = segment.planet.transparentTexture;
|
||||
material.pickingMask = segment.planet.transparentTexture;
|
||||
}
|
||||
return [0, 0, 1, 1];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.clearMaterial = function (material) {
|
||||
if (material.isReady) {
|
||||
var gl = material.segment.handler.gl;
|
||||
|
||||
material.isReady = false;
|
||||
material.pickingReady = false;
|
||||
|
||||
var t = material.texture;
|
||||
material.texture = null;
|
||||
t && !t.default && gl.deleteTexture(t);
|
||||
|
||||
t = material.pickingMask;
|
||||
material.pickingMask = null;
|
||||
t && !t.default && gl.deleteTexture(t);
|
||||
|
||||
t = material._updateTexture;
|
||||
material._updateTexture = null;
|
||||
t && !t.default && gl.deleteTexture(t);
|
||||
|
||||
t = material._updatePickingMask;
|
||||
material._updatePickingMask = null;
|
||||
t && !t.default && gl.deleteTexture(t);
|
||||
}
|
||||
|
||||
this.abortMaterialLoading(material);
|
||||
|
||||
material.isLoading = false;
|
||||
material.textureExists = false;
|
||||
material.fromTile = null;
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._refreshRecursevely = function (item, treeNode) {
|
||||
var lid = this._id;
|
||||
for (var i = 0; i < treeNode.nodes.length; i++) {
|
||||
var ni = treeNode.nodes[i];
|
||||
if (item._extent.overlaps(ni.planetSegment._extent)) {
|
||||
this._refreshRecursevely(item, ni);
|
||||
var m = ni.planetSegment.materials[lid];
|
||||
if (m && m.isReady) {
|
||||
if (m.segment.node.getState() !== og.quadTree.RENDERING) {
|
||||
m.layer.clearMaterial(m);
|
||||
} else {
|
||||
m.pickingReady = m.pickingReady && item._pickingReady;
|
||||
m.isReady = false;
|
||||
m._updateTexture = m.texture;
|
||||
m._updatePickingMask = m.pickingMask;
|
||||
}
|
||||
item._pickingReady = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._refreshPlanetNode = function (treeNode) {
|
||||
for (var i = 0, items = this._updatedItemArr; i < items.length; i++) {
|
||||
this._refreshRecursevely(items[i], treeNode);
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype._updatePlanet = function () {
|
||||
if (this._updatedItemArr.length) {
|
||||
if (this._planet) {
|
||||
this._refreshPlanetNode(this._planet._quadTree);
|
||||
}
|
||||
this._updatedItemArr.length = 0;
|
||||
this._updatedItemArr = [];
|
||||
this._updatedItems = {};
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.updateItems = function (items) {
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
this.updateItem(items[i]);
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.updateItem = function (item) {
|
||||
if (item._extent) {
|
||||
this._updatedItemArr.push(item);
|
||||
this._updatedItems[item.id] = item;
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.update = function () {
|
||||
this._updatePlanet();
|
||||
this.events.dispatch(this.events.draw, this);
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.setStyle = function (style) {
|
||||
//...
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.clear = function () {
|
||||
this._itemCache = {};
|
||||
this._tileDataCache = {};
|
||||
this._tileDataGroupCache = {};
|
||||
this._tileVersions = {};
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.refresh = function () {
|
||||
if (this._gmxProperties) {
|
||||
this.clear();
|
||||
if (this._planet) {
|
||||
this._planet._gmxCheckVersion.update();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.VectorLayer.prototype.setDateInterval = function (beginDate, endDate) {
|
||||
this._beginDate = beginDate;
|
||||
this._endDate = endDate;
|
||||
// if (this._gmxProperties && this._gmxProperties.Temporal) {
|
||||
// }
|
||||
};
|
||||
@ -1,385 +0,0 @@
|
||||
goog.provide('og.gmx.VectorTileCreator');
|
||||
|
||||
goog.require('og.utils.VectorTileCreator');
|
||||
goog.require('og.inheritance');
|
||||
|
||||
og.gmx.VectorTileCreator = function (planet, maxFrames, width, height) {
|
||||
og.inheritance.base(this, planet, maxFrames, width, height);
|
||||
|
||||
planet.events.on("draw", this.frame, this);
|
||||
};
|
||||
|
||||
og.inheritance.extend(og.gmx.VectorTileCreator, og.utils.VectorTileCreator);
|
||||
|
||||
og.gmx.VectorTileCreator.appendLineData = function (pathArr, isClosed, outVertices, outOrders, outIndexes) {
|
||||
var index = 0;
|
||||
|
||||
if (outIndexes.length > 0) {
|
||||
index = outIndexes[outIndexes.length - 5] + 9;
|
||||
outIndexes.push(index, index);
|
||||
} else {
|
||||
outIndexes.push(0, 0);
|
||||
}
|
||||
|
||||
for (var j = 0; j < pathArr.length; j++) {
|
||||
var path = pathArr[j];
|
||||
var startIndex = index;
|
||||
var last;
|
||||
if (isClosed) {
|
||||
last = path[path.length - 1];
|
||||
} else {
|
||||
var p0 = path[0],
|
||||
p1 = path[1];
|
||||
last = [p0[0] + p0[0] - p1[0], p0[1] + p0[1] - p1[1]];
|
||||
}
|
||||
outVertices.push(last[0], last[1], last[0], last[1], last[0], last[1], last[0], last[1]);
|
||||
outOrders.push(1, -1, 2, -2);
|
||||
|
||||
for (var i = 0; i < path.length; i++) {
|
||||
var cur = path[i];
|
||||
outVertices.push(cur[0], cur[1], cur[0], cur[1], cur[0], cur[1], cur[0], cur[1]);
|
||||
outOrders.push(1, -1, 2, -2);
|
||||
outIndexes.push(index++, index++, index++, index++);
|
||||
}
|
||||
|
||||
var first;
|
||||
if (isClosed) {
|
||||
first = path[0];
|
||||
outIndexes.push(startIndex, startIndex + 1, startIndex + 1, startIndex + 1);
|
||||
} else {
|
||||
var p0 = path[path.length - 1],
|
||||
p1 = path[path.length - 2];
|
||||
first = [p0[0] + p0[0] - p1[0], p0[1] + p0[1] - p1[1]];
|
||||
outIndexes.push(index - 1, index - 1, index - 1, index - 1);
|
||||
}
|
||||
outVertices.push(first[0], first[1], first[0], first[1], first[0], first[1], first[0], first[1]);
|
||||
outOrders.push(1, -1, 2, -2);
|
||||
|
||||
if (j < pathArr.length - 1) {
|
||||
index += 8;
|
||||
outIndexes.push(index, index);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
og.gmx.VectorTileCreator.prototype._initialize = function () {
|
||||
|
||||
//Line
|
||||
if (!this._handler.shaderPrograms.gmxVectorTileLineRasterization) {
|
||||
this._handler.addShaderProgram(new og.shaderProgram.ShaderProgram("gmxVectorTileLineRasterization", {
|
||||
uniforms: {
|
||||
'viewport': { type: og.shaderProgram.types.VEC2 },
|
||||
'thicknessOutline': { type: og.shaderProgram.types.FLOAT },
|
||||
'alpha': { type: og.shaderProgram.types.FLOAT },
|
||||
'extentParams': { type: og.shaderProgram.types.VEC4 },
|
||||
'color': { type: og.shaderProgram.types.VEC4 },
|
||||
'thickness': { type: og.shaderProgram.types.FLOAT }
|
||||
},
|
||||
attributes: {
|
||||
'prev': { type: og.shaderProgram.types.VEC2 },
|
||||
'current': { type: og.shaderProgram.types.VEC2 },
|
||||
'next': { type: og.shaderProgram.types.VEC2 },
|
||||
'order': { type: og.shaderProgram.types.FLOAT }
|
||||
},
|
||||
vertexShader: 'attribute vec2 prev;\
|
||||
attribute vec2 current;\
|
||||
attribute vec2 next;\
|
||||
attribute float order;\
|
||||
uniform float thickness;\
|
||||
uniform float thicknessOutline;\
|
||||
uniform vec2 viewport;\
|
||||
uniform vec4 extentParams;\
|
||||
\
|
||||
vec2 proj(vec2 coordinates){\
|
||||
return vec2(-1.0 + (coordinates - extentParams.xy) * extentParams.zw) * vec2(1.0, -1.0);\
|
||||
}\
|
||||
\
|
||||
void main(){\
|
||||
vec2 _next = next;\
|
||||
vec2 _prev = prev;\
|
||||
if(prev == current){\
|
||||
if(next == current){\
|
||||
_next = current + vec2(1.0, 0.0);\
|
||||
_prev = current - next;\
|
||||
}else{\
|
||||
_prev = current + normalize(current - next);\
|
||||
}\
|
||||
}\
|
||||
if(next == current){\
|
||||
_next = current + normalize(current - _prev);\
|
||||
}\
|
||||
\
|
||||
vec2 sNext = proj(_next),\
|
||||
sCurrent = proj(current),\
|
||||
sPrev = proj(_prev);\
|
||||
vec2 dirNext = normalize(sNext - sCurrent);\
|
||||
vec2 dirPrev = normalize(sPrev - sCurrent);\
|
||||
float dotNP = dot(dirNext, dirPrev);\
|
||||
\
|
||||
vec2 normalNext = normalize(vec2(-dirNext.y, dirNext.x));\
|
||||
vec2 normalPrev = normalize(vec2(dirPrev.y, -dirPrev.x));\
|
||||
vec2 d = (thickness + thicknessOutline) * 0.5 * sign(order) / viewport;\
|
||||
\
|
||||
vec2 m;\
|
||||
if(dotNP >= 0.99991){\
|
||||
m = sCurrent - normalPrev * d;\
|
||||
}else{\
|
||||
vec2 dir = normalPrev + normalNext;\
|
||||
m = sCurrent + dir * d / (dirNext.x * dir.y - dirNext.y * dir.x);\
|
||||
\
|
||||
if( dotNP > 0.5 && dot(dirNext + dirPrev, m - sCurrent) < 0.0 ){\
|
||||
float occw = order * sign(dirNext.x * dirPrev.y - dirNext.y * dirPrev.x);\
|
||||
if(occw == -1.0){\
|
||||
m = sCurrent + normalPrev * d;\
|
||||
}else if(occw == 1.0){\
|
||||
m = sCurrent + normalNext * d;\
|
||||
}else if(occw == -2.0){\
|
||||
m = sCurrent + normalNext * d;\
|
||||
}else if(occw == 2.0){\
|
||||
m = sCurrent + normalPrev * d;\
|
||||
}\
|
||||
}else if(distance(sCurrent, m) > min(distance(sCurrent, sNext), distance(sCurrent, sPrev))){\
|
||||
m = sCurrent + normalNext * d;\
|
||||
}\
|
||||
}\
|
||||
gl_Position = vec4(m.x, m.y, 0.0, 1.0);\
|
||||
}',
|
||||
fragmentShader: 'precision highp float;\
|
||||
uniform float alpha;\
|
||||
uniform vec4 color;\
|
||||
void main() {\
|
||||
gl_FragColor = vec4(color.rgb, alpha * color.a);\
|
||||
}'
|
||||
}));
|
||||
}
|
||||
|
||||
//Polygon
|
||||
if (!this._handler.shaderPrograms.gmxVectorTilePolygonRasterization) {
|
||||
this._handler.addShaderProgram(new og.shaderProgram.ShaderProgram("gmxVectorTilePolygonRasterization", {
|
||||
uniforms: {
|
||||
'extentParams': { type: og.shaderProgram.types.VEC4 },
|
||||
'color': { type: og.shaderProgram.types.VEC4 }
|
||||
},
|
||||
attributes: {
|
||||
'coordinates': { type: og.shaderProgram.types.VEC2 }
|
||||
},
|
||||
vertexShader: 'attribute vec2 coordinates; \
|
||||
uniform vec4 extentParams; \
|
||||
void main() { \
|
||||
gl_Position = vec4((-1.0 + (coordinates - extentParams.xy) * extentParams.zw) * vec2(1.0, -1.0), 0.0, 1.0); \
|
||||
}',
|
||||
fragmentShader: 'precision highp float;\
|
||||
uniform vec4 color;\
|
||||
void main () { \
|
||||
gl_FragColor = color; \
|
||||
}'
|
||||
}));
|
||||
}
|
||||
|
||||
this._framebuffer = new og.webgl.Framebuffer(this._handler, {
|
||||
width: this._width,
|
||||
height: this._height,
|
||||
useDepth: false
|
||||
});
|
||||
};
|
||||
|
||||
og.gmx.VectorTileCreator.prototype.add = function (data) {
|
||||
this._queue.push(data);
|
||||
};
|
||||
|
||||
og.gmx.VectorTileCreator.prototype.frame = function () {
|
||||
|
||||
if (this._planet.layerLock.isFree() && this._queue.length) {
|
||||
var h = this._handler,
|
||||
gl = h.gl;
|
||||
var p = this._planet;
|
||||
|
||||
gl.disable(gl.CULL_FACE);
|
||||
gl.disable(gl.DEPTH_TEST);
|
||||
gl.enable(gl.BLEND);
|
||||
gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD);
|
||||
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
var hLine = h.shaderPrograms.gmxVectorTileLineRasterization,
|
||||
hPoly = h.shaderPrograms.gmxVectorTilePolygonRasterization;
|
||||
|
||||
var f = this._framebuffer.activate();
|
||||
|
||||
var width, height;
|
||||
var width2 = this._width * 2,
|
||||
height2 = this._height * 2;
|
||||
|
||||
var deltaTime = 0,
|
||||
startTime = window.performance.now();
|
||||
|
||||
while (p.layerLock.isFree() && this._queue.length && deltaTime < 0.25) {
|
||||
|
||||
var q = this._queue.shift();
|
||||
var fromTile = q.fromTile,
|
||||
material = q.material;
|
||||
|
||||
if (material.isLoading && material.segment.node.getState() === og.quadTree.RENDERING) {
|
||||
|
||||
var layer = material.layer;
|
||||
var tItems = fromTile.tileItemArr;
|
||||
|
||||
tItems.sort(function (a, b) {
|
||||
return layer.getItemStyle(a.item).zIndex - layer.getItemStyle(b.item).zIndex || a.item.id - b.item.id;
|
||||
});
|
||||
|
||||
if (material.segment.tileZoom <= 3) {
|
||||
width = width2;
|
||||
height = height2;
|
||||
} else {
|
||||
width = this._width;
|
||||
height = this._height;
|
||||
}
|
||||
|
||||
var extent = material.segment.getExtentMerc();
|
||||
var extentParams = [extent.southWest.lon, extent.southWest.lat, 2.0 / extent.getWidth(), 2.0 / extent.getHeight()];
|
||||
|
||||
var texture = material._updateTexture && material._updateTexture || h.createEmptyTexture_l(width, height);
|
||||
|
||||
var pickingMask;
|
||||
if (layer._pickingEnabled && !material.pickingReady) {
|
||||
if (material._updatePickingMask) {
|
||||
pickingMask = material._updatePickingMask;
|
||||
} else {
|
||||
pickingMask = h.createEmptyTexture_n(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
f.setSize(width, height);
|
||||
|
||||
f.bindOutputTexture(texture);
|
||||
gl.clearColor(1.0, 1.0, 1.0, 0.0);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
|
||||
f.bindOutputTexture(pickingMask);
|
||||
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
|
||||
//draw vectors
|
||||
for (var i = 0; i < tItems.length; i++) {
|
||||
var ti = tItems[i];
|
||||
if (layer.getItemVisibility(ti.item)) {
|
||||
|
||||
if (layer._gmxProperties.Temporal) {
|
||||
let sceneTextureOffset = layer.applySceneTexture(ti, material);
|
||||
}
|
||||
|
||||
var style = layer.getItemStyle(ti.item),
|
||||
fillColor = [style.fillColor.x, style.fillColor.y, style.fillColor.z, style.fillColor.w];
|
||||
|
||||
var pickingColor = [ti.item._pickingColor.x / 255.0, ti.item._pickingColor.y / 255.0, ti.item._pickingColor.z / 255.0, 1.0];
|
||||
|
||||
hPoly.activate();
|
||||
var sh = hPoly._program;
|
||||
var sha = sh.attributes,
|
||||
shu = sh.uniforms;
|
||||
|
||||
//==============
|
||||
//polygon
|
||||
//==============
|
||||
f.bindOutputTexture(texture);
|
||||
gl.uniform4fv(shu.color._pName, fillColor);
|
||||
gl.uniform4fv(shu.extentParams._pName, extentParams);
|
||||
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, ti._polyVerticesBufferMerc);
|
||||
gl.vertexAttribPointer(sha.coordinates._pName, ti._polyVerticesBufferMerc.itemSize, gl.FLOAT, false, 0, 0);
|
||||
|
||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ti._polyIndexesBuffer);
|
||||
gl.drawElements(gl.TRIANGLES, ti._polyIndexesBuffer.numItems, gl.UNSIGNED_INT, 0);
|
||||
|
||||
//Polygon picking pass
|
||||
if (layer._pickingEnabled) {
|
||||
if (!material.pickingReady) {
|
||||
f.bindOutputTexture(pickingMask);
|
||||
gl.uniform4fv(shu.color._pName, pickingColor);
|
||||
gl.drawElements(gl.TRIANGLES, ti._polyIndexesBuffer.numItems, gl.UNSIGNED_INT, 0);
|
||||
} else {
|
||||
pickingMask = material.pickingMask;
|
||||
}
|
||||
}
|
||||
|
||||
//==============
|
||||
//Outline
|
||||
//==============
|
||||
hLine.activate();
|
||||
sh = hLine._program;
|
||||
sha = sh.attributes;
|
||||
shu = sh.uniforms;
|
||||
|
||||
f.bindOutputTexture(texture);
|
||||
|
||||
gl.uniform2fv(shu.viewport._pName, [width, height]);
|
||||
gl.uniform4fv(shu.extentParams._pName, extentParams);
|
||||
|
||||
//vertex
|
||||
var mb = ti._lineVerticesBufferMerc;
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, mb);
|
||||
gl.vertexAttribPointer(sha.prev._pName, mb.itemSize, gl.FLOAT, false, 8, 0);
|
||||
gl.vertexAttribPointer(sha.current._pName, mb.itemSize, gl.FLOAT, false, 8, 32);
|
||||
gl.vertexAttribPointer(sha.next._pName, mb.itemSize, gl.FLOAT, false, 8, 64);
|
||||
|
||||
//order
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, ti._lineOrdersBuffer);
|
||||
gl.vertexAttribPointer(sha.order._pName, ti._lineOrdersBuffer.itemSize, gl.FLOAT, false, 4, 0);
|
||||
|
||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ti._lineIndexesBuffer);
|
||||
|
||||
//PASS - stroke
|
||||
gl.uniform1f(shu.thickness._pName, style.strokeWidth);
|
||||
gl.uniform4fv(shu.color._pName, style.strokeColor.toArray());
|
||||
|
||||
//Antialias pass
|
||||
gl.uniform1f(shu.thicknessOutline._pName, 2);
|
||||
gl.uniform1f(shu.alpha._pName, 0.54);
|
||||
gl.drawElements(gl.TRIANGLE_STRIP, ti._lineIndexesBuffer.numItems, gl.UNSIGNED_INT, 0);
|
||||
//
|
||||
//Aliased pass
|
||||
gl.uniform1f(shu.thicknessOutline._pName, 1);
|
||||
gl.uniform1f(shu.alpha._pName, 1.0);
|
||||
gl.drawElements(gl.TRIANGLE_STRIP, ti._lineIndexesBuffer.numItems, gl.UNSIGNED_INT, 0);
|
||||
|
||||
//PASS - inside line
|
||||
gl.uniform1f(shu.thickness._pName, style.lineWidth);
|
||||
gl.uniform4fv(shu.color._pName, style.lineColor.toArray());
|
||||
|
||||
//Antialias pass
|
||||
gl.uniform1f(shu.thicknessOutline._pName, 2);
|
||||
gl.uniform1f(shu.alpha._pName, 0.54);
|
||||
gl.drawElements(gl.TRIANGLE_STRIP, ti._lineIndexesBuffer.numItems, gl.UNSIGNED_INT, 0);
|
||||
//
|
||||
//Aliased pass
|
||||
gl.uniform1f(shu.thicknessOutline._pName, 1);
|
||||
gl.uniform1f(shu.alpha._pName, 1.0);
|
||||
gl.drawElements(gl.TRIANGLE_STRIP, ti._lineIndexesBuffer.numItems, gl.UNSIGNED_INT, 0);
|
||||
|
||||
//Outline picking pass
|
||||
if (layer._pickingEnabled && !material.pickingReady) {
|
||||
f.bindOutputTexture(pickingMask);
|
||||
gl.uniform1f(shu.thicknessOutline._pName, 8);
|
||||
gl.uniform4fv(shu.color._pName, pickingColor);
|
||||
gl.drawElements(gl.TRIANGLE_STRIP, ti._lineIndexesBuffer.numItems, gl.UNSIGNED_INT, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
material.applyTexture(texture, pickingMask);
|
||||
|
||||
} else {
|
||||
material.isLoading = false;
|
||||
}
|
||||
|
||||
deltaTime = window.performance.now() - startTime;
|
||||
}
|
||||
|
||||
gl.disable(gl.BLEND);
|
||||
gl.enable(gl.DEPTH_TEST);
|
||||
gl.enable(gl.CULL_FACE);
|
||||
|
||||
f.deactivate();
|
||||
}
|
||||
};
|
||||
@ -22,9 +22,9 @@ export const Units = {
|
||||
* @type {Object.<og.proj.Units, number>}
|
||||
*/
|
||||
export const METERS_PER_UNIT = {};
|
||||
METERS_PER_UNIT[og.proj.Units.FEET] = 0.3048;
|
||||
METERS_PER_UNIT[og.proj.Units.METERS] = 1;
|
||||
METERS_PER_UNIT[og.proj.Units.KILOMETERS] = 1000;
|
||||
METERS_PER_UNIT[Units.FEET] = 0.3048;
|
||||
METERS_PER_UNIT[Units.METERS] = 1;
|
||||
METERS_PER_UNIT[Units.KILOMETERS] = 1000;
|
||||
|
||||
const Proj = function (options) {
|
||||
|
||||
|
||||
@ -4,15 +4,15 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as inheritance from '../inheritance.js';
|
||||
import * as mercator from '../mercator.js';
|
||||
import * as quadTree from './quadTree.js';
|
||||
import { Box } from '../bv/Box.js';
|
||||
import { EntityCollection } from '../entity/EntityCollection.js';
|
||||
import { Extent } from '../Extent.js';
|
||||
import { LonLat } from '../LonLat.js';
|
||||
import { Vec3 } from '../math/Vec3.js';
|
||||
import { EntityCollection } from '../entity/EntityCollection.js';
|
||||
import { Box } from '../bv/Box.js';
|
||||
import { inherits } from '../inherits.js';
|
||||
import { Sphere } from '../bv/Sphere.js';
|
||||
import { Vec3 } from '../math/Vec3.js';
|
||||
|
||||
const EntityCollectionNode = function (layer, partId, parent, id, extent, planet, zoom) {
|
||||
this.layer = layer;
|
||||
@ -322,12 +322,22 @@ EntityCollectionNode.prototype.isVisible = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Node of entity collections for WGS84 coordinates.
|
||||
* @param {any} layer
|
||||
* @param {any} partId
|
||||
* @param {any} parent
|
||||
* @param {any} id
|
||||
* @param {any} extent
|
||||
* @param {any} planet
|
||||
* @param {any} zoom
|
||||
*/
|
||||
const EntityCollectionNodeWGS84 = function (layer, partId, parent, id, extent, planet, zoom) {
|
||||
inheritance.base(this, layer, partId, parent, id, extent, planet, zoom);
|
||||
EntityCollectionNode.call(this, layer, partId, parent, id, extent, planet, zoom);
|
||||
this.isNorth = false;
|
||||
};
|
||||
|
||||
inheritance.extend(EntityCollectionNodeWGS84, EntityCollectionQuadNode);
|
||||
inherits(EntityCollectionNodeWGS84, EntityCollectionNode);
|
||||
|
||||
EntityCollectionNodeWGS84.prototype._setExtentBounds = function () {
|
||||
if (this.extent.northEast.lat > 0) {
|
||||
|
||||
@ -14,8 +14,6 @@ import { EPSG3857 } from '../proj/EPSG3857.js';
|
||||
import { Vec3 } from '../math/Vec3.js';
|
||||
|
||||
const VISIBLE_DISTANCE = 3570;
|
||||
const _vertOrder = [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 0, y: 1 }, { x: 1, y: 1 }];
|
||||
const _neGridSize = Math.sqrt(Node._vertOrder.length) - 1;
|
||||
|
||||
/**
|
||||
* Returns triangle coordinate array from inside of the source triangle array.
|
||||
@ -74,6 +72,9 @@ const Node = function (segmentPrototype, planet, partId, parent, id, tileZoom, e
|
||||
this.planet._createdNodesCount++;
|
||||
};
|
||||
|
||||
const _vertOrder = [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 0, y: 1 }, { x: 1, y: 1 }];
|
||||
const _neGridSize = Math.sqrt(_vertOrder.length) - 1;
|
||||
|
||||
Node.prototype.createChildrenNodes = function () {
|
||||
var p = this.planet;
|
||||
var ps = this.planetSegment;
|
||||
|
||||
@ -192,7 +192,7 @@ class RendererEvents extends Events {
|
||||
if (name == "keypress" || name == "charkeypress") {
|
||||
this._keyboardHandler.addEvent(name, p2, p1, p0, p3);
|
||||
} else {
|
||||
this.constructor.superclass.on.call(this, name, p0, p1);
|
||||
super.on(name, p0, p1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
import * as coder from '../math/coder.js';
|
||||
import * as shaders from '../shaderProgram/drawnode.js';
|
||||
import * as shaders from '../shaders/drawnode.js';
|
||||
import * as math from '../math.js';
|
||||
import * as mercator from '../mercator.js';
|
||||
import * as planetSegmentHelper from '../planetSegment/planetSegmentHelper.js';
|
||||
@ -29,6 +29,8 @@ import { TerrainWorker } from '../utils/TerrainWorker.js';
|
||||
import { VectorTileCreator } from '../utils/VectorTileCreator.js';
|
||||
import { wgs84 } from '../ellipsoid/wgs84.js';
|
||||
|
||||
const RESOURCES_URL = "";
|
||||
|
||||
/**
|
||||
* Maximum created nodes count. The more nodes count the more memory usage.
|
||||
* @const
|
||||
@ -401,7 +403,7 @@ class Planet extends RenderNode {
|
||||
* Add the given controls array to the renderer of the planet.
|
||||
* @param {Array.<og.control.BaseControl>} cArr - Control array.
|
||||
*/
|
||||
addControls = function (cArr) {
|
||||
addControls(cArr) {
|
||||
for (var i = 0; i < cArr.length; i++) {
|
||||
this.addControl(cArr[i]);
|
||||
}
|
||||
@ -655,7 +657,7 @@ class Planet extends RenderNode {
|
||||
img.onload = function () {
|
||||
that._nightTexture = that.renderer.handler.createTexture_mm(this);
|
||||
};
|
||||
img.src = og.RESOURCES_URL + "night.png";
|
||||
img.src = RESOURCES_URL + "night.png";
|
||||
}
|
||||
|
||||
//load water specular mask
|
||||
@ -665,7 +667,7 @@ class Planet extends RenderNode {
|
||||
img2.onload = function () {
|
||||
that._specularTexture = that.renderer.handler.createTexture_l(this);
|
||||
};
|
||||
img2.src = og.RESOURCES_URL + "spec.png";
|
||||
img2.src = RESOURCES_URL + "spec.png";
|
||||
}
|
||||
|
||||
this._geoImageCreator = new GeoImageCreator(this.renderer.handler);
|
||||
@ -1105,7 +1107,7 @@ class Planet extends RenderNode {
|
||||
*/
|
||||
_multiRenderNodesPASS() {
|
||||
|
||||
var sh;
|
||||
var sh, shu;
|
||||
var renderer = this.renderer;
|
||||
var h = renderer.handler;
|
||||
var gl = h.gl;
|
||||
@ -1116,8 +1118,8 @@ class Planet extends RenderNode {
|
||||
|
||||
if (this.lightEnabled) {
|
||||
h.shaderPrograms.drawnode_wl.activate();
|
||||
sh = h.shaderPrograms.drawnode_wl._program,
|
||||
shu = sh.uniforms;
|
||||
sh = h.shaderPrograms.drawnode_wl._program;
|
||||
shu = sh.uniforms;
|
||||
|
||||
gl.uniform4fv(shu.lightsPositions._pName, this._lightsTransformedPositions);
|
||||
|
||||
@ -1181,7 +1183,7 @@ class Planet extends RenderNode {
|
||||
}
|
||||
|
||||
gl.enable(gl.POLYGON_OFFSET_FILL);
|
||||
for (j = 1; j < sl.length; j++) {
|
||||
for (let j = 1; j < sl.length; j++) {
|
||||
i = rn.length;
|
||||
gl.polygonOffset(0, -j);
|
||||
while (i--) {
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
import * as shaders from '../shaderProgram/skybox.js';
|
||||
import { RenderNode } from './RenderNode.js';
|
||||
|
||||
const RESOURCES_URL = "";
|
||||
|
||||
class SkyBox extends RenderNode {
|
||||
constructor(params) {
|
||||
super("skybox");
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @namespace og.shape
|
||||
*/
|
||||
@ -4,10 +4,10 @@
|
||||
|
||||
'use sctrict';
|
||||
|
||||
import * as planetSegmentHelper from '../planetSegment/planetSegmentHelper.js';
|
||||
import * as utils from '../utils/shared.js';
|
||||
import { Framebuffer } from '../webgl/Framebuffer.js';
|
||||
import { LonLat } from '../LonLat.js';
|
||||
import { PlanetSegmentHelper } from '../planetSegment/planetSegmentHelper.js';
|
||||
import { ShaderProgram } from '../webgl/ShaderProgram.js';
|
||||
import { types } from '../webgl/types.js';
|
||||
|
||||
@ -112,16 +112,16 @@ GeoImageCreator.prototype.remove = function (geoImage) {
|
||||
};
|
||||
|
||||
GeoImageCreator.prototype._initBuffers = function () {
|
||||
PlanetSegmentHelper.initIndexesTables(3);
|
||||
planetSegmentHelper.initIndexesTables(3);
|
||||
|
||||
this._framebuffer = new Framebuffer(this._handler, { width: 2, height: 2, useDepth: false });
|
||||
this._framebufferMercProj = new Framebuffer(this._handler, { width: 2, height: 2, useDepth: false });
|
||||
|
||||
var gs = this._gridSize;
|
||||
var gs1 = this._gridSize + 1;
|
||||
this._texCoordsBuffer = this._handler.createArrayBuffer(PlanetSegmentHelper.textureCoordsTable[gs], 2, gs1 * gs1);
|
||||
this._texCoordsBuffer = this._handler.createArrayBuffer(planetSegmentHelper.textureCoordsTable[gs], 2, gs1 * gs1);
|
||||
|
||||
var indexes = PlanetSegmentHelper.createSegmentIndexes(gs, [gs, gs, gs, gs]);
|
||||
var indexes = planetSegmentHelper.createSegmentIndexes(gs, [gs, gs, gs, gs]);
|
||||
this._indexBuffer = this._handler.createElementArrayBuffer(indexes, 1, indexes.length);
|
||||
|
||||
this._quadTexCoordsBuffer = this._handler.createArrayBuffer(new Float32Array([0, 1, 1, 1, 0, 0, 1, 0]), 2, 4);
|
||||
|
||||
@ -56,7 +56,7 @@ class ImageBitmapLoader {
|
||||
this._workers = new Array(options.numWorkers || NUM_WORKERS);
|
||||
this._counter = 0;
|
||||
|
||||
var p = new Blob([Program(options.maxRequests || MAX_REQUESTS)], { type: 'application/javascript' });
|
||||
var p = new Blob([program(options.maxRequests || MAX_REQUESTS)], { type: 'application/javascript' });
|
||||
|
||||
for (var i = 0; i < this._workers.length; i++) {
|
||||
this._workers[i] = new Worker(URL.createObjectURL(p));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user