MaplyActiveObject
Objective-C
@interface MaplyActiveObject : NSObject
Swift
class MaplyActiveObject : NSObject
Active Objects are used implement animation.
Active Objects work in conjuction with the renderer to make updates on the main thread. The way they work is this. They’re called right at the beginning of a frame draw. They can make updates to regular Maply objects via the MaplyBaseViewController add and remove calls with the MaplyThreadMode set to MaplyThreadCurrent. This forces the changes to happen immediately on the current (main) thread.
Fill in at least the hasUpdate and updateForFrameMethods.
Active Objects are run on the main thread and you’re probably going to be asking the view controller to add and remove objects on the main thread. As such, this can be slow. Be sure to precalculate whatever you might need to make this run faster. Also consider implementing your changes another way. If it can be done on another thread, do it on another thread.
-
Initialize with a view controller
The default initializer just takes a view controller. If you replace this with your own, be sure to pass in what you need.
Declaration
Objective-C
- (nonnull instancetype)initWithViewController: (NSObject<MaplyRenderControllerProtocol> *_Nonnull)viewC;
-
The view controller this active object is associated with
Declaration
Objective-C
@property (nonatomic, weak, readonly) NSObject<MaplyRenderControllerProtocol> *_Nullable viewC;
-
Has Update
This is called every frame to determine if the active model has an update. If it doesn't, we may not need to render. So use this judiciously.
Declaration
Objective-C
- (_Bool)hasUpdate;
Swift
func hasUpdate() -> Bool
-
Update for the current frame.
Run the update right now. This should not take too long, as it's holding up the renderer. The frameInfo object is undefined at this point.
Declaration
Objective-C
- (void)updateForFrame:(void *_Nonnull)frameInfo;
Swift
func update(forFrame frameInfo: UnsafeMutableRawPointer)
-
Teardown active model.
The active model will no longer be run. Get rid of your internal state.
Declaration
Objective-C
- (void)teardown;
Swift
func teardown()