You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/src/Add-on/loadfbx.ts

35 lines
1.0 KiB

import { Command } from "../Editor/CommandMachine";
import { FileSystem } from "../Common/FileSystem";
import { app } from '../ApplicationServices/Application';
5 years ago
import { LoadingManager, FBXLoader } from "three";
export class Fbx implements Command
{
async exec()
{
5 years ago
let files = await FileSystem.ChooseFile(".fbx");
for (let i = 0; i < files.length; i++)
{
5 years ago
let f = files.item(i);
var reader = new FileReader();
// Closure to capture the file information.
reader.onload = (ev) =>
{
console.log(ev);
5 years ago
let manager = new LoadingManager();
let loader = new FBXLoader(manager);
let obj = loader.parse(reader.result as string, "");
obj.scale.set(0.01, 0.01, 0.01);
obj.matrixWorldNeedsUpdate = true;
app.Viewer.Scene.add(obj);
}
// Read in the image file as a data URL.
5 years ago
reader.readAsArrayBuffer(f);
}
}
}