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
این نمونه مش.
static union(a, b)
NOT IMPLEMENTED. این متد در سطح API تعریف شده است اما استثنا میاندازد Error('union is not implemented') در زمان اجرا. از آن در کد تولیدی استفاده نکنید.
یک اتحاد بولی بین دو مش انجام میدهد. نتیجه شامل حجم ترکیبی هر دو ورودی است.
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
مش پایه.
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}`);