Häufig gestellte Fragen
Häufig gestellte Fragen
Wie installiere ich @aspose/3d?
Installation über npm. Node.js 18 oder höher ist erforderlich:
npm install @aspose/3dInstallation überprüfen:
import { Scene } from '@aspose/3d';
const scene = new Scene();
console.log('@aspose/3d ready');TypeScript‑Typdefinitionen sind im Paket enthalten. Kein separates @types/‑Paket ist erforderlich.
Welche Dateiformate werden unterstützt?
| Format | Import | Export |
|---|---|---|
| OBJ (Wavefront) | Ja | Ja |
| glTF 2.0 / GLB | Ja | Ja |
| FBX (Autodesk) | Nein* | Nein* |
| STL (Stereo Lithography) | Ja | Ja |
| 3MF (3D Manufacturing) | Ja | Ja |
| COLLADA (.dae) | Ja | Ja |
Wie lade ich eine 3D-Datei?
Erstelle ein Scene und rufe scene.open() auf:
import { Scene } from '@aspose/3d';
import { ObjLoadOptions } from '@aspose/3d/formats/obj';
const scene = new Scene();
scene.open('model.obj', new ObjLoadOptions());Für Formate, die keine speziellen Optionen benötigen, lassen Sie das zweite Argument weg:
const scene = new Scene();
scene.open('model.glb');Ist scene.open() asynchron?
Nein. scene.open() und scene.openFromBuffer() sind synchrone Aufrufe. Wenn Sie nicht‑blockierende I/O benötigen, führen Sie sie in einem Node.js‑Worker‑Thread aus oder wickeln Sie sie mit setImmediate ein.
Wie speichere ich in glTF/GLB?
Rufen Sie scene.save() mit einem Dateipfad auf. Das Format wird automatisch anhand der Erweiterung erkannt:
scene.save('output.glb'); // binary glTF
scene.save('output.gltf'); // JSON glTF
scene.save('output.obj'); // OBJ
scene.save('output.stl'); // STL
Wie lade ich aus einem Buffer (im Speicher)?
Verwenden Sie scene.openFromBuffer():
import * as fs from 'fs';
import { Scene } from '@aspose/3d';
import { ObjLoadOptions } from '@aspose/3d/formats/obj';
const buffer = fs.readFileSync('model.obj');
const scene = new Scene();
scene.openFromBuffer(buffer, new ObjLoadOptions());Fehler: Modul ‘@aspose/3d/formats/obj’ nicht gefunden
Dies erfordert die Auflösung von package exports in Node.js 12.7+. Stellen Sie sicher, dass Sie Node.js 18+ verwenden. Für TypeScript setzen Sie "moduleResolution": "node16" oder "bundler" in tsconfig.json:
{
"compilerOptions": {
"moduleResolution": "node16",
"target": "ES2020"
}
}Was ist der Typ von node.entity?
node.entity ist allgemein typisiert. Um mesh‑spezifische Eigenschaften zuzugreifen, prüfen Sie deren Vorhandensein mit 'controlPoints' in node.entity oder verwenden Sie die Mesh‑Klasse aus @aspose/3d/entities:
import { Mesh } from '@aspose/3d/entities';
if (node.entity instanceof Mesh) {
const mesh = node.entity;
console.log(mesh.controlPoints.length);
}Läuft die Bibliothek im Browser?
Die Bibliothek ist für Node.js konzipiert. Die Browserunterstützung hängt von der Bundler‑Konfiguration ab und davon, dass Dateisystem‑APIs durch In‑Memory‑Alternativen ersetzt werden.
Ist die Bibliothek thread‑sicher?
Jedes Scene‑Objekt ist unabhängig. Die Verwendung separater Scene‑Instanzen aus separaten Node.js‑Worker‑Threads ist sicher, solange Sie nicht eine einzelne Szene über Threads hinweg teilen, ohne externe Synchronisation.
Welche Node.js-Versionen werden unterstützt?
Node.js 18, 20 und 22 werden offiziell unterstützt. TypeScript 5.0+ wird empfohlen.
Unterstützt @aspose/3d Animationen?
Ja. Das Animationssystem umfasst AnimationClip, AnimationChannel und Keyframe‑Kurventypen, die über @aspose/3d/animation zugänglich sind.