Remove grid code.

This commit is contained in:
kovacsv 2022-02-21 21:21:22 +01:00
parent 7a05c62e50
commit a5f4d41455
7 changed files with 1 additions and 135 deletions

View File

@ -253,7 +253,7 @@ export class Viewer
{
this.navigation.SetContextMenuHandler (onContext);
}
SetEnvironmentMapSettings (textures, useAsBackground)
{
this.shading.SetEnvironment (textures, useAsBackground, () => {
@ -270,12 +270,6 @@ export class Viewer
this.Render ();
}
SetGridSettings (show)
{
this.geometry.SetGridSettings (show);
this.Render ();
}
SetEdgeSettings (show, color, threshold)
{
this.geometry.SetEdgeSettings (show, color, threshold);

View File

@ -1,4 +1,3 @@
import { IsEqual } from '../geometry/geometry.js';
import { Color } from '../model/color.js';
import { ConvertColorToThreeColor } from '../threejs/threeutils.js';
@ -26,12 +25,8 @@ export class ViewerGeometry
this.scene = scene;
this.mainObject = null;
this.mainGridObject = null;
this.mainEdgeObject = null;
this.gridSettings = {
showGrid : false
};
this.edgeSettings = {
showEdges : false,
edgeColor : new Color (0, 0, 0),
@ -43,10 +38,6 @@ export class ViewerGeometry
{
this.mainObject = mainObject;
this.scene.add (this.mainObject);
if (this.gridSettings.showGrid) {
this.GenerateMainGridObject ();
}
if (this.edgeSettings.showEdges) {
this.GenerateMainEdgeObject ();
}
@ -59,21 +50,6 @@ export class ViewerGeometry
}
}
SetGridSettings (show)
{
this.gridSettings.showGrid = show;
if (this.mainObject === null) {
return;
}
if (this.gridSettings.showGrid) {
this.ClearMainGridObject ();
this.GenerateMainGridObject ();
} else {
this.ClearMainGridObject ();
}
}
SetEdgeSettings (show, color, threshold)
{
let needToGenerate = false;
@ -105,67 +81,6 @@ export class ViewerGeometry
}
}
GenerateMainGridObject ()
{
function CreateLine (from, to, material)
{
let points = [from, to];
let geometry = new THREE.BufferGeometry ().setFromPoints (points);
let line = new THREE.Line (geometry, material);
return line;
}
this.UpdateWorldMatrix ();
let boundingBox = this.GetBoundingBox ((meshUserData) => {
return true;
});
if (boundingBox === null) {
return;
}
this.mainGridObject = new THREE.Object3D ();
const strongMaterial = new THREE.LineBasicMaterial ({ color: 0x888888 });
const lightMaterial = new THREE.LineBasicMaterial ({ color: 0xdddddd });
// TODO: direction handling
let boundingBoxSize = new THREE.Vector3 ();
boundingBox.getSize (boundingBoxSize);
let expandSize = 1.0;
let minValue = new THREE.Vector2 (boundingBox.min.z - expandSize, boundingBox.min.x - expandSize);
let maxValue = new THREE.Vector2 (boundingBox.max.z + expandSize, boundingBox.max.x + expandSize);
let cellSize = 1.0;
let alignedMinValue = new THREE.Vector2 (
Math.floor (minValue.x / cellSize) * cellSize,
Math.floor (minValue.y / cellSize) * cellSize
);
let alignedMaxValue = new THREE.Vector2 (
Math.ceil (maxValue.x / cellSize) * cellSize,
Math.ceil (maxValue.y / cellSize) * cellSize
);
let level = boundingBox.min.y;
let cellCountX = Math.floor ((alignedMaxValue.x - alignedMinValue.x) / cellSize);
let cellCountY = Math.floor ((alignedMaxValue.y - alignedMinValue.y) / cellSize);
for (let step = 0; step < cellCountX + 1; step++) {
let lineDist = alignedMinValue.x + step * cellSize;
let beg = new THREE.Vector3 (alignedMinValue.y, level, lineDist);
let end = new THREE.Vector3 (alignedMaxValue.y, level, lineDist);
let material = IsEqual (lineDist, 0.0) ? strongMaterial : lightMaterial;
this.mainGridObject.add (CreateLine (beg, end, material));
}
for (let step = 0; step < cellCountY + 1; step++) {
let lineDist = alignedMinValue.y + step * cellSize;
let beg = new THREE.Vector3 (lineDist, level, alignedMinValue.x);
let end = new THREE.Vector3 (lineDist, level, alignedMaxValue.x);
let material = IsEqual (lineDist, 0.0) ? strongMaterial : lightMaterial;
this.mainGridObject.add (CreateLine (beg, end, material));
}
this.scene.add (this.mainGridObject);
}
GenerateMainEdgeObject ()
{
let edgeColor = ConvertColorToThreeColor (this.edgeSettings.edgeColor);
@ -217,7 +132,6 @@ export class ViewerGeometry
Clear ()
{
this.ClearMainObject ();
this.ClearMainGridObject ();
this.ClearMainEdgeObject ();
}
@ -234,21 +148,6 @@ export class ViewerGeometry
this.mainObject = null;
}
ClearMainGridObject ()
{
if (this.mainGridObject === null) {
return;
}
this.mainGridObject.traverse ((obj) => {
if (obj.isLineSegments) {
obj.geometry.dispose ();
}
});
this.scene.remove (this.mainGridObject);
this.mainGridObject = null;
}
ClearMainEdgeObject ()
{
if (this.mainEdgeObject === null) {

View File

@ -1,6 +1,5 @@
export const FeatureSet =
{
ShowGrid : false,
MeasureTool : false,
EnvironmentMap : false
};

View File

@ -15,7 +15,6 @@ export class Settings
this.backgroundIsEnvMap = false;
this.backgroundColor = new Color (255, 255, 255);
this.defaultColor = new Color (200, 200, 200);
this.showGrid = false;
this.showEdges = false;
this.edgeColor = new Color (0, 0, 0);
this.edgeThreshold = 1;
@ -28,7 +27,6 @@ export class Settings
this.backgroundIsEnvMap = CookieGetBoolVal ('ov_background_is_envmap', false);
this.backgroundColor = CookieGetColorVal ('ov_background_color', new Color (255, 255, 255));
this.defaultColor = CookieGetColorVal ('ov_default_color', new Color (200, 200, 200));
this.showGrid = CookieGetBoolVal ('ov_show_grid', false);
this.showEdges = CookieGetBoolVal ('ov_show_edges', false);
this.edgeColor = CookieGetColorVal ('ov_edge_color', new Color (0, 0, 0));
this.edgeThreshold = CookieGetIntVal ('ov_edge_threshold', 1);
@ -41,7 +39,6 @@ export class Settings
CookieSetBoolVal ('ov_background_is_envmap', this.backgroundIsEnvMap);
CookieSetColorVal ('ov_background_color', this.backgroundColor);
CookieSetColorVal ('ov_default_color', this.defaultColor);
CookieSetBoolVal ('ov_show_grid', this.showGrid);
CookieSetBoolVal ('ov_show_edges', this.showEdges);
CookieSetColorVal ('ov_edge_color', this.edgeColor);
CookieSetIntVal ('ov_edge_threshold', this.edgeThreshold);

View File

@ -54,9 +54,6 @@ export class Sidebar
onDefaultColorChange : () => {
this.callbacks.onDefaultColorChange ();
},
onGridDisplayChange : () => {
this.callbacks.onGridDisplayChange ();
},
onEdgeDisplayChange : () => {
this.callbacks.onEdgeDisplayChange ();
},

View File

@ -427,7 +427,6 @@ export class SidebarSettingsPanel extends SidebarPanel
this.settings.backgroundIsEnvMap = defaultSettings.backgroundIsEnvMap;
this.settings.backgroundColor = defaultSettings.backgroundColor;
this.settings.defaultColor = defaultSettings.defaultColor;
this.settings.showGrid = defaultSettings.showGrid;
this.settings.showEdges = defaultSettings.showEdges;
this.settings.edgeColor = defaultSettings.edgeColor;
this.settings.edgeThreshold = defaultSettings.edgeThreshold;

View File

@ -435,12 +435,6 @@ export class Website
}
}
UpdateGridDisplay ()
{
this.settings.SaveToCookies ();
this.viewer.SetGridSettings (this.settings.showGrid);
}
UpdateEdgeDisplay ()
{
this.settings.SaveToCookies ();
@ -480,7 +474,6 @@ export class Website
{
let canvas = AddDomElement (this.parameters.viewerDiv, 'canvas');
this.viewer.Init (canvas);
this.viewer.SetGridSettings (this.settings.showGrid);
this.viewer.SetEdgeSettings (this.settings.showEdges, this.settings.edgeColor, this.settings.edgeThreshold);
this.viewer.SetBackgroundColor (this.settings.backgroundColor);
this.UpdateEnvironmentMap ();
@ -651,9 +644,6 @@ export class Website
}
this.viewer.Render ();
},
onGridDisplayChange : () => {
this.UpdateGridDisplay ();
},
onEdgeDisplayChange : () => {
HandleEvent ('edge_display_changed', this.settings.showEdges ? 'on' : 'off');
this.UpdateEdgeDisplay ();
@ -662,15 +652,6 @@ export class Website
HandleEvent ('theme_changed', this.settings.themeId === Theme.Light ? 'light' : 'dark');
this.SwitchTheme (this.settings.themeId, true);
},
/* onMeasureToolActivedChange : (isActivated) => {
if (isActivated) {
this.navigator.SetSelection (null);
this.measureTool.SetActive (true);
} else {
this.measureTool.SetActive (false);
}
this.sidebar.UpdateMeasureTool ();
},*/
onResize : () => {
this.Resize ();
},