vim-web 1.0.0-alpha.12 → 1.0.0-alpha.13

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/dist/vim-web.d.ts CHANGED
@@ -7,14 +7,6 @@ import * as React from 'react';
7
7
  import React__default, { ReactNode } from 'react';
8
8
  import * as react_jsx_runtime from 'react/jsx-runtime';
9
9
 
10
- /**
11
- * @module vim-loader
12
- */
13
- /**
14
- * Determines how to draw (or not) transparent and opaque objects
15
- */
16
- type TransparencyMode = 'opaqueOnly' | 'transparentOnly' | 'allAsOpaque' | 'all';
17
-
18
10
  /**
19
11
  * @module vim-loader
20
12
  */
@@ -45,10 +37,6 @@ type VimSettings = {
45
37
  * Setting this will override individual position, rotation, and scale properties.
46
38
  */
47
39
  matrix: THREE.Matrix4;
48
- /**
49
- * Determines whether objects are drawn based on their transparency.
50
- */
51
- transparency: TransparencyMode;
52
40
  /**
53
41
  * Set to true to enable verbose HTTP logging.
54
42
  */
@@ -411,6 +399,8 @@ interface IMaterials {
411
399
  outlineColor: THREE.Color;
412
400
  /** Clipping planes applied to all materials. Set to undefined to disable clipping. */
413
401
  clippingPlanes: THREE.Plane[] | undefined;
402
+ /** Opacity of the transparent model material (0 = invisible, 1 = fully opaque). Default: 0.25. */
403
+ transparentOpacity: number;
414
404
  /** Selection fill mode: 'none' | 'default' | 'xray' | 'seethrough'. */
415
405
  selectionFillMode: SelectionFillMode;
416
406
  /** Color used to tint selected elements. */
@@ -894,7 +884,7 @@ interface IWebglVim extends IVim<IElement3D> {
894
884
  subset(): ISubset;
895
885
  /**
896
886
  * Loads geometry for the given subset, or all geometry if no subset is provided.
897
- * Caller is responsible for not loading the same subset twice.
887
+ * Clears any previously loaded geometry first so meshes are never duplicated.
898
888
  * @param subset - The subset to load. Omit to load everything.
899
889
  */
900
890
  load(subset?: ISubset): Promise<void>;
@@ -1762,7 +1752,7 @@ declare function createCoreWebglViewer(settings?: PartialViewerSettings): IWebgl
1762
1752
 
1763
1753
  declare namespace Core_Webgl {
1764
1754
  export { MaterialSet, createCoreWebglViewer as createViewer, isElement3D };
1765
- export type { AxesSettings, ICameraMovement, IElement3D, IGizmoAxes, IGizmoMarkers, IGizmoOrbit, IGizmos, IMarker, IMaterials, IMeasure, IRenderingSection, IScene, ISelectable, ISubset, IWebglCamera, IWebglLoadRequest, IWebglRaycastResult, IWebglRaycaster, IWebglRenderer, IWebglSectionBox, IWebglSelection, IWebglViewport, IWebglVim, MaterialSettings, MeasureStage, PartialViewerSettings, RequestSource, SelectionFillMode, SubsetFilter, TransparencyMode, IWebglViewer as Viewer, ViewerSettings, VimPartialSettings, VimSettings };
1755
+ export type { AxesSettings, ICameraMovement, IElement3D, IGizmoAxes, IGizmoMarkers, IGizmoOrbit, IGizmos, IMarker, IMaterials, IMeasure, IRenderingSection, IScene, ISelectable, ISubset, IWebglCamera, IWebglLoadRequest, IWebglRaycastResult, IWebglRaycaster, IWebglRenderer, IWebglSectionBox, IWebglSelection, IWebglViewport, IWebglVim, MaterialSettings, MeasureStage, PartialViewerSettings, RequestSource, SelectionFillMode, SubsetFilter, IWebglViewer as Viewer, ViewerSettings, VimPartialSettings, VimSettings };
1766
1756
  }
1767
1757
 
1768
1758
  /**
@@ -2515,7 +2505,9 @@ interface IsolationApi {
2515
2505
  /** Ghost material opacity 0-1 (observable). */
2516
2506
  ghostOpacity: StateRef<number>;
2517
2507
  /** Whether transparent materials are rendered (observable). */
2518
- transparency: StateRef<boolean>;
2508
+ showTransparent: StateRef<boolean>;
2509
+ /** Opacity of transparent materials 0-1 (observable). Default: 0.25. */
2510
+ transparentOpacity: StateRef<number>;
2519
2511
  /** Whether selection outlines are enabled (observable). */
2520
2512
  outlineEnabled: StateRef<boolean>;
2521
2513
  /** Outline quality: 'low' (0.5x) | 'medium' (1x) | 'high' (2x) render target scale. */
@@ -2663,7 +2655,7 @@ type PartialWebglSettings = RecursivePartial<WebglSettings>;
2663
2655
  type IsolationSettings = {
2664
2656
  autoIsolate: boolean;
2665
2657
  showGhost: boolean;
2666
- transparency: boolean;
2658
+ showTransparent: boolean;
2667
2659
  showRooms: boolean;
2668
2660
  };
2669
2661
  type SectionBoxSettings = {
@@ -3492,7 +3484,8 @@ declare const IsolationPanel: {
3492
3484
  Ids: {
3493
3485
  showGhost: string;
3494
3486
  ghostOpacity: string;
3495
- transparency: string;
3487
+ showTransparent: string;
3488
+ transparentOpacity: string;
3496
3489
  outlineEnabled: string;
3497
3490
  outlineQuality: string;
3498
3491
  outlineThickness: string;
@@ -58779,12 +58779,13 @@ void main() {
58779
58779
  }
58780
58780
  /**
58781
58781
  * Loads geometry for the given subset, or all geometry if no subset is provided.
58782
- * Caller is responsible for not loading the same subset twice.
58782
+ * Clears any previously loaded geometry first so meshes are never duplicated.
58783
58783
  * @param subset - The subset to load. Omit to load everything.
58784
58784
  */
58785
58785
  async load(subset) {
58786
58786
  subset ?? (subset = this.subset());
58787
58787
  if (subset.getInstanceCount() === 0) return;
58788
+ this.clear();
58788
58789
  this._factory.add(subset);
58789
58790
  this._onGeometryLoaded.dispatch();
58790
58791
  }
@@ -66194,6 +66195,16 @@ void main() {
66194
66195
  this.three.uniformsNeedUpdate = true;
66195
66196
  (_a3 = this._onUpdate) == null ? void 0 : _a3.call(this);
66196
66197
  }
66198
+ /** Base opacity of the material (0 = invisible, 1 = fully opaque). */
66199
+ get baseOpacity() {
66200
+ return this.three.uniforms.baseOpacity.value;
66201
+ }
66202
+ set baseOpacity(value) {
66203
+ var _a3;
66204
+ this.three.uniforms.baseOpacity.value = value;
66205
+ this.three.uniformsNeedUpdate = true;
66206
+ (_a3 = this._onUpdate) == null ? void 0 : _a3.call(this);
66207
+ }
66197
66208
  /** Blend strength for selection tint (0 = off, 1 = solid). */
66198
66209
  get selectionTintOpacity() {
66199
66210
  return this.three.uniforms.selectionTintOpacity.value;
@@ -66241,7 +66252,8 @@ void main() {
66241
66252
  uniforms: {
66242
66253
  colorPaletteTexture: { value: null },
66243
66254
  selectionTintColor: { value: new Color(25855) },
66244
- selectionTintOpacity: { value: 0 }
66255
+ selectionTintOpacity: { value: 0 },
66256
+ baseOpacity: { value: transparent ? 0.25 : 1 }
66245
66257
  },
66246
66258
  clipping: true,
66247
66259
  transparent,
@@ -66309,6 +66321,7 @@ void main() {
66309
66321
 
66310
66322
  uniform vec3 selectionTintColor;
66311
66323
  uniform float selectionTintOpacity;
66324
+ uniform float baseOpacity;
66312
66325
 
66313
66326
  out vec4 fragColor;
66314
66327
 
@@ -66330,7 +66343,7 @@ void main() {
66330
66343
  finalColor = mix(finalColor, selectionTintColor, selectionTintOpacity);
66331
66344
  }
66332
66345
 
66333
- fragColor = vec4(finalColor, ${transparent ? "0.25" : "1.0"});
66346
+ fragColor = vec4(finalColor, baseOpacity);
66334
66347
  }
66335
66348
  `
66336
66349
  )
@@ -66588,6 +66601,13 @@ void main() {
66588
66601
  set ghostColor(value) {
66589
66602
  this._ghost.color = value;
66590
66603
  }
66604
+ /** Opacity of the transparent model material (0 = invisible, 1 = fully opaque). Default: 0.25. */
66605
+ get transparentOpacity() {
66606
+ return this._modelTransparent.baseOpacity;
66607
+ }
66608
+ set transparentOpacity(value) {
66609
+ this._modelTransparent.baseOpacity = value;
66610
+ }
66591
66611
  /**
66592
66612
  * Updates material settings based on the provided configuration.
66593
66613
  */
@@ -68975,68 +68995,17 @@ void main() {
68975
68995
  this._composer.outlineScale = value;
68976
68996
  }
68977
68997
  };
68978
- function isTransparencyModeValid(value) {
68979
- if (!value) return false;
68980
- return ["all", "opaqueOnly", "transparentOnly", "allAsOpaque"].includes(
68981
- value
68982
- );
68983
- }
68984
- function createGeometryFromMesh(g3d2, mesh, section) {
68985
- const colorIndices = createColorIndices(g3d2, mesh, section);
68986
- const positions = g3d2.positions.subarray(
68987
- g3d2.getMeshVertexStart(mesh) * 3,
68988
- g3d2.getMeshVertexEnd(mesh) * 3
68989
- );
68990
- const start = g3d2.getMeshIndexStart(mesh, section);
68991
- const end = g3d2.getMeshIndexEnd(mesh, section);
68992
- const indices = g3d2.indices.subarray(start, end);
68993
- return createGeometryFromArrays(
68994
- positions,
68995
- indices,
68996
- colorIndices
68997
- );
68998
- }
68999
- function createColorIndices(g3d2, mesh, section) {
69000
- const vertexCount = g3d2.getMeshVertexCount(mesh);
69001
- const result = new Uint16Array(vertexCount);
69002
- const subStart = g3d2.getMeshSubmeshStart(mesh, section);
69003
- const subEnd = g3d2.getMeshSubmeshEnd(mesh, section);
69004
- for (let submesh = subStart; submesh < subEnd; submesh++) {
69005
- const start = g3d2.getSubmeshIndexStart(submesh);
69006
- const end = g3d2.getSubmeshIndexEnd(submesh);
69007
- const index2 = g3d2.colorIndices[submesh];
69008
- for (let i2 = start; i2 < end; i2++) {
69009
- const vertexIndex = g3d2.indices[i2];
69010
- result[vertexIndex] = index2;
69011
- }
69012
- }
69013
- return result;
69014
- }
69015
- function createGeometryFromArrays(vertices, indices, colorIndices = void 0) {
69016
- const geometry = new BufferGeometry();
69017
- geometry.setAttribute("position", new BufferAttribute(vertices, 3));
69018
- geometry.setIndex(new Uint32BufferAttribute(indices, 1));
69019
- if (colorIndices) {
69020
- geometry.setAttribute(
69021
- "colorIndex",
69022
- new Uint16BufferAttribute(colorIndices, 1)
69023
- );
69024
- }
69025
- return geometry;
69026
- }
69027
68998
  function getDefaultVimSettings() {
69028
68999
  return {
69029
69000
  position: new Vector3(),
69030
69001
  rotation: new Vector3(),
69031
69002
  scale: 1,
69032
69003
  matrix: void 0,
69033
- transparency: "all",
69034
69004
  verboseHttp: false
69035
69005
  };
69036
69006
  }
69037
69007
  function createVimSettings(options) {
69038
69008
  const merge = options ? deepmerge(getDefaultVimSettings(), options, void 0) : getDefaultVimSettings();
69039
- merge.transparency = isTransparencyModeValid(merge.transparency) ? merge.transparency : "all";
69040
69009
  merge.matrix = merge.matrix ?? new Matrix4().compose(
69041
69010
  merge.position,
69042
69011
  new Quaternion().setFromEuler(
@@ -69413,6 +69382,49 @@ void main() {
69413
69382
  return mesh;
69414
69383
  }
69415
69384
  }
69385
+ function createGeometryFromMesh(g3d2, mesh, section) {
69386
+ const colorIndices = createColorIndices(g3d2, mesh, section);
69387
+ const positions = g3d2.positions.subarray(
69388
+ g3d2.getMeshVertexStart(mesh) * 3,
69389
+ g3d2.getMeshVertexEnd(mesh) * 3
69390
+ );
69391
+ const start = g3d2.getMeshIndexStart(mesh, section);
69392
+ const end = g3d2.getMeshIndexEnd(mesh, section);
69393
+ const indices = g3d2.indices.subarray(start, end);
69394
+ return createGeometryFromArrays(
69395
+ positions,
69396
+ indices,
69397
+ colorIndices
69398
+ );
69399
+ }
69400
+ function createColorIndices(g3d2, mesh, section) {
69401
+ const vertexCount = g3d2.getMeshVertexCount(mesh);
69402
+ const result = new Uint16Array(vertexCount);
69403
+ const subStart = g3d2.getMeshSubmeshStart(mesh, section);
69404
+ const subEnd = g3d2.getMeshSubmeshEnd(mesh, section);
69405
+ for (let submesh = subStart; submesh < subEnd; submesh++) {
69406
+ const start = g3d2.getSubmeshIndexStart(submesh);
69407
+ const end = g3d2.getSubmeshIndexEnd(submesh);
69408
+ const index2 = g3d2.colorIndices[submesh];
69409
+ for (let i2 = start; i2 < end; i2++) {
69410
+ const vertexIndex = g3d2.indices[i2];
69411
+ result[vertexIndex] = index2;
69412
+ }
69413
+ }
69414
+ return result;
69415
+ }
69416
+ function createGeometryFromArrays(vertices, indices, colorIndices = void 0) {
69417
+ const geometry = new BufferGeometry();
69418
+ geometry.setAttribute("position", new BufferAttribute(vertices, 3));
69419
+ geometry.setIndex(new Uint32BufferAttribute(indices, 1));
69420
+ if (colorIndices) {
69421
+ geometry.setAttribute(
69422
+ "colorIndex",
69423
+ new Uint16BufferAttribute(colorIndices, 1)
69424
+ );
69425
+ }
69426
+ return geometry;
69427
+ }
69416
69428
  class InstancedMeshFactory {
69417
69429
  constructor(mapping, vimIndex = 0) {
69418
69430
  __publicField(this, "_mapping");
@@ -86829,7 +86841,8 @@ Averrage Date/Second ${avgDataRatePS} kb
86829
86841
  const Ids = {
86830
86842
  showGhost: "isolationPanel.showGhost",
86831
86843
  ghostOpacity: "isolationPanel.ghostOpacity",
86832
- transparency: "isolationPanel.transparency",
86844
+ showTransparent: "isolationPanel.showTransparent",
86845
+ transparentOpacity: "isolationPanel.transparentOpacity",
86833
86846
  outlineEnabled: "isolationPanel.outlineEnabled",
86834
86847
  outlineQuality: "isolationPanel.outlineQuality",
86835
86848
  outlineThickness: "isolationPanel.outlineThickness",
@@ -86848,9 +86861,20 @@ Averrage Date/Second ${avgDataRatePS} kb
86848
86861
  entries: [
86849
86862
  {
86850
86863
  type: "bool",
86851
- id: Ids.transparency,
86852
- label: "Transparency",
86853
- state: props.state.transparency
86864
+ id: Ids.showTransparent,
86865
+ label: "Show Transparent",
86866
+ state: props.state.showTransparent
86867
+ },
86868
+ {
86869
+ type: "number",
86870
+ id: Ids.transparentOpacity,
86871
+ label: "Transparent Opacity",
86872
+ state: props.state.transparentOpacity,
86873
+ enabled: () => props.state.showTransparent.get(),
86874
+ min: 0,
86875
+ max: 1,
86876
+ step: 0.05,
86877
+ transform: (n) => Math.max(0, Math.min(1, n))
86854
86878
  },
86855
86879
  {
86856
86880
  type: "bool",
@@ -86931,7 +86955,8 @@ Averrage Date/Second ${avgDataRatePS} kb
86931
86955
  const showPanel = useStateRef(false);
86932
86956
  const showRooms = useStateRef(false);
86933
86957
  const showGhost = useStateRef(() => adapter.getShowGhost(), true);
86934
- const transparency = useStateRef(() => adapter.getTransparency(), true);
86958
+ const showTransparent = useStateRef(() => adapter.getShowTransparent(), true);
86959
+ const transparentOpacity = useStateRef(() => adapter.getTransparentOpacity(), true, "vim.transparent.opacity");
86935
86960
  const outlineEnabled = useStateRef(() => adapter.getOutlineEnabled(), true, "vim.outline.enabled");
86936
86961
  const outlineQuality = useStateRef(() => adapter.getOutlineQuality(), true, "vim.outline.quality");
86937
86962
  const outlineThickness = useStateRef(() => adapter.getOutlineThickness(), true, "vim.outline.thickness");
@@ -86959,7 +86984,8 @@ Averrage Date/Second ${avgDataRatePS} kb
86959
86984
  if (v) onAutoIsolate.call();
86960
86985
  });
86961
86986
  showGhost.useOnChange((v) => adapter.showGhost(v));
86962
- transparency.useOnChange((v) => adapter.setTransparency(v));
86987
+ showTransparent.useOnChange((v) => adapter.setShowTransparent(v));
86988
+ transparentOpacity.useOnChange((v) => adapter.setTransparentOpacity(v));
86963
86989
  outlineEnabled.useOnChange((v) => adapter.setOutlineEnabled(v));
86964
86990
  outlineQuality.useOnChange((v) => adapter.setOutlineQuality(v));
86965
86991
  outlineThickness.useOnChange((v) => adapter.setOutlineThickness(v));
@@ -86977,7 +87003,8 @@ Averrage Date/Second ${avgDataRatePS} kb
86977
87003
  autoIsolate: autoIsolate2,
86978
87004
  showPanel,
86979
87005
  showGhost,
86980
- transparency,
87006
+ showTransparent,
87007
+ transparentOpacity,
86981
87008
  outlineEnabled,
86982
87009
  outlineQuality,
86983
87010
  outlineThickness,
@@ -87007,13 +87034,13 @@ Averrage Date/Second ${avgDataRatePS} kb
87007
87034
  }
87008
87035
  function createWebglIsolationAdapter(viewer, initialState) {
87009
87036
  var ghost2 = (initialState == null ? void 0 : initialState.showGhost) ?? false;
87010
- var transparency = (initialState == null ? void 0 : initialState.transparency) ?? true;
87037
+ var showTransparent = (initialState == null ? void 0 : initialState.showTransparent) ?? true;
87011
87038
  var rooms = (initialState == null ? void 0 : initialState.showRooms) ?? false;
87012
87039
  function updateMaterials() {
87013
87040
  const m = viewer.materials;
87014
87041
  viewer.renderer.modelMaterial = new MaterialSet(
87015
87042
  m.modelOpaqueMaterial,
87016
- transparency ? m.modelTransparentMaterial : m.modelOpaqueMaterial,
87043
+ showTransparent ? m.modelTransparentMaterial : m.modelOpaqueMaterial,
87017
87044
  ghost2 ? m.ghostMaterial : void 0
87018
87045
  );
87019
87046
  }
@@ -87080,7 +87107,11 @@ Averrage Date/Second ${avgDataRatePS} kb
87080
87107
  getGhostOpacity: () => viewer.materials.ghostOpacity,
87081
87108
  setGhostOpacity: (opacity) => viewer.materials.ghostOpacity = opacity,
87082
87109
  getShowGhost: () => ghost2,
87083
- getTransparency: () => transparency,
87110
+ getShowTransparent: () => showTransparent,
87111
+ getTransparentOpacity: () => viewer.materials.transparentOpacity,
87112
+ setTransparentOpacity: (opacity) => {
87113
+ viewer.materials.transparentOpacity = opacity;
87114
+ },
87084
87115
  getOutlineEnabled: () => viewer.renderer.outlineEnabled,
87085
87116
  getOutlineQuality: () => {
87086
87117
  const scale = viewer.renderer.outlineScale;
@@ -87091,8 +87122,8 @@ Averrage Date/Second ${avgDataRatePS} kb
87091
87122
  getOutlineThickness: () => viewer.materials.outlineThickness,
87092
87123
  getSelectionFillMode: () => viewer.materials.selectionFillMode,
87093
87124
  getSelectionOverlayOpacity: () => viewer.materials.selectionOverlayOpacity,
87094
- setTransparency: (enabled) => {
87095
- transparency = enabled;
87125
+ setShowTransparent: (enabled) => {
87126
+ showTransparent = enabled;
87096
87127
  updateMaterials();
87097
87128
  },
87098
87129
  setOutlineEnabled: (enabled) => {
@@ -87157,7 +87188,7 @@ Averrage Date/Second ${avgDataRatePS} kb
87157
87188
  isolation: {
87158
87189
  autoIsolate: false,
87159
87190
  showGhost: true,
87160
- transparency: true,
87191
+ showTransparent: true,
87161
87192
  showRooms: false
87162
87193
  },
87163
87194
  sectionBox: {
@@ -87286,9 +87317,18 @@ Averrage Date/Second ${avgDataRatePS} kb
87286
87317
  },
87287
87318
  {
87288
87319
  type: "bool",
87289
- id: "transparency",
87290
- label: "Transparency",
87291
- state: isolation.transparency
87320
+ id: "showTransparent",
87321
+ label: "Show Transparent",
87322
+ state: isolation.showTransparent
87323
+ },
87324
+ {
87325
+ type: "number",
87326
+ id: "transparentOpacity",
87327
+ label: "Transparent Opacity",
87328
+ info: "[0,1]",
87329
+ step: 0.05,
87330
+ transform: (n) => Math.max(0, Math.min(1, n)),
87331
+ state: isolation.transparentOpacity
87292
87332
  },
87293
87333
  {
87294
87334
  type: "bool",
@@ -87897,10 +87937,13 @@ Averrage Date/Second ${avgDataRatePS} kb
87897
87937
  setGhostOpacity: (opacity) => {
87898
87938
  viewer.renderer.ghostOpacity = opacity;
87899
87939
  },
87900
- setTransparency: (_enabled) => {
87940
+ setShowTransparent: (_enabled) => {
87901
87941
  },
87902
87942
  getShowGhost: () => ghost2.get(),
87903
- getTransparency: () => true,
87943
+ getShowTransparent: () => true,
87944
+ getTransparentOpacity: () => 0.25,
87945
+ setTransparentOpacity: (_opacity) => {
87946
+ },
87904
87947
  getOutlineEnabled: () => true,
87905
87948
  getOutlineQuality: () => "high",
87906
87949
  getOutlineThickness: () => 2,
@@ -87963,7 +88006,7 @@ Averrage Date/Second ${avgDataRatePS} kb
87963
88006
  isolation: {
87964
88007
  autoIsolate: false,
87965
88008
  showGhost: false,
87966
- transparency: true,
88009
+ showTransparent: true,
87967
88010
  showRooms: false
87968
88011
  },
87969
88012
  sectionBox: {