1 | import { BufferGeometry } from "../core/BufferGeometry.js";
|
2 | import { JSONMeta, Object3D, Object3DEventMap, Object3DJSON, Object3DJSONObject } from "../core/Object3D.js";
|
3 | import { Material } from "../materials/Material.js";
|
4 | import { Vector3 } from "../math/Vector3.js";
|
5 |
|
6 | export interface MeshJSONObject extends Object3DJSONObject {
|
7 | geometry: string;
|
8 | }
|
9 |
|
10 | export interface MeshJSON extends Object3DJSON {
|
11 | object: MeshJSONObject;
|
12 | }
|
13 |
|
14 | /**
|
15 | * Class representing triangular {@link https://en.wikipedia.org/wiki/Polygon_mesh | polygon mesh} based objects.
|
16 | * @remarks
|
17 | * Also serves as a base for other classes such as {@link THREE.SkinnedMesh | SkinnedMesh}, {@link THREE.InstancedMesh | InstancedMesh}.
|
18 | * @example
|
19 | * ```typescript
|
20 | * const geometry = new THREE.BoxGeometry(1, 1, 1);
|
21 | * const material = new THREE.MeshBasicMaterial({
|
22 | * color: 0xffff00
|
23 | * });
|
24 | * const {@link Mesh} = new THREE.Mesh(geometry, material);
|
25 | * scene.add(mesh);
|
26 | * ```
|
27 | * @see {@link https://threejs.org/docs/index.html#api/en/objects/Mesh | Official Documentation}
|
28 | * @see {@link https://github.com/mrdoob/three.js/blob/master/src/objects/Mesh.js | Source}
|
29 | */
|
30 | export class Mesh<
|
31 | TGeometry extends BufferGeometry = BufferGeometry,
|
32 | TMaterial extends Material | Material[] = Material | Material[],
|
33 | TEventMap extends Object3DEventMap = Object3DEventMap,
|
34 | > extends Object3D<TEventMap> {
|
35 | /**
|
36 | * Create a new instance of {@link Mesh}
|
37 | * @param geometry An instance of {@link THREE.BufferGeometry | BufferGeometry}. Default {@link THREE.BufferGeometry | `new THREE.BufferGeometry()`}.
|
38 | * @param material A single or an array of {@link THREE.Material | Material}. Default {@link THREE.MeshBasicMaterial | `new THREE.MeshBasicMaterial()`}.
|
39 | */
|
40 | constructor(geometry?: TGeometry, material?: TMaterial);
|
41 |
|
42 | /**
|
43 | * Read-only flag to check if a given object is of type { Mesh}.
|
44 | * This is a _constant_ value
|
45 | * `true`
|
46 | */
|
47 | readonly isMesh: true;
|
48 |
|
49 | /**
|
50 | * @override
|
51 | * @defaultValue `Mesh`
|
52 | */
|
53 | override readonly type: string | "Mesh";
|
54 |
|
55 | /**
|
56 | * An instance of {@link THREE.BufferGeometry | BufferGeometry} (or derived classes), defining the object's structure.
|
57 | * @defaultValue {@link THREE.BufferGeometry | `new THREE.BufferGeometry()`}.
|
58 | */
|
59 | geometry: TGeometry;
|
60 |
|
61 | /**
|
62 | * An instance of material derived from the {@link THREE.Material | Material} base class or an array of materials, defining the object's appearance.
|
63 | * @defaultValue {@link THREE.MeshBasicMaterial | `new THREE.MeshBasicMaterial()`}.
|
64 | */
|
65 | material: TMaterial;
|
66 |
|
67 | /**
|
68 | * An array of weights typically from `0-1` that specify how much of the morph is applied.
|
69 | * @defaultValue `undefined`, _but reset to a blank array by {@link updateMorphTargets | .updateMorphTargets()}._
|
70 | */
|
71 | morphTargetInfluences?: number[] | undefined;
|
72 |
|
73 | /**
|
74 | * A dictionary of morphTargets based on the `morphTarget.name` property.
|
75 | * @defaultValue `undefined`, _but rebuilt by {@link updateMorphTargets | .updateMorphTargets()}._
|
76 | */
|
77 | morphTargetDictionary?: { [key: string]: number } | undefined;
|
78 |
|
79 | /**
|
80 | * Updates the morphTargets to have no influence on the object
|
81 | * @remarks Resets the {@link morphTargetInfluences} and {@link morphTargetDictionary} properties.
|
82 | */
|
83 | updateMorphTargets(): void;
|
84 |
|
85 | /**
|
86 | * Get the local-space position of the vertex at the given index,
|
87 | * taking into account the current animation state of both morph targets and skinning.
|
88 | * @param index Expects a `Integer`
|
89 | * @param target
|
90 | */
|
91 | getVertexPosition(index: number, target: Vector3): Vector3;
|
92 |
|
93 | toJSON(meta?: JSONMeta): MeshJSON;
|
94 | }
|