vim-web 0.6.0-dev.10 → 0.6.0-dev.12

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.js CHANGED
@@ -47528,25 +47528,6 @@ const _CameraMovementSnap = class _CameraMovementSnap extends CameraMovement$1 {
47528
47528
  };
47529
47529
  __publicField(_CameraMovementSnap, "_ZERO", new Vector3());
47530
47530
  let CameraMovementSnap = _CameraMovementSnap;
47531
- function createOpaque() {
47532
- return new StandardMaterial(createBasicOpaque());
47533
- }
47534
- function createTransparent() {
47535
- return new StandardMaterial(createBasicTransparent());
47536
- }
47537
- function createBasicOpaque() {
47538
- return new MeshLambertMaterial({
47539
- color: 13421772,
47540
- flatShading: true,
47541
- side: DoubleSide
47542
- });
47543
- }
47544
- function createBasicTransparent() {
47545
- const mat = createBasicOpaque();
47546
- mat.transparent = true;
47547
- mat.opacity = 0.25;
47548
- return mat;
47549
- }
47550
47531
  class StandardMaterial {
47551
47532
  constructor(material) {
47552
47533
  __publicField(this, "three");
@@ -53761,7 +53742,7 @@ let SectionBox$1 = class SectionBox {
53761
53742
  }
53762
53743
  };
53763
53744
  class Gizmos {
53764
- constructor(renderer, viewport, viewer, camera2) {
53745
+ constructor(renderer, viewport, viewer, camera2, settings2) {
53765
53746
  __publicField(this, "_viewport");
53766
53747
  __publicField(this, "_measure");
53767
53748
  /**
@@ -53788,9 +53769,9 @@ class Gizmos {
53788
53769
  renderer,
53789
53770
  camera2,
53790
53771
  viewer.inputs,
53791
- viewer.settings
53772
+ settings2
53792
53773
  );
53793
- this.axes = new GizmoAxes(camera2, viewport, viewer.settings.axes);
53774
+ this.axes = new GizmoAxes(camera2, viewport, settings2.axes);
53794
53775
  this.markers = new GizmoMarkers(renderer, viewer.selection);
53795
53776
  (_a3 = viewport.canvas.parentElement) == null ? void 0 : _a3.prepend(this.axes.canvas);
53796
53777
  }
@@ -54193,33 +54174,13 @@ function createGhostShader() {
54193
54174
  });
54194
54175
  }
54195
54176
  class OutlineMaterial {
54196
- constructor(options, onUpdate) {
54177
+ constructor(onUpdate) {
54197
54178
  __publicField(this, "three");
54198
- __publicField(this, "_camera");
54199
54179
  __publicField(this, "_resolution");
54200
- __publicField(this, "_precision", 1);
54201
54180
  __publicField(this, "_onUpdate");
54202
54181
  this.three = createOutlineMaterial();
54203
54182
  this._onUpdate = onUpdate;
54204
- this._precision = (options == null ? void 0 : options.precision) ?? 1;
54205
- this._resolution = (options == null ? void 0 : options.resolution) ?? new Vector2(1, 1);
54206
- this.resolution = this._resolution;
54207
- if (options == null ? void 0 : options.sceneBuffer) {
54208
- this.sceneBuffer = options.sceneBuffer;
54209
- }
54210
- this.camera = options == null ? void 0 : options.camera;
54211
- }
54212
- /**
54213
- * Precision of the outline. This is used to scale the resolution of the outline.
54214
- */
54215
- get precision() {
54216
- return this._precision;
54217
- }
54218
- set precision(value) {
54219
- var _a3;
54220
- this._precision = value;
54221
- this.resolution = this._resolution;
54222
- (_a3 = this._onUpdate) == null ? void 0 : _a3.call(this);
54183
+ this._resolution = new Vector2(1, 1);
54223
54184
  }
54224
54185
  /**
54225
54186
  * Resolution of the outline. This should match the resolution of screen.
@@ -54230,29 +54191,15 @@ class OutlineMaterial {
54230
54191
  set resolution(value) {
54231
54192
  var _a3;
54232
54193
  this.three.uniforms.screenSize.value.set(
54233
- value.x * this._precision,
54234
- value.y * this._precision,
54235
- 1 / (value.x * this._precision),
54236
- 1 / (value.y * this._precision)
54194
+ value.x,
54195
+ value.y,
54196
+ 1 / value.x,
54197
+ 1 / value.y
54237
54198
  );
54238
54199
  this._resolution = value;
54239
54200
  this.three.uniformsNeedUpdate = true;
54240
54201
  (_a3 = this._onUpdate) == null ? void 0 : _a3.call(this);
54241
54202
  }
54242
- /**
54243
- * Camera used to render the outline.
54244
- */
54245
- get camera() {
54246
- return this._camera;
54247
- }
54248
- set camera(value) {
54249
- var _a3;
54250
- this._camera = value;
54251
- this.three.uniforms.cameraNear.value = (value == null ? void 0 : value.near) ?? 1;
54252
- this.three.uniforms.cameraFar.value = (value == null ? void 0 : value.far) ?? 1e3;
54253
- this.three.uniformsNeedUpdate = true;
54254
- (_a3 = this._onUpdate) == null ? void 0 : _a3.call(this);
54255
- }
54256
54203
  /**
54257
54204
  * Thickness of the outline in pixels (of the outline render target).
54258
54205
  */
@@ -54265,18 +54212,6 @@ class OutlineMaterial {
54265
54212
  this.three.uniformsNeedUpdate = true;
54266
54213
  (_a3 = this._onUpdate) == null ? void 0 : _a3.call(this);
54267
54214
  }
54268
- /**
54269
- * Color of the outline.
54270
- */
54271
- get color() {
54272
- return this.three.uniforms.outlineColor.value;
54273
- }
54274
- set color(value) {
54275
- var _a3;
54276
- this.three.uniforms.outlineColor.value.set(value);
54277
- this.three.uniformsNeedUpdate = true;
54278
- (_a3 = this._onUpdate) == null ? void 0 : _a3.call(this);
54279
- }
54280
54215
  /**
54281
54216
  * Scene buffer used to render the outline.
54282
54217
  */
@@ -54289,18 +54224,6 @@ class OutlineMaterial {
54289
54224
  this.three.uniformsNeedUpdate = true;
54290
54225
  (_a3 = this._onUpdate) == null ? void 0 : _a3.call(this);
54291
54226
  }
54292
- /**
54293
- * Depth buffer used to render the outline.
54294
- */
54295
- get depthBuffer() {
54296
- return this.three.uniforms.depthBuffer.value;
54297
- }
54298
- set depthBuffer(value) {
54299
- var _a3;
54300
- this.three.uniforms.depthBuffer.value = value;
54301
- this.three.uniformsNeedUpdate = true;
54302
- (_a3 = this._onUpdate) == null ? void 0 : _a3.call(this);
54303
- }
54304
54227
  /**
54305
54228
  * Dispose of the outline material.
54306
54229
  */
@@ -54314,17 +54237,8 @@ function createOutlineMaterial() {
54314
54237
  glslVersion: GLSL3,
54315
54238
  depthWrite: false,
54316
54239
  uniforms: {
54317
- // Input buffers
54318
54240
  sceneBuffer: { value: null },
54319
- depthBuffer: { value: null },
54320
- // Input parameters
54321
- cameraNear: { value: 1 },
54322
- cameraFar: { value: 1e3 },
54323
- screenSize: {
54324
- value: new Vector4(1, 1, 1, 1)
54325
- },
54326
- // Options
54327
- outlineColor: { value: new Color(16777215) },
54241
+ screenSize: { value: new Vector4(1, 1, 1, 1) },
54328
54242
  thickness: { value: 2 }
54329
54243
  },
54330
54244
  vertexShader: `
@@ -54622,9 +54536,7 @@ function applyMaterial(mesh, value) {
54622
54536
  mesh.visible = true;
54623
54537
  }
54624
54538
  const _Materials = class _Materials {
54625
- constructor(opaque, transparent, modelOpaque, modelTransparent, ghost2, mask, outline, merge) {
54626
- __publicField(this, "_opaque");
54627
- __publicField(this, "_transparent");
54539
+ constructor(modelOpaque, modelTransparent, ghost2, mask, outline, merge) {
54628
54540
  __publicField(this, "_modelOpaque");
54629
54541
  __publicField(this, "_modelTransparent");
54630
54542
  __publicField(this, "_ghost");
@@ -54633,20 +54545,15 @@ const _Materials = class _Materials {
54633
54545
  __publicField(this, "_outline");
54634
54546
  __publicField(this, "_merge");
54635
54547
  __publicField(this, "_clippingPlanes");
54636
- __publicField(this, "_sectionStrokeWidth", 0.01);
54637
- __publicField(this, "_sectionStrokeFalloff", 0.75);
54638
- __publicField(this, "_sectionStrokeColor", new Color(16185078));
54639
54548
  __publicField(this, "_onUpdate", new distExports$2.SignalDispatcher());
54640
54549
  // Shared color palette texture for all scene materials
54641
54550
  __publicField(this, "_colorPaletteTexture");
54642
- this._opaque = opaque ?? createOpaque();
54643
- this._transparent = transparent ?? createTransparent();
54644
54551
  const onUpdate = () => this._onUpdate.dispatch();
54645
54552
  this._modelOpaque = modelOpaque ?? createModelOpaque(onUpdate);
54646
54553
  this._modelTransparent = modelTransparent ?? createModelTransparent(onUpdate);
54647
54554
  this._ghost = ghost2 ?? new GhostMaterial(void 0, onUpdate);
54648
54555
  this._mask = mask ?? createMaskMaterial();
54649
- this._outline = outline ?? new OutlineMaterial(void 0, onUpdate);
54556
+ this._outline = outline ?? new OutlineMaterial(onUpdate);
54650
54557
  this._merge = merge ?? new MergeMaterial(onUpdate);
54651
54558
  }
54652
54559
  static createInstance(instance) {
@@ -54692,12 +54599,8 @@ const _Materials = class _Materials {
54692
54599
  * Updates material settings based on the provided configuration.
54693
54600
  */
54694
54601
  applySettings(settings2) {
54695
- this.modelColor = settings2.standard.color;
54696
54602
  this._ghost.opacity = settings2.ghost.opacity;
54697
54603
  this._ghost.color = settings2.ghost.color;
54698
- this.sectionStrokeWidth = settings2.section.strokeWidth;
54699
- this.sectionStrokeFalloff = settings2.section.strokeFalloff;
54700
- this.sectionStrokeColor = settings2.section.strokeColor;
54701
54604
  this.outlineOpacity = settings2.outline.opacity;
54702
54605
  this.outlineColor = settings2.outline.color;
54703
54606
  this.outlineThickness = settings2.outline.thickness;
@@ -54706,15 +54609,6 @@ const _Materials = class _Materials {
54706
54609
  get onUpdate() {
54707
54610
  return this._onUpdate.asEvent();
54708
54611
  }
54709
- /** Base color tint applied to opaque and transparent model materials. */
54710
- get modelColor() {
54711
- return this._opaque.color;
54712
- }
54713
- set modelColor(color) {
54714
- this._opaque.color = color;
54715
- this._transparent.color = color;
54716
- this._onUpdate.dispatch();
54717
- }
54718
54612
  /** Opacity of the selection outline (0 = invisible, 1 = fully opaque). */
54719
54613
  get outlineOpacity() {
54720
54614
  return this._merge.opacity;
@@ -54744,45 +54638,10 @@ const _Materials = class _Materials {
54744
54638
  this._clippingPlanes = value;
54745
54639
  this._modelOpaque.clippingPlanes = value ?? null;
54746
54640
  this._modelTransparent.clippingPlanes = value ?? null;
54747
- this._opaque.clippingPlanes = value ?? null;
54748
- this._transparent.clippingPlanes = value ?? null;
54749
54641
  this._ghost.clippingPlanes = value ?? null;
54750
54642
  this._mask.clippingPlanes = value ?? null;
54751
54643
  this._onUpdate.dispatch();
54752
54644
  }
54753
- /** Width of the stroke rendered where the section box intersects the model. */
54754
- get sectionStrokeWidth() {
54755
- return this._sectionStrokeWidth;
54756
- }
54757
- set sectionStrokeWidth(value) {
54758
- if (this._sectionStrokeWidth === value) return;
54759
- this._sectionStrokeWidth = value;
54760
- this._opaque.sectionStrokeWidth = value;
54761
- this._transparent.sectionStrokeWidth = value;
54762
- this._onUpdate.dispatch();
54763
- }
54764
- /** Gradient falloff of the section box intersection stroke. */
54765
- get sectionStrokeFalloff() {
54766
- return this._sectionStrokeFalloff;
54767
- }
54768
- set sectionStrokeFalloff(value) {
54769
- if (this._sectionStrokeFalloff === value) return;
54770
- this._sectionStrokeFalloff = value;
54771
- this._opaque.sectionStrokeFalloff = value;
54772
- this._transparent.sectionStrokeFalloff = value;
54773
- this._onUpdate.dispatch();
54774
- }
54775
- /** Color of the section box intersection stroke. */
54776
- get sectionStrokeColor() {
54777
- return this._sectionStrokeColor;
54778
- }
54779
- set sectionStrokeColor(value) {
54780
- if (this._sectionStrokeColor === value) return;
54781
- this._sectionStrokeColor = value;
54782
- this._opaque.sectionStrokeColor = value;
54783
- this._transparent.sectionStrokeColor = value;
54784
- this._onUpdate.dispatch();
54785
- }
54786
54645
  /**
54787
54646
  * Creates the fixed quantized color palette texture if it doesn't exist.
54788
54647
  * The palette is deterministic (25³ = 15,625 quantized colors in 128×128 texture)
@@ -54792,6 +54651,8 @@ const _Materials = class _Materials {
54792
54651
  if (this._colorPaletteTexture) return;
54793
54652
  const textureData = buildPaletteTexture();
54794
54653
  this._colorPaletteTexture = new DataTexture(
54654
+ // Cast: TS 5.7 narrows Uint8Array.buffer to ArrayBufferLike (includes SharedArrayBuffer),
54655
+ // but Three.js expects BufferSource (ArrayBuffer only). Safe — Uint8Array always backs ArrayBuffer.
54795
54656
  textureData,
54796
54657
  128,
54797
54658
  128,
@@ -54801,8 +54662,6 @@ const _Materials = class _Materials {
54801
54662
  this._colorPaletteTexture.needsUpdate = true;
54802
54663
  this._colorPaletteTexture.minFilter = NearestFilter;
54803
54664
  this._colorPaletteTexture.magFilter = NearestFilter;
54804
- this._opaque.setColorPaletteTexture(this._colorPaletteTexture);
54805
- this._transparent.setColorPaletteTexture(this._colorPaletteTexture);
54806
54665
  this._modelOpaque.setColorPaletteTexture(this._colorPaletteTexture);
54807
54666
  this._modelTransparent.setColorPaletteTexture(this._colorPaletteTexture);
54808
54667
  this._onUpdate.dispatch();
@@ -54813,8 +54672,6 @@ const _Materials = class _Materials {
54813
54672
  this._colorPaletteTexture.dispose();
54814
54673
  this._colorPaletteTexture = void 0;
54815
54674
  }
54816
- this._opaque.dispose();
54817
- this._transparent.dispose();
54818
54675
  this._modelOpaque.dispose();
54819
54676
  this._modelTransparent.dispose();
54820
54677
  this._ghost.dispose();
@@ -55547,47 +55404,11 @@ function getDefaultViewerSettings() {
55547
55404
  }
55548
55405
  },
55549
55406
  background: { color: new Color(16777215) },
55550
- skybox: {
55551
- enable: true,
55552
- skyColor: new Color(16777215),
55553
- // white
55554
- groundColor: new Color(16185078),
55555
- // less white
55556
- sharpness: 2
55557
- },
55558
- skylight: {
55559
- skyColor: new Color(16777215),
55560
- groundColor: new Color(16777215),
55561
- intensity: 0.8
55562
- },
55563
- sunlights: [
55564
- {
55565
- followCamera: true,
55566
- position: new Vector3(1e3, 1e3, 1e3),
55567
- color: new Color(16777215),
55568
- intensity: 0.8
55569
- },
55570
- {
55571
- followCamera: true,
55572
- position: new Vector3(-1e3, -1e3, -1e3),
55573
- color: new Color(16777215),
55574
- intensity: 0.2
55575
- }
55576
- ],
55577
55407
  materials: {
55578
- useFastMaterials: false,
55579
- standard: {
55580
- color: new Color(13421772)
55581
- },
55582
55408
  ghost: {
55583
55409
  color: new Color(921102),
55584
55410
  opacity: 7 / 255
55585
55411
  },
55586
- section: {
55587
- strokeWidth: 0.01,
55588
- strokeFalloff: 0.75,
55589
- strokeColor: new Color(16185078)
55590
- },
55591
55412
  outline: {
55592
55413
  opacity: 0.85,
55593
55414
  color: new Color(65535),
@@ -55763,11 +55584,11 @@ let Viewport$1 = class Viewport {
55763
55584
  this._unregisterResize = () => window.removeEventListener("resize", onResize);
55764
55585
  }
55765
55586
  };
55766
- function createInputHandler(viewer) {
55587
+ function createInputHandler(viewer, controls) {
55767
55588
  return new InputHandler(
55768
55589
  viewer.viewport.canvas,
55769
55590
  createAdapter$2(viewer),
55770
- viewer.settings.camera.controls
55591
+ controls
55771
55592
  );
55772
55593
  }
55773
55594
  function createAdapter$2(viewer) {
@@ -56279,24 +56100,17 @@ class RenderPass extends Pass {
56279
56100
  }
56280
56101
  }
56281
56102
  class OutlinePass extends Pass {
56282
- constructor(camera2, material) {
56103
+ constructor(material) {
56283
56104
  super();
56284
56105
  __publicField(this, "_fsQuad");
56285
56106
  __publicField(this, "material");
56286
- this.material = material ?? new OutlineMaterial();
56287
- this.material.camera = camera2;
56107
+ this.material = material;
56288
56108
  this._fsQuad = new FullScreenQuad(this.material.three);
56289
56109
  this.needsSwap = true;
56290
56110
  }
56291
56111
  setSize(width, height) {
56292
56112
  this.material.resolution = new Vector2(width, height);
56293
56113
  }
56294
- get camera() {
56295
- return this.material.camera;
56296
- }
56297
- set camera(value) {
56298
- this.material.camera = value;
56299
- }
56300
56114
  dispose() {
56301
56115
  this._fsQuad.dispose();
56302
56116
  this.material.dispose();
@@ -56304,7 +56118,6 @@ class OutlinePass extends Pass {
56304
56118
  render(renderer, writeBuffer, readBuffer) {
56305
56119
  const depthBufferValue = writeBuffer.depthBuffer;
56306
56120
  writeBuffer.depthBuffer = false;
56307
- this.material.depthBuffer = readBuffer.depthTexture;
56308
56121
  this.material.sceneBuffer = readBuffer.texture;
56309
56122
  if (this.renderToScreen) {
56310
56123
  renderer.setRenderTarget(null);
@@ -56481,8 +56294,7 @@ class RenderingComposer {
56481
56294
  outlineHeight,
56482
56295
  {
56483
56296
  format: RedFormat,
56484
- type: UnsignedByteType,
56485
- depthTexture: new DepthTexture(outlineWidth, outlineHeight)
56297
+ type: UnsignedByteType
56486
56298
  }
56487
56299
  );
56488
56300
  this._outlineTarget.texture.name = "selectionTarget";
@@ -56496,7 +56308,6 @@ class RenderingComposer {
56496
56308
  this._selectionRenderPass.clearAlpha = 0;
56497
56309
  this._composer.addPass(this._selectionRenderPass);
56498
56310
  this._outlinePass = new OutlinePass(
56499
- this._camera,
56500
56311
  this._materials.system.outline
56501
56312
  );
56502
56313
  this._composer.addPass(this._outlinePass);
@@ -56549,7 +56360,6 @@ class RenderingComposer {
56549
56360
  set camera(value) {
56550
56361
  this._renderPass.camera = value;
56551
56362
  this._selectionRenderPass.camera = value;
56552
- this._outlinePass.material.camera = value;
56553
56363
  this._camera = value;
56554
56364
  }
56555
56365
  /**
@@ -57593,16 +57403,12 @@ let LoadRequest$2 = class LoadRequest2 extends LoadRequest$3 {
57593
57403
  }
57594
57404
  };
57595
57405
  class WebglViewer {
57596
- constructor(settings2) {
57406
+ constructor(options) {
57597
57407
  /**
57598
57408
  * The type of the viewer, indicating it is a WebGL viewer.
57599
57409
  * Useful for distinguishing between different viewer types in a multi-viewer application.
57600
57410
  */
57601
57411
  __publicField(this, "type", "webgl");
57602
- /**
57603
- * The settings configuration used by the viewer.
57604
- */
57605
- __publicField(this, "settings");
57606
57412
  __publicField(this, "_renderer");
57607
57413
  __publicField(this, "_viewport");
57608
57414
  /**
@@ -57622,22 +57428,22 @@ class WebglViewer {
57622
57428
  __publicField(this, "vimCollection", new VimCollection());
57623
57429
  __publicField(this, "_onVimLoaded", new distExports$2.SignalDispatcher());
57624
57430
  __publicField(this, "_updateId");
57625
- this.settings = createViewerSettings(settings2);
57431
+ const settings2 = createViewerSettings(options);
57626
57432
  this._materials = Materials.getInstance();
57627
57433
  const scene = new RenderScene();
57628
- this._viewport = new Viewport$1(this.settings);
57629
- this._camera = new Camera$1(scene, this._viewport, this.settings);
57434
+ this._viewport = new Viewport$1(settings2);
57435
+ this._camera = new Camera$1(scene, this._viewport, settings2);
57630
57436
  this._renderer = new Renderer$1(
57631
57437
  scene,
57632
57438
  this._viewport,
57633
57439
  this._materials,
57634
57440
  this._camera,
57635
- this.settings
57441
+ settings2
57636
57442
  );
57637
57443
  this.selection = createSelection$1();
57638
- this._inputs = createInputHandler(this);
57639
- this._gizmos = new Gizmos(this._renderer, this._viewport, this, this._camera);
57640
- this.materials.applySettings(this.settings.materials);
57444
+ this._inputs = createInputHandler(this, settings2.camera.controls);
57445
+ this._gizmos = new Gizmos(this._renderer, this._viewport, this, this._camera, settings2);
57446
+ this.materials.applySettings(settings2.materials);
57641
57447
  const size = this._renderer.three.getSize(new Vector2());
57642
57448
  const gpuPicker = new GpuPicker(
57643
57449
  this._renderer.three,