@openglobus/og
Advanced tools
Comparing version 0.12.1 to 0.12.3
{ | ||
"name": "@openglobus/og", | ||
"version": "0.12.1", | ||
"version": "0.12.3", | ||
"description": "[OpenGlobus](http://www.openglobus.org/) is a javascript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers and 3d objects. It uses the WebGL technology, open source and completely free.", | ||
@@ -19,3 +19,3 @@ "directories": { | ||
"test_watch": "jest --env=jsdom --watch", | ||
"lint": "eslint src/og", | ||
"lint": "eslint -c ./.eslintrc.js src/og", | ||
"generate_types": "rm -rf types; tsc src/**/*.js --declaration --allowJs --emitDeclarationOnly --outDir types", | ||
@@ -22,0 +22,0 @@ "compile_js_as_ts": "tsc src/og/index.js --AllowJs --checkJs --outDir dist/@openglobus/src/" |
@@ -17,3 +17,4 @@ "use strict"; | ||
SIZE_BUFFER = 7, | ||
PICKINGCOLOR_BUFFER = 8; | ||
PICKINGCOLOR_BUFFER = 8, | ||
VISIBLE_BUFFER = 9; | ||
@@ -52,2 +53,3 @@ const setParametersToArray = (arr = [], index = 0, length, itemSize, ...params) => { | ||
this._pickingColorArr = [[]]; | ||
this._vehicleVisibleArr = [[]]; | ||
@@ -64,2 +66,3 @@ this._pitchRollBuffer = []; | ||
this._pickingColorBuffer = []; | ||
this._vehicleVisibleBuffer = []; | ||
@@ -77,2 +80,3 @@ this.__staticId = GeoObjectHandler._staticCounter++; | ||
this._buffersUpdateCallbacks[PITCH_ROLL_BUFFER] = this.createPitchRollBuffer; | ||
this._buffersUpdateCallbacks[VISIBLE_BUFFER] = this.createVisibleBuffer; | ||
@@ -107,2 +111,11 @@ this._changedBuffers = new Array(this._buffersUpdateCallbacks.length); | ||
createVisibleBuffer() { | ||
const h = this._renderer.handler; | ||
for (let i = 0, len = this._vehicleVisibleArr.length; i < len; i++) { | ||
this._vehicleVisibleBuffer && h.gl.deleteBuffer(this._vehicleVisibleBuffer[i]); | ||
this._vehicleVisibleArr[i] = makeArrayTyped(this._vehicleVisibleArr[i]); | ||
this._vehicleVisibleBuffer[i] = h.createArrayBuffer(this._vehicleVisibleArr[i], 1, this._vehicleVisibleArr[i].length); | ||
} | ||
} | ||
createSizeBuffer() { | ||
@@ -233,3 +246,3 @@ const h = this._renderer.handler; | ||
geoObject._tagIndex = tagData.iCounts - 1; | ||
if (geoObject._visibility) { | ||
if (!this._vertexArr[ti] || this._vertexArr[ti].length !== geoObject._vertices.length) { | ||
@@ -259,8 +272,7 @@ | ||
} | ||
} else { | ||
this._vertexArr[ti] = concatArrays( | ||
this._vertexArr[ti], | ||
setParametersToArray([], 0, geoObject._verticesCount * itemSize, 1, 0) | ||
); | ||
} | ||
this._vehicleVisibleArr[ti] = concatArrays( | ||
this._vehicleVisibleArr[ti], | ||
setParametersToArray([], 0, 1, 1, geoObject._visibility ? 1 : 0) | ||
); | ||
let x = geoObject._positionHigh.x, | ||
@@ -376,2 +388,5 @@ y = geoObject._positionHigh.y, | ||
gl.bindBuffer(gl.ARRAY_BUFFER, this._vehicleVisibleBuffer[ti]); | ||
gl.vertexAttribPointer(a.aDispose, this._vehicleVisibleBuffer[ti].itemSize, gl.FLOAT, false, 0, 0); | ||
gl.bindBuffer(gl.ARRAY_BUFFER, this._positionHighBuffer[ti]); | ||
@@ -514,2 +529,5 @@ gl.vertexAttribPointer( | ||
gl.bindBuffer(gl.ARRAY_BUFFER, this._vehicleVisibleBuffer[ti]); | ||
gl.vertexAttribPointer(a.aDispose, this._vehicleVisibleBuffer[ti].itemSize, gl.FLOAT, false, 0, 0); | ||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indicesBuffer[ti]); | ||
@@ -639,10 +657,8 @@ | ||
setVisibility(index, visibility) { | ||
const ob = this.getObjectByIndex(index); | ||
let vArr; | ||
if (visibility) { | ||
vArr = ob._vertices; | ||
} else { | ||
vArr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
} | ||
this.setVertexArr(index, vArr); | ||
const ob = this.getObjectByIndex(index), | ||
ti = this.getTagIndexByObjectIndex(index); | ||
setParametersToArray(this._vehicleVisibleArr[ti], ob._tagIndex, 1, 1, visibility ? 1 : 0); | ||
this._changedBuffers[VISIBLE_BUFFER] = true; | ||
} | ||
@@ -766,2 +782,3 @@ | ||
this._pickingColorArr = null; | ||
this._vehicleVisibleArr = null; | ||
@@ -778,2 +795,3 @@ this._pitchRollArr = [new Float32Array()]; | ||
this._pickingColorArr = [new Float32Array()]; | ||
this._vehicleVisibleArr = [new Int8Array()]; | ||
@@ -895,2 +913,3 @@ this._removeGeoObjects(); | ||
this._sizeArr[ti] = spliceArray(this._sizeArr[ti], i, 1); | ||
this._vehicleVisibleArr[ti] = spliceArray(this._vehicleVisibleArr[ti], i, 1); | ||
@@ -897,0 +916,0 @@ this._removeIndices(geoObject); |
@@ -6,2 +6,3 @@ /** | ||
"use strict"; | ||
import { Billboard } from "../entity/Billboard.js"; | ||
import { Entity } from "../entity/Entity.js"; | ||
@@ -44,8 +45,10 @@ import { Extent } from "../Extent.js"; | ||
const raw = Array.from(xmlDoc.getElementsByTagName("coordinates")); | ||
const coordinates = raw.map((item) => | ||
item.textContent | ||
.trim() | ||
.replace(/\n/g, " ") | ||
.split(" ") | ||
.map((co) => co.split(",").map(parseFloat)) | ||
const rawText = raw.map(item => item.textContent.trim()); | ||
const coordinates = rawText.map(item => | ||
item | ||
.replace(/\n/g, " ") | ||
.replace(/\t/g, " ") | ||
.replace(/ +/g," ") | ||
.split(" ") | ||
.map((co) => co.split(",").map(parseFloat)) | ||
); | ||
@@ -126,5 +129,7 @@ return coordinates; | ||
* @param {File[]} kmls | ||
* @param {string} [color] | ||
* @param {Billboard} [billboard] | ||
* @returns {Promise<{entities: Entity[], extent: Extent}>} | ||
*/ | ||
async addKmlFromFiles(kmls) { | ||
async addKmlFromFiles(kmls, color = null, billboard = null) { | ||
const kmlObjs = await Promise.all(kmls.map(this._getXmlContent)); | ||
@@ -134,4 +139,4 @@ const coordonates = kmlObjs.map(this._extractCoordonatesFromKml); | ||
coordonates, | ||
this._color, | ||
this._billboard | ||
color || this._color, | ||
billboard || this._billboard | ||
); | ||
@@ -175,5 +180,7 @@ this._extent = this._expandExtents(this._extent, extent); | ||
* @param {string} url - Url of the KML to display. './myFile.kml' or 'http://mySite/myFile.kml' for example. | ||
* @param {string} [color] | ||
* @param {Billboard} [billboard] | ||
* @returns {Promise<{entities: Entity[], extent: Extent}>} | ||
*/ | ||
async addKmlFromUrl(url) { | ||
async addKmlFromUrl(url, color = null, billboard = null) { | ||
const kml = await this._getKmlFromUrl(url); | ||
@@ -183,4 +190,4 @@ const coordonates = this._extractCoordonatesFromKml(kml); | ||
[coordonates], | ||
this._color, | ||
this._billboard | ||
color || this._color, | ||
billboard || this._billboard | ||
); | ||
@@ -187,0 +194,0 @@ this._extent = this._expandExtents(this._extent, extent); |
@@ -501,2 +501,5 @@ /** | ||
this._planet.updateVisibleLayers(); | ||
if (visibility) { | ||
this._planet._preLoad(); | ||
} | ||
} | ||
@@ -503,0 +506,0 @@ this.events.dispatch(this.events.visibilitychange, this); |
@@ -846,16 +846,6 @@ /** | ||
_preLoad() { | ||
this._clearRenderedNodeList(); | ||
this._skipPreRender = false; | ||
// Zoom 0 | ||
this._quadTree.segment.passReady = true; | ||
this._quadTree.renderNode(true); | ||
this._normalMapCreator.drawSingle(this._quadTree.segment); | ||
// Zoom 1 | ||
for (let i = 0; i < this._quadTree.nodes.length; i++) { | ||
this._quadTree.nodes[i].segment.passReady = true; | ||
this._quadTree.nodes[i].renderNode(true); | ||
this._normalMapCreator.drawSingle(this._quadTree.nodes[i].segment); | ||
} | ||
// Same for poles | ||
@@ -881,2 +871,14 @@ this._quadTreeNorth.segment.passReady = true; | ||
} | ||
// Zoom 1 | ||
for (let i = 0; i < this._quadTree.nodes.length; i++) { | ||
this._quadTree.nodes[i].segment.passReady = true; | ||
this._quadTree.nodes[i].renderNode(true); | ||
this._normalMapCreator.drawSingle(this._quadTree.nodes[i].segment); | ||
} | ||
// Zoom 0 | ||
this._quadTree.segment.passReady = true; | ||
this._quadTree.renderNode(true); | ||
this._normalMapCreator.drawSingle(this._quadTree.segment); | ||
} | ||
@@ -960,4 +962,2 @@ | ||
this._preLoad(); | ||
} else if (li._fading && li._fadingOpacity > 0) { | ||
@@ -964,0 +964,0 @@ if (li.hasImageryTiles()) { |
@@ -33,3 +33,4 @@ /** | ||
aColor: { type: "vec4", divisor: 1 }, | ||
aScale: { type: "float", divisor: 1 } | ||
aScale: { type: "float", divisor: 1 }, | ||
aDispose: { type: "float", divisor: 1 } | ||
}, | ||
@@ -46,2 +47,3 @@ vertexShader: `precision highp float; | ||
attribute float aScale; | ||
attribute float aDispose; | ||
@@ -59,2 +61,3 @@ uniform vec3 uScaleByDistance; | ||
varying vec4 vColor; | ||
varying float vDispose; | ||
@@ -65,2 +68,3 @@ const float RADIANS = 3.141592653589793 / 180.0; | ||
vDispose = aDispose; | ||
vColor = aColor; | ||
@@ -98,3 +102,3 @@ float roll = aPitchRoll.y * RADIANS; | ||
gl_Position = projectionMatrix * vPosition; | ||
gl_Position = mix(vec4(0.0, 0.0, 0.0, 0.0), projectionMatrix * vPosition, aDispose); | ||
}`, | ||
@@ -143,3 +147,3 @@ fragmentShader: `precision highp float; | ||
eyePositionLow: "vec3", | ||
pickingScale: "float", | ||
pickingScale: "float" | ||
@@ -154,3 +158,4 @@ }, | ||
aPickingColor: { type: "vec3", divisor: 1 }, | ||
aScale: { type: "float", divisor: 1 } | ||
aScale: { type: "float", divisor: 1 }, | ||
aDispose: { type: "float", divisor: 1 } | ||
}, | ||
@@ -166,2 +171,3 @@ vertexShader: `precision highp float; | ||
attribute float aScale; | ||
attribute float aDispose; | ||
@@ -176,2 +182,3 @@ uniform vec3 uScaleByDistance; | ||
varying float vDispose; | ||
varying vec3 vColor; | ||
@@ -183,2 +190,3 @@ | ||
vDispose = aDispose; | ||
vColor = aPickingColor; | ||
@@ -213,3 +221,3 @@ float roll = aPitchRoll.y * RADIANS; | ||
gl_Position = projectionMatrix *viewMatrixRTE * vec4(highDiff + lowDiff, 1.0); | ||
gl_Position = mix(vec4(0.0, 0.0, 0.0, 0.0), projectionMatrix *viewMatrixRTE * vec4(highDiff + lowDiff, 1.0), aDispose); | ||
}`, | ||
@@ -219,5 +227,6 @@ fragmentShader: | ||
varying vec3 vColor; | ||
varying float vDispose; | ||
void main () { | ||
gl_FragColor = vec4(vColor, 1.0); | ||
gl_FragColor = vec4(vColor, vDispose); | ||
}` | ||
}); |
11609001
345
75617