Class Mesh

الحزمة: @aspose/3d (v24.12.0)

Mesh متاح أيضًا عبر استيراد المسار الفرعي @aspose/3d/entities.

Mesh هو الكيان الأساسي لهندسة المضلعات في @aspose/3d. يخزن مواضع الرؤوس كنقاط تحكم، يعرّف وجوه المضلعات بقوائم فهارس الرؤوس، ويدعم طبقات بيانات عناصر الرؤوس المتعددة مثل المتجهات العمودية وإحداثيات UV.

export class Mesh extends Geometry

Properties

A3DObject ← SceneObject ← Entity ← Geometry ← Mesh

Properties

أنشئ شبكة مثلثية واحدة، أرفقها بالمشهد، واحفظها بصيغة 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

Properties

PropertiesPropertiesProperties
controlPointsVector4[]مواضع الرؤوس في الشبكة. كل نقطة تستخدم إحداثيات متجانسة (x, y, z, w). أضف نقاطًا بدفعها إلى هذا المصفوفة قبل تعريف المضلعات.
polygonCountnumberللقراءة فقط. عدد المضلعات (الوجوه) المعرفة حاليًا على الشبكة.
polygonsnumber[][]للقراءة فقط. جدول فهارس المضلعات. كل إدخال هو مصفوفة من فهارس نقاط التحكم التي تُعرّف وجهًا واحدًا.
edgesnumber[]قائمة الحواف، تُستخدم لتحديد الحواف الصلبة وتوزين الطيات.
vertexElementsVertexElement[]مجموعة طبقات عناصر الرؤوس (normals, UVs, vertex colors, إلخ) المرتبطة بهذه الشبكة.
visiblebooleanما إذا كانت الشبكة مُعروضة. القيمة الافتراضية هي true.
castShadowsbooleanما إذا كانت الشبكة تُسقط ظلالًا في المُعالجين المدعومين. القيمة الافتراضية هي true.
receiveShadowsbooleanما إذا كانت الشبكة تستقبل ظلالًا من كائنات أخرى. القيمة الافتراضية هي true.

Properties

createPolygon(…indices)

يُعرّف وجهًا متعدد الأضلاع جديدًا باستخدام مؤشرات نقاط التحكم المقدمة. يجب أن تشير المؤشرات إلى مواضع صالحة في controlPoints.

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

Properties

...indices number[]

ثلاثة مؤشرات أو أكثر ذات أساس صفر إلى controlPoints المصفوفة، بترتيب لف عكس اتجاه عقارب الساعة.

Properties

void

Properties

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

Properties

Mesh

الشبكة المثلثة.

Properties

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),
);
mesh.createPolygon(0, 1, 2, 3); // quad
const triangulated = mesh.triangulate();
console.log(`Polygons after triangulation: ${triangulated.polygonCount}`); // 2

toMesh()

يعيد الشبكة كـ Mesh مثيل. من أجل Mesh الكائنات، هذه عملية هوية؛ الطريقة أكثر معنىً على أنواع الهندسة الأولية التي ترث من Geometry.

toMesh(): Mesh

Properties

Mesh

كائن الشبكة هذا.


static union(a, b)

NOT IMPLEMENTED. هذه الطريقة معرفة في واجهة برمجة التطبيقات ولكنها throws Error('union is not implemented') أثناء التشغيل. لا تستدعها في كود الإنتاج.

ينفّذ اتحادًا بوليًا بين شبكتين. النتيجة تحتوي على الحجم المدمج لكلا المدخلين.

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

Properties

a Mesh

المعامل الأول للشبكة.

b Mesh

المعامل الثاني للشبكة.

Properties

Mesh

شبكة جديدة تمثل اتحاد a و b.

Properties

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. هذه الطريقة معرفة في واجهة برمجة التطبيقات ولكنها throws Error('difference is not implemented') أثناء التشغيل. لا تستدعها في كود الإنتاج.

ينفّذ فرقًا بوليًا، بطرح حجم الـ mesh b من الـ mesh a.

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

Properties

a Mesh

الشبكة الأساسية.

b Mesh

الشبكة التي يُطرح منها a.

Properties

Mesh

شبكة جديدة تمثّل a ناقص b.

Properties

import { Mesh } from '@aspose/3d/entities';

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') أثناء التشغيل. لا تستدعها في كود الإنتاج.

ينفّذ تقاطعًا بوليًا بين شبكتين. النتيجة تحتوي فقط على الحجم المتقاطع.

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

Properties

a Mesh

المعامل الأول للشبكة.

b Mesh

المعامل الثاني للشبكة.

Properties

Mesh

شبكة جديدة تمثل تقاطع a و b.

Properties

import { Mesh } from '@aspose/3d/entities';

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

createElement(type, mapping?, reference?)

ينشئ جديدًا VertexElement طبقة بيانات على هذه الشبكة للسمات المخصصة لكل رأس.

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

Properties

type VertexElementType

نوع سمة الرأس التي سيتم إنشاؤها (على سبيل المثال،, VertexElementType.Normal).

mapping MappingMode (اختياري)

كيفية ربط بيانات العنصر بطوبولوجيا الشبكة. الافتراضي هو MappingMode.ControlPoint.

reference ReferenceMode (اختياري)

كيف تُشير مؤشرات العنصر إلى مصفوفة البيانات. القيمة الافتراضية هي ReferenceMode.Direct.

Properties

VertexElement

طبقة سمة الرأس التي تم إنشاؤها حديثًا.


createElementUV(mapping, mappingMode?, referenceMode?)

ينشئ طبقة إحداثيات UV على هذه الشبكة.

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

Properties

mapping TextureMapping

قناة الـ UV التي سيتم إنشاؤها (على سبيل المثال،, TextureMapping.Diffuse).

mappingMode MappingMode (اختياري)

كيفية ربط إحداثيات UV بالرؤوس.

referenceMode ReferenceMode (اختياري)

كيفية إشارة بيانات فهرس UV إلى مصفوفة UV.

Properties

VertexElementUV

طبقة عنصر UV التي تم إنشاؤها حديثًا.

Properties

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}`);
 العربية