From dc6bf928e3bc36386118102466785fa9afefca0b Mon Sep 17 00:00:00 2001 From: Mikhail <94560571+mikhailmtion@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:11:35 +0300 Subject: [PATCH 01/12] Update main.js --- example/main.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/example/main.js b/example/main.js index 096cb4bc..3e8937ca 100644 --- a/example/main.js +++ b/example/main.js @@ -108,7 +108,7 @@ viewer.IFC.loader.ifcManager.applyWebIfcConfig({ COORDINATE_TO_ORIGIN: true }); -viewer.context.renderer.postProduction.active = true; +// viewer.context.renderer.postProduction.active = true; // Setup loader @@ -196,19 +196,11 @@ const handleKeyDown = async (event) => { } }; -window.onmousemove = () => viewer.IFC.selector.prePickIfcItem(); +// window.onmousemove = () => viewer.IFC.selector.prePickIfcItem(); window.onkeydown = handleKeyDown; window.ondblclick = async () => { - - if (viewer.clipper.active) { - viewer.clipper.createPlane(); - } else { - const result = await viewer.IFC.selector.highlightIfcItem(true); - if (!result) return; - const { modelID, id } = result; - const props = await viewer.IFC.getProperties(modelID, id, true, false); - console.log(props); - } + viewer.dimensions.create() + console.log(1) }; //Setup UI @@ -227,5 +219,6 @@ sectionButton.addEventListener('click', () => { const dropBoxButton = createSideMenuButton('./resources/dropbox-icon.svg'); dropBoxButton.addEventListener('click', () => { dropBoxButton.blur(); - viewer.dropbox.loadDropboxIfc(); + viewer.dimensions.active = true; + viewer.dimensions.previewActive = true; }); \ No newline at end of file From d6a8039ad80b88b1a72b24937c9cff4892f3478f Mon Sep 17 00:00:00 2001 From: Mikhail <94560571+mikhailmtion@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:22:52 +0300 Subject: [PATCH 02/12] Add currentDimensionIn2D and draw2DDimension --- example/build/main.js | 37 +++++++++++-------- .../display/dimensions/dimensions.ts | 29 ++++++++++++++- 2 files changed, 48 insertions(+), 18 deletions(-) diff --git a/example/build/main.js b/example/build/main.js index ab50f5ef..d8e637bb 100644 --- a/example/build/main.js +++ b/example/build/main.js @@ -110343,6 +110343,7 @@ this.dimensions.forEach((dim) => dim.dispose()); this.dimensions = null; this.currentDimension = null; + this.currentDimensionIn2D = null; this.endpoint.dispose(); this.endpoint = null; this.previewElement.removeFromParent(); @@ -110458,12 +110459,14 @@ this.dimensions = []; } cancelDrawing() { - var _a; - if (!this.currentDimension) + var _a, _b; + if (!this.currentDimension || !this.currentDimensionIn2D) return; this.dragging = false; (_a = this.currentDimension) === null || _a === void 0 ? void 0 : _a.removeFromScene(); this.currentDimension = undefined; + (_b = this.currentDimensionIn2D) === null || _b === void 0 ? void 0 : _b.removeFromScene(); + this.currentDimensionIn2D = undefined; } setDimensionUnit(units) { if (!units) @@ -110504,14 +110507,20 @@ this.endPoint = found; if (!this.currentDimension) this.currentDimension = this.drawDimension(); + if (!this.currentDimensionIn2D) + this.currentDimensionIn2D = this.draw2DDimension(); this.currentDimension.endPoint = this.endPoint; + this.currentDimensionIn2D.endPoint = this.endPoint.setY(this.startPoint.y); } drawEnd() { - if (!this.currentDimension) + if (!this.currentDimension || !this.currentDimensionIn2D) return; this.currentDimension.createBoundingBox(); this.dimensions.push(this.currentDimension); + this.currentDimensionIn2D.createBoundingBox(); + this.dimensions.push(this.currentDimensionIn2D); this.currentDimension = undefined; + this.currentDimensionIn2D = undefined; this.dragging = false; } get getDimensionsLines() { @@ -110520,6 +110529,9 @@ drawDimension() { return new IfcDimensionLine(this.context, this.startPoint, this.endPoint, this.lineMaterial, this.endpointsMaterial, this.endpoint, this.labelClassName, this.baseScale); } + draw2DDimension() { + return new IfcDimensionLine(this.context, this.startPoint, this.endPoint, this.lineMaterial, this.endpointsMaterial, this.endpoint, this.labelClassName, this.baseScale); + } getBoundingBoxes() { return this.dimensions .map((dim) => dim.boundingBox) @@ -138355,7 +138367,7 @@ COORDINATE_TO_ORIGIN: true }); - viewer.context.renderer.postProduction.active = true; + // viewer.context.renderer.postProduction.active = true; // Setup loader @@ -138443,19 +138455,11 @@ } }; - window.onmousemove = () => viewer.IFC.selector.prePickIfcItem(); + // window.onmousemove = () => viewer.IFC.selector.prePickIfcItem(); window.onkeydown = handleKeyDown; window.ondblclick = async () => { - - if (viewer.clipper.active) { - viewer.clipper.createPlane(); - } else { - const result = await viewer.IFC.selector.highlightIfcItem(true); - if (!result) return; - const { modelID, id } = result; - const props = await viewer.IFC.getProperties(modelID, id, true, false); - console.log(props); - } + viewer.dimensions.create(); + console.log(1); }; //Setup UI @@ -138474,7 +138478,8 @@ const dropBoxButton = createSideMenuButton('./resources/dropbox-icon.svg'); dropBoxButton.addEventListener('click', () => { dropBoxButton.blur(); - viewer.dropbox.loadDropboxIfc(); + viewer.dimensions.active = true; + viewer.dimensions.previewActive = true; }); }()); diff --git a/viewer/src/components/display/dimensions/dimensions.ts b/viewer/src/components/display/dimensions/dimensions.ts index c54d9e92..cd5cc8a0 100644 --- a/viewer/src/components/display/dimensions/dimensions.ts +++ b/viewer/src/components/display/dimensions/dimensions.ts @@ -18,6 +18,7 @@ export class IfcDimensions extends IfcComponent { private readonly context: IfcContext; private dimensions: IfcDimensionLine[] = []; private currentDimension?: IfcDimensionLine; + private currentDimensionIn2D?: IfcDimensionLine; readonly labelClassName = 'ifcjs-dimension-label'; readonly previewClassName = 'ifcjs-dimension-preview'; @@ -65,6 +66,7 @@ export class IfcDimensions extends IfcComponent { this.dimensions.forEach((dim) => dim.dispose()); (this.dimensions as any) = null; (this.currentDimension as any) = null; + (this.currentDimensionIn2D as any) = null; this.endpoint.dispose(); (this.endpoint as any) = null; @@ -191,10 +193,13 @@ export class IfcDimensions extends IfcComponent { } cancelDrawing() { - if (!this.currentDimension) return; + if (!this.currentDimension || !this.currentDimensionIn2D) return; this.dragging = false; this.currentDimension?.removeFromScene(); this.currentDimension = undefined; + + this.currentDimensionIn2D?.removeFromScene(); + this.currentDimensionIn2D = undefined; } setDimensionUnit(units: string) { @@ -232,14 +237,21 @@ export class IfcDimensions extends IfcComponent { if (!found) return; this.endPoint = found; if (!this.currentDimension) this.currentDimension = this.drawDimension(); + if (!this.currentDimensionIn2D) this.currentDimensionIn2D = this.draw2DDimension(); this.currentDimension.endPoint = this.endPoint; + this.currentDimensionIn2D.endPoint = this.endPoint.setY(this.startPoint.y); } private drawEnd() { - if (!this.currentDimension) return; + if (!this.currentDimension || !this.currentDimensionIn2D) return; this.currentDimension.createBoundingBox(); this.dimensions.push(this.currentDimension); + + this.currentDimensionIn2D.createBoundingBox(); + this.dimensions.push(this.currentDimensionIn2D); + this.currentDimension = undefined; + this.currentDimensionIn2D = undefined; this.dragging = false; } @@ -260,6 +272,19 @@ export class IfcDimensions extends IfcComponent { ); } + private draw2DDimension() { + return new IfcDimensionLine( + this.context, + this.startPoint, + this.endPoint, + this.lineMaterial, + this.endpointsMaterial, + this.endpoint, + this.labelClassName, + this.baseScale + ); + } + private getBoundingBoxes() { return this.dimensions .map((dim) => dim.boundingBox) From 663b1e40e7312a92d626983fb2dc95f88610b301 Mon Sep 17 00:00:00 2001 From: Mikhail <94560571+mikhailmtion@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:25:14 +0300 Subject: [PATCH 03/12] Delete currentDimension if active 2D --- example/build/main.js | 2 ++ viewer/src/components/display/dimensions/dimensions.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/example/build/main.js b/example/build/main.js index d8e637bb..44d96a35 100644 --- a/example/build/main.js +++ b/example/build/main.js @@ -110513,12 +110513,14 @@ this.currentDimensionIn2D.endPoint = this.endPoint.setY(this.startPoint.y); } drawEnd() { + var _a; if (!this.currentDimension || !this.currentDimensionIn2D) return; this.currentDimension.createBoundingBox(); this.dimensions.push(this.currentDimension); this.currentDimensionIn2D.createBoundingBox(); this.dimensions.push(this.currentDimensionIn2D); + (_a = this.currentDimension) === null || _a === void 0 ? void 0 : _a.removeFromScene(); this.currentDimension = undefined; this.currentDimensionIn2D = undefined; this.dragging = false; diff --git a/viewer/src/components/display/dimensions/dimensions.ts b/viewer/src/components/display/dimensions/dimensions.ts index cd5cc8a0..7a221218 100644 --- a/viewer/src/components/display/dimensions/dimensions.ts +++ b/viewer/src/components/display/dimensions/dimensions.ts @@ -250,6 +250,7 @@ export class IfcDimensions extends IfcComponent { this.currentDimensionIn2D.createBoundingBox(); this.dimensions.push(this.currentDimensionIn2D); + this.currentDimension?.removeFromScene(); this.currentDimension = undefined; this.currentDimensionIn2D = undefined; this.dragging = false; From bbbfaf8db628f32e90b0f5ca2cda17d959ec2db8 Mon Sep 17 00:00:00 2001 From: Mikhail <94560571+mikhailmtion@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:55:08 +0300 Subject: [PATCH 04/12] Replace logic 2D --- example/build/main.js | 8 ++++---- viewer/src/components/display/dimensions/dimensions.ts | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/example/build/main.js b/example/build/main.js index 44d96a35..2dde4fce 100644 --- a/example/build/main.js +++ b/example/build/main.js @@ -110507,17 +110507,17 @@ this.endPoint = found; if (!this.currentDimension) this.currentDimension = this.drawDimension(); - if (!this.currentDimensionIn2D) - this.currentDimensionIn2D = this.draw2DDimension(); this.currentDimension.endPoint = this.endPoint; - this.currentDimensionIn2D.endPoint = this.endPoint.setY(this.startPoint.y); } drawEnd() { var _a; - if (!this.currentDimension || !this.currentDimensionIn2D) + if (!this.currentDimension) return; this.currentDimension.createBoundingBox(); this.dimensions.push(this.currentDimension); + if (!this.currentDimensionIn2D) + this.currentDimensionIn2D = this.draw2DDimension(); + this.currentDimensionIn2D.endPoint = this.endPoint.setY(this.startPoint.y); this.currentDimensionIn2D.createBoundingBox(); this.dimensions.push(this.currentDimensionIn2D); (_a = this.currentDimension) === null || _a === void 0 ? void 0 : _a.removeFromScene(); diff --git a/viewer/src/components/display/dimensions/dimensions.ts b/viewer/src/components/display/dimensions/dimensions.ts index 7a221218..f9b44738 100644 --- a/viewer/src/components/display/dimensions/dimensions.ts +++ b/viewer/src/components/display/dimensions/dimensions.ts @@ -237,16 +237,18 @@ export class IfcDimensions extends IfcComponent { if (!found) return; this.endPoint = found; if (!this.currentDimension) this.currentDimension = this.drawDimension(); - if (!this.currentDimensionIn2D) this.currentDimensionIn2D = this.draw2DDimension(); + this.currentDimension.endPoint = this.endPoint; - this.currentDimensionIn2D.endPoint = this.endPoint.setY(this.startPoint.y); + } private drawEnd() { - if (!this.currentDimension || !this.currentDimensionIn2D) return; + if (!this.currentDimension) return; this.currentDimension.createBoundingBox(); this.dimensions.push(this.currentDimension); + if (!this.currentDimensionIn2D) this.currentDimensionIn2D = this.draw2DDimension(); + this.currentDimensionIn2D.endPoint = this.endPoint.setY(this.startPoint.y); this.currentDimensionIn2D.createBoundingBox(); this.dimensions.push(this.currentDimensionIn2D); From fe3acbb2d3d3f29b5dbd9b7177fc98d52d735187 Mon Sep 17 00:00:00 2001 From: Mikhail <94560571+mikhailmtion@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:24:04 +0300 Subject: [PATCH 05/12] Add type dimension units --- viewer/src/components/display/dimensions/dimensions.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/viewer/src/components/display/dimensions/dimensions.ts b/viewer/src/components/display/dimensions/dimensions.ts index f9b44738..c60ea2e4 100644 --- a/viewer/src/components/display/dimensions/dimensions.ts +++ b/viewer/src/components/display/dimensions/dimensions.ts @@ -14,6 +14,8 @@ import { IfcComponent } from '../../../base-types'; import { IfcDimensionLine } from './dimension-line'; import { IfcContext } from '../../context'; +type DimensionUnits = "m" | "mm"; + export class IfcDimensions extends IfcComponent { private readonly context: IfcContext; private dimensions: IfcDimensionLine[] = []; @@ -202,7 +204,7 @@ export class IfcDimensions extends IfcComponent { this.currentDimensionIn2D = undefined; } - setDimensionUnit(units: string) { + setDimensionUnit(units: DimensionUnits) { if (!units) return; if (units === "mm") { IfcDimensionLine.units = units; From 502c024f8179e4b5b8b7abf74b7384a316f443c8 Mon Sep 17 00:00:00 2001 From: Mikhail <94560571+mikhailmtion@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:57:15 +0300 Subject: [PATCH 06/12] Add to delete method toggleDimensionIn2D --- example/build/main.js | 33 +++++++++++++++---- example/main.js | 12 +++++++ .../display/dimensions/dimensions.ts | 21 ++++++++---- 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/example/build/main.js b/example/build/main.js index 2dde4fce..0515d3a5 100644 --- a/example/build/main.js +++ b/example/build/main.js @@ -110319,6 +110319,7 @@ this.snapDistance = 0.25; // Measures this.baseScale = new Vector3(1, 1, 1); + this.dimensionIn2D = false; // Materials this.lineMaterial = new LineDashedMaterial({ color: 0x000000, @@ -110457,6 +110458,7 @@ dim.removeFromScene(); }); this.dimensions = []; + this.toggleDimensionIn2D(); } cancelDrawing() { var _a, _b; @@ -110480,6 +110482,9 @@ IfcDimensionLine.scale = 1; } } + toggleDimensionIn2D() { + this.dimensionIn2D ? this.dimensionIn2D = false : this.dimensionIn2D = true; + } drawStart() { this.dragging = true; const intersects = this.context.castRayIfc(); @@ -110515,14 +110520,16 @@ return; this.currentDimension.createBoundingBox(); this.dimensions.push(this.currentDimension); - if (!this.currentDimensionIn2D) - this.currentDimensionIn2D = this.draw2DDimension(); - this.currentDimensionIn2D.endPoint = this.endPoint.setY(this.startPoint.y); - this.currentDimensionIn2D.createBoundingBox(); - this.dimensions.push(this.currentDimensionIn2D); - (_a = this.currentDimension) === null || _a === void 0 ? void 0 : _a.removeFromScene(); + if (this.dimensionIn2D) { + if (!this.currentDimensionIn2D) + this.currentDimensionIn2D = this.draw2DDimension(); + this.currentDimensionIn2D.endPoint = this.endPoint.setY(this.startPoint.y); + this.currentDimensionIn2D.createBoundingBox(); + this.dimensions.push(this.currentDimensionIn2D); + this.currentDimensionIn2D = undefined; + (_a = this.currentDimension) === null || _a === void 0 ? void 0 : _a.removeFromScene(); + } this.currentDimension = undefined; - this.currentDimensionIn2D = undefined; this.dragging = false; } get getDimensionsLines() { @@ -138484,4 +138491,16 @@ viewer.dimensions.previewActive = true; }); + const d = createSideMenuButton('./resources/dropbox-icon.svg'); + d.addEventListener('click', () => { + d.blur(); + viewer.dimensions.toggleDimensionIn2D(); + }); + + const a = createSideMenuButton('./resources/dropbox-icon.svg'); + a.addEventListener('click', () => { + a.blur(); + viewer.dimensions.deleteAll(); + }); + }()); diff --git a/example/main.js b/example/main.js index 3e8937ca..bdcc4523 100644 --- a/example/main.js +++ b/example/main.js @@ -221,4 +221,16 @@ dropBoxButton.addEventListener('click', () => { dropBoxButton.blur(); viewer.dimensions.active = true; viewer.dimensions.previewActive = true; +}); + +const d = createSideMenuButton('./resources/dropbox-icon.svg'); +d.addEventListener('click', () => { + d.blur(); + viewer.dimensions.toggleDimensionIn2D() +}); + +const a = createSideMenuButton('./resources/dropbox-icon.svg'); +a.addEventListener('click', () => { + a.blur(); + viewer.dimensions.deleteAll() }); \ No newline at end of file diff --git a/viewer/src/components/display/dimensions/dimensions.ts b/viewer/src/components/display/dimensions/dimensions.ts index c60ea2e4..0164fced 100644 --- a/viewer/src/components/display/dimensions/dimensions.ts +++ b/viewer/src/components/display/dimensions/dimensions.ts @@ -33,6 +33,7 @@ export class IfcDimensions extends IfcComponent { // Measures private baseScale = new Vector3(1, 1, 1); + private dimensionIn2D = false; // Geometries private endpoint: BufferGeometry; @@ -192,6 +193,7 @@ export class IfcDimensions extends IfcComponent { dim.removeFromScene(); }); this.dimensions = []; + this.toggleDimensionIn2D() } cancelDrawing() { @@ -215,6 +217,10 @@ export class IfcDimensions extends IfcComponent { } } + toggleDimensionIn2D() { + this.dimensionIn2D ? this.dimensionIn2D = false : this.dimensionIn2D = true + } + private drawStart() { this.dragging = true; const intersects = this.context.castRayIfc(); @@ -241,7 +247,6 @@ export class IfcDimensions extends IfcComponent { if (!this.currentDimension) this.currentDimension = this.drawDimension(); this.currentDimension.endPoint = this.endPoint; - } private drawEnd() { @@ -249,14 +254,16 @@ export class IfcDimensions extends IfcComponent { this.currentDimension.createBoundingBox(); this.dimensions.push(this.currentDimension); - if (!this.currentDimensionIn2D) this.currentDimensionIn2D = this.draw2DDimension(); - this.currentDimensionIn2D.endPoint = this.endPoint.setY(this.startPoint.y); - this.currentDimensionIn2D.createBoundingBox(); - this.dimensions.push(this.currentDimensionIn2D); + if (this.dimensionIn2D) { + if (!this.currentDimensionIn2D) this.currentDimensionIn2D = this.draw2DDimension(); + this.currentDimensionIn2D.endPoint = this.endPoint.setY(this.startPoint.y); + this.currentDimensionIn2D.createBoundingBox(); + this.dimensions.push(this.currentDimensionIn2D); + this.currentDimensionIn2D = undefined; + this.currentDimension?.removeFromScene(); + } - this.currentDimension?.removeFromScene(); this.currentDimension = undefined; - this.currentDimensionIn2D = undefined; this.dragging = false; } From 84062b02fba40ba33c321dff6b5a547cbb55e526 Mon Sep 17 00:00:00 2001 From: Mikhail <94560571+mikhailmtion@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:59:22 +0300 Subject: [PATCH 07/12] Reset example to initial state --- example/build/main.js | 31 +++++++++++++------------------ example/main.js | 31 +++++++++++++------------------ 2 files changed, 26 insertions(+), 36 deletions(-) diff --git a/example/build/main.js b/example/build/main.js index 0515d3a5..a40544dc 100644 --- a/example/build/main.js +++ b/example/build/main.js @@ -138376,7 +138376,7 @@ COORDINATE_TO_ORIGIN: true }); - // viewer.context.renderer.postProduction.active = true; + viewer.context.renderer.postProduction.active = true; // Setup loader @@ -138464,11 +138464,19 @@ } }; - // window.onmousemove = () => viewer.IFC.selector.prePickIfcItem(); + window.onmousemove = () => viewer.IFC.selector.prePickIfcItem(); window.onkeydown = handleKeyDown; window.ondblclick = async () => { - viewer.dimensions.create(); - console.log(1); + + if (viewer.clipper.active) { + viewer.clipper.createPlane(); + } else { + const result = await viewer.IFC.selector.highlightIfcItem(true); + if (!result) return; + const { modelID, id } = result; + const props = await viewer.IFC.getProperties(modelID, id, true, false); + console.log(props); + } }; //Setup UI @@ -138487,20 +138495,7 @@ const dropBoxButton = createSideMenuButton('./resources/dropbox-icon.svg'); dropBoxButton.addEventListener('click', () => { dropBoxButton.blur(); - viewer.dimensions.active = true; - viewer.dimensions.previewActive = true; - }); - - const d = createSideMenuButton('./resources/dropbox-icon.svg'); - d.addEventListener('click', () => { - d.blur(); - viewer.dimensions.toggleDimensionIn2D(); - }); - - const a = createSideMenuButton('./resources/dropbox-icon.svg'); - a.addEventListener('click', () => { - a.blur(); - viewer.dimensions.deleteAll(); + viewer.dropbox.loadDropboxIfc(); }); }()); diff --git a/example/main.js b/example/main.js index bdcc4523..096cb4bc 100644 --- a/example/main.js +++ b/example/main.js @@ -108,7 +108,7 @@ viewer.IFC.loader.ifcManager.applyWebIfcConfig({ COORDINATE_TO_ORIGIN: true }); -// viewer.context.renderer.postProduction.active = true; +viewer.context.renderer.postProduction.active = true; // Setup loader @@ -196,11 +196,19 @@ const handleKeyDown = async (event) => { } }; -// window.onmousemove = () => viewer.IFC.selector.prePickIfcItem(); +window.onmousemove = () => viewer.IFC.selector.prePickIfcItem(); window.onkeydown = handleKeyDown; window.ondblclick = async () => { - viewer.dimensions.create() - console.log(1) + + if (viewer.clipper.active) { + viewer.clipper.createPlane(); + } else { + const result = await viewer.IFC.selector.highlightIfcItem(true); + if (!result) return; + const { modelID, id } = result; + const props = await viewer.IFC.getProperties(modelID, id, true, false); + console.log(props); + } }; //Setup UI @@ -219,18 +227,5 @@ sectionButton.addEventListener('click', () => { const dropBoxButton = createSideMenuButton('./resources/dropbox-icon.svg'); dropBoxButton.addEventListener('click', () => { dropBoxButton.blur(); - viewer.dimensions.active = true; - viewer.dimensions.previewActive = true; -}); - -const d = createSideMenuButton('./resources/dropbox-icon.svg'); -d.addEventListener('click', () => { - d.blur(); - viewer.dimensions.toggleDimensionIn2D() -}); - -const a = createSideMenuButton('./resources/dropbox-icon.svg'); -a.addEventListener('click', () => { - a.blur(); - viewer.dimensions.deleteAll() + viewer.dropbox.loadDropboxIfc(); }); \ No newline at end of file From f9815b16746c622b97d035e340de21fe90b1d65a Mon Sep 17 00:00:00 2001 From: Mikhail <94560571+mikhailmtion@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:36:21 +0300 Subject: [PATCH 08/12] Updaye main.js build file --- example/build/main.js | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/example/build/main.js b/example/build/main.js index a40544dc..ab50f5ef 100644 --- a/example/build/main.js +++ b/example/build/main.js @@ -110319,7 +110319,6 @@ this.snapDistance = 0.25; // Measures this.baseScale = new Vector3(1, 1, 1); - this.dimensionIn2D = false; // Materials this.lineMaterial = new LineDashedMaterial({ color: 0x000000, @@ -110344,7 +110343,6 @@ this.dimensions.forEach((dim) => dim.dispose()); this.dimensions = null; this.currentDimension = null; - this.currentDimensionIn2D = null; this.endpoint.dispose(); this.endpoint = null; this.previewElement.removeFromParent(); @@ -110458,17 +110456,14 @@ dim.removeFromScene(); }); this.dimensions = []; - this.toggleDimensionIn2D(); } cancelDrawing() { - var _a, _b; - if (!this.currentDimension || !this.currentDimensionIn2D) + var _a; + if (!this.currentDimension) return; this.dragging = false; (_a = this.currentDimension) === null || _a === void 0 ? void 0 : _a.removeFromScene(); this.currentDimension = undefined; - (_b = this.currentDimensionIn2D) === null || _b === void 0 ? void 0 : _b.removeFromScene(); - this.currentDimensionIn2D = undefined; } setDimensionUnit(units) { if (!units) @@ -110482,9 +110477,6 @@ IfcDimensionLine.scale = 1; } } - toggleDimensionIn2D() { - this.dimensionIn2D ? this.dimensionIn2D = false : this.dimensionIn2D = true; - } drawStart() { this.dragging = true; const intersects = this.context.castRayIfc(); @@ -110515,20 +110507,10 @@ this.currentDimension.endPoint = this.endPoint; } drawEnd() { - var _a; if (!this.currentDimension) return; this.currentDimension.createBoundingBox(); this.dimensions.push(this.currentDimension); - if (this.dimensionIn2D) { - if (!this.currentDimensionIn2D) - this.currentDimensionIn2D = this.draw2DDimension(); - this.currentDimensionIn2D.endPoint = this.endPoint.setY(this.startPoint.y); - this.currentDimensionIn2D.createBoundingBox(); - this.dimensions.push(this.currentDimensionIn2D); - this.currentDimensionIn2D = undefined; - (_a = this.currentDimension) === null || _a === void 0 ? void 0 : _a.removeFromScene(); - } this.currentDimension = undefined; this.dragging = false; } @@ -110538,9 +110520,6 @@ drawDimension() { return new IfcDimensionLine(this.context, this.startPoint, this.endPoint, this.lineMaterial, this.endpointsMaterial, this.endpoint, this.labelClassName, this.baseScale); } - draw2DDimension() { - return new IfcDimensionLine(this.context, this.startPoint, this.endPoint, this.lineMaterial, this.endpointsMaterial, this.endpoint, this.labelClassName, this.baseScale); - } getBoundingBoxes() { return this.dimensions .map((dim) => dim.boundingBox) From 816c548291a588c1ba91f387905bf14e7a06cadb Mon Sep 17 00:00:00 2001 From: Mikhail <94560571+mikhailmtion@users.noreply.github.com> Date: Thu, 3 Aug 2023 12:52:33 +0300 Subject: [PATCH 09/12] Update setter in setToggleDimensionIn2D --- viewer/src/components/display/dimensions/dimensions.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/viewer/src/components/display/dimensions/dimensions.ts b/viewer/src/components/display/dimensions/dimensions.ts index 0164fced..c35a0ba6 100644 --- a/viewer/src/components/display/dimensions/dimensions.ts +++ b/viewer/src/components/display/dimensions/dimensions.ts @@ -193,7 +193,6 @@ export class IfcDimensions extends IfcComponent { dim.removeFromScene(); }); this.dimensions = []; - this.toggleDimensionIn2D() } cancelDrawing() { @@ -217,8 +216,12 @@ export class IfcDimensions extends IfcComponent { } } - toggleDimensionIn2D() { - this.dimensionIn2D ? this.dimensionIn2D = false : this.dimensionIn2D = true + setToggleDimensionIn2D(state: boolean) { + if (state) { + this.dimensionIn2D = true + } else { + this.dimensionIn2D = false + } } private drawStart() { From 65a20ab083be6d1d561842c5e956e9be45e7430b Mon Sep 17 00:00:00 2001 From: Mikhail <94560571+mikhailmtion@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:07:17 +0300 Subject: [PATCH 10/12] Updayte setDimensionIn2D --- viewer/src/components/display/dimensions/dimensions.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/viewer/src/components/display/dimensions/dimensions.ts b/viewer/src/components/display/dimensions/dimensions.ts index c35a0ba6..b90a127e 100644 --- a/viewer/src/components/display/dimensions/dimensions.ts +++ b/viewer/src/components/display/dimensions/dimensions.ts @@ -217,11 +217,7 @@ export class IfcDimensions extends IfcComponent { } setToggleDimensionIn2D(state: boolean) { - if (state) { - this.dimensionIn2D = true - } else { - this.dimensionIn2D = false - } + this.dimensionIn2D = state } private drawStart() { From 72fbe4e779bbe54f126a047b06d1a1505470f9a4 Mon Sep 17 00:00:00 2001 From: Mikhail <94560571+mikhailmtion@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:07:44 +0300 Subject: [PATCH 11/12] Update setDimensionIn2D --- viewer/src/components/display/dimensions/dimensions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viewer/src/components/display/dimensions/dimensions.ts b/viewer/src/components/display/dimensions/dimensions.ts index b90a127e..42276fe3 100644 --- a/viewer/src/components/display/dimensions/dimensions.ts +++ b/viewer/src/components/display/dimensions/dimensions.ts @@ -216,7 +216,7 @@ export class IfcDimensions extends IfcComponent { } } - setToggleDimensionIn2D(state: boolean) { + setDimensionIn2D(state: boolean) { this.dimensionIn2D = state } From b98a10005b62d54916ceda4e973dd4d547cba0a2 Mon Sep 17 00:00:00 2001 From: Mikhail <94560571+mikhailmtion@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:42:54 +0300 Subject: [PATCH 12/12] Create setter --- viewer/src/components/display/dimensions/dimensions.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/viewer/src/components/display/dimensions/dimensions.ts b/viewer/src/components/display/dimensions/dimensions.ts index 42276fe3..e955c157 100644 --- a/viewer/src/components/display/dimensions/dimensions.ts +++ b/viewer/src/components/display/dimensions/dimensions.ts @@ -216,8 +216,8 @@ export class IfcDimensions extends IfcComponent { } } - setDimensionIn2D(state: boolean) { - this.dimensionIn2D = state + set setDimensionIn2D(state: boolean) { + this.dimensionIn2D = state; } private drawStart() {