Mesh
Paket: @aspose/3d (v24.12.0)
Mesh alt-yol ithalatı aracılığıyla da kullanılabilir @aspose/3d/entities.
Mesh, içinde birincil çokgen geometri varlığıdır @aspose/3d. Düğüm konumlarını kontrol noktaları olarak depolar, çokgen yüzeylerini düğüm indeks listeleriyle tanımlar ve normaller ve UV koordinatları gibi birden çok düğüm öğesi veri katmanını destekler.
export class Mesh extends GeometryEnumerations
A3DObject ← SceneObject ← Entity ← Geometry ← Mesh
Enumerations
Tek bir üçgen mesh oluşturun, sahneye ekleyin ve GLB olarak kaydedin.
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
Enumerations
| 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. |
Enumerations
createPolygon(…indices)
Sağlanan kontrol noktası indekslerini kullanarak yeni bir çokgen yüzeyi tanımlar. İndeksler, içinde geçerli konumlara referans vermelidir controlPoints.
createPolygon(...indices: number[]): voidEnumerations
...indices number[]
Üç veya daha fazla sıfır tabanlı indeks controlPoints dizi, saat yönünün tersine sarma sırasıyla.
Enumerations
void
Enumerations
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()
Bu mesh içindeki tüm üçgen olmayan çokgenleri üçgenlere dönüştürür. Üçgenleştirilmiş mesh’i döndürür (aynı örnek olabilir veya yeni bir tane).
triangulate(): MeshEnumerations
Mesh
Üçgenleştirilmiş mesh.
Enumerations
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'i ... olarak döndürür `Mesh` örnek. İçin `Mesh` nesneler bu bir kimlik işlemidir; yöntem, miras alan ilkel geometri türlerinde daha anlamlıdır `Geometry`.
```typescript
toMesh(): MeshEnumerations
Mesh
Bu mesh örneği.
static union(a, b)
NOT IMPLEMENTED. Bu yöntem API yüzeyinde tanımlıdır ancak fırlatır Error('union is not implemented') çalışma zamanında. Üretim kodunda çağırmayın.
İki mesh’in Boolean birleşimini gerçekleştirir. Sonuç, her iki girdinin birleşik hacmini içerir.
static union(a: Mesh, b: Mesh): MeshEnumerations
a Mesh
İlk ağ operandi.
b Mesh
İkinci ağ operandi.
Enumerations
Mesh
Birleşimini temsil eden yeni bir mesh a ve b.
Enumerations
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. Bu yöntem API yüzeyinde tanımlıdır ancak fırlatır Error('difference is not implemented') çalışma zamanında. Üretim kodunda çağırmayın.
Boolean farkı gerçekleştirir, mesh hacmini çıkararak b mesh’ten a.
static difference(a: Mesh, b: Mesh): MeshEnumerations
a Mesh
Temel mesh.
b Mesh
Çıkarılacak mesh a.
Enumerations
Mesh
Temsil eden yeni bir mesh a eksi b.
Enumerations
const result = Mesh.difference(meshA, meshB);
console.log(Difference polygon count: ${result.polygonCount});
---
### static intersect(a, b)
**NOT IMPLEMENTED.** Bu yöntem API yüzeyinde tanımlıdır ancak fırlatır `Error('intersect is not implemented')` çalışma zamanında. Üretim kodunda çağırmayın.
İki ağın Boolean kesişimini gerçekleştirir. Sonuç yalnızca çakışan hacmi içerir.
```typescript
static intersect(a: Mesh, b: Mesh): MeshEnumerations
a Mesh
İlk ağ operandi.
b Mesh
İkinci ağ operandi.
Enumerations
Mesh
Kesişimini temsil eden yeni bir mesh a ve b.
Enumerations
const overlap = Mesh.intersect(meshA, meshB);
console.log(Intersection polygon count: ${overlap.polygonCount});
---
### createElement(type, mapping?, reference?)
Yeni bir oluşturur `VertexElement` bu mesh üzerinde özel per-vertex öznitelikleri için veri katmanı.
```typescript
createElement(
type: VertexElementType,
mapping?: MappingMode,
reference?: ReferenceMode
): VertexElementEnumerations
type VertexElementType
Oluşturulacak vertex özniteliği türü (örneğin, VertexElementType.Normal).
mapping MappingMode (isteğe bağlı)
Eleman verisinin mesh topolojisine nasıl eşlendiği. Varsayılan: MappingMode.ControlPoint.
reference ReferenceMode (isteğe bağlı)
Eleman indekslerinin veri dizisine nasıl referans verdiği. Varsayılan: ReferenceMode.Direct.
Enumerations
VertexElement
Yeni oluşturulan köşe ögesi katmanı.
createElementUV(mapping, mappingMode?, referenceMode?)
Bu ağ üzerinde bir UV koordinat katmanı oluşturur.
createElementUV(
mapping: TextureMapping,
mappingMode?: MappingMode,
referenceMode?: ReferenceMode
): VertexElementUVEnumerations
mapping TextureMapping
Oluşturulacak UV kanalı (örneğin, TextureMapping.Diffuse).
mappingMode MappingMode (isteğe bağlı)
UV koordinatlarının köşelere nasıl eşlendiği.
referenceMode ReferenceMode (isteğe bağlı)
UV indeks verisinin UV dizisine nasıl referans verdiği.
Enumerations
VertexElementUV
Yeni oluşturulan UV element layer.
Enumerations
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}`);