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
991 B

import { Command } from "../Editor/CommandMachine";
import { FileSystem } from "../Common/FileSystem";
import * as THREE from "three";
import { app } from '../ApplicationServices/Application';
//FileSystem
export class Fbx implements Command
{
async exec()
{
FileSystem.chooseFile((f: FileList) =>
{
var reader = new FileReader();
// Closure to capture the file information.
reader.onload = (ev) =>
{
console.log(ev);
let manager = new THREE.LoadingManager();
let loader = new THREE.FBXLoader(manager);
let obj = loader.parse(reader.result as string, "");
obj.scale.set(0.01, 0.01, 0.01);
obj.matrixWorldNeedsUpdate = true;
app.m_Viewer.Scene.add(obj);
}
// Read in the image file as a data URL.
reader.readAsArrayBuffer(f.item(0));
}, null, null);
}
}