- npm updates

- correct slicing of blend areas (via UpdatableBoxGeometry.ts)
This commit is contained in:
Arno Kaimbacher 2021-05-05 10:50:05 +02:00
parent 78437eb89c
commit 2f3a0e7b92
4 changed files with 111 additions and 67 deletions

74
package-lock.json generated
View File

@ -1509,9 +1509,9 @@
"peer": true "peer": true
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "15.0.1", "version": "15.0.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.0.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-15.0.2.tgz",
"integrity": "sha512-TMkXt0Ck1y0KKsGr9gJtWGjttxlZnnvDtphxUOSd0bfaR6Q1jle+sPvrzNR1urqYTWMinoKvjKfXUGsumaO1PA==", "integrity": "sha512-p68+a+KoxpoB47015IeYZYRrdqMUcpbK8re/zpFB8Ld46LHC1lPEbp3EXgkEhAYEcPvjJF6ZO+869SQ0aH1dcA==",
"dev": true "dev": true
}, },
"node_modules/@types/normalize-package-data": { "node_modules/@types/normalize-package-data": {
@ -1726,9 +1726,9 @@
"dev": true "dev": true
}, },
"node_modules/acorn": { "node_modules/acorn": {
"version": "8.2.2", "version": "8.2.4",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.2.2.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.2.4.tgz",
"integrity": "sha512-VrMS8kxT0e7J1EX0p6rI/E0FbfOVcvBpbIqHThFv+f8YrZIlMfVotYcXKVPmTvPW8sW5miJzfUFrrvthUZg8VQ==", "integrity": "sha512-Ibt84YwBDDA890eDiDCEqcbwvHlBvzzDkU2cGBBDDI1QWT12jTiXIOn2CIw5KK4i6N5Z2HUxwYjzriDyqaqqZg==",
"dev": true, "dev": true,
"bin": { "bin": {
"acorn": "bin/acorn" "acorn": "bin/acorn"
@ -2125,9 +2125,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001221", "version": "1.0.30001222",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001221.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001222.tgz",
"integrity": "sha512-b9TOZfND3uGSLjMOrLh8XxSQ41x8mX+9MLJYDM4AAHLfaZHttrLNPrScWjVnBITRZbY5sPpCt7X85n7VSLZ+/g==", "integrity": "sha512-rPmwUK0YMjfMlZVmH6nVB5U3YJ5Wnx3vmT5lnRO3nIKO8bJ+TRWMbGuuiSugDJqESy/lz+1hSrlQEagCtoOAWQ==",
"dev": true "dev": true
}, },
"node_modules/caseless": { "node_modules/caseless": {
@ -2616,9 +2616,9 @@
} }
}, },
"node_modules/date-fns": { "node_modules/date-fns": {
"version": "2.21.1", "version": "2.21.2",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.21.1.tgz", "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.21.2.tgz",
"integrity": "sha512-m1WR0xGiC6j6jNFAyW4Nvh4WxAi4JF4w9jRJwSI8nBmNcyZXPcP9VUQG+6gHQXAmqaGEKDKhOqAtENDC941UkA==", "integrity": "sha512-FMkG7pIPx64mGIpS2LOb3Wp3O606H/hatoiz7G0oiYWai1izdM4tF1dd7QABv2NogkIDI4wxsfLLFQSuVvDHgA==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=0.11" "node": ">=0.11"
@ -2704,12 +2704,12 @@
} }
}, },
"node_modules/dotenv": { "node_modules/dotenv": {
"version": "8.2.0", "version": "8.5.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.5.1.tgz",
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==", "integrity": "sha512-qC1FbhCH7UH7B+BcRNUDhAk04d/n+tnGGB1ctwndZkVFeehYJOn39pRWWzmdzpFqImyX1KB8tO0DCHLf8yRaYQ==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=8" "node": ">=10"
} }
}, },
"node_modules/ecc-jsbn": { "node_modules/ecc-jsbn": {
@ -2723,9 +2723,9 @@
} }
}, },
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.3.725", "version": "1.3.726",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.725.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.726.tgz",
"integrity": "sha512-2BbeAESz7kc6KBzs7WVrMc1BY5waUphk4D4DX5dSQXJhsc3tP5ZFaiyuL0AB7vUKzDYpIeYwTYlEfxyjsGUrhw==", "integrity": "sha512-dw7WmrSu/JwtACiBzth8cuKf62NKL1xVJuNvyOg0jvruN/n4NLtGYoTzciQquCPNaS2eR+BT5GrxHbslfc/w1w==",
"dev": true "dev": true
}, },
"node_modules/emoji-regex": { "node_modules/emoji-regex": {
@ -7933,9 +7933,9 @@
"peer": true "peer": true
}, },
"@types/node": { "@types/node": {
"version": "15.0.1", "version": "15.0.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.0.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-15.0.2.tgz",
"integrity": "sha512-TMkXt0Ck1y0KKsGr9gJtWGjttxlZnnvDtphxUOSd0bfaR6Q1jle+sPvrzNR1urqYTWMinoKvjKfXUGsumaO1PA==", "integrity": "sha512-p68+a+KoxpoB47015IeYZYRrdqMUcpbK8re/zpFB8Ld46LHC1lPEbp3EXgkEhAYEcPvjJF6ZO+869SQ0aH1dcA==",
"dev": true "dev": true
}, },
"@types/normalize-package-data": { "@types/normalize-package-data": {
@ -8137,9 +8137,9 @@
"dev": true "dev": true
}, },
"acorn": { "acorn": {
"version": "8.2.2", "version": "8.2.4",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.2.2.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.2.4.tgz",
"integrity": "sha512-VrMS8kxT0e7J1EX0p6rI/E0FbfOVcvBpbIqHThFv+f8YrZIlMfVotYcXKVPmTvPW8sW5miJzfUFrrvthUZg8VQ==", "integrity": "sha512-Ibt84YwBDDA890eDiDCEqcbwvHlBvzzDkU2cGBBDDI1QWT12jTiXIOn2CIw5KK4i6N5Z2HUxwYjzriDyqaqqZg==",
"dev": true "dev": true
}, },
"adjust-sourcemap-loader": { "adjust-sourcemap-loader": {
@ -8442,9 +8442,9 @@
} }
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30001221", "version": "1.0.30001222",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001221.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001222.tgz",
"integrity": "sha512-b9TOZfND3uGSLjMOrLh8XxSQ41x8mX+9MLJYDM4AAHLfaZHttrLNPrScWjVnBITRZbY5sPpCt7X85n7VSLZ+/g==", "integrity": "sha512-rPmwUK0YMjfMlZVmH6nVB5U3YJ5Wnx3vmT5lnRO3nIKO8bJ+TRWMbGuuiSugDJqESy/lz+1hSrlQEagCtoOAWQ==",
"dev": true "dev": true
}, },
"caseless": { "caseless": {
@ -8831,9 +8831,9 @@
} }
}, },
"date-fns": { "date-fns": {
"version": "2.21.1", "version": "2.21.2",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.21.1.tgz", "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.21.2.tgz",
"integrity": "sha512-m1WR0xGiC6j6jNFAyW4Nvh4WxAi4JF4w9jRJwSI8nBmNcyZXPcP9VUQG+6gHQXAmqaGEKDKhOqAtENDC941UkA==", "integrity": "sha512-FMkG7pIPx64mGIpS2LOb3Wp3O606H/hatoiz7G0oiYWai1izdM4tF1dd7QABv2NogkIDI4wxsfLLFQSuVvDHgA==",
"dev": true "dev": true
}, },
"debug": { "debug": {
@ -8889,9 +8889,9 @@
} }
}, },
"dotenv": { "dotenv": {
"version": "8.2.0", "version": "8.5.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.5.1.tgz",
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==", "integrity": "sha512-qC1FbhCH7UH7B+BcRNUDhAk04d/n+tnGGB1ctwndZkVFeehYJOn39pRWWzmdzpFqImyX1KB8tO0DCHLf8yRaYQ==",
"dev": true "dev": true
}, },
"ecc-jsbn": { "ecc-jsbn": {
@ -8905,9 +8905,9 @@
} }
}, },
"electron-to-chromium": { "electron-to-chromium": {
"version": "1.3.725", "version": "1.3.726",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.725.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.726.tgz",
"integrity": "sha512-2BbeAESz7kc6KBzs7WVrMc1BY5waUphk4D4DX5dSQXJhsc3tP5ZFaiyuL0AB7vUKzDYpIeYwTYlEfxyjsGUrhw==", "integrity": "sha512-dw7WmrSu/JwtACiBzth8cuKf62NKL1xVJuNvyOg0jvruN/n4NLtGYoTzciQquCPNaS2eR+BT5GrxHbslfc/w1w==",
"dev": true "dev": true
}, },
"emoji-regex": { "emoji-regex": {

View File

@ -1,4 +1,3 @@
import { BoxGeometry } from 'three/src/geometries/BoxGeometry';
import { Mesh } from 'three/src/objects/Mesh'; import { Mesh } from 'three/src/objects/Mesh';
import * as material from './material'; import * as material from './material';
import { Vector3 } from 'three/src/math/Vector3'; import { Vector3 } from 'three/src/math/Vector3';
@ -7,6 +6,7 @@ import { SelectionBoxFace } from './SelectionBoxFace';
import { SelectionBoxLine } from './SelectionBoxLine'; import { SelectionBoxLine } from './SelectionBoxLine';
import { Layer } from '../layer/Layer'; import { Layer } from '../layer/Layer';
import { Group } from 'three/src/objects/Group'; import { Group } from 'three/src/objects/Group';
import { UpdatableBoxGeometry } from './UpdatableBoxGeometry';
export class Selection extends Layer { export class Selection extends Layer {
visible; visible;
@ -15,10 +15,10 @@ export class Selection extends Layer {
limit; limit;
limitLow; limitLow;
limitHigh; limitHigh;
box; box: UpdatableBoxGeometry;
boxMesh; boxMesh: Mesh;
vertices; vertices;
touchMeshes; displayMeshes; meshGeometries; selectables; touchMeshes; displayMeshes; meshGeometries; lineGeometries; selectables;
faces; faces;
map; map;
scale; scale;
@ -44,8 +44,7 @@ export class Selection extends Layer {
} }
this.scale = 1.0; this.scale = 1.0;
this.box = new BoxGeometry(1, 1, 1);
this.boxMesh = new Mesh(this.box, material.capMaterial);
this.vertices = [ this.vertices = [
new Vector3(), new Vector3(), new Vector3(), new Vector3(),
@ -53,10 +52,15 @@ export class Selection extends Layer {
new Vector3(), new Vector3(), new Vector3(), new Vector3(),
new Vector3(), new Vector3() new Vector3(), new Vector3()
]; ];
this.updateVertices();
this._updateVertices();
// this.box = new BoxGeometry(1, 1, 1);
let box = this.box = new UpdatableBoxGeometry(this.vertices)
this.boxMesh = new Mesh(box, material.capMaterial);
let v = this.vertices; let v = this.vertices;
this.touchMeshes = new Group(); //Object3D(); this.touchMeshes = new Group(); //Object3D();
this.displayMeshes = new Group(); // Object3D(); this.displayMeshes = new Group(); // Object3D();
this.meshGeometries = []; this.meshGeometries = [];
@ -86,14 +90,13 @@ export class Selection extends Layer {
this.boxLines.push(new SelectionBoxLine(v[5], v[7], f[3], f[5], this)); this.boxLines.push(new SelectionBoxLine(v[5], v[7], f[3], f[5], this));
this.boxLines.push(new SelectionBoxLine(v[6], v[7], f[4], f[5], this)); this.boxLines.push(new SelectionBoxLine(v[6], v[7], f[4], f[5], this));
this.setBox(); // this.setBox();
// this.setUniforms(); // this.setUniforms();
} }
onAdd(map) { onAdd(map) {
this.map = map; this.map = map;
this.build(this.getScene()); this.build(this.getScene());
//this.update();
this.emit('add'); this.emit('add');
} }
@ -114,12 +117,13 @@ export class Selection extends Layer {
setVisible(visible) { setVisible(visible) {
this.visible = visible; this.visible = visible;
this.boxMesh.visible = visible; // this.boxMesh.visible = visible;
this.displayMeshes.visible = visible; this.displayMeshes.visible = visible;
this.touchMeshes.visible = visible; this.touchMeshes.visible = visible;
this.emit('visibility-change'); this.emit('visibility-change');
} }
toggle () {
toggle() {
let visible = !this.visible; let visible = !this.visible;
this.visible = visible; this.visible = visible;
this.boxMesh.visible = visible; this.boxMesh.visible = visible;
@ -130,13 +134,13 @@ export class Selection extends Layer {
scaleZ(z) { scaleZ(z) {
this.scale = z; this.scale = z;
// this.boxMesh.scale.z = z; this.boxMesh.scale.z = z;
this.displayMeshes.scale.z = z; this.displayMeshes.scale.z = z;
this.touchMeshes.scale.z = z; this.touchMeshes.scale.z = z;
this.setUniforms(); this.setUniforms();
} }
updateVertices() { _updateVertices() {
this.vertices[0].set(this.limitLow.x, this.limitLow.y, this.limitLow.z); this.vertices[0].set(this.limitLow.x, this.limitLow.y, this.limitLow.z);
this.vertices[1].set(this.limitHigh.x, this.limitLow.y, this.limitLow.z); this.vertices[1].set(this.limitHigh.x, this.limitLow.y, this.limitLow.z);
this.vertices[2].set(this.limitLow.x, this.limitHigh.y, this.limitLow.z); this.vertices[2].set(this.limitLow.x, this.limitHigh.y, this.limitLow.z);
@ -173,14 +177,6 @@ export class Selection extends Layer {
} }
} }
setBox() {
let width = new Vector3();
width.subVectors(this.limitHigh, this.limitLow);
this.boxMesh.scale.copy(width);
width.multiplyScalar(0.5).add(this.limitLow);
this.boxMesh.position.copy(width);
}
setUniforms() { setUniforms() {
let unif = uniforms.clipping; let unif = uniforms.clipping;
unif.clippingLow.value.copy(this.limitLow); unif.clippingLow.value.copy(this.limitLow);
@ -223,10 +219,12 @@ export class Selection extends Layer {
this.limitHigh.z = Math.max(this.limitLow.z + buffer, Math.min(this.limit.z2, value)); this.limitHigh.z = Math.max(this.limitLow.z + buffer, Math.min(this.limit.z2, value));
} }
this.setBox();
this.setUniforms(); this.setUniforms();
this.updateVertices(); this._updateVertices();
this.updateGeometries(); this.updateGeometries();
// this.setBox();
this.box.update();
} }
} }

View File

@ -0,0 +1,49 @@
import { BufferGeometry } from 'three/src/core/BufferGeometry';
import { Uint16BufferAttribute } from 'three/src/core/BufferAttribute';
import { Vector3 } from 'three/src/math/Vector3';
class UpdatableBoxGeometry extends BufferGeometry {
faces;
vertices: Array<Vector3>;
indexArray: Array<number>;
constructor(vertices: Array<Vector3>) {
super();
this.indexArray = new Array();
this.vertices = new Array();
this.buildPlane(0, vertices[0], vertices[1], vertices[5], vertices[4]); //y1
this.buildPlane(4, vertices[0], vertices[2], vertices[3], vertices[1]); //z1
this.buildPlane(8, vertices[0], vertices[4], vertices[6], vertices[2]); //x1
this.buildPlane(12, vertices[7], vertices[5], vertices[1], vertices[3]); //x2
this.buildPlane(16, vertices[7], vertices[3], vertices[2], vertices[6]); //y2
this.buildPlane(20, vertices[7], vertices[6], vertices[4], vertices[5]); //z2
this.setFromPoints(this.vertices);
let indices = new Uint16BufferAttribute(this.indexArray, 1);//.setDynamic(true);
this.setIndex(indices);
this.computeVertexNormals();
}
buildPlane(i, v0, v1, v2, v3) {
// let frontFaceGeometry = new PlaneGeometry(v0, v1, v2, v3);
// let frontFaceMesh = new Mesh(frontFaceGeometry, material.Invisible);
// frontFaceMesh.axis = axis;
this.vertices.push(v0, v1, v2, v3);
this.indexArray.push(i, i +1, i + 2, i, i +2, i+3);
// let indexArray = [0, 1, 2, 0, 2, 3];
}
update() {
this.setFromPoints(this.vertices);
this.attributes.position.needsUpdate = true;
this.computeBoundingSphere();
}
}
export { UpdatableBoxGeometry };

View File

@ -5,19 +5,16 @@ import { Mesh } from 'three/src/objects/Mesh';
import { Layer } from './Layer'; import { Layer } from './Layer';
import { BitStream } from '../lib/bitstream'; import { BitStream } from '../lib/bitstream';
import { Vector3 } from 'three/src/math/Vector3'; import { Vector3 } from 'three/src/math/Vector3';
import { Color } from 'three/src/math/Color';
import { MyMeshStandardMaterial } from '../clip/MyMeshStandardMaterial'; import { MyMeshStandardMaterial } from '../clip/MyMeshStandardMaterial';
import { Group } from 'three/src/objects/Group'; import { Group } from 'three/src/objects/Group';
import { TextureLoader } from 'three/src/loaders/TextureLoader'; import { TextureLoader } from 'three/src/loaders/TextureLoader';
import proj4 from 'proj4/dist/proj4'; import proj4 from 'proj4/dist/proj4-src';
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 { Vector2 } from 'three/src/math/Vector2'; import { Vector2 } from 'three/src/math/Vector2';
import { Matrix4 } from 'three/src/math/Matrix4'; import { Matrix4 } from 'three/src/math/Matrix4';
import { Box3 } from 'three/src/math/Box3'; import { Box3 } from 'three/src/math/Box3';
import { PlaneGeometry } from 'three/src/geometries/PlaneGeometry';
import { uniforms } from '../clip/uniforms'; import { uniforms } from '../clip/uniforms';
const POINTURL = 'https://geusegdi01.geus.dk/geom3d/data/nodes/'; const POINTURL = 'https://geusegdi01.geus.dk/geom3d/data/nodes/';