API Overview — @aspose/3d for TypeScript

الحزمة: @aspose/3d (v24.12.0) اللغة: TypeScript / Node.js 18+ الترخيص: MIT

@aspose/3d هي مكتبة مرخصة بموجب MIT لقراءة وبناء وتصدير المشاهد ثلاثية الأبعاد في Node.js. تأتي مع تعريفات نوع TypeScript كاملة، واعتماد تشغيل واحد ( «<SEG_7»> )، وتدعم سبعة صيغ ملفات ثلاثية الأبعاد رئيسية. جميع عمليات الإدخال/الإخراج متزامنة. لا يلزم أي إضافات أصلية.xmldom),.


Enumerations

npm install @aspose/3d

Enumerations tsconfig.json إعدادات لتصحيح حل المسار الفرعي:

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "moduleResolution": "node",
    "esModuleInterop": true,
    "strict": true
  }
}

تمثل الفئتان Comment و CommentAuthor تعليقات الشرائح ومؤلفيها. تقوم بتنفيذ IComment و ICommentAuthor على التوالي.

Enumerations

الحاوية الجذرية لمشهد ثلاثي الأبعاد. جميع المحتويات؛ العقد، الهندسة، المواد، والرسوم المتحركة؛ تُخزن في شجرة جذورها في scene.rootNode. استخدم open() / openFromBuffer() لتحميل ملف و save() / saveToBuffer() للتصدير.

EnumerationsEnumerationsEnumerations
rootNodeNodeجذر مخطط المشهد
assetInfoAssetInfoبيانات ملف التعريف (المُنشئ، الوحدات، نظام الإحداثيات)
animationClipsAnimationClip[]جميع مقاطع الرسوم المتحركة في المشهد
open(path, opts?)(string, LoadOptions?) → voidتحميل ملف من القرص
openFromBuffer(buf, opts?)(Buffer, LoadOptions?) → voidتحميل من المخزن المؤقت في الذاكرة
save(path, opts?)(string, SaveOptions?) → voidحفظ إلى القرص (يتم استنتاج الصيغة من الامتداد)
saveToBuffer(ext, opts?)(string, SaveOptions?) → Bufferحفظ إلى المخزن المؤقت في الذاكرة
createAnimationClip(name)(string) → AnimationClipإنشاء وتسجيل مقطع رسوم متحركة جديد

Enumerations

عُقْدَة شجرة مسماة في رسم المشهد. العقد تحمل خيارًا اختياريًا Entity (mesh, camera, light) و Transform الذي يضع العقدة بالنسبة إلى العنصر الأب.

EnumerationsEnumerationsEnumerations
namestringاسم العقدة
childNodesNode[]العقد الفرعية المباشرة
entity`Entitynull`
transformTransformالإزاحة المحلية، الدوران، المقياس
materialsMaterial[]المواد المعيّنة لهذه العقدة
createChildNode(name)(string) → Nodeإضافة عقدة فرعية
getChildNode(name)`(string) → Nodenull`

Enumerations

شبكة مضلعات؛ نوع الهندسة الأساسي. يمتد Geometry.

EnumerationsEnumerationsEnumerations
controlPointsVector4[]مواقع الرؤوس (w=1 للمواقع)
polygonCountnumberعدد المضلعات
createPolygon(indices)(number[]) → voidإضافة مضلع (مثلث أو رباعي)
getElement(type)`(VertexElementType) → VertexElementnull`
createElement(type)(VertexElementType) → VertexElementإنشاء عنصر رأس

Enumerations

تحويل محلي يُطبق على عقدة.

EnumerationsEnumerationsEnumerations
translationVector3الموضع المحلي
eulerAnglesVector3دوران أويلر بالدرجات (ترتيب XYZ)
rotationQuaternionالدوران ككواترنيون
scalingVector3المقياس المحلي

فئات المواد

EnumerationsEnumerationsالخصائص الأساسية
LambertMaterialتظليل الانتشار + الإضاءة المحيطةdiffuseColor, ambientColor, transparency
PhongMaterialيضيف اللمعان + الانبعاث إلى لامبرتspecularColor, shininess, emissiveColor
PbrMaterialمستند إلى الفيزياء لـ glTF 2.0albedo, metallicFactor, roughnessFactor, emissiveColor

فئات الرياضيات

EnumerationsEnumerations
Vector33-component double-precision vector (x, y, z)
Vector44-component vector for homogeneous math (x, y, z, w)
FVector3متغيّر بدقة مفردة يُستخدم في بيانات الرؤوس
Matrix44×4 transformation matrix; multiply, invert, decompose
Quaternionكواترن الدوران; fromEulerAngle, toEulerAngles, slerp
BoundingBoxصندوق احتواء محاذى للمحاور; minimum, maximum, center, size, merge

فئات الرسوم المتحركة

EnumerationsEnumerations
AnimationClipمقطع مسمى; يحتوي على AnimationNode قائمة; يتم الوصول إليها عبر scene.animationClips
AnimationNodeيربط مقطعًا بعقدة مشهد مسماة; يحتوي على AnimationChannel قائمة
AnimationChannelيستهدف خاصية واحدة (مثل translation X)؛ يحتوي على KeyframeSequence
KeyframeSequenceقائمة مرتبة من KeyFrame كائنات مع interpolation و extrapolation
KeyFrameزوج وقت/قيمة واحد

Enumerations

EnumerationsEnumerationsEnumerations
VertexElementTypeNORMAL, UV, VERTEX_COLOR, BINORMAL, TANGENTدلالة عنصر القمة
MappingModeCONTROL_POINT, POLYGON_VERTEX, POLYGON, ALL_SAMEكيفية ربط البيانات بالهندسة
ReferenceModeDIRECT, INDEX, INDEX_TO_DIRECTاستراتيجية الفهرسة لبيانات عنصر القمة
InterpolationCONSTANT, LINEAR, BEZIERاستيفاء الإطارات المفتاحية
ExtrapolationCONSTANT, GRADIENT, CYCLE, CYCLE_RELATIVE, OSCILLATEالسلوك خارج نطاق الإطارات المفتاحية

وحدات الصيغ

فئات الخيارات الخاصة بكل صيغة يتم تصديرها من وحدات المسارات الفرعية. استوردها بشكل منفصل:

import { ObjLoadOptions } from '@aspose/3d/formats/obj';
import { GltfSaveOptions, GltfFormat } from '@aspose/3d/formats/gltf';
import { StlLoadOptions, StlSaveOptions } from '@aspose/3d/formats/stl';
import { FbxLoadOptions, FbxSaveOptions } from '@aspose/3d/formats/fbx';
import { ColladaLoadOptions } from '@aspose/3d/formats/collada';
import { ThreeMfSaveOptions } from '@aspose/3d/formats/3mf';

وحدة OBJ (@aspose/3d/formats/obj)

Enumerationsالخيارات الرئيسية
ObjLoadOptionsenableMaterials, flipCoordinateSystem, scale, normalizeNormal

وحدة glTF/GLB (@aspose/3d/formats/gltf)

Enumerationsالخيارات الرئيسية
GltfSaveOptionsbinaryMode (true → .glb)،, flipTexCoordV
GltfFormatGltfFormat.getInstance(): مثيل التنسيق لـ scene.save()

وحدة STL (@aspose/3d/formats/stl)

Enumerationsالخيارات الرئيسية
StlLoadOptionsN/A
StlSaveOptionsbinaryMode (false → ASCII، true → binary)

وحدة FBX (@aspose/3d/formats/fbx)

Enumerationsالخيارات الرئيسية
FbxLoadOptionsN/A
FbxSaveOptionsembedTextures

الصيغ المدعومة

EnumerationsEnumerationsEnumerationsEnumerations
Enumerations.objEnumerationsEnumerations
glTF 2.0.gltfEnumerationsEnumerations
Enumerations.glbEnumerationsEnumerations
STL.stlEnumerationsEnumerations
FBX.fbxلا*لا*
COLLADA.daeEnumerationsEnumerations
3MF.3mfEnumerationsEnumerations

مثال مرجعي سريع

import { Scene } from '@aspose/3d';
import { ObjLoadOptions } from '@aspose/3d/formats/obj';
import { GltfSaveOptions } from '@aspose/3d/formats/gltf';

// Load OBJ with materials
const scene = new Scene();
const loadOpts = new ObjLoadOptions();
loadOpts.enableMaterials = true;
scene.open('input.obj', loadOpts);

// Inspect root nodes
for (const node of scene.rootNode.childNodes) {
    console.log(`Node: ${node.name}, entity: ${node.entity?.constructor.name}`);
}

// Export as GLB (binary glTF)
const saveOpts = new GltfSaveOptions();
saveOpts.binaryMode = true;
scene.save('output.glb', saveOpts);

انظر أيضًا

 العربية