From 6b74e7a9c7ca39b25e046e4986136734dfcb6a63 Mon Sep 17 00:00:00 2001 From: blackboots <47943405+aka-blackboots@users.noreply.github.com> Date: Mon, 27 Oct 2025 00:55:00 +0530 Subject: [PATCH 1/2] progress --- main/opengeometry-three/src/primitives/line.ts | 5 +++++ main/opengeometry-three/src/shapes/opening.ts | 4 +++- main/opengeometry/Cargo.toml | 4 +++- main/opengeometry/src/primitives/line.rs | 9 +++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/main/opengeometry-three/src/primitives/line.ts b/main/opengeometry-three/src/primitives/line.ts index eefe777..0bb6cda 100644 --- a/main/opengeometry-three/src/primitives/line.ts +++ b/main/opengeometry-three/src/primitives/line.ts @@ -80,4 +80,9 @@ export class Line extends THREE.Line { this.geometry = geometry; this.material = new THREE.LineBasicMaterial({ color: this.options.color }); } + + getDXF() { + const dxfData = this.line.get_dxf_serialized(); + return dxfData; + } } diff --git a/main/opengeometry-three/src/shapes/opening.ts b/main/opengeometry-three/src/shapes/opening.ts index d675eec..fda01ce 100644 --- a/main/opengeometry-three/src/shapes/opening.ts +++ b/main/opengeometry-three/src/shapes/opening.ts @@ -109,7 +109,9 @@ export class Opening extends THREE.Mesh { const material = new THREE.MeshStandardMaterial({ color: this.options.color, transparent: true, - opacity: 0.6, + opacity: 0, + // Disable depth writing for transparent materials, so that we can see through openings and elements behind them + depthWrite: false, }); geometry.computeVertexNormals(); diff --git a/main/opengeometry/Cargo.toml b/main/opengeometry/Cargo.toml index 3d61163..5a29059 100644 --- a/main/opengeometry/Cargo.toml +++ b/main/opengeometry/Cargo.toml @@ -18,4 +18,6 @@ serde_json = "1.0.127" web-sys = { version = "0.3", features = ["console"] } openmaths = "0.2.4" uuid = { version = "1.17.0", features = ["v4", "serde", "js"] } -earcutr = "=0.3.0" \ No newline at end of file +getrandom = { version = "0.2", features = ["js"] } +earcutr = "=0.3.0" +dxf = "0.6.0" \ No newline at end of file diff --git a/main/opengeometry/src/primitives/line.rs b/main/opengeometry/src/primitives/line.rs index 45790c2..b1a4d0b 100644 --- a/main/opengeometry/src/primitives/line.rs +++ b/main/opengeometry/src/primitives/line.rs @@ -12,6 +12,8 @@ use wasm_bindgen::prelude::*; use serde::{Serialize, Deserialize}; use openmaths::Vector3; use uuid::Uuid; +use dxf::Drawing; +use dxf::entities::*; #[wasm_bindgen] #[derive(Clone, Serialize, Deserialize)] @@ -104,4 +106,11 @@ impl OGLine { let vertex_serialized = serde_json::to_string(&vertex_buffer).unwrap(); vertex_serialized } + + pub fn get_dxf_serialized(&self) -> String { + let mut drawing = Drawing::new(); + let added_entity_ref = drawing.add_entity(Entity::new(EntityType::Line(Line::default()))); + // `added_entity_ref` is a reference to the newly added entity + let data = drawing. + } } \ No newline at end of file From 0f06a8a48220f425982789cc22003d264f2bbf9d Mon Sep 17 00:00:00 2001 From: blackboots <47943405+aka-blackboots@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:05:33 +0530 Subject: [PATCH 2/2] Polygon changes --- main/opengeometry-three/src/shapes/cuboid.ts | 4 +- main/opengeometry-three/src/shapes/polygon.ts | 46 ++++++++++++------- main/opengeometry/src/primitives/line.rs | 6 +-- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/main/opengeometry-three/src/shapes/cuboid.ts b/main/opengeometry-three/src/shapes/cuboid.ts index 11bac95..28b2bbb 100644 --- a/main/opengeometry-three/src/shapes/cuboid.ts +++ b/main/opengeometry-three/src/shapes/cuboid.ts @@ -60,7 +60,7 @@ export class Cuboid extends THREE.Mesh { setConfig(options: ICuboidOptions) { this.validateOptions(); - const { width, height, depth, center } = options; + const { width, height, depth, center, color } = options; this.cuboid.set_config( center.clone(), width, @@ -68,6 +68,8 @@ export class Cuboid extends THREE.Mesh { depth ); + this.options.color = color; + this.generateGeometry(); } diff --git a/main/opengeometry-three/src/shapes/polygon.ts b/main/opengeometry-three/src/shapes/polygon.ts index 9706962..acc092f 100644 --- a/main/opengeometry-three/src/shapes/polygon.ts +++ b/main/opengeometry-three/src/shapes/polygon.ts @@ -3,21 +3,21 @@ import { OGPolygon, Vector3 } from "../../../opengeometry/pkg/opengeometry"; import { getUUID } from "../utils/randomizer"; interface IPolygonOptions { + ogid?: string; vertices: Vector3[]; + color: number; } export class Polygon extends THREE.Mesh { ogid: string; - options: IPolygonOptions = { vertices: [] }; + options: IPolygonOptions = { vertices: [], color: 0x00ff00 }; polygon: OGPolygon; #outlineMesh: THREE.Line | null = null; - #color: number = 0x00ff00; - transformationMatrix: THREE.Matrix4 = new THREE.Matrix4(); set color(color: number) { - this.#color = color; + this.options.color = color; if (this.material instanceof THREE.MeshStandardMaterial) { this.material.color.set(color); } @@ -33,14 +33,13 @@ export class Polygon extends THREE.Mesh { // constructor(vertices?: Vector3[]) // If no vertices are provided, it will be an empty polygon constructor(options?: IPolygonOptions) { super(); - this.ogid = getUUID(); - if (options) { - this.options = options; - } + this.ogid = options?.ogid ?? getUUID(); this.polygon = new OGPolygon(this.ogid); + + this.options = { ...this.options, ...options }; + this.options.ogid = this.ogid; - this.setConfig(); - this.generateGeometry(); + this.setConfig(this.options); // TODO: THIS MIGHT HELP WITH SHARING THE POSITION with KERNEL when something is changed // const originalSet = this.position.set.bind(this.position); @@ -64,10 +63,15 @@ export class Polygon extends THREE.Mesh { } } - setConfig() { + setConfig(options: IPolygonOptions) { this.validateOptions(); - const { vertices } = this.options; + + const { vertices, color } = options; this.polygon.set_config(vertices); + + this.options.color = color; + + this.generateGeometry(); } // /** @@ -128,7 +132,17 @@ export class Polygon extends THREE.Mesh { // return this._yaw; // } + cleanGeometry() { + this.geometry.dispose(); + if (Array.isArray(this.material)) { + this.material.forEach(mat => mat.dispose()); + } else { + this.material.dispose(); + } + } + generateGeometry() { + this.cleanGeometry(); // this.updateMatrix(); // this.transformationMatrix.copy(this.matrix); @@ -155,10 +169,10 @@ export class Polygon extends THREE.Mesh { new THREE.Float32BufferAttribute(bufferData, 3) ); - const material = new THREE.MeshStandardMaterial({ - color: this.#color, - transparent: true, - opacity: 0.6, + const material = new THREE.MeshBasicMaterial({ + color: this.options.color, + // transparent: true, + // opacity: 1, // TODO: Enabling Double Side untill we have proper face normals from triangulation side: THREE.DoubleSide, }); diff --git a/main/opengeometry/src/primitives/line.rs b/main/opengeometry/src/primitives/line.rs index b1a4d0b..04a7fbe 100644 --- a/main/opengeometry/src/primitives/line.rs +++ b/main/opengeometry/src/primitives/line.rs @@ -108,9 +108,7 @@ impl OGLine { } pub fn get_dxf_serialized(&self) -> String { - let mut drawing = Drawing::new(); - let added_entity_ref = drawing.add_entity(Entity::new(EntityType::Line(Line::default()))); - // `added_entity_ref` is a reference to the newly added entity - let data = drawing. + // TODO: Implement DXF serialization for line + String::new() } } \ No newline at end of file