Mesh

Csomag: @aspose/3d (v24.12.0)

Mesh szintén elérhető az alútvonal importálásával @aspose/3d/entities.

A Mesh a fő polygon geometriai entitás a @aspose/3d. Tárolja a csúcspontok pozícióit vezérlőpontként, a polygon felületeket csúcsindex-listákkal definiálja, és több csúcs elem adat réteget támogat, például normálokat és UV koordinátákat.

export class Mesh extends Geometry

ImageRenderOptions

A3DObject ← SceneObject ← Entity ← Geometry ← Mesh

ImageRenderOptions

Építs egy egyszerű háromszög mesh-et, csatold a jelenethez, és mentsd GLB formátumban.

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

NameTypeAccessDescription
edgesnumber[]ReadGets the edges.
polygonCountnumberReadGets the polygon count.
polygonsnumber[][]ReadGets the polygons.
deformersany[]ReadGets the deformers.
SignatureDescription
`constructor(name: stringnull, _heightMap: any, _transform: any, _triMesh: boolean
createPolygon()Adds a new polygon to the mesh
getPolygonSize(index: number)numberReturns the number of vertices in the polygon at the given index
toMesh()MeshReturns a Mesh instance representing the current object (identity conversion)
optimize(_vertexElements: boolean, _toleranceControlPoint: number, _toleranceNormal: number, _toleranceUV: number)MeshNot 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)MeshNot implemented in the FOSS edition — throws at runtime. Performs a boolean operation defined by _op on meshes _a and _b with respective transforms
isManifold()booleanNot implemented in the FOSS edition — throws at runtime. Returns true if manifold is set.
union(_a: Mesh, _b: Mesh)MeshNot 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)MeshNot 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)MeshNot implemented in the FOSS edition — throws at runtime.
triangulate()MeshConverts all polygons in the mesh to triangles and returns the mesh
getBoundingBox()anyReturns the bounding box.
getEntityRendererKey()anyNot implemented in the FOSS edition — throws at runtime. Returns the entity renderer key.

ImageRenderOptions

createPolygon(…indices)

Új polygon felületet definiál a megadott vezérlőpont indexekkel. Az indexeknek érvényes pozíciókra kell hivatkozni a controlPoints.

createPolygon(...indices: number[]): void

ImageRenderOptions

...indices number[]

Három vagy több nullától kezdődő index a controlPoints tömb, az óramutató járásával ellentétes tekerési sorrendben.

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()

Átalakítja a mesh összes nem háromszög alakú sokszögét háromszögekké. Visszaadja a triangulált mesh-et (lehet ugyanaz a példány vagy egy új).

triangulate(): Mesh

ImageRenderOptions

Mesh

A triangulált 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()

Visszaadja a hálót, mint egy `Mesh` példány. A `Mesh` objektumok esetén ez egy identitás művelet; a metódus jelentősebb azoknál az egyszerű geometriai típusoknál, amelyek öröklik a `Geometry`.

```typescript
toMesh(): Mesh

ImageRenderOptions

Mesh

Ez a háló példány.


static union(a, b)

NOT IMPLEMENTED. Ez a metódus definiálva van az API felületén, de dob Error('union is not implemented') futásidőben. Ne hívd meg termelési kódban.

Két háló Boolean unióját hajtja végre. Az eredmény tartalmazza mindkét bemenet kombinált térfogatát.

static union(a: Mesh, b: Mesh): Mesh

ImageRenderOptions

a Mesh

Az első háló operandus.

b Mesh

A második háló operandus.

ImageRenderOptions

Mesh

Egy új háló, amely a a és 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. Ez a metódus definiálva van az API felületén, de dob Error('difference is not implemented') futásidőben. Ne hívd meg termelési kódban.

Boolean különbséget hajt végre, kivonva a(z) háló térfogatát b a(z) hálóból a.

static difference(a: Mesh, b: Mesh): Mesh

ImageRenderOptions

a Mesh

Az alap háló.

b Mesh

A háló, amelyből kivonni a.

ImageRenderOptions

Mesh

Egy új háló, amely ábrázolja a mínusz b.

ImageRenderOptions

const result = Mesh.difference(meshA, meshB); console.log(Difference polygon count: ${result.polygonCount});


---

### static intersect(a, b)

**NOT IMPLEMENTED.** Ez a metódus definiálva van az API felületén, de dob `Error('intersect is not implemented')` futásidőben. Ne hívd meg termelési kódban.

Két háló Boolean metszetét hajtja végre. Az eredmény csak a átfedő térfogatot tartalmazza.

```typescript
static intersect(a: Mesh, b: Mesh): Mesh

ImageRenderOptions

a Mesh

Az első háló operandus.

b Mesh

A második háló operandus.

ImageRenderOptions

Mesh

Új háló, amely a metszetet ábrázolja a és b.

ImageRenderOptions

const overlap = Mesh.intersect(meshA, meshB); console.log(Intersection polygon count: ${overlap.polygonCount});


---

### createElement(type, mapping?, reference?)

Létrehoz egy új `VertexElement` adatréteget ezen a hálón egyedi csúcsra vonatkozó attribútumokhoz.

```typescript
createElement(
  type: VertexElementType,
  mapping?: MappingMode,
  reference?: ReferenceMode
): VertexElement

ImageRenderOptions

type VertexElementType

A létrehozandó csúcsattribútum típusa (például, VertexElementType.Normal).

mapping MappingMode (opcionális)

Hogyan van leképezve az elemadat a háló topológiájára. Alapértelmezett: MappingMode.ControlPoint.

reference ReferenceMode (opcionális)

Hogyan hivatkoznak az elemindexek az adat tömbre. Alapértelmezett: ReferenceMode.Direct.

ImageRenderOptions

VertexElement

Az újonnan létrehozott csúcspont elem réteg.


createElementUV(mapping, mappingMode?, referenceMode?)

Létrehoz egy UV koordináta réteget ezen a hálón.

createElementUV(
  mapping: TextureMapping,
  mappingMode?: MappingMode,
  referenceMode?: ReferenceMode
): VertexElementUV

ImageRenderOptions

mapping TextureMapping

A létrehozandó UV csatorna (például, TextureMapping.Diffuse).

mappingMode MappingMode (opcionális)

Hogyan vannak leképezve az UV koordináták a csúcspontokra.

referenceMode ReferenceMode (opcionális)

Hogyan hivatkozik az UV index adat az UV tömbre.

ImageRenderOptions

VertexElementUV

Az újonnan létrehozott UV elem réteg.

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}`);
 Magyar