tidy up method call handler and add example project with camera panning

This commit is contained in:
Nick Fisher
2021-09-16 17:33:24 +08:00
parent a0f877be48
commit 8288758e78
16 changed files with 363 additions and 141 deletions

View File

@@ -16,21 +16,26 @@
// These defines are set in the "Preprocessor Macros" build setting for each scheme.
#include "FilamentView.h"
#include "FilamentViewer.hpp"
#import <Foundation/Foundation.h>
using namespace std;
@interface FilamentView ()
- (void)initCommon;
- (void)setViewer:(mimetic::FilamentViewer*)viewer;
@end
@implementation FilamentView {
mimetic::FilamentViewer* _viewer;
}
- (void)setViewer:(mimetic::FilamentViewer*)viewer {
_viewer = viewer;
_viewer->updateViewportAndCameraProjection(self.bounds.size.width, self.bounds.size.height, self.contentScaleFactor);
}
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self initCommon];
@@ -58,4 +63,18 @@ using namespace std;
return [CAEAGLLayer class];
}
- (void)layoutSubviews {
[super layoutSubviews];
if(_viewer) {
_viewer->updateViewportAndCameraProjection(self.bounds.size.width, self.bounds.size.height, self.contentScaleFactor);
}
}
- (void)setContentScaleFactor:(CGFloat)contentScaleFactor {
[super setContentScaleFactor:contentScaleFactor];
if(_viewer) {
_viewer->updateViewportAndCameraProjection(self.bounds.size.width, self.bounds.size.height, self.contentScaleFactor);
}
}
@end