brep-io-kernel 1.0.15 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brep-io-kernel",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "scripts": {
5
5
  "dev": "pnpm generateLicenses && pnpm build:kernel && vite --host 0.0.0.0",
6
6
  "build": "pnpm generateLicenses && vite build",
@@ -116,7 +116,7 @@ export const CADmaterials = {
116
116
  }),
117
117
  SELECTED: new THREE.MeshStandardMaterial({
118
118
  color: "#ffc400",
119
- side: THREE.FrontSide,
119
+ side: THREE.DoubleSide,
120
120
  transparent: false,
121
121
  opacity: 1,
122
122
  wireframe: false,
@@ -127,8 +127,8 @@ export const CADmaterials = {
127
127
  depthWrite: true,
128
128
  // Keep selected faces slightly behind edges as well.
129
129
  polygonOffset: true,
130
- polygonOffsetFactor: 2,
131
- polygonOffsetUnits: 1,
130
+ polygonOffsetFactor: 0,
131
+ polygonOffsetUnits: 0,
132
132
  emissiveIntensity: 0,
133
133
  })
134
134
  },
@@ -559,7 +559,7 @@ export class SelectionFilter {
559
559
 
560
560
  static selectItem(scene, itemName) {
561
561
  scene.traverse((child) => {
562
- if (child instanceof THREE.Mesh && child.name === itemName) {
562
+ if (child && child.name === itemName) {
563
563
  child.selected = true;
564
564
  // change material to selected
565
565
  if (child.type === SelectionFilter.FACE) {
@@ -4,6 +4,7 @@ export function renderReferenceSelectionField({ ui, key, def, id, controlWrap, v
4
4
  const inputEl = document.createElement('input');
5
5
  inputEl.type = 'hidden';
6
6
  inputEl.id = id;
7
+ try { inputEl.dataset.key = String(key); } catch (_) { }
7
8
 
8
9
  const isMulti = !!def.multiple;
9
10
  if (isMulti) inputEl.dataset.multiple = 'true';
@@ -108,6 +109,7 @@ export function renderReferenceSelectionField({ ui, key, def, id, controlWrap, v
108
109
  inputEl.value = '';
109
110
  updateSingleDisplay(null);
110
111
  emitChange(null);
112
+ try { ui._syncActiveReferenceSelectionHighlight(inputEl, def); } catch (_) { }
111
113
  };
112
114
 
113
115
  clearBtn.addEventListener('click', clearSelection);
@@ -137,6 +139,7 @@ export function renderReferenceSelectionField({ ui, key, def, id, controlWrap, v
137
139
  const normalized = normalizeReferenceName(inputEl.value);
138
140
  writeRawValue(normalized);
139
141
  emitChange(normalized);
142
+ try { ui._syncActiveReferenceSelectionHighlight(inputEl, def); } catch (_) { }
140
143
  });
141
144
  }
142
145
 
@@ -188,6 +191,7 @@ export function renderReferenceSelectionField({ ui, key, def, id, controlWrap, v
188
191
  inputEl.value = normalized ?? '';
189
192
  writeRawValue(normalized);
190
193
  emitChange(normalized);
194
+ try { ui._syncActiveReferenceSelectionHighlight(inputEl, def); } catch (_) { }
191
195
  }
192
196
  });
193
197
 
@@ -312,6 +312,12 @@ export class SchemaForm {
312
312
  const clearBtn = display.querySelector('.ref-chip-remove');
313
313
  if (clearBtn) clearBtn.style.visibility = normalized ? 'visible' : 'hidden';
314
314
  }
315
+ try {
316
+ const inputEl = this._inputs.get(key);
317
+ if (inputEl && inputEl === SchemaForm.__activeRefInput) {
318
+ this._syncActiveReferenceSelectionHighlight(inputEl, def);
319
+ }
320
+ } catch (_) { }
315
321
  }
316
322
  continue;
317
323
  }
@@ -481,13 +487,61 @@ export class SchemaForm {
481
487
  return false;
482
488
  }
483
489
 
490
+ _getReferenceSelectionScene() {
491
+ return this.options?.scene
492
+ || this.options?.viewer?.partHistory?.scene
493
+ || this.options?.viewer?.scene
494
+ || null;
495
+ }
496
+
497
+ _collectReferenceSelectionNames(inputEl, def = null) {
498
+ if (!inputEl) return [];
499
+ const isMulti = Boolean(def && def.multiple) || (inputEl.dataset && inputEl.dataset.multiple === 'true');
500
+ if (isMulti) {
501
+ let list = null;
502
+ if (typeof inputEl.__getSelectionList === 'function') {
503
+ try { list = inputEl.__getSelectionList(); } catch (_) { list = null; }
504
+ }
505
+ if (!Array.isArray(list) && inputEl.dataset && inputEl.dataset.selectedValues) {
506
+ try {
507
+ const parsed = JSON.parse(inputEl.dataset.selectedValues);
508
+ if (Array.isArray(parsed)) list = parsed;
509
+ } catch (_) { /* ignore */ }
510
+ }
511
+ if (!Array.isArray(list) && inputEl.dataset && inputEl.dataset.key && this.params && Array.isArray(this.params[inputEl.dataset.key])) {
512
+ list = this.params[inputEl.dataset.key];
513
+ }
514
+ return normalizeReferenceList(Array.isArray(list) ? list : []);
515
+ }
516
+ let value = null;
517
+ if (inputEl.value != null && String(inputEl.value).trim() !== '') {
518
+ value = inputEl.value;
519
+ } else if (inputEl.dataset && inputEl.dataset.key && this.params && this.params[inputEl.dataset.key] != null) {
520
+ value = this.params[inputEl.dataset.key];
521
+ }
522
+ const normalized = normalizeReferenceName(value);
523
+ return normalized ? [normalized] : [];
524
+ }
525
+
526
+ _syncActiveReferenceSelectionHighlight(inputEl, def = null) {
527
+ try {
528
+ const active = SchemaForm.__activeRefInput;
529
+ if (!active || active !== inputEl) return;
530
+ const scene = this._getReferenceSelectionScene();
531
+ if (!scene) return;
532
+ const names = this._collectReferenceSelectionNames(inputEl, def);
533
+ SelectionFilter.unselectAll(scene);
534
+ for (const name of names) {
535
+ if (!name) continue;
536
+ try { SelectionFilter.selectItem(scene, name); } catch (_) { }
537
+ }
538
+ } catch (_) { }
539
+ }
540
+
484
541
  _activateReferenceSelection(inputEl, def) {
485
542
  // Clear any lingering scene selection so the new reference starts fresh
486
543
  try {
487
- const scene = this.options?.scene
488
- || this.options?.viewer?.partHistory?.scene
489
- || this.options?.viewer?.scene
490
- || null;
544
+ const scene = this._getReferenceSelectionScene();
491
545
  if (scene) {
492
546
  SchemaForm.__setGlobalActiveRefInput(null);
493
547
  SelectionFilter.unselectAll(scene);
@@ -526,6 +580,9 @@ export class SchemaForm {
526
580
  SelectionFilter.stashAllowedSelectionTypes();
527
581
  SelectionFilter.SetSelectionTypes(def.selectionFilter);
528
582
  try { window.__BREP_activeRefInput = inputEl; } catch (_) { }
583
+
584
+ // Highlight existing selections while this reference field is active
585
+ try { this._syncActiveReferenceSelectionHighlight(inputEl, def); } catch (_) { }
529
586
  }
530
587
 
531
588
  // Activate a TransformControls session for a transform widget
@@ -997,8 +1054,15 @@ export class SchemaForm {
997
1054
  } catch (_) { }
998
1055
  }
999
1056
  } catch (_) { }
1057
+ const hadActive = !!SchemaForm.__activeRefInput;
1000
1058
  SchemaForm.__activeRefInput = null;
1001
1059
  try { if (window.__BREP_activeRefInput === undefined || window.__BREP_activeRefInput === SchemaForm.__activeRefInput) window.__BREP_activeRefInput = null; } catch (_) { }
1060
+ if (hadActive) {
1061
+ try {
1062
+ const scene = this._getReferenceSelectionScene();
1063
+ if (scene) SelectionFilter.unselectAll(scene);
1064
+ } catch (_) { }
1065
+ }
1002
1066
  SelectionFilter.restoreAllowedSelectionTypes();
1003
1067
  }
1004
1068
 
@@ -1091,6 +1155,13 @@ export class SchemaForm {
1091
1155
  chipsWrap.appendChild(hint);
1092
1156
  }
1093
1157
  }
1158
+
1159
+ try {
1160
+ if (inputEl && inputEl === SchemaForm.__activeRefInput) {
1161
+ const def = this.schema ? (this.schema[key] || {}) : null;
1162
+ this._syncActiveReferenceSelectionHighlight(inputEl, def);
1163
+ }
1164
+ } catch (_) { }
1094
1165
  }
1095
1166
 
1096
1167
  _emitParamsChange(key, value) {