I am working on an application using ARKit and SceneKit frameworks. I am able to render my 3D object, create overlay etc. I want to load a GIF animation like a overlay in ARSession
on tap of one of my child nodes. Is this possible?
I tried adding SKScene
as a overlay to my SCNScene
like below, and it looks good.
informationOverlay = InformationOverlayScene(size: self.sceneView.frame.size)
self.sceneView.overlaySKScene = informationOverlay
But how to load this GIF file in SKScene
or SCNNode
?
The following SO question answers how to display an animation inside an SKNode
:
Simple Gif like animation with Spritekit
You could use projectPoint to project the location of the SCNNode
(of your 3D model) to a 2D location on screen, and then use that for the location of the SKNode
containing the animation. That way the animation will always face the screen.
Alternatively, you could assign a Core Animation layer containing the animation to the .diffuse.contents
property of a SCNMaterial
and assign that to a SCNPlane
which you can add to the scene and position above the 3D model. If you want that plane to face the camera, simply assign the .pointOfView.orientantion
property of your SCNView
to the SCNNode
that holds the SCNPlane
.