1) Migrate to rollup.

2) Eslint cleanup.
3) Fixed layer zoom visibility.
This commit is contained in:
Zemledelec 2020-02-16 21:53:14 +03:00
parent 708ec265df
commit 72cd6bcc63
132 changed files with 2074 additions and 13886 deletions

38
.eslintrc.js Normal file
View File

@ -0,0 +1,38 @@
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": "standard",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"semi": [2, "always"],
"indent": "off",
"padded-blocks": "off",
"no-trailing-spaces": "off",
"one-var": "off",
"camelcase": "off",
"prefer-const": "off",
"quotes": "off",
"space-before-function-paren": "off",
"eol-last": "off",
"standard/no-callback-literal": "off",
"eqeqeq": "off",
"no-return-assign": "off",
"no-undef": "off",
"no-multi-spaces": "off",
"dot-notation": "off",
"no-useless-constructor": "off",
"no-void": "off",
"spaced-comment": "off",
"quote-props": "off",
"no-useless-escape": "off"
}
};

2
.gitignore vendored
View File

@ -5,6 +5,8 @@ Thumbs.db
Release
Debug
eslint
node_modules
.eslintrc

View File

@ -1,25 +0,0 @@
{
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
]
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
eslint -c .eslintrc.json -o errors.html -f html ../src/og/*.*

409
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "og",
"version": "0.1.1",
"version": "0.1.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -1415,6 +1415,16 @@
"integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=",
"dev": true
},
"array.prototype.flat": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz",
"integrity": "sha512-gBlRZV0VSmfPIeWfuuy56XZMvbVfbEUnOXUvt3F/eUUUSyzlgLxhEX4YAEpxNAogRGehPSnfXyPtYyKAhkzQhQ==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.17.0-next.1"
}
},
"asn1": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
@ -2722,6 +2732,12 @@
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"contains-path": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz",
"integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=",
"dev": true
},
"content-disposition": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
@ -3245,21 +3261,6 @@
"esutils": "^2.0.2"
}
},
"glob-parent": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz",
"integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==",
"dev": true,
"requires": {
"is-glob": "^4.0.1"
}
},
"ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
"integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
"dev": true
},
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
@ -3274,12 +3275,289 @@
"integrity": "sha1-oJCtwTspNeP0OzzQSKknAWVOWtU=",
"dev": true
},
"eslint-config-standard": {
"version": "14.1.0",
"resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-14.1.0.tgz",
"integrity": "sha512-EF6XkrrGVbvv8hL/kYa/m6vnvmUT+K82pJJc4JJVMM6+Qgqh0pnwprSxdduDLB9p/7bIxD+YV5O0wfb8lmcPbA==",
"dev": true
},
"eslint-import-resolver-node": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.3.tgz",
"integrity": "sha512-b8crLDo0M5RSe5YG8Pu2DYBj71tSB6OvXkfzwbJU2w7y8P4/yo0MyF8jU26IEuEuHF2K5/gcAJE3LhQGqBBbVg==",
"dev": true,
"requires": {
"debug": "^2.6.9",
"resolve": "^1.13.1"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dev": true,
"requires": {
"ms": "2.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
}
}
},
"eslint-module-utils": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.5.2.tgz",
"integrity": "sha512-LGScZ/JSlqGKiT8OC+cYRxseMjyqt6QO54nl281CK93unD89ijSeRV6An8Ci/2nvWVKe8K/Tqdm75RQoIOCr+Q==",
"dev": true,
"requires": {
"debug": "^2.6.9",
"pkg-dir": "^2.0.0"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dev": true,
"requires": {
"ms": "2.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
}
}
},
"eslint-plugin-es": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.0.tgz",
"integrity": "sha512-6/Jb/J/ZvSebydwbBJO1R9E5ky7YeElfK56Veh7e4QGFHCXoIXGH9HhVz+ibJLM3XJ1XjP+T7rKBLUa/Y7eIng==",
"dev": true,
"requires": {
"eslint-utils": "^2.0.0",
"regexpp": "^3.0.0"
},
"dependencies": {
"eslint-utils": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz",
"integrity": "sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA==",
"dev": true,
"requires": {
"eslint-visitor-keys": "^1.1.0"
}
},
"regexpp": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.0.0.tgz",
"integrity": "sha512-Z+hNr7RAVWxznLPuA7DIh8UNX1j9CDrUQxskw9IrBE1Dxue2lyXT+shqEIeLUjrokxIP8CMy1WkjgG3rTsd5/g==",
"dev": true
}
}
},
"eslint-plugin-eslint-plugin": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-eslint-plugin/-/eslint-plugin-eslint-plugin-2.1.0.tgz",
"integrity": "sha512-kT3A/ZJftt28gbl/Cv04qezb/NQ1dwYIbi8lyf806XMxkus7DvOVCLIfTXMrorp322Pnoez7+zabXH29tADIDg==",
"dev": true
},
"eslint-plugin-import": {
"version": "2.20.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.1.tgz",
"integrity": "sha512-qQHgFOTjguR+LnYRoToeZWT62XM55MBVXObHM6SKFd1VzDcX/vqT1kAz8ssqigh5eMj8qXcRoXXGZpPP6RfdCw==",
"dev": true,
"requires": {
"array-includes": "^3.0.3",
"array.prototype.flat": "^1.2.1",
"contains-path": "^0.1.0",
"debug": "^2.6.9",
"doctrine": "1.5.0",
"eslint-import-resolver-node": "^0.3.2",
"eslint-module-utils": "^2.4.1",
"has": "^1.0.3",
"minimatch": "^3.0.4",
"object.values": "^1.1.0",
"read-pkg-up": "^2.0.0",
"resolve": "^1.12.0"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dev": true,
"requires": {
"ms": "2.0.0"
}
},
"doctrine": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz",
"integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=",
"dev": true,
"requires": {
"esutils": "^2.0.2",
"isarray": "^1.0.0"
}
},
"find-up": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz",
"integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=",
"dev": true,
"requires": {
"locate-path": "^2.0.0"
}
},
"load-json-file": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz",
"integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.2",
"parse-json": "^2.2.0",
"pify": "^2.0.0",
"strip-bom": "^3.0.0"
}
},
"locate-path": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz",
"integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=",
"dev": true,
"requires": {
"p-locate": "^2.0.0",
"path-exists": "^3.0.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
},
"p-limit": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz",
"integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==",
"dev": true,
"requires": {
"p-try": "^1.0.0"
}
},
"p-locate": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz",
"integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
"dev": true,
"requires": {
"p-limit": "^1.1.0"
}
},
"p-try": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
"integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=",
"dev": true
},
"parse-json": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
"integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
"dev": true,
"requires": {
"error-ex": "^1.2.0"
}
},
"path-type": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz",
"integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=",
"dev": true,
"requires": {
"pify": "^2.0.0"
}
},
"pify": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
},
"read-pkg": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz",
"integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=",
"dev": true,
"requires": {
"load-json-file": "^2.0.0",
"normalize-package-data": "^2.3.2",
"path-type": "^2.0.0"
}
},
"read-pkg-up": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz",
"integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=",
"dev": true,
"requires": {
"find-up": "^2.0.0",
"read-pkg": "^2.0.0"
}
}
}
},
"eslint-plugin-node": {
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.0.0.tgz",
"integrity": "sha512-chUs/NVID+sknFiJzxoN9lM7uKSOEta8GC8365hw1nDfwIPIjjpRSwwPvQanWv8dt/pDe9EV4anmVSwdiSndNg==",
"dev": true,
"requires": {
"eslint-plugin-es": "^3.0.0",
"eslint-utils": "^2.0.0",
"ignore": "^5.1.1",
"minimatch": "^3.0.4",
"resolve": "^1.10.1",
"semver": "^6.1.0"
},
"dependencies": {
"eslint-utils": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz",
"integrity": "sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA==",
"dev": true,
"requires": {
"eslint-visitor-keys": "^1.1.0"
}
},
"ignore": {
"version": "5.1.4",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.4.tgz",
"integrity": "sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==",
"dev": true
},
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"dev": true
}
}
},
"eslint-plugin-promise": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz",
"integrity": "sha512-VoM09vT7bfA7D+upt+FjeBO5eHIJQBUWki1aPvB+vbNiHS3+oGIJGIeyBtKQTME6UPXXy3vV07OL1tHd3ANuDw==",
"dev": true
},
"eslint-plugin-react": {
"version": "7.17.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.17.0.tgz",
@ -3298,6 +3576,12 @@
"resolve": "^1.13.1"
}
},
"eslint-plugin-standard": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-4.0.1.tgz",
"integrity": "sha512-v/KBnfyaOMPmZc/dmc6ozOdWqekGp7bBGq4jLAecEfPGmfKiWS4sA8sC0LqiV9w5qmXAtXVn4M3p1jSyhY85SQ==",
"dev": true
},
"eslint-scope": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz",
@ -3341,9 +3625,9 @@
"dev": true
},
"esquery": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz",
"integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.1.0.tgz",
"integrity": "sha512-MxYW9xKmROWF672KqjO75sszsA8Mxhw06YFeS5VHlB98KDHbOSurm3ArsjO60Eaf3QmGMCP1yn+0JQkNLo/97Q==",
"dev": true,
"requires": {
"estraverse": "^4.0.0"
@ -3625,9 +3909,9 @@
}
},
"figures": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.1.0.tgz",
"integrity": "sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg==",
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
"integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==",
"dev": true,
"requires": {
"escape-string-regexp": "^1.0.5"
@ -4388,6 +4672,15 @@
"path-is-absolute": "^1.0.0"
}
},
"glob-parent": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz",
"integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==",
"dev": true,
"requires": {
"is-glob": "^4.0.1"
}
},
"globals": {
"version": "12.3.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-12.3.0.tgz",
@ -4621,6 +4914,12 @@
"safer-buffer": ">= 2.1.2 < 3"
}
},
"ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
"integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
"dev": true
},
"import-fresh": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz",
@ -4724,9 +5023,9 @@
"dev": true
},
"inquirer": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.1.tgz",
"integrity": "sha512-V1FFQ3TIO15det8PijPLFR9M9baSlnRs9nL7zWu1MNVA2T9YVl9ZbrHJhYs7e9X8jeMZ3lr2JH/rdHFgNCBdYw==",
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.4.tgz",
"integrity": "sha512-Bu5Td5+j11sCkqfqmUTiwv+tWisMtP0L7Q8WrqA2C/BbBhy1YTdFrvjjlrKq8oagA/tLQBski2Gcx/Sqyi2qSQ==",
"dev": true,
"requires": {
"ansi-escapes": "^4.2.1",
@ -7158,6 +7457,60 @@
"node-modules-regexp": "^1.0.0"
}
},
"pkg-dir": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz",
"integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=",
"dev": true,
"requires": {
"find-up": "^2.1.0"
},
"dependencies": {
"find-up": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz",
"integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=",
"dev": true,
"requires": {
"locate-path": "^2.0.0"
}
},
"locate-path": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz",
"integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=",
"dev": true,
"requires": {
"p-locate": "^2.0.0",
"path-exists": "^3.0.0"
}
},
"p-limit": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz",
"integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==",
"dev": true,
"requires": {
"p-try": "^1.0.0"
}
},
"p-locate": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz",
"integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
"dev": true,
"requires": {
"p-limit": "^1.1.0"
}
},
"p-try": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
"integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=",
"dev": true
}
}
},
"pn": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/pn/-/pn-1.1.0.tgz",
@ -8794,9 +9147,9 @@
"dev": true
},
"v8-compile-cache": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.0.3.tgz",
"integrity": "sha512-CNmdbwQMBjwr9Gsmohvm0pbL954tJrNzf6gWL3K+QMQf00PF7ERGrEiLgjuU3mKreLC2MeGhUsNV9ybTbLgd3w==",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz",
"integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==",
"dev": true
},
"validate-npm-package-license": {

View File

@ -1,6 +1,6 @@
{
"name": "og",
"version": "0.1.1",
"version": "0.1.2",
"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.",
"directories": {
"example": "./sandbox"
@ -11,7 +11,8 @@
"build": "node_modules/.bin/rollup -c",
"webgl": "node_modules/.bin/rollup -c --environment entry:webgl",
"core": "node_modules/.bin/rollup -c --environment entry:core",
"test": "jest --coverage"
"test": "jest --coverage",
"lint": "node_modules/.bin/eslint src/og"
},
"repository": {
"type": "git",
@ -32,7 +33,12 @@
"enhanced-resolve": "^4.1.1",
"eslint": "^6.8.0",
"eslint-config-defaults": "^9.0.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.3.0",
"eslint-plugin-standard": "^4.0.1",
"jaguarjs-jsdoc": "^1.1.0",
"jest": "^24.9.0",
"jsdoc": "^3.6.3",

View File

@ -1,15 +1,15 @@
'use strict';
import { Globe } from '../../src/og/Globe.js';
import { GlobusTerrain } from '../../src/og/terrain/GlobusTerrain.js';
// import { GlobusTerrain } from '../../src/og/terrain/GlobusTerrain.js';
import { MapboxTerrain } from '../../src/og/terrain/MapboxTerrain.js';
import { XYZ } from '../../src/og/layer/XYZ.js';
import { CanvasTiles } from '../../src/og/layer/CanvasTiles.js';
import { Vector } from '../../src/og/layer/Vector.js';
import { Entity } from '../../src/og/entity/Entity.js';
// import { Vector } from '../../src/og/layer/Vector.js';
// import { Entity } from '../../src/og/entity/Entity.js';
import { DebugInfo } from '../../src/og/control/DebugInfo.js';
import { ToggleWireframe } from '../../src/og/control/ToggleWireframe.js';
import * as math from '../../src/og/math.js';
// import * as math from '../../src/og/math.js';
import { LayerSwitcher } from '../../src/og/control/LayerSwitcher.js';
let cnv = document.createElement("canvas");
@ -21,10 +21,10 @@ const tg = new CanvasTiles("Tile grid", {
visibility: true,
isBaseLayer: true,
drawTile: function (material, applyCanvas) {
//Clear canvas
// Clear canvas
ctx.clearRect(0, 0, cnv.width, cnv.height);
//Draw border
// Draw border
ctx.beginPath();
ctx.rect(0, 0, cnv.width, cnv.height);
ctx.lineWidth = 2;
@ -33,7 +33,7 @@ const tg = new CanvasTiles("Tile grid", {
let size;
//Draw text
// Draw text
if (material.segment.tileZoom > 17) {
size = "18";
} else if (material.segment.tileZoom > 14) {
@ -46,31 +46,30 @@ const tg = new CanvasTiles("Tile grid", {
ctx.textAlign = 'center';
ctx.fillText(material.segment.tileX + "," + material.segment.tileY + "," + material.segment.tileZoom, cnv.width / 2, cnv.height / 2);
//Draw canvas tile
// Draw canvas tile
applyCanvas(cnv);
}
});
let osm = new XYZ("OSM", {
'specular': [0.0003, 0.00012, 0.00001],
'shininess': 20,
'diffuse': [0.89, 0.9, 0.83],
'isBaseLayer': true,
'url': "//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
'visibility': true,
'attribution': 'Data @ OpenStreetMap contributors, ODbL'
specular: [0.0003, 0.00012, 0.00001],
shininess: 20,
diffuse: [0.89, 0.9, 0.83],
isBaseLayer: true,
url: "//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
visibility: true,
attribution: 'Data @ OpenStreetMap contributors, ODbL'
});
window.globe = new Globe({
'name': "Earth",
'target': "earth",
'terrain': new MapboxTerrain(),
'layers': [osm, tg]
name: "Earth",
target: "earth",
terrain: new MapboxTerrain(),
layers: [osm, tg]
});
globe.planet.addControl(new DebugInfo());
globe.planet.addControl(new ToggleWireframe({
window.globe.planet.addControl(new DebugInfo());
window.globe.planet.addControl(new ToggleWireframe({
isActive: false
}));
globe.planet.addControl(new LayerSwitcher());
window.globe.planet.addControl(new LayerSwitcher());

View File

@ -59,7 +59,7 @@ class Events {
*/
registerNames(eventNames) {
for (var i = 0; i < eventNames.length; i++) {
this[eventNames[i]] = { "active": true, "handlers": [] };
this[eventNames[i]] = { active: true, handlers: [] };
this._eventNames.push(eventNames[i]);
}
}
@ -79,7 +79,7 @@ class Events {
var ogid = stamp(obj);
var st = this._getStamp(name, this.__id, ogid);//name + "_" + this.__id + "_" + ogid;
var st = this._getStamp(name, this.__id, ogid);
if (!this._stampCache[st]) {
this._stampCache[st] = ogid;
@ -105,7 +105,6 @@ class Events {
binaryInsert(this[name].handlers, c, (a, b) => {
return b._openglobus_priority - a._openglobus_priority;
});
//this[name].handlers.unshift(c);
}
}
}
@ -118,7 +117,7 @@ class Events {
*/
off(name, callback) {
if (callback) {
var st = this._getStamp(name, this.__id, callback._openglobus_id);//name + "_" + this.__id + "_" + callback._openglobus_id;
var st = this._getStamp(name, this.__id, callback._openglobus_id);
if (callback._openglobus_id && this._stampCache[st]) {
var h = this[name].handlers;
var i = h.length;

View File

@ -182,7 +182,7 @@ Extent.prototype.getWidth = function () {
* @return {number} Extent height.
*/
Extent.prototype.getHeight = function () {
return this.northEast.lat - this.southWest.lat
return this.northEast.lat - this.southWest.lat;
};
/**

View File

@ -23,9 +23,11 @@ class Frustum {
* @type {Array.<Array.<number>>}
*/
this._f = new Array(6);
for (var i = 0; i < 6; i++)
for (var i = 0; i < 6; i++) {
this._f[i] = new Array(4);
}
}
/**
* Normalize frustum plane.
* @static
@ -125,8 +127,9 @@ class Frustum {
var d;
for (var p = 0; p < 6; p++) {
d = point.dotArr(this._f[p]) + this._f[p][3];
if (d <= 0)
if (d <= 0) {
return false;
}
}
return true;
}
@ -206,17 +209,18 @@ class Frustum {
for (var k = 0; k < 8 && (cin === 0 || cout === 0); k++) {
var d = box.vertices[k].dotArr(this._f[i]) + this._f[i][3];
if (d < 0)
if (d < 0) {
cout++;
else
} else {
cin++;
}
}
if (cin === 0)
if (cin === 0) {
return false;
else if (cout > 0)
} else if (cout > 0) {
result = true;
}
}
return result;

View File

@ -61,7 +61,7 @@ const PLANET_NAME_PREFIX = "globus_planet_";
class Globe {
constructor(options) {
//Canvas creation.
// Canvas creation
var _canvasId = CANVAS_ID_PREFIX + Globe._staticCounter++;
this._canvas = document.createElement("canvas");
@ -92,14 +92,14 @@ class Globe {
*/
this.renderer = new Renderer(
new Handler(_canvasId, {
'context': {
'alpha': false,
'antialias': false,
'powerPreference': "high-performance"
context: {
alpha: false,
antialias: false,
powerPreference: "high-performance"
}
}), {
'autoActivate': false
});
autoActivate: false
});
this.renderer.initialize();
this.renderer.div = this.div;
this.renderer.div.attributions = document.createElement("div");
@ -110,7 +110,7 @@ class Globe {
this.div.appendChild(this.renderer.div.attributions);
}
//Skybox
// Skybox
if (options.skybox) {
this.renderer.addNode(options.skybox);
}
@ -129,13 +129,13 @@ class Globe {
* @type {og.scene.Planet|og.scene.PlanetAtmosphere}
*/
//TODO:
// TODO:
} else {
this.planet = new Planet(this._planetName, options.ellipsoid ? options.ellipsoid : wgs84);
}
//Attach terrain provider
// Attach terrain provider
if (options.terrain) {
this.planet.setTerrain(options.terrain);
} else {
@ -144,9 +144,7 @@ class Globe {
this.renderer.addNode(this.planet);
this.sun;
//Add controls
// Add controls
if (options.controls) {
this.planet.addControls(options.controls);
} else {
@ -181,7 +179,7 @@ class Globe {
this.planet.addLayers(options.layers);
}
//TODO: view center, altitude, extent
// TODO: view center, altitude, extent
if (options.viewExtent) {
this.planet.viewToExtent(options.viewExtent);
}
@ -190,7 +188,7 @@ class Globe {
this._fadeHandler = null;
this._stopHandler = null;
//Run!
// Run!
if (options.autoActivate || isEmpty(options.autoActivate)) {
this.renderer.start();
this.fadeIn();

View File

@ -187,7 +187,7 @@ class ImageCanvas {
that.resize(img.width, img.height);
that._context.drawImage(img, 0, 0, img.width, img.height);
callback && callback(img);
}
};
img.src = url;
}
@ -199,9 +199,9 @@ class ImageCanvas {
var img = this.getImage();
var dataUrl = img.src;
var windowContent = '<!DOCTYPE html>';
windowContent += '<html>'
windowContent += '<html>';
windowContent += '<head><title>Print</title></head>';
windowContent += '<body>'
windowContent += '<body>';
windowContent += '<img src="' + dataUrl + '">';
windowContent += '</body>';
windowContent += '</html>';
@ -212,7 +212,6 @@ class ImageCanvas {
printWin.focus();
}
destroy() {
this._canvas.width = 1;
this._canvas.height = 1;

View File

@ -6,21 +6,12 @@
import * as mercator from './mercator.js';
const HALF_PI = Math.PI * 0.5;
const PI_BY_180 = Math.PI / 180.0;
const INV_PI_BY_180 = 180.0 / Math.PI;
const INV_PI_BY_360 = INV_PI_BY_180 * 2.0;
const PI_BY_360 = Math.PI / 360.0;
const INV_PI_BY_180_HALF_PI = INV_PI_BY_180 * HALF_PI;
/**
* Represents a geographical point with a certain latitude, longitude and height.
* @class
@ -167,7 +158,6 @@ LonLat.prototype.forwardMercatorEPS01 = function () {
Math.log(Math.tan((90.0 + lat) * PI_BY_360)) * mercator.POLE_BY_PI);
};
/**
* Converts from mercator coordinates.
* @public

View File

@ -9,7 +9,7 @@ class QueueArray {
this.length = 0;
}
reset(){
reset() {
this._popIndex = parseInt(this._size * 0.5);
this._shiftIndex = this._popIndex;
this.length = 0;
@ -31,7 +31,7 @@ class QueueArray {
pop() {
if (this.length) {
this.length--;
var res = this._array[--this._popIndex]
var res = this._array[--this._popIndex];
this._array[this._popIndex] = null;
if (!this._array[this._popIndex - 1]) {
this._popIndex = parseInt(this._size * 0.5);

View File

@ -90,8 +90,8 @@ const defaultParams = {
function createXMLHttp() {
var xhr = null;
if (typeof XMLHttpRequest !== undefined) {
xhr = new XMLHttpRequest;
if (typeof XMLHttpRequest != "undefined") {
xhr = new XMLHttpRequest();
return xhr;
} else if (window.ActiveXObject) {
var ieXMLHttpVersions = ['MSXML2.XMLHttp.5.0', 'MSXML2.XMLHttp.4.0', 'MSXML2.XMLHttp.3.0', 'MSXML2.XMLHttp', 'Microsoft.XMLHttp'];
@ -100,7 +100,7 @@ function createXMLHttp() {
xhr = new ActiveXObject(ieXMLHttpVersions[i]);
return xhr;
} catch (e) {
console.log('error: og.ajax.createXMLHttp creation filed.');
throw new Error('og.ajax.createXMLHttp creation failed.');
}
}
}
@ -166,21 +166,23 @@ ajax.request = function (url, params) {
xhr.open(p.type, url, p.async);
}
if (p.async)
if (p.async) {
xhr.responseType = p.responseType;
}
xhr.overrideMimeType("text/plain");
xhr.onreadystatechange = function () {
if (xhr.readyState === ajax.ReadyState.Complete) {
if (xhr.status === ajax.Status.OK) {
if (params.success)
if (params.success) {
/**
* Success callback.
* @callback ajax.Xhr~successCallback
* @param {Object} Response data
*/
params.success.call(params.sender || customXhr, xhr.response);
}
} else if (xhr.aborted) {
/**
* Abort callback.
@ -202,7 +204,7 @@ ajax.request = function (url, params) {
xhr.onreadystatechange = null;
xhr = null;
} else {
//still loading
// still loading
}
};

View File

@ -1,10 +1,5 @@
/**
* @module og/astro/astro
*/
'use strict';
import * as jd from './jd.js';
/**

View File

@ -4,7 +4,6 @@
'use strict';
import * as jd from './jd.js';
import * as math from '../math.js';
import * as astro from './astro.js';
@ -17,7 +16,7 @@ import { Vec3 } from '../math/Vec3.js';
* @returns {og.Vec3} - Sun geocentric coordinates.
*/
export function getSunPosition(jDate) {
//http://stjarnhimlen.se/comp/tutorial.html
// http://stjarnhimlen.se/comp/tutorial.html
// a Mean distance, or semi-major axis
// e Eccentricity
// T Time at perihelion
@ -71,31 +70,31 @@ export function getSunPosition(jDate) {
var d = jDate - jd.J2000;
var w = 282.9404 + 4.70935E-5 * d; //longitude of perihelion
var a = 1.000000; //mean distance, a.u.
var e = 0.016709 - 1.151E-9 * d; //eccentricity
var M = math.rev(356.0470 + 0.9856002585 * d); //mean anomaly
var w = 282.9404 + 4.70935E-5 * d; // longitude of perihelion
// var a = 1.000000; // mean distance, a.u.
var e = 0.016709 - 1.151E-9 * d; // eccentricity
var M = math.rev(356.0470 + 0.9856002585 * d); // mean anomaly
var oblecl = astro.J2000_OBLIQUITY - 3.563E-7 * d; //obliquity of the ecliptic
var oblecl = astro.J2000_OBLIQUITY - 3.563E-7 * d; // obliquity of the ecliptic
var L = math.rev(w + M); //Sun's mean longitude
// var L = math.rev(w + M); // Sun's mean longitude
var E = M + math.DEGREES * e * Math.sin(M * math.RADIANS) * (1 + e * Math.cos(M * math.RADIANS)); //eccentric anomaly
var E = M + math.DEGREES * e * Math.sin(M * math.RADIANS) * (1 + e * Math.cos(M * math.RADIANS)); // eccentric anomaly
//Sun rectangular coordiantes, where the X axis points towards the perihelion
// Sun rectangular coordiantes, where the X axis points towards the perihelion
var x = Math.cos(E * math.RADIANS) - e;
var y = Math.sin(E * math.RADIANS) * Math.sqrt(1 - e * e);
var r = Math.sqrt(x * x + y * y); // distance
var r = Math.sqrt(x * x + y * y); // distance
var v = Math.atan2(y, x) * math.DEGREES; // true anomaly
var lon = math.rev(v + w); //longitude of the Sun
var lon = math.rev(v + w); // longitude of the Sun
//the Sun's ecliptic rectangular coordinates
// the Sun's ecliptic rectangular coordinates
x = r * Math.cos(lon * math.RADIANS);
y = r * Math.sin(lon * math.RADIANS);
//We use oblecl, and rotate these coordinates
// We use oblecl, and rotate these coordinates
var xequat = x;
var yequat = y * Math.cos(oblecl * math.RADIANS);
var zequat = y * Math.sin(oblecl * math.RADIANS);
@ -105,7 +104,7 @@ export function getSunPosition(jDate) {
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
//var RA = Math.atan2(yequat, xequat) * math.DEGREES;
//var Decl = Math.atan2(zequat, Math.sqrt(xequat * xequat + yequat * yequat)) * math.DEGREES;
// Convert to RA and Decl
// var RA = Math.atan2(yequat, xequat) * math.DEGREES;
// var Decl = Math.atan2(zequat, Math.sqrt(xequat * xequat + yequat * yequat)) * math.DEGREES;
};

View File

@ -475,39 +475,39 @@ export function daysToSeconds(d) {
function __ls(jd, leapSeconds) {
return {
"jd": jd,
"leapSeconds": leapSeconds
jd: jd,
leapSeconds: leapSeconds
};
};
const leapSecondsTable = [
__ls(2441317.5, 10.0), // 1972-01-01T00:00:00.000Z
__ls(2441499.5, 11.0), // 1972-07-01T00:00:00.000Z
__ls(2441683.5, 12.0), // 1973-01-01T00:00:00.000Z
__ls(2442048.5, 13.0), // 1974-01-01T00:00:00.000Z
__ls(2442413.5, 14.0), // 1975-01-01T00:00:00.000Z
__ls(2442778.5, 15.0), // 1976-01-01T00:00:00.000Z
__ls(2443144.5, 16.0), // 1977-01-01T00:00:00.000Z
__ls(2443509.5, 17.0), // 1978-01-01T00:00:00.000Z
__ls(2443874.5, 18.0), // 1979-01-01T00:00:00.000Z
__ls(2444239.5, 19.0), // 1980-01-01T00:00:00.000Z
__ls(2444786.5, 20.0), // 1981-07-01T00:00:00.000Z
__ls(2445151.5, 21.0), // 1982-07-01T00:00:00.000Z
__ls(2445516.5, 22.0), // 1983-01-01T00:00:00.000Z
__ls(2446247.5, 23.0), // 1985-07-01T00:00:00.000Z
__ls(2447161.5, 24.0), // 1988-01-01T00:00:00.000Z
__ls(2447892.5, 25.0), // 1990-01-01T00:00:00.000Z
__ls(2448257.5, 26.0), // 1991-01-01T00:00:00.000Z
__ls(2448804.5, 27.0), // 1992-07-01T00:00:00.000Z
__ls(2449169.5, 28.0), // 1993-07-01T00:00:00.000Z
__ls(2449534.5, 29.0), // 1994-07-01T00:00:00.000Z
__ls(2450083.5, 30.0), // 1996-01-01T00:00:00.000Z
__ls(2450630.5, 31.0), // 1997-07-01T00:00:00.000Z
__ls(2451179.5, 32.0), // 1999-01-01T00:00:00.000Z
__ls(2453736.5, 33.0), // 2006-01-01T00:00:00.000Z
__ls(2454832.5, 34.0), // 2009-01-01T00:00:00.000Z
__ls(2456109.5, 35.0), // 2012-07-01T00:00:00.000Z
__ls(2457204.5, 36.0) // 2015-07-01T00:00:00.000Z
__ls(2441317.5, 10.0), // 1972-01-01T00:00:00.000Z
__ls(2441499.5, 11.0), // 1972-07-01T00:00:00.000Z
__ls(2441683.5, 12.0), // 1973-01-01T00:00:00.000Z
__ls(2442048.5, 13.0), // 1974-01-01T00:00:00.000Z
__ls(2442413.5, 14.0), // 1975-01-01T00:00:00.000Z
__ls(2442778.5, 15.0), // 1976-01-01T00:00:00.000Z
__ls(2443144.5, 16.0), // 1977-01-01T00:00:00.000Z
__ls(2443509.5, 17.0), // 1978-01-01T00:00:00.000Z
__ls(2443874.5, 18.0), // 1979-01-01T00:00:00.000Z
__ls(2444239.5, 19.0), // 1980-01-01T00:00:00.000Z
__ls(2444786.5, 20.0), // 1981-07-01T00:00:00.000Z
__ls(2445151.5, 21.0), // 1982-07-01T00:00:00.000Z
__ls(2445516.5, 22.0), // 1983-01-01T00:00:00.000Z
__ls(2446247.5, 23.0), // 1985-07-01T00:00:00.000Z
__ls(2447161.5, 24.0), // 1988-01-01T00:00:00.000Z
__ls(2447892.5, 25.0), // 1990-01-01T00:00:00.000Z
__ls(2448257.5, 26.0), // 1991-01-01T00:00:00.000Z
__ls(2448804.5, 27.0), // 1992-07-01T00:00:00.000Z
__ls(2449169.5, 28.0), // 1993-07-01T00:00:00.000Z
__ls(2449534.5, 29.0), // 1994-07-01T00:00:00.000Z
__ls(2450083.5, 30.0), // 1996-01-01T00:00:00.000Z
__ls(2450630.5, 31.0), // 1997-07-01T00:00:00.000Z
__ls(2451179.5, 32.0), // 1999-01-01T00:00:00.000Z
__ls(2453736.5, 33.0), // 2006-01-01T00:00:00.000Z
__ls(2454832.5, 34.0), // 2009-01-01T00:00:00.000Z
__ls(2456109.5, 35.0), // 2012-07-01T00:00:00.000Z
__ls(2457204.5, 36.0) // 2015-07-01T00:00:00.000Z
];
export const J2000TAI = UTCtoTAI(J2000);

View File

@ -22,14 +22,14 @@ export function getEccentricAnomaly(M, ecc) {
// Extremely stable Laguerre-Conway method for solving Kepler's
// equation. Only use this for high-eccentricity orbits, as it
// requires more calcuation.
var E = M + 0.85 * ecc * sign(sin(M));
let E = M + 0.85 * ecc * sign(sin(M));
return math.solve_iteration_fixed(solveKeplerLaguerreConway(ecc, M), E, 8);
} else if (ecc == 1.0) {
//TODO: Parabolic orbit
// TODO: Parabolic orbit
return M;
} else {
// Laguerre-Conway method for hyperbolic (ecc > 1) orbits.
var E = log(2 * M / ecc + 1.85);
let E = log(2 * M / ecc + 1.85);
return math.solve_iteration_fixed(solveKeplerLaguerreConwayHyp(ecc, M), E, 30);
}
};
@ -38,7 +38,7 @@ export function getEccentricAnomaly(M, ecc) {
function solveKeplerFunc1(ecc, M) {
return function (x) {
return M + ecc * Math.sin(x);
}
};
};
// Faster converging iteration for Kepler's Equation; more efficient
@ -47,7 +47,7 @@ function solveKeplerFunc1(ecc, M) {
function solveKeplerFunc2(ecc, M) {
return function (x) {
return x + (M + ecc * Math.sin(x) - x) / (1 - ecc * Math.cos(x));
}
};
};
function solveKeplerLaguerreConway(ecc, M) {
@ -59,7 +59,7 @@ function solveKeplerLaguerreConway(ecc, M) {
var f2 = s;
x += -5 * f / (f1 + Math.sign(f1) * Math.sqrt(abs(16 * f1 * f1 - 20 * f * f2)));
return x;
}
};
};
function solveKeplerLaguerreConwayHyp(ecc, M) {
@ -71,7 +71,7 @@ function solveKeplerLaguerreConwayHyp(ecc, M) {
var f2 = s;
x += -5 * f / (f1 + Math.sign(f1) * Math.sqrt(Math.abs(16 * f1 * f1 - 20 * f * f2)));
return x;
}
};
};
export function getEllipticalEccentricAnomaly(meanAnomaly, eccentricity) {

View File

@ -138,14 +138,14 @@ class Camera {
* @protected
* @type {og.Vec3}
*/
this._u = new Vec3(0, 1, 0); //up x n
this._u = new Vec3(0, 1, 0); // up x n
/**
* Camera up vector.
* @protected
* @type {og.Vec3}
*/
this._v = new Vec3(1, 0, 0); //n x u - UP
this._v = new Vec3(1, 0, 0); // n x u - UP
this.slope = 0;
@ -154,7 +154,7 @@ class Camera {
* @protected
* @type {og.Vec3}
*/
this._n = new Vec3(0, 0, 1); //eye - look - FORWARD
this._n = new Vec3(0, 0, 1); // eye - look - FORWARD
this._pu = this._u.clone();
this._pv = this._v.clone();
@ -299,7 +299,7 @@ class Camera {
this._projectionViewMatrix = this._projectionMatrix.mul(this._viewMatrix);
this.frustum.setFrustum(this._projectionViewMatrix);
this._inverseProjectionViewMatrix = this._projectionViewMatrix.inverseTo();
this._normalMatrix = this._viewMatrix.toMatrix3();//this._viewMatrix.toInverseMatrix3().transposeTo();
this._normalMatrix = this._viewMatrix.toMatrix3();// this._viewMatrix.toInverseMatrix3().transposeTo();
this.events.dispatch(this.events.viewchange, this);
}
@ -646,12 +646,12 @@ const EVENT_NAMES = [
];
const defaultOptions = {
'viewAngle': 30,
'near': 1,
'far': 500000000,
'eye': new Vec3(),
'look': new Vec3(),
'up': new Vec3(0.0, 1.0, 0.0)
viewAngle: 30,
near: 1,
far: 500000000,
eye: new Vec3(),
look: new Vec3(),
up: new Vec3(0.0, 1.0, 0.0)
};
export { Camera };

View File

@ -10,7 +10,6 @@ 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/Mat4.js';
import { Ray } from '../math/Ray.js';
import { Quat } from '../math/Quat.js';
@ -93,7 +92,7 @@ class PlanetCamera extends Camera {
this._keyLock = new Key();
//Camera's flying frames
// Camera's flying frames
this._framesArr = [];
this._framesCounter = 0;
this._numFrames = 50;
@ -138,7 +137,7 @@ class PlanetCamera extends Camera {
this._inverseProjectionViewMatrix = this._projectionMatrixPrecise.mul(this._viewMatrix).inverseTo();
//this._normalMatrix = this._viewMatrix.toInverseMatrix3().transposeTo();
// this._normalMatrix = this._viewMatrix.toInverseMatrix3().transposeTo();
this._normalMatrix = this._viewMatrix.toMatrix3();
this.updateGeodeticPosition();
@ -257,7 +256,7 @@ class PlanetCamera extends Camera {
northEast.subA(center);
southWest.subA(center);
var direction = center.normal();//ellipsoid.getSurfaceNormal(center).negate().normalize();
var direction = center.normal(); // ellipsoid.getSurfaceNormal(center).negate().normalize();
var right = direction.cross(Vec3.UP).normalize();
var up = right.cross(direction).normalize();
@ -349,11 +348,6 @@ class PlanetCamera extends Camera {
*/
flyCartesian(cartesian, look, up, ampl = 1.0, completeCallback, startCallback, frameCallback) {
//???????
//if (this.eye.distance(cartesian) < 23000) {
// return;
//}
this.stopFlying();
this._completeCallback = completeCallback;
@ -396,13 +390,13 @@ class PlanetCamera extends Camera {
var max_h = currMaxHeight + 2.5 * hM_a * (maxHeight - currMaxHeight);
var zero = Vec3.ZERO;
//camera path and orientations calculation
// camera path and orientations calculation
for (var i = 0; i <= this._numFrames; i++) {
var d = 1 - i / this._numFrames;
d = d * d * (3 - 2 * d);
d *= d;
//Error here
// Error here
var g_i = ground_a.smerp(ground_b, d).normalize();
var ground_i = this.planet.getRayIntersectionEllipsoid(new Ray(zero, g_i));
var t = 1 - d;
@ -419,10 +413,10 @@ class PlanetCamera extends Camera {
var v = n.cross(u);
this._framesArr[i] = {
"eye": eye_i,
"n": n,
"u": u,
"v": v
eye: eye_i,
n: n,
u: u,
v: v
};
}

View File

@ -105,5 +105,4 @@ export class Cons {
}
}
export const cons = new Cons();
export const cons = new Cons();

View File

@ -5,7 +5,6 @@
'use strict';
import { Control } from './Control.js';
import { print2d } from '../utils/shared.js';
/**
* Debug information
@ -54,51 +53,51 @@ class DebugInfo extends Control {
if (p) {
this.addWatches([{
'label': "Nodes count",
'frame': () => p._renderedNodes.length
label: "Nodes count",
frame: () => p._renderedNodes.length
}, {
'label': "createdNodes",
'frame': () => p._createdNodesCount
label: "createdNodes",
frame: () => p._createdNodesCount
}, {
'label': "distBeforeMemClear",
'frame': () => p._distBeforeMemClear
},{
'label': "maxZoom/minZoom",
'frame': () => p.maxCurrZoom + '/' + p.minCurrZoom
label: "distBeforeMemClear",
frame: () => p._distBeforeMemClear
}, {
'label': "height/alt (km)",
'frame': () => (p.camera._lonLat.height / 1000.0).toFixed(2) + '/' + (p.camera.getAltitude() / 1000.0).toFixed(2)
label: "maxZoom/minZoom",
frame: () => p.maxCurrZoom + '/' + p.minCurrZoom
}, {
'label': "cam.slope",
'frame': () => p.camera.slope
label: "height/alt (km)",
frame: () => (p.camera._lonLat.height / 1000.0).toFixed(2) + '/' + (p.camera.getAltitude() / 1000.0).toFixed(2)
}, {
'label': "lodRatio",
'frame': () => p._lodRatio
label: "cam.slope",
frame: () => p.camera.slope
}, {
'label': "deltaTime",
'frame': () => p.renderer.handler.deltaTime
label: "lodRatio",
frame: () => p._lodRatio
}, {
'label': "-------------------------"
label: "deltaTime",
frame: () => p.renderer.handler.deltaTime
}, {
'label': "PlainWorker",
'frame': () => p._plainSegmentWorker._pendingQueue.length
label: "-------------------------"
}, {
'label': "TileLoader",
'frame': () => p._tileLoader._loading + ' ' + p._tileLoader._queue.length
label: "PlainWorker",
frame: () => p._plainSegmentWorker._pendingQueue.length
}, {
'label': "TerrainLoader",
'frame': () => {
if (p.terrain && p.terrain._loader)
label: "TileLoader",
frame: () => p._tileLoader._loading + ' ' + p._tileLoader._queue.length
}, {
label: "TerrainLoader",
frame: () => {
if (p.terrain && p.terrain._loader) {
return p.terrain._loader._loading + ' ' + p.terrain._loader._queue.length;
else
return '';
}
return '';
}
}, {
'label': "TerrainWorker",
'frame': () => p._terrainWorker._pendingQueue.length
label: "TerrainWorker",
frame: () => p._terrainWorker._pendingQueue.length
}, {
'label': "NormalMapCreator",
'frame': () => p._normalMapCreator._queue.length
label: "NormalMapCreator",
frame: () => p._normalMapCreator._queue.length
}]);
}
}

View File

@ -7,10 +7,10 @@
import { Control } from './Control.js';
function dec2deg(base) {
var t, t2;
var t;
var degrees = base < 0 ? Math.ceil(base) : Math.floor(base);
var minutes = Math.floor(t = Math.abs((base - degrees)) * 60);
var seconds = Math.floor(t2 = (t - minutes) * 6000);
var seconds = Math.floor((t - minutes) * 6000);
seconds = seconds / 100.00;
return (numToFixedString(degrees, 3) + "\u00B0" +
numToFixedString(minutes, 2) + "\u0027" +
@ -107,8 +107,11 @@ class EarthCoordinates extends Control {
var that = this;
function _refresh(el) {
if (that._displayType >= DisplayTypesConverters.length)
if (that._displayType >= DisplayTypesConverters.length) {
that._displayType = 0;
}
if (that._displayType == 0) {
el.style.width = "275px";
} else if (that._displayType == 1) {
@ -175,7 +178,6 @@ class EarthCoordinates extends Control {
_grabCoordinates() {
var r = this.renderer;
var ts = r.events.touchState;
this.position = this.planet.getLonLatFromPixelTerrain(r.handler.getCenter());
this._showPosition();
}

View File

@ -34,7 +34,7 @@ class GeoImageDragControl extends Control {
_bindLayer(layer) {
if (layer instanceof BaseGeoImage) {
var p = this.planet;
layer.events.on('mousemove', function (ms) {
@ -46,7 +46,7 @@ class GeoImageDragControl extends Control {
} else {
this._cornerIndex = -1;
for (var i = 0; i < layer._cornersWgs84.length; i++) {
var ground = p.getLonLatFromPixelTerrain(ms, true)
var ground = p.getLonLatFromPixelTerrain(ms, true);
if (ground && p.ellipsoid.getGreatCircleDistance(layer._cornersWgs84[i], ground) / p.getDistanceFromPixel(ms, true) <= 0.05) {
this._cornerIndex = i;
break;
@ -59,7 +59,6 @@ class GeoImageDragControl extends Control {
layer.events.on('ldown', function (ms) {
if (this._active && this._cornerIndex != -1) {
this._catchCorner = true;
//p.renderer.controls.mouseNavigation._active = false;
ms.renderer.controls.mouseNavigation.deactivate();
}
}, this);
@ -67,7 +66,6 @@ class GeoImageDragControl extends Control {
layer.events.on('lup', function (ms) {
if (this._active) {
this._catchCorner = false;
//p.renderer.controls.mouseNavigation._active = true;
ms.renderer.controls.mouseNavigation.activate();
}
}, this);

View File

@ -84,7 +84,7 @@ class LayerSwitcher extends Control {
obj._removeCallback = function () {
container.removeChild(lineDiv);
}
};
lineDiv.appendChild(center);
lineDiv.appendChild(inp);
@ -155,5 +155,4 @@ class LayerSwitcher extends Control {
}
};
export { LayerSwitcher };
export { LayerSwitcher };

View File

@ -15,7 +15,6 @@ import { Ray } from '../math/Ray.js';
import { Sphere } from '../bv/Sphere.js';
import { Vec3 } from '../math/Vec3.js';
/**
* Mouse planet camera dragging control.
* @class
@ -52,7 +51,7 @@ class MouseNavigation extends Control {
static getMovePointsFromPixelTerrain(cam, planet, stepsCount, delta, point, forward, dir) {
var steps = []
var steps = [];
var eye = cam.eye.clone(),
n = cam._n.clone(),
@ -86,7 +85,7 @@ class MouseNavigation extends Control {
grabbedSpheroid.radius = a.length();
var rotArr = [],
eyeArr = []
eyeArr = [];
var breaked = false;
for (var i = 0; i < stepsCount; i++) {
@ -102,7 +101,7 @@ class MouseNavigation extends Control {
}
if (!breaked) {
for (var i = 0; i < stepsCount; i++) {
for (let i = 0; i < stepsCount; i++) {
var rot = rotArr[i];
steps[i] = {};
steps[i].eye = rot.mulVec3(eyeArr[i]);
@ -112,7 +111,7 @@ class MouseNavigation extends Control {
}
} else {
eye = cam.eye.clone();
for (var i = 0; i < stepsCount; i++) {
for (let i = 0; i < stepsCount; i++) {
steps[i] = {};
steps[i].eye = eye.addA(scaled_n).clone();
steps[i].v = v;
@ -121,7 +120,7 @@ class MouseNavigation extends Control {
}
}
} else {
for (var i = 0; i < stepsCount; i++) {
for (let i = 0; i < stepsCount; i++) {
steps[i] = {};
steps[i].eye = eye.addA(dir.scaleTo(-d)).clone();
steps[i].v = v;
@ -176,8 +175,9 @@ class MouseNavigation extends Control {
onMouseWheel(event) {
if (this.stepIndex)
if (this.stepIndex) {
return;
}
this.planet.stopFlying();
@ -243,8 +243,10 @@ class MouseNavigation extends Control {
onMouseLeftButtonDown(e) {
if (this._active) {
if (!this.grabbedPoint)
if (!this.grabbedPoint) {
return;
}
this.planet.stopFlying();
@ -356,8 +358,9 @@ class MouseNavigation extends Control {
}
}
if (r.events.mouseState.leftButtonDown || !this.scaleRot)
if (r.events.mouseState.leftButtonDown || !this.scaleRot) {
return;
}
this.scaleRot -= this.inertia;
if (this.scaleRot <= 0.0) {

View File

@ -25,8 +25,7 @@ class ShowFps extends Control {
document.body.appendChild(d);
this.renderer.events.on("draw", this._draw, this);
}
_draw() {
print2d("ogShowFpsControl", (1000.0 / this.renderer.handler.deltaTime).toFixed(1), this.renderer.handler.canvas.clientWidth - 60, 0);
}

View File

@ -1,10 +1,5 @@
/**
* @module og/control/SimpleNavigation
*/
'use strict';
import * as math from '../math.js';
import { Control } from './Control.js';
import { input } from '../input/input.js';
@ -23,7 +18,6 @@ class SimpleNavigation extends Control {
this.speed = options.speed || 1.0;
}
oninit() {
this.camera = this.renderer.activeCamera;
this.renderer.events.on("keypress", input.KEY_W, this.onCameraMoveForward, this);
@ -99,7 +93,6 @@ class SimpleNavigation extends Control {
}
};
/**
* Creates simple navigation control instance.
*/

View File

@ -6,7 +6,6 @@
import { Control } from './Control.js';
import { getSunPosition } from '../astro/earth.js';
import { input } from '../input/input.js';
import { LightSource } from '../light/LightSource.js';
import { Quat } from '../math/Quat.js';
import { Vec3 } from '../math/Vec3.js';
@ -38,7 +37,7 @@ class Sun extends Control {
* @private
* @type {boolean}
*/
//this._isCameraSunlight = false;
// this._isCameraSunlight = false;
this.offsetVertical = options.offsetVertical || -5000000;
@ -76,20 +75,20 @@ class Sun extends Control {
this.planet.lightEnabled = true;
//sunlight initialization
// sunlight initialization
this.sunlight = new LightSource("Sun", {
'ambient': new Vec3(0.15, 0.15, 0.25),
'diffuse': new Vec3(0.9, 0.9, 0.8),
'specular': new Vec3(0.1, 0.1, 0.06),
'shininess': 110
ambient: new Vec3(0.15, 0.15, 0.25),
diffuse: new Vec3(0.9, 0.9, 0.8),
specular: new Vec3(0.1, 0.1, 0.06),
shininess: 110
});
this.sunlight.addTo(this.planet);
var that = this;
this.renderer.events.on("draw", this._draw, this);
if (!this._clockPtr)
if (!this._clockPtr) {
this._clockPtr = this.renderer.handler.defaultClock;
}
}
stop() {
@ -126,8 +125,8 @@ class Sun extends Control {
var pos = cam.eye.add(d);
if (this._k > 0) {
this._k -= 0.01;
var rot = Quat.getRotationBetweenVectors(this.sunlight._position.normal(), pos.normal());
var r = rot.slerp(Quat.IDENTITY, this._k).normalize();
let rot = Quat.getRotationBetweenVectors(this.sunlight._position.normal(), pos.normal());
let r = rot.slerp(Quat.IDENTITY, this._k).normalize();
this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
} else {
this.sunlight.setPosition3v(pos);
@ -136,11 +135,11 @@ class Sun extends Control {
this._k = 1;
if (this._f > 0) {
this._f -= 0.01;
var rot = Quat.getRotationBetweenVectors(this.sunlight._position.normal(), getSunPosition(this._currDate).normal());
var r = rot.slerp(Quat.IDENTITY, this._f).normalize();
let rot = Quat.getRotationBetweenVectors(this.sunlight._position.normal(), getSunPosition(this._currDate).normal());
let r = rot.slerp(Quat.IDENTITY, this._f).normalize();
this.sunlight.setPosition3v(r.mulVec3(this.sunlight._position));
} else {
if (Math.abs(this._currDate - this._prevDate) > 0.00034 && this._active || this._lightOn) {
if ((Math.abs(this._currDate - this._prevDate) > 0.00034 && this._active) || this._lightOn) {
this._lightOn = false;
this._prevDate = this._currDate;
this.sunlight.setPosition3v(getSunPosition(this._currDate));
@ -158,5 +157,4 @@ export function sun(options) {
return Sun(options);
}
export { Sun };
export { Sun };

View File

@ -19,7 +19,6 @@ class ToggleWireframe extends Control {
this._isActive = options.isActive || false;
}
oninit() {
this.renderer.events.on("charkeypress", input.KEY_X, this.toogleWireframe, this);
if (this._isActive) {

View File

@ -6,16 +6,13 @@
import * as math from '../math.js';
import { Control } from './Control.js';
import { input } from '../input/input.js';
import { Key } from '../Lock.js';
import { LonLat } from '../LonLat.js';
import { Mat4 } from '../math/Mat4.js';
import { Quat } from '../math/Quat.js';
import { Ray } from '../math/Ray.js';
import { Sphere } from '../bv/Sphere.js';
import { Vec3 } from '../math/Vec3.js';
/**
* Touch pad planet camera dragging control.
* @class
@ -90,7 +87,7 @@ class TouchNavigation extends Control {
t1.prev_y = e.sys.touches.item(1).clientY - e.sys.offsetTop;
t1.grabbedPoint = this.planet.getCartesianFromPixelTerrain(t1, true);
//this.planet._viewChanged = true;
// this.planet._viewChanged = true;
this.pointOnEarth = this.planet.getCartesianFromPixelTerrain(this.renderer.handler.getCenter(), true);
if (this.pointOnEarth) {
@ -133,8 +130,9 @@ class TouchNavigation extends Control {
}
onDoubleTouch(e) {
if (this.stepIndex)
if (this.stepIndex) {
return;
}
this.planet.stopFlying();
this.stopRotation();
@ -145,16 +143,18 @@ class TouchNavigation extends Control {
onTouchEnd(e) {
if (e.sys.touches.length === 0)
if (e.sys.touches.length === 0) {
this._touching = false;
}
if (e.sys.touches.length === 1) {
this._startTouchOne(e);
}
if (Math.abs(this.touches[0].x - this.touches[0].prev_x) < 3 &&
Math.abs(this.touches[0].y - this.touches[0].prev_y) < 3)
if ((Math.abs(this.touches[0].x - this.touches[0].prev_x) < 3) &&
(Math.abs(this.touches[0].y - this.touches[0].prev_y) < 3)) {
this.scaleRot = 0;
}
}
onTouchCancel(e) {
@ -171,8 +171,9 @@ class TouchNavigation extends Control {
var t0 = this.touches[0],
t1 = this.touches[1];
if (!t0.grabbedPoint || !t1.grabbedPoint)
if (!t0.grabbedPoint || !t1.grabbedPoint) {
return;
}
this.planet.stopFlying();
@ -186,23 +187,8 @@ class TouchNavigation extends Control {
t1.x = e.sys.touches.item(1).clientX - e.sys.offsetLeft;
t1.y = e.sys.touches.item(1).clientY - e.sys.offsetTop;
//var center_x = Math.round(t0.x + (t1.x - t0.x) * 0.5);
//var center_y = Math.round(t0.y + (t1.y - t0.y) * 0.5);
//var dirC = cam.unproject(center_x, center_y);
//var targetPointC = this.planet.getCartesianFromPixelTerrain(new og.math.Pixel(center_x, center_y));
//var dir0 = cam.unproject(t0.x, t0.y);
//var targetPoint0 = new og.Ray(cam.eye, dir0).hitSphere(t0.grabbedSpheroid);
//var dir1 = cam.unproject(t1.x, t1.y);
//var targetPoint1 = new og.Ray(cam.eye, dir1).hitSphere(t1.grabbedSpheroid);
//print2d("t1", center_x + "," + center_y, 100, 100);
//print2d("t2", targetPointC.x + "," + targetPointC.y + "," + targetPointC.z, 100, 120);
if (t0.dY() > 0 && t1.dY() > 0 || t0.dY() < 0 && t1.dY() < 0 ||
t0.dX() > 0 && t1.dX() > 0 || t0.dX() < 0 && t1.dX() < 0) {
if ((t0.dY() > 0 && t1.dY() > 0) || (t0.dY() < 0 && t1.dY() < 0) ||
(t0.dX() > 0 && t1.dX() > 0) || (t0.dX() < 0 && t1.dX() < 0)) {
var l = 0.5 / cam.eye.distance(this.pointOnEarth) * cam._lonLat.height * math.RADIANS;
if (l > 0.007) l = 0.007;
cam.rotateHorizontal(l * t0.dX(), false, this.pointOnEarth, this.earthUp);
@ -222,8 +208,9 @@ class TouchNavigation extends Control {
t.x = e.sys.touches.item(0).clientX - e.sys.offsetLeft;
t.y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
if (!t.grabbedPoint)
if (!t.grabbedPoint) {
return;
}
this.planet.stopFlying();
@ -262,8 +249,9 @@ class TouchNavigation extends Control {
this.renderer.controlsBag.scaleRot = this.scaleRot;
if (this._touching)
if (this._touching) {
return;
}
var r = this.renderer;
var cam = r.activeCamera;
@ -272,7 +260,6 @@ class TouchNavigation extends Control {
if (this.stepIndex) {
r.controlsBag.scaleRot = 1;
var sf = this.stepsForward[this.stepsCount - this.stepIndex--];
var cam = this.renderer.activeCamera;
cam.eye = sf.eye;
cam._v = sf.v;
cam._u = sf.u;
@ -281,15 +268,15 @@ class TouchNavigation extends Control {
cam.update();
}
if (r.events.mouseState.leftButtonDown || !this.scaleRot)
if (r.events.mouseState.leftButtonDown || !this.scaleRot) {
return;
}
this.scaleRot -= this.inertia;
if (this.scaleRot <= 0)
if (this.scaleRot <= 0) {
this.scaleRot = 0;
else {
} else {
r.controlsBag.scaleRot = this.scaleRot;
var cam = r.activeCamera;
var rot = this.qRot.slerp(Quat.IDENTITY, 1 - this.scaleRot * this.scaleRot * this.scaleRot).normalize();
if (!(rot.x || rot.y || rot.z)) {
this.scaleRot = 0;

View File

@ -46,13 +46,13 @@ class ZoomControl extends Control {
btnZoomOut.addEventListener("mousedown", (e) => this.zoomOut());
btnZoomOut.addEventListener("mouseup", (e) => this.stopZoom());
btnZoomIn.addEventListener('touchstart', (e) => { e.preventDefault(); this.zoomIn() });
btnZoomIn.addEventListener('touchend', (e) => { e.preventDefault(); this.stopZoom() });
btnZoomIn.addEventListener('touchcancel', (e) => { e.preventDefault(); this.stopZoom() });
btnZoomIn.addEventListener('touchstart', (e) => { e.preventDefault(); this.zoomIn(); });
btnZoomIn.addEventListener('touchend', (e) => { e.preventDefault(); this.stopZoom(); });
btnZoomIn.addEventListener('touchcancel', (e) => { e.preventDefault(); this.stopZoom(); });
btnZoomOut.addEventListener('touchstart', (e) => { e.preventDefault(); this.zoomOut() });
btnZoomOut.addEventListener('touchend', (e) => { e.preventDefault(); this.stopZoom() });
btnZoomOut.addEventListener('touchcancel', (e) => { e.preventDefault(); this.stopZoom() });
btnZoomOut.addEventListener('touchstart', (e) => { e.preventDefault(); this.zoomOut(); });
btnZoomOut.addEventListener('touchend', (e) => { e.preventDefault(); this.stopZoom(); });
btnZoomOut.addEventListener('touchcancel', (e) => { e.preventDefault(); this.stopZoom(); });
this.renderer.events.on("draw", this._draw, this);
}

View File

@ -43,8 +43,9 @@ class Ellipsoid {
b_y = Math.cos(b), b_x = Math.sin(b);
let c = a_y * b_x - b_y * a_x,
d = a_x * b_x + a_y * b_y;
if (c > 0.0)
if (c > 0.0) {
return Math.acos(d);
}
return -Math.acos(d);
}
@ -110,8 +111,7 @@ class Ellipsoid {
if (Math.abs(dLon) > Math.PI) {
if (dLon > 0) {
dLon = (2 * Math.PI - dLon) * -1;
}
else {
} else {
dLon = 2 * Math.PI + dLon;
}
}
@ -161,8 +161,7 @@ class Ellipsoid {
var df = f2 - f1,
dl = l2 - l1;
var d12 = 2 * Math.asin(Math.sqrt(Math.sin(df / 2) * Math.sin(df / 2)
+ Math.cos(f1) * Math.cos(f2) * Math.sin(dl / 2) * Math.sin(dl / 2)));
var d12 = 2 * Math.asin(Math.sqrt(Math.sin(df / 2) * Math.sin(df / 2) + Math.cos(f1) * Math.cos(f2) * Math.sin(dl / 2) * Math.sin(dl / 2)));
if (d12 == 0) return null;
// initial/final bearings between points
@ -177,10 +176,10 @@ class Ellipsoid {
var a2 = (D21 - D23 + Math.PI) % (2 * Math.PI) - Math.PI;
if (Math.sin(a1) == 0 && Math.sin(a2) == 0) return null; // infinite intersections
if (Math.sin(a1) * Math.sin(a2) < 0) return null; // ambiguous intersection
if (Math.sin(a1) * Math.sin(a2) < 0) return null; // ambiguous intersection
//a1 = Math.abs(a1);
//a2 = Math.abs(a2);
// a1 = Math.abs(a1);
// a2 = Math.abs(a2);
// ... Ed Williams takes abs of a1/a2, but seems to break calculation?
var a3 = Math.acos(-Math.cos(a1) * Math.cos(a2) + Math.sin(a1) * Math.sin(a2) * Math.cos(d12));
@ -311,13 +310,12 @@ class Ellipsoid {
var q = Math.sqrt(1.0 + 2.0 * ecc22 * p);
var recc2r0 = r - ecc2 * (-(p * ecc2 * r) / 1 + q + Math.sqrt(0.5 * this._a2 * (1.0 + 1.0 / q) - p * (1.0 - ecc2) * z2 / (q * (1.0 + q)) - 0.5 * p * r2));
var recc2r02 = recc2r0 * recc2r0;
var u = Math.sqrt(recc2r02 + z2);
// var u = Math.sqrt(recc2r02 + z2);
var v = Math.sqrt(recc2r02 + (1.0 - ecc2) * z2);
var z0 = this._b2 * z / (this._a * v);
var lat = Math.atan((z + this._k2 * z0) / r) * math.DEGREES;
var lon = Math.atan2(y, x) * math.DEGREES;
var c = this.geodeticToCartesian(lon, lat);
return new LonLat(lon, lat, cartesian.length() - c.length());
return new LonLat(lon, lat, cartesian.length() - this.geodeticToCartesian(lon, lat).length());
}
/**
@ -335,7 +333,6 @@ class Ellipsoid {
return new Vec3(nx * l, ny * l, nz * l);
}
/**
* Returns the distance from one point to another(using haversine formula) on the great circle.
* @param {og.LonLat} lonLat1 - Longitude/latitude of source point.
@ -356,8 +353,7 @@ class Ellipsoid {
var f1 = lonLat1.lat * math.RADIANS, l1 = nlon * math.RADIANS;
var dR = distance / this._a;
var f2 = Math.asin(Math.sin(f1) * Math.cos(dR) + Math.cos(f1) * Math.sin(dR) * Math.cos(bearing));
return new LonLat((l1 + Math.atan2(Math.sin(bearing) * Math.sin(dR) * Math.cos(f1), Math.cos(dR) - Math.sin(f1) * Math.sin(f2)))
* math.DEGREES, f2 * math.DEGREES);
return new LonLat((l1 + Math.atan2(Math.sin(bearing) * Math.sin(dR) * Math.cos(f1), Math.cos(dR) - Math.sin(f1) * Math.sin(f2))) * math.DEGREES, f2 * math.DEGREES);
}
/**

View File

@ -116,8 +116,8 @@ class Billboard extends BaseBillboard {
*/
getSize() {
return {
"width": this._width,
"height": this._height
width: this._width,
height: this._height
};
}

View File

@ -201,7 +201,7 @@ class BillboardHandler {
this._billboards.push(billboard);
this._addBillboardToArrays(billboard);
this.refresh();
billboard.setSrc(billboard._src || billboard._image && billboard._image.src);
billboard.setSrc(billboard._src || (billboard._image && billboard._image.src));
}
}
@ -217,7 +217,7 @@ class BillboardHandler {
var x = billboard._positionHigh.x, y = billboard._positionHigh.y, z = billboard._positionHigh.z, w;
BillboardHandler.concArr(this._positionHighArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
x = billboard._positionLow.x, y = billboard._positionLow.y, z = billboard._positionLow.z;
x = billboard._positionLow.x; y = billboard._positionLow.y; z = billboard._positionLow.z;
BillboardHandler.concArr(this._positionLowArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
x = billboard._width; y = billboard._height;
@ -232,10 +232,10 @@ class BillboardHandler {
x = billboard._rotation;
BillboardHandler.concArr(this._rotationArr, [x, x, x, x, x, x]);
x = billboard._alignedAxis.x, y = billboard._alignedAxis.y, z = billboard._alignedAxis.z;
x = billboard._alignedAxis.x; y = billboard._alignedAxis.y; z = billboard._alignedAxis.z;
BillboardHandler.concArr(this._alignedAxisArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
x = billboard._entity._pickingColor.x / 255, y = billboard._entity._pickingColor.y / 255, z = billboard._entity._pickingColor.z / 255;
x = billboard._entity._pickingColor.x / 255; y = billboard._entity._pickingColor.y / 255; z = billboard._entity._pickingColor.z / 255;
BillboardHandler.concArr(this._pickingColorArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
}
@ -304,8 +304,6 @@ class BillboardHandler {
var sha = sh.attributes,
shu = sh.uniforms;
var gl = h.gl;
var gl = h.gl,
ec = this._entityCollection;
@ -412,7 +410,7 @@ class BillboardHandler {
var i = index * 18;
//High
// High
var a = this._positionHighArr, x = positionHigh.x, y = positionHigh.y, z = positionHigh.z;
a[i] = x;
@ -439,8 +437,8 @@ class BillboardHandler {
a[i + 16] = y;
a[i + 17] = z;
//Low
a = this._positionLowArr, x = positionLow.x, y = positionLow.y, z = positionLow.z;
// Low
a = this._positionLowArr; x = positionLow.x; y = positionLow.y; z = positionLow.z;
a[i] = x;
a[i + 1] = y;
@ -609,7 +607,7 @@ class BillboardHandler {
a[i + 4] = rotation;
a[i + 5] = rotation;
this._changedBuffers[ROTATION_BUFFER] = true
this._changedBuffers[ROTATION_BUFFER] = true;
}
setTexCoordArr(index, tcoordArr) {

View File

@ -8,7 +8,6 @@ import * as mercator from '../mercator.js';
import * as utils from '../utils/shared.js';
import { Billboard } from './Billboard.js';
import { Strip } from './Strip.js';
//import { Box } from '../shapes/Box.js';
import { Extent } from '../Extent.js';
import { Geometry } from './Geometry.js';
import { Label } from './Label.js';
@ -19,7 +18,6 @@ import { PointCloud } from './PointCloud.js';
import { Sphere } from '../shapes/Sphere.js';
import { Vec3 } from '../math/Vec3.js';
/**
* Entity instances aggregate multiple forms of visualization into a single high-level object.
* They can be created manually and added to entity collection.
@ -154,15 +152,15 @@ class Entity {
this._pickingColor = new Vec3(0, 0, 0);
this._featureConstructorArray = {
"billboard": [Billboard, this.setBillboard],
"label": [Label, this.setLabel],
"sphere": [Sphere, this.setShape],
//"box": [Box, this.setShape],
"polyline": [Polyline, this.setPolyline],
"pointCloud": [PointCloud, this.setPointCloud],
"geometry": [Geometry, this.setGeometry],
"strip": [Strip, this.setStrip],
"ray": [Ray, this.setRay]
billboard: [Billboard, this.setBillboard],
label: [Label, this.setLabel],
sphere: [Sphere, this.setShape],
// box: [Box, this.setShape],
polyline: [Polyline, this.setPolyline],
pointCloud: [PointCloud, this.setPointCloud],
geometry: [Geometry, this.setGeometry],
strip: [Strip, this.setStrip],
ray: [Ray, this.setRay]
};
/**
@ -220,9 +218,6 @@ class Entity {
* @type {og.Strip}
*/
this.strip = this._createOptionFeature('strip', options.strip);
//this.model = null;
//...
}
static get _staticCounter() {
@ -281,22 +276,22 @@ class Entity {
setVisibility(visibility) {
this._visibility = visibility;
//billboards
// billboards
this.billboard && this.billboard.setVisibility(visibility);
//labels
// labels
this.label && this.label.setVisibility(visibility);
//shape
// shape
this.shape && this.shape.setVisibility(visibility);
//polyline
// polyline
this.polyline && this.polyline.setVisibility(visibility);
//ray
// ray
this.ray && this.ray.setVisibility(visibility);
//geometry
// geometry
this.geometry && this.geometry.setVisibility(visibility);
for (var i = 0; i < this.childrenNodes.length; i++) {
@ -337,13 +332,13 @@ class Entity {
p.y = y;
p.z = z;
//billboards
// billboards
this.billboard && this.billboard.setPosition3v(p);
//labels
// labels
this.label && this.label.setPosition3v(p);
//shape
// shape
this.shape && this.shape.setPosition3v(p);
for (var i = 0; i < this.childrenNodes.length; i++) {
@ -380,13 +375,13 @@ class Entity {
p.y = cartesian.y;
p.z = cartesian.z;
//billboards
// billboards
this.billboard && this.billboard.setPosition3v(p);
//labels
// labels
this.label && this.label.setPosition3v(p);
//shape
// shape
this.shape && this.shape.setPosition3v(p);
for (var i = 0; i < this.childrenNodes.length; i++) {
@ -641,22 +636,22 @@ class Entity {
var c = this._pickingColor;
//billboard
// billboard
this.billboard && this.billboard.setPickingColor3v(c);
//label
// label
this.label && this.label.setPickingColor3v(c);
//shape
// shape
this.shape && this.shape.setPickingColor3v(c);
//polyline
// polyline
this.polyline && this.polyline.setPickingColor3v(c);
//ray
// ray
this.ray && this.ray.setPickingColor3v(c);
//strip
// strip
this.strip && this.strip.setPickingColor3v(c);
for (var i = 0; i < this.childrenNodes.length; i++) {
@ -681,7 +676,7 @@ class Entity {
ne = res.northEast;
if (this.polyline) {
var e = this.polyline.getExtent();
let e = this.polyline.getExtent();
if (e.southWest.lon < sw.lon) sw.lon = e.southWest.lon;
if (e.southWest.lat < sw.lat) sw.lat = e.southWest.lat;
if (e.northEast.lon > ne.lon) ne.lon = e.northEast.lon;
@ -689,7 +684,7 @@ class Entity {
}
if (this.geometry) {
var e = this.geometry.getExtent();
let e = this.geometry.getExtent();
if (e.southWest.lon < sw.lon) sw.lon = e.southWest.lon;
if (e.southWest.lat < sw.lat) sw.lat = e.southWest.lat;
if (e.northEast.lon > ne.lon) ne.lon = e.northEast.lon;
@ -697,7 +692,7 @@ class Entity {
}
for (var i = 0; i < this.childrenNodes.length; i++) {
var e = this.childrenNodes[i].getExtent();
let e = this.childrenNodes[i].getExtent();
if (e.southWest.lon < sw.lon) sw.lon = e.southWest.lon;
if (e.southWest.lat < sw.lat) sw.lat = e.southWest.lat;
if (e.northEast.lon > ne.lon) ne.lon = e.northEast.lon;

View File

@ -158,8 +158,6 @@ class EntityCollection {
* @type {og.StripHandler}
*/
this.stripHandler = new StripHandler(this);
//
//...
if (options.pickingEnabled != undefined) {
this.setPickingEnabled(options.pickingEnabled);
@ -206,9 +204,10 @@ class EntityCollection {
this.rendererEvents = this.events;
//initialize current entities
if (options.entities)
// initialize current entities
if (options.entities) {
this.addEntities(options.entities);
}
}
static get _staticCounter() {
@ -295,25 +294,25 @@ class EntityCollection {
_addRecursively(entity) {
//billboard
// billboard
entity.billboard && this.billboardHandler.add(entity.billboard);
//label
// label
entity.label && this.labelHandler.add(entity.label);
//shape
// shape
entity.shape && this.shapeHandler.add(entity.shape);
//polyline
// polyline
entity.polyline && this.polylineHandler.add(entity.polyline);
//ray
// ray
entity.ray && this.rayHandler.add(entity.ray);
//pointCloud
// pointCloud
entity.pointCloud && this.pointCloudHandler.add(entity.pointCloud);
//strip
// strip
entity.strip && this.stripHandler.add(entity.strip);
this.events.dispatch(this.events.entityadd, entity);
@ -377,25 +376,25 @@ class EntityCollection {
entity._entityCollection = null;
entity._entityCollectionIndex = -1;
//billboard
// billboard
entity.billboard && this.billboardHandler.remove(entity.billboard);
//label
// label
entity.label && this.labelHandler.remove(entity.label);
//shape
// shape
entity.shape && this.shapeHandler.remove(entity.shape);
//polyline
// polyline
entity.polyline && this.polylineHandler.remove(entity.polyline);
//ray
// ray
entity.ray && this.rayHandler.remove(entity.ray);
//pointCloud
// pointCloud
entity.pointCloud && this.pointCloudHandler.remove(entity.pointCloud);
//strip
// strip
entity.strip && this.stripHandler.remove(entity.strip);
for (var i = 0; i < entity.childrenNodes.length; i++) {
@ -412,7 +411,7 @@ class EntityCollection {
this._entities.splice(entity._entityCollectionIndex, 1);
this.reindexEntitiesArray(entity._entityCollectionIndex);
//clear picking color
// clear picking color
if (this.renderNode && this.renderNode.renderer) {
this.renderNode.renderer.clearPickingColor(entity);
entity._pickingColor.clear();
@ -429,7 +428,7 @@ class EntityCollection {
this._entities.splice(entity._entityCollectionIndex, 1);
this.reindexEntitiesArray(entity._entityCollectionIndex);
//clear picking color
// clear picking color
if (this.renderNode && this.renderNode.renderer) {
this.renderNode.renderer.clearPickingColor(entity);
entity._pickingColor.clear();
@ -511,6 +510,7 @@ class EntityCollection {
this.createPickingColors();
}
}
/**
* Updates coordiantes all lonLat entities in collection after collecction attached to the planet node.
* @private
@ -557,7 +557,7 @@ class EntityCollection {
if (this.renderNode) {
if (this._renderNodeIndex !== -1) {
this.renderNode.entityCollections.splice(this._renderNodeIndex, 1);
//reindex in the renderNode
// reindex in the renderNode
for (var i = this._renderNodeIndex; i < this.renderNode.entityCollections.length; i++) {
this.renderNode.entityCollections._renderNodeIndex = i;
}
@ -596,8 +596,8 @@ class EntityCollection {
*/
clear() {
//TODO: Optimize by replace delete
//code to the clearEntity function.
// TODO: Optimize by replace delete
// code to the clearEntity function.
this.billboardHandler.clear();
this.labelHandler.clear();
this.shapeHandler.clear();
@ -633,7 +633,6 @@ class EntityCollection {
}
};
const EVENT_NAMES = [
/**
* Triggered when entity has moved.

View File

@ -34,14 +34,14 @@ class Geometry {
this._handler = null;
this._handlerIndex = -1;
//Polygon
// Polygon
this._polyVerticesMerc = [];
this._polyVerticesLength = -1;
this._polyIndexesLength = -1;
this._polyVerticesHandlerIndex = -1;
this._polyIndexesHandlerIndex = -1;
//Line(Linestring and polygon's stroke(s)
// Line(Linestring and polygon's stroke(s)
this._lineVerticesMerc = [];
this._lineVerticesLength = -1;
this._lineOrdersLength = -1;
@ -54,11 +54,11 @@ class Geometry {
this._lineThicknessHandlerIndex = -1;
this._lineColorsHandlerIndex = -1;
this._type = options.type && Geometry.getType(options.type) || GeometryType.POINT;
this._type = (options.type && Geometry.getType(options.type)) || GeometryType.POINT;
this._coordinates = [];
this._extent = Geometry.getExtent({
'type': options.type || "Point",
'coordinates': options.coordinates || []
type: options.type || "Point",
coordinates: options.coordinates || []
}, this._coordinates);
this._style = options.style || {};
@ -70,7 +70,7 @@ class Geometry {
this._visibility = options.visibility || true;
//optimization flag for picking mask rendering pass
// optimization flag for picking mask rendering pass
this._pickingReady = false;
}
@ -198,7 +198,7 @@ class Geometry {
setFillColor(r, g, b, a) {
var c = this._style.fillColor;
if (c.w === 0.0 && a !== 0.0 || c.w !== 0.0 && a === 0.0) {
if ((c.w === 0.0 && a !== 0.0) || (c.w !== 0.0 && a === 0.0)) {
this._pickingReady = false;
}
c.x = r;
@ -215,7 +215,7 @@ class Geometry {
setStrokeColor(r, g, b, a) {
var c = this._style.strokeColor;
if (c.w === 0.0 && a !== 0.0 || c.w !== 0.0 && a === 0.0) {
if ((c.w === 0.0 && a !== 0.0) || (c.w !== 0.0 && a === 0.0)) {
this._pickingReady = false;
}
c.x = r;
@ -228,7 +228,7 @@ class Geometry {
setLineColor(r, g, b, a) {
var c = this._style.lineColor;
if (c.w === 0.0 && a !== 0.0 || c.w !== 0.0 && a === 0.0) {
if ((c.w === 0.0 && a !== 0.0) || (c.w !== 0.0 && a === 0.0)) {
this._pickingReady = false;
}
c.x = r;
@ -280,7 +280,7 @@ class Geometry {
setFillOpacity(opacity) {
var c = this._style.fillColor;
if (c.w === 0.0 && opacity !== 0.0 || c.w !== 0.0 && opacity === 0.0) {
if ((c.w === 0.0 && opacity !== 0.0) || (c.w !== 0.0 && opacity === 0.0)) {
this._pickingReady = false;
}
c.w = opacity;

View File

@ -38,13 +38,13 @@ class GeometryHandler {
this._removeGeometryExtentArr = [];
this._removeGeometryExtents = {};
//Polygon arrays
// Polygon arrays
this._polyVerticesMerc = [];
this._polyColors = [];
this._polyPickingColors = [];
this._polyIndexes = [];
//Line arrays
// Line arrays
this._lineVerticesMerc = [];
this._lineOrders = [];
this._lineIndexes = [];
@ -54,7 +54,7 @@ class GeometryHandler {
this._lineStrokes = [];
this._lineStrokeColors = [];
//Buffers
// Buffers
this._polyVerticesBufferMerc = null;
this._polyColorsBuffer = null;
this._polyPickingColorsBuffer = null;
@ -245,7 +245,7 @@ class GeometryHandler {
geometry._polyVerticesLength = data.vertices.length;
geometry._polyIndexesLength = indexes.length;
//Creates polygon stroke data
// Creates polygon stroke data
geometry._lineVerticesHandlerIndex = this._lineVerticesMerc.length;
geometry._lineOrdersHandlerIndex = this._lineOrders.length;
geometry._lineIndexesHandlerIndex = this._lineIndexes.length;
@ -268,10 +268,9 @@ class GeometryHandler {
let coordinates = geometry._coordinates;
let vertices = [],
indexes = [],
colors = [];
indexes = [];
//Creates polygon stroke data
// Creates polygon stroke data
geometry._lineVerticesHandlerIndex = this._lineVerticesMerc.length;
geometry._lineOrdersHandlerIndex = this._lineOrders.length;
geometry._lineIndexesHandlerIndex = this._lineIndexes.length;
@ -336,7 +335,7 @@ class GeometryHandler {
ci[j] = [mercator.forward_lon(coordinates[j][0]), mercator.forward_lat(coordinates[j][1])];
}
//Creates polygon stroke data
// Creates polygon stroke data
geometry._lineVerticesHandlerIndex = this._lineVerticesMerc.length;
geometry._lineOrdersHandlerIndex = this._lineOrders.length;
geometry._lineIndexesHandlerIndex = this._lineIndexes.length;
@ -365,7 +364,7 @@ class GeometryHandler {
}
}
//Creates polygon stroke data
// Creates polygon stroke data
geometry._lineVerticesHandlerIndex = this._lineVerticesMerc.length;
geometry._lineOrdersHandlerIndex = this._lineOrders.length;
geometry._lineIndexesHandlerIndex = this._lineIndexes.length;
@ -385,7 +384,7 @@ class GeometryHandler {
geometry._lineThicknessLength = this._lineThickness.length - geometry._lineThicknessHandlerIndex;
}
//Refresh visibility
// Refresh visibility
this.setGeometryVisibility(geometry);
!this._updatedGeometry[geometry._id] && this._updatedGeometryArr.push(geometry);
@ -399,8 +398,8 @@ class GeometryHandler {
if (index !== -1) {
this._geometries.splice(index, 1);
//polygon
//this._polyVerticesLonLat.splice(geometry._polyVerticesHandlerIndex, geometry._polyVerticesLength);
// polygon
// this._polyVerticesLonLat.splice(geometry._polyVerticesHandlerIndex, geometry._polyVerticesLength);
this._polyVerticesMerc.splice(geometry._polyVerticesHandlerIndex, geometry._polyVerticesLength);
this._polyColors.splice(geometry._polyVerticesHandlerIndex * 2, geometry._polyVerticesLength * 2);
this._polyPickingColors.splice(geometry._polyVerticesHandlerIndex * 2, geometry._polyVerticesLength * 2);
@ -410,8 +409,8 @@ class GeometryHandler {
this._polyIndexes[i] -= di;
}
//line
//this._lineVerticesLonLat.splice(geometry._lineVerticesHandlerIndex, geometry._lineVerticesLength);
// line
// this._lineVerticesLonLat.splice(geometry._lineVerticesHandlerIndex, geometry._lineVerticesLength);
this._lineVerticesMerc.splice(geometry._lineVerticesHandlerIndex, geometry._lineVerticesLength);
this._lineOrders.splice(geometry._lineOrdersHandlerIndex, geometry._lineOrdersLength);
this._lineColors.splice(geometry._lineColorsHandlerIndex, geometry._lineColorsLength);
@ -425,7 +424,7 @@ class GeometryHandler {
this._lineIndexes[i] -= di;
}
//reindex
// reindex
var g = this._geometries;
for (let i = index; i < g.length; i++) {
var gi = g[i];

View File

@ -8,7 +8,6 @@ import * as utils from '../utils/shared.js';
import { BaseBillboard } from './BaseBillboard.js';
import { Vec4 } from '../math/Vec4.js';
const ALIGN = {
RIGHT: 0,
LEFT: 1,
@ -21,9 +20,9 @@ const ALIGN = {
* @enum {number}
*/
const STR2ALIGN = {
"left": ALIGN.LEFT,
"right": ALIGN.RIGHT,
"center": ALIGN.CENTER
left: ALIGN.LEFT,
right: ALIGN.RIGHT,
center: ALIGN.CENTER
};
/**

View File

@ -50,7 +50,6 @@ class LabelHandler extends BillboardHandler {
this._maxLetters = 25;
}
initProgram() {
if (this._renderer.handler) {
@ -170,7 +169,7 @@ class LabelHandler extends BillboardHandler {
var x = label._positionHigh.x, y = label._positionHigh.y, z = label._positionHigh.z, w;
BillboardHandler.concArr(this._positionHighArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
x = label._positionLow.x, y = label._positionLow.y, z = label._positionLow.z;
x = label._positionLow.x; y = label._positionLow.y; z = label._positionLow.z;
BillboardHandler.concArr(this._positionLowArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
x = label._size;
@ -185,22 +184,22 @@ class LabelHandler extends BillboardHandler {
x = label._rotation;
BillboardHandler.concArr(this._rotationArr, [x, x, x, x, x, x]);
x = label._alignedAxis.x, y = label._alignedAxis.y, z = label._alignedAxis.z;
x = label._alignedAxis.x; y = label._alignedAxis.y; z = label._alignedAxis.z;
BillboardHandler.concArr(this._alignedAxisArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
x = label._fontIndex;
BillboardHandler.concArr(this._fontIndexArr, [0, 0, 0, 0, 0, 0]);
x = 1.0 - label._outline, y = 0.0;
x = 1.0 - label._outline; y = 0.0;
BillboardHandler.concArr(this._outlineArr, [x, y, x, y, x, y, x, y, x, y, x, y]);
x = 0.75, y = 0.7;
x = 0.75; y = 0.7;
BillboardHandler.concArr(this._noOutlineArr, [x, y, x, y, x, y, x, y, x, y, x, y]);
x = label._outlineColor.x; y = label._outlineColor.y; z = label._outlineColor.z; w = label._outlineColor.w;
BillboardHandler.concArr(this._outlineColorArr, [x, y, z, w, x, y, z, w, x, y, z, w, x, y, z, w, x, y, z, w, x, y, z, w]);
x = label._entity._pickingColor.x / 255, y = label._entity._pickingColor.y / 255, z = label._entity._pickingColor.z / 255;
x = label._entity._pickingColor.x / 255; y = label._entity._pickingColor.y / 255; z = label._entity._pickingColor.z / 255;
BillboardHandler.concArr(this._pickingColorArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
}
};
@ -261,7 +260,7 @@ class LabelHandler extends BillboardHandler {
gl.bindBuffer(gl.ARRAY_BUFFER, this._fontIndexBuffer);
gl.vertexAttribPointer(sha.a_fontIndex, this._fontIndexBuffer.itemSize, gl.FLOAT, false, 0, 0);
//buffer
// buffer
gl.bindBuffer(gl.ARRAY_BUFFER, this._outlineColorBuffer);
gl.vertexAttribPointer(sha.a_rgba, this._outlineColorBuffer.itemSize, gl.FLOAT, false, 0, 0);
@ -271,7 +270,7 @@ class LabelHandler extends BillboardHandler {
gl.uniform1f(shu.uZ, -2.0);
gl.drawArrays(gl.TRIANGLES, 0, this._vertexBuffer.numItems);
//nobuffer
// nobuffer
gl.bindBuffer(gl.ARRAY_BUFFER, this._rgbaBuffer);
gl.vertexAttribPointer(sha.a_rgba, this._rgbaBuffer.itemSize, gl.FLOAT, false, 0, 0);
@ -374,8 +373,8 @@ class LabelHandler extends BillboardHandler {
label._handlerIndex = -1;
label._handler = null;
//label._fontIndex = 0;
//label._fontAtlas = null;
// label._fontIndex = 0;
// label._fontAtlas = null;
};
setText(index, text, fontIndex, align) {
@ -389,14 +388,14 @@ class LabelHandler extends BillboardHandler {
var c = 0;
var j = i + c * 24;
// var j = i + c * 24;
var n = fa.nodes[text[c]];
var f = n ? n.emptySize : 0.0;
var offset = f;
for (c = 0; c < text.length; c++) {
var j = i + c * 24;
var n = fa.nodes[text[c]] || fa.nodes[" "];
n = fa.nodes[text[c]] || fa.nodes[" "];
var tc = n.texCoords;
a[j] = tc[0];
@ -432,11 +431,11 @@ class LabelHandler extends BillboardHandler {
offset += n.emptySize;
}
//49/512 - font atlas left border letter offset
// 49/512 - font atlas left border letter offset
if (align === ALIGN.CENTER) {
offset = (f + 49 / 512 - offset) * 0.5;
for (c = 0; c < text.length; c++) {
var j = i + c * 24;
let j = i + c * 24;
a[j + 3] = offset;
a[j + 7] = offset;
a[j + 11] = offset;
@ -447,7 +446,7 @@ class LabelHandler extends BillboardHandler {
} else if (align === ALIGN.LEFT) {
offset = (f + 49 / 512 - offset);
for (c = 0; c < text.length; c++) {
var j = i + c * 24;
let j = i + c * 24;
a[j + 3] = offset;
a[j + 7] = offset;
a[j + 11] = offset;
@ -458,7 +457,7 @@ class LabelHandler extends BillboardHandler {
}
for (; c < this._maxLetters; c++) {
var j = i + c * 24;
let j = i + c * 24;
a[j + 2] = -1.0;
a[j + 6] = -1.0;
a[j + 10] = -1.0;
@ -473,7 +472,7 @@ class LabelHandler extends BillboardHandler {
setPositionArr(index, positionHigh, positionLow) {
var i = index * 18 * this._maxLetters;
var a = this._positionHighArr, x = positionHigh.x, y = positionHigh.y, z = positionHigh.z,
b = this._positionLowArr, xl = positionLow.x, yl = positionLow.y, zl = positionLow.z
b = this._positionLowArr, xl = positionLow.x, yl = positionLow.y, zl = positionLow.z;
for (var q = 0; q < this._maxLetters; q++) {
var j = i + q * 18;
@ -501,7 +500,7 @@ class LabelHandler extends BillboardHandler {
a[j + 16] = y;
a[j + 17] = z;
//low
// low
b[j] = xl;
b[j + 1] = yl;
b[j + 2] = zl;
@ -731,7 +730,7 @@ class LabelHandler extends BillboardHandler {
a[j + 5] = rotation;
}
this._changedBuffers[ROTATION_BUFFER] = true
this._changedBuffers[ROTATION_BUFFER] = true;
}
setVertexArr(index, vertexArr) {
@ -849,11 +848,11 @@ class LabelHandler extends BillboardHandler {
setMaxLetters(c) {
this._maxLetters = c;
//...
// TODO: ...
}
refreshTexCoordsArr() {
//it is empty
// it is empty
return null;
}
};

View File

@ -221,13 +221,13 @@ class PointCloud {
this._coordinatesData.push(pos.x, pos.y, pos.z);
this._colorData.push(col.x / 255.0, col.y / 255.0, col.z / 255.0, col.w / 255.0);
var p = {
'_pickingColor': new Vec3(),
'_entityCollection': this._entity && this._entity._entityCollection,
'index': i,
'position': pos,
'color': col,
'pointCloud': this,
'properties': pi[7] || {}
_pickingColor: new Vec3(),
_entityCollection: this._entity && this._entity._entityCollection,
index: i,
position: pos,
color: col,
pointCloud: this,
properties: pi[7] || {}
};
this._points.push(p);
@ -244,21 +244,21 @@ class PointCloud {
setPointPosition(index, x, y, z) {
//...
// TODO: ...
this._changedBuffers[COORDINATES_BUFFER] = true;
}
setPointColor(index, r, g, b, a) {
//...
// TODO: ...
this._changedBuffers[COLOR_BUFFER] = true;
}
addPoints(points) {
//...
// TODO: ...
this._changedBuffers[COORDINATES_BUFFER] = true;
this._changedBuffers[COLOR_BUFFER] = true;
@ -267,7 +267,7 @@ class PointCloud {
addPoint(index, point) {
//...
// TODO: ...
this._changedBuffers[COORDINATES_BUFFER] = true;
this._changedBuffers[COLOR_BUFFER] = true;
@ -286,7 +286,7 @@ class PointCloud {
removePoint(index) {
//...
// TODO: ...
this._changedBuffers[COORDINATES_BUFFER] = true;
this._changedBuffers[COLOR_BUFFER] = true;
@ -295,7 +295,7 @@ class PointCloud {
insertPoint(index, point) {
//...
// TODO: ...
this._changedBuffers[COORDINATES_BUFFER] = true;
this._changedBuffers[COLOR_BUFFER] = true;

View File

@ -61,7 +61,7 @@ class PointCloudHandler {
setRenderNode(renderNode) {
this._renderer = renderNode.renderer;
this._initProgram()
this._initProgram();
for (var i = 0; i < this._pointClouds.length; i++) {
this._pointClouds[i].setRenderNode(renderNode);
}

View File

@ -8,8 +8,6 @@ import * as utils from '../utils/shared.js';
import { Extent } from '../Extent.js';
import { LonLat } from '../LonLat.js';
import { Vec3 } from '../math/Vec3.js';
import { Vec4 } from '../math/Vec4.js';
import { doubleToTwoFloats } from '../math/coder.js';
const VERTICES_BUFFER = 0;
const INDEX_BUFFER = 1;
@ -62,7 +60,7 @@ class Polyline {
* @public
* @type {Array<Number,Number,Number,Number>}
*/
this._defaultColor = utils.htmlColorToFloat32Array(options.color || DEFAULT_COLOR, options.opacity);//utils.createColorRGBA(options.color, new Vec4(1.0, 1.0, 1.0, 1.0));
this._defaultColor = utils.htmlColorToFloat32Array(options.color || DEFAULT_COLOR, options.opacity); // utils.createColorRGBA(options.color, new Vec4(1.0, 1.0, 1.0, 1.0));
/**
* Polyline visibility.
@ -146,7 +144,7 @@ class Polyline {
this._changedBuffers = new Array(this._buffersUpdateCallbacks.length);
//create path
// create path
if (options.pathLonLat) {
this.setPathLonLat(options.pathLonLat);
} else if (options.path3v) {
@ -167,7 +165,6 @@ class Polyline {
this._counter = n;
}
/**
* Appends to the line array new cartesian coordinates line data.
* @param {Array.<Array.<number, number, number>>} path3v - Line coordinates path array.
@ -282,21 +279,25 @@ class Polyline {
outTransformedPathLonLat[j].push(lonLat);
outTransformedPathMerc[j].push(lonLat.forwardMercator());
if (lonLat.lon < outExtent.southWest.lon)
if (lonLat.lon < outExtent.southWest.lon) {
outExtent.southWest.lon = lonLat.lon;
if (lonLat.lat < outExtent.southWest.lat)
}
if (lonLat.lat < outExtent.southWest.lat) {
outExtent.southWest.lat = lonLat.lat;
if (lonLat.lon > outExtent.northEast.lon)
}
if (lonLat.lon > outExtent.northEast.lon) {
outExtent.northEast.lon = lonLat.lon;
if (lonLat.lat > outExtent.northEast.lat)
}
if (lonLat.lat > outExtent.northEast.lat) {
outExtent.northEast.lat = lonLat.lat;
}
}
if (pathColors_j && pathColors_j[i]) {
color = pathColors_j[i];
}
r = color[R], g = color[G], b = color[B], a = (color[A] != undefined ? color[A] : 1.0);
r = color[R]; g = color[G]; b = color[B]; a = (color[A] != undefined ? color[A] : 1.0);
Vec3.doubleToTwoFloats(cur, v_high, v_low);
outVerticesHigh.push(v_high.x, v_high.y, v_high.z, v_high.x, v_high.y, v_high.z, v_high.x, v_high.y, v_high.z, v_high.x, v_high.y, v_high.z);
@ -332,7 +333,7 @@ class Polyline {
color = pathColors_j[path.length - 1];
}
r = color[R], g = color[G], b = color[B], a = (color[A] != undefined ? color[A] : 1.0);
r = color[R]; g = color[G]; b = color[B]; a = (color[A] != undefined ? color[A] : 1.0);
Vec3.doubleToTwoFloats(first, v_high, v_low);
outVerticesHigh.push(v_high.x, v_high.y, v_high.z, v_high.x, v_high.y, v_high.z, v_high.x, v_high.y, v_high.z, v_high.x, v_high.y, v_high.z);
@ -482,14 +483,18 @@ class Polyline {
transformedPathLonLat.push(lonLat);
transformedPathMerc.push(lonLat.forwardMercator());
if (lonLat.lon < outExtent.southWest.lon)
if (lonLat.lon < outExtent.southWest.lon) {
outExtent.southWest.lon = lonLat.lon;
if (lonLat.lat < outExtent.southWest.lat)
}
if (lonLat.lat < outExtent.southWest.lat) {
outExtent.southWest.lat = lonLat.lat;
if (lonLat.lon > outExtent.northEast.lon)
}
if (lonLat.lon > outExtent.northEast.lon) {
outExtent.northEast.lon = lonLat.lon;
if (lonLat.lat > outExtent.northEast.lat)
}
if (lonLat.lat > outExtent.northEast.lat) {
outExtent.northEast.lat = lonLat.lat;
}
}
Vec3.doubleToTwoFloats(point3v, v_high, v_low);
@ -545,7 +550,6 @@ class Polyline {
outIndexes[ii + 1] = index++;
outIndexes[ii + 2] = index++;
outIndexes[ii + 3] = index++;
//}
//
// Close path
@ -682,7 +686,7 @@ class Polyline {
color = pathColors_j[i];
}
r = color[R], g = color[G], b = color[B], a = (color[A] != undefined ? color[A] : 1.0);
r = color[R]; g = color[G]; b = color[B]; a = (color[A] != undefined ? color[A] : 1.0);
var cartesian = ellipsoid.lonLatToCartesian(cur);
outTransformedPathCartesian[j].push(cartesian);
@ -698,14 +702,18 @@ class Polyline {
outOrders.push(1, -1, 2, -2);
outIndexes.push(index++, index++, index++, index++);
if (cur.lon < outExtent.southWest.lon)
if (cur.lon < outExtent.southWest.lon) {
outExtent.southWest.lon = cur.lon;
if (cur.lat < outExtent.southWest.lat)
}
if (cur.lat < outExtent.southWest.lat) {
outExtent.southWest.lat = cur.lat;
if (cur.lon > outExtent.northEast.lon)
}
if (cur.lon > outExtent.northEast.lon) {
outExtent.northEast.lon = cur.lon;
if (cur.lat > outExtent.northEast.lat)
}
if (cur.lat > outExtent.northEast.lat) {
outExtent.northEast.lat = cur.lat;
}
}
var first;
@ -745,7 +753,7 @@ class Polyline {
color = pathColors_j[path.length - 1];
}
r = color[R], g = color[G], b = color[B], a = (color[A] != undefined ? color[A] : 1.0);
r = color[R]; g = color[G]; b = color[B]; a = (color[A] != undefined ? color[A] : 1.0);
Vec3.doubleToTwoFloats(first, v_high, v_low);
outVerticesHigh.push(v_high.x, v_high.y, v_high.z, v_high.x, v_high.y, v_high.z, v_high.x, v_high.y, v_high.z, v_high.x, v_high.y, v_high.z);
@ -789,7 +797,7 @@ class Polyline {
var last;
if (this._closedLine) {
last = path[path.length - 1]
last = path[path.length - 1];
} else {
last = new Vec3(path[0].x + path[0].x - path[1].x, path[0].y + path[0].y - path[1].y, path[0].z + path[0].z - path[1].z);
}
@ -839,14 +847,18 @@ class Polyline {
l[j][i] = lonLat;
m[j][i] = lonLat.forwardMercator();
if (lonLat.lon < extent.southWest.lon)
if (lonLat.lon < extent.southWest.lon) {
extent.southWest.lon = lonLat.lon;
if (lonLat.lat < extent.southWest.lat)
}
if (lonLat.lat < extent.southWest.lat) {
extent.southWest.lat = lonLat.lat;
if (lonLat.lon > extent.northEast.lon)
}
if (lonLat.lon > extent.northEast.lon) {
extent.northEast.lon = lonLat.lon;
if (lonLat.lat > extent.northEast.lat)
}
if (lonLat.lat > extent.northEast.lat) {
extent.northEast.lat = lonLat.lat;
}
}
Vec3.doubleToTwoFloats(cur, v_high, v_low);
@ -1011,14 +1023,18 @@ class Polyline {
vh[k] = v_high.z;
vl[k++] = v_low.z;
if (cur.lon < extent.southWest.lon)
if (cur.lon < extent.southWest.lon) {
extent.southWest.lon = cur.lon;
if (cur.lat < extent.southWest.lat)
}
if (cur.lat < extent.southWest.lat) {
extent.southWest.lat = cur.lat;
if (cur.lon > extent.northEast.lon)
}
if (cur.lon > extent.northEast.lon) {
extent.northEast.lon = cur.lon;
if (cur.lat > extent.northEast.lat)
}
if (cur.lat > extent.northEast.lat) {
extent.northEast.lat = cur.lat;
}
}
var first;
@ -1079,14 +1095,18 @@ class Polyline {
for (var j = 0; j < pi.length; j++) {
var lon = pi[j].lon,
lat = pi[j].lat;
if (lon > extent.northEast.lon)
if (lon > extent.northEast.lon) {
extent.northEast.lon = lon;
if (lat > extent.northEast.lat)
}
if (lat > extent.northEast.lat) {
extent.northEast.lat = lat;
if (lon < extent.southWest.lon)
}
if (lon < extent.southWest.lon) {
extent.southWest.lon = lon;
if (lat < extent.southWest.lat)
}
if (lat < extent.southWest.lat) {
extent.southWest.lat = lat;
}
}
}
@ -1129,12 +1149,10 @@ class Polyline {
let _closedLine = this._closedLine || path.length === 1;
//if (path.length === 1) return;
if (index === 0 || index === 1) {
var last;
if (_closedLine) {
last = path[path.length - 1]
last = path[path.length - 1];
} else {
last = new Vec3(path[0].x + path[0].x - path[1].x, path[0].y + path[0].y - path[1].y, path[0].z + path[0].z - path[1].z);
}
@ -1181,19 +1199,23 @@ class Polyline {
var extent = this._extent;
extent.southWest.set(180.0, 90.0);
extent.northEast.set(-180.0, -90.0);
for (var i = 0; i < l.length; i++) {
for (let i = 0; i < l.length; i++) {
var pi = l[i];
for (var j = 0; j < pi.length; j++) {
var lon = pi[j].lon,
lat = pi[j].lat;
if (lon > extent.northEast.lon)
if (lon > extent.northEast.lon) {
extent.northEast.lon = lon;
if (lat > extent.northEast.lat)
}
if (lat > extent.northEast.lat) {
extent.northEast.lat = lat;
if (lon < extent.southWest.lon)
}
if (lon < extent.southWest.lon) {
extent.southWest.lon = lon;
if (lat < extent.southWest.lat)
}
if (lat < extent.southWest.lat) {
extent.southWest.lat = lat;
}
}
}
}
@ -1280,7 +1302,7 @@ class Polyline {
removeSegment(index) {
//
//TODO: could be optimized. Partially see appendPoint3v.
// TODO: could be optimized. Partially see appendPoint3v.
//
this._path3v.splice(index, 1);
this.setPath3v([].concat(this._path3v));
@ -1288,7 +1310,7 @@ class Polyline {
removePoint(index, multiLineIndex) {
//
//TODO: could be optimized. Partially see appendPoint3v.
// TODO: could be optimized. Partially see appendPoint3v.
//
multiLineIndex = multiLineIndex || 0;
this._path3v[multiLineIndex].splice(index, 1);
@ -1357,7 +1379,7 @@ class Polyline {
*/
addPoint3v(point3v, multiLineIndex = 0) {
//
//TODO: could be optimized
// TODO: could be optimized
//
if (multiLineIndex >= this._path3v.length) {
this._path3v.push([]);
@ -1374,7 +1396,7 @@ class Polyline {
*/
addPointLonLat(lonLat, multiLineIndex = 0) {
//
//TODO: could be optimized
// TODO: could be optimized
//
if (multiLineIndex >= this._pathLonLat.length) {
this._pathLonLat.push([]);
@ -1406,7 +1428,7 @@ class Polyline {
}
if (!colors[index]) {
colors[index] = new Array(color[R], color[G], color[B], color[A] || 1.0);
colors[index] = [color[R], color[G], color[B], color[A] || 1.0];
} else {
colors[index][R] = color[R];
colors[index][G] = color[G];
@ -1634,21 +1656,10 @@ class Polyline {
setPathColors(pathColors) {
if (this._renderNode) {
//...
// ...
}
}
setPointColor(color, index, segmentIndex) {
let s = this._pathColors[segmentIndex];
if (s) {
s[index][0] = color[0];
s[index][1] = color[1];
s[index][2] = color[2];
s[index][3] = color[3];
}
//...
}
setColorHTML(htmlColor) {
let color = utils.htmlColorToRgba(htmlColor),
p = this._pathColors;
@ -1750,7 +1761,7 @@ class Polyline {
gl.uniformMatrix4fv(shu.proj, false, r.activeCamera._projectionMatrix._m);
gl.uniformMatrix4fv(shu.view, false, r.activeCamera._viewMatrix._m);
//gl.uniform4fv(shu.color, [this.color.x, this.color.y, this.color.z, this.color.w * this._handler._entityCollection._fadingOpacity]);
// gl.uniform4fv(shu.color, [this.color.x, this.color.y, this.color.z, this.color.w * this._handler._entityCollection._fadingOpacity]);
gl.uniform3fv(shu.eyePositionHigh, r.activeCamera.eyeHigh);
gl.uniform3fv(shu.eyePositionLow, r.activeCamera.eyeLow);
@ -1759,11 +1770,9 @@ class Polyline {
gl.uniform2fv(shu.viewport, [r.handler.canvas.width, r.handler.canvas.height]);
gl.uniform1f(shu.thickness, this.thickness * 0.5);
gl.bindBuffer(gl.ARRAY_BUFFER, this._colorsBuffer);
gl.vertexAttribPointer(sha.color, this._colorsBuffer.itemSize, gl.FLOAT, false, 0, 0);
var v = this._verticesHighBuffer;
gl.bindBuffer(gl.ARRAY_BUFFER, v);
gl.vertexAttribPointer(sha.prevHigh, v.itemSize, gl.FLOAT, false, 12, 0);

View File

@ -44,7 +44,7 @@ class PolylineHandler {
setRenderNode(renderNode) {
this._renderer = renderNode.renderer;
this._initProgram()
this._initProgram();
for (var i = 0; i < this._polylines.length; i++) {
this._polylines[i].setRenderNode(renderNode);
}

View File

@ -31,10 +31,10 @@ class Ray {
*/
this.id = Entity._staticCounter++;
//Thickenss
// Thickenss
this._thickness = options.thickness || 2.0;
//RTE length
// RTE length
this._length = options.length || 0.0;
this._lengthHighLow = new Float32Array(2);
doubleToTwoFloats2(this._length, this._lengthHighLow);
@ -51,7 +51,7 @@ class Ray {
this._endPositionLow = new Vec3();
Vec3.doubleToTwoFloats(this._endPosition, this._endPositionHigh, this._endPositionLow);
//start end point colors
// start end point colors
this._startColor = utils.createColorRGBA(options.startColor);
this._endColor = utils.createColorRGBA(options.endColor);
@ -142,7 +142,6 @@ class Ray {
setLength(length) {
this._length = length;
//doubleToTwoFloats2(this._length, this._lengthHighLow);
this._handler && this._handler.setLengthArr(this._handlerIndex, length);
}

View File

@ -90,9 +90,9 @@ class RayHandler {
this._renderer.handler.addProgram(shaders.rayScreen());
}
//if (!this._renderer.handler.programs.billboardPicking) {
// this._renderer.handler.addProgram(shaders.billboardPicking());
//}
// if (!this._renderer.handler.programs.billboardPicking) {
// this._renderer.handler.addProgram(shaders.billboardPicking());
// }
}
}
@ -108,7 +108,7 @@ class RayHandler {
}
}
_removeRay() {
_removeRays() {
var i = this._rays.length;
while (i--) {
var ri = this._rays[i];
@ -198,13 +198,13 @@ class RayHandler {
let x = ray._startPositionHigh.x, y = ray._startPositionHigh.y, z = ray._startPositionHigh.z;
RayHandler.concArr(this._startPositionHighArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
x = ray._startPositionLow.x, y = ray._startPositionLow.y, z = ray._startPositionLow.z;
x = ray._startPositionLow.x; y = ray._startPositionLow.y; z = ray._startPositionLow.z;
RayHandler.concArr(this._startPositionLowArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
x = ray._endPositionHigh.x, y = ray._endPositionHigh.y, z = ray._endPositionHigh.z;
x = ray._endPositionHigh.x; y = ray._endPositionHigh.y; z = ray._endPositionHigh.z;
RayHandler.concArr(this._endPositionHighArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
x = ray._endPositionLow.x, y = ray._endPositionLow.y, z = ray._endPositionLow.z;
x = ray._endPositionLow.x; y = ray._endPositionLow.y; z = ray._endPositionLow.z;
RayHandler.concArr(this._endPositionLowArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
x = ray._thickness;
@ -217,7 +217,7 @@ class RayHandler {
r1 = ray._endColor.x, g1 = ray._endColor.y, b1 = ray._endColor.z, a1 = ray._endColor.w;
RayHandler.concArr(this._rgbaArr, [r1, g1, b1, a1, r0, g0, b0, a0, r0, g0, b0, a0, r0, g0, b0, a0, r1, g1, b1, a1, r1, g1, b1, a1]);
x = ray._entity._pickingColor.x / 255, y = ray._entity._pickingColor.y / 255, z = ray._entity._pickingColor.z / 255;
x = ray._entity._pickingColor.x / 255; y = ray._entity._pickingColor.y / 255; z = ray._entity._pickingColor.z / 255;
RayHandler.concArr(this._pickingColorArr, [x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y, z]);
}
@ -244,23 +244,18 @@ class RayHandler {
gl.uniform1f(shu.resolution, r.activeCamera._tanViewAngle_hradOneByHeight);
gl.bindBuffer(gl.ARRAY_BUFFER, this._startPositionHighBuffer);
gl.vertexAttribPointer(sha.a_startPosHigh, this._startPositionHighBuffer.itemSize, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, this._startPositionLowBuffer);
gl.vertexAttribPointer(sha.a_startPosLow, this._startPositionLowBuffer.itemSize, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, this._endPositionHighBuffer);
gl.vertexAttribPointer(sha.a_endPosHigh, this._endPositionHighBuffer.itemSize, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, this._endPositionLowBuffer);
gl.vertexAttribPointer(sha.a_endPosLow, this._endPositionLowBuffer.itemSize, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, this._rgbaBuffer);
gl.vertexAttribPointer(sha.a_rgba, this._rgbaBuffer.itemSize, gl.FLOAT, false, 0, 0);
@ -278,7 +273,7 @@ class RayHandler {
}
_pickingPASS() {
//...
// ...
};
draw() {
@ -340,7 +335,7 @@ class RayHandler {
var i = index * 18;
//High
// High
var a = this._startPositionHighArr, x = positionHigh.x, y = positionHigh.y, z = positionHigh.z;
a[i] = x;
@ -367,8 +362,8 @@ class RayHandler {
a[i + 16] = y;
a[i + 17] = z;
//Low
a = this._startPositionLowArr, x = positionLow.x, y = positionLow.y, z = positionLow.z;
// Low
a = this._startPositionLowArr; x = positionLow.x; y = positionLow.y; z = positionLow.z;
a[i] = x;
a[i + 1] = y;
@ -400,7 +395,7 @@ class RayHandler {
setEndPositionArr(index, positionHigh, positionLow) {
var i = index * 18;
//High
// High
var a = this._endPositionHighArr, x = positionHigh.x, y = positionHigh.y, z = positionHigh.z;
a[i] = x;
@ -427,8 +422,8 @@ class RayHandler {
a[i + 16] = y;
a[i + 17] = z;
//Low
a = this._endPositionLowArr, x = positionLow.x, y = positionLow.y, z = positionLow.z;
// Low
a = this._endPositionLowArr; x = positionLow.x; y = positionLow.y; z = positionLow.z;
a[i] = x;
a[i + 1] = y;
@ -541,7 +536,7 @@ class RayHandler {
a[i + 4] = thickness;
a[i + 5] = thickness;
this._changedBuffers[THICKNESS_BUFFER] = true
this._changedBuffers[THICKNESS_BUFFER] = true;
}
setLengthArr(index, length) {
@ -556,7 +551,7 @@ class RayHandler {
a[i + 4] = length;
a[i + 5] = length;
this._changedBuffers[LENGTH_BUFFER] = true
this._changedBuffers[LENGTH_BUFFER] = true;
}
setVisibility(index, visibility) {

View File

@ -44,15 +44,15 @@ class ShapeHandler {
if (!this._renderer.handler.programs.shape_wl) {
this._renderer.handler.addProgram(shaders.shape_wl());
}
//if (!this._renderer.handler.programs.shapePicking) {
// this._renderer.handler.addProgram(shaders.shapePicking());
//}
// if (!this._renderer.handler.programs.shapePicking) {
// this._renderer.handler.addProgram(shaders.shapePicking());
// }
}
}
setRenderNode(renderNode) {
this._renderer = renderNode.renderer;
this._initProgram()
this._initProgram();
for (var i = 0; i < this._shapes.length; i++) {
this._shapes[i].setRenderNode(renderNode);
}
@ -68,7 +68,7 @@ class ShapeHandler {
}
remove(shape) {
//TODO
// TODO
}
draw() {
@ -79,11 +79,11 @@ class ShapeHandler {
}
drawPicking() {
//TODO
// TODO
}
clear() {
//TODO
// TODO
}
};

View File

@ -3,7 +3,6 @@
import { Vec3 } from '../math/Vec3.js';
import { Line3 } from '../math/Line3.js';
let _tempHigh = new Vec3(),
_tempLow = new Vec3();
@ -496,7 +495,7 @@ class Strip {
let p01 = p0.lerp(p1, dj),
p23 = p2.lerp(p3, dj);
//prev
// prev
(new Line3(p02, p13)).intersects(new Line3(p01, p23), p);
let ij = i * gs1 + j;
@ -515,7 +514,7 @@ class Strip {
vLow[ind3 + 1] = _tempLow.y;
vLow[ind3 + 2] = _tempLow.z;
//next
// next
let p45 = p4.lerp(p5, dj);
p23 = p2.lerp(p3, dj);

View File

@ -96,7 +96,7 @@ class StripHandler {
setRenderNode(renderNode) {
this._renderer = renderNode.renderer;
this._initProgram()
this._initProgram();
for (var i = 0; i < this._strips.length; i++) {
this._strips[i].setRenderNode(renderNode);
}

View File

@ -7,22 +7,11 @@ import * as utils from './utils/shared.js';
import { Box } from './bv/Box.js';
import { Sphere } from './bv/Sphere.js';
const bv = {
'Box': Box,
'Sphere': Sphere
};
import { Control } from './control/Control.js';
import { DebugInfo } from './control/DebugInfo';
import { SimpleNavigation } from './control/SimpleNavigation.js';
import { ShowFps } from './control/ShowFps.js';
const control = {
'DebugInfo': DebugInfo,
'SimpleNavigation': SimpleNavigation,
'ShowFps': ShowFps
};
import { Entity } from './entity/Entity.js';
import { EntityCollection } from './entity/EntityCollection.js';
import { Billboard } from './entity/Billboard.js';
@ -30,13 +19,6 @@ import { Label } from './entity/Label.js';
import { PointCloud } from './entity/PointCloud.js';
import { Polyline } from './entity/Polyline.js';
const entity = {
'Billboard': Billboard,
'Label': Label,
'PointCloud': PointCloud,
'Polyline': Polyline
};
import { input } from './input/input.js';
import { Camera } from './camera/Camera.js';
@ -58,14 +40,6 @@ import { Multisample } from './webgl/Multisample.js';
import { types } from './webgl/types.js';
import { Program } from './webgl/Program.js';
const webgl = {
'Framebuffer': Framebuffer,
'Handler': Handler,
'Multisample': Multisample,
'types': types,
'Program': Program
};
import { Renderer } from './renderer/Renderer.js';
import { LightSource } from './light/LightSource.js';
@ -78,8 +52,34 @@ import { RenderNode } from './scene/RenderNode.js';
import { TextureAtlas } from './utils/TextureAtlas.js';
const bv = {
Box: Box,
Sphere: Sphere
};
const control = {
DebugInfo: DebugInfo,
SimpleNavigation: SimpleNavigation,
ShowFps: ShowFps
};
const entity = {
Billboard: Billboard,
Label: Label,
PointCloud: PointCloud,
Polyline: Polyline
};
const webgl = {
Framebuffer: Framebuffer,
Handler: Handler,
Multisample: Multisample,
types: types,
Program: Program
};
const scene = {
'Axes': Axes
Axes: Axes
};
export {

View File

@ -1,9 +1,5 @@
'use strict';
const version = {
version: __VERSION__
};
import '../../css/og.css';
import * as jd from './astro/jd.js';
@ -16,11 +12,6 @@ import { Globe } from './Globe.js';
import { Box } from './bv/Box.js';
import { Sphere } from './bv/Sphere.js';
const bv = {
'Box': Box,
'Sphere': Sphere
};
import { CanvasTiles } from './layer/CanvasTiles.js';
import { GeoImage } from './layer/GeoImage.js';
import { GeoTexture2d } from './layer/GeoTexture2d.js';
@ -30,16 +21,6 @@ import { Vector } from './layer/Vector.js';
import { WMS } from './layer/WMS.js';
import { XYZ } from './layer/XYZ.js';
const layer = {
'CanvasTiles': CanvasTiles,
'GeoImage': GeoImage,
'GeoTexture2d': GeoTexture2d,
'GeoVideo': GeoVideo,
'Vector': Vector,
'WMS': WMS,
'XYZ': XYZ,
};
import { Control } from './control/Control.js';
import { DebugInfo } from './control/DebugInfo';
import { EarthCoordinates } from './control/EarthCoordinates.js';
@ -54,21 +35,6 @@ import { ShowFps } from './control/ShowFps.js';
import { Sun } from './control/Sun.js';
import { ZoomControl } from './control/ZoomControl.js';
const control = {
'DebugInfo': DebugInfo,
'EarthCoordinates': EarthCoordinates,
'GeoImageDragControl': GeoImageDragControl,
'KeyboardNavigation': KeyboardNavigation,
'LayerSwitcher': LayerSwitcher,
'MouseNavigation': MouseNavigation,
'ToggleWireframe': ToggleWireframe,
'TouchNavigation': TouchNavigation,
'SimpleNavigation': SimpleNavigation,
'ShowFps': ShowFps,
'Sun': Sun,
'ZoomControl': ZoomControl
};
import { Entity } from './entity/Entity.js';
import { EntityCollection } from './entity/EntityCollection.js';
import { Billboard } from './entity/Billboard.js';
@ -77,14 +43,6 @@ import { Label } from './entity/Label.js';
import { PointCloud } from './entity/PointCloud.js';
import { Polyline } from './entity/Polyline.js';
const entity = {
'Billboard': Billboard,
'Geometry': Geometry,
'Label': Label,
'PointCloud': PointCloud,
'Polyline': Polyline
};
import { input } from './input/input.js';
import { Ellipsoid } from './ellipsoid/Ellipsoid.js';
@ -94,12 +52,6 @@ import { EmptyTerrain } from './terrain/EmptyTerrain.js';
import { GlobusTerrain } from './terrain/GlobusTerrain.js';
import { MapboxTerrain } from './terrain/MapboxTerrain.js';
const terrain = {
'EmptyTerrain': EmptyTerrain,
'GlobusTerrain': GlobusTerrain,
'MapboxTerrain': MapboxTerrain
};
import { Camera } from './camera/Camera.js';
import { PlanetCamera } from './camera/PlanetCamera.js';
@ -120,14 +72,6 @@ import { Multisample } from './webgl/Multisample.js';
import { types } from './webgl/types.js';
import { Program } from './webgl/Program.js';
const webgl = {
'Framebuffer': Framebuffer,
'Handler': Handler,
'Multisample': Multisample,
'types': types,
'Program': Program
};
import { Renderer } from './renderer/Renderer.js';
import { LightSource } from './light/LightSource.js';
@ -141,9 +85,65 @@ import { Axes } from './scene/Axes.js';
import { Planet } from './scene/Planet.js';
import { RenderNode } from './scene/RenderNode.js';
const version = {
version: __VERSION__
};
const bv = {
Box: Box,
Sphere: Sphere
};
const layer = {
CanvasTiles: CanvasTiles,
GeoImage: GeoImage,
GeoTexture2d: GeoTexture2d,
GeoVideo: GeoVideo,
Vector: Vector,
WMS: WMS,
XYZ: XYZ
};
const control = {
DebugInfo: DebugInfo,
EarthCoordinates: EarthCoordinates,
GeoImageDragControl: GeoImageDragControl,
KeyboardNavigation: KeyboardNavigation,
LayerSwitcher: LayerSwitcher,
MouseNavigation: MouseNavigation,
ToggleWireframe: ToggleWireframe,
TouchNavigation: TouchNavigation,
SimpleNavigation: SimpleNavigation,
ShowFps: ShowFps,
Sun: Sun,
ZoomControl: ZoomControl
};
const entity = {
Billboard: Billboard,
Geometry: Geometry,
Label: Label,
PointCloud: PointCloud,
Polyline: Polyline
};
const terrain = {
EmptyTerrain: EmptyTerrain,
GlobusTerrain: GlobusTerrain,
MapboxTerrain: MapboxTerrain
};
const webgl = {
Framebuffer: Framebuffer,
Handler: Handler,
Multisample: Multisample,
types: types,
Program: Program
};
const scene = {
'Planet': Planet,
'Axes': Axes
Planet: Planet,
Axes: Axes
};
export {

View File

@ -20,8 +20,8 @@ const KeyboardHandler = function () {
} else {
KeyboardHandler.prototype._instance = this;
document.onkeydown = function (event) { _event = event; _active && _that.handleKeyDown.call(_that) };
document.onkeyup = function (event) { _event = event; _active && _that.handleKeyUp.call(_that) };
document.onkeydown = function (event) { _event = event; _active && _that.handleKeyDown(); };
document.onkeyup = function (event) { _event = event; _active && _that.handleKeyUp(); };
}
var _sortByPriority = function (a, b) {
@ -30,7 +30,7 @@ const KeyboardHandler = function () {
this.removeEvent = function (events, callback) {
//
//TODO:...
// TODO:...
//
};
@ -43,17 +43,17 @@ const KeyboardHandler = function () {
priority = 1600;
}
switch (event) {
case "keyfree": {
case "keyfree":
if (!_unpressedKeysCallbacks[keyCode]) {
_unpressedKeysCallbacks[keyCode] = [];
}
_unpressedKeysCallbacks[keyCode].push({ callback: callback, sender: sender, priority: priority });
_unpressedKeysCallbacks[keyCode].sort(_sortByPriority);
} break;
break;
case "keypress": {
case "keypress":
if (keyCode == null) {
_anykeyCallback = { "callback": callback, "sender": sender || _that };
_anykeyCallback = { callback: callback, sender: sender || _that };
} else {
if (!_pressedKeysCallbacks[keyCode]) {
_pressedKeysCallbacks[keyCode] = [];
@ -61,15 +61,15 @@ const KeyboardHandler = function () {
_pressedKeysCallbacks[keyCode].push({ callback: callback, sender: sender, priority: priority });
_pressedKeysCallbacks[keyCode].sort(_sortByPriority);
}
} break;
break;
case "charkeypress": {
case "charkeypress":
if (!_charkeysCallbacks[keyCode]) {
_charkeysCallbacks[keyCode] = [];
}
_charkeysCallbacks[keyCode].push({ callback: callback, sender: sender, priority: priority });
_charkeysCallbacks[keyCode].sort(_sortByPriority);
} break;
break;
}
};

View File

@ -10,7 +10,7 @@ const MouseHandler = function (htmlObject) {
MouseHandler.prototype.setEvent = function (event, sender, callback) {
switch (event) {
case "mousewheel": {
case "mousewheel":
this._htmlObject.addEventListener('mousewheel', function (evt) {
var delta = evt.deltaY || evt.detail || evt.wheelDelta;
if (evt.wheelDelta == undefined) {
@ -28,8 +28,9 @@ MouseHandler.prototype.setEvent = function (event, sender, callback) {
callback.call(sender, evt);
evt.preventDefault();
}, false);
} break;
case "mousedown": {
break;
case "mousedown":
this._htmlObject.addEventListener('mousedown', function (event) {
callback.call(sender, event);
});
@ -37,21 +38,23 @@ MouseHandler.prototype.setEvent = function (event, sender, callback) {
event.preventDefault();
return false;
});
} break;
case "mouseup": {
break;
case "mouseup":
this._htmlObject.addEventListener('mouseup', function (event) {
callback.call(sender, event);
});
} break;
case "mousemove": {
break;
case "mousemove":
this._htmlObject.addEventListener('mousemove', function (event) {
var rect = this.getBoundingClientRect();
callback.call(sender, {
'clientX': event.clientX - rect.left,
'clientY': event.clientY - rect.top
clientX: event.clientX - rect.left,
clientY: event.clientY - rect.top
});
});
} break;
break;
}
};

View File

@ -10,7 +10,7 @@ const TouchHandler = function (htmlObject) {
TouchHandler.prototype.setEvent = function (event, sender, callback) {
switch (event) {
case "touchcancel": {
case "touchcancel":
this._htmlObject.addEventListener('touchcancel', function (event) {
event.preventDefault();
var rect = this.getBoundingClientRect();
@ -19,9 +19,9 @@ TouchHandler.prototype.setEvent = function (event, sender, callback) {
callback.call(sender, event);
event.preventDefault();
});
}
break;
case "touchstart": {
case "touchstart":
this._htmlObject.addEventListener('touchstart', function (event) {
event.preventDefault();
var rect = this.getBoundingClientRect();
@ -30,8 +30,9 @@ TouchHandler.prototype.setEvent = function (event, sender, callback) {
callback.call(sender, event);
event.preventDefault();
});
} break;
case "touchend": {
break;
case "touchend":
this._htmlObject.addEventListener('touchend', function (event) {
event.preventDefault();
var rect = this.getBoundingClientRect();
@ -40,8 +41,9 @@ TouchHandler.prototype.setEvent = function (event, sender, callback) {
callback.call(sender, event);
event.preventDefault();
});
} break;
case "touchmove": {
break;
case "touchmove":
this._htmlObject.addEventListener('touchmove', function (event) {
event.preventDefault();
var rect = this.getBoundingClientRect();
@ -50,7 +52,7 @@ TouchHandler.prototype.setEvent = function (event, sender, callback) {
callback.call(sender, event);
event.preventDefault();
});
} break;
break;
}
};

View File

@ -95,10 +95,12 @@ class BaseGeoImage extends Layer {
this._cornersWgs84 = [corners[0].clone(), corners[1].clone(), corners[2].clone(), corners[3].clone()] || [0, 0, 0, 0];
for (var i = 0; i < this._cornersWgs84.length; i++) {
if (this._cornersWgs84[i].lat >= 89.9)
if (this._cornersWgs84[i].lat >= 89.9) {
this._cornersWgs84[i].lat = 89.9;
if (this._cornersWgs84[i].lat <= -89.9)
}
if (this._cornersWgs84[i].lat <= -89.9) {
this._cornersWgs84[i].lat = -89.9;
}
}
this._extent.setByCoordinates(this._cornersWgs84);
@ -135,7 +137,7 @@ class BaseGeoImage extends Layer {
this._extentMercParams = [this._extentMerc.southWest.lon, this._extentMerc.southWest.lat, 2.0 / this._extentMerc.getWidth(), 2.0 / this._extentMerc.getHeight()];
}
//creates material frame textures
// creates material frame textures
if (this._planet) {
var p = this._planet,
h = p.renderer.handler,
@ -201,11 +203,12 @@ class BaseGeoImage extends Layer {
super.setVisibility(visibility);
//remove from creator
if (visibility)
// remove from creator
if (visibility) {
this._sourceReady && this._planet._geoImageCreator.add(this);
else
} else {
this._sourceReady && this._planet._geoImageCreator.remove(this);
}
}
}
@ -215,7 +218,6 @@ class BaseGeoImage extends Layer {
* @param {og.planetSegment.Material} material - GeoImage material.
*/
clearMaterial(material) {
//just clear material pointer not geoimage
material.image = null;
material.texture = null;
material.isLoading = false;

View File

@ -5,7 +5,6 @@
'use strict';
import * as quadTree from '../quadTree/quadTree.js';
import { ImageCanvas } from '../ImageCanvas.js';
import { Layer } from './Layer.js';
/**
@ -13,7 +12,6 @@ import { Layer } from './Layer.js';
* @const
* @type {number}
*/
const MAX_REQUESTS = 7;
const EVENT_NAMES = [
/**
@ -67,7 +65,7 @@ class CanvasTiles extends Layer {
* @protected
* @type {Array.<og.planetSegment.Material>}
*/
this._pendingsQueue = []; //new og.QueueArray();
this._pendingsQueue = []; // new og.QueueArray();
/**
* Draw tile callback.
@ -93,7 +91,7 @@ class CanvasTiles extends Layer {
}
}
this._pendingsQueue = [];
//this._pendingsQueue.clear();
// this._pendingsQueue.clear();
};
/**
@ -203,8 +201,9 @@ class CanvasTiles extends Layer {
if (this._pendingsQueue.length) {
if (CanvasTiles.__requestsCounter < CanvasTiles.MAX_REQUESTS) {
var pmat = this._whilePendings();
if (pmat)
this._exec.call(this, pmat);
if (pmat) {
this._exec(pmat);
}
}
} else if (this._counter === 0) {
this.events.dispatch(this.events.loadend);
@ -224,7 +223,6 @@ class CanvasTiles extends Layer {
return null;
}
applyMaterial(material) {
if (material.isReady) {
return [0, 0, 1, 1];

View File

@ -94,13 +94,13 @@ class GeoImage extends BaseGeoImage {
if (this._image.complete) {
this._onLoad(this._image);
} else if (this._image.src) {
var that = this;
let that = this;
this._image.addEventListener('load', function (e) {
that._onLoad(this);
});
}
} else {
var that = this;
let that = this;
this._image = new Image();
this._image.addEventListener('load', function (e) {
that._onLoad(this);

View File

@ -7,7 +7,6 @@
import * as math from '../math.js';
import { BaseGeoImage } from './BaseGeoImage.js';
class GeoTexture2d extends BaseGeoImage {
constructor(name, options) {
super(name, options);

View File

@ -74,7 +74,7 @@ class GeoVideo extends BaseGeoImage {
super.setVisibility(visibility);
//remove from creator
// remove from creator
if (visibility) {
this._sourceReady && this._planet._geoImageCreator.add(this);
this._video && this._video.play();
@ -142,14 +142,14 @@ class GeoVideo extends BaseGeoImage {
if (this._video.readyState === this._video.HAVE_ENOUGH_DATA) {
this._onCanPlay(this._video);
} else if (this._video.src) {
var that = this;
let that = this;
this._video.addEventListener('canplay', function (e) {
that._onCanPlay(this);
});
}
} else {
this._video = document.createElement('video');
var that = this;
let that = this;
this._video.addEventListener('canplay', function () {
that._onCanPlay(this);
});
@ -187,7 +187,6 @@ class GeoVideo extends BaseGeoImage {
this._refreshFrame && this._createFrame();
if (this._sourceCreated) {
var gl = this._planet.renderer.handler.gl;
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._video);
} else {
@ -244,7 +243,6 @@ class GeoVideo extends BaseGeoImage {
this._sourceTexture = this._planet.renderer.handler.createTexture_n(this._video);
this._sourceCreated = true;
} else {
var gl = this._planet.renderer.handler.gl;
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._video);
}

View File

@ -12,7 +12,6 @@ import { LonLat } from '../LonLat.js';
import { Material } from './Material.js';
import { Vec3 } from '../math/Vec3.js';
export const FADING_FACTOR = 0.29;
/**
@ -191,7 +190,7 @@ class Layer {
*/
this._extentMerc = null;
//Setting the extent up
// Setting the extent up
this.setExtent(utils.createExtent(options.extent, new Extent(new LonLat(-180, -90), new LonLat(180, 90))));
/**
@ -273,7 +272,7 @@ class Layer {
}
get pickingEnabled() {
return this._pickingEnabled ? true : false;
return !!this._pickingEnabled;
}
/**
@ -350,7 +349,6 @@ class Layer {
remove() {
var p = this._planet;
if (p) {
var lid = this._id;
for (var i = 0; i < p.layers.length; i++) {
if (this.isEqual(p.layers[i])) {
p.renderer.clearPickingColor(this);
@ -530,22 +528,22 @@ class Layer {
* @protected
*/
_correctFullExtent() {
//var e = this._extent,
// var e = this._extent,
// em = this._extentMerc;
//var ENLARGE_MERCATOR_LON = og.mercator.POLE + 50000;
//var ENLARGE_MERCATOR_LAT = og.mercator.POLE + 50000;
//if (e.northEast.lat === 90.0) {
// var ENLARGE_MERCATOR_LON = og.mercator.POLE + 50000;
// var ENLARGE_MERCATOR_LAT = og.mercator.POLE + 50000;
// if (e.northEast.lat === 90.0) {
// em.northEast.lat = ENLARGE_MERCATOR_LAT;
//}
//if (e.northEast.lon === 180.0) {
// }
// if (e.northEast.lon === 180.0) {
// em.northEast.lon = ENLARGE_MERCATOR_LON;
//}
//if (e.southWest.lat === -90.0) {
// }
// if (e.southWest.lat === -90.0) {
// em.southWest.lat = -ENLARGE_MERCATOR_LAT;
//}
//if (e.southWest.lon === -180.0) {
// }
// if (e.southWest.lon === -180.0) {
// em.southWest.lon = -ENLARGE_MERCATOR_LON;
//}
// }
}
_refreshFadingOpacity() {
@ -555,8 +553,8 @@ class Layer {
this._fadingOpacity += this._fadingFactor;
if (this._fadingFactor > 0.0 && this._fadingOpacity > this._opacity ||
this._fadingFactor < 0.0 && this._fadingOpacity < this._opacity) {
if ((this._fadingFactor > 0.0 && this._fadingOpacity > this._opacity) ||
(this._fadingFactor < 0.0 && this._fadingOpacity < this._opacity)) {
this._fadingOpacity = this._opacity;
}
return false;

View File

@ -17,7 +17,7 @@ const Material = function (segment, layer) {
this.texOffset = [0.0, 0.0, 1.0, 1.0];
this.loadingAttempts = 0;
//vector data
// vector data
this._updateTexture = null;
this._updatePickingMask = null;
this.pickingReady = false;

View File

@ -16,7 +16,6 @@ import {
} from '../quadTree/EntityCollectionNode.js';
import { GeometryHandler } from '../entity/GeometryHandler.js';
import { Layer } from './Layer.js';
import { LonLat } from '../LonLat.js';
import { QueueArray } from '../QueueArray.js';
import { Vec3 } from '../math/Vec3.js';
@ -134,12 +133,12 @@ class Vector extends Layer {
this._entities = _entitiesConstructor(options.entities || []);
this._stripEntityCollection = new EntityCollection({
'pickingEnabled': this.pickingEnabled
pickingEnabled: this.pickingEnabled
});
this._bindEventsDefault(this._stripEntityCollection);
this._polylineEntityCollection = new EntityCollection({
'pickingEnabled': this.pickingEnabled
pickingEnabled: this.pickingEnabled
});
this._bindEventsDefault(this._polylineEntityCollection);
@ -158,7 +157,7 @@ class Vector extends Layer {
this._pendingsQueue = [];
/** Creates collections tree*/
// Creates collections tree
this.setEntities(this._entities);
/**
@ -273,7 +272,7 @@ class Vector extends Layer {
let temp = this._hasImageryTiles;
//
//...pointCloud, shape, model etc.
// ...pointCloud, shape, model etc.
//
if (entity.strip) {
@ -301,11 +300,11 @@ class Vector extends Layer {
entity._lonlat = this._planet.ellipsoid.cartesianToLonLat(entity._cartesian);
}
//north tree
// north tree
if (entity._lonlat.lat > mercator.MAX_LAT) {
this._entityCollectionsTreeNorth.insertEntity(entity, rightNow);
} else if (entity._lonlat.lat < mercator.MIN_LAT) {
//south tree
// south tree
this._entityCollectionsTreeSouth.insertEntity(entity, rightNow);
} else {
this._entityCollectionsTree.insertEntity(entity, rightNow);
@ -362,7 +361,7 @@ class Vector extends Layer {
entity._nodePtr.deferredEntities.length === 0) {
entity._nodePtr.entityCollection = null;
//
//...
// ...
//
}
} else if (entity._nodePtr &&
@ -469,7 +468,7 @@ class Vector extends Layer {
* @public
*/
clear() {
//TODO
// TODO
}
/**
@ -647,7 +646,7 @@ class Vector extends Layer {
outArr.push(ec);
//
//...TODO: extent
// ...TODO: extent
//
}
@ -676,8 +675,8 @@ class Vector extends Layer {
while (e_i--) {
var p = e[e_i].polyline;
if (visibleExtent.overlaps(p._extent)) {
//TODO:this works only for mercator area.
//So it needs to be working on poles.
// TODO:this works only for mercator area.
// needs to be working on poles.
let coords = p._pathLonLatMerc,
c_j = coords.length;
while (c_j--) {
@ -690,7 +689,7 @@ class Vector extends Layer {
if (seg._extent.isInside(ll)) {
let cart = p._path3v[c_j][c_j_h];
seg.getTerrainPoint(cart, ll, res);
p.setPoint3v(res.addA(res.normal().scale(rtg && p.altitude || 0.0)), c_j_h, c_j, true);
p.setPoint3v(res.addA(res.normal().scale((rtg && p.altitude) || 0.0)), c_j_h, c_j, true);
break;
}
}
@ -704,19 +703,19 @@ class Vector extends Layer {
collectVisibleCollections(outArr) {
var p = this._planet;
if (this._fading && this._fadingOpacity > 0.0 ||
this.minZoom <= this._planet.maxCurrZoom && this.maxZoom >= p.maxCurrZoom) {
if ((this._fading && this._fadingOpacity > 0.0) ||
(this.minZoom <= this._planet.maxCurrZoom && this.maxZoom >= p.maxCurrZoom)) {
this._renderingNodes = {};
this._renderingNodesNorth = {};
this._renderingNodesSouth = {};
//Common collections first
// Common collections first
this._collectStripCollectionPASS(outArr);
this._collectPolylineCollectionPASS(outArr);
//Merc nodes
// Merc nodes
this._secondPASS = [];
this._entityCollectionsTree.collectRenderCollectionsPASS1(p._visibleNodes, outArr);
var i = this._secondPASS.length;
@ -724,7 +723,7 @@ class Vector extends Layer {
this._secondPASS[i].collectRenderCollectionsPASS2(p._visibleNodes, outArr, this._secondPASS[i].nodeId);
}
//North nodes
// North nodes
this._secondPASS = [];
this._entityCollectionsTreeNorth.collectRenderCollectionsPASS1(p._visibleNodesNorth, outArr);
i = this._secondPASS.length;
@ -732,7 +731,7 @@ class Vector extends Layer {
this._secondPASS[i].collectRenderCollectionsPASS2(p._visibleNodesNorth, outArr, this._secondPASS[i].nodeId);
}
//South nodes
// South nodes
this._secondPASS = [];
this._entityCollectionsTreeSouth.collectRenderCollectionsPASS1(p._visibleNodesSouth, outArr);
i = this._secondPASS.length;
@ -818,8 +817,8 @@ class Vector extends Layer {
var mId = this._id;
var psegm = material;
var i = 0;
while (pn.parentNode && i < 2) {
while (pn.parentNode) {
if (psegm && psegm.isReady) {
notEmpty = true;
break;

View File

@ -166,10 +166,10 @@ class XYZ extends Layer {
material.loadingAttempts++;
this._planet._tileLoader.load({
'src': this._getHTTPRequestString(material.segment),
'type': 'imageBitmap',
'filter': () => seg.initialized && seg.node.getState() === RENDERING || forceLoading,
'options': {}
src: this._getHTTPRequestString(material.segment),
type: 'imageBitmap',
filter: () => (seg.initialized && seg.node.getState() === RENDERING) || forceLoading,
options: {}
}, (response) => {
if (response.status === "ready") {
if (material.isLoading) {
@ -202,10 +202,10 @@ class XYZ extends Layer {
*/
_createUrl(segment) {
return stringTemplate(this.url, {
"s": this._getSubdomain(),
"x": segment.tileX.toString(),
"y": segment.tileY.toString(),
"z": segment.tileZoom.toString()
s: this._getSubdomain(),
x: segment.tileX.toString(),
y: segment.tileY.toString(),
z: segment.tileZoom.toString()
});
}
@ -257,7 +257,7 @@ class XYZ extends Layer {
psegm = pn.segment.materials[mId];
}
let maxNativeZoom = material.layer.maxNativeZoom
let maxNativeZoom = material.layer.maxNativeZoom;
if (pn.segment.tileZoom === maxNativeZoom) {
material.textureNotExists();
@ -346,7 +346,6 @@ class XYZ extends Layer {
};
};
const EVENT_NAMES = [
/**
* Triggered when current tile image has loaded before rendereing.

View File

@ -108,7 +108,7 @@ class LightSource {
* @returns {og.LightSource}
*/
clone() {
//TODO
// TODO
}
/**

View File

@ -176,10 +176,11 @@ export function random(min, max) {
* @returns {number} -
**/
export function degToDec(d, m, s, p) {
if (p)
if (p) {
return d + m / 60.0 + s / 3600.0;
else
} else {
return -d - m / 60.0 - s / 3600.0;
}
};
/**
@ -319,8 +320,7 @@ export function rev(x) {
* @returns {number} -
*/
export function norm_lon(lon) {
return lon > 180 ? ((lon + 180) % 360) - 180 :
lon < -180 ? ((lon - 180) % 360) + 180 : lon;
return lon > 180 ? ((lon + 180) % 360) - 180 : lon < -180 ? ((lon - 180) % 360) + 180 : lon;
};
/**
@ -368,8 +368,9 @@ export function solve_iteration(f, x0, err, maxIter) {
for (var i = 0; i < maxIter; i++) {
x = x2;
x2 = f(x);
if (Math.abs(x2 - x) < err)
if (Math.abs(x2 - x) < err) {
return x2;
}
}
return x2;
};

View File

@ -53,7 +53,6 @@ Line3.prototype.getSphereIntersection = function (sphere) {
// prefer a solution that's on the line segment itself
if (Math.Abs(t1 - 0.5) < Math.abs(t2 - 0.5)) {
//return new Point3D[] { solution1, solution2 };
return [solution1, solution2];
}
@ -65,13 +64,15 @@ Line3.prototype.intersects = function (line, pa, pb) {
let p13 = this.p0.sub(line.p0),
p43 = line.p1.sub(line.p0);
if (Math.abs(p43.x) < math.EPSILON10 && Math.abs(p43.y) < math.EPSILON10 && Math.abs(p43.z) < math.EPSILON10)
if (Math.abs(p43.x) < math.EPSILON10 && Math.abs(p43.y) < math.EPSILON10 && Math.abs(p43.z) < math.EPSILON10) {
return false;
}
let p21 = this.p1.sub(this.p0);
if (Math.abs(p21.x) < math.EPSILON10 && Math.abs(p21.y) < math.EPSILON10 && Math.abs(p21.z) < math.EPSILON10)
if (Math.abs(p21.x) < math.EPSILON10 && Math.abs(p21.y) < math.EPSILON10 && Math.abs(p21.z) < math.EPSILON10) {
return false;
}
let d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z,
d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z,
@ -81,8 +82,9 @@ Line3.prototype.intersects = function (line, pa, pb) {
let denom = d2121 * d4343 - d4321 * d4321;
if (Math.abs(denom) < math.EPSILON10)
if (Math.abs(denom) < math.EPSILON10) {
return false;
}
let numer = d1343 * d4321 - d1321 * d4343;

View File

@ -4,7 +4,6 @@
'use strict';
import * as math from '../math.js';
import { Mat4 } from './Mat4.js';
import { Vec3 } from './Vec3.js';

View File

@ -21,32 +21,32 @@ const Mat4 = function () {
* Projection frustum left value.
* @public
*/
this.left;
this.left = 0.0;
/**
* Projection frustum right value.
* @public
*/
this.right;
this.right = 0.0;
/**
* Projection frustum bottom value.
* @public
*/
this.bottom;
this.bottom = 0.0;
/**
* Projection frustum top value.
* @public
*/
this.top;
this.top = 0.0;
/**
* Projection frustum near value.
* @public
*/
this.near;
this.near = 0.0;
/**
* Projection frustum far value.
* @public
*/
this.far;
this.far = 0.0;
};
/**
@ -184,8 +184,11 @@ Mat4.prototype.toInverseMatrix3 = function () {
o = -k * g + h * i,
m = j * g - f * i,
n = c * l + d * o + e * m;
if (!n)
if (!n) {
return null;
}
n = 1 / n;
var res = new Mat3();
@ -376,7 +379,6 @@ Mat4.prototype.scale = function (v) {
mx[0] = mx[0] * v.x; mx[1] = mx[1] * v.x; mx[2] = mx[2] * v.x; mx[3] = mx[3] * v.x;
mx[4] = mx[4] * v.y; mx[5] = mx[5] * v.y; mx[6] = mx[6] * v.y; mx[7] = mx[7] * v.y;
mx[8] = mx[8] * v.z; mx[9] = mx[9] * v.z; mx[10] = mx[10] * v.z; mx[11] = mx[11] * v.z;
mx[12] = mx[12]; mx[13] = mx[13]; mx[14] = mx[14]; mx[15] = mx[15];
return this;
};
@ -393,13 +395,6 @@ Mat4.prototype.scale = function (v) {
*/
Mat4.prototype.setFrustum = function (left, right, bottom, top, near, far) {
//this.left = left;
//this.right = right;
//this.bottom = bottom;
//this.top = top;
//this.near = near;
//this.far = far;
var h = right - left, i = top - bottom, j = far - near;
this._m[0] = near * 2 / h;
this._m[1] = 0;
@ -432,7 +427,7 @@ Mat4.prototype.setFrustum = function (left, right, bottom, top, near, far) {
Mat4.prototype.setPerspective = function (angle, aspect, near, far) {
angle = near * Math.tan(angle * Math.PI / 360);
aspect = angle * aspect;
return this.setFrustum(-aspect, aspect, -angle, angle, near, far)
return this.setFrustum(-aspect, aspect, -angle, angle, near, far);
};
/**
@ -448,13 +443,6 @@ Mat4.prototype.setPerspective = function (angle, aspect, near, far) {
*/
Mat4.prototype.setOrtho = function (left, right, bottom, top, near, far) {
//this.left = left;
//this.right = right;
//this.bottom = bottom;
//this.top = top;
//this.near = near;
//this.far = far;
var lr = 1.0 / (left - right),
bt = 1.0 / (bottom - top),
nf = 1.0 / (near - far),
@ -515,5 +503,4 @@ Mat4.prototype.eulerToMatrix = function (ax, ay, az) {
return this;
};
export { Mat4 };
export { Mat4 };

View File

@ -53,24 +53,28 @@ class Plane {
if ((ax + ay + az) < math.EPSILON5) { // Pn1 and Pn2 are near parallel
// test if disjoint or coincide
var v = Pn2.p.sub(Pn1.p);
if (Pn1.n.dot(v) == 0) // Pn2.V0 lies in Pn1
if (Pn1.n.dot(v) == 0) { // Pn2.V0 lies in Pn1
return 1; // Pn1 and Pn2 coincide
else
} else {
return 0; // Pn1 and Pn2 are disjoint
}
}
// Pn1 and Pn2 intersect in a line
// first determine max abs coordinate of cross product
var maxc; // max coordinate
if (ax > ay) {
if (ax > az)
if (ax > az) {
maxc = 1;
else maxc = 3;
}
else {
if (ay > az)
} else {
maxc = 3;
}
} else {
if (ay > az) {
maxc = 2;
else maxc = 3;
} else {
maxc = 3;
}
}
// next, to get a point on the intersect line

View File

@ -358,7 +358,8 @@ Quat.prototype.scaleTo = function (scale) {
* @returns {og.Quat} -
*/
Quat.prototype.scale = function (scale) {
return this.x * scale, this.y * scale, this.z * scale, this.w * scale;
this.x *= scale; this.y *= scale; this.z *= scale; this.w *= scale;
return this;
};
/**
@ -392,7 +393,6 @@ Quat.prototype.setFromSphericalCoords = function (lat, lon, angle) {
return this;
};
/**
* Sets rotation with the given heading and up vectors.
* @static
@ -414,22 +414,19 @@ Quat.prototype.setLookRotation = function (forward, up) {
this.y = (s.z - f.x) * fd;
this.z = (u.x - s.y) * fd;
this.w = 0.25 / fd;
}
else if (s.x > u.y && s.x > f.z) {
} else if (s.x > u.y && s.x > f.z) {
let fd = 1.0 / (2.0 * Math.sqrt(1.0 + s.x - u.y - f.z));
this.x = 0.25 / fd;
this.y = (u.x + s.y) * fd;
this.z = (s.z + f.x) * fd;
this.w = (f.y - u.z) * fd;
}
else if (u.y > f.z) {
} else if (u.y > f.z) {
let fd = 1.0 / (2.0 * Math.sqrt(1.0 + u.y - s.x - f.z));
this.x = (u.x + s.y) * fd;
this.y = 0.25 / fd;
this.z = (f.y + u.z) * fd;
this.w = (s.z - f.x) * fd;
}
else {
} else {
let fd = 1.0 / (2.0 * Math.sqrt(1.0 + f.z - s.x - u.y));
this.x = (s.z + f.x) * fd;
this.y = (f.y + u.z) * fd;
@ -448,20 +445,23 @@ Quat.prototype.setLookRotation = function (forward, up) {
Quat.prototype.toSphericalCoords = function () {
var cos_a = this.w;
var sin_a = Math.sqrt(1.0 - cos_a * cos_a);
var angle = Math.acos(cos_a) * 2;
if (Math.abs(sin_a) < 0.0005)
// var angle = Math.acos(cos_a) * 2;
if (Math.abs(sin_a) < 0.0005) {
sin_a = 1;
}
var tx = this.x / sin_a;
var ty = this.y / sin_a;
var tz = this.z / sin_a;
var lon, lat = -Math.asin(ty);
if (tx * tx + tz * tz < 0.0005)
if (tx * tx + tz * tz < 0.0005) {
lon = 0;
else
} else {
lon = Math.atan2(tx, tz);
if (lon < 0)
}
if (lon < 0) {
lon += 360.0;
}
return { lat: lat, lon: lon, alpha: Math.acos(cos_a) };
};
@ -492,10 +492,11 @@ Quat.prototype.getAxisAngle = function () {
if (vl > 0.0000001) {
var ivl = 1.0 / vl;
axis = new Vec3(x * ivl, y * ivl, z * ivl);
if (this.w < 0)
angle = 2.0 * Math.atan2(-vl, -w); //-PI,0
else
angle = 2.0 * Math.atan2(vl, w); //0,PI
if (this.w < 0) {
angle = 2.0 * Math.atan2(-vl, -w); // -PI,0
} else {
angle = 2.0 * Math.atan2(vl, w); // 0,PI
}
} else {
axis = new Vec3(0, 0, 0);
angle = 0;
@ -675,8 +676,8 @@ Quat.prototype.getMat3 = function () {
*/
Quat.prototype.mulVec3 = function (v) {
//t = 2 * cross(q.xyz, v)
//v' = v + q.w * t + cross(q.xyz, t)
// t = 2 * cross(q.xyz, v)
// v' = v + q.w * t + cross(q.xyz, t)
var d = v.x,
e = v.y,

View File

@ -7,7 +7,6 @@
import * as math from '../math.js';
import { Vec3 } from './Vec3.js';
/**
* Represents a ray that extends infinitely from the provided origin in the provided direction.
* @class
@ -85,7 +84,6 @@ Ray.prototype.getPoint = function (distance) {
* 2 - og.Ray.INPLANE and 3 - og.Ray.AWAY(ray goes away from triangle).
*/
Ray.prototype.hitTriangle = function (v0, v1, v2, res, normal) {
var state;
var u = v1.sub(v0);
var v = v2.sub(v0);
var n = u.cross(v);
@ -112,8 +110,9 @@ Ray.prototype.hitTriangle = function (v0, v1, v2, res, normal) {
res.copy(this.origin.add(this.direction.scaleTo(r)));
// ray goes away from triangle
if (r < 0.0)
if (r < 0.0) {
return Ray.AWAY;
}
// is res point inside the triangle?
var uu = u.dot(u);
@ -125,12 +124,14 @@ Ray.prototype.hitTriangle = function (v0, v1, v2, res, normal) {
var D = uv * uv - uu * vv;
var s = (uv * wv - vv * wu) / D;
if (s < 0.0 || s > 1.0)
if (s < 0.0 || s > 1.0) {
return Ray.OUTSIDE;
}
var t = (uv * wu - uu * wv) / D;
if (t < 0.0 || (s + t) > 1.0)
if (t < 0.0 || (s + t) > 1.0) {
return Ray.OUTSIDE;
}
return Ray.INSIDE;
};
@ -195,27 +196,27 @@ Ray.prototype.hitSphere = function (sphere) {
} else if (l === r) {
return o.clone();
}
var pc = c.projToRay(o, vpc);
let pc = c.projToRay(o, vpc);
var lc = Vec3.sub(pc, c).length();
var dist = Math.sqrt(r * r - lc * lc);
var di1 = dist - Vec3.sub(pc, o).length();
var intersection = Vec3.add(o, d.scaleTo(di1));
let dist = Math.sqrt(r * r - lc * lc);
let di1 = dist - Vec3.sub(pc, o).length();
let intersection = Vec3.add(o, d.scaleTo(di1));
return intersection;
} else {
var pc = c.projToRay(o, d);
let pc = c.projToRay(o, d);
var cpcl = Vec3.sub(c, pc).length();
if (cpcl > sphere.radius) {
return null;
} else {
var dist = Math.sqrt(r * r - cpcl * cpcl);
var di1;
let dist = Math.sqrt(r * r - cpcl * cpcl);
let di1;
pc.subA(o);
if (vpc.length() > r) {
di1 = pc.length() - dist;
} else {
di1 = pc.length() + dist;
}
var intersection = Vec3.add(o, d.scaleTo(di1));
let intersection = Vec3.add(o, d.scaleTo(di1));
return intersection;
}
}
@ -223,7 +224,7 @@ Ray.prototype.hitSphere = function (sphere) {
Ray.prototype.hitBox = function (box) {
//
//TODO
// TODO
//
};

View File

@ -70,7 +70,7 @@ Vec2.add = function (a, b) {
* @returns {og.math.Vec2} - Vectors subtraction.
*/
Vec2.sub = function (a, b) {
var res = new oVec2(a.x, a.y);
var res = new Vec2(a.x, a.y);
res.subA(b);
return res;
};
@ -84,7 +84,7 @@ Vec2.sub = function (a, b) {
*/
Vec2.scale = function (a, scale) {
var res = new Vec2(a.x, a.y);
res.scale(scale)
res.scale(scale);
return res;
};
@ -294,7 +294,6 @@ Vec2.prototype.mul = function (vec) {
return new Vec2(this.x * vec.x, this.y * vec.y);
};
/**
* Divide current vector's components to another. Results stores in the current vector object.
* @public

View File

@ -76,36 +76,36 @@ export function vec3(x, y, z) {
* @param {Vec3} low - Out vector low values.
* @returns {Array.<number,number>} Encoded array.
*/
Vec3.doubleToTwoFloats = function(v, high, low) {
Vec3.doubleToTwoFloats = function (v, high, low) {
let x = v.x, y = v.y, z = v.z;
if (x >= 0.0) {
var doubleHigh = Math.floor(x / 65536.0) * 65536.0;
let doubleHigh = Math.floor(x / 65536.0) * 65536.0;
high.x = Math.fround(doubleHigh);
low.x = Math.fround(x - doubleHigh);
} else {
var doubleHigh = Math.floor(-x / 65536.0) * 65536.0;
let doubleHigh = Math.floor(-x / 65536.0) * 65536.0;
high.x = Math.fround(-doubleHigh);
low.x = Math.fround(x + doubleHigh);
}
if (y >= 0.0) {
var doubleHigh = Math.floor(y / 65536.0) * 65536.0;
let doubleHigh = Math.floor(y / 65536.0) * 65536.0;
high.y = Math.fround(doubleHigh);
low.y = Math.fround(y - doubleHigh);
} else {
var doubleHigh = Math.floor(-y / 65536.0) * 65536.0;
let doubleHigh = Math.floor(-y / 65536.0) * 65536.0;
high.y = Math.fround(-doubleHigh);
low.y = Math.fround(y + doubleHigh);
}
if (z >= 0.0) {
var doubleHigh = Math.floor(z / 65536.0) * 65536.0;
let doubleHigh = Math.floor(z / 65536.0) * 65536.0;
high.z = Math.fround(doubleHigh);
low.z = Math.fround(z - doubleHigh);
} else {
var doubleHigh = Math.floor(-z / 65536.0) * 65536.0;
let doubleHigh = Math.floor(-z / 65536.0) * 65536.0;
high.z = Math.fround(-doubleHigh);
low.z = Math.fround(z + doubleHigh);
}
@ -124,31 +124,31 @@ Vec3.doubleToTwoFloat32Array = function (v, high, low) {
let x = v.x, y = v.y, z = v.z;
if (x >= 0.0) {
var doubleHigh = Math.floor(x / 65536.0) * 65536.0;
let doubleHigh = Math.floor(x / 65536.0) * 65536.0;
high[0] = Math.fround(doubleHigh);
low[0] = Math.fround(x - doubleHigh);
} else {
var doubleHigh = Math.floor(-x / 65536.0) * 65536.0;
let doubleHigh = Math.floor(-x / 65536.0) * 65536.0;
high[0] = Math.fround(-doubleHigh);
low[0] = Math.fround(x + doubleHigh);
}
if (y >= 0.0) {
var doubleHigh = Math.floor(y / 65536.0) * 65536.0;
let doubleHigh = Math.floor(y / 65536.0) * 65536.0;
high[1] = Math.fround(doubleHigh);
low[1] = Math.fround(y - doubleHigh);
} else {
var doubleHigh = Math.floor(-y / 65536.0) * 65536.0;
let doubleHigh = Math.floor(-y / 65536.0) * 65536.0;
high[1] = Math.fround(-doubleHigh);
low[1] = Math.fround(y + doubleHigh);
}
if (z >= 0.0) {
var doubleHigh = Math.floor(z / 65536.0) * 65536.0;
let doubleHigh = Math.floor(z / 65536.0) * 65536.0;
high[2] = Math.fround(doubleHigh);
low[2] = Math.fround(z - doubleHigh);
} else {
var doubleHigh = Math.floor(-z / 65536.0) * 65536.0;
let doubleHigh = Math.floor(-z / 65536.0) * 65536.0;
high[2] = Math.fround(-doubleHigh);
low[2] = Math.fround(z + doubleHigh);
}
@ -222,7 +222,7 @@ Vec3.sub = function (a, b) {
*/
Vec3.scale = function (a, scale) {
var res = new Vec3(a.x, a.y, a.z);
res.scale(scale)
res.scale(scale);
return res;
};
@ -534,7 +534,6 @@ Vec3.prototype.dotArr = function (arr) {
return arr[0] * this.x + arr[1] * this.y + arr[2] * this.z;
};
/**
* Gets vectors cross production.
* @public
@ -821,17 +820,16 @@ Vec3.prototype.getRotationTo = function (dest, fallbackAxis) {
if (!fallbackAxis.isEqual(Vec3.ZERO)) {
// rotate 180 degrees about the fallback axis
return Quat.axisAngleToQuat(Math.PI, fallbackAxis);
}
else {
} else {
// Generate an axis
let axis = Vec3.UNIT_X.cross(v0);
if (axis.isZero()) // pick another if colinear
if (axis.isZero()) { // pick another if colinear
axis = Vec3.UNIT_Y.cross(v0);
}
axis.normalize();
return Quat.axisAngleToQuat(Math.PI, axis);
}
}
else {
} else {
let s = Math.sqrt((1 + d) * 2);
let invs = 1.0 / s;

View File

@ -122,7 +122,6 @@ Vec4.prototype.toVec = function () {
return [this.x, this.y, this.z, this.w];
};
/**
* Converts vector to a number array.
* @public

View File

@ -41,11 +41,11 @@ export function decodeFloatFromRGBA(rgba) {
export function doubleToTwoFloats(value) {
var high, low;
if (value >= 0.0) {
var doubleHigh = Math.floor(value / 65536.0) * 65536.0;
let doubleHigh = Math.floor(value / 65536.0) * 65536.0;
high = Math.fround(doubleHigh);
low = Math.fround(value - doubleHigh);
} else {
var doubleHigh = Math.floor(-value / 65536.0) * 65536.0;
let doubleHigh = Math.floor(-value / 65536.0) * 65536.0;
high = Math.fround(-doubleHigh);
low = Math.fround(value + doubleHigh);
}
@ -60,11 +60,11 @@ export function doubleToTwoFloats(value) {
*/
export function doubleToTwoFloats2(value, highLowArr) {
if (value >= 0.0) {
var doubleHigh = Math.floor(value / 65536.0) * 65536.0;
let doubleHigh = Math.floor(value / 65536.0) * 65536.0;
highLowArr[0] = Math.fround(doubleHigh);
highLowArr[1] = Math.fround(value - doubleHigh);
} else {
var doubleHigh = Math.floor(-value / 65536.0) * 65536.0;
let doubleHigh = Math.floor(-value / 65536.0) * 65536.0;
highLowArr[0] = Math.fround(-doubleHigh);
highLowArr[1] = Math.fround(value + doubleHigh);
}

View File

@ -1,141 +0,0 @@
/**
* @module og/gmx/GmxCheckVersion
*/
'use strict';
import { ajax } from '../../ajax.js';
import { GmxVector } from './GmxVector.js';
const GmxCheckVersion = 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.instanceName === "GmxVector") {
if (l._visibility) {
this._addLayer(l);
}
}
}, this);
planet.events.on("layerremove", function (l) {
if (l.instanceName === "GmxVector") {
this._removeLayer(l);
}
}, this);
planet.events.on("layervisibilitychange", function (l) {
if (l.instanceName === "GmxVector") {
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.getViewExtent();
if (e) {
e = e.inverseMercator();
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.0);
p.dateEnd = parseInt(li._endDate.getTime() / 1000.0);
}
layers.push(p);
}
}
if (layers.length) {
var that = this;
//TODO: fetch
this._r = 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();
};
};
export { GmxCheckVersion };

View File

@ -1,129 +0,0 @@
/**
* @module og/gmx/GmxItem
*/
'use strict';
import * as utils from '../../utils/shared.js';
/**
* 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.
*/
const GmxItem = 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;
};
GmxItem.prototype.addTo = function (layer) {
layer.addItem(this);
};
GmxItem.prototype.setStyle = function (style) {
var s = this._style;
for (var i in style) {
s[i] = style[i];
}
this._layer && this._layer.updateItem(this);
};
GmxItem.prototype.bringToFront = function () {
this._pickingReady = false;
//
//...
//
};
GmxItem.prototype.setZIndex = function (zIndex) {
this._pickingReady = false;
this._style.zIndex = zIndex;
this._layer && this._layer.updateItem(this);
};
GmxItem.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);
};
GmxItem.prototype.setFillColor4v = function (color) {
this.setFillColor(color.x, color.y, color.z, color.w);
};
GmxItem.prototype.setFillColorHTML = function (color) {
var c = utils.htmlColorToRgba(color);
this.setFillColor(c.x, c.y, c.z, c.w);
};
GmxItem.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);
};
GmxItem.prototype.setLineColor4v = function (color) {
this.setLineColor(color.x, color.y, color.z, color.w);
};
GmxItem.prototype.setLineColorHTML = function (color) {
var c = og.utils.htmlColorToRgba(color);
this.setLineColor(c.x, c.y, c.z, c.w);
};
GmxItem.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);
};
GmxItem.prototype.setStrokeColor4v = function (color) {
this.setLineColor(color.x, color.y, color.z, color.w);
};
GmxItem.prototype.setStrokeColorHTML = function (color) {
var c = og.utils.htmlColorToRgba(color);
this.setStrokeColor(c.x, c.y, c.z, c.w);
};
GmxItem.prototype.setLineWidth = function (v) {
this._style.lineWidth = v;
};
GmxItem.prototype.setStrokeWidth = function (v) {
this._style.strokeWidth = v;
};
export { GmxItem };

View File

@ -1,104 +0,0 @@
/**
* @module og/gmx/GmxMaterial
*/
'use strict';
import { inherits } from '../../inherits.js';
import { Material } from '../../layer/Material.js';
const GmxMaterial = function (segment, layer) {
Material.call(this, segment, layer);
this.fromTile = null;
this.maskTexture = null;
this.sceneIsLoading = {};
this.sceneExists = {};
this.sceneIsReady = {};
this.sceneTexture = {};
this._completedItems = 0;
this._totalItems = 0;
};
inherits(GmxMaterial, Material);
GmxMaterial.applySceneBitmapImage = function (id, bitmapImage) {
this.sceneTexture[id] = this.segment.handler.createTexture(bitmapImage);
this.sceneExists[id] = true;
this.sceneIsReady[id] = true;
this.sceneIsLoading[id] = false;
};
GmxMaterial.prototype.setTotalItems = function (n) {
this._totalItems = n;
};
GmxMaterial.prototype.notComplete = function () {
return this._completedItems !== this._totalItems;
};
GmxMaterial.prototype.sceneNotExists = function (id) {
this.sceneIsReady[id] = true;
this.sceneExists[id] = false;
this.sceneIsLoading[id] = false;
};
GmxMaterial.prototype.clear = function () {
if (this.isReady) {
var gl = this.segment.handler.gl;
this.isReady = false;
this.pickingReady = false;
var t = this.texture;
this.texture = null;
t && !t.default && gl.deleteTexture(t);
t = this.pickingMask;
this.pickingMask = null;
t && !t.default && gl.deleteTexture(t);
t = this._updateTexture;
this._updateTexture = null;
t && !t.default && gl.deleteTexture(t);
t = this._updatePickingMask;
this._updatePickingMask = null;
t && !t.default && gl.deleteTexture(t);
this._completedItems = 0;
this._totalItems = 0;
}
this._gmxClear();
this.layer.abortMaterialLoading(this);
this.isLoading = false;
this.textureExists = false;
this.fromTile = null;
};
GmxMaterial.prototype.abort = function () {
this.isLoading = false;
this.isReady = false;
this._gmxClear();
};
GmxMaterial.prototype._gmxClear = function () {
this.sceneIsLoading = {};
this.sceneExists = {};
this.sceneIsReady = {};
for (let c in this.sceneTexture) {
let t = this.sceneTexture[c];
t && !t.default && gl.deleteTexture(t);
}
};
export { GmxMaterial };

View File

@ -1,45 +0,0 @@
/**
* @module og/gmx/GmxTileData
*/
'use strict';
/**
* 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.
*/
const GmxTileData = 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 = [];
};
GmxTileData.prototype.addTileItem = function (tileItem) {
tileItem.tileData = this;
tileItem.tileDataIndex = this.tileItems.length;
this.tileItems.push(tileItem);
};
GmxTileData.prototype.addTileItems = function (tileItems) {
for (var i = 0; i < tileItems.length; i++) {
this.addTileItem(tileItems[i]);
}
};
export { GmxTileData };

View File

@ -1,48 +0,0 @@
/**
* @module og/gmx/GmxTileDataGroup
*/
'use strict';
/**
* 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.
*/
const GmxTileDataGroup = function (layer, extent) {
this.layer = layer;
this.tileExtent = extent;
this.tileDataArr = [];
this.tileItemArr = [];
this.tileItemsCache = {};
};
GmxTileDataGroup.prototype.addTileData = function (tileData) {
tileData.group = this;
tileData.groupIndex = this.tileDataArr.length;
this.tileDataArr.push(tileData);
};
GmxTileDataGroup.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]);
}
}
};
GmxTileDataGroup.prototype.addTileItem = function (tileItem) {
this.tileItemArr.push(tileItem);
this.tileItemsCache[tileItem.item.id] = tileItem;
};
export { GmxTileDataGroup };

View File

@ -1,186 +0,0 @@
/**
* @module og/gmx/GmxTileItem
*/
'use strict';
import * as math from '../../math.js';
import { Extent } from '../../Extent.js';
import { earcut, flatten } from '../../utils/earcut.js';
import { GmxVectorTileCreator } from './GmxVectorTileCreator.js';
import { LonLat } from '../../LonLat.js';
function chkOnEdge(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;
};
const GmxTileItem = function (item, geometry) {
this.tileData = null;
this.tileDataIndex = -1;
this.item = item;
this.geometry = geometry;
this.extent = null;
//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;
};
GmxTileItem.prototype.createBuffers = function (handler, extent) {
if (!this._ready) {
this._createVertices(extent);
this._createBuffers(handler);
this._ready = true;
}
};
GmxTileItem.prototype._createVertices = function (extent) {
var geometry = this.geometry;
this._polyVerticesMerc = [];
this._lineVerticesMerc = [];
if (!this.extent) {
this.extent = new Extent(new LonLat(math.MAX_FLOAT, math.MAX_FLOAT), new LonLat(-math.MAX_FLOAT, -math.MAX_FLOAT));
}
var ne = this.extent.northEast,
sw = this.extent.southWest;
if (geometry.type.trim().toLowerCase() === "polygon") {
let coordinates = geometry.coordinates;
let data = flatten(coordinates);
let indexes = earcut(data.vertices, data.holes, 2);
this._polyVerticesMerc = data.vertices;
this._polyIndexes = indexes;
for (let i = 0; i < coordinates.length; i++) {
let ci = coordinates[i];
let path = [];
let startLine = false;
let isClosed = true;
for (let j = 0; j < ci.length; j++) {
let 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] > ne.lat) ne.lat = p[1];
if (!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);
GmxVectorTileCreator.appendLineData([path], false, this._lineVerticesMerc, this._lineOrders, this._lineIndexes);
path = [];
}
}
if (path.length) {
GmxVectorTileCreator.appendLineData([path], isClosed, this._lineVerticesMerc, this._lineOrders, this._lineIndexes);
}
}
} else if (geometry.type.trim().toLowerCase() === "multipolygon") {
let coordinates = geometry.coordinates;
let vertices = [],
indexes = [];
for (let i = 0; i < coordinates.length; i++) {
let cci = coordinates[i];
let data = flatten(cci);
let dataIndexes = earcut(data.vertices, data.holes, 2);
for (let 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++) {
let ci = cci[ii];
let path = [];
let startLine = false;
let isClosed = true;
for (let j = 0; j < ci.length; j++) {
let 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] > ne.lat) ne.lat = p[1];
if (!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);
GmxVectorTileCreator.appendLineData([path], false, this._lineVerticesMerc, this._lineOrders, this._lineIndexes);
path = [];
}
}
if (path.length) {
GmxVectorTileCreator.appendLineData([path], isClosed, this._lineVerticesMerc, this._lineOrders, this._lineIndexes);
}
}
}
this._polyVerticesMerc = vertices;
this._polyIndexes = indexes;
} else if (geometry.type.toLowerCase() === "linestring") {
//
//TODO:extent
//
GmxVectorTileCreator.appendLineData([geometry._coordinates], false, this._lineVerticesMerc, this._lineOrders, this._lineIndexes);
} else if (geometry.type.toLowerCase() === "multilinestring") {
//
//TODO:extent
//
GmxVectorTileCreator.appendLineData(geometry._coordinates, false, this._lineVerticesMerc, this._lineOrders, this._lineIndexes);
}
};
GmxTileItem.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);
};
export { GmxTileItem };

View File

@ -1,841 +0,0 @@
/**
* @module og/gmx/GmxVector
*/
'use strict';
import * as utils from '../../utils/shared.js';
import { ajax } from '../../ajax.js';
import { EPSG3857 } from '../../proj/EPSG3857.js';
import { Extent } from '../../Extent.js';
import { Geometry } from '../../entity/Geometry.js';
import { GmxCheckVersion } from './GmxCheckVersion.js';
import { GmxItem } from './GmxItem.js';
import { GmxMaterial } from './GmxMaterial.js';
import { GmxTileData } from './GmxTileData.js';
import { GmxTileItem } from './GmxTileItem.js';
import { GmxTileDataGroup } from './GmxTileDataGroup.js';
import { GmxVectorTileCreator } from './GmxVectorTileCreator.js';
import { isEmpty } from '../../utils/shared.js';
import { Layer } from '../../layer/Layer.js';
import { QueueArray } from '../../QueueArray.js';
import { RENDERING } from '../../quadTree/quadTree.js';
import { Vec4 } from '../../math/Vec4.js';
const TileSenderUrlImagery = '//maps.kosmosnimki.ru/TileSender.ashx?ModeKey=tile&ftc=osm&x={x}&y={y}&z={z}&srs=3857&LayerName={l}';
const 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}';
const 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}';
let __requestsCounter = 0;
const MAX_REQUESTS = 15;
const 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"
];
/**
* TODO: description
* @class
* @param {String} name - Layer user name.
* @param {Object} options:
* @extends {og.Layer}
*/
class GmxVector extends Layer {
constructor(name, options) {
super(name, options);
options = 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 = utils.createColorRGBA(this._style.fillColor, new Vec4(0.19, 0.62, 0.85, 0.57));
this._style.lineColor = utils.createColorRGBA(this._style.lineColor, new Vec4(0.19, 0.62, 0.85, 1));
this._style.strokeColor = utils.createColorRGBA(this._style.strokeColor, new Vec4(1, 1, 1, 0.95));
this._style.lineWidth = this._style.lineWidth || 5;
this._style.strokeWidth = this._style.strokeWidth || 0;
this.events.registerNames(EVENT_NAMES);
this._needRefresh = false;
this._tileDataGroupQueue = new 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 QueueArray();
}
static getLayerInfo(hostUrl, layerId, proceedCallback, errorCallback) {
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);
}
});
}
static dateToEpoch(date) {
var time = date.getTime();
return time - time % 86400000;
}
get instanceName() {
return "GmxVector";
}
_bindPicking() {
this._pickingColor.clear();
}
createMaterial(segment) {
return new GmxMaterial(segment, this);
}
/**
* Adds layer to the planet.
* @public
* @param {og.scene.RenderNode} planet - Planet scene.
* @return {og.gmx.VectorLayer} - Returns og.gmx.VectorLayer instance.
*/
addTo(planet) {
//Bind checkVersion to the planet
if (!planet._gmxCheckVersion) {
planet._gmxCheckVersion = new GmxCheckVersion(planet);
}
//Bind gmxVectorTileCreator to the planet
if (!planet._gmxVectorTileCreator) {
planet._gmxVectorTileCreator = new GmxVectorTileCreator(planet);
}
this._assignPlanet(planet);
if (this._visibility && !this._initialized) {
this._initialize();
}
return this;
}
/**
* Removes from planet.
* @public
* @returns {og.gmx.VectorLayer.Layer} -This layer.
*/
remove() {
super.remove();
this._planet && this._planet.events.off("draw", this._onRefreshNodes);
this._initialized = false;
return this;
}
_initialize() {
this._initialized = true;
var p = this._planet;
var that = this;
GmxVector.getLayerInfo(this.hostUrl, this._layerId, function (data) {
that._gmxProperties = data.properties;
if (data.properties.Temporal) {
var d = new Date();
var currEpoch = GmxVector.dateToEpoch(d);
that._beginDate = that._beginDate || new Date(currEpoch);
that._endDate = that._endDate || new Date(d.setTime(currEpoch + 24 * 60 * 60 * 1000));
that._tileSenderUrlTemplate = TileSenderUrlTemporal;
that._tileImageryUrlTemplate = TileSenderUrlImagery;
} else {
that._tileSenderUrlTemplate = TileSenderUrl;
}
that.setExtent(Geometry.getExtent(data.geometry));
p._gmxCheckVersion.update();
});
}
/**
* Sets layer visibility.
* @public
* @virtual
* @param {boolean} visibility - Layer visibility.
*/
setVisibility(visibility) {
super.setVisibility(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();
}
}
_checkVersionSuccess(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 = 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()
});
}
}
}
setFilter(filterCallback) {
this._filterCallback = filterCallback;
this.updateFilter();
}
removeFilter() {
this._filterCallback = null;
this.updateFilter();
}
getItemVisibility(item) {
if (!this._filterCallback) {
return true;
}
var visibility = this._filteredItems[item.id];
if (isEmpty(visibility)) {
visibility = this._filteredItems[item.id] = this._filterCallback[item.id](item);
}
return visibility;
}
updateFilter() {
this._filteredItems = {};
//...TODO
}
setStyleHook(styleCallback) {
this._styleCallback = styleCallback;
this.updateStyle();
}
getItemStyle(item) {
if (!this._styleCallback) {
return item._style;
}
var style = this._styledItems[item.id];
if (isEmpty(style)) {
style = this._styledItems[item.id] = this._styleCallback[item.id](item);
}
return style;
}
updateStyle() {
this._styledItems = {};
//...TODO
}
_vecLoadTileData(t) {
if (__requestsCounter >= MAX_REQUESTS && this._vecCounter) {
this._vecPendingsQueue.push(t);
} else {
this._vecExec(t);
}
}
_vecExec(t) {
var url = utils.stringTemplate(this._tileSenderUrlTemplate, t);
__requestsCounter++;
this._vecCounter++;
var that = this;
ajax.request(url, {
'type': "GET",
'responseType': "text",
'success': function (dataStr) {
__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) {
__requestsCounter--;
that._vecCounter--;
console.log(err);
that._vecDequeueRequest();
}
});
}
_vecDequeueRequest() {
if (this._vecPendingsQueue.length) {
if (__requestsCounter < 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);
}
}
}
_vecWhilePendings() {
while (this._vecPendingsQueue.length) {
return this._vecPendingsQueue.pop();
}
}
addItem(item) {
if (!item._layer) {
this._itemCache[item.id] = item;
item._layer = this;
if (this._planet) {
this._planet.renderer.assignPickingColor(item);
}
}
}
_getAttributes(item) {
var res = {},
prop = this._gmxProperties;
var attrs = prop.attributes,
types = prop.attrTypes;
for (var i = 0; i < attrs.length; i++) {
res[attrs[i]] = utils.castType[types[i]](item[i + 1]);
}
return res;
}
getStyle() {
}
_handleTileData(t, data) {
var items = data.values,
style = this._style,
v = data.v;
var h = this._planet.renderer.handler;
var tileIndex = Layer.getTileIndex(t.x, t.y, t.z),
tileExtent = Extent.fromTile(t.x, t.y, t.z),
cacheTileDataGroup = this._tileDataGroupCache[tileIndex];
if (!cacheTileDataGroup) {
cacheTileDataGroup = this._tileDataGroupCache[tileIndex] = new GmxTileDataGroup(this, tileExtent);
}
var tileData = new GmxTileData(data),
tileDataCacheIndex = 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 GmxItem(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 GmxTileItem(cacheItem, item[item.length - 1]);
ti.createBuffers(h, tileExtent);
tileData.addTileItem(ti);
cacheTileDataGroup.addTileItem(ti);
}
this._tileDataGroupQueue.push(cacheTileDataGroup);
this._needRefresh = true;
}
_onRefreshNodes(p) {
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.
}
_refreshRecursevelyExtent(extent, treeNode) {
if (treeNode.ready) {
var lid = this._id;
for (var i = 0; i < treeNode.nodes.length; i++) {
var ni = treeNode.nodes[i];
if (extent.overlaps(ni.segment._extent)) {
this._refreshRecursevelyExtent(extent, ni);
var m = ni.segment.materials[lid];
if (m) {
if (m.segment.node.getState() !== 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;
//reset drawing process
m._completedItems = 0;
m._totalItems = 0;
}
//item._pickingReady = true;
}
}
}
}
}
/**
* Start to load tile material.
* @public
* @virtual
* @param {og.planetSegment.Material} material - Current material.
*/
loadMaterial(material) {
var seg = material.segment;
if (seg._projection.id !== 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
});
}
}
}
_getTileDataGroup(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.segment.tileIndex];
if (ptc) {
return ptc;
}
pn = pn.parentNode;
}
}
return null;
}
getGmxProperties() {
return this._gmxProperties;
}
_loadScene(tileItem, material) {
const item_id = tileItem.item.id;
let seg = material.segment;
material.sceneIsLoading[item_id] = true;
var url = utils.stringTemplate(this._tileImageryUrlTemplate, {
'x': seg.tileX,
'y': seg.tileY,
'z': seg.tileZoom,
'l': tileItem.item.attributes.GMX_RasterCatalogID
});
this._planet._tileLoader.load({
'src': url,
'type': 'imageBitmap',
'filter': () => seg.plainReady && seg.node.getState() === RENDERING,
'options': {}
}, (response) => {
if (response.status === "ready") {
if (material.isLoading) {
let e = this.events.load;
if (e.handlers.length) {
this.events.dispatch(e, material);
}
material.applySceneBitmapImage(item_id, response.data);
}
} else if (response.status === "abort") {
material.sceneIsLoading[item_id] = false;
} else if (response.status === "error") {
if (material.sceneIsLoading[item_id] === true) {
material.sceneNotExists(item_id);
}
}
});
}
applySceneTexture(tileItem, material) {
const item_id = tileItem.item.id;
if (material.sceneIsReady[item_id]) {
return [0, 0, 1, 1];
} else {
if (!material.sceneIsLoading[item_id]) {
this._loadScene(tileItem, material);
}
// var segment = material.segment;
// var pn = segment.node,
// notEmpty = false;
// var mId = this._id;
// var psegm = material;
// while (pn.parentNode) {
// if (psegm && psegm.sceneIsReady[item_id]) {
// notEmpty = true;
// break;
// }
// pn = pn.parentNode;
// psegm = pn.segment.materials[mId];
// }
// if (notEmpty) {
// material.sceneTexture[item_id] = psegm.sceneTexture[item_id];
// var dZ2 = 1.0 / (2 << (segment.tileZoom - pn.segment.tileZoom - 1));
// return [
// segment.tileX * dZ2 - pn.segment.tileX,
// segment.tileY * dZ2 - pn.segment.tileY,
// dZ2,
// dZ2
// ];
// } else {
// material.sceneTexture[item_id] = segment.planet.transparentTexture;
// return [0, 0, 1, 1];
// }
}
}
/**
* Abort exact material loading.
* @public
* @param {og.planetSegment.Material} material - Segment material.
*/
abortMaterialLoading(material) {
material.abort();
}
applyMaterial(material) {
if (material.isReady) {
if (material.notComplete() && !material.isLoading) {
material.isLoading = true;
this._planet._gmxVectorTileCreator.add({
'material': material,
'fromTile': material.fromTile
});
}
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.segment.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.segment.tileZoom - 1));
return [
segment.tileX * dZ2 - pn.segment.tileX,
segment.tileY * dZ2 - pn.segment.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];
}
}
}
clearMaterial(material) {
material.clear();
}
_refreshRecursevely(item, treeNode) {
if (treeNode.ready) {
var lid = this._id;
for (var i = 0; i < treeNode.nodes.length; i++) {
var ni = treeNode.nodes[i];
if (item._extent.overlaps(ni.segment._extent)) {
this._refreshRecursevely(item, ni);
var m = ni.segment.materials[lid];
if (m && m.isReady) {
if (m.segment.node.getState() !== RENDERING) {
m.layer.clearMaterial(m);
} else {
m.pickingReady = m.pickingReady && item._pickingReady;
m.isReady = false;
m._updateTexture = m.texture;
m._updatePickingMask = m.pickingMask;
//reset drawing process
m._completedItems = 0;
m._totalItems = 0;
}
item._pickingReady = true;
}
}
}
}
}
_refreshPlanetNode(treeNode) {
for (var i = 0, items = this._updatedItemArr; i < items.length; i++) {
this._refreshRecursevely(items[i], treeNode);
}
}
_updatePlanet() {
if (this._updatedItemArr.length) {
if (this._planet) {
this._refreshPlanetNode(this._planet._quadTree);
}
this._updatedItemArr.length = 0;
this._updatedItemArr = [];
this._updatedItems = {};
}
}
updateItems(items) {
for (var i = 0; i < items.length; i++) {
this.updateItem(items[i]);
}
}
updateItem(item) {
if (item._extent) {
this._updatedItemArr.push(item);
this._updatedItems[item.id] = item;
}
}
update() {
this._updatePlanet();
this.events.dispatch(this.events.draw, this);
}
setStyle(style) {
//...
}
clear() {
this._itemCache = {};
this._tileDataCache = {};
this._tileDataGroupCache = {};
this._tileVersions = {};
}
refresh() {
if (this._gmxProperties) {
this.clear();
if (this._planet) {
this._planet._gmxCheckVersion.update();
}
}
}
setDateInterval(beginDate, endDate) {
this._beginDate = beginDate;
this._endDate = endDate;
// if (this._gmxProperties && this._gmxProperties.Temporal) {
// }
}
};
export { GmxVector };

View File

@ -1,444 +0,0 @@
/**
* @module og/gmx/GmxVectorTileCreator
*/
'use strict';
import { VectorTileCreator } from '../../utils/VectorTileCreator.js';
import { inherits } from '../../inherits.js';
import { RENDERING } from '../../quadTree/quadTree.js';
import { Program } from '../../webgl/Program.js';
import { types } from '../../webgl/types.js';
import { Framebuffer } from '../../webgl/Framebuffer.js';
const GmxVectorTileCreator = function (planet, maxFrames, width, height) {
VectorTileCreator.call(this, planet, maxFrames, width, height);
this._maskTexture = null;
this._framebuffer = null;
this._temporaryData_ = null;
planet.events.on("draw", this.frame, this);
};
inherits(GmxVectorTileCreator, VectorTileCreator);
GmxVectorTileCreator.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 {
let 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 {
let 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);
}
}
};
GmxVectorTileCreator.prototype._initialize = function () {
//Line
if (!this._handler.programs.gmxVectorTileLineRasterization) {
this._handler.addProgram(new Program("gmxVectorTileLineRasterization", {
uniforms: {
'viewport': { type: types.VEC2 },
'thicknessOutline': { type: types.FLOAT },
'alpha': { type: types.FLOAT },
'extentParams': { type: types.VEC4 },
'color': { type: types.VEC4 },
'thickness': { type: types.FLOAT }
},
attributes: {
'prev': { type: types.VEC2 },
'current': { type: types.VEC2 },
'next': { type: types.VEC2 },
'order': { type: 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.programs.gmxVectorTilePolygonRasterization) {
this._handler.addProgram(new Program("gmxVectorTilePolygonRasterization", {
uniforms: {
'extentParams': { type: types.VEC4 },
'color': { type: types.VEC4 }
},
attributes: {
'coordinates': { type: 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 Framebuffer(this._handler, {
width: this._width,
height: this._height,
useDepth: false
});
this._framebuffer.init();
this._temporaryData_ = new Uint8Array(4 * this._width * this._height);
this._maskTexture = this._handler.createEmptyTexture_n(this._width, this._height);
};
GmxVectorTileCreator.prototype.add = function (data) {
this._queue.push(data);
};
GmxVectorTileCreator.prototype.frame = function () {
if (this._planet.layerLock.isFree() && this._queue.length) {
const h = this._handler;
const gl = h.gl;
const p = this._planet;
const hLine = h.programs.gmxVectorTileLineRasterization;
const hPoly = h.programs.gmxVectorTilePolygonRasterization;
const f = this._framebuffer.activate();
const _w = this._width;
const _h = this._height;
const _w2 = _w << 1;
const _h2 = _h << 1;
let width = _w,
height = _h;
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);
let deltaTime = 0,
startTime = window.performance.now();
while (p.layerLock.isFree() && this._queue.length && deltaTime < 0.25) {
let q = this._queue.shift(),
fromTile = q.fromTile,
material = q.material;
if (material.isLoading && material.segment.node.getState() === RENDERING) {
let layer = material.layer,
tItems = fromTile.tileItemArr,
materialZoom = material.segment.tileZoom,
zoomAvailable = materialZoom >= layer._gmxProperties.RCMinZoomForRasters,
extent = material.segment.getExtentMerc(),
extentParams = [extent.southWest.lon, extent.southWest.lat, 2.0 / extent.getWidth(), 2.0 / extent.getHeight()];
material.setTotalItems(tItems.length);
//
//TODO: sort optimization is needed PLEASE!!!! PLEASE!!!!
tItems.sort(function (a, b) {
return layer.getItemStyle(a.item).zIndex - layer.getItemStyle(b.item).zIndex || a.item.id - b.item.id;
});
//
if (materialZoom <= 3) {
width = _w2;
height = _h2;
} else {
width = _w;
height = _h;
}
f.setSize(width, height);
let texture = material.texture,
pickingMask = material.pickingMask;
if (material._completedItems === 0) {
texture = material._updateTexture && material._updateTexture || h.createEmptyTexture_l(width, height);
if (layer._pickingEnabled && !material.pickingReady) {
if (material._updatePickingMask) {
pickingMask = material._updatePickingMask;
} else {
pickingMask = h.createEmptyTexture_n(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);
}
let i = 0;
while (i < 200 && material._completedItems < material._totalItems) {
let ti = tItems[material._completedItems];
if (layer.getItemVisibility(ti.item) && ti.extent.overlaps(extent)) {
let style = layer.getItemStyle(ti.item),
pickingColor = [ti.item._pickingColor.x / 255.0, ti.item._pickingColor.y / 255.0, ti.item._pickingColor.z / 255.0, 1.0];
hPoly.activate();
let sh = hPoly._program,
sha = sh.attributes,
shu = sh.uniforms;
//==============
//polygon
//==============
f.bindOutputTexture(texture);
gl.uniform4fv(shu.color, [style.fillColor.x, style.fillColor.y, style.fillColor.z, style.fillColor.w]);
gl.uniform4fv(shu.extentParams, extentParams);
gl.bindBuffer(gl.ARRAY_BUFFER, ti._polyVerticesBufferMerc);
gl.vertexAttribPointer(sha.coordinates, 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 (!material.pickingReady) {
f.bindOutputTexture(pickingMask);
gl.uniform4fv(shu.color, 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, [width, height]);
gl.uniform4fv(shu.extentParams, extentParams);
//vertex
var mb = ti._lineVerticesBufferMerc;
gl.bindBuffer(gl.ARRAY_BUFFER, mb);
gl.vertexAttribPointer(sha.prev, mb.itemSize, gl.FLOAT, false, 8, 0);
gl.vertexAttribPointer(sha.current, mb.itemSize, gl.FLOAT, false, 8, 32);
gl.vertexAttribPointer(sha.next, mb.itemSize, gl.FLOAT, false, 8, 64);
//order
gl.bindBuffer(gl.ARRAY_BUFFER, ti._lineOrdersBuffer);
gl.vertexAttribPointer(sha.order, ti._lineOrdersBuffer.itemSize, gl.FLOAT, false, 4, 0);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ti._lineIndexesBuffer);
//PASS - stroke
gl.uniform1f(shu.thickness, style.strokeWidth);
gl.uniform4fv(shu.color, style.strokeColor.toArray());
//Antialias pass
gl.uniform1f(shu.thicknessOutline, 2);
gl.uniform1f(shu.alpha, 0.54);
gl.drawElements(gl.TRIANGLE_STRIP, ti._lineIndexesBuffer.numItems, gl.UNSIGNED_INT, 0);
//
//Aliased pass
gl.uniform1f(shu.thicknessOutline, 1);
gl.uniform1f(shu.alpha, 1.0);
gl.drawElements(gl.TRIANGLE_STRIP, ti._lineIndexesBuffer.numItems, gl.UNSIGNED_INT, 0);
//PASS - inside line
gl.uniform1f(shu.thickness, style.lineWidth);
gl.uniform4fv(shu.color, style.lineColor.toArray());
//Antialias pass
gl.uniform1f(shu.thicknessOutline, 2);
gl.uniform1f(shu.alpha, 0.54);
gl.drawElements(gl.TRIANGLE_STRIP, ti._lineIndexesBuffer.numItems, gl.UNSIGNED_INT, 0);
//
//Aliased pass
gl.uniform1f(shu.thicknessOutline, 1);
gl.uniform1f(shu.alpha, 1.0);
gl.drawElements(gl.TRIANGLE_STRIP, ti._lineIndexesBuffer.numItems, gl.UNSIGNED_INT, 0);
//Outline picking pass
f.bindOutputTexture(pickingMask);
gl.uniform1f(shu.thicknessOutline, 8);
gl.uniform4fv(shu.color, pickingColor);
gl.drawElements(gl.TRIANGLE_STRIP, ti._lineIndexesBuffer.numItems, gl.UNSIGNED_INT, 0);
}
material._completedItems++;
i++;
}
material.applyTexture(texture, pickingMask);
if (material.notComplete()) {
material.isLoading = true;
this.add(q);
} else if (layer._gmxProperties.Temporal && zoomAvailable) {
//Suggested that material.pickingMask is applied already in the frame buffer
this._proceedImageryTiles(layer, material);
}
} 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();
}
};
GmxVectorTileCreator.prototype._proceedImageryTiles = function (layer, material) {
const f = this._framebuffer;
let data = this._temporaryData_;
f.readAllPixels(data);
var toLoad = 0;
for (let i = data.length - 1; i >= 0; i -= 4) {
let c = layer.planet.renderer.getPickingObjectByColor(data[i - 3], data[i - 2], data[i - 1]);
if (c) {
toLoad++;
let sceneTextureOffset = layer.applySceneTexture(
material.fromTile.tileItemsCache[c.id], material);
}
}
};
export { GmxVectorTileCreator };

View File

@ -10,10 +10,10 @@
* @api
*/
export const Units = {
"DEGREES": "degrees",
"FEET": "ft",
"METERS": "m",
"KILOMETERS": "km"
DEGREES: "degrees",
FEET: "ft",
METERS: "m",
KILOMETERS: "km"
};
/**

View File

@ -6,7 +6,6 @@
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';
@ -46,7 +45,7 @@ EntityCollectionNode.prototype._addEntitiesToCollection = function (entities, ri
if (!ec) {
ec = new EntityCollection({
'pickingEnabled': l._pickingEnabled
pickingEnabled: l._pickingEnabled
});
ec._layer = this.layer;
ec.addTo(p, true);
@ -136,7 +135,6 @@ EntityCollectionNode.prototype.buildTree = function (entities, rightNow) {
}
};
EntityCollectionNode.prototype.createChildrenNodes = function () {
var l = this.layer;
var ext = this.extent;
@ -164,10 +162,7 @@ EntityCollectionNode.prototype.createChildrenNodes = function () {
};
EntityCollectionNode.prototype.collectRenderCollectionsPASS1 = function (visibleNodes, outArr) {
var p = this.layer._planet;
var cam = p.renderer.activeCamera;
var n = visibleNodes[this.nodeId];
if (n) {
var cn = this.childrenNodes;
if (this.entityCollection) {
@ -288,7 +283,7 @@ EntityCollectionNode.prototype.renderCollection = function (outArr, visibleNodes
EntityCollectionNode.prototype.alignEntityToTheGround = function (entity, segment) {
var res = new Vec3();
segment.getEntityTerrainPoint(entity, res);
entity._setCartesian3vSilent(res.addA(res.normal().scale(Number(this.layer.relativeToGround) && entity._altitude || 0.0)));
entity._setCartesian3vSilent(res.addA(res.normal().scale((Number(this.layer.relativeToGround) && entity._altitude) || 0.0)));
};
EntityCollectionNode.prototype.isVisible = function () {

View File

@ -58,8 +58,7 @@ function getMatrixSubArray(sourceArr, gridSize, i0, j0, size) {
return res;
};
///**
// /**
// * Returns two float32 triangle coordinate arrays from inside of the source triangle array.
// * @static
// * @param {Array.<number>} sourceArr - Source array
@ -70,7 +69,7 @@ function getMatrixSubArray(sourceArr, gridSize, i0, j0, size) {
// * @return{Array.<number>} Triangle coordinates array from the source array.
// * @TODO: optimization
// */
//function getMatrixSubArrayExt(sourceArrHigh, sourceArrLow, gridSize, i0, j0, size, outArrHigh, outArrLow) {
// function getMatrixSubArrayExt(sourceArrHigh, sourceArrLow, gridSize, i0, j0, size, outArrHigh, outArrLow) {
// const i0size = i0 + size + 1;
// const j0size = j0 + size + 1;
@ -90,9 +89,9 @@ function getMatrixSubArray(sourceArr, gridSize, i0, j0, size) {
// outArrHigh[vInd++] = sourceArrHigh[ind + 2];
// }
// }
//};
// };
///**
// /**
// * Returns triangle coordinate array from inside of the source triangle array.
// * @static
// * @param {Array.<number>} sourceArr - Source array
@ -104,7 +103,7 @@ function getMatrixSubArray(sourceArr, gridSize, i0, j0, size) {
// * @return{Array.<number>} Triangle coordinates array from the source array.
// * @TODO: optimization
// */
//function getMatrixSubArrayBounds(sourceArr, gridSize, i0, j0, size, outBounds) {
// function getMatrixSubArrayBounds(sourceArr, gridSize, i0, j0, size, outBounds) {
// const size_1 = size + 1;
// const i0size = i0 + size_1;
@ -134,7 +133,7 @@ function getMatrixSubArray(sourceArr, gridSize, i0, j0, size) {
// }
// }
// return res;
//};
// };
/**
* Returns two float32 triangle coordinate arrays from inside of the source triangle array.
@ -195,8 +194,8 @@ function getMatrixSubArrayBoundsExt(sourceArr, sourceArrHigh, sourceArrLow, grid
* @param {number} tileZoom - Deep index of the quad tree.
* @param {og.Extent} extent - Planet segment extent.
*/
const Node = function (segmentPrototype, planet, partId, parent, id, tileZoom, extent) {
this.SegmentPrototype = segmentPrototype;
const Node = function (SegmentPrototype, planet, partId, parent, id, tileZoom, extent) {
this.SegmentPrototype = SegmentPrototype;
this.planet = planet;
this.parentNode = parent;
this.partId = partId;
@ -207,7 +206,7 @@ const Node = function (segmentPrototype, planet, partId, parent, id, tileZoom, e
this.ready = false;
this.neighbors = [[], [], [], []];
this.nodes = [null, null, null, null];
this.segment = new segmentPrototype(this, planet, tileZoom, extent);
this.segment = new SegmentPrototype(this, planet, tileZoom, extent);
this._cameraInside = false;
this.createBounds();
this.planet._createdNodesCount++;
@ -300,7 +299,7 @@ Node.prototype.createBounds = function () {
);
if (seg.tileZoom < MAX_NORMAL_ZOOM) {
//check for segment zoom
// check for segment zoom
let v_nw = new Vec3(pVerts[ind_nw], pVerts[ind_nw + 1], pVerts[ind_nw + 2]),
v_se = new Vec3(pVerts[ind_se], pVerts[ind_se + 1], pVerts[ind_se + 2]);
@ -440,7 +439,7 @@ Node.prototype.renderTree = function (cam, maxZoom, terrainReadySegment, stopLoa
this._cameraInside = false;
//Search a node which the camera is flying over.
// Search a node which the camera is flying over.
if (!this.parentNode || this.parentNode._cameraInside) {
let inside;
if (Math.abs(cam._lonLat.lat) <= MAX_LAT &&
@ -468,16 +467,16 @@ Node.prototype.renderTree = function (cam, maxZoom, terrainReadySegment, stopLoa
let altVis = (cam.eye.distance(seg.bsphere.center) - seg.bsphere.radius < VISIBLE_DISTANCE * Math.sqrt(h)) || seg.tileZoom < 2;
if (inFrustum && (altVis || h > 10000.0) || this._cameraInside) {
if ((inFrustum && (altVis || h > 10000.0)) || this._cameraInside) {
seg._collectVisibleNodes();
}
//First skip lowest zoom nodes
// First skip lowest zoom nodes
if (seg.tileZoom < 2 && seg.normalMapReady) {
this.traverseNodes(cam, maxZoom, terrainReadySegment, stopLoading);
} else if (!maxZoom && seg.acceptForRendering(cam) || seg.tileZoom === maxZoom) {
} else if ((!maxZoom && seg.acceptForRendering(cam)) || seg.tileZoom === maxZoom) {
this.prepareForRendering(cam, altVis, inFrustum, terrainReadySegment, stopLoading);
} else if (seg.tileZoom < planet.terrain._maxNodeZoom && seg.terrainReady && !maxZoom || maxZoom) {
} else if (((seg.tileZoom < planet.terrain._maxNodeZoom) && (seg.terrainReady && !maxZoom)) || maxZoom) {
if (seg.terrainReady) {
this.traverseNodes(cam, maxZoom, seg, stopLoading);
} else {
@ -539,7 +538,7 @@ Node.prototype.renderNode = function (onlyTerrain, terrainReadySegment, stopLoad
var seg = this.segment;
//Create and load terrain data.
// Create and load terrain data
if (!seg.terrainReady) {
if (!seg.initialized) {
@ -560,7 +559,7 @@ Node.prototype.renderNode = function (onlyTerrain, terrainReadySegment, stopLoad
}
}
//Create normal map texture
// Create normal map texture
if (seg.planet.lightEnabled && !seg.normalMapReady && !seg.parentNormalMapReady) {
this.whileNormalMapCreating();
}
@ -570,7 +569,7 @@ Node.prototype.renderNode = function (onlyTerrain, terrainReadySegment, stopLoad
return;
}
//Calculate minimal and maximal zoom index on the screen
// Calculate minimal and maximal zoom index on the screen
if (!this._cameraInside && seg.tileZoom > this.planet.maxCurrZoom) {
this.planet.maxCurrZoom = seg.tileZoom;
}
@ -581,7 +580,7 @@ Node.prototype.renderNode = function (onlyTerrain, terrainReadySegment, stopLoad
seg._addViewExtent();
//Finally this node proceeds to rendering.
// Finally this node proceeds to rendering.
this.addToRender();
};
@ -717,7 +716,6 @@ Node.prototype.whileNormalMapCreating = function () {
seg.normalMapTextureBias[1] = seg.tileY - pn.segment.tileY * dZ2;
seg.normalMapTextureBias[2] = 1.0 / dZ2;
if (seg.tileZoom > maxZ) {
if (pn.segment.tileZoom === maxZ) {
seg.parentNormalMapReady = true;
@ -726,12 +724,12 @@ Node.prototype.whileNormalMapCreating = function () {
};
let BOUNDS = {
'xmin': 0.0,
'ymin': 0.0,
'zmin': 0.0,
'xmax': 0.0,
'ymax': 0.0,
'zmax': 0.0
xmin: 0.0,
ymin: 0.0,
zmin: 0.0,
xmax: 0.0,
ymax: 0.0,
zmax: 0.0
};
Node.prototype.whileTerrainLoading = function (terrainReadySegment, stopLoading) {
@ -761,8 +759,6 @@ Node.prototype.whileTerrainLoading = function (terrainReadySegment, stopLoading)
tempVerticesHigh,
tempVerticesLow;
//if (this.appliedTerrainNodeId !== pn.nodeId) { //Replced to the first if 768
this.appliedTerrainNodeId = pn.nodeId;
let gridSize = pn.segment.gridSize / dZ2,
@ -810,7 +806,7 @@ Node.prototype.whileTerrainLoading = function (terrainReadySegment, stopLoading)
pseg.normalMapVertices,
pseg.normalMapVerticesHigh,
pseg.normalMapVerticesLow,
pn.segment.fileGridSize,//pn.segment.planet.terrain.fileGridSize,
pn.segment.fileGridSize,
gridSizeExt * offsetY,
gridSizeExt * offsetX,
gridSizeExt,
@ -890,16 +886,12 @@ Node.prototype.whileTerrainLoading = function (terrainReadySegment, stopLoading)
}
}
//replace
//seg.createCoordsBuffers(tempVerticesHigh, tempVerticesLow, seg.gridSize);
//with
seg.readyToEngage = true;
seg.terrainVertices = tempVertices;
seg.terrainVerticesHigh = tempVerticesHigh;
seg.terrainVerticesLow = tempVerticesLow;
//is used for earth point calculation(see segment object)
seg.tempVertices = tempVertices;
seg.tempVerticesHigh = tempVerticesHigh;
seg.tempVerticesLow = tempVerticesLow;
@ -910,7 +902,6 @@ Node.prototype.whileTerrainLoading = function (terrainReadySegment, stopLoading)
BOUNDS.zmin + (BOUNDS.zmax - BOUNDS.zmin) * 0.5,
new Vec3(BOUNDS.xmin, BOUNDS.ymin, BOUNDS.zmin)
);
//}
if (seg.tileZoom > terrain.maxZoom) {
if (pn.segment.tileZoom >= terrain.maxZoom) {
@ -930,14 +921,14 @@ Node.prototype.whileTerrainLoading = function (terrainReadySegment, stopLoading)
seg.normalMapVertices = tempVertices;
seg.fileGridSize = Math.sqrt(tempVertices.length / 3) - 1;
let fgs = Math.sqrt(pseg.normalMapNormals.length / 3) - 1,//terrain.fileGridSize,
let fgs = Math.sqrt(pseg.normalMapNormals.length / 3) - 1,
fgsZ = fgs / dZ2;
if (fgs > 1) {
seg.normalMapNormals = getMatrixSubArray(pseg.normalMapNormals,
fgs, fgsZ * offsetY, fgsZ * offsetX, fgsZ);
} else {
//TODO: interpolation
// TODO: interpolation
seg.normalMapNormals = pseg.normalMapNormals;
}
}
@ -995,7 +986,7 @@ Node.prototype.clearTree = function () {
};
Node.prototype.clearBranches = function () {
for (i = 0; i < this.nodes.length; i++) {
for (let i = 0; i < this.nodes.length; i++) {
this.nodes[i].clearBranches();
this.nodes[i].segment.deleteMaterials();
}
@ -1034,6 +1025,4 @@ Node.prototype.traverseTree = function (callback) {
}
};
export { Node };
export { Node };

View File

@ -8,7 +8,6 @@ import { RendererEvents } from './RendererEvents.js';
import { Vec2 } from '../math/Vec2.js';
import { Vec3 } from '../math/Vec3.js';
import { cons } from '../cons.js';
//import { Program } from '../webgl/Program.js';
import { input } from '../input/input.js';
import { isEmpty } from '../utils/shared.js';
import { toneMapping } from '../shaders/toneMapping.js';
@ -223,7 +222,7 @@ Renderer.prototype.setEventsActivity = function (activity) {
*/
Renderer.prototype.addPickingCallback = function (sender, callback) {
var id = Renderer.__pickingCallbackCounter__++;
this._pickingCallbacks.push({ "id": id, "callback": callback, "sender": sender });
this._pickingCallbacks.push({ id: id, callback: callback, sender: sender });
return id;
};
@ -265,16 +264,17 @@ Renderer.prototype.assignPickingColor = function (obj) {
str = r + "_" + g + "_" + b;
}
if (!obj._pickingColor)
if (!obj._pickingColor) {
obj._pickingColor = new Vec3(r, g, b);
else
} else {
obj._pickingColor.set(r, g, b);
}
obj._pickingColorU = new Float32Array([r / 255, g / 255, b / 255]);
this.colorObjects[str] = obj;
}
}
};
/**
* Removes picking color from object.
@ -352,10 +352,11 @@ Renderer.prototype.removeControl = function (control) {
*/
Renderer.prototype.initialize = function () {
if (this._initialized)
if (this._initialized) {
return;
else
} else {
this._initialized = true;
}
var that = this;
@ -368,14 +369,14 @@ Renderer.prototype.initialize = function () {
});
this.activeCamera = new Camera(this, {
'eye': new Vec3(0, 0, 0),
'look': new Vec3(0, 0, -1),
'up': new Vec3(0, 1, 0)
eye: new Vec3(0, 0, 0),
look: new Vec3(0, 0, -1),
up: new Vec3(0, 1, 0)
});
this.events.initialize();
//Bind console key
// Bind console key
this.events.on("charkeypress", input.KEY_APOSTROPHE, function () {
cons.setVisibility(!cons.getVisibility());
});
@ -383,8 +384,8 @@ Renderer.prototype.initialize = function () {
this.handler.addProgram(screenFrame());
this.pickingFramebuffer = new Framebuffer(this.handler, {
'width': 640,
'height': 480
width: 640,
height: 480
}).init();
this.readPixels = () => { };
@ -532,11 +533,11 @@ Renderer.prototype._drawEntityCollections = function () {
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE);
gl.disable(gl.CULL_FACE);
//Z-buffer offset
// Z-buffer offset
gl.enable(gl.POLYGON_OFFSET_FILL);
gl.polygonOffset(0.0, 0.0);
//billboards pass
// billboards pass
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, this.billboardsTextureAtlas.texture);
@ -544,13 +545,13 @@ Renderer.prototype._drawEntityCollections = function () {
while (i--) {
var eci = ec[i];
if (eci._fadingOpacity) {
//first begin draw event
// first begin draw event
eci.events.dispatch(eci.events.draw, eci);
eci.billboardHandler.draw();
}
}
//labels pass
// labels pass
var fa = this.fontAtlas.atlasesArr;
for (i = 0; i < fa.length; i++) {
gl.activeTexture(gl.TEXTURE0 + i);
@ -562,13 +563,13 @@ Renderer.prototype._drawEntityCollections = function () {
ec[i]._fadingOpacity && ec[i].labelHandler.draw();
}
//rays
// rays
i = ec.length;
while (i--) {
ec[i]._fadingOpacity && ec[i].rayHandler.draw();
}
//polyline pass
// polyline pass
i = ec.length;
while (i--) {
ec[i]._fadingOpacity && ec[i].polylineHandler.draw();
@ -576,7 +577,7 @@ Renderer.prototype._drawEntityCollections = function () {
gl.enable(gl.CULL_FACE);
//pointClouds pass
// pointClouds pass
i = ec.length;
while (i--) {
if (ec[i]._fadingOpacity) {
@ -584,32 +585,32 @@ Renderer.prototype._drawEntityCollections = function () {
}
}
//shapes pass
// shapes pass
i = ec.length;
while (i--) {
var eci = ec[i];
eci = ec[i];
if (eci._fadingOpacity) {
eci.shapeHandler.draw();
}
}
//Strip pass
// Strip pass
i = ec.length;
while (i--) {
if (ec[i]._fadingOpacity) {
ec[i].stripHandler.draw();
//post draw event
// post draw event
eci.events.dispatch(eci.events.drawend, eci);
}
}
//gl.polygonOffset(0.0, 0.0);
// gl.polygonOffset(0.0, 0.0);
gl.disable(gl.POLYGON_OFFSET_FILL);
this._entityCollections.length = 0;
this._entityCollections = [];
}
}
};
/**
* Draw nodes.
@ -627,7 +628,7 @@ Renderer.prototype.draw = function () {
var h = this.handler;
//h.gl.clearColor(0.0, 0.0, 0.0, 1.0);
// h.gl.clearColor(0.0, 0.0, 0.0, 1.0);
h.gl.clearColor(115 / 255, 203 / 255, 249 / 255, 1.0);
h.gl.clear(h.gl.COLOR_BUFFER_BIT | h.gl.DEPTH_BUFFER_BIT);
@ -636,7 +637,7 @@ Renderer.prototype.draw = function () {
h.gl.activeTexture(h.gl.TEXTURE0);
h.gl.bindTexture(h.gl.TEXTURE_2D, h.transparentTexture);
//Rendering scene nodes
// Rendering scene nodes
var rn = this._renderNodesArr,
i = rn.length;
while (i--) {
@ -651,10 +652,10 @@ Renderer.prototype.draw = function () {
this.blitFramebuffer && sfb.blit(this.blitFramebuffer);
//Rendering picking callbacks and refresh pickingColor
// Rendering picking callbacks and refresh pickingColor
this._drawPickingBuffer();
//Rendering on the screen
// Rendering on the screen
this._fnScreenFrame();
e.mouseState.moving = false;
@ -677,7 +678,7 @@ Renderer.prototype._screenFrameMSAA = function () {
sh.activate();
//screen texture
// screen texture
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, this.blitFramebuffer.textures[0]);
gl.uniform1i(p.uniforms.hdrBuffer, 0);
@ -697,8 +698,8 @@ Renderer.prototype._screenFrameMSAA = function () {
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, this.bloomFramebuffer.textures[0]);
//gl.bindTexture(gl.TEXTURE_2D, this.pickingFramebuffer.textures[0]);
//gl.bindTexture(gl.TEXTURE_2D, globe.planet._heightPickingFramebuffer.textures[0]);
// gl.bindTexture(gl.TEXTURE_2D, this.pickingFramebuffer.textures[0]);
// gl.bindTexture(gl.TEXTURE_2D, globe.planet._heightPickingFramebuffer.textures[0]);
gl.uniform1i(p.uniforms.texture, 0);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
@ -716,7 +717,7 @@ Renderer.prototype._screenFrameNoMSAA = function () {
sh.activate();
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, this.sceneFramebuffer.textures[window.SCREEN]);
//gl.bindTexture(gl.TEXTURE_2D, this.pickingFramebuffer.textures[0]);
// gl.bindTexture(gl.TEXTURE_2D, this.pickingFramebuffer.textures[0]);
gl.uniform1i(p.uniforms.texture, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, this._screenFrameCornersBuffer);
gl.vertexAttribPointer(p.attributes.corners, 2, gl.FLOAT, false, 0, 0);
@ -773,12 +774,14 @@ Renderer.prototype._drawPickingBuffer = function () {
var pc = this._currPickingColor;
if (ts.x || ts.y) {
this.pickingFramebuffer.readPixels(pc, ts.nx, 1.0 - ts.ny);
if (!(pc[0] || pc[1] || pc[2]))
if (!(pc[0] || pc[1] || pc[2])) {
this.readPixels(pc, ts.nx, 1.0 - ts.ny, 1);
}
} else {
this.pickingFramebuffer.readPixels(pc, ms.nx, 1.0 - ms.ny);
if (!(pc[0] || pc[1] || pc[2]))
if (!(pc[0] || pc[1] || pc[2])) {
this.readPixels(pc, ms.nx, 1.0 - ms.ny, 1);
}
}
}
};
@ -791,5 +794,4 @@ Renderer.prototype.start = function () {
this.handler.start();
};
export { Renderer };

View File

@ -231,10 +231,6 @@ class RendererEvents extends Events {
}
}
isKeyPressed(keyCode) {
return this._keyboardHandler.isKeyPressed(keyCode);
}
/**
* Check key is pressed.
* @public
@ -299,7 +295,6 @@ class RendererEvents extends Events {
//dispatch stop mouse event
clearTimeout(this._mousestopThread);
var that = this;
this._mousestopThread = setTimeout(function () {
ms.justStopped = true;
}, 100);
@ -348,7 +343,7 @@ class RendererEvents extends Events {
(t - this._lClkBegins <= ms.clickDelay)) {
if (this._ldblClkBegins) {
var deltatime = window.performance.now() - this._ldblClkBegins;
let deltatime = window.performance.now() - this._ldblClkBegins;
if (deltatime <= ms.doubleClickDelay) {
ms.leftButtonDoubleClick = true;
}
@ -370,7 +365,7 @@ class RendererEvents extends Events {
(t - this._rClkBegins <= ms.clickDelay)) {
if (this._rdblClkBegins) {
var deltatime = window.performance.now() - this._rdblClkBegins;
let deltatime = window.performance.now() - this._rdblClkBegins;
if (deltatime <= ms.doubleClickDelay) {
ms.rightButtonDoubleClick = true;
}

View File

@ -6,7 +6,6 @@
import { RenderNode } from './RenderNode.js';
import { Program } from '../webgl/Program.js';
import { types } from '../webgl/types.js';
class Axes extends RenderNode {
constructor(size) {
@ -29,20 +28,20 @@ class Axes extends RenderNode {
aVertexColor: 'vec4'
},
vertexShader:
'attribute vec3 aVertexPosition;\
attribute vec4 aVertexColor;\
uniform mat4 projectionViewMatrix;\
varying vec4 vColor;\
void main(void) {\
gl_Position = projectionViewMatrix * vec4(aVertexPosition, 1.0);\
vColor = aVertexColor;\
}',
`attribute vec3 aVertexPosition;
attribute vec4 aVertexColor;
uniform mat4 projectionViewMatrix;
varying vec4 vColor;
void main(void) {
gl_Position = projectionViewMatrix * vec4(aVertexPosition, 1.0);
vColor = aVertexColor;
}`,
fragmentShader:
'precision highp float;\
varying vec4 vColor;\
void main(void) {\
gl_FragColor = vColor;\
}'
`precision highp float;
varying vec4 vColor;
void main(void) {
gl_FragColor = vColor;
}`
}));
}

View File

@ -57,7 +57,6 @@ class BaseNode {
this.__counter__ = n;
}
/**
* Adds node to the current hierarchy.
* @public
@ -66,8 +65,7 @@ class BaseNode {
addNode(node) {
if (this.parentNode == null) {
node.topNode = this;
}
else {
} else {
node.topNode = this.topNode;
}
node.parentNode = this;

View File

@ -10,8 +10,6 @@ import * as math from '../math.js';
import * as mercator from '../mercator.js';
import * as segmentHelper from '../segment/segmentHelper.js';
import * as quadTree from '../quadTree/quadTree.js';
import { MAX_RENDERED_NODES } from '../quadTree/quadTree.js';
import { EPSG3857 } from '../proj/EPSG3857.js';
import { EPSG4326 } from '../proj/EPSG4326.js';
import { Extent } from '../Extent.js';
import { Framebuffer } from '../webgl/Framebuffer.js';
@ -32,12 +30,9 @@ import { PlainSegmentWorker } from '../segment/PlainSegmentWorker.js';
import { TerrainWorker } from '../utils/TerrainWorker.js';
import { VectorTileCreator } from '../utils/VectorTileCreator.js';
import { wgs84 } from '../ellipsoid/wgs84.js';
import { print2d } from '../utils/shared.js';
import { NIGHT } from '../res/night.js';
import { SPECULAR } from '../res/spec.js';
import { Plane } from '../math/Plane.js';
import { Geoid } from '../terrain/Geoid.js';
import { doubleToTwoFloats } from '../math/coder.js';
const MAX_LOD = 1.0;
const MIN_LOD = 0.95;
@ -50,8 +45,6 @@ const MIN_LOD = 0.95;
*/
const MAX_NODES = 500;
const GLOBAL_DRAW_PRIORITY = -math.MAX;
const EVENT_NAMES = [
/**
* Triggered before globe frame begins to render.
@ -357,7 +350,6 @@ class Planet extends RenderNode {
this._maxLodRatio = MAX_LOD;
this._minLodRatio = MIN_LOD;
this._diffuseMaterialArr = new Float32Array(this.SLICE_SIZE_3 + 3);
this._ambientMaterialArr = new Float32Array(this.SLICE_SIZE_3 + 3);
this._specularMaterialArr = new Float32Array(this.SLICE_SIZE_4 + 4);
@ -388,7 +380,6 @@ class Planet extends RenderNode {
this._memKey = new Key();
//events initialization
this.events.registerNames(EVENT_NAMES);
this._tempPickingPix_ = new Uint8Array(4);
@ -409,8 +400,9 @@ class Planet extends RenderNode {
setRatioLod(maxLod, minLod) {
this._maxLodRatio = maxLod;
if (minLod)
if (minLod) {
this._minLodRatio = minLod;
}
}
/**
@ -432,8 +424,9 @@ class Planet extends RenderNode {
getLayerByName(name) {
var i = this.layers.length;
while (i--) {
if (this.layers[i].name === name)
if (this.layers[i].name === name) {
return this.layers[i];
}
}
}
@ -548,7 +541,7 @@ class Planet extends RenderNode {
setTerrain(terrain) {
//
//TODO: Replace to terrain
// TODO: Replace to terrain
//
this.terrain = terrain;
@ -583,8 +576,8 @@ class Planet extends RenderNode {
this.renderer.addPickingCallback(this, this._renderColorPickingFramebufferPASS);
this._heightPickingFramebuffer = new Framebuffer(this.renderer.handler, {
'width': 320,
'height': 240
width: 320,
height: 240
});
this._heightPickingFramebuffer.init();
@ -595,10 +588,10 @@ class Planet extends RenderNode {
* @public
*/
init() {
//Initialization indexes table
// Initialization indexes table
var TABLESIZE = segmentHelper.TABLESIZE;
//Iniytialize indexes buffers cache. It takes ~120mb RAM!
// Initialization indexes buffers cache. It takes about 120mb RAM!
for (var i = 0; i <= TABLESIZE; i++) {
var c = Math.pow(2, i);
!this._indexesCache[c] && (this._indexesCache[c] = []);
@ -623,8 +616,8 @@ class Planet extends RenderNode {
}
this._indexesCache[c][w][n][e][s] = {
'indexes': indexes,
'buffer': buffer
indexes: indexes,
buffer: buffer
};
}
}
@ -632,7 +625,7 @@ class Planet extends RenderNode {
}
}
//create empty textures
// creating empty textures
var that = this;
this.renderer.handler.createDefaultTexture(null, function (t) {
that.solidTextureOne = t;
@ -649,14 +642,14 @@ class Planet extends RenderNode {
this.camera.update();
//Creating quad trees nodes
// Creating quad trees nodes
this._quadTree = new Node(Segment, this, quadTree.NW, null, 0, 0, Extent.createFromArray([-20037508.34, -20037508.34, 20037508.34, 20037508.34]));
this._quadTreeNorth = new Node(SegmentLonLat, this, quadTree.NW, null, 0, 0, Extent.createFromArray([-180, mercator.MAX_LAT, 180, 90]));
this._quadTreeSouth = new Node(SegmentLonLat, this, quadTree.NW, null, 0, 0, Extent.createFromArray([-180, -90, 180, mercator.MIN_LAT]));
this.drawMode = this.renderer.handler.gl.TRIANGLE_STRIP;
//Applying shaders
// Applying shaders
this._initializeShaders();
this.updateVisibleLayers();
@ -675,15 +668,17 @@ class Planet extends RenderNode {
this.renderer.addPickingCallback(this, this._frustumEntityCollectionPickingCallback);
//load Earth night glowing texture
// loading Earth night glowing texture
if (this._useNightTexture) {
// eslint-disable-next-line no-undef
createImageBitmap(NIGHT).then((e) =>
this._nightTexture = this.renderer.handler.createTexture_mm(e)
);
}
//load water specular mask
// load water specular mask
if (this._useSpecularTexture) {
// eslint-disable-next-line no-undef
createImageBitmap(SPECULAR).then((e) =>
this._specularTexture = this.renderer.handler.createTexture_l(e)
);
@ -699,7 +694,7 @@ class Planet extends RenderNode {
this.renderer.events.on("draw", this._globalPreDraw, this, -100);
//Loads first nodes for better viewing if you have started on a lower altitude.
// Loading first nodes for better viewing if you have started on a lower altitude.
this._preRender();
}
@ -866,8 +861,7 @@ class Planet extends RenderNode {
_collectRenderNodes() {
this._lodRatio = math.lerp(
this.camera.slope < 0.0 ? 0.0 :
this.camera.slope,
this.camera.slope < 0.0 ? 0.0 : this.camera.slope,
this._maxLodRatio, this._minLodRatio
);
@ -875,7 +869,7 @@ class Planet extends RenderNode {
this._nodeCounterError_ = 0;
//clear first
// clear first
this._renderedNodes.length = 0;
this._renderedNodes = [];
@ -892,7 +886,7 @@ class Planet extends RenderNode {
this._quadTreeSouth.renderTree(this.camera, 0, null);
this._quadTree.renderTree(this.camera, 0, null);
//TODO:Abolish "magic" numbers
// TODO:Abolish "magic" numbers
if (this.renderer.activeCamera.slope > 0.8 &&
this.renderer.activeCamera._lonLat.height < 850000.0 &&
this.renderer.activeCamera._lonLat.height > 10000.0) {
@ -917,8 +911,6 @@ class Planet extends RenderNode {
}
}
}
//this._renderedNodes.push(this.camera._insideSegment.node);
}
_globalPreDraw() {
@ -935,15 +927,15 @@ class Planet extends RenderNode {
*/
frame() {
//free memory
// free memory
if (this._createdNodesCount > MAX_NODES && this._distBeforeMemClear > 10000.0) {
this.memClear();
}
this._collectRenderNodes();
//Here is the planet node dispatches a draw event before
//rendering begins and we have got render nodes.
// Here is the planet node dispatches a draw event before
// rendering begins and we have got render nodes.
this.events.dispatch(this.events.draw, this);
this.transformLights();
@ -952,7 +944,7 @@ class Planet extends RenderNode {
this._singleframebufferRendering();
//Creates geoImages textures.
// Creating geoImages textures.
this._geoImageCreator.frame();
}
@ -992,12 +984,12 @@ class Planet extends RenderNode {
gl.uniformMatrix4fv(shu.viewMatrix, false, renderer.activeCamera._viewMatrix._m);
gl.uniformMatrix4fv(shu.projectionMatrix, false, renderer.activeCamera._projectionMatrix._m);
//bind night glowing material
// bind night glowing material
gl.activeTexture(gl.TEXTURE0 + this.SLICE_SIZE);
gl.bindTexture(gl.TEXTURE_2D, (this.camera._lonLat.height > 329958.0) && (this._nightTexture || this.transparentTexture) || this.transparentTexture);
gl.bindTexture(gl.TEXTURE_2D, ((this.camera._lonLat.height > 329958.0) && (this._nightTexture || this.transparentTexture)) || this.transparentTexture);
gl.uniform1i(shu.nightTexture, this.SLICE_SIZE);
//bind specular material
// bind specular material
gl.activeTexture(gl.TEXTURE0 + this.SLICE_SIZE + 1);
gl.bindTexture(gl.TEXTURE_2D, this._specularTexture || this.transparentTexture);
gl.uniform1i(shu.specularTexture, this.SLICE_SIZE + 1);
@ -1041,7 +1033,7 @@ class Planet extends RenderNode {
gl.uniform3fv(shu.eyePositionHigh, cam.eyeHigh);
gl.uniform3fv(shu.eyePositionLow, cam.eyeLow);
//draw planet's nodes
// drawing planet nodes
var rn = this._renderedNodes,
sl = this._visibleTileLayerSlices;
@ -1056,9 +1048,9 @@ class Planet extends RenderNode {
}
i = rn.length;
while (i--) {
while (i--) {
let s = rn[i].segment;
//s.equalize();
// TODO: s.equalize();
s.readyToEngage && s.engage();
s.screenRendering(sh, sl[0], 0);
}
@ -1115,7 +1107,7 @@ class Planet extends RenderNode {
gl.uniform3fv(shu.eyePositionHigh, cam.eyeHigh);
gl.uniform3fv(shu.eyePositionLow, cam.eyeLow);
//draw planet's nodes
// drawing planet nodes
var rn = this._renderedNodes,
sl = this._visibleTileLayerSlices;
@ -1163,7 +1155,7 @@ class Planet extends RenderNode {
gl.uniform3fv(shu.eyePositionHigh, cam.eyeHigh);
gl.uniform3fv(shu.eyePositionLow, cam.eyeLow);
//draw planet's nodes
// drawing planet nodes
var rn = this._renderedNodes,
sl = this._visibleTileLayerSlices;
@ -1207,10 +1199,10 @@ class Planet extends RenderNode {
vi.update();
}
//3d entities(billnoards, labesl, shapes etc.) rendering
// Entities(billnoards, labesl, shapes etc.) rendering
this.drawEntityCollections(this._frustumEntityCollections);
//Vector tiles rasteriazation
// Vector tiles rasteriazation
this._vectorTileCreator.frame();
}
@ -1229,7 +1221,6 @@ class Planet extends RenderNode {
memClear() {
this._distBeforeMemClear = 0;
//??? private ???
this.camera._insideSegment = null;
this.layerLock.lock(this._memKey);
@ -1241,7 +1232,7 @@ class Planet extends RenderNode {
this._tileLoader.abort();
var that = this;
//setTimeout(function () {
// setTimeout(function () {
that._quadTree.clearTree();
that._quadTreeNorth.clearTree();
that._quadTreeSouth.clearTree();
@ -1249,7 +1240,7 @@ class Planet extends RenderNode {
that.layerLock.free(that._memKey);
that.terrainLock.free(that._memKey);
that._normalMapCreator.free(that._memKey);
//}, 0);
// }, 0);
this._createdNodesCount = 0;
}
@ -1357,8 +1348,9 @@ class Planet extends RenderNode {
*/
getPixelFromLonLat(lonlat) {
var coords = this.ellipsoid.lonLatToCartesian(lonlat);
if (coords)
if (coords) {
return this.renderer.activeCamera.project(coords);
}
return null;
}

View File

@ -251,8 +251,9 @@ class RenderNode extends BaseNode {
*/
_drawNodes() {
for (var i = 0; i < this.childNodes.length; i++) {
if (this.childNodes[i]._isActive)
if (this.childNodes[i]._isActive) {
this.childNodes[i]._drawNodes();
}
}
if (this.show) {
@ -280,24 +281,24 @@ class RenderNode extends BaseNode {
gl.disable(gl.CULL_FACE);
//Z-buffer offset
// Z-buffer offset
gl.enable(gl.POLYGON_OFFSET_FILL);
gl.polygonOffset(0.0, 0.0);
//billoard pass
// billoard pass
var i = ec.length;
while (i--) {
ec[i]._fadingOpacity && ec[i].billboardHandler.drawPicking();
}
//label pass
// label pass
i = ec.length;
while (i--) {
ec[i]._fadingOpacity && ec[i].labelHandler.drawPicking();
}
//ray pass
var i = ec.length;
// ray pass
i = ec.length;
while (i--) {
ec[i]._fadingOpacity && ec[i].rayHandler.drawPicking();
}
@ -307,29 +308,29 @@ class RenderNode extends BaseNode {
gl.disable(gl.POLYGON_OFFSET_FILL);
gl.enable(gl.CULL_FACE);
//polylines pass
// polylines pass
i = ec.length;
while (i--) {
ec[i]._visibility && ec[i].polylineHandler.drawPicking();
}
////shapes pass
//i = ec.length;
//while (i--) {
// //shapes pass
// i = ec.length;
// while (i--) {
// ec[i]._visibility && ec[i].shapeHandler.drawPicking();
//}
// }
////pointClouds pass
//i = ec.length;
//while (i--) {
// //pointClouds pass
// i = ec.length;
// while (i--) {
// ec[i]._visibility && ec[i].pointCloudHandler.drawPicking();
//}
// }
////Strip pass
//i = ec.length;
//while (i--) {
// //Strip pass
// i = ec.length;
// while (i--) {
// ec[i]._visibility && ec[i].stripHandler.drawPicking();
//}
// }
}
}

View File

@ -7,8 +7,6 @@
import * as shaders from '../Program/skybox.js';
import { RenderNode } from './RenderNode.js';
const RESOURCES_URL = "";
class SkyBox extends RenderNode {
constructor(params) {
super("skybox");
@ -19,12 +17,12 @@ class SkyBox extends RenderNode {
static createDefault(RESOURCES_URL) {
return new SkyBox({
"nx": RESOURCES_URL + "skybox/gal/_nx.jpg",
"px": RESOURCES_URL + "skybox/gal/_px.jpg",
"py": RESOURCES_URL + "skybox/gal/_py.jpg",
"ny": RESOURCES_URL + "skybox/gal/_ny.jpg",
"pz": RESOURCES_URL + "skybox/gal/_pz.jpg",
"nz": RESOURCES_URL + "skybox/gal/_nz.jpg"
nx: RESOURCES_URL + "skybox/gal/_nx.jpg",
px: RESOURCES_URL + "skybox/gal/_px.jpg",
py: RESOURCES_URL + "skybox/gal/_py.jpg",
ny: RESOURCES_URL + "skybox/gal/_ny.jpg",
pz: RESOURCES_URL + "skybox/gal/_pz.jpg",
nz: RESOURCES_URL + "skybox/gal/_nz.jpg"
});
}
@ -60,47 +58,47 @@ class SkyBox extends RenderNode {
_createBuffers() {
var vertices = new Float32Array([
- 10000.0, 10000.0, - 10000.0,
- 10000.0, - 10000.0, - 10000.0,
10000.0, - 10000.0, - 10000.0,
10000.0, - 10000.0, - 10000.0,
10000.0, 10000.0, - 10000.0,
- 10000.0, 10000.0, - 10000.0,
-10000.0, 10000.0, -10000.0,
-10000.0, -10000.0, -10000.0,
10000.0, -10000.0, -10000.0,
10000.0, -10000.0, -10000.0,
10000.0, 10000.0, -10000.0,
-10000.0, 10000.0, -10000.0,
- 10000.0, - 10000.0, 10000.0,
- 10000.0, - 10000.0, - 10000.0,
- 10000.0, 10000.0, - 10000.0,
- 10000.0, 10000.0, - 10000.0,
- 10000.0, 10000.0, 10000.0,
- 10000.0, - 10000.0, 10000.0,
-10000.0, -10000.0, 10000.0,
-10000.0, -10000.0, -10000.0,
-10000.0, 10000.0, -10000.0,
-10000.0, 10000.0, -10000.0,
-10000.0, 10000.0, 10000.0,
-10000.0, -10000.0, 10000.0,
10000.0, - 10000.0, - 10000.0,
10000.0, - 10000.0, 10000.0,
10000.0, -10000.0, -10000.0,
10000.0, -10000.0, 10000.0,
10000.0, 10000.0, 10000.0,
10000.0, 10000.0, 10000.0,
10000.0, 10000.0, - 10000.0,
10000.0, - 10000.0, - 10000.0,
10000.0, 10000.0, -10000.0,
10000.0, -10000.0, -10000.0,
- 10000.0, - 10000.0, 10000.0,
- 10000.0, 10000.0, 10000.0,
-10000.0, -10000.0, 10000.0,
-10000.0, 10000.0, 10000.0,
10000.0, 10000.0, 10000.0,
10000.0, 10000.0, 10000.0,
10000.0, - 10000.0, 10000.0,
- 10000.0, - 10000.0, 10000.0,
10000.0, -10000.0, 10000.0,
-10000.0, -10000.0, 10000.0,
- 10000.0, 10000.0, - 10000.0,
10000.0, 10000.0, - 10000.0,
-10000.0, 10000.0, -10000.0,
10000.0, 10000.0, -10000.0,
10000.0, 10000.0, 10000.0,
10000.0, 10000.0, 10000.0,
- 10000.0, 10000.0, 10000.0,
- 10000.0, 10000.0, - 10000.0,
-10000.0, 10000.0, 10000.0,
-10000.0, 10000.0, -10000.0,
- 10000.0, - 10000.0, - 10000.0,
- 10000.0, - 10000.0, 10000.0,
10000.0, - 10000.0, - 10000.0,
10000.0, - 10000.0, - 10000.0,
- 10000.0, - 10000.0, 10000.0,
10000.0, - 10000.0, 10000.0
-10000.0, -10000.0, -10000.0,
-10000.0, -10000.0, 10000.0,
10000.0, -10000.0, -10000.0,
10000.0, -10000.0, -10000.0,
-10000.0, -10000.0, 10000.0,
10000.0, -10000.0, 10000.0
]);
this.vertexPositionBuffer = this.renderer.handler.createArrayBuffer(vertices, 3, vertices.length / 3);

View File

@ -1,6 +1,6 @@
'use sctrict';
import { QueueArray } from '../QueueArray.js';
// import { QueueArray } from '../QueueArray.js';
import { EPSG4326 } from '../proj/EPSG4326.js';
class PlainSegmentWorker {
@ -43,13 +43,13 @@ class PlainSegmentWorker {
let m = geoid.model;
let model = {
'scale': m.scale,
'offset': m.offset,
'width': m.width,
'height': m.height,
'rlonres': m.rlonres,
'rlatres': m.rlatres,
'i': m.i
scale: m.scale,
offset: m.offset,
width: m.width,
height: m.height,
rlonres: m.rlonres,
rlatres: m.rlatres,
i: m.i
};
this._workerQueue.forEach((w) => {
@ -58,11 +58,11 @@ class PlainSegmentWorker {
rawfile.set(m.rawfile);
w.postMessage({
'model': model,
'rawfile': rawfile
model: model,
rawfile: rawfile
}, [
rawfile.buffer
]);
rawfile.buffer
]);
});
}
@ -93,10 +93,10 @@ class PlainSegmentWorker {
]);
w.postMessage({
'params': params
params: params
}, [
params.buffer
]);
params.buffer
]);
} else {
this._pendingQueue.push(segment);
@ -105,7 +105,7 @@ class PlainSegmentWorker {
this.check();
}
}
};
}
const _programm =
`

View File

@ -2,12 +2,7 @@
import * as math from '../math.js';
import * as mercator from '../mercator.js';
import {
NW, NE, SW, SE,
N, E, S, W,
OPSIDE, NOTRENDERING
} from '../quadTree/quadTree.js';
import { Box } from '../bv/Box.js';
import { N, E, S, W, OPSIDE, NOTRENDERING } from '../quadTree/quadTree.js';
import { EPSG3857 } from '../proj/EPSG3857.js';
import { Extent } from '../Extent.js';
import { Layer } from '../layer/Layer.js';
@ -16,12 +11,11 @@ import { textureCoordsTable } from './segmentHelper.js';
import { Ray } from '../math/Ray.js';
import { Sphere } from '../bv/Sphere.js';
import { Vec3 } from '../math/Vec3.js';
import { cons } from '../cons.js';
export const MAX_NORMAL_ZOOM = 7;
let _tempHigh = new Vec3(),
_tempLow = new Vec3();
var _tempHigh = new Vec3();
var _tempLow = new Vec3();
var _RenderingSlice = function (p) {
this.layers = [];
@ -69,12 +63,6 @@ const Segment = function (node, planet, tileZoom, extent) {
*/
this.handler = planet.renderer.handler;
///**
// * Segment bounding box.
// * @type {og.bv.Box}
// */
//this.bbox = new Box();
/**
* Segment bounding box.
* @type {og.bv.Sphere}
@ -128,7 +116,7 @@ const Segment = function (node, planet, tileZoom, extent) {
*/
this.tileY = 0;
this.tileIndex = "";
this.tileIndex = '';
this._assignTileIndexes();
@ -180,7 +168,7 @@ const Segment = function (node, planet, tileZoom, extent) {
*/
this.terrainExists = false;
//this.plainIndexes = null;
// this.plainIndexes = null;
this.plainVertices = null;
this.plainVerticesHigh = null;
this.plainVerticesLow = null;
@ -234,7 +222,6 @@ Segment.prototype.acceptForRendering = function (camera) {
return camera.projectedSize(this.bsphere.center, this.bsphere.radius) < 256 / this.planet._lodRatio;
};
/**
* Returns entity terrain point.
* @public
@ -261,8 +248,7 @@ Segment.prototype.isEntityInside = function (e) {
* @returns {number} -
*/
Segment.prototype.getTerrainPoint = function (xyz, insideSegmentPosition, res, normal) {
var verts = this.tempVertices,//this.terrainReady ? this.terrainVertices : this.tempVertices,
var verts = this.tempVertices, // this.terrainReady ? this.terrainVertices : this.tempVertices,
ray = new Ray(xyz, xyz.negateTo());
if (verts) {
@ -295,7 +281,7 @@ Segment.prototype.getTerrainPoint = function (xyz, insideSegmentPosition, res, n
var ind_v2 = ((size + 1) * (indY + 1) + indX) * 3;
//
//TODO: replace with temp variables
// TODO: replace with temp variables
var v0 = new Vec3(verts[ind_v0], verts[ind_v0 + 1], verts[ind_v0 + 2]),
v1 = new Vec3(verts[ind_v0 + 3], verts[ind_v0 + 4], verts[ind_v0 + 5]),
v2 = new Vec3(verts[ind_v2], verts[ind_v2 + 1], verts[ind_v2 + 2]);
@ -341,7 +327,6 @@ Segment.prototype.getTerrainPoint = function (xyz, insideSegmentPosition, res, n
}
};
/**
* Project wgs86 to segment native projection.
* @public
@ -389,7 +374,7 @@ Segment.prototype.elevationsExists = function (elevations) {
Segment.prototype.equalize = function () {
this.readyToEngage = true;
//TODO
// TODO
};
Segment.prototype.engage = function () {
@ -445,7 +430,6 @@ Segment.prototype._terrainWorkerCallback = function (data) {
this.tempVerticesHigh = null;
this.tempVerticesLow = null;
this.normalMapNormals = data.normalMapNormals;
this.normalMapNormalsRaw = data.normalMapNormalsRaw;
this.normalMapVertices = data.normalMapVertices;
@ -497,7 +481,7 @@ Segment.prototype.elevationsNotExists = function () {
this.terrainIsLoading = false;
this.node.appliedTerrainNodeId = this.node.nodeId;
//this.gridSize = this.planet.terrain.gridSizeByZoom[this.tileZoom];
// this.gridSize = this.planet.terrain.gridSizeByZoom[this.tileZoom];
if (this.planet.lightEnabled && !this._inTheQueue) {
this.planet._normalMapCreator.queue(this);
@ -562,13 +546,13 @@ Segment.prototype._normalMapEdgeEqualize = function (side) {
let seg_a_raw = s.normalMapNormalsRaw,
seg_b_raw = b.normalMapNormalsRaw;
let seg_a_verts = s.terrainVertices,
seg_b_verts = s.terrainVertices;
// let seg_a_verts = s.terrainVertices,
// seg_b_verts = s.terrainVertices;
let s_gs = Math.sqrt(seg_a.length / 3),
b_gs = Math.sqrt(seg_b.length / 3),
s_gs1 = s_gs - 1,
b_gs1 = b_gs - 1;
// b_gs = Math.sqrt(seg_b.length / 3),
s_gs1 = s_gs - 1;
// b_gs1 = b_gs - 1;
const i_a = s_gs1 * _S[side];
@ -576,7 +560,7 @@ Segment.prototype._normalMapEdgeEqualize = function (side) {
if (s.tileZoom === b.tileZoom) {
let i_b = s_gs1 - i_a;
const i_b = s_gs1 - i_a;
if (_V[side]) {
for (let k = 0; k < s_gs; k++) {
@ -621,7 +605,6 @@ Segment.prototype._normalMapEdgeEqualize = function (side) {
}
};
Segment.prototype.applyTerrain = function (elevations) {
if (elevations) {
this.elevationsExists(elevations);
@ -748,7 +731,7 @@ Segment.prototype.destroySegment = function () {
this.materials = null;
//this.plainIndexes = null;
// this.plainIndexes = null;
this.plainVertices = null;
this.plainVerticesHigh = null;
this.plainVerticesLow = null;
@ -799,7 +782,7 @@ Segment.prototype.createBoundsByExtent = function () {
var coord_sw = ellipsoid.geodeticToCartesian(extent.southWest.lon, extent.southWest.lat);
var coord_ne = ellipsoid.geodeticToCartesian(extent.northEast.lon, extent.northEast.lat);
//check for zoom
// check for zoom
if (this.tileZoom < MAX_NORMAL_ZOOM) {
var coord_nw = ellipsoid.geodeticToCartesian(extent.southWest.lon, extent.northEast.lat);
@ -858,7 +841,6 @@ Segment.prototype.createTerrainFromChildNodes = function () {
let hgsOne = 0.5 * gs + 0.5;
this.terrainVertices = new Float64Array(sgs3);
this.terrainVerticesHigh = new Float32Array(sgs3);
this.terrainVerticesLow = new Float32Array(sgs3);
@ -870,7 +852,6 @@ Segment.prototype.createTerrainFromChildNodes = function () {
this.normalMapNormals = new Float32Array(gs3);
this.normalMapNormalsRaw = new Float32Array(gs3);
let verts = this.terrainVertices,
vertsHigh = this.terrainVerticesHigh,
vertsLow = this.terrainVerticesLow,
@ -960,7 +941,6 @@ Segment.prototype.createTerrainFromChildNodes = function () {
new Vec3(xmin, ymin, zmin)
);
this.appliedTerrainNodeId = this.nodeId;
this.terrainReady = true;
this.terrainExists = true;
@ -1074,7 +1054,6 @@ Segment.prototype._assignGlobalTextureCoordinates = function () {
this._globalTextureCoordinates[3] = (mercator.POLE - e.southWest.lat) * mercator.ONE_BY_POLE_DOUBLE;
};
Segment.prototype.createPlainSegmentAsync = function () {
let p = this.planet,
@ -1179,7 +1158,7 @@ Segment.prototype._createPlainVertices = function () {
this.terrainVerticesHigh = vertsHigh;
this.terrainVerticesLow = vertsLow;
//store raw normals
// store raw normals
this.normalMapNormalsRaw = new Float32Array(nmNorms.length);
this.normalMapNormalsRaw.set(nmNorms);
@ -1224,7 +1203,7 @@ Segment.prototype.screenRendering = function (sh, layerSlice, sliceIndex, defaul
currHeight = 0;
}
//First always draw whole planet base layer segment with solid texture.
// First always draw whole planet base layer segment with solid texture.
gl.activeTexture(gl.TEXTURE0 + p.SLICE_SIZE + 2);
gl.bindTexture(gl.TEXTURE_2D, defaultTexture || this.getDefaultTexture());
gl.uniform1i(shu.defaultTexture, p.SLICE_SIZE + 2);
@ -1245,9 +1224,9 @@ Segment.prototype.screenRendering = function (sh, layerSlice, sliceIndex, defaul
this._indexBuffer = this._getIndexBuffer();
while (li) {
if (this.layerOverlap(li) &&
(li._fading && li._fadingOpacity > 0.0 ||
li.minZoom <= p.minCurrZoom && li.maxZoom >= p.maxCurrZoom)) {
if (this.layerOverlap(li) && ((li._fading && (li._fadingOpacity > 0.0)) ||
((li.minZoom >= p.minCurrZoom || li.maxZoom >= p.minCurrZoom) && (li.minZoom <= p.maxCurrZoom || li.maxZoom <= p.maxCurrZoom)))
) {
notEmpty = true;
var m = pm[li._id];
@ -1310,7 +1289,7 @@ Segment.prototype.screenRendering = function (sh, layerSlice, sliceIndex, defaul
gl.uniform4fv(shu.visibleExtentOffsetArr, slice.visibleExtentOffsetArr);
gl.uniform4fv(shu.transparentColorArr, slice.transparentColorArr);
//bind normalmap texture
// bind normalmap texture
if (p.lightEnabled) {
gl.activeTexture(gl.TEXTURE0 + p.SLICE_SIZE + 3);
gl.bindTexture(gl.TEXTURE_2D, this.normalMapTexture || p.transparentTexture);
@ -1318,7 +1297,7 @@ Segment.prototype.screenRendering = function (sh, layerSlice, sliceIndex, defaul
gl.uniform3fv(shu.uNormalMapBias, this.normalMapTextureBias);
//bind segment specular and night material texture coordinates
// bind segment specular and night material texture coordinates
gl.uniform4fv(shu.uGlobalTextureCoord, this._globalTextureCoordinates);
gl.uniform3fv(shu.diffuseMaterial, p._diffuseMaterialArr);
@ -1413,7 +1392,7 @@ Segment.prototype.heightPickingRendering = function (sh, layerSlice, sliceIndex,
var pm = this.materials,
p = this.planet;
//First always draw whole planet base layer segment with solid texture.
// First always draw whole planet base layer segment with solid texture.
gl.activeTexture(gl.TEXTURE0 + p.SLICE_SIZE);
gl.bindTexture(gl.TEXTURE_2D, defaultTexture || p.solidTextureOne);
gl.uniform1i(shu.defaultTexture, p.SLICE_SIZE);
@ -1495,7 +1474,7 @@ Segment.prototype.getExtent = function () {
Segment.prototype.getNodeState = function () {
var vn = this.planet._visibleNodes[this.node.nodeId];
return vn && vn.state || NOTRENDERING;
return (vn && vn.state) || NOTRENDERING;
};
Segment.prototype.getNeighborSide = function (b) {
@ -1518,4 +1497,4 @@ Segment.prototype.getNeighborSide = function (b) {
return -1;
};
export { Segment };
export { Segment };

View File

@ -1,6 +1,5 @@
'use sctrict';
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';
@ -11,7 +10,6 @@ import { LonLat } from '../LonLat.js';
import { Segment } from './Segment.js';
import { Vec3 } from '../math/Vec3.js';
const _heightLat = 90.0 - mercator.MAX_LAT;
const _maxPoleZoom = 7;
const _pieceSize = _heightLat / Math.pow(2, _maxPoleZoom);
@ -186,7 +184,6 @@ SegmentLonLat.prototype._createPlainVertices = function () {
this.plainReady = true;
};
SegmentLonLat.prototype._assignGlobalTextureCoordinates = function () {
var e = this._extent;
this._globalTextureCoordinates[0] = (e.southWest.lon + 180.0) / 360.0;
@ -242,7 +239,7 @@ SegmentLonLat.prototype.getNodeState = function () {
} else {
vn = this.planet._visibleNodesSouth[this.node.nodeId];
}
return vn && vn.state || quadTree.NOTRENDERING;
return (vn && vn.state) || quadTree.NOTRENDERING;
};
SegmentLonLat.prototype._freeCache = function () {

View File

@ -5,7 +5,6 @@
'use sctrict';
import { Program } from '../webgl/Program.js';
import { types } from '../webgl/types.js';
export function billboardPicking() {
return new Program("billboardPicking", {

Some files were not shown because too many files have changed in this diff Show More