- add slicing box as layer
- npm updates - small syntax improvements
This commit is contained in:
parent
be8c6d0a8c
commit
dfec6b542b
1170
package-lock.json
generated
1170
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -2,12 +2,13 @@ import { MeshStandardMaterial } from 'three/src/materials/MeshStandardMaterial';
|
||||||
import { shader } from './shader';
|
import { shader } from './shader';
|
||||||
|
|
||||||
export class MyMeshStandardMaterial extends MeshStandardMaterial {
|
export class MyMeshStandardMaterial extends MeshStandardMaterial {
|
||||||
constructor(materialParameters, uniforms) {
|
|
||||||
|
|
||||||
|
constructor(materialParameters, uniforms) {
|
||||||
super(materialParameters);
|
super(materialParameters);
|
||||||
this.uniforms = uniforms;
|
this.uniforms = uniforms;
|
||||||
|
}
|
||||||
|
|
||||||
this.onBeforeCompile = m_shader => {
|
onBeforeCompile = m_shader => {
|
||||||
|
|
||||||
m_shader.uniforms.clippingLow = this.uniforms.clippingLow; // { type: "v3", value: new Vector3(0, 0, 0) };
|
m_shader.uniforms.clippingLow = this.uniforms.clippingLow; // { type: "v3", value: new Vector3(0, 0, 0) };
|
||||||
m_shader.uniforms.clippingHigh = this.uniforms.clippingHigh; // { type: "v3", value: new Vector3(0, 0, 0) };
|
m_shader.uniforms.clippingHigh = this.uniforms.clippingHigh; // { type: "v3", value: new Vector3(0, 0, 0) };
|
||||||
|
@ -63,4 +64,3 @@ export class MyMeshStandardMaterial extends MeshStandardMaterial {
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -78,7 +78,7 @@ export class Picking {
|
||||||
}
|
}
|
||||||
|
|
||||||
mouseMove(event) {
|
mouseMove(event) {
|
||||||
if (this.isDraging == true) {
|
if (this.isDraging == true || this.simulation.selection.visible == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let point = this._getCanvasPoint(event);
|
let point = this._getCanvasPoint(event);
|
||||||
|
@ -116,6 +116,9 @@ export class Picking {
|
||||||
}
|
}
|
||||||
|
|
||||||
beginDrag(event) {
|
beginDrag(event) {
|
||||||
|
if (this.simulation.selection.visible == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// exit drag method, if not left mouse button was clicked
|
// exit drag method, if not left mouse button was clicked
|
||||||
if (this.touchCapable == false && event.which != 1) {
|
if (this.touchCapable == false && event.which != 1) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -6,8 +6,9 @@ import { Object3D } from 'three/src/core/Object3D';
|
||||||
import { uniforms } from "./uniforms";
|
import { uniforms } from "./uniforms";
|
||||||
import { SelectionBoxFace } from './SelectionBoxFace';
|
import { SelectionBoxFace } from './SelectionBoxFace';
|
||||||
import { SelectionBoxLine } from './SelectionBoxLine';
|
import { SelectionBoxLine } from './SelectionBoxLine';
|
||||||
|
import { Layer } from '../layer/Layer';
|
||||||
|
|
||||||
export class Selection {
|
export class Selection extends Layer {
|
||||||
limitLow;
|
limitLow;
|
||||||
limitHigh;
|
limitHigh;
|
||||||
box;
|
box;
|
||||||
|
@ -16,9 +17,16 @@ export class Selection {
|
||||||
touchMeshes; displayMeshes; meshGeometries; selectables;
|
touchMeshes; displayMeshes; meshGeometries; selectables;
|
||||||
faces;
|
faces;
|
||||||
map;
|
map;
|
||||||
|
scale;
|
||||||
|
|
||||||
constructor(low, high, map) {
|
constructor(parameters, low, high) {
|
||||||
this.map = map;
|
super();
|
||||||
|
this.type = 'Selection';
|
||||||
|
this.visible = true;
|
||||||
|
this.opacity = 1;
|
||||||
|
for (var k in parameters) {
|
||||||
|
this[k] = parameters[k];
|
||||||
|
}
|
||||||
this.limitLow = low;
|
this.limitLow = low;
|
||||||
this.limitHigh = high;
|
this.limitHigh = high;
|
||||||
this.limit = {
|
this.limit = {
|
||||||
|
@ -27,6 +35,7 @@ export class Selection {
|
||||||
x2: high.x,
|
x2: high.x,
|
||||||
y2: high.y
|
y2: high.y
|
||||||
}
|
}
|
||||||
|
this.scale = 1;
|
||||||
|
|
||||||
this.box = new BoxGeometry(1, 1, 1);
|
this.box = new BoxGeometry(1, 1, 1);
|
||||||
this.boxMesh = new Mesh(this.box, material.capMaterial);
|
this.boxMesh = new Mesh(this.box, material.capMaterial);
|
||||||
|
@ -71,8 +80,39 @@ export class Selection {
|
||||||
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) {
|
||||||
|
this.map = map;
|
||||||
|
this.build(this.getScene());
|
||||||
|
//this.update();
|
||||||
|
this.emit('add');
|
||||||
|
}
|
||||||
|
|
||||||
|
build(app_scene) {
|
||||||
|
// app_scene.add(this.boxMesh);
|
||||||
|
app_scene.add(this.displayMeshes);
|
||||||
|
app_scene.add(this.touchMeshes);
|
||||||
|
}
|
||||||
|
|
||||||
|
setWireframeMode(wireframe) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setVisible(visible) {
|
||||||
|
this.visible = visible;
|
||||||
|
this.boxMesh.visible = visible;
|
||||||
|
this.displayMeshes.visible = visible;
|
||||||
|
this.touchMeshes.visible = visible;
|
||||||
|
this.emit('visibility-change');
|
||||||
|
}
|
||||||
|
|
||||||
|
scaleZ(z) {
|
||||||
|
this.scale = z;
|
||||||
|
// this.boxMesh.scale.z = z;
|
||||||
|
// this.displayMeshes.scale.z = z;
|
||||||
|
// this.touchMeshes.scale.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateVertices() {
|
updateVertices() {
|
||||||
|
@ -115,7 +155,6 @@ export class Selection {
|
||||||
setBox() {
|
setBox() {
|
||||||
let width = new Vector3();
|
let width = new Vector3();
|
||||||
width.subVectors(this.limitHigh, this.limitLow);
|
width.subVectors(this.limitHigh, this.limitLow);
|
||||||
|
|
||||||
this.boxMesh.scale.copy(width);
|
this.boxMesh.scale.copy(width);
|
||||||
width.multiplyScalar(0.5).add(this.limitLow);
|
width.multiplyScalar(0.5).add(this.limitLow);
|
||||||
this.boxMesh.position.copy(width);
|
this.boxMesh.position.copy(width);
|
||||||
|
@ -164,7 +203,4 @@ export class Selection {
|
||||||
this.updateVertices();
|
this.updateVertices();
|
||||||
this.updateGeometries();
|
this.updateGeometries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,12 +1,9 @@
|
||||||
import { LineSegments } from 'three/src/objects/LineSegments';
|
import { LineSegments } from 'three/src/objects/LineSegments';
|
||||||
// import { Float32BufferAttribute } from 'three/src/core/BufferAttribute';
|
|
||||||
import * as material from './material';
|
import * as material from './material';
|
||||||
import { BufferGeometry } from 'three/src/core/BufferGeometry';
|
import { BufferGeometry } from 'three/src/core/BufferGeometry';
|
||||||
|
|
||||||
export class SelectionBoxLine {
|
export class SelectionBoxLine {
|
||||||
|
|
||||||
// material;
|
|
||||||
|
|
||||||
constructor(v0, v1, f0, f1, selection) {
|
constructor(v0, v1, f0, f1, selection) {
|
||||||
// var lineGeometry = new THREE.Geometry();
|
// var lineGeometry = new THREE.Geometry();
|
||||||
// lineGeometry.vertices.push(v0, v1);
|
// lineGeometry.vertices.push(v0, v1);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
// import { Group } from 'three/src/objects/Group';
|
|
||||||
import { BufferGeometry } from 'three/src/core/BufferGeometry';
|
import { BufferGeometry } from 'three/src/core/BufferGeometry';
|
||||||
import { Float32BufferAttribute, Uint16BufferAttribute } from 'three/src/core/BufferAttribute';
|
import { Float32BufferAttribute, Uint16BufferAttribute } from 'three/src/core/BufferAttribute';
|
||||||
import { DoubleSide } from 'three/src/constants';
|
import { DoubleSide } from 'three/src/constants';
|
||||||
|
@ -8,7 +7,6 @@ import { BitStream } from '../lib/bitstream';
|
||||||
import { Plane } from 'three/src/math/Plane';
|
import { Plane } from 'three/src/math/Plane';
|
||||||
import { Vector3 } from 'three/src/math/Vector3';
|
import { Vector3 } from 'three/src/math/Vector3';
|
||||||
import { Color } from 'three/src/math/Color';
|
import { Color } from 'three/src/math/Color';
|
||||||
|
|
||||||
import { MyMeshStandardMaterial } from '../clip/MyMeshStandardMaterial';
|
import { MyMeshStandardMaterial } from '../clip/MyMeshStandardMaterial';
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,8 +15,6 @@ const EDGEURL = 'https://geusegdi01.geus.dk/geom3d/data/triangles/';
|
||||||
|
|
||||||
class TinLayer extends Layer {
|
class TinLayer extends Layer {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
constructor(params) {
|
constructor(params) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -31,7 +27,6 @@ class TinLayer extends Layer {
|
||||||
this[k] = params[k];
|
this[k] = params[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.objectGroup = new Group();
|
|
||||||
this.queryableObjects = [];
|
this.queryableObjects = [];
|
||||||
this.borderVisible = false;
|
this.borderVisible = false;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +47,6 @@ class TinLayer extends Layer {
|
||||||
|
|
||||||
scaleZ(z) {
|
scaleZ(z) {
|
||||||
this.mainMesh.scale.z = z;
|
this.mainMesh.scale.z = z;
|
||||||
//this.objectGroup.scale.z = z;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async onAdd(map) {
|
async onAdd(map) {
|
||||||
|
@ -60,7 +54,6 @@ class TinLayer extends Layer {
|
||||||
map.update();
|
map.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
//build BufferGeometry with Index
|
|
||||||
async build(app_scene) {
|
async build(app_scene) {
|
||||||
|
|
||||||
let geometry = new BufferGeometry();
|
let geometry = new BufferGeometry();
|
||||||
|
@ -120,8 +113,6 @@ class TinLayer extends Layer {
|
||||||
this.materialsArray.push(this.material);
|
this.materialsArray.push(this.material);
|
||||||
let mesh = this.mainMesh = new Mesh(geometry, this.material);
|
let mesh = this.mainMesh = new Mesh(geometry, this.material);
|
||||||
// mesh.userData.layerId = this.index;
|
// mesh.userData.layerId = this.index;
|
||||||
// this.addObject(mesh, true);
|
|
||||||
//this.mainMesh = mesh;
|
|
||||||
if (app_scene) {
|
if (app_scene) {
|
||||||
app_scene.add(mesh);
|
app_scene.add(mesh);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +123,6 @@ class TinLayer extends Layer {
|
||||||
this.yLocalPlane.constant = filterY;
|
this.yLocalPlane.constant = filterY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async points(geomId) {
|
async points(geomId) {
|
||||||
const url = POINTURL + geomId;
|
const url = POINTURL + geomId;
|
||||||
const buffer = await this.request(url);
|
const buffer = await this.request(url);
|
||||||
|
@ -214,10 +204,6 @@ class TinLayer extends Layer {
|
||||||
return sigbits;
|
return sigbits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export { TinLayer };
|
export { TinLayer };
|
|
@ -187,10 +187,11 @@ class Application {
|
||||||
this.selection = new Selection(
|
this.selection = new Selection(
|
||||||
// new Vector3(-7, -14, -14),
|
// new Vector3(-7, -14, -14),
|
||||||
// new Vector3(14, 9, 3)
|
// new Vector3(14, 9, 3)
|
||||||
|
{ name: 'Slicing Box'},
|
||||||
new Vector3(x.min, y.min, z.min),
|
new Vector3(x.min, y.min, z.min),
|
||||||
new Vector3(x.max, y.max, z.max),
|
new Vector3(x.max, y.max, z.max)
|
||||||
map
|
|
||||||
);
|
);
|
||||||
|
this.map.addLayer(this.selection);
|
||||||
|
|
||||||
new Picking(size, center, this);
|
new Picking(size, center, this);
|
||||||
|
|
||||||
|
@ -263,9 +264,9 @@ class Application {
|
||||||
// new Vector3(x.min, y.min, z.min),
|
// new Vector3(x.min, y.min, z.min),
|
||||||
// new Vector3(x.max, y.max, z.max)
|
// new Vector3(x.max, y.max, z.max)
|
||||||
// );
|
// );
|
||||||
this.capsScene.add(this.selection.boxMesh);
|
// this.capsScene.add(this.selection.boxMesh);
|
||||||
this.scene.add(this.selection.displayMeshes);
|
// this.scene.add(this.selection.displayMeshes);
|
||||||
this.scene.add(this.selection.touchMeshes);
|
// this.scene.add(this.selection.touchMeshes);
|
||||||
|
|
||||||
// domEvent.on(window, 'resize', this.onWindowResize, this);
|
// domEvent.on(window, 'resize', this.onWindowResize, this);
|
||||||
// domEvent.on(window, 'keydown', this.keydown, this);
|
// domEvent.on(window, 'keydown', this.keydown, this);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user