Mesh
패키지: @aspose/3d (v24.12.0)
Mesh 하위 경로 가져오기를 통해서도 사용할 수 있습니다. @aspose/3d/entities.
Mesh는 에서 기본 다각형 기하학 엔터티입니다. @aspose/3d. 정점 위치를 컨트롤 포인트로 저장하고, 정점 인덱스 목록으로 다각형 면을 정의하며, 노멀 및 UV 좌표와 같은 여러 정점 요소 데이터 레이어를 지원합니다.
export class Mesh extends GeometryImageRenderOptions
A3DObject ← SceneObject ← Entity ← Geometry ← Mesh
ImageRenderOptions
단일 삼각형 메시를 생성하고, 이를 씬에 첨부한 뒤 GLB 형식으로 저장합니다.
import { Scene, Vector4 } from '@aspose/3d';
import { Mesh } from '@aspose/3d/entities';
// Create the mesh and define three control points (vertices)
const mesh = new Mesh();
mesh.controlPoints.push(
new Vector4(0, 1, 0, 1), // apex
new Vector4(-1, 0, 0, 1), // bottom-left
new Vector4(1, 0, 0, 1), // bottom-right
);
// Define one triangular polygon using vertex indices
mesh.createPolygon(0, 1, 2);
// Attach the mesh to the scene and save (extension infers GLB format)
const scene = new Scene();
scene.rootNode.createChildNode('triangle', mesh);
scene.save('triangle.glb');
console.log(`Polygon count: ${mesh.polygonCount}`); // 1
ImageRenderOptions
| Name | Type | Access | Description |
|---|---|---|---|
edges | number[] | Read | Gets the edges. |
polygonCount | number | Read | Gets the polygon count. |
polygons | number[][] | Read | Gets the polygons. |
deformers | any[] | Read | Gets the deformers. |
| Signature | Description |
|---|---|
| `constructor(name: string | null, _heightMap: any, _transform: any, _triMesh: boolean |
createPolygon() | Adds a new polygon to the mesh |
getPolygonSize(index: number) → number | Returns the number of vertices in the polygon at the given index |
toMesh() → Mesh | Returns a Mesh instance representing the current object (identity conversion) |
optimize(_vertexElements: boolean, _toleranceControlPoint: number, _toleranceNormal: number, _toleranceUV: number) → Mesh | Not implemented in the FOSS edition — throws at runtime. Reduces mesh complexity using vertex element flag and tolerance values for control points, normals, and UVs |
doBoolean(_op: any, _a: Mesh, _transformA: any, _b: Mesh, _transformB: any) → Mesh | Not implemented in the FOSS edition — throws at runtime. Performs a boolean operation defined by _op on meshes _a and _b with respective transforms |
isManifold() → boolean | Not implemented in the FOSS edition — throws at runtime. Returns true if manifold is set. |
union(_a: Mesh, _b: Mesh) → Mesh | Not implemented in the FOSS edition — throws at runtime. Returns a new Mesh that is the union of meshes _a and _b |
difference(_a: Mesh, _b: Mesh) → Mesh | Not implemented in the FOSS edition — throws at runtime. Returns a new Mesh that is the difference of mesh _a minus mesh _b |
intersect(_a: Mesh, _b: Mesh) → Mesh | Not implemented in the FOSS edition — throws at runtime. |
triangulate() → Mesh | Converts all polygons in the mesh to triangles and returns the mesh |
getBoundingBox() → any | Returns the bounding box. |
getEntityRendererKey() → any | Not implemented in the FOSS edition — throws at runtime. Returns the entity renderer key. |
ImageRenderOptions
createPolygon(…indices)
제공된 컨트롤 포인트 인덱스를 사용하여 새로운 다각형 면을 정의합니다. 인덱스는 유효한 위치를 참조해야 합니다. controlPoints.
createPolygon(...indices: number[]): voidImageRenderOptions
...indices number[]
세 개 이상의 제로 기반 인덱스 controlPoints 배열, 반시계 방향 감김 순서로.
ImageRenderOptions
void
ImageRenderOptions
import { Vector4 } from '@aspose/3d';
import { Mesh } from '@aspose/3d/entities';
const mesh = new Mesh();
mesh.controlPoints.push(
new Vector4(0, 0, 0, 1),
new Vector4(1, 0, 0, 1),
new Vector4(1, 1, 0, 1),
new Vector4(0, 1, 0, 1),
);
// Define a quad as two triangles, or a single quad polygon:
mesh.createPolygon(0, 1, 2, 3);
console.log(`Polygons: ${mesh.polygonCount}`); // 1
triangulate()
이 메시의 모든 비삼각형 다각형을 삼각형으로 변환합니다. 삼각형화된 메시를 반환합니다(같은 인스턴스일 수도 있고 새 인스턴스일 수도 있습니다).
triangulate(): MeshImageRenderOptions
Mesh
삼각형화된 메시.
ImageRenderOptions
const mesh = new Mesh();
mesh.controlPoints.push(
new Vector4(0, 0, 0, 1),
new Vector4(1, 0, 0, 1),
new Vector4(1, 1, 0, 1),
new Vector4(0, 1, 0, 1),
);
mesh.createPolygon(0, 1, 2, 3); // quad
const triangulated = mesh.triangulate();
console.log(Polygons after triangulation: ${triangulated.polygonCount}); // 2
---
### toMesh()
메시를 ~ 형태로 반환합니다. `Mesh` 인스턴스. 에 대해 `Mesh` 객체에 대해 이것은 항등 연산이며, 이 메서드는 상속받는 기본 기하학 타입에서 더 의미가 있습니다. `Geometry`.
```typescript
toMesh(): MeshImageRenderOptions
Mesh
이 Mesh 인스턴스.
static union(a, b)
NOT IMPLEMENTED. 이 메서드는 API 표면에 정의되어 있지만 예외를 발생시킵니다. Error('union is not implemented') 런타임에. 프로덕션 코드에서 호출하지 마세요.
두 Mesh의 불리언 합집합을 수행합니다. 결과는 두 입력의 결합된 부피를 포함합니다.
static union(a: Mesh, b: Mesh): MeshImageRenderOptions
a Mesh
첫 번째 메시 피연산자.
b Mesh
두 번째 메시 피연산자.
ImageRenderOptions
Mesh
합집합을 나타내는 새로운 메시 a 및 b.
ImageRenderOptions
import { Mesh } from '@aspose/3d/entities';
// Assumes meshA and meshB are already populated Mesh instances
const combined = Mesh.union(meshA, meshB);
console.log(`Union polygon count: ${combined.polygonCount}`);static difference(a, b)
NOT IMPLEMENTED. 이 메서드는 API 표면에 정의되어 있지만 예외를 발생시킵니다. Error('difference is not implemented') 런타임에. 프로덕션 코드에서 호출하지 마세요.
불리언 차이를 수행하여 메시의 부피를 빼냅니다. b 메시에서 a.
static difference(a: Mesh, b: Mesh): MeshImageRenderOptions
a Mesh
기본 Mesh.
b Mesh
빼낼 대상 메시 a.
ImageRenderOptions
Mesh
다음을 나타내는 새로운 메시 a 빼기 b.
ImageRenderOptions
const result = Mesh.difference(meshA, meshB);
console.log(Difference polygon count: ${result.polygonCount});
---
### static intersect(a, b)
**NOT IMPLEMENTED.** 이 메서드는 API 표면에 정의되어 있지만 예외를 발생시킵니다. `Error('intersect is not implemented')` 런타임에. 프로덕션 코드에서 호출하지 마세요.
두 메시에 대한 불리언 교차를 수행합니다. 결과는 겹치는 부피만 포함합니다.
```typescript
static intersect(a: Mesh, b: Mesh): MeshImageRenderOptions
a Mesh
첫 번째 메시 피연산자.
b Mesh
두 번째 메시 피연산자.
ImageRenderOptions
Mesh
교차를 나타내는 새로운 메시 a 및 b.
ImageRenderOptions
const overlap = Mesh.intersect(meshA, meshB);
console.log(Intersection polygon count: ${overlap.polygonCount});
---
### createElement(type, mapping?, reference?)
새로운 것을 생성합니다 `VertexElement` 이 메시에 사용자 정의 정점당 속성을 위한 데이터 레이어.
```typescript
createElement(
type: VertexElementType,
mapping?: MappingMode,
reference?: ReferenceMode
): VertexElementImageRenderOptions
type VertexElementType
생성할 정점 속성의 종류 (예:, VertexElementType.Normal).
mapping MappingMode (옵션)
요소 데이터가 메시 토폴로지에 매핑되는 방식. 기본값은 MappingMode.ControlPoint.
reference ReferenceMode (옵션)
요소 인덱스가 데이터 배열을 참조하는 방식. 기본값은 ReferenceMode.Direct.
ImageRenderOptions
VertexElement
새로 생성된 정점 요소 레이어.
createElementUV(mapping, mappingMode?, referenceMode?)
이 메시에 UV 좌표 레이어를 생성합니다.
createElementUV(
mapping: TextureMapping,
mappingMode?: MappingMode,
referenceMode?: ReferenceMode
): VertexElementUVImageRenderOptions
mapping TextureMapping
생성할 UV 채널 (예:, TextureMapping.Diffuse).
mappingMode MappingMode (옵션)
UV 좌표가 정점에 매핑되는 방식.
referenceMode ReferenceMode (옵션)
UV 인덱스 데이터가 UV 배열을 참조하는 방식.
ImageRenderOptions
VertexElementUV
새로 생성된 UV 요소 레이어.
ImageRenderOptions
import { Mesh } from '@aspose/3d/entities';
import { TextureMapping } from '@aspose/3d';
const mesh = new Mesh();
// ... define control points and polygons ...
const uvLayer = mesh.createElementUV(TextureMapping.Diffuse);
console.log(`UV element created: ${uvLayer !== undefined}`);