1 | import { BufferGeometry } from "../core/BufferGeometry.js";
|
2 | import { Curve } from "../extras/core/Curve.js";
|
3 | import { Vector3 } from "../math/Vector3.js";
|
4 |
|
5 | /**
|
6 | * Creates a tube that extrudes along a 3d curve.
|
7 | * @example
|
8 | * ```typescript
|
9 | * class CustomSinCurve extends THREE.Curve {
|
10 | * constructor(scale = 1) {
|
11 | * super();
|
12 | * this.scale = scale;
|
13 | * }
|
14 | * getPoint(t, optionalTarget = new THREE.Vector3()) {
|
15 | * const tx = t * 3 - 1.5;
|
16 | * const ty = Math.sin(2 * Math.PI * t);
|
17 | * const tz = 0;
|
18 | * return optionalTarget.set(tx, ty, tz).multiplyScalar(this.scale);
|
19 | * }
|
20 | * }
|
21 | * const path = new CustomSinCurve(10);
|
22 | * const geometry = new THREE.TubeGeometry(path, 20, 2, 8, false);
|
23 | * const material = new THREE.MeshBasicMaterial({
|
24 | * color: 0x00ff00
|
25 | * });
|
26 | * const mesh = new THREE.Mesh(geometry, material);
|
27 | * scene.add(mesh);
|
28 | * ```
|
29 | * @see {@link https://threejs.org/docs/index.html#api/en/geometries/TubeGeometry | Official Documentation}
|
30 | * @see {@link https://github.com/mrdoob/three.js/blob/master/src/geometries/TubeGeometry.js | Source}
|
31 | */
|
32 | export class TubeGeometry extends BufferGeometry {
|
33 | /**
|
34 | * Create a new instance of {@link TubeGeometry}
|
35 | * @param path A 3D path that inherits from the {@link THREE.Curve | Curve} base class.
|
36 | * Default {@link THREE.QuadraticBezierCurve3 | new THREE.QuadraticBezierCurve3(new Vector3(-1, -1, 0 ), new Vector3(-1, 1, 0), new Vector3(1, 1, 0))}.
|
37 | * @param tubularSegments The number of segments that make up the tube. Expects a `Integer`. Default `64`.
|
38 | * @param radius The radius of the tube. Expects a `Float`. Default `1`.
|
39 | * @param radialSegments The number of segments that make up the cross-section. Expects a `Integer`. Default `8`.
|
40 | * @param closed Is the tube open or closed. Default `false`.
|
41 | */
|
42 | constructor(
|
43 | path?: Curve<Vector3>,
|
44 | tubularSegments?: number,
|
45 | radius?: number,
|
46 | radialSegments?: number,
|
47 | closed?: boolean,
|
48 | );
|
49 |
|
50 | /**
|
51 | * A Read-only _string_ to check if `this` object type.
|
52 | * @remarks Sub-classes will update this value.
|
53 | * @defaultValue `TubeGeometry`
|
54 | */
|
55 | override readonly type: string | "TubeGeometry";
|
56 |
|
57 | /**
|
58 | * An object with a property for each of the constructor parameters.
|
59 | * @remarks Any modification after instantiation does not change the geometry.
|
60 | */
|
61 | readonly parameters: {
|
62 | readonly path: Curve<Vector3>;
|
63 | readonly tubularSegments: number;
|
64 | readonly radius: number;
|
65 | readonly radialSegments: number;
|
66 | readonly closed: boolean;
|
67 | };
|
68 |
|
69 | /**
|
70 | * An array of { THREE.Vector3 | Vector3} tangents
|
71 | */
|
72 | tangents: Vector3[];
|
73 |
|
74 | /**
|
75 | * An array of {@link THREE.Vector3 | Vector3} normals
|
76 | */
|
77 | normals: Vector3[];
|
78 |
|
79 | /**
|
80 | * An array of {@link THREE.Vector3 | Vector3} binormals
|
81 | */
|
82 | binormals: Vector3[];
|
83 |
|
84 | /** @internal */
|
85 | static fromJSON(data: {}): TubeGeometry;
|
86 | }
|