Send a file to DropListener?

Currently I have a fallback in my 3d model viewer for the web which loads a model from the url using GLTFLoader if there is a model with a file param there. The same model viewer also has a DropListener in it for drag/dropped models.

The issue I am finding is that dropped models using DropListener set up their animations correctly in this example

glb file:
Parent object (empty)
-Cube with animation
-another model with no animation

Loading this file with droplistener applies an Animator component to the cube with animation and it works correct

When I use a GLTFLoader to load the file from the url without droploader from the FTP server I use this code

    loader.load(result, (gltf) => {
        new CustomEvent(LoaderFixerListenerEvents.ObjectAdded, { detail: gltf })

Which doesn’t create any animator components - I have written some code to add an Animator if there are animations in the file but I just add the Animator to the Parent object (empty) because I don’t have any way to find out what objects the Animator should actually be on (which should be the child object Cube with animation in the example above).

To circumvent this I would like to just sent the DropListener the url of the file or the file itself from my script but all the methods in DropListener are private

Is there any way to do this?

Original Post on Discord

by user 103054507105067008

Hi Rob,
loader is a three gltfLoader?
And both the dropped files and the externally loaded files are GLBs exported with some Needle Engine integration (Unity or Blender) ?

Either way the droplistener is not doing anything special here:
what you actually want is to call loadSync(context, url, sourceId, seed) (source id is usually also just the url) - the method can be imported via { loadSync } from @needle-tools/engine

Trying now! Think I overcomplicated what I was doing as I was just using GLTFLoader from Three

by user 103054507105067008

What are sourceid and seed there?

by user 103054507105067008

If you create a new GltfLoader it wont have the needle engine extension plugins

as said: sourceId can be the same as url.
Seed can be any number e.g. 0 (or an UIDProvider but you dont need that)

Is there a callback for when it has loaded?

by user 103054507105067008

It returns a promise (awaitable) - well actually it returns the loaded glTF

const gltf = await loadSync...