Hi all,
I have a quick, simple question (I think!) : can I use gsap inside a web worker? I've tried importing it, but I get an error in my console which says Uncaught ReferenceError: document is not defined. Which is not surprising, since the worker can't see the DOM.
A brief overview of what I'm trying to accomplish: I have a complex ThreeJS scene which includes a 3D character. I use TimelineMax to create animated timelines to sync the character's lips with audio files of the character's speech. The audio files come from a text-to-speech API so they are different every time. The system I've developed works perfectly because the API I'm using gives me an XML file of the mouth visemes and timings along with the audio. So I simply manipulate my character's mouth morph shapes with a TimelineMax. In fact I have a virtual object called "face" and it has properties pertaining to the available morph shapes, so it's something like
face = {
smile: 0,
grin: 0,
sad: 0,
AA: 0,
EE: 0,
EH: 0,
ER: 0,
F: 0,
IH: 0
etc. etc.
}
and I simply animate these properties of face between 0 and 1 and on my requestAnimationFrame update I manipulate the 3D mesh accordingly, so I don't manipulate and DOM elements at all. This has worked perfectly for some time.
Now, however, I'm looking at moving my 3D scene to an offscreencanvas to speed up its rendering but also to prevent the main page becoming janky whilst the assets are loading. Does anyone have any suggestions as to how I might continue to use TimelineMax please? I don't need the full functionality of gsap.
Any pointers much appreciated, thank you :o)