Sketchfab Forum

Viewer API to explode and reassemble model

(Jon Russell) #1


I have a model of a machine and I have animated it exploding and reassembling (two separate animations), but is it possible to use javascript and the Viewer API to create an icon that allows the user to click and explode the model, then click to reassemble? I do not want to load separate animations per click as this would ruin the fluidity of the feature. Could I combine them into one video then maybe play e.g. half of the video to explode, then half again upon reassemble? I am not sure if this is possible? Any help appreciated.



The Viewer API has (undocumented) translate() and rotate() functions. It would be a bit tedious, but certainly possible:

translate( [nodeID], [translateTo], [duration], [easing], [callback] )

rotate( [nodeID], [rotateTo], [duration], [easing], [callback] )

getMatrix( nodeID, callback )

Returns the transform matrices for a given node.
The callback will be passed (err, matrices).

setMatrix( nodeID, matrix, [duration], [callback] )

Sets the transform matrix of a given node.
The callback will be invoked with no parameter.

There are also animation functions, so you could have a button to play the explode animation, and another button to reset (i.e. go to frame 1 and stop)

Another solution could be a timeframe:

(Jon Russell) #3

Ok, after several days of trying, I cant do it. I wanted to have one icon to play the first 7 seconds of a video, then another to play the next 7 seconds, then loop it so that it just repeats. I cant seem to do this, not sure why. Will there be an example in the labs section in the future? It would be a good feature to have.