بدء سريع

بدء سريع

هذا الدليل يظهر أسرع مسار من التثبيت إلى تحميل وتخزين ملف 3D باستخدام @aspose/3d الحزمة مرخصة من MIT، ونظيفة JavaScript/TypeScript، و لا يتطلب أي أدوات البناء الأصلية أو منصة محددة.


المعايير

مطلوبالتفاصيل
Node.js18 or later
OSWindows، macOS، Linux، Docker
حزمة@aspose/3d من NPM

تثبيت

تثبيت الحزمة من npm. تعريفات النوع مرتبطة بالحزمة، لذلك لا منفصلة @types الحزمة مطلوبة :

asposefoss/3d is not yet published — build from source until it ships. See the project README for build instructions.

تحميل ملف 3D

مكالمة scene.open() مع مسار لتحميل أي تنسيق مدعوم.المكتبة تظهر تنسيق من ملف التمديد.الوصول إلى الهرم الحرفي عبر scene.rootNode:

import { Scene } from "@aspose/3d";

const scene = new Scene();
scene.open("model.obj");
console.log(`Root node: ${scene.rootNode.name}`);

عبر المسرحية الرسوم البيانية

المشهد المزدحم هو شجرة من Node الأجسام التي تُدخل في scene.rootNode.استخدام مسار تجريبي لمعالجة كل عقدة وأطفالها:

import { Scene, Node } from "@aspose/3d";

function walk(node: Node, depth: number = 0): void {
    const indent = " ".repeat(depth * 2);
    console.log(`${indent}Node: ${node.name}`);
    for (const child of node.childNodes) {
        walk(child, depth + 1);
    }
}

const scene = new Scene();
scene.open("model.glb");
walk(scene.rootNode);

حفظها في شكل مختلف

يكتشف المكتبة تنسيق النتيجة من ملحق الملف. scene.save() مع مسار الخروج لتحويل بين التنسيقات:

import { Scene } from "@aspose/3d";

const scene = new Scene();
scene.open("model.obj");
scene.save("output.glb");
console.log("Converted to GLB.");

خلق مشهد جديد و حفظه

بناء أ Scene مع عدم وجود حجة للبدء فارغة ، إضافة عقدة الطفل إلى scene.rootNode,ثم اتصل scene.save() لكي تكتب الملف :

import { Scene, Node } from "@aspose/3d";

const scene = new Scene();
const box = scene.rootNode.createChildNode("box");
scene.save("new_scene.obj");

الخطوات التالية

 العربية