Mesh

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

Mesh on myös saatavilla alipolku‑tuonnin kautta @aspose/3d/entities.

Mesh on ensisijainen polygoni‑geometriayksikkö kohteessa @aspose/3d. Se tallentaa kärkipisteiden sijainnit ohjauspisteinä, määrittelee polygoni‑pinnat kärjen indeksilistojen avulla, ja tukee useita kärjen elementtitietokerroksia, kuten normaalit ja UV‑koordinaatit.

export class Mesh extends Geometry

ImageRenderOptions

A3DObject ← SceneObject ← Entity ← Geometry ← Mesh

ImageRenderOptions

Rakenna yksittäinen kolmio‑mesh, liitä se kohtaukseen ja tallenna GLB‑muotoon.

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)

Määrittelee uuden polygonipinnan käyttäen annettuja ohjauspisteindeksejä. Indeksien on viitattava kelvollisiin paikkoihin kohteessa controlPoints.

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

ImageRenderOptions

...indices number[]

Kolme tai useampaa nollapohjaista indeksiä controlPoints taulukkoon, vastapäivään kierretyssä järjestyksessä.

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

Muuntaa kaikki ei‑kolmiomaiset monikulmiot tässä meshissä kolmioiksi. Palauttaa kolmioidun meshin (voi olla sama instanssi tai uusi).

triangulate(): Mesh

ImageRenderOptions

Mesh

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

Palauttaa verkon muodossa `Mesh` instanssi. Kohteelle `Mesh` objekteilla tämä on identiteettitoiminto; menetelmä on merkityksellisempi primitiivisillä geometria-tyypeillä, jotka periytyvät from `Geometry`.

```typescript
toMesh(): Mesh

ImageRenderOptions

Mesh

Tämä verkko-instanssi.


static union(a, b)

NOT IMPLEMENTED. Tämä menetelmä on määritelty API-rajapinnassa, mutta heittää Error('union is not implemented') suoritusaikana. Älä kutsu sitä tuotantokoodissa.

Suorittaa kahden verkon Boolen unionin. Tulos sisältää molempien syötteiden yhdistetyn tilavuuden.

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

ImageRenderOptions

a Mesh

Ensimmäinen verkko‑operaandi.

b Mesh

Toinen verkko‑operaandi.

ImageRenderOptions

Mesh

Uusi verkko, joka edustaa yhdistelmää a ja 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. Tämä menetelmä on määritelty API-rajapinnassa, mutta heittää Error('difference is not implemented') suoritusaikana. Älä kutsu sitä tuotantokoodissa.

Suorittaa Boolen erotuksen, vähentäen verkon tilavuutta b verkosta a.

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

ImageRenderOptions

a Mesh

Perusverkko.

b Mesh

Verkko, josta vähennetään a.

ImageRenderOptions

Mesh

Uusi verkko, joka edustaa a miinus b.

ImageRenderOptions

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


---

### static intersect(a, b)

**NOT IMPLEMENTED.** Tämä menetelmä on määritelty API-rajapinnassa, mutta heittää `Error('intersect is not implemented')` suoritusaikana. Älä kutsu sitä tuotantokoodissa.

Suorittaa kahden verkon Boolen leikkauksen. Tulos sisältää vain päällekkäisen tilavuuden.

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

ImageRenderOptions

a Mesh

Ensimmäinen verkko‑operaandi.

b Mesh

Toinen verkko‑operaandi.

ImageRenderOptions

Mesh

Uusi verkko, joka edustaa leikkausta a ja b.

ImageRenderOptions

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


---

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

Luo uuden `VertexElement` datakerroksen tähän verkkoon mukautetuille per-vertex-ominaisuuksille.

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

ImageRenderOptions

type VertexElementType

Luotavan vertex-ominaisuuden tyyppi (esimerkiksi, VertexElementType.Normal).

mapping MappingMode (valinnainen)

Miten elementin data kartoitetaan verkon topologiaan. Oletusarvo on MappingMode.ControlPoint.

reference ReferenceMode (valinnainen)

Miten elementtien indeksit viittaavat data-taulukkoon. Oletusarvo on ReferenceMode.Direct.

ImageRenderOptions

VertexElement

Uudeksi luotu vertex-elementtikerros.


createElementUV(mapping, mappingMode?, referenceMode?)

Luo UV-koordinaattilayer tähän verkkoon.

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

ImageRenderOptions

mapping TextureMapping

Luotava UV-kanava (esimerkiksi, TextureMapping.Diffuse).

mappingMode MappingMode (valinnainen)

Miten UV-koordinaatit kartoitetaan vertexeihin.

referenceMode ReferenceMode (valinnainen)

Miten UV-indeksidata viittaa UV-taulukkoon.

ImageRenderOptions

VertexElementUV

Uudeksi luotu UV-elementtikerros.

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