Replies: 1 comment 4 replies
-
Okay, I managed to make it load. The ScaledModelWithProgress is just from the story examples. Don't really like how I am setting state of a JSX element to force the render, but it works. Any further suggestions welcome! function DragDropFileLoader(): JSX.Element {
const scene = useScene();
const engine = useEngine();
const [renderModel, setRenderModel] = useState<JSX.Element | undefined>();
if (!filesInput) {
console.log("init file input");
filesInput = new FilesInput(
engine,
scene,
() => void 0,
() => void 0,
() => void 0,
() => void 0,
() => void 0,
(sceneFile: File) => {
setRenderModel(
<ScaledModelWithProgress
rootUrl={`file:`}
sceneFilename={sceneFile.name}
scaleTo={100}
progressBarColor={Color3.FromInts(255, 165, 0)}
center={Vector3.Zero()}
/>
);
},
(file, scene, message) => {
console.log(message, file, scene);
}
);
filesInput.monitorElementForDragNDrop(engine.getRenderingCanvas());
}
if (renderModel) {
return renderModel;
}
return <></>;
} |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to use
FilesInput
(docs) as a drag/drop handler on the canvas, so I can load in files by drag/drop.I thought I could just do something like below, but when I drag/drop files, simply nothing happens at all (nothing is loaded automatically anyway.
Any thoughts on what I am missing? I think in the "reload" callback, I am provided with a
File
(onReloadCallback: (sceneFile: File) => void
) which I think I may need to manually load in. However I am not sure how exactly to do that. Should it be withuseAssetManager
,sceneLoader
? Both of which don't acceptFile
?Beta Was this translation helpful? Give feedback.
All reactions