three-base 2.0.112 → 2.0.113

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.
@@ -3,7 +3,8 @@ import { PathPointList } from "./PathPointList";
3
3
  import { PathTubeGeometry } from "./PathTubeGeometry";
4
4
  export type PipeMeshProps = {
5
5
  vector3s: Array<Vector3>;
6
- radius: number;
6
+ radius?: number;
7
+ segments?: number;
7
8
  };
8
9
  /**
9
10
  * 创建基础的管道模型
@@ -13,6 +14,7 @@ export default class PipeMesh extends Mesh<PathTubeGeometry, Material> {
13
14
  type: string;
14
15
  vector3s: Array<Vector3>;
15
16
  radius: number;
17
+ segments: number;
16
18
  pathPointList: PathPointList;
17
19
  material: Material;
18
20
  set(props: PipeMeshProps): void;
@@ -16,8 +16,9 @@ export default class PipeMesh extends Mesh {
16
16
  this.set(props);
17
17
  }
18
18
  type = "pipemesh";
19
- vector3s = [];
20
- radius = 1;
19
+ vector3s = []; // 管道上的点
20
+ radius = 1; //管道的半径
21
+ segments = 10; //管道的段数
21
22
  pathPointList = new PathPointList();
22
23
  material = new MeshLambertMaterial({
23
24
  side: DoubleSide,
@@ -26,7 +27,8 @@ export default class PipeMesh extends Mesh {
26
27
  // 设置数据
27
28
  set(props) {
28
29
  this.vector3s = props.vector3s;
29
- this.radius = props.radius;
30
+ this.radius = props.radius || 1;
31
+ this.segments = props.segments || 10;
30
32
  this.pathPointList.set(this.vector3s, props.radius * 2, 10);
31
33
  this.geometry = new PathTubeGeometry({
32
34
  pathPointList: this.pathPointList,
@@ -34,7 +36,7 @@ export default class PipeMesh extends Mesh {
34
36
  arrow: true,
35
37
  progress: 1,
36
38
  radius: props.radius,
37
- radialSegments: 10,
39
+ radialSegments: this.segments,
38
40
  },
39
41
  usage: DynamicDrawUsage,
40
42
  transparent: true,
@@ -43,7 +45,7 @@ export default class PipeMesh extends Mesh {
43
45
  // 设置指定点的坐标
44
46
  setVector(i, vector) {
45
47
  this.vector3s[i].copy(vector);
46
- this.pathPointList.set(this.vector3s, this.radius * 2, 10);
48
+ this.pathPointList.set(this.vector3s, this.radius * 2, this.segments);
47
49
  this.geometry.update(this.pathPointList, { radius: this.radius });
48
50
  }
49
51
  // 获取指定点的坐标
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-base",
3
- "version": "2.0.112",
3
+ "version": "2.0.113",
4
4
  "description": "three 3d three-base",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"