- bug: exaggeration slicing box

- npm updates
This commit is contained in:
Arno Kaimbacher 2021-03-11 09:45:05 +01:00
parent 91e43173e5
commit 87496903e6
5 changed files with 75 additions and 49 deletions

View file

@ -12,6 +12,7 @@ export class MyMeshStandardMaterial extends MeshStandardMaterial {
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.clippingScale = this.uniforms.clippingScale; // { type: "f", value: 1.0 };

View file

@ -38,7 +38,7 @@ export class Selection extends Layer {
z1: low.z - 5000,
z2: high.z + 5000
}
this.scale = 1;
this.scale = 1.0;
this.box = new BoxGeometry(1, 1, 1);
this.boxMesh = new Mesh(this.box, material.capMaterial);
@ -113,10 +113,10 @@ export class Selection extends Layer {
scaleZ(z) {
this.scale = z;
// this.boxMesh.scale.z = z;
// this.displayMeshes.scale.z = z;
this.displayMeshes.scale.set(1, 1, z);
// this.touchMeshes.scale.z = z;
this.boxMesh.scale.z = z;
this.displayMeshes.scale.z = z;
this.touchMeshes.scale.z = z;
this.setUniforms();
}
updateVertices() {
@ -172,8 +172,11 @@ export class Selection extends Layer {
if (this.map.layers) {
for (const [key, layer] of Object.entries(this.map.layers)) {
if (layer.uniforms) {
let scale = Number(this.scale);
layer.uniforms.clipping.clippingLow.value.copy(this.limitLow);
layer.uniforms.clipping.clippingHigh.value.copy(this.limitHigh);
layer.uniforms.clipping.clippingScale.value = scale;
}
}
}

View file

@ -131,10 +131,11 @@ let shader = {
vertexMeshStandard: `
#define STANDARD
uniform float scale;
varying vec3 vViewPosition;
varying vec4 worldPosition;
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
@ -170,14 +171,20 @@ let shader = {
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
worldPosition = modelMatrix * vec4( position, 1.0 );
// position.z = position.z * scale;
worldPosition = modelMatrix * vec4( position, 1.0 );
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,
fragmentClippingMeshStandard: `
#ifdef GL_ES
precision highp float;
#endif
#define STANDARD
uniform vec3 diffuse;
@ -186,9 +193,11 @@ let shader = {
uniform float metalness;
uniform float opacity;
varying vec3 vViewPosition;
uniform vec3 clippingLow;
uniform vec3 clippingHigh;
uniform vec3 clippingHigh;
uniform float clippingScale;
varying vec4 worldPosition;
#include <common>
@ -266,8 +275,8 @@ let shader = {
|| worldPosition.x > clippingHigh.x
|| worldPosition.y < clippingLow.y
|| worldPosition.y > clippingHigh.y
|| worldPosition.z < clippingLow.z
|| worldPosition.z > clippingHigh.z
|| (worldPosition.z) < (clippingLow.z * clippingScale)
|| (worldPosition.z) > (clippingHigh.z * clippingScale)
) {
discard;
} else {

View file

@ -8,6 +8,7 @@ import { Plane } from 'three/src/math/Plane';
import { Vector3 } from 'three/src/math/Vector3';
import { Color } from 'three/src/math/Color';
import { MyMeshStandardMaterial } from '../clip/MyMeshStandardMaterial';
import { Object3D } from 'three/src/core/Object3D';
const POINTURL = 'https://geusegdi01.geus.dk/geom3d/data/nodes/';
@ -29,6 +30,7 @@ class TinLayer extends Layer {
this.queryableObjects = [];
this.borderVisible = false;
this.scale = 1;
}
setWireframeMode(wireframe) {
@ -46,7 +48,17 @@ class TinLayer extends Layer {
}
scaleZ(z) {
this.scale = z;
this.mainMesh.scale.z = z;
// let highObject = new Object3D();
// highObject.position.copy(this.uniforms.clipping.clippingHigh.value);
// let lowObject = new Object3D();
// lowObject.position.copy(this.uniforms.clipping.clippingLow.value);
// highObject.scale.z =z;
// lowObject.scale.z = z;
// this.uniforms.clipping.clippingHigh.value.z = highObject.position.z;
// this.uniforms.clipping.clippingLow.value.z = lowObject.position.z;
// this.uniforms.clipping.scale.value = z;
}
async onAdd(map) {
@ -95,6 +107,7 @@ class TinLayer extends Layer {
let uniforms = this.uniforms = {
clipping: {
clippingScale: { type: "f", value: 1.0 },
color: { type: "c", value: new Color(color) },
clippingLow: { type: "v3", value: new Vector3(0, 0, 0) },
clippingHigh: { type: "v3", value: new Vector3(0, 0, 0) }
@ -103,7 +116,7 @@ class TinLayer extends Layer {
this.material = new MyMeshStandardMaterial({
color: color,
metalness: 0.1,
roughness: 0.75,
roughness: 0.75,
flatShading: true,
side: DoubleSide,
clippingPlanes: [this.xLocalPlane, this.yLocalPlane],