API Overview — @aspose/3d for TypeScript

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

@aspose/3d ist eine MIT-lizenzierte Bibliothek zum Lesen, Erstellen und Exportieren von 3D‑Szenen in Node.js. Sie wird mit vollständigen TypeScript‑Typdefinitionen, einer einzigen Laufzeitabhängigkeit («<SEG_7»> ), und unterstützt sieben gängige 3D‑Dateiformate. Alle Ein‑/Ausgaben sind synchron. Es werden keine nativen Add‑Ons benötigt.xmldom), und unterstützt sieben gängige 3D‑Dateiformate. Alle Ein‑/Ausgaben sind synchron. Es werden keine nativen Add‑Ons benötigt.


Properties

npm install @aspose/3d

Properties tsconfig.json Einstellungen für die korrekte Auflösung von Unterpfaden:

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

Die Klasse Shape stellt interne Methoden zur Arbeit mit Platzhaltern bereit:

Properties

Der Wurzelcontainer für eine 3D‑Szene. Alle Inhalte; Knoten, Geometrie, Materialien und Animationen; werden in einem Baum gespeichert, dessen Wurzel bei scene.rootNode.Verwenden Sie open() / openFromBuffer() um eine Datei zu laden und save() / saveToBuffer() zu exportieren.

PropertiesPropertiesProperties
rootNodeNodeWurzel des Szenengraphen
assetInfoAssetInfoDateimetadaten (Ersteller, Einheiten, Koordinatensystem)
animationClipsAnimationClip[]Alle Animationsclips in der Szene
open(path, opts?)(string, LoadOptions?) → voidLade eine Datei von der Festplatte
openFromBuffer(buf, opts?)(Buffer, LoadOptions?) → voidLade aus dem In-Memory-Puffer
save(path, opts?)(string, SaveOptions?) → voidSpeichere auf die Festplatte (Format wird aus der Erweiterung abgeleitet)
saveToBuffer(ext, opts?)(string, SaveOptions?) → BufferSpeichere in den In-Memory-Puffer
createAnimationClip(name)(string) → AnimationClipErstelle und registriere einen neuen Animationsclip

Properties

Ein benannter Baumknoten im Szenengraphen. Knoten tragen optional ein Entity (Mesh, Kamera, Licht) und ein Transform die den Knoten relativ zu seinem Elternteil positioniert.

PropertiesPropertiesProperties
namestringKnotenname
childNodesNode[]Direkte Kindknoten
entity`Entitynull`
transformTransformLokale Translation, Rotation, Skalierung
materialsMaterial[]Dem Knoten zugewiesene Materialien
createChildNode(name)(string) → NodeKindknoten hinzufügen
getChildNode(name)`(string) → Nodenull`

Properties

Polygonnetz; der primäre Geometrietyp. Erweitert Geometry.

PropertiesPropertiesProperties
controlPointsVector4[]Scheitelpunktpositionen (w=1 für Positionen)
polygonCountnumberAnzahl der Polygone
createPolygon(indices)(number[]) → voidPolygon hinzufügen (Dreieck oder Viereck)
getElement(type)`(VertexElementType) → VertexElementnull`
createElement(type)(VertexElementType) → VertexElementVertex-Element erstellen

Properties

Lokale Transformation, die auf einen Knoten angewendet wird.

PropertiesPropertiesProperties
translationVector3Lokale Position
eulerAnglesVector3Euler-Rotation in Grad (XYZ-Reihenfolge)
rotationQuaternionRotation als Quaternion
scalingVector3Lokale Skalierung

Materialklassen

PropertiesPropertiesWichtige Eigenschaften
LambertMaterialDiffuse + UmgebungsbeleuchtungdiffuseColor, ambientColor, transparency
PhongMaterialFügt zu Lambert spekulare + emittierende Komponenten hinzuspecularColor, shininess, emissiveColor
PbrMaterialPhysikbasiert für glTF 2.0albedo, metallicFactor, roughnessFactor, emissiveColor

Mathematikklassen

PropertiesProperties
Vector33-component double-precision vector (x, y, z)
Vector44-component vector for homogeneous math (x, y, z, w)
FVector3Single-precision-Variante, die in Vertex-Daten verwendet wird
Matrix44×4 transformation matrix; multiply, invert, decompose
QuaternionRotations-Quaternion; fromEulerAngle, toEulerAngles, slerp
BoundingBoxAchsenorientierte Bounding-Box; minimum, maximum, center, size, merge

Animationsklassen

PropertiesProperties
AnimationClipBenannter Clip; enthält AnimationNode Liste; zugegriffen über scene.animationClips
AnimationNodeBindet einen Clip an einen benannten Szenenknoten; enthält AnimationChannel Liste
AnimationChannelZielt auf eine einzelne Eigenschaft (z. B. Translation X); hält ein KeyframeSequence
KeyframeSequenceGeordnete Liste von KeyFrame Objekten mit interpolation und extrapolation
KeyFrameEinzelnes Zeit/Wert-Paar

Properties

PropertiesPropertiesProperties
VertexElementTypeNORMAL, UV, VERTEX_COLOR, BINORMAL, TANGENTVertex-Element-Semantik
MappingModeCONTROL_POINT, POLYGON_VERTEX, POLYGON, ALL_SAMEWie Daten auf Geometrie abgebildet werden
ReferenceModeDIRECT, INDEX, INDEX_TO_DIRECTIndexierungsstrategie für Vertex-Element-Daten
InterpolationCONSTANT, LINEAR, BEZIERKeyframe-Interpolation
ExtrapolationCONSTANT, GRADIENT, CYCLE, CYCLE_RELATIVE, OSCILLATEVerhalten außerhalb des Keyframe-Bereichs

Formatmodule

Format‑spezifische Optionsklassen werden aus Sub‑Pfad‑Modulen exportiert. Importieren Sie sie separat:

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

PropertiesSchlüsseloptionen
ObjLoadOptionsenableMaterials, flipCoordinateSystem, scale, normalizeNormal

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

PropertiesSchlüsseloptionen
GltfSaveOptionsbinaryMode (true → .glb), flipTexCoordV
GltfFormatGltfFormat.getInstance():Formatinstanz für scene.save()

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

PropertiesSchlüsseloptionen
StlLoadOptionsN/A
StlSaveOptionsbinaryMode (false → ASCII, true → binär)

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

PropertiesSchlüsseloptionen
FbxLoadOptionsN/A
FbxSaveOptionsembedTextures

Unterstützte Formate

PropertiesPropertiesPropertiesProperties
Properties.objPropertiesProperties
glTF 2.0.gltfPropertiesProperties
Properties.glbPropertiesProperties
STL.stlPropertiesProperties
FBX.fbxNein*Nein*
COLLADA.daePropertiesProperties
3MF.3mfPropertiesProperties

Kurzreferenzbeispiel

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

Siehe auch

 Deutsch