API Overview — @aspose/3d for TypeScript

Paket: @aspose/3d (v24.12.0) Bahasa: TypeScript / Node.js 18+ Lisensi: MIT

@aspose/3d adalah pustaka berlisensi MIT untuk membaca, membangun, dan mengekspor adegan 3D di Node.js. Ia dilengkapi dengan definisi tipe TypeScript lengkap, satu dependensi runtime (xmldom), dan mendukung tujuh format file 3D utama. Semua I/O bersifat sinkron. Tidak diperlukan addon native.


Enumerations

npm install @aspose/3d

Enumerations tsconfig.json pengaturan untuk resolusi sub‑path yang benar:

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

Referensi API untuk fitur terkait perlindungan di Aspose.Slides FOSS untuk C++. Kunci bentuk dan pengaturan perlindungan.

Enumerations

Kontainer akar untuk adegan 3D. Semua konten; node, geometri, material, dan animasi; disimpan dalam pohon yang berakar di scene.rootNode.Gunakan open() / openFromBuffer() untuk memuat file dan save() / saveToBuffer() untuk mengekspor.

EnumerationsEnumerationsEnumerations
rootNodeNodeAkar dari grafik adegan
assetInfoAssetInfoMetadata file (pembuat, satuan, sistem koordinat)
animationClipsAnimationClip[]Semua klip animasi dalam adegan
open(path, opts?)(string, LoadOptions?) → voidMuat file dari disk
openFromBuffer(buf, opts?)(Buffer, LoadOptions?) → voidMuat dari buffer dalam memori
save(path, opts?)(string, SaveOptions?) → voidSimpan ke disk (format diperkirakan dari ekstensi)
saveToBuffer(ext, opts?)(string, SaveOptions?) → BufferSimpan ke buffer dalam memori
createAnimationClip(name)(string) → AnimationClipBuat dan daftarkan klip animasi baru

Enumerations

Sebuah node pohon bernama dalam grafik adegan. Node membawa opsional Entity (mesh, kamera, cahaya) dan sebuah Transform yang memposisikan node relatif terhadap induknya.

EnumerationsEnumerationsEnumerations
namestringNama node
childNodesNode[]Node anak langsung
entity`Entitynull`
transformTransformTranslasi, rotasi, skala lokal
materialsMaterial[]Material yang ditetapkan ke node ini
createChildNode(name)(string) → NodeTambahkan node anak
getChildNode(name)`(string) → Nodenull`

Enumerations

Mesh poligon; tipe geometri utama. Memperluas Geometry.

EnumerationsEnumerationsEnumerations
controlPointsVector4[]Posisi vertex (w=1 untuk posisi)
polygonCountnumberJumlah poligon
createPolygon(indices)(number[]) → voidTambahkan poligon (segitiga atau quad)
getElement(type)`(VertexElementType) → VertexElementnull`
createElement(type)(VertexElementType) → VertexElementBuat elemen vertex

Enumerations

Transformasi lokal yang diterapkan pada node.

EnumerationsEnumerationsEnumerations
translationVector3Posisi lokal
eulerAnglesVector3Rotasi Euler dalam derajat (urutan XYZ)
rotationQuaternionRotasi sebagai kuaternion
scalingVector3Skala lokal

Kelas Material

EnumerationsEnumerationsProperti Kunci
LambertMaterialPenyinaran difus + ambientdiffuseColor, ambientColor, transparency
PhongMaterialMenambahkan specular + emissive ke LambertspecularColor, shininess, emissiveColor
PbrMaterialBerbasis fisik untuk glTF 2.0albedo, metallicFactor, roughnessFactor, emissiveColor

Kelas Matematika

EnumerationsEnumerations
Vector33-component double-precision vector (x, y, z)
Vector44-component vector for homogeneous math (x, y, z, w)
FVector3Varian presisi tunggal yang digunakan dalam data vertex
Matrix44×4 transformation matrix; multiply, invert, decompose
QuaternionQuaternion rotasi; fromEulerAngle, toEulerAngles, slerp
BoundingBoxBounding box yang sejajar sumbu; minimum, maximum, center, size, merge

Kelas Animasi

EnumerationsEnumerations
AnimationClipKlip bernama; berisi AnimationNode daftar; diakses melalui scene.animationClips
AnimationNodeMengikat klip ke node adegan bernama; berisi AnimationChannel daftar
AnimationChannelMengarahkan ke satu properti (mis. translasi X); menyimpan sebuah KeyframeSequence
KeyframeSequenceDaftar terurut dari KeyFrame objek dengan interpolation dan extrapolation
KeyFramePasangan waktu/nilai tunggal

Enumerations

EnumerationsEnumerationsEnumerations
VertexElementTypeNORMAL, UV, VERTEX_COLOR, BINORMAL, TANGENTSemantik elemen vertex
MappingModeCONTROL_POINT, POLYGON_VERTEX, POLYGON, ALL_SAMEBagaimana data dipetakan ke geometri
ReferenceModeDIRECT, INDEX, INDEX_TO_DIRECTStrategi pengindeksan untuk data elemen vertex
InterpolationCONSTANT, LINEAR, BEZIERInterpolasi keyframe
ExtrapolationCONSTANT, GRADIENT, CYCLE, CYCLE_RELATIVE, OSCILLATEPerilaku di luar rentang keyframe

Modul Format

Kelas opsi khusus format diekspor dari modul sub‑path. Impor mereka secara terpisah:

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';

Modul OBJ (@aspose/3d/formats/obj)

EnumerationsOpsi Kunci
ObjLoadOptionsenableMaterials, flipCoordinateSystem, scale, normalizeNormal

Modul glTF/GLB (@aspose/3d/formats/gltf)

EnumerationsOpsi Kunci
GltfSaveOptionsbinaryMode (true → .glb), flipTexCoordV
GltfFormatGltfFormat.getInstance(): instance format untuk scene.save()

Modul STL (@aspose/3d/formats/stl)

EnumerationsOpsi Utama
StlLoadOptionsN/A
StlSaveOptionsbinaryMode (false → ASCII, true → biner)

Modul FBX (@aspose/3d/formats/fbx)

EnumerationsOpsi Utama
FbxLoadOptionsN/A
FbxSaveOptionsembedTextures

Format yang Didukung

EnumerationsEnumerationsEnumerationsEnumerations
Enumerations.objEnumerationsEnumerations
glTF 2.0.gltfEnumerationsEnumerations
Enumerations.glbEnumerationsEnumerations
STL.stlEnumerationsEnumerations
FBX.fbxTidak*Tidak*
COLLADA.daeEnumerationsEnumerations
3MF.3mfEnumerationsEnumerations

Contoh Referensi Cepat

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

Lihat Juga

 Bahasa Indonesia