- 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
/.env
debug.log
/noteDemLayer.txt

130
package-lock.json generated
View File

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

View File

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

View File

@ -26,6 +26,7 @@ class Map extends OrbitControls {
public serviceUrl: string;
public basemaps: Object;
public baseExtent: Object;
public currentBasemap;
constructor(x, y, z, scene, container) {
@ -124,7 +125,8 @@ class Map extends OrbitControls {
citation: layerData.geologicdescription !== null ? layerData.geologicdescription.citation : 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);
this.emit("ready");

View File

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

View File

@ -3,7 +3,7 @@ import * as util from '../core/utilities';
import { BaseEditor } from '../core/BaseEditor';
import { CylinderGeometry } from 'three/src/geometries/CylinderGeometry';
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';
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 { shader } from '../clip/shader';
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 EDGEURL = 'https://geusegdi01.geus.dk/geom3d/data/triangles/';
@ -113,19 +115,183 @@ class TinLayer extends Layer {
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) {
let geometry = new BufferGeometry();
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);
geometry.setAttribute('position', positions);
@ -136,21 +302,26 @@ class TinLayer extends Layer {
let indices = new Uint16BufferAttribute(indexArray, 1);//.setDynamic(true);
geometry.setIndex(indices);
// const uvNumComponents = 2;
// geometry.setAttribute(
// 'uv',
// new Float32BufferAttribute(new Float32Array(uvs), uvNumComponents));
geometry.scale(1, 1, 1);
geometry.computeBoundingSphere();
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();
// const center = new Vector3();
// let bboxSize = geometry.boundingBox.getSize(center);
// let uvMapSize = Math.min(bboxSize.x, bboxSize.y, bboxSize.z);
let boundingBox = geometry.boundingBox;
this.baseExtent.min.x = boundingBox.min.x;
this.baseExtent.min.y = boundingBox.min.y;
this.baseExtent.max.x = boundingBox.max.x;
this.baseExtent.max.y = boundingBox.max.y;
let color = parseInt(this.color, 16);
// this.material = new MeshStandardMaterial({
// color: color,
@ -166,7 +337,8 @@ class TinLayer extends Layer {
if (this.name == "test") {
if (this.name == "Topography") {
let image = this.images[0];
if (image.texture === undefined) {
@ -187,15 +359,23 @@ class TinLayer extends Layer {
clippingScale: { type: "f", value: 1.0 },
clippingLow: { 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 }
}
};
//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({
// map: image.texture,
// transparent: true,
// side: DoubleSide,
// opacity: 0.7
// });
this.material = new ShaderMaterial({
transparent: true,
@ -204,6 +384,8 @@ class TinLayer extends Layer {
vertexShader: shader.vertexClipping,
fragmentShader: shader.fragmentClippingFront,
});
// this.material.map.wrapS = RepeatWrapping;
// this.material.map.wrapT = RepeatWrapping;
} else {
let uniforms = this.uniforms = {

File diff suppressed because it is too large Load Diff