import { Command } from "../Editor/CommandMachine"; import { FileSystem } from "../Common/FileSystem"; import { app } from '../ApplicationServices/Application'; import { LoadingManager, FBXLoader } from "three"; export class Fbx implements Command { async exec() { let files = await FileSystem.ChooseFile(".fbx"); for (let i = 0; i < files.length; i++) { let f = files.item(i); var reader = new FileReader(); // Closure to capture the file information. reader.onload = (ev) => { console.log(ev); 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.m_Viewer.Scene.add(obj); } // Read in the image file as a data URL. reader.readAsArrayBuffer(f); } } }