@inweb/viewer-three 27.2.1 → 27.2.3

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.
@@ -31,69 +31,65 @@ import {
31
31
  MeshBasicMaterial,
32
32
  Object3D,
33
33
  Plane,
34
- Vector3,
35
34
  } from "three";
36
35
 
37
- class PlaneHelper extends Line {
36
+ export class PlaneHelper2 extends Object3D {
38
37
  public plane: Plane;
39
38
  public size: number;
40
- public offset: Vector3;
41
- public helper: Object3D;
39
+ public outline: Line;
40
+ public mesh: Mesh;
42
41
 
43
- constructor(plane: Plane, size = 1, color = 0xffff00, offset: Vector3 = new Vector3()) {
44
- // const positions = [1, -1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0];
45
- const positions = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0];
42
+ constructor(size = 1, color = 0xf0f0f0, opacity = 0.15) {
43
+ super();
44
+
45
+ (this as any).type = "PlaneHelper2";
46
+ this.size = size;
46
47
 
48
+ const positions = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0];
47
49
  const geometry = new BufferGeometry();
48
50
  geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
49
51
  geometry.computeBoundingSphere();
50
52
 
51
- super(geometry, new LineBasicMaterial({ color, toneMapped: false }));
52
-
53
- (this as any).type = "PlaneHelper";
54
-
55
- this.plane = plane;
56
- this.size = size;
57
- this.offset = offset;
53
+ this.outline = new Line(geometry, new LineBasicMaterial({ color, toneMapped: false }));
58
54
 
59
55
  const positions2 = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0];
60
-
61
56
  const geometry2 = new BufferGeometry();
62
57
  geometry2.setAttribute("position", new Float32BufferAttribute(positions2, 3));
63
58
  geometry2.computeBoundingSphere();
64
59
 
65
- this.helper = new Mesh(
60
+ this.mesh = new Mesh(
66
61
  geometry2,
67
62
  new MeshBasicMaterial({
68
63
  color,
69
- opacity: 0.2,
64
+ opacity,
70
65
  transparent: true,
71
66
  depthWrite: false,
72
67
  toneMapped: false,
73
68
  side: DoubleSide,
74
69
  })
75
70
  );
76
- this.add(this.helper);
71
+
72
+ this.add(this.outline);
73
+ this.add(this.mesh);
77
74
  }
78
75
 
79
76
  dispose() {
80
- this.geometry.dispose();
81
- (this.material as any).dispose();
82
- (this.children[0] as any).geometry.dispose();
83
- (this.children[0] as any).material.dispose();
77
+ this.outline.geometry.dispose();
78
+ (this.outline.material as LineBasicMaterial).dispose();
79
+ this.mesh.geometry.dispose();
80
+ (this.mesh.material as MeshBasicMaterial).dispose();
84
81
  }
85
82
 
86
83
  override updateMatrixWorld(force: boolean) {
87
- this.position.set(0, 0, 0);
88
- this.lookAt(this.plane.normal);
89
-
90
- this.position.copy(this.offset);
91
- this.translateZ(-(this.offset.dot(this.plane.normal) + this.plane.constant));
92
-
93
84
  this.scale.set(0.5 * this.size, 0.5 * this.size, 1);
94
-
95
85
  super.updateMatrixWorld(force);
96
86
  }
97
- }
98
87
 
99
- export { PlaneHelper };
88
+ getLineMaterial(): LineBasicMaterial {
89
+ return this.outline.material as LineBasicMaterial;
90
+ }
91
+
92
+ getMeshMaterial(): MeshBasicMaterial {
93
+ return this.mesh.material as MeshBasicMaterial;
94
+ }
95
+ }