Exporting Blender camera animation to Sketchfab - work in progress


(Bart) #1

Hey folks,

I just had a crazy idea for a 'friday afternoon' project: I'd like to try and set up some simple camera animation on Sketchfab using an animated path in Blender. Using the Sketchfab Viewer API, you can set up a Javascript to drive the camera and it's target.

I guess this means it's possible to select a camera and to have a Python script write out 'ready-to-use' Javascript file that contains the camera coordinates and target for each frame.

My Python skills are rather nonexistent, so I was hoping someone might be able to help me with this?


Exporting 3DS Max camera animation to Sketchfab - work in progress
Status of animations?
Upcoming API sneak peek
Feature requests: notification title, custom environments, annotions
#2

Really cool idea. I don't know anything about how Blender's animation paths are encoded.


(Bart) #3

I guess you could just step through the frames and for each frame export camera + camera target position. That way you wouldn't need to worry about how the camera animation is driven (which could be done in SO many different ways).

I think the one thing that's missing is support for camera banking, right? That would make a fly-through totally awesome smile


(Tuan Kuranes) #4

Export camera & light animation:
http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/ClarisseCameraExport (save that into a csv file instead of their py code)
Then parse the csv http://papaparse.com/ in js, of usage in js

Directly Drive viewer API from blender
blender network server: https://github.com/verse/verse-blender
blender network client in js: https://github.com/verse/verse-javascript
(remote Real time demo ?)


(Shaderbytes) #5

Sadly I have no experience with python just like you and dont have the time at the moment for a experiment. Some thoughts though..

Actually the way the camera is animated would be important, you can't just export the points alone otherwise you wont get the same animation result expected which would probably frustrate users. Blender uses IPO curves for all animations , I think a smooth bezier is the default interpolation. For most animations i presume many beginner/ intermediate blender users dont touch the IPO curves and you could just do the same formula on your end without problems. But this is not always the case , I know I edit the curves so something to think about would be to then also export the user specified IPO curves for the animation as well.


(Bart) #6

Hey @tuan_kuranes that's clever, I'll go and give that a try!

@shaderbytes if you export the position and orientation for every single frame of the animation you wouldn't have to worry about interpolation models, right?


(Shaderbytes) #7

yes for every frame that would work .. sorry I missed that part , I was thinking according to keyed frames only


(Shaderbytes) #8

of coarse the trade off means a lot of points wink


(Bart) #9

Compared to how much data we're already pushing to WebGL, I don't think that will be a problem wink


(Shaderbytes) #10

yeah its not a train smash or anything 5kb of data vs 50kb does not make a difference really in modern computing and the pro side of storing data for every frame means you wont have to calculate any bezier points at runtime wink


(Tuan Kuranes) #11

Without interpolation: camera movement speed will depend on user viewer rendering speed, users at 120fps will have a fast camera moving, whereas user at 15 fps will have slow ones...
In fact, you have to interpolate either if viewer FPS is > or < to your camera animation, unless you don't need/want fixed time animation.

So Either you interpolate, which means remembering dual numbers and Quaternion from math courses ?
Or you export at max possible FPS (144fps for current monitors) and instead of interpolate, you drop frames when user viewer are slower ?

I would add not to worry about file size, If done smartly, as in lowering the decimal digit to a reasonnable number (<4), it will compress very well and thus can be very small.


(Bart) #12

Thanks @tuan_kuranes, that's great input!

I think I'll go for the maximum frame rate and then dropping frames, my quaternion math is a little rusty wink. I'll have a go at that script you suggested earlier and see where it leads.


(Bart) #13

So today I spent a few hours on a first version of this script. I followed @tuan_kuranes's suggestion and downloaded the Clarisse camera exporter. Instead of doing parsing and stuff, I just tweaked the code so that it would spit out a ready to use HTML page with the javascript and all the data included.

So this is the idea smile

And it sort of works smile Try this. It's still a long way from production-ready, but I'll keep working on it.

Is anyone interested in joining me? If so, I'll put my code up on GitHub.


#14

Very interested in seeing the code at least


Exporting 3DS Max camera animation to Sketchfab - work in progress
(Tuan Kuranes) #15

Works Nicely, Great !
Now need some better camera animation, like the best directors smile
See https://www.youtube.com/user/everyframeapainting


(Bart) #16

Yeah my test animation is crap wink I'm cleaning up the script a little now and will put it on GitHub later this weekend. Would love to get a little collaboration going on to clean it up.


(Bart) #17

I moved a post to a new topic: Exporting 3DS Max camera animation to Sketchfab - work in progress


(Mhazani) #18

Any update on this? A camera spline flythrough would be awesome for my immersive VR thing:)


(Bart) #19

Afraid not :-/ I'll add your +1 to the ticket!