Skip to content

fix: fix layer-0 ByLayer inheritance for INSERT material remapping (issue #219)#227

Merged
mlightcad merged 2 commits intomainfrom
fix/219
Apr 23, 2026
Merged

fix: fix layer-0 ByLayer inheritance for INSERT material remapping (issue #219)#227
mlightcad merged 2 commits intomainfrom
fix/219

Conversation

@mlightcad
Copy link
Copy Markdown
Owner

@mlightcad mlightcad commented Apr 20, 2026

Summary

  • Fixes layer-0 block entities so ByLayer traits inherit INSERT layer values during render and later layer edits.
  • Introduces typed material metadata with per-trait ByLayer flags to make remapping and layer updates deterministic.
  • Adds unit and e2e regression coverage (with fixture + snapshot) for INSERT/layer-0 color inheritance behavior.

Why

  • Some layer-0 block paths could lose explicit isByLayerColor while still being logically ByLayer, causing incorrect inherited color behavior.
  • A single isByLayer flag was too coarse for correctly applying inherited updates across color, linetype, lineweight, and transparency.
  • Issue layer color change not applied to all entities in the same layer #219 flows need stronger regression protection at both renderer-unit and viewer-e2e levels.

What Changed

  • packages/cad-simple-viewer/src/view/AcTrView2d.ts now remaps inherited block materials via getLayerBoundMaterial, resolves effective layer traits, and promotes layer-0 color binding when other ByLayer bindings are present.
  • packages/three-renderer/src/renderer/AcTrRenderer.ts and packages/three-renderer/src/style/AcTrStyleManager.ts replace remapMaterialLayer with getLayerBoundMaterial(material, layerName, layerTraits?).
  • packages/three-renderer/src/style/AcTrMaterialManager.ts now applies inherited layer traits only for flagged ByLayer attributes and stores/reads granular metadata flags.
  • packages/three-renderer/src/style/AcTrMaterialMetadata.ts adds typed metadata helpers (getMaterialMetadata, setMaterialMetadata, hasByLayerBinding), exported via packages/three-renderer/src/index.ts.
  • packages/three-renderer/__tests__/AcTrStyleManager.spec.ts updates remap tests and adds a case that refreshes ByLayer color even when target layer is unchanged.
  • packages/cad-viewer-example/e2e/tests/smoke.spec.ts adds a regression test using new fixture packages/cad-viewer-example/e2e/fixtures/block-color.dxf and snapshot block-layer0-bylayer-inherit-chromium-win32.png.
  • Branch baseline (main..fix/219) also includes broader issue layer color change not applied to all entities in the same layer #219 refactors across viewer/renderer/layer UI files plus dependency/lockfile adjustments.

Risks / Notes

  • External/custom code reading material.userData.isByLayer may need migration to granular flags.
  • API consumers using remapMaterialLayer must migrate to getLayerBoundMaterial.
  • The added DXF fixture (~15,952 lines) and screenshot snapshot increase review noise and repository size.

Breaking Changes

  • AcTrRenderer/AcTrStyleManager layer-remap API renamed from remapMaterialLayer to getLayerBoundMaterial.
  • Material metadata contract now relies on isByLayerColor, isByLayerLineType, isByLayerLineWeight, and isByLayerTransparency instead of a single isByLayer.

@mlightcad mlightcad self-assigned this Apr 20, 2026
@mlightcad mlightcad added the bug Something isn't working label Apr 20, 2026
@mlightcad mlightcad changed the title fix: fix issue #219 fix: fix layer-0 ByLayer inheritance for INSERT material remapping (issue #219) Apr 23, 2026
@mlightcad mlightcad merged commit 5aed9be into main Apr 23, 2026
2 checks passed
@mlightcad mlightcad deleted the fix/219 branch April 23, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant