dwg-dxf-viewer-sample/ ← hmwebviewer 형제 폴더
+ src/main.ts ← 모듈을 직접 import 해서 조립 (핵심)
+ src/viewer2d/ ← acadrust-dwg · Viewer2D · dxf-*
+ index.html ← 툴바 + Module recipe 패널
+ public/fonts/ ← NanumGothic (slugText)
+ public/samples/ ← BasicSample.dwg · simple.dxf
+ docs/modules-dwg-dxf.html
+
+실행
+ cd ../dwg-dxf-viewer-sample # (hmwebviewer 기준 형제)
+ npm install
+ npm run dev → http://localhost:5173
+
+
+
+
+
diff --git a/public/fonts/NanumGothic-Regular.ttf b/public/fonts/NanumGothic-Regular.ttf
new file mode 100644
index 0000000..2aa2b20
Binary files /dev/null and b/public/fonts/NanumGothic-Regular.ttf differ
diff --git a/public/licenses/THIRD-PARTY-NOTICES.md b/public/licenses/THIRD-PARTY-NOTICES.md
new file mode 100644
index 0000000..a3ecaef
--- /dev/null
+++ b/public/licenses/THIRD-PARTY-NOTICES.md
@@ -0,0 +1,70 @@
+# Third-party notices
+
+This viewer bundles third-party code. The notices below apply to the source
+tree **and** to the built site (`dist2/`, deployed at
+`https://dwg-dxf-viewer-sample.pages.dev/`), because the build embeds the
+components listed here.
+
+Served copies of the license texts live under
+[`public/licenses/`](./public/licenses/) → `/licenses/…` on the deployed site.
+
+---
+
+## acadrust 0.4.1 — Mozilla Public License 2.0 — **MODIFIED**
+
+| | |
+|---|---|
+| Component | `acadrust` (DWG/DXF parser, Rust) |
+| Version | 0.4.1 |
+| License | MPL-2.0 — full text: [`public/licenses/acadrust-MPL-2.0.txt`](./public/licenses/acadrust-MPL-2.0.txt) (`/licenses/acadrust-MPL-2.0.txt`) |
+| Upstream | https://github.com/hakanaktt/acadrust · https://crates.io/crates/acadrust/0.4.1 |
+| Upstream commit | `f249c2f816acf36ee51cd5533716bdd443c2517e` (from the crate's `.cargo_vcs_info.json`) |
+| Author | Hakan AK |
+| Shipped as | compiled into `assets/acadrust_dwg_bg-*.wasm` (Executable Form) |
+
+**This copy is modified.** One file differs from the published crate:
+
+```
+src/io/dwg/dwg_stream_readers/object_reader/entities.rs (read_mesh array-count bounds)
+```
+
+The modification bounds `read_mesh`'s array counts by the bits remaining in the
+object stream instead of the blanket 100 000-item guard, which truncated and
+thereby corrupted large SubD meshes.
+
+### How to obtain the Source Code Form (MPL-2.0 §3.2)
+
+1. Get the unmodified crate source — `cargo vendor`, or
+ `https://crates.io/api/v1/crates/acadrust/0.4.1/download`, or the upstream
+ commit above.
+2. Apply [`public/licenses/acadrust-0.4.1-read_mesh.patch`](./public/licenses/acadrust-0.4.1-read_mesh.patch)
+ (`/licenses/acadrust-0.4.1-read_mesh.patch` on the deployed site):
+
+ ```bash
+ tar xf acadrust-0.4.1.crate && cd acadrust-0.4.1
+ patch -p1 < acadrust-0.4.1-read_mesh.patch
+ ```
+
+The result is the exact Source Code Form of the acadrust code compiled into the
+shipped `.wasm`. Both the original and the modified file remain under MPL-2.0.
+
+---
+
+## dwg-wasm — MIT
+
+The wasm-bindgen wrapper that turns acadrust output into this viewer's
+`parseResult` (`hmwebviewer/rust/dwg-wasm/`). Our own code, MIT. MPL-2.0 §3.3
+permits distributing this Larger Work under different terms as long as the
+MPL-covered files above keep their license — which they do.
+
+---
+
+## Other components
+
+| Component | License |
+|---|---|
+| three.js | MIT |
+| dxf-parser | MIT |
+| opentype.js | MIT |
+| NanumGothic (`public/fonts/`) | SIL Open Font License 1.1 |
+| Viewer2D / sample glue | MIT |
diff --git a/public/licenses/acadrust-0.4.1-read_mesh.patch b/public/licenses/acadrust-0.4.1-read_mesh.patch
new file mode 100644
index 0000000..59193bd
--- /dev/null
+++ b/public/licenses/acadrust-0.4.1-read_mesh.patch
@@ -0,0 +1,111 @@
+--- a/src/io/dwg/dwg_stream_readers/object_reader/entities.rs
++++ b/src/io/dwg/dwg_stream_readers/object_reader/entities.rs
+@@ -1682,20 +1682,49 @@
+ MLineData { scale_factor, justification, start_point, normal, openclosed, lines_in_style, vertex_count, vertices, style_handle }
+ }
+
++/// Cap an array count against the bits actually left in the object's main
++/// stream instead of the blanket [`MAX_ARRAY_COUNT`].
++///
++/// MESH is the one entity whose arrays legitimately run past 100 000 items: a
++/// road-surface mesh in a civil drawing carries hundreds of thousands of
++/// vertices. Clamping those to the blanket cap does not merely truncate the
++/// mesh — the reader then continues from the wrong bit offset, so the face,
++/// edge and crease lists that follow decode as garbage (observed: a 100 000
++/// vertex clamp left a 14-face mesh with face sizes `[64, 0, 64, 23, 0, …]`).
++/// Bounding by the remaining bits keeps the corrupt-data protection — no
++/// unbounded allocation is possible — without mis-parsing a valid drawing.
++///
++/// `min_bits_per_item` is the shortest legal encoding of one element: a
++/// BitDouble is 2 bits at minimum (the 0.0 / 1.0 forms), so a 3BD vertex is 6
++/// and a BitLong is 2.
++fn stream_bounded_count(reader: &DwgMergedReader, raw: i32, min_bits_per_item: i64) -> i32 {
++ let raw = raw.max(0) as i64;
++ let total_bits = (reader.main().data_len() as i64).saturating_mul(8);
++ // The handle stream follows the main stream; anything past its start is not
++ // array data. handle_start() is 0 when the framing did not supply it.
++ let handle_start = reader.handle_start();
++ let end_bits = if handle_start > 0 { handle_start.min(total_bits) } else { total_bits };
++ let remaining = (end_bits - reader.position_in_bits()).max(0);
++ raw.min(remaining / min_bits_per_item.max(1)).min(i32::MAX as i64) as i32
++}
++
+ pub fn read_mesh(reader: &mut DwgMergedReader) -> MeshData {
+ let version = reader.read_bit_short();
+ let blend_crease = reader.read_bit();
+ let subdivision_level = reader.read_bit_long();
+
+- let num_verts = safe_count(reader.read_bit_long());
++ let raw_verts = reader.read_bit_long();
++ let num_verts = stream_bounded_count(reader, raw_verts, 6);
+ let mut vertices = Vec::with_capacity(num_verts as usize);
+ for _ in 0..num_verts { vertices.push(reader.read_3bit_double()); }
+
+- let total_face_data = safe_count(reader.read_bit_long());
++ let raw_face_data = reader.read_bit_long();
++ let total_face_data = stream_bounded_count(reader, raw_face_data, 2);
+ let mut faces = Vec::new();
+ let mut i = 0;
+ while i < total_face_data {
+- let n = safe_count(reader.read_bit_long());
++ let raw_n = reader.read_bit_long();
++ let n = stream_bounded_count(reader, raw_n, 2);
+ i += 1;
+ let mut face = Vec::new();
+ for _ in 0..n {
+@@ -1705,7 +1734,8 @@
+ faces.push(face);
+ }
+
+- let num_edges = safe_count(reader.read_bit_long());
++ let raw_edges = reader.read_bit_long();
++ let num_edges = stream_bounded_count(reader, raw_edges, 4);
+ let mut edges = Vec::with_capacity(num_edges as usize);
+ for _ in 0..num_edges {
+ let s = reader.read_bit_long();
+@@ -1713,7 +1743,8 @@
+ edges.push((s, e));
+ }
+
+- let num_creases = safe_count(reader.read_bit_long());
++ let raw_creases = reader.read_bit_long();
++ let num_creases = stream_bounded_count(reader, raw_creases, 2);
+ let mut crease_values = Vec::with_capacity(num_creases as usize);
+ for _ in 0..num_creases { crease_values.push(reader.read_bit_double()); }
+
+@@ -2350,14 +2381,31 @@
+ pub fn read_ole2frame(reader: &mut DwgMergedReader, version: DwgVersion) -> Ole2FrameData {
+ let ver = reader.read_bit_short();
+ let mode = if version.r2000_plus() { reader.read_bit_short() } else { 0 };
+- // OLE binary data can be very large (embedded images/documents),
+- // so don't use safe_count (100 KB cap). Use a generous 10 MB cap instead.
+ let data_len = (reader.read_bit_long().max(0) as usize).min(10_000_000);
+ let data = reader.read_bytes(data_len);
+ let trailing_byte = if version.r2000_plus() { reader.read_byte() } else { 3 };
+- let upper_left = reader.read_3bit_double();
+- let lower_right = reader.read_3bit_double();
++
++ let mut upper_left = Vector3::new(0.0, 0.0, 0.0);
++ let mut lower_right = Vector3::new(0.0, 0.0, 0.0);
++
++ // Extract 4-corner coordinates stored in the OLE binary data header starting at offset 2
++ if data.len() >= 66 {
++ let ul_x = f64::from_le_bytes(data[2..10].try_into().unwrap());
++ let ul_y = f64::from_le_bytes(data[10..18].try_into().unwrap());
++ let ul_z = f64::from_le_bytes(data[18..26].try_into().unwrap());
++ let lr_x = f64::from_le_bytes(data[50..58].try_into().unwrap());
++ let lr_y = f64::from_le_bytes(data[58..66].try_into().unwrap());
++ let lr_z = if data.len() >= 74 { f64::from_le_bytes(data[66..74].try_into().unwrap()) } else { 0.0 };
++
++ if ul_x.is_finite() && ul_y.is_finite() && lr_x.is_finite() && lr_y.is_finite()
++ && (ul_x != 0.0 || ul_y != 0.0 || lr_x != 0.0 || lr_y != 0.0) {
++ upper_left = Vector3::new(ul_x, ul_y, if ul_z.is_finite() { ul_z } else { 0.0 });
++ lower_right = Vector3::new(lr_x, lr_y, if lr_z.is_finite() { lr_z } else { 0.0 });
++ }
++ }
++
+ let ole_type = if version.r2000_plus() { reader.read_byte() } else { 2 };
++
+ Ole2FrameData { version: ver, mode, data, trailing_byte, upper_left, lower_right, ole_type }
+ }
+
diff --git a/public/licenses/acadrust-MPL-2.0.txt b/public/licenses/acadrust-MPL-2.0.txt
new file mode 100644
index 0000000..7321068
--- /dev/null
+++ b/public/licenses/acadrust-MPL-2.0.txt
@@ -0,0 +1,375 @@
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+ means each individual or legal entity that creates, contributes to
+ the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+ means the combination of the Contributions of others (if any) used
+ by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+ means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+ means Source Code Form to which the initial Contributor has attached
+ the notice in Exhibit A, the Executable Form of such Source Code
+ Form, and Modifications of such Source Code Form, in each case
+ including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+ means
+
+ (a) that the initial Contributor has attached the notice described
+ in Exhibit B to the Covered Software; or
+
+ (b) that the Covered Software was made available under the terms of
+ version 1.1 or earlier of the License, but not also under the
+ terms of a Secondary License.
+
+1.6. "Executable Form"
+ means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+ means a work that combines Covered Software with other material, in
+ a separate file or files, that is not Covered Software.
+
+1.8. "License"
+ means this document.
+
+1.9. "Licensable"
+ means having the right to grant, to the maximum extent possible,
+ whether at the time of the initial grant or subsequently, any and
+ all of the rights conveyed by this License.
+
+1.10. "Modifications"
+ means any of the following:
+
+ (a) any file in Source Code Form that results from an addition to,
+ deletion from, or modification of the contents of Covered
+ Software; or
+
+ (b) any new file in Source Code Form that contains any Covered
+ Software.
+
+1.11. "Patent Claims" of a Contributor
+ means any patent claim(s), including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by such
+ Contributor that would be infringed, but for the grant of the
+ License, by the making, using, selling, offering for sale, having
+ made, import, or transfer of either its Contributions or its
+ Contributor Version.
+
+1.12. "Secondary License"
+ means either the GNU General Public License, Version 2.0, the GNU
+ Lesser General Public License, Version 2.1, the GNU Affero General
+ Public License, Version 3.0, or any later versions of those
+ licenses.
+
+1.13. "Source Code Form"
+ means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, "You" includes any entity that
+ controls, is controlled by, or is under common control with You. For
+ purposes of this definition, "control" means (a) the power, direct
+ or indirect, to cause the direction or management of such entity,
+ whether by contract or otherwise, or (b) ownership of more than
+ fifty percent (50%) of the outstanding shares or beneficial
+ ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or
+ as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+ for sale, have made, import, and otherwise transfer either its
+ Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+ or
+
+(b) for infringements caused by: (i) Your and any other third party's
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+ its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+ Form, as described in Section 3.1, and You must inform recipients of
+ the Executable Form how they can obtain a copy of such Source Code
+ Form by reasonable means in a timely manner, at a charge no more
+ than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+ License, or sublicense it under different terms, provided that the
+ license for the Executable Form does not attempt to limit or alter
+ the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under the name "LEGAL", and included in all Covered Software
+distributed in Source Code Form. Except to the extent prohibited by
+statute or regulation, such description must be sufficiently detailed
+for a recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+* *
+* 6. Disclaimer of Warranty *
+* ------------------------- *
+* *
+* Covered Software is provided under this License on an "as is" *
+* basis, without warranty of any kind, either expressed, implied, or *
+* statutory, including, without limitation, warranties that the *
+* Covered Software is free of defects, merchantable, fit for a *
+* particular purpose or non-infringing. The entire risk as to the *
+* quality and performance of the Covered Software is with You. *
+* Should any Covered Software prove defective in any respect, You *
+* (not any Contributor) assume the cost of any necessary servicing, *
+* repair, or correction. This disclaimer of warranty constitutes an *
+* essential part of this License. No use of any Covered Software is *
+* authorized under this License except under this disclaimer. *
+* *
+************************************************************************
+
+************************************************************************
+* *
+* 7. Limitation of Liability *
+* -------------------------- *
+* *
+* Under no circumstances and under no legal theory, whether tort *
+* (including negligence), contract, or otherwise, shall any *
+* Contributor, or anyone who distributes Covered Software as *
+* permitted above, be liable to You for any direct, indirect, *
+* special, incidental, or consequential damages of any character *
+* including, without limitation, damages for lost profits, loss of *
+* goodwill, work stoppage, computer failure or malfunction, or any *
+* and all other commercial damages or losses, even if such party *
+* shall have been informed of the possibility of such damages. This *
+* limitation of liability shall not apply to liability for death or *
+* personal injury resulting from such party's negligence to the *
+* extent applicable law prohibits such limitation. Some *
+* jurisdictions do not allow the exclusion or limitation of *
+* incidental or consequential damages, so this exclusion and *
+* limitation may not apply to You. *
+* *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+ This Source Code Form is "Incompatible With Secondary Licenses", as
+ defined by the Mozilla Public License, v. 2.0.
+
diff --git a/public/samples/BasicSample.dwg b/public/samples/BasicSample.dwg
new file mode 100644
index 0000000..cd34d2c
Binary files /dev/null and b/public/samples/BasicSample.dwg differ
diff --git a/public/samples/C0060202-001-평면및종단면도(1)(대산방향STA.18+492.08-19+411.50).dwg b/public/samples/C0060202-001-평면및종단면도(1)(대산방향STA.18+492.08-19+411.50).dwg
new file mode 100644
index 0000000..3ee01bb
Binary files /dev/null and b/public/samples/C0060202-001-평면및종단면도(1)(대산방향STA.18+492.08-19+411.50).dwg differ
diff --git a/public/samples/C0060203-001-표준단면도(2차로,자연환기300m이상).dwg b/public/samples/C0060203-001-표준단면도(2차로,자연환기300m이상).dwg
new file mode 100644
index 0000000..a8ec60d
Binary files /dev/null and b/public/samples/C0060203-001-표준단면도(2차로,자연환기300m이상).dwg differ
diff --git a/public/samples/bb.dwg b/public/samples/bb.dwg
new file mode 100644
index 0000000..438112c
Binary files /dev/null and b/public/samples/bb.dwg differ
diff --git a/public/samples/civil.dwg b/public/samples/civil.dwg
new file mode 100644
index 0000000..3ee01bb
Binary files /dev/null and b/public/samples/civil.dwg differ
diff --git a/public/samples/simple.dxf b/public/samples/simple.dxf
new file mode 100644
index 0000000..10fa791
--- /dev/null
+++ b/public/samples/simple.dxf
@@ -0,0 +1,146 @@
+0
+SECTION
+2
+HEADER
+9
+$ACADVER
+1
+AC1015
+9
+$INSUNITS
+70
+4
+0
+ENDSEC
+0
+SECTION
+2
+TABLES
+0
+TABLE
+2
+LAYER
+0
+LAYER
+2
+0
+70
+0
+62
+7
+0
+LAYER
+2
+OUTLINE
+70
+0
+62
+1
+0
+ENDTAB
+0
+ENDSEC
+0
+SECTION
+2
+BLOCKS
+0
+ENDSEC
+0
+SECTION
+2
+ENTITIES
+0
+LINE
+8
+OUTLINE
+10
+0.0
+20
+0.0
+30
+0.0
+11
+100.0
+21
+0.0
+31
+0.0
+0
+LINE
+8
+OUTLINE
+10
+100.0
+20
+0.0
+30
+0.0
+11
+100.0
+21
+60.0
+31
+0.0
+0
+LINE
+8
+OUTLINE
+10
+100.0
+20
+60.0
+30
+0.0
+11
+0.0
+21
+60.0
+31
+0.0
+0
+LINE
+8
+OUTLINE
+10
+0.0
+20
+60.0
+30
+0.0
+11
+0.0
+21
+0.0
+31
+0.0
+0
+CIRCLE
+8
+0
+10
+50.0
+20
+30.0
+30
+0.0
+40
+15.0
+0
+TEXT
+8
+0
+10
+10.0
+20
+70.0
+30
+0.0
+40
+5.0
+1
+Hello DWG/DXF package
+0
+ENDSEC
+0
+EOF
diff --git a/src/engine/layerPanel.ts b/src/engine/layerPanel.ts
new file mode 100644
index 0000000..68b1897
--- /dev/null
+++ b/src/engine/layerPanel.ts
@@ -0,0 +1,195 @@
+/**
+ * Layer Panel manager for dwg-dxf-viewer-sample.
+ * Renders layer items, color swatches, entity counts, search filters, and visibility toggles.
+ */
+
+import type { Viewer2D } from './viewer2d/Viewer2D';
+
+export interface LayerItem {
+ name: string;
+ colorHex: string;
+ count: number;
+ visible: boolean;
+}
+
+export class LayerPanelManager {
+ private viewer: Viewer2D;
+ private listEl: HTMLElement;
+ private countEl: HTMLElement | null;
+ private searchInputEl: HTMLInputElement | null;
+ private hiddenLayers: Set = new Set();
+ private searchQuery: string = '';
+
+ constructor(
+ viewer: Viewer2D,
+ listEl: HTMLElement,
+ options?: {
+ countEl?: HTMLElement | null;
+ searchInputEl?: HTMLInputElement | null;
+ showAllBtnEl?: HTMLElement | null;
+ hideAllBtnEl?: HTMLElement | null;
+ }
+ ) {
+ this.viewer = viewer;
+ this.listEl = listEl;
+ this.countEl = options?.countEl || null;
+ this.searchInputEl = options?.searchInputEl || null;
+
+ if (this.searchInputEl) {
+ this.searchInputEl.addEventListener('input', (e) => {
+ this.searchQuery = (e.target as HTMLInputElement).value.trim().toLowerCase();
+ this.render();
+ });
+ }
+
+ if (options?.showAllBtnEl) {
+ options.showAllBtnEl.addEventListener('click', () => this.showAllLayers());
+ }
+
+ if (options?.hideAllBtnEl) {
+ options.hideAllBtnEl.addEventListener('click', () => this.hideAllLayers());
+ }
+
+ // Delegated click handling: bound once, so render() never has to re-attach
+ // a listener per row (that was O(layers) DOM work on every single toggle).
+ this.listEl.addEventListener('click', (e) => {
+ const row = (e.target as HTMLElement)?.closest?.('.layer-row') as HTMLElement | null;
+ if (!row) return;
+ const layerName = row.dataset.name;
+ if (layerName) this.toggleLayer(layerName);
+ });
+ }
+
+ /** Refresh and re-render layer list from Viewer2D state */
+ public update(): void {
+ this.hiddenLayers.clear();
+ const layers = this.viewer.getLayerInfo() || [];
+ for (const l of layers) {
+ if (!l.visible) {
+ this.hiddenLayers.add(l.name);
+ }
+ }
+ this.render();
+ }
+
+ public showAllLayers(): void {
+ this.hiddenLayers.clear();
+ this.viewer.setHiddenLayers(this.hiddenLayers);
+ this.syncRows();
+ }
+
+ public hideAllLayers(): void {
+ const layers = this.viewer.getLayerInfo() || [];
+ for (const l of layers) {
+ this.hiddenLayers.add(l.name);
+ }
+ this.viewer.setHiddenLayers(this.hiddenLayers);
+ this.syncRows();
+ }
+
+ public toggleLayer(name: string): void {
+ if (this.hiddenLayers.has(name)) {
+ this.hiddenLayers.delete(name);
+ } else {
+ this.hiddenLayers.add(name);
+ }
+ this.viewer.setHiddenLayers(this.hiddenLayers);
+ this.syncRow(name);
+ }
+
+ /** Patch one row in place — a full render() would rebuild the whole list. */
+ private syncRow(name: string): void {
+ const row = this.listEl?.querySelector(
+ `.layer-row[data-name="${cssEscape(name)}"]`
+ );
+ if (!row) return;
+ this.paintRow(row, !this.hiddenLayers.has(name));
+ }
+
+ /** Patch every row (show-all / hide-all) without touching the DOM structure. */
+ private syncRows(): void {
+ if (!this.listEl) return;
+ this.listEl.querySelectorAll('.layer-row').forEach((row) => {
+ const name = row.dataset.name;
+ if (name != null) this.paintRow(row, !this.hiddenLayers.has(name));
+ });
+ }
+
+ private paintRow(row: HTMLElement, visible: boolean): void {
+ row.style.opacity = visible ? '1' : '0.4';
+ const btn = row.querySelector('.eye-btn');
+ if (btn) {
+ btn.textContent = visible ? '👁️' : '🕶️';
+ btn.title = visible ? '숨기기' : '표시하기';
+ }
+ }
+
+ public render(): void {
+ if (!this.listEl) return;
+
+ const layers: LayerItem[] = this.viewer.getLayerInfo() || [];
+
+ if (this.countEl) {
+ this.countEl.textContent = `${layers.length}개`;
+ }
+
+ if (!layers.length) {
+ this.listEl.innerHTML = `
+