Format Load and Save Options

Format Load and Save Options

แพคเกจ: @aspose/3d (v24.12.0)

คลาสตัวเลือกรูปแบบควบคุมวิธีที่ @aspose/3d อ่านและเขียนรูปแบบไฟล์ 3D เฉพาะ ส่งอินสแตนซ์ของตัวเลือกเป็นอาร์กิวเมนต์ที่สองให้กับ scene.open() (load options) หรือ scene.save() (save options). คลาสตัวเลือกทั้งหมดสืบทอดจากหนึ่งใน LoadOptions หรือ SaveOptions.

// Load with options
import { Scene } from '@aspose/3d';
import { ObjLoadOptions } from '@aspose/3d/formats/obj';

const opts = new ObjLoadOptions();
opts.enableMaterials = false;
scene.open('mesh.obj', opts);

// Save with options
import { GltfSaveOptions } from '@aspose/3d/formats/gltf';

const saveOpts = new GltfSaveOptions();
saveOpts.binaryMode = true;
scene.save('output.glb', saveOpts);

GltfSaveOptions

ตัวเลือกการบันทึกสำหรับ glTF 2.0 JSON (.gltf) และ GLB แบบไบนารี (.glb) เอาต์พุต.

import { GltfSaveOptions } from '@aspose/3d/formats/gltf';
// or
import { GltfSaveOptions } from '@aspose/3d';

Properties

PropertiesPropertiesPropertiesProperties
binaryModebooleanfalseProperties true,ตัวส่งออกจะเขียนไฟล์ GLB แบบไบนารีที่เป็นอิสระเอง เมื่อ false,จะเขียนไฟล์ JSON .gltf ไฟล์ที่มี .bin บัฟเฟอร์.
flipTexCoordVbooleantrueProperties true, พิกัด UV V จะถูกพลิก (v = 1 - v). สเปค glTF 2.0 ใช้จุดกำเนิด UV ที่มุมบนซ้าย ดังนั้นแฟล็กนี้จะ true โดยค่าเริ่มต้นเพื่อให้สอดคล้องกับแนวปฏิบัติของเครื่องมือ DCC ส่วนใหญ่.

Properties

ส่งออกฉากเป็นไฟล์ GLB ไบนารีโดยคงพิกัด UV ไว้ตามเดิม.

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

const scene = new Scene();
scene.open('model.obj');

const opts = new GltfSaveOptions();
opts.binaryMode = true;
opts.flipTexCoordV = false;

scene.save('output.glb', opts);
console.log('Saved as binary GLB without UV flip.');

GltfLoadOptions

ตัวเลือกการโหลดสำหรับ glTF 2.0 JSON (.gltf) และ GLB แบบไบนารี (.glb) ไฟล์.

import { GltfLoadOptions } from '@aspose/3d/formats/gltf';

GltfLoadOptions ขยาย LoadOptions. มันไม่ได้เปิดเผยคุณสมบัติเพิ่มเติมที่ผู้ใช้มองเห็นในเวอร์ชันปัจจุบัน; ส่งผ่านอินสแตนซ์ค่าเริ่มต้นเพื่อใช้ค่าตั้งต้นที่แนะนำ.

Properties

import { Scene } from '@aspose/3d';
import { GltfLoadOptions } from '@aspose/3d/formats/gltf';

const scene = new Scene();
scene.open('model.glb', new GltfLoadOptions());

ObjLoadOptions

ตัวเลือกการโหลดสำหรับ Wavefront OBJ (.obj) ไฟล์.

import { ObjLoadOptions } from '@aspose/3d/formats/obj';
// or
import { ObjLoadOptions } from '@aspose/3d';

Properties

PropertiesPropertiesPropertiesProperties
enableMaterialsbooleantrueProperties true, ตัวนำเข้าอ่าน .mtl ไลบรารีวัสดุที่อ้างอิงโดย mtllib คำสั่งและเติมคุณสมบัติวัสดุลงในโหนดเมช ตั้งค่าเป็น false เพื่อข้ามการโหลดวัสดุ.
flipCoordinateSystembooleanfalseProperties true, แกน Y และ Z จะถูกสลับระหว่างการนำเข้าเพื่อแปลงระหว่างระบบพิกัด Y-up และ Z-up.
normalizeNormalbooleantrueProperties true, เวกเตอร์ปกติของเวอร์เท็กซ์ที่อ่านจากไฟล์จะถูกทำให้เป็นหน่วยความยาวหนึ่งระหว่างการนำเข้า.
scalenumber1.0ปัจจัยสเกลแบบสม่ำเสมอที่ใช้กับเรขาคณิตทั้งหมดระหว่างการนำเข้า.

Properties

โหลดไฟล์ OBJ โดยไม่ทำการ resolve ไลบรารีวัสดุของมัน.

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

const opts = new ObjLoadOptions();
opts.enableMaterials = false;

const scene = new Scene();
scene.open('mesh.obj', opts);
console.log(`Root children: ${scene.rootNode.childNodes.length}`);

ObjSaveOptions

ตัวเลือกการบันทึกสำหรับ Wavefront OBJ (.obj) ผลลัพธ์.

import { ObjSaveOptions } from '@aspose/3d/formats/obj';

หมายเหตุ: การส่งออก OBJ (canExport: false) ยังไม่รองรับอย่างเต็มที่ในเวอร์ชันนี้ของไลบรารี การพยายามบันทึกเป็น OBJ อาจทำให้เกิดข้อผิดพลาด unsupported-operation error.

Properties

PropertiesPropertiesPropertiesProperties
enableMaterialsbooleantrueProperties true, คู่หู .mtl ไฟล์ไลบรารีวัสดุจะถูกเขียนพร้อมกับ .obj ผลลัพธ์.
pointCloudbooleanfalseProperties true, เรขาคณิตจะถูกส่งออกเป็นเมฆจุด (เฉพาะจุดยอดเท่านั้น, ไม่มีการกำหนดหน้า).
verbosebooleanfalseProperties true, มีคอมเมนต์วินิจฉัยเพิ่มเติมรวมอยู่ในผลลัพธ์ OBJ.
serializeWbooleanfalseProperties true, คอมโพเนนต์ W ของพิกัดเวอร์เท็กซ์แบบโฮโมจีนีอัสจะถูกเขียนลงไฟล์.
flipCoordinateSystembooleanfalseProperties true, แกน Y และ Z จะถูกสลับกันระหว่างการส่งออก.
applyUnitScalebooleanfalseProperties true, สเกลหน่วยของฉากจะถูกนำไปใช้กับพิกัดเรขาคณิตทั้งหมดระหว่างการส่งออก.

StlSaveOptions

Save options for STL (.stl) ผลลัพธ์.

import { StlSaveOptions } from '@aspose/3d/formats/stl';
// or
import { StlSaveOptions } from '@aspose/3d';

Properties

PropertiesPropertiesPropertiesProperties
binaryModebooleanfalseProperties true, ผลลัพธ์จะถูกเขียนเป็น binary STL (กระชับ, ไม่อ่านได้โดยมนุษย์). เมื่อ false, จะเขียนเป็น ASCII STL.
flipCoordinateSystembooleanfalseProperties true, แกน Y และ Z จะถูกสลับกันระหว่างการส่งออก.
scalenumber1.0ปัจจัยสเกลสากลถูกนำไปใช้กับเรขาคณิตทั้งหมดระหว่างการส่งออก.

Properties

บันทึกเมชเป็น STL ไบนารี.

import { Scene } from '@aspose/3d';
import { StlSaveOptions } from '@aspose/3d/formats/stl';

const scene = new Scene();
scene.open('model.obj');

const opts = new StlSaveOptions();
opts.binaryMode = true;
scene.save('output.stl', opts);
console.log('Saved binary STL.');

StlLoadOptions

ตัวเลือกการโหลดสำหรับ STL (.stl) ไฟล์. ทั้ง ASCII และ binary STL จะได้รับการสนับสนุนโดยอัตโนมัติ; ไม่มีคุณสมบัติใดควบคุมการตรวจจับ.

import { StlLoadOptions } from '@aspose/3d/formats/stl';

StlLoadOptions ขยาย LoadOptions และไม่ได้เปิดเผยคุณสมบัติเพิ่มเติมที่ผู้ใช้มองเห็นในเวอร์ชันปัจจุบัน.


FbxSaveOptions

Save options for FBX (.fbx) ผลลัพธ์.

import { FbxSaveOptions } from '@aspose/3d/formats/fbx';
// or
import { FbxSaveOptions } from '@aspose/3d';

Properties

PropertiesPropertiesPropertiesProperties
embedTexturesbooleanfalseProperties true, ภาพเทกเจอร์ที่อ้างอิงถูกฝังอยู่ในไฟล์เก็บบีนนารี FBX. เมื่อ false, เส้นทางเทกเจอร์จะถูกเขียนเป็นการอ้างอิงภายนอก.

Properties

ส่งออกไฟล์ FBX พร้อมฝังเทกเจอร์ทั้งหมดไว้ในไฟล์.

import { Scene } from '@aspose/3d';
import { FbxSaveOptions } from '@aspose/3d/formats/fbx';

const scene = new Scene();
scene.open('character.gltf');

const opts = new FbxSaveOptions();
opts.embedTextures = true;
scene.save('character-embedded.fbx', opts);
console.log('Saved FBX with embedded textures.');

FbxLoadOptions

ตัวเลือกการโหลดสำหรับ FBX (.fbx) ไฟล์. รองรับทั้ง FBX แบบไบนารีและ ASCII.

import { FbxLoadOptions } from '@aspose/3d/formats/fbx';

FbxLoadOptions ขยาย LoadOptions และไม่เปิดเผยคุณสมบัติเพิ่มเติมที่มองเห็นได้โดยผู้ใช้ในเวอร์ชันปัจจุบัน.


คลาสฐาน

LoadOptions

คลาสฐานสำหรับอ็อบเจกต์ตัวเลือกการโหลดทั้งหมด.

import { LoadOptions } from '@aspose/3d';

ส่ง LoadOptions อินสแตนซ์ของซับคลาสไปยัง scene.open(filePath, options) หรือ scene.openFromBuffer(buffer, options).

SaveOptions

คลาสฐานสำหรับอ็อบเจกต์ตัวเลือกการบันทึกทั้งหมด.

import { SaveOptions } from '@aspose/3d';

ส่ง SaveOptions อินสแตนซ์ของซับคลาสไปยัง scene.save(filePath, options).

 ภาษาไทย