- npm updates

- projecting images to TinLayer.ts
- three.js version 0.128.0
This commit is contained in:
Arno Kaimbacher 2021-04-26 13:05:13 +02:00
parent 063dfc2609
commit d679f0350a
8 changed files with 276 additions and 40477 deletions

1
.gitignore vendored
View File

@ -31,3 +31,4 @@ desktop.ini
/notes.txt /notes.txt
/.env /.env
debug.log debug.log
/noteDemLayer.txt

130
package-lock.json generated
View File

@ -15,7 +15,7 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"proj4": "^2.6.3", "proj4": "^2.6.3",
"three": "^0.127.0" "three": "^0.128.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.9", "@babel/core": "^7.12.9",
@ -1669,9 +1669,9 @@
"dev": true "dev": true
}, },
"node_modules/acorn": { "node_modules/acorn": {
"version": "8.1.1", "version": "8.2.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.1.1.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.2.1.tgz",
"integrity": "sha512-xYiIVjNuqtKXMxlRMDc6mZUhXehod4a3gbZ1qRlM7icK4EbxUFNLhWoPblCvFtB2Y9CIqHP3CF/rdxLItaQv8g==", "integrity": "sha512-z716cpm5TX4uzOzILx8PavOE6C6DKshHDw1aQN52M/yNSqE9s5O8SMfyhCCfCJ3HmTL0NkVOi+8a/55T7YB3bg==",
"dev": true, "dev": true,
"bin": { "bin": {
"acorn": "bin/acorn" "acorn": "bin/acorn"
@ -1987,14 +1987,14 @@
} }
}, },
"node_modules/browserslist": { "node_modules/browserslist": {
"version": "4.16.4", "version": "4.16.5",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.4.tgz", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.5.tgz",
"integrity": "sha512-d7rCxYV8I9kj41RH8UKYnvDYCRENUlHRgyXy/Rhr/1BaeLGfiCptEdFE8MIrvGfWbBFNjVYx76SQWvNX1j+/cQ==", "integrity": "sha512-C2HAjrM1AI/djrpAUU/tr4pml1DqLIzJKSLDBXBrNErl9ZCCTXdhwxdJjYc16953+mBWf7Lw+uUJgpgb8cN71A==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"caniuse-lite": "^1.0.30001208", "caniuse-lite": "^1.0.30001214",
"colorette": "^1.2.2", "colorette": "^1.2.2",
"electron-to-chromium": "^1.3.712", "electron-to-chromium": "^1.3.719",
"escalade": "^3.1.1", "escalade": "^3.1.1",
"node-releases": "^1.1.71" "node-releases": "^1.1.71"
}, },
@ -2068,9 +2068,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001214", "version": "1.0.30001216",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001214.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001216.tgz",
"integrity": "sha512-O2/SCpuaU3eASWVaesQirZv1MSjUNOvmugaD8zNSJqw6Vv5SGwoOpA9LJs3pNPfM745nxqPvfZY3MQKY4AKHYg==", "integrity": "sha512-1uU+ww/n5WCJRwUcc9UH/W6925Se5aNnem/G5QaSDga2HzvjYMs8vRbekGUN/PnTZ7ezTHcxxTEb9fgiMYwH6Q==",
"dev": true "dev": true
}, },
"node_modules/caseless": { "node_modules/caseless": {
@ -2288,9 +2288,9 @@
} }
}, },
"node_modules/concurrently/node_modules/chalk": { "node_modules/concurrently/node_modules/chalk": {
"version": "4.1.0", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz",
"integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"ansi-styles": "^4.1.0", "ansi-styles": "^4.1.0",
@ -2373,9 +2373,9 @@
} }
}, },
"node_modules/core-js-compat": { "node_modules/core-js-compat": {
"version": "3.10.2", "version": "3.11.0",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.10.2.tgz", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.11.0.tgz",
"integrity": "sha512-IGHnpuaM1N++gLSPI1F1wu3WXICPxSyj/Q++clcwsIOnUVp5uKUIPl/+6h0TQ112KU3fMiSxqJuM+OrCyKj5+A==", "integrity": "sha512-3wsN9YZJohOSDCjVB0GequOyHax8zFiogSX3XWLE28M1Ew7dTU57tgHjIylSBKSIouwmLBp3g61sKMz/q3xEGA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"browserslist": "^4.16.4", "browserslist": "^4.16.4",
@ -2666,9 +2666,9 @@
} }
}, },
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.3.718", "version": "1.3.720",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.718.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.720.tgz",
"integrity": "sha512-CikzdUSShGXwjq1pcW740wK8j+KbazgHZiwzlHICejDaczM6OVsPcrZmBHPwzj9i2rj5twg20MBwp+cYZwldYA==", "integrity": "sha512-B6zLTxxaOFP4WZm6DrvgRk8kLFYWNhQ5TrHMC0l5WtkMXhU5UbnvWoTfeEwqOruUSlNMhVLfYak7REX6oC5Yfw==",
"dev": true "dev": true
}, },
"node_modules/emoji-regex": { "node_modules/emoji-regex": {
@ -3504,9 +3504,9 @@
"dev": true "dev": true
}, },
"node_modules/is-core-module": { "node_modules/is-core-module": {
"version": "2.2.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.3.0.tgz",
"integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==", "integrity": "sha512-xSphU2KG9867tsYdLD4RWQ1VqdFl4HTO9Thf3I/3dLEfr0dbPTWKsuCKrgqMljg4nPE+Gq0VCnzT3gr0CyBmsw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"has": "^1.0.3" "has": "^1.0.3"
@ -4581,9 +4581,9 @@
} }
}, },
"node_modules/postcss": { "node_modules/postcss": {
"version": "8.2.10", "version": "8.2.12",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.10.tgz", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.12.tgz",
"integrity": "sha512-b/h7CPV7QEdrqIxtAf2j31U5ef05uBDuvoXv6L51Q4rcS1jdlXAVKJv+atCFdUXYl9dyTHGyoMzIepwowRJjFw==", "integrity": "sha512-BJnGT5+0q2tzvs6oQfnY2NpEJ7rIXNfBnZtQOKCIsweeWXBXeDd5k31UgTdS3d/c02ouspufn37mTaHWkJyzMQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"colorette": "^1.2.2", "colorette": "^1.2.2",
@ -5973,9 +5973,9 @@
} }
}, },
"node_modules/three": { "node_modules/three": {
"version": "0.127.0", "version": "0.128.0",
"resolved": "https://registry.npmjs.org/three/-/three-0.127.0.tgz", "resolved": "https://registry.npmjs.org/three/-/three-0.128.0.tgz",
"integrity": "sha512-wtgrn+mhYUbobxT7QN3GPdu3SRpSBQvwY6uOzLChWS7QE//f7paDU/+wlzbg+ngeIvBBqjBHSRuywTh8A99Jng==" "integrity": "sha512-i0ap/E+OaSfzw7bD1TtYnPo3VEplkl70WX5fZqZnfZsE3k3aSFudqrrC9ldFZfYFkn1zwDmBcdGfiIm/hnbyZA=="
}, },
"node_modules/to-fast-properties": { "node_modules/to-fast-properties": {
"version": "2.0.0", "version": "2.0.0",
@ -6252,9 +6252,9 @@
} }
}, },
"node_modules/webpack": { "node_modules/webpack": {
"version": "5.35.0", "version": "5.35.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.35.0.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.35.1.tgz",
"integrity": "sha512-au3gu55yYF/h6NXFr0KZPZAYxS6Nlc595BzYPke8n0CSff5WXcoixtjh5LC/8mXunkRKxhymhXmBY0+kEbR6jg==", "integrity": "sha512-uWKYStqJ23+N6/EnMEwUjPSSKUG1tFmcuKhALEh/QXoUxwN8eb3ATNIZB38A+fO6QZ0xfc7Cu7KNV9LXNhDCsw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@types/eslint-scope": "^3.7.0", "@types/eslint-scope": "^3.7.0",
@ -8035,9 +8035,9 @@
"dev": true "dev": true
}, },
"acorn": { "acorn": {
"version": "8.1.1", "version": "8.2.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.1.1.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.2.1.tgz",
"integrity": "sha512-xYiIVjNuqtKXMxlRMDc6mZUhXehod4a3gbZ1qRlM7icK4EbxUFNLhWoPblCvFtB2Y9CIqHP3CF/rdxLItaQv8g==", "integrity": "sha512-z716cpm5TX4uzOzILx8PavOE6C6DKshHDw1aQN52M/yNSqE9s5O8SMfyhCCfCJ3HmTL0NkVOi+8a/55T7YB3bg==",
"dev": true "dev": true
}, },
"adjust-sourcemap-loader": { "adjust-sourcemap-loader": {
@ -8282,14 +8282,14 @@
} }
}, },
"browserslist": { "browserslist": {
"version": "4.16.4", "version": "4.16.5",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.4.tgz", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.5.tgz",
"integrity": "sha512-d7rCxYV8I9kj41RH8UKYnvDYCRENUlHRgyXy/Rhr/1BaeLGfiCptEdFE8MIrvGfWbBFNjVYx76SQWvNX1j+/cQ==", "integrity": "sha512-C2HAjrM1AI/djrpAUU/tr4pml1DqLIzJKSLDBXBrNErl9ZCCTXdhwxdJjYc16953+mBWf7Lw+uUJgpgb8cN71A==",
"dev": true, "dev": true,
"requires": { "requires": {
"caniuse-lite": "^1.0.30001208", "caniuse-lite": "^1.0.30001214",
"colorette": "^1.2.2", "colorette": "^1.2.2",
"electron-to-chromium": "^1.3.712", "electron-to-chromium": "^1.3.719",
"escalade": "^3.1.1", "escalade": "^3.1.1",
"node-releases": "^1.1.71" "node-releases": "^1.1.71"
} }
@ -8340,9 +8340,9 @@
} }
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30001214", "version": "1.0.30001216",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001214.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001216.tgz",
"integrity": "sha512-O2/SCpuaU3eASWVaesQirZv1MSjUNOvmugaD8zNSJqw6Vv5SGwoOpA9LJs3pNPfM745nxqPvfZY3MQKY4AKHYg==", "integrity": "sha512-1uU+ww/n5WCJRwUcc9UH/W6925Se5aNnem/G5QaSDga2HzvjYMs8vRbekGUN/PnTZ7ezTHcxxTEb9fgiMYwH6Q==",
"dev": true "dev": true
}, },
"caseless": { "caseless": {
@ -8520,9 +8520,9 @@
} }
}, },
"chalk": { "chalk": {
"version": "4.1.0", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz",
"integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==",
"dev": true, "dev": true,
"requires": { "requires": {
"ansi-styles": "^4.1.0", "ansi-styles": "^4.1.0",
@ -8588,9 +8588,9 @@
} }
}, },
"core-js-compat": { "core-js-compat": {
"version": "3.10.2", "version": "3.11.0",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.10.2.tgz", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.11.0.tgz",
"integrity": "sha512-IGHnpuaM1N++gLSPI1F1wu3WXICPxSyj/Q++clcwsIOnUVp5uKUIPl/+6h0TQ112KU3fMiSxqJuM+OrCyKj5+A==", "integrity": "sha512-3wsN9YZJohOSDCjVB0GequOyHax8zFiogSX3XWLE28M1Ew7dTU57tgHjIylSBKSIouwmLBp3g61sKMz/q3xEGA==",
"dev": true, "dev": true,
"requires": { "requires": {
"browserslist": "^4.16.4", "browserslist": "^4.16.4",
@ -8803,9 +8803,9 @@
} }
}, },
"electron-to-chromium": { "electron-to-chromium": {
"version": "1.3.718", "version": "1.3.720",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.718.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.720.tgz",
"integrity": "sha512-CikzdUSShGXwjq1pcW740wK8j+KbazgHZiwzlHICejDaczM6OVsPcrZmBHPwzj9i2rj5twg20MBwp+cYZwldYA==", "integrity": "sha512-B6zLTxxaOFP4WZm6DrvgRk8kLFYWNhQ5TrHMC0l5WtkMXhU5UbnvWoTfeEwqOruUSlNMhVLfYak7REX6oC5Yfw==",
"dev": true "dev": true
}, },
"emoji-regex": { "emoji-regex": {
@ -9455,9 +9455,9 @@
"dev": true "dev": true
}, },
"is-core-module": { "is-core-module": {
"version": "2.2.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.3.0.tgz",
"integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==", "integrity": "sha512-xSphU2KG9867tsYdLD4RWQ1VqdFl4HTO9Thf3I/3dLEfr0dbPTWKsuCKrgqMljg4nPE+Gq0VCnzT3gr0CyBmsw==",
"dev": true, "dev": true,
"requires": { "requires": {
"has": "^1.0.3" "has": "^1.0.3"
@ -10276,9 +10276,9 @@
} }
}, },
"postcss": { "postcss": {
"version": "8.2.10", "version": "8.2.12",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.10.tgz", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.12.tgz",
"integrity": "sha512-b/h7CPV7QEdrqIxtAf2j31U5ef05uBDuvoXv6L51Q4rcS1jdlXAVKJv+atCFdUXYl9dyTHGyoMzIepwowRJjFw==", "integrity": "sha512-BJnGT5+0q2tzvs6oQfnY2NpEJ7rIXNfBnZtQOKCIsweeWXBXeDd5k31UgTdS3d/c02ouspufn37mTaHWkJyzMQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"colorette": "^1.2.2", "colorette": "^1.2.2",
@ -11350,9 +11350,9 @@
} }
}, },
"three": { "three": {
"version": "0.127.0", "version": "0.128.0",
"resolved": "https://registry.npmjs.org/three/-/three-0.127.0.tgz", "resolved": "https://registry.npmjs.org/three/-/three-0.128.0.tgz",
"integrity": "sha512-wtgrn+mhYUbobxT7QN3GPdu3SRpSBQvwY6uOzLChWS7QE//f7paDU/+wlzbg+ngeIvBBqjBHSRuywTh8A99Jng==" "integrity": "sha512-i0ap/E+OaSfzw7bD1TtYnPo3VEplkl70WX5fZqZnfZsE3k3aSFudqrrC9ldFZfYFkn1zwDmBcdGfiIm/hnbyZA=="
}, },
"to-fast-properties": { "to-fast-properties": {
"version": "2.0.0", "version": "2.0.0",
@ -11562,9 +11562,9 @@
} }
}, },
"webpack": { "webpack": {
"version": "5.35.0", "version": "5.35.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.35.0.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.35.1.tgz",
"integrity": "sha512-au3gu55yYF/h6NXFr0KZPZAYxS6Nlc595BzYPke8n0CSff5WXcoixtjh5LC/8mXunkRKxhymhXmBY0+kEbR6jg==", "integrity": "sha512-uWKYStqJ23+N6/EnMEwUjPSSKUG1tFmcuKhALEh/QXoUxwN8eb3ATNIZB38A+fO6QZ0xfc7Cu7KNV9LXNhDCsw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/eslint-scope": "^3.7.0", "@types/eslint-scope": "^3.7.0",

View File

@ -10,7 +10,7 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"proj4": "^2.6.3", "proj4": "^2.6.3",
"three": "^0.127.0" "three": "^0.128.0"
}, },
"author": "Arno Kaimbacher", "author": "Arno Kaimbacher",
"license": "MIT", "license": "MIT",

View File

@ -26,6 +26,7 @@ class Map extends OrbitControls {
public serviceUrl: string; public serviceUrl: string;
public basemaps: Object; public basemaps: Object;
public baseExtent: Object; public baseExtent: Object;
public currentBasemap;
constructor(x, y, z, scene, container) { constructor(x, y, z, scene, container) {
@ -124,7 +125,8 @@ class Map extends OrbitControls {
citation: layerData.geologicdescription !== null ? layerData.geologicdescription.citation : null, citation: layerData.geologicdescription !== null ? layerData.geologicdescription.citation : null,
feature_type: layerData.geologicdescription !== null ? layerData.geologicdescription['feature type'] : null, feature_type: layerData.geologicdescription !== null ? layerData.geologicdescription['feature type'] : null,
}); });
callStack.push(this.addLayer(dxfLayer)) callStack.push(this.addLayer(dxfLayer));
if (dxfLayer.name == " Topography") this.currentBasemap = dxfLayer;
} }
await Promise.all(callStack); await Promise.all(callStack);
this.emit("ready"); this.emit("ready");

View File

@ -92,6 +92,10 @@ import * as util from '../core/utilities';
return; return;
} }
setWireframeMode(wireframe) {
return;
}
getLayerId(layer) { getLayerId(layer) {
return util.stamp(layer); return util.stamp(layer);
} }

View File

@ -3,7 +3,7 @@ import * as util from '../core/utilities';
import { BaseEditor } from '../core/BaseEditor'; import { BaseEditor } from '../core/BaseEditor';
import { CylinderGeometry } from 'three/src/geometries/CylinderGeometry'; import { CylinderGeometry } from 'three/src/geometries/CylinderGeometry';
import { MeshLambertMaterial } from 'three/src/materials/MeshLambertMaterial'; import { MeshLambertMaterial } from 'three/src/materials/MeshLambertMaterial';
import { MathUtils } from 'three/src/math/MathUtils'; import * as MathUtils from 'three/src/math/MathUtils';
import { Mesh } from 'three/src/objects/Mesh'; import { Mesh } from 'three/src/objects/Mesh';
export class MarkerLayer extends Layer { export class MarkerLayer extends Layer {

View File

@ -16,7 +16,9 @@ import proj4 from 'proj4/dist/proj4';
import { ShaderMaterial } from 'three/src/materials/ShaderMaterial'; import { ShaderMaterial } from 'three/src/materials/ShaderMaterial';
import { shader } from '../clip/shader'; import { shader } from '../clip/shader';
import { Material } from 'three/src/materials/Material'; import { Material } from 'three/src/materials/Material';
import { MeshLambertMaterial } from 'three/src/materials/MeshLambertMaterial'; // import { MeshLambertMaterial } from 'three/src/materials/MeshLambertMaterial';
import { Vector2 } from 'three/src/math/Vector2';
import { Matrix4 } from 'three/src/math/Matrix4';
const POINTURL = 'https://geusegdi01.geus.dk/geom3d/data/nodes/'; const POINTURL = 'https://geusegdi01.geus.dk/geom3d/data/nodes/';
const EDGEURL = 'https://geusegdi01.geus.dk/geom3d/data/triangles/'; const EDGEURL = 'https://geusegdi01.geus.dk/geom3d/data/triangles/';
@ -113,19 +115,183 @@ class TinLayer extends Layer {
async initMaterials() { async initMaterials() {
} }
_applyBoxUV(geom, transformMatrix, bbox, bbox_max_size) {
let coords = [];
coords.length = 2 * geom.attributes.position.array.length / 3;
// geom.removeAttribute('uv');
if (geom.attributes.uv === undefined) {
geom.setAttribute('uv', new Float32BufferAttribute(coords, 2));
// const uvNumComponents = 2;
// geometry.setAttribute(
// 'uv',
// new Float32BufferAttribute(new Float32Array(uvs), uvNumComponents));
}
//maps 3 verts of 1 face on the better side of the cube
//side of the cube can be XY, XZ or YZ
let makeUVs = function (v0, v1, v2) {
//pre-rotate the model so that cube sides match world axis
v0.applyMatrix4(transformMatrix);
v1.applyMatrix4(transformMatrix);
v2.applyMatrix4(transformMatrix);
//get normal of the face, to know into which cube side it maps better
let n = new Vector3();
n.crossVectors(v1.clone().sub(v0), v1.clone().sub(v2)).normalize();
n.x = Math.abs(n.x);
n.y = Math.abs(n.y);
n.z = Math.abs(n.z);
let uv0 = new Vector2();
let uv1 = new Vector2();
let uv2 = new Vector2();
// xz mapping
if (n.y > n.x && n.y > n.z) {
uv0.x = (v0.x - bbox.min.x) / bbox_max_size;
uv0.y = (bbox.max.z - v0.z) / bbox_max_size;
uv1.x = (v1.x - bbox.min.x) / bbox_max_size;
uv1.y = (bbox.max.z - v1.z) / bbox_max_size;
uv2.x = (v2.x - bbox.min.x) / bbox_max_size;
uv2.y = (bbox.max.z - v2.z) / bbox_max_size;
} else
if (n.x > n.y && n.x > n.z) {
uv0.x = (v0.z - bbox.min.z) / bbox_max_size;
uv0.y = (v0.y - bbox.min.y) / bbox_max_size;
uv1.x = (v1.z - bbox.min.z) / bbox_max_size;
uv1.y = (v1.y - bbox.min.y) / bbox_max_size;
uv2.x = (v2.z - bbox.min.z) / bbox_max_size;
uv2.y = (v2.y - bbox.min.y) / bbox_max_size;
} else
if (n.z > n.y && n.z > n.x) {
uv0.x = (v0.x - bbox.min.x) / bbox_max_size;
uv0.y = (v0.y - bbox.min.y) / bbox_max_size;
uv1.x = (v1.x - bbox.min.x) / bbox_max_size;
uv1.y = (v1.y - bbox.min.y) / bbox_max_size;
uv2.x = (v2.x - bbox.min.x) / bbox_max_size;
uv2.y = (v2.y - bbox.min.y) / bbox_max_size;
}
return {
uv0: uv0,
uv1: uv1,
uv2: uv2
};
};
if (geom.index) { // is it indexed buffer geometry?
for (let vi = 0; vi < geom.index.array.length; vi += 3) {
let idx0 = geom.index.array[vi];
let idx1 = geom.index.array[vi + 1];
let idx2 = geom.index.array[vi + 2];
let vx0 = geom.attributes.position.array[3 * idx0];
let vy0 = geom.attributes.position.array[3 * idx0 + 1];
let vz0 = geom.attributes.position.array[3 * idx0 + 2];
let vx1 = geom.attributes.position.array[3 * idx1];
let vy1 = geom.attributes.position.array[3 * idx1 + 1];
let vz1 = geom.attributes.position.array[3 * idx1 + 2];
let vx2 = geom.attributes.position.array[3 * idx2];
let vy2 = geom.attributes.position.array[3 * idx2 + 1];
let vz2 = geom.attributes.position.array[3 * idx2 + 2];
let v0 = new Vector3(vx0, vy0, vz0);
let v1 = new Vector3(vx1, vy1, vz1);
let v2 = new Vector3(vx2, vy2, vz2);
let uvs = makeUVs(v0, v1, v2);
coords[2 * idx0] = uvs.uv0.x;
coords[2 * idx0 + 1] = uvs.uv0.y;
coords[2 * idx1] = uvs.uv1.x;
coords[2 * idx1 + 1] = uvs.uv1.y;
coords[2 * idx2] = uvs.uv2.x;
coords[2 * idx2 + 1] = uvs.uv2.y;
}
} else {
for (let vi = 0; vi < geom.attributes.position.array.length; vi += 9) {
let vx0 = geom.attributes.position.array[vi];
let vy0 = geom.attributes.position.array[vi + 1];
let vz0 = geom.attributes.position.array[vi + 2];
let vx1 = geom.attributes.position.array[vi + 3];
let vy1 = geom.attributes.position.array[vi + 4];
let vz1 = geom.attributes.position.array[vi + 5];
let vx2 = geom.attributes.position.array[vi + 6];
let vy2 = geom.attributes.position.array[vi + 7];
let vz2 = geom.attributes.position.array[vi + 8];
let v0 = new Vector3(vx0, vy0, vz0);
let v1 = new Vector3(vx1, vy1, vz1);
let v2 = new Vector3(vx2, vy2, vz2);
let uvs = makeUVs(v0, v1, v2);
let idx0 = vi / 3;
let idx1 = idx0 + 1;
let idx2 = idx0 + 2;
coords[2 * idx0] = uvs.uv0.x;
coords[2 * idx0 + 1] = uvs.uv0.y;
coords[2 * idx1] = uvs.uv1.x;
coords[2 * idx1 + 1] = uvs.uv1.y;
coords[2 * idx2] = uvs.uv2.x;
coords[2 * idx2 + 1] = uvs.uv2.y;
}
}
geom.attributes.uv.array = new Float32Array(coords);
}
applyBoxUV(bufferGeometry, transformMatrix, boxSize?) {
if (transformMatrix === undefined) {
transformMatrix = new Matrix4();
}
let geom = bufferGeometry;
geom.computeBoundingBox();
// let bbox = geom.boundingBox;
if (boxSize === undefined) {
let geom = bufferGeometry;
geom.computeBoundingBox();
let bbox = geom.boundingBox;
let bbox_size_x = bbox.max.x - bbox.min.x;
let bbox_size_z = bbox.max.z - bbox.min.z;
let bbox_size_y = bbox.max.y - bbox.min.y;
boxSize = Math.max(bbox_size_x, bbox_size_y, bbox_size_z);
}
//let uvBbox = new Box3(new Vector3(-boxSize / 2, -boxSize / 2, -boxSize / 2), new Vector3(boxSize / 2, boxSize / 2, boxSize / 2));
let uvBbox = geom.boundingBox
this._applyBoxUV(bufferGeometry, transformMatrix, uvBbox, boxSize);
}
async build(app_scene) { async build(app_scene) {
let geometry = new BufferGeometry(); let geometry = new BufferGeometry();
let vertices = await (this.points(this.featuregeom_id)); let vertices = await (this.points(this.featuregeom_id));
// const positions = [];
// const normals = [];
// const uvs = [];
// for (let i = 0; i < vertices.length; i = i +3) {
// // positions.push(...vertex.pos);
// // normals.push(...vertex.norm);
// uvs.push([0,0]);
// uvs.push([1, 0]);
// uvs.push([0, 1]);
// }
let positions = new Float32BufferAttribute(vertices, 3); let positions = new Float32BufferAttribute(vertices, 3);
geometry.setAttribute('position', positions); geometry.setAttribute('position', positions);
@ -136,21 +302,26 @@ class TinLayer extends Layer {
let indices = new Uint16BufferAttribute(indexArray, 1);//.setDynamic(true); let indices = new Uint16BufferAttribute(indexArray, 1);//.setDynamic(true);
geometry.setIndex(indices); geometry.setIndex(indices);
// const uvNumComponents = 2;
// geometry.setAttribute(
// 'uv',
// new Float32BufferAttribute(new Float32Array(uvs), uvNumComponents));
geometry.scale(1, 1, 1); geometry.scale(1, 1, 1);
geometry.computeBoundingSphere(); geometry.computeBoundingSphere();
geometry.computeVertexNormals();// computed vertex normals are orthogonal to the face f geometry.computeVertexNormals();// computed vertex normals are orthogonal to the face f
// geometry.computeBoundingBox();
//find out the dimensions, to let texture size 100% fit without stretching
geometry.computeBoundingBox(); geometry.computeBoundingBox();
// const center = new Vector3();
// let bboxSize = geometry.boundingBox.getSize(center);
// let uvMapSize = Math.min(bboxSize.x, bboxSize.y, bboxSize.z);
let boundingBox = geometry.boundingBox; let boundingBox = geometry.boundingBox;
this.baseExtent.min.x = boundingBox.min.x; this.baseExtent.min.x = boundingBox.min.x;
this.baseExtent.min.y = boundingBox.min.y; this.baseExtent.min.y = boundingBox.min.y;
this.baseExtent.max.x = boundingBox.max.x; this.baseExtent.max.x = boundingBox.max.x;
this.baseExtent.max.y = boundingBox.max.y; this.baseExtent.max.y = boundingBox.max.y;
let color = parseInt(this.color, 16); let color = parseInt(this.color, 16);
// this.material = new MeshStandardMaterial({ // this.material = new MeshStandardMaterial({
// color: color, // color: color,
@ -166,7 +337,8 @@ class TinLayer extends Layer {
if (this.name == "test") {
if (this.name == "Topography") {
let image = this.images[0]; let image = this.images[0];
if (image.texture === undefined) { if (image.texture === undefined) {
@ -187,15 +359,23 @@ class TinLayer extends Layer {
clippingScale: { type: "f", value: 1.0 }, clippingScale: { type: "f", value: 1.0 },
clippingLow: { type: "v3", value: new Vector3(0, 0, 0) }, clippingLow: { type: "v3", value: new Vector3(0, 0, 0) },
clippingHigh: { type: "v3", value: new Vector3(0, 0, 0) }, clippingHigh: { type: "v3", value: new Vector3(0, 0, 0) },
// map: { type: 't', value: image.texture }, map: { type: 't', value: image.texture },
percent: { type: "f", value: 0.7 } percent: { type: "f", value: 0.7 }
} }
}; };
//calculate UV coordinates, if uv attribute is not present, it will be added
// https://jsfiddle.net/mmalex/pcjbysn1/
// https://stackoverflow.com/questions/20774648/three-js-generate-uv-coordinate
this.applyBoxUV(geometry, new Matrix4());
//let three.js know
geometry.attributes.uv.needsUpdate = true;
// this.material = new MeshLambertMaterial({ // this.material = new MeshLambertMaterial({
// map: image.texture, // map: image.texture,
// transparent: true, // transparent: true,
// side: DoubleSide, // side: DoubleSide,
// opacity: 0.7
// }); // });
this.material = new ShaderMaterial({ this.material = new ShaderMaterial({
transparent: true, transparent: true,
@ -204,6 +384,8 @@ class TinLayer extends Layer {
vertexShader: shader.vertexClipping, vertexShader: shader.vertexClipping,
fragmentShader: shader.fragmentClippingFront, fragmentShader: shader.fragmentClippingFront,
}); });
// this.material.map.wrapS = RepeatWrapping;
// this.material.map.wrapT = RepeatWrapping;
} else { } else {
let uniforms = this.uniforms = { let uniforms = this.uniforms = {

File diff suppressed because it is too large Load Diff