diff --git a/example/README.md b/example/README.md index b94554b3..ec21688a 100644 --- a/example/README.md +++ b/example/README.md @@ -1,6 +1,6 @@ -# mimetic_filament_example +# holovox_filament_example -Demonstrates how to use the mimetic_filament plugin. +Demonstrates how to use the holovox_filament plugin. ## Getting Started diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 28140955..cd9d5b99 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -350,7 +350,7 @@ "@executable_path/Frameworks", ); PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.example.mimeticAvatarExample; + PRODUCT_BUNDLE_IDENTIFIER = com.example.holovoxAvatarExample; PRODUCT_NAME = "$(TARGET_NAME)"; STRIP_INSTALLED_PRODUCT = NO; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -489,7 +489,7 @@ "@executable_path/Frameworks", ); PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.example.mimeticAvatarExample; + PRODUCT_BUNDLE_IDENTIFIER = com.example.holovoxAvatarExample; PRODUCT_NAME = "$(TARGET_NAME)"; STRIP_INSTALLED_PRODUCT = NO; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -516,7 +516,7 @@ "@executable_path/Frameworks", ); PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.example.mimeticAvatarExample; + PRODUCT_BUNDLE_IDENTIFIER = com.example.holovoxAvatarExample; PRODUCT_NAME = "$(TARGET_NAME)"; STRIP_INSTALLED_PRODUCT = NO; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/example/lib/main.dart b/example/lib/main.dart index 18fe229b..21ca90ff 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -19,7 +19,7 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { - final FilamentController _filamentController = MimeticFilamentController(); + final FilamentController _filamentController = HolovoxFilamentController(); bool _rotate = false; int _primitiveIndex = 0; diff --git a/ios/Classes/MimeticFilamentPlugin.h b/ios/Classes/HolovoxFilamentPlugin.h similarity index 100% rename from ios/Classes/MimeticFilamentPlugin.h rename to ios/Classes/HolovoxFilamentPlugin.h diff --git a/ios/Classes/MimeticFilamentPlugin.mm b/ios/Classes/HolovoxFilamentPlugin.mm similarity index 84% rename from ios/Classes/MimeticFilamentPlugin.mm rename to ios/Classes/HolovoxFilamentPlugin.mm index 55a87f16..916908de 100644 --- a/ios/Classes/MimeticFilamentPlugin.mm +++ b/ios/Classes/HolovoxFilamentPlugin.mm @@ -7,6 +7,6 @@ FilamentNativeViewFactory* factory; + (void)registerWithRegistrar:(NSObject*)registrar { factory = [[FilamentNativeViewFactory alloc] initWithRegistrar:registrar]; - [registrar registerViewFactory:factory withId:@"mimetic.app/filament_view"]; + [registrar registerViewFactory:factory withId:@"holovox.app/filament_view"]; } @end diff --git a/ios/Classes/filament/FilamentMethodCallHandler.h b/ios/Classes/filament/FilamentMethodCallHandler.h index 869f5204..2902b3e1 100644 --- a/ios/Classes/filament/FilamentMethodCallHandler.h +++ b/ios/Classes/filament/FilamentMethodCallHandler.h @@ -7,12 +7,12 @@ #include "FilamentViewer.hpp" -static const id VIEW_TYPE = @"mimetic.app/filament_view"; +static const id VIEW_TYPE = @"holovox.app/filament_view"; @interface FilamentMethodCallHandler : FlutterMethodChannel - (void)handleMethodCall:(FlutterMethodCall* _Nonnull)call result:( FlutterResult _Nonnull)result; -- (mimetic::FilamentViewer*) _viewer; -- (mimetic::ResourceBuffer)loadResource:(const char* const)path; +- (holovox::FilamentViewer*) _viewer; +- (holovox::ResourceBuffer)loadResource:(const char* const)path; - (void)freeResource:(void*)mem size:(size_t)size misc:(void*)misc; - (void)ready; - (instancetype)initWithController:(FilamentViewController*)controller diff --git a/ios/Classes/filament/FilamentMethodCallHandler.mm b/ios/Classes/filament/FilamentMethodCallHandler.mm index 194d8c73..4c0eca84 100644 --- a/ios/Classes/filament/FilamentMethodCallHandler.mm +++ b/ios/Classes/filament/FilamentMethodCallHandler.mm @@ -4,7 +4,7 @@ static const FilamentMethodCallHandler* _handler; -static mimetic::ResourceBuffer loadResourceGlobal(const char* name) { +static holovox::ResourceBuffer loadResourceGlobal(const char* name) { return [_handler loadResource:name]; } @@ -16,7 +16,7 @@ static void* freeResourceGlobal(void* mem, size_t size, void* misc) { @implementation FilamentMethodCallHandler { FilamentViewController *_controller; FlutterMethodChannel* _channel; - mimetic::FilamentViewer* _viewer; + holovox::FilamentViewer* _viewer; void* _layer; NSObject* _registrar; @@ -43,9 +43,9 @@ static void* freeResourceGlobal(void* mem, size_t size, void* misc) { - (void)handleMethodCall:(FlutterMethodCall* _Nonnull)call result:(FlutterResult _Nonnull )result { if([@"initialize" isEqualToString:call.method]) { if(!call.arguments) - _viewer = new mimetic::FilamentViewer(_layer, nullptr, loadResourceGlobal, freeResourceGlobal); + _viewer = new holovox::FilamentViewer(_layer, nullptr, loadResourceGlobal, freeResourceGlobal); else - _viewer = new mimetic::FilamentViewer(_layer, [call.arguments UTF8String], loadResourceGlobal, freeResourceGlobal); + _viewer = new holovox::FilamentViewer(_layer, [call.arguments UTF8String], loadResourceGlobal, freeResourceGlobal); [_controller setViewer:_viewer]; [_controller startDisplayLink]; result(@"OK"); @@ -117,7 +117,7 @@ static void* freeResourceGlobal(void* mem, size_t size, void* misc) { _viewer->playAnimation([call.arguments intValue]); result(@"OK"); } else if([@"getTargetNames" isEqualToString:call.method]) { - mimetic::StringList list = _viewer->getTargetNames([call.arguments UTF8String]); + holovox::StringList list = _viewer->getTargetNames([call.arguments UTF8String]); NSMutableArray* asArray = [NSMutableArray arrayWithCapacity:list.count]; for(int i = 0; i < list.count; i++) { asArray[i] = [NSString stringWithFormat:@"%s", list.strings[i]]; @@ -146,7 +146,7 @@ static void* freeResourceGlobal(void* mem, size_t size, void* misc) { } } -- (mimetic::ResourceBuffer)loadResource:(const char* const)path { +- (holovox::ResourceBuffer)loadResource:(const char* const)path { NSString* p = [NSString stringWithFormat:@"%s", path]; NSString* key = [_registrar lookupKeyForAsset:p]; NSString* nsPath = [[NSBundle mainBundle] pathForResource:key @@ -159,7 +159,7 @@ static void* freeResourceGlobal(void* mem, size_t size, void* misc) { NSData* buffer = [NSData dataWithContentsOfFile:nsPath]; void* cpy = malloc([buffer length]); memcpy(cpy, [buffer bytes], [buffer length]); // can we avoid this copy somehow? - mimetic::ResourceBuffer rbuf(cpy, [buffer length]); + holovox::ResourceBuffer rbuf(cpy, [buffer length]); return rbuf; } diff --git a/ios/Classes/filament/FilamentNativeViewFactory.mm b/ios/Classes/filament/FilamentNativeViewFactory.mm index 9caaae8d..76977bf5 100644 --- a/ios/Classes/filament/FilamentNativeViewFactory.mm +++ b/ios/Classes/filament/FilamentNativeViewFactory.mm @@ -30,7 +30,7 @@ @implementation FilamentNativeView { FilamentView* _view; FilamentViewController* _controller; - mimetic::FilamentViewer* _viewer; + holovox::FilamentViewer* _viewer; FilamentMethodCallHandler* _handler; void* _layer; } diff --git a/ios/Classes/filament/FilamentView.h b/ios/Classes/filament/FilamentView.h index 103e9378..79d12a3b 100644 --- a/ios/Classes/filament/FilamentView.h +++ b/ios/Classes/filament/FilamentView.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN * */ @interface FilamentView : UIView -- (void)setViewer:(mimetic::FilamentViewer*)viewer; +- (void)setViewer:(holovox::FilamentViewer*)viewer; @end NS_ASSUME_NONNULL_END diff --git a/ios/Classes/filament/FilamentView.mm b/ios/Classes/filament/FilamentView.mm index 22ed970a..49ce813a 100644 --- a/ios/Classes/filament/FilamentView.mm +++ b/ios/Classes/filament/FilamentView.mm @@ -23,14 +23,14 @@ using namespace std; @interface FilamentView () - (void)initCommon; -- (void)setViewer:(mimetic::FilamentViewer*)viewer; +- (void)setViewer:(holovox::FilamentViewer*)viewer; @end @implementation FilamentView { - mimetic::FilamentViewer* _viewer; + holovox::FilamentViewer* _viewer; } -- (void)setViewer:(mimetic::FilamentViewer*)viewer { +- (void)setViewer:(holovox::FilamentViewer*)viewer { _viewer = viewer; _viewer->updateViewportAndCameraProjection(self.bounds.size.width, self.bounds.size.height, self.contentScaleFactor); } diff --git a/ios/Classes/filament/FilamentViewController.h b/ios/Classes/filament/FilamentViewController.h index 670e238b..bde79382 100644 --- a/ios/Classes/filament/FilamentViewController.h +++ b/ios/Classes/filament/FilamentViewController.h @@ -23,7 +23,7 @@ @interface FilamentViewController : UIViewController @property(weak, nonatomic) IBOutlet FilamentView* modelView; -- (void)setViewer:(mimetic::FilamentViewer*)viewer; +- (void)setViewer:(holovox::FilamentViewer*)viewer; - (void)startDisplayLink; - (void)stopDisplayLink; diff --git a/ios/Classes/filament/FilamentViewController.mm b/ios/Classes/filament/FilamentViewController.mm index bb11b2c1..a483c87d 100644 --- a/ios/Classes/filament/FilamentViewController.mm +++ b/ios/Classes/filament/FilamentViewController.mm @@ -22,7 +22,7 @@ @implementation FilamentViewController { CADisplayLink* _displayLink; NSObject* _registrar; - mimetic::FilamentViewer* _viewer; + holovox::FilamentViewer* _viewer; FilamentView* _view; } @@ -35,7 +35,7 @@ return self; } -- (void)setViewer:(mimetic::FilamentViewer*)viewer { +- (void)setViewer:(holovox::FilamentViewer*)viewer { _viewer = viewer; [_view setViewer:_viewer]; } diff --git a/ios/src/FilamentViewer.cpp b/ios/src/FilamentViewer.cpp index 2c89bb78..dcd7f2ba 100644 --- a/ios/src/FilamentViewer.cpp +++ b/ios/src/FilamentViewer.cpp @@ -75,7 +75,7 @@ namespace gltfio { filament::math::quatf* rotation, filament::math::float3* scale); } -namespace mimetic { +namespace holovox { const double kNearPlane = 0.05; // 5 cm const double kFarPlane = 1000.0; // 1 km diff --git a/ios/src/FilamentViewer.hpp b/ios/src/FilamentViewer.hpp index 322e4a0e..eda37026 100644 --- a/ios/src/FilamentViewer.hpp +++ b/ios/src/FilamentViewer.hpp @@ -40,7 +40,7 @@ using namespace utils; using namespace camutils; -namespace mimetic { +namespace holovox { typedef std::chrono::time_point time_point_t; diff --git a/lib/filament_controller.dart b/lib/filament_controller.dart index 4093e776..0e6548c7 100644 --- a/lib/filament_controller.dart +++ b/lib/filament_controller.dart @@ -25,31 +25,32 @@ abstract class FilamentController { Future zoom(double z); } -class MimeticFilamentController extends FilamentController { +class HolovoxFilamentController extends FilamentController { late int _id; late MethodChannel _channel; final String materialPath; + final Function(int id)? onFilamentViewCreatedHandler; - MimeticFilamentController( - {this.materialPath = "packages/holovox_filament/assets/compiled.mat"}); + HolovoxFilamentController( + {this.materialPath = "packages/holovox_filament/assets/compiled.mat", + this.onFilamentViewCreatedHandler}); @override void onFilamentViewCreated(int id) async { _id = id; - _channel = MethodChannel("mimetic.app/filament_view_$id"); + _channel = MethodChannel("holovox.app/filament_view_$id"); _channel.setMethodCallHandler((call) async { await Future.delayed(Duration( seconds: - 1)); // todo - need a better way to know when the GL context is actaully ready + 1)); // todo - need a better way to know when the GL context is actually ready await _initialize(); + onFilamentViewCreatedHandler?.call(_id); return Future.value(true); }); } @override Future _initialize() async { - final foo = await rootBundle.load(materialPath); - print("Initializing with material path of size ${foo.lengthInBytes}"); await _channel.invokeMethod("initialize", materialPath); } diff --git a/lib/view/filament_view.dart b/lib/view/filament_view.dart index 11956a3f..1db6a458 100644 --- a/lib/view/filament_view.dart +++ b/lib/view/filament_view.dart @@ -8,7 +8,7 @@ import '../../filament_controller.dart'; import 'filament_view_platform.dart'; class FilamentView extends FilamentViewPlatform { - static const FILAMENT_VIEW_ID = 'mimetic.app/filament_view'; + static const FILAMENT_VIEW_ID = 'holovox.app/filament_view'; @override Widget buildView(