API Overview — @aspose/3d for TypeScript

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

@aspose/3d MIT lisanslı bir kütüphanedir; Node.js’te 3D sahneleri okuma, oluşturma ve dışa aktarma için kullanılır. Tam TypeScript tip tanımları, tek bir çalışma zamanı bağımlılığı (xmldom), ve yedi büyük 3D dosya formatını destekler. Tüm G/Ç eşzamanlıdır. Yerel eklentiler gerektirmez.


Enumerations

npm install @aspose/3d

Enumerations tsconfig.json doğru alt yol çözümlemesi için ayarlar:

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

Çekirdek Sınıflar

Enumerations

3D sahne için kök kapsayıcı. Tüm içerik; düğümler, geometri, materyaller ve animasyonlar; şu konumda köklenen bir ağaçta depolanır scene.rootNode.Kullan open() / openFromBuffer() bir dosya yüklemek için ve save() / saveToBuffer() dışa aktarmak için.

EnumerationsEnumerationsEnumerations
rootNodeNodeSahne grafiğinin kökü
assetInfoAssetInfoDosya meta verileri (oluşturucu, birimler, koordinat sistemi)
animationClipsAnimationClip[]Sahnede bulunan tüm animasyon klipleri
open(path, opts?)(string, LoadOptions?) → voidDiskten bir dosya yükle
openFromBuffer(buf, opts?)(Buffer, LoadOptions?) → voidBellek içi tampondan yükle
save(path, opts?)(string, SaveOptions?) → voidDiskte kaydet (format uzantıdan çıkarılır)
saveToBuffer(ext, opts?)(string, SaveOptions?) → BufferBellek içi tamponda kaydet
createAnimationClip(name)(string) → AnimationClipYeni bir animasyon klibi oluştur ve kaydet

Enumerations

Sahne grafiğinde adlandırılmış bir ağaç düğümü. Düğümler isteğe bağlı bir Entity (mesh, camera, light) ve bir Transform düğümü ebeveynine göre konumlandıran.

EnumerationsEnumerationsEnumerations
namestringDüğüm adı
childNodesNode[]Doğrudan alt düğümler
entity`Entitynull`
transformTransformYerel çeviri, dönüş, ölçek
materialsMaterial[]Bu düğüme atanmış materyaller
createChildNode(name)(string) → NodeBir alt düğüm ekle
getChildNode(name)`(string) → Nodenull`

Enumerations

Poligon ağı; birincil geometri türü. Extends Geometry.

EnumerationsEnumerationsEnumerations
controlPointsVector4[]Vertex konumları (w=1 konumlar için)
polygonCountnumberPoligon sayısı
createPolygon(indices)(number[]) → voidBir poligon ekle (üçgen veya dörtgen)
getElement(type)`(VertexElementType) → VertexElementnull`
createElement(type)(VertexElementType) → VertexElementBir vertex öğesi oluştur

Enumerations

Bir düğüme uygulanan yerel dönüşüm.

EnumerationsEnumerationsEnumerations
translationVector3Yerel konum
eulerAnglesVector3Derece cinsinden Euler dönüşü (XYZ sırası)
rotationQuaternionRotasyon quaternion olarak
scalingVector3Yerel ölçek

Malzeme Sınıfları

EnumerationsEnumerationsAna Özellikler
LambertMaterialDifüz + ortam gölgelendirmediffuseColor, ambientColor, transparency
PhongMaterialLambert’e speküler + yayılımlı eklerspecularColor, shininess, emissiveColor
PbrMaterialFiziksel temelli glTF 2.0 içinalbedo, metallicFactor, roughnessFactor, emissiveColor

Matematik Sınıfları

EnumerationsEnumerations
Vector33-component double-precision vector (x, y, z)
Vector44-component vector for homogeneous math (x, y, z, w)
FVector3Tek duyarlıklı varyant, köşe verilerinde kullanılır
Matrix44×4 transformation matrix; multiply, invert, decompose
QuaternionDönüş kuaterniyonu; fromEulerAngle, toEulerAngles, slerp
BoundingBoxEksen hizalı sınırlayıcı kutu; minimum, maximum, center, size, merge

Animasyon Sınıfları

EnumerationsEnumerations
AnimationClipAdlandırılmış klip; içerir AnimationNode liste; aracılığıyla erişilir scene.animationClips
AnimationNodeBir klibi adlandırılmış sahne düğümüne bağlar; içerir AnimationChannel liste
AnimationChannelTek bir özelliği hedefler (ör. translation X); bir … tutar KeyframeSequence
KeyframeSequenceSıralı … listesi KeyFrame nesnelerle interpolation ve extrapolation
KeyFrameTek zaman/değer çifti

Enumerations

EnumerationsEnumerationsEnumerations
VertexElementTypeNORMAL, UV, VERTEX_COLOR, BINORMAL, TANGENTVertex eleman semantiği
MappingModeCONTROL_POINT, POLYGON_VERTEX, POLYGON, ALL_SAMEVerinin geometriye nasıl eşlendiği
ReferenceModeDIRECT, INDEX, INDEX_TO_DIRECTVertex eleman verisi için indeksleme stratejisi
InterpolationCONSTANT, LINEAR, BEZIERAnahtar kare interpolasyonu
ExtrapolationCONSTANT, GRADIENT, CYCLE, CYCLE_RELATIVE, OSCILLATEAnahtar kare aralığının dışındaki davranış

Format Modülleri

Biçime özgü seçenek sınıfları alt yol modüllerinden dışa aktarılır. Bunları ayrı ayrı içe aktarın:

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 Modülü (@aspose/3d/formats/obj)

EnumerationsAnahtar Seçenekleri
ObjLoadOptionsenableMaterials, flipCoordinateSystem, scale, normalizeNormal

glTF/GLB Modülü (@aspose/3d/formats/gltf)

EnumerationsAnahtar Seçenekleri
GltfSaveOptionsbinaryMode (true → .glb), flipTexCoordV
GltfFormatGltfFormat.getInstance(): format örneği için scene.save()

STL Modülü (@aspose/3d/formats/stl)

EnumerationsAnahtar Seçenekler
StlLoadOptionsN/A
StlSaveOptionsbinaryMode (false → ASCII, true → ikili)

FBX Modülü (@aspose/3d/formats/fbx)

EnumerationsAnahtar Seçenekler
FbxLoadOptionsN/A
FbxSaveOptionsembedTextures

Desteklenen Biçimler

EnumerationsEnumerationsEnumerationsEnumerations
Enumerations.objEnumerationsEnumerations
glTF 2.0.gltfEnumerationsEnumerations
Enumerations.glbEnumerationsEnumerations
STL.stlEnumerationsEnumerations
FBX.fbxHayır*Hayır*
COLLADA.daeEnumerationsEnumerations
3MF.3mfEnumerationsEnumerations

Hızlı Referans Örneği

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

Ayrıca Bakınız

 Türkçe