From 77a68a11de86527580774a300394299ec3193186 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Mon, 6 Dec 2021 17:19:52 +0800 Subject: [PATCH] package name changes and fixes --- example/lib/main.dart | 205 ++++++++---------- example/test/widget_test.dart | 2 +- .../FilamentMethodCallHandler.h | 0 .../FilamentMethodCallHandler.mm | 0 .../FilamentNativeViewFactory.h | 0 .../FilamentNativeViewFactory.mm | 0 ios/Classes/{filament => }/FilamentView.h | 0 ios/Classes/{filament => }/FilamentView.mm | 0 .../{filament => }/FilamentViewController.h | 0 .../{filament => }/FilamentViewController.mm | 0 ios/Classes/HolovoxFilamentPlugin.h | 4 - ios/Classes/PolyvoxFilamentPlugin.h | 4 + ...mentPlugin.mm => PolyvoxFilamentPlugin.mm} | 6 +- ios/{include => Classes}/cgltf.h | 0 ios/include/MaterialKey.h | 68 ------ ...ament.podspec => polyvox_filament.podspec} | 22 +- lib/filament_controller.dart | 8 +- lib/view/filament_view_platform.dart | 2 +- pubspec.yaml | 6 +- test/mimetic_filament_test.dart | 2 +- 20 files changed, 121 insertions(+), 208 deletions(-) rename ios/Classes/{filament => }/FilamentMethodCallHandler.h (100%) rename ios/Classes/{filament => }/FilamentMethodCallHandler.mm (100%) rename ios/Classes/{filament => }/FilamentNativeViewFactory.h (100%) rename ios/Classes/{filament => }/FilamentNativeViewFactory.mm (100%) rename ios/Classes/{filament => }/FilamentView.h (100%) rename ios/Classes/{filament => }/FilamentView.mm (100%) rename ios/Classes/{filament => }/FilamentViewController.h (100%) rename ios/Classes/{filament => }/FilamentViewController.mm (100%) delete mode 100644 ios/Classes/HolovoxFilamentPlugin.h create mode 100644 ios/Classes/PolyvoxFilamentPlugin.h rename ios/Classes/{HolovoxFilamentPlugin.mm => PolyvoxFilamentPlugin.mm} (70%) rename ios/{include => Classes}/cgltf.h (100%) delete mode 100644 ios/include/MaterialKey.h rename ios/{holovox_filament.podspec => polyvox_filament.podspec} (62%) diff --git a/example/lib/main.dart b/example/lib/main.dart index 21ca90ff..f70c5c86 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,11 +1,9 @@ import 'dart:math'; import 'package:flutter/material.dart'; -import 'dart:async'; - -import 'package:flutter/services.dart'; -import 'package:holovox_filament/filament_controller.dart'; -import 'package:holovox_filament/view/filament_widget.dart'; +import 'package:polyvox_filament/filament_controller.dart'; +import 'package:polyvox_filament/gesture_detecting_filament_view.dart'; +import 'package:polyvox_filament/view/filament_widget.dart'; void main() { runApp(const MyApp()); @@ -19,9 +17,8 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { - final FilamentController _filamentController = HolovoxFilamentController(); + final FilamentController _filamentController = PolyvoxFilamentController(); - bool _rotate = false; int _primitiveIndex = 0; final weights = List.filled(255, 0.0); List _targets = []; @@ -35,126 +32,108 @@ class _MyAppState extends State { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( - appBar: AppBar( - title: const Text('Plugin example app'), - ), - body: GestureDetector( - behavior: HitTestBehavior.opaque, - onPanDown: (details) { - _rotate - ? _filamentController.rotateStart( - details.localPosition.dx, details.localPosition.dy) - : _filamentController.panStart( - details.localPosition.dx, details.localPosition.dy); - }, - onPanUpdate: (details) { - _rotate - ? _filamentController.rotateUpdate( - details.localPosition.dx, details.localPosition.dy) - : _filamentController.panUpdate( - details.localPosition.dx, details.localPosition.dy); - }, - onPanEnd: (d) { - _rotate - ? _filamentController.rotateEnd() - : _filamentController.panEnd(); - }, - child: Stack(children: [ - FilamentWidget(controller: _filamentController), - Positioned.fill( - top: 200, - child: SingleChildScrollView( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - SizedBox( - height: 100, - child: Row(children: [ - ElevatedButton( - child: Text("initialize"), - onPressed: () async { - await _filamentController.loadSkybox( - "assets/default_env/default_env_skybox.ktx", - "assets/default_env/default_env_ibl.ktx"); - await _filamentController.loadGltf( - "assets/caleb_mouth_morph_target.gltf", - "assets"); - _targets = await _filamentController - .getTargetNames("CC_Base_Body"); - setState(() {}); + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: Stack(children: [ + GestureDetectingFilamentView( + controller: _filamentController, + ), + Positioned.fill( + child: Wrap( + alignment: WrapAlignment.end, + crossAxisAlignment: WrapCrossAlignment.end, + children: [ + ElevatedButton( + child: const Text('load skybox'), + onPressed: () async { + await _filamentController.loadSkybox( + 'assets/default_env/default_env_skybox.ktx', + 'assets/default_env/default_env_ibl.ktx'); + }), + ElevatedButton( + child: const Text('load cube'), + onPressed: () async { + await _filamentController.loadGltf( + 'assets/cube.gltf', 'assets'); + await _filamentController.createMorpher('Cube', [0]); + }), + ElevatedButton( + child: const Text('stretch'), + onPressed: () async { + await _filamentController + .applyWeights(List.filled(8, 1.0)); + }), + ElevatedButton( + child: const Text('squeeze'), + onPressed: () async { + await _filamentController + .applyWeights(List.filled(8, 0)); + }), + ElevatedButton( + child: const Text('load caleb'), + onPressed: () async { + await _filamentController.loadGltf( + 'assets/caleb_mouth_morph_target.gltf', 'assets'); + _targets = await _filamentController + .getTargetNames('CC_Base_Body'); + setState(() {}); - _filamentController.createMorpher( - "CC_Base_Body", [1, 7, 8]); - }), - Checkbox( - value: _rotate, - onChanged: (v) { - setState(() { - _rotate = v == true; - }); - }), - ElevatedButton( - onPressed: () => - _filamentController.zoom(30.0), - child: const Text("-")), - ElevatedButton( - onPressed: () => - _filamentController.zoom(-30.0), - child: const Text("+")), - ElevatedButton( - onPressed: () => - _filamentController.playAnimation(0), - child: const Text("Play")) - ])), - Column( - children: _targets - .asMap() - .map((i, t) => MapEntry( - i, - Row(children: [ - Text(t), - Slider( - min: 0, - max: 1, - divisions: 10, - value: weights[i], - onChanged: (v) { - setState(() { - weights[i] = v; - _filamentController - .applyWeights(weights); - }); - }) - ]))) - .values - .toList(), - ) - ], - ), - )), - ])), - ), + _filamentController + .createMorpher('CC_Base_Body', [1, 7, 8]); + }), + ElevatedButton( + onPressed: () => _filamentController.playAnimation(0), + child: const Text('Play')) + ], + ), + ), + ])), ); } } // ElevatedButton( -// child: Text("load skybox"), +// child: Text('load skybox'), // onPressed: () { // _filamentController.loadSkybox( -// "assets/default_env/default_env_skybox.ktx", -// "assets/default_env/default_env_ibl.ktx"); +// 'assets/default_env/default_env_skybox.ktx', +// 'assets/default_env/default_env_ibl.ktx'); // }), // ElevatedButton( -// child: Text("load gltf"), +// child: Text('load gltf'), // onPressed: () { // _filamentController.loadGltf( -// "assets/guy.gltf", "assets", "Material"); +// 'assets/guy.gltf', 'assets', 'Material'); // }), // ElevatedButton( -// child: Text("create morpher"), +// child: Text('create morpher'), // onPressed: () { // _filamentController.createMorpher( -// "CC_Base_Body.003", "CC_Base_Body.003", -// materialName: "Material"); +// 'CC_Base_Body.003', 'CC_Base_Body.003', +// materialName: 'Material'); // }), +// ])), +// Column( +// children: _targets +// .asMap() +// .map((i, t) => MapEntry( +// i, +// Row(children: [ +// Text(t), +// Slider( +// min: 0, +// max: 1, +// divisions: 10, +// value: weights[i], +// onChanged: (v) { +// setState(() { +// weights[i] = v; +// _filamentController +// .applyWeights(weights); +// }); +// }) +// ]))) +// .values +// .toList(), +// ) diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 3656091a..a8710c4c 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:holovox_filament_example/main.dart'; +import 'package:polyvox_filament_example/main.dart'; void main() { testWidgets('Verify Platform version', (WidgetTester tester) async { diff --git a/ios/Classes/filament/FilamentMethodCallHandler.h b/ios/Classes/FilamentMethodCallHandler.h similarity index 100% rename from ios/Classes/filament/FilamentMethodCallHandler.h rename to ios/Classes/FilamentMethodCallHandler.h diff --git a/ios/Classes/filament/FilamentMethodCallHandler.mm b/ios/Classes/FilamentMethodCallHandler.mm similarity index 100% rename from ios/Classes/filament/FilamentMethodCallHandler.mm rename to ios/Classes/FilamentMethodCallHandler.mm diff --git a/ios/Classes/filament/FilamentNativeViewFactory.h b/ios/Classes/FilamentNativeViewFactory.h similarity index 100% rename from ios/Classes/filament/FilamentNativeViewFactory.h rename to ios/Classes/FilamentNativeViewFactory.h diff --git a/ios/Classes/filament/FilamentNativeViewFactory.mm b/ios/Classes/FilamentNativeViewFactory.mm similarity index 100% rename from ios/Classes/filament/FilamentNativeViewFactory.mm rename to ios/Classes/FilamentNativeViewFactory.mm diff --git a/ios/Classes/filament/FilamentView.h b/ios/Classes/FilamentView.h similarity index 100% rename from ios/Classes/filament/FilamentView.h rename to ios/Classes/FilamentView.h diff --git a/ios/Classes/filament/FilamentView.mm b/ios/Classes/FilamentView.mm similarity index 100% rename from ios/Classes/filament/FilamentView.mm rename to ios/Classes/FilamentView.mm diff --git a/ios/Classes/filament/FilamentViewController.h b/ios/Classes/FilamentViewController.h similarity index 100% rename from ios/Classes/filament/FilamentViewController.h rename to ios/Classes/FilamentViewController.h diff --git a/ios/Classes/filament/FilamentViewController.mm b/ios/Classes/FilamentViewController.mm similarity index 100% rename from ios/Classes/filament/FilamentViewController.mm rename to ios/Classes/FilamentViewController.mm diff --git a/ios/Classes/HolovoxFilamentPlugin.h b/ios/Classes/HolovoxFilamentPlugin.h deleted file mode 100644 index 357a20af..00000000 --- a/ios/Classes/HolovoxFilamentPlugin.h +++ /dev/null @@ -1,4 +0,0 @@ -#import - -@interface HolovoxFilamentPlugin : NSObject -@end diff --git a/ios/Classes/PolyvoxFilamentPlugin.h b/ios/Classes/PolyvoxFilamentPlugin.h new file mode 100644 index 00000000..e5b6cbbc --- /dev/null +++ b/ios/Classes/PolyvoxFilamentPlugin.h @@ -0,0 +1,4 @@ +#import + +@interface PolyvoxFilamentPlugin : NSObject +@end diff --git a/ios/Classes/HolovoxFilamentPlugin.mm b/ios/Classes/PolyvoxFilamentPlugin.mm similarity index 70% rename from ios/Classes/HolovoxFilamentPlugin.mm rename to ios/Classes/PolyvoxFilamentPlugin.mm index bc16cfbf..c9d256d1 100644 --- a/ios/Classes/HolovoxFilamentPlugin.mm +++ b/ios/Classes/PolyvoxFilamentPlugin.mm @@ -1,9 +1,9 @@ -#import "HolovoxFilamentPlugin.h" -#import "filament/FilamentNativeViewFactory.h" +#import "PolyvoxFilamentPlugin.h" +#import "FilamentNativeViewFactory.h" FilamentNativeViewFactory* factory; -@implementation HolovoxFilamentPlugin +@implementation PolyvoxFilamentPlugin + (void)registerWithRegistrar:(NSObject*)registrar { factory = [[FilamentNativeViewFactory alloc] initWithRegistrar:registrar]; diff --git a/ios/include/cgltf.h b/ios/Classes/cgltf.h similarity index 100% rename from ios/include/cgltf.h rename to ios/Classes/cgltf.h diff --git a/ios/include/MaterialKey.h b/ios/include/MaterialKey.h deleted file mode 100644 index 10406c9d..00000000 --- a/ios/include/MaterialKey.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include - -#define JAVA_MATERIAL_KEY "com/google/android/filament/gltfio/MaterialProvider$MaterialKey" - -class MaterialKeyHelper { -public: - static MaterialKeyHelper& get(); - - void copy(JNIEnv* env, gltfio::MaterialKey& dst, jobject src); - void copy(JNIEnv* env, jobject dst, const gltfio::MaterialKey& src); - - void init(JNIEnv* env); // called only from the Java static class constructor - -private: - jfieldID doubleSided; - jfieldID unlit; - jfieldID hasVertexColors; - jfieldID hasBaseColorTexture; - jfieldID hasNormalTexture; - jfieldID hasOcclusionTexture; - jfieldID hasEmissiveTexture; - jfieldID useSpecularGlossiness; - jfieldID alphaMode; - jfieldID enableDiagnostics; - jfieldID hasMetallicRoughnessTexture; - jfieldID metallicRoughnessUV; - jfieldID baseColorUV; - jfieldID hasClearCoatTexture; - jfieldID clearCoatUV; - jfieldID hasClearCoatRoughnessTexture; - jfieldID clearCoatRoughnessUV; - jfieldID hasClearCoatNormalTexture; - jfieldID clearCoatNormalUV; - jfieldID hasClearCoat; - jfieldID hasTransmission; - jfieldID hasTextureTransforms; - jfieldID emissiveUV; - jfieldID aoUV; - jfieldID normalUV; - jfieldID hasTransmissionTexture; - jfieldID transmissionUV; - jfieldID hasSheenColorTexture; - jfieldID sheenColorUV; - jfieldID hasSheenRoughnessTexture; - jfieldID sheenRoughnessUV; - jfieldID hasVolumeThicknessTexture; - jfieldID volumeThicknessUV; - jfieldID hasSheen; - jfieldID hasIOR; -}; diff --git a/ios/holovox_filament.podspec b/ios/polyvox_filament.podspec similarity index 62% rename from ios/holovox_filament.podspec rename to ios/polyvox_filament.podspec index 3ea668ff..52f09b87 100644 --- a/ios/holovox_filament.podspec +++ b/ios/polyvox_filament.podspec @@ -1,9 +1,9 @@ # # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint holovox_filament.podspec` to validate before publishing. +# Run `pod lib lint polyvox_filament.podspec` to validate before publishing. # Pod::Spec.new do |s| - s.name = 'holovox_filament' + s.name = 'polyvox_filament' s.version = '0.0.1' s.summary = 'A new flutter plugin project.' s.description = <<-DESC @@ -13,8 +13,9 @@ A new flutter plugin project. s.license = { :file => '../LICENSE' } s.author = { 'Your Company' => 'email@example.com' } s.source = { :path => '.' } - s.source_files = 'Classes/**/*', 'src/*.*', 'src/morph/*.*', 'src/morph/UbershaderLoader.cpp' - #s.dependency 'Filament', '~> 1.12.8' + s.source_files = 'Classes/**/*', 'src/*.*', 'src/morph/*.*', 'src/morph/UbershaderLoader.cpp' #, "include/**/*" + #s.header_dir = "include" + #s.header_mappings_dir = "include" s.dependency 'Flutter' s.platform = :ios, '12.1' s.static_framework = true @@ -24,21 +25,22 @@ A new flutter plugin project. s.user_target_xcconfig = { 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES', 'ALWAYS_SEARCH_USER_PATHS' => 'YES', - 'USER_HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/holovox_filament/ios/include" "${PODS_ROOT}/../.symlinks/plugins/holovox_filament/ios/src", "${PODS_ROOT}/../.symlinks/plugins/holovox_filament/ios/morph"', - 'OTHER_CXXFLAGS' => '--std=c++17 -fmodules -fcxx-modules', + 'USER_HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/include" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src", "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/morph" "$(inherited)"', + 'OTHER_CXXFLAGS' => '"--std=c++17" "-fmodules" "-fcxx-modules" "$(inherited)"', "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", - 'LIBRARY_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/holovox_filament/ios/lib"', + #'LIBRARY_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/lib" "$(inherited)"', #"CLANG_CXX_LIBRARY" => "libc++" } s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386', "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", - 'OTHER_CXXFLAGS' => '--std=c++17 -fmodules -fcxx-modules', + #'OTHER_CXXFLAGS' => '--std=c++17 -fmodules -fcxx-modules -x c++', + 'OTHER_CXXFLAGS' => '"--std=c++17" "-fmodules" "-fcxx-modules" "$(inherited)"', "OTHER_LDFLAGS" => '-lfilament -lbackend -lmathio -lfilameshio -lviewer -lfilamat -lgeometry -lutils -lfilabridge -lgltfio_resources_lite -lgltfio_core -lfilament-iblprefilter -limage -lcamutils -lgltfio_resources -lmath -lfilaflat -ldracodec -libl', - 'USER_HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/holovox_filament/ios/include" "${PODS_ROOT}/../.symlinks/plugins/holovox_filament/ios/src", "${PODS_ROOT}/../.symlinks/plugins/holovox_filament/ios/morph"', + 'USER_HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/include" "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/src", "${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/morph" "$(inherited)"', 'ALWAYS_SEARCH_USER_PATHS' => 'YES', - 'LIBRARY_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/holovox_filament/ios/lib"', + 'LIBRARY_SEARCH_PATHS' => '"${PODS_ROOT}/../.symlinks/plugins/polyvox_filament/ios/lib" "$(inherited)"', } s.swift_version = '5.0' diff --git a/lib/filament_controller.dart b/lib/filament_controller.dart index d287917a..89b43a47 100644 --- a/lib/filament_controller.dart +++ b/lib/filament_controller.dart @@ -30,13 +30,13 @@ abstract class FilamentController { Future zoom(double z); } -class HolovoxFilamentController extends FilamentController { +class PolyvoxFilamentController extends FilamentController { late int _id; late MethodChannel _channel; final Function(int id)? onFilamentViewCreatedHandler; - HolovoxFilamentController({this.onFilamentViewCreatedHandler}); + PolyvoxFilamentController({this.onFilamentViewCreatedHandler}); @override void onFilamentViewCreated(int id) async { @@ -55,8 +55,8 @@ class HolovoxFilamentController extends FilamentController { @override Future _initialize() async { await _channel.invokeMethod("initialize", [ - "packages/holovox_filament/assets/lit_opaque.filamat", - "packages/holovox_filament/assets/lit_fade.filamat" + "packages/polyvox_filament/assets/lit_opaque.filamat", + "packages/polyvox_filament/assets/lit_fade.filamat" ]); } diff --git a/lib/view/filament_view_platform.dart b/lib/view/filament_view_platform.dart index e775fb67..cc2e2ceb 100644 --- a/lib/view/filament_view_platform.dart +++ b/lib/view/filament_view_platform.dart @@ -1,5 +1,5 @@ import 'package:flutter/widgets.dart'; -import 'package:holovox_filament/view/filament_view.dart'; +import 'package:polyvox_filament/view/filament_view.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; typedef void FilamentViewCreatedCallback(int id); diff --git a/pubspec.yaml b/pubspec.yaml index cd274374..9efd606b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ -name: holovox_filament -description: The 3D rendering layer for the Holovox app. +name: polyvox_filament +description: The 3D rendering layer for the Polyvox app. version: 0.0.1 homepage: @@ -31,4 +31,4 @@ flutter: #package: com.thepipecat.flutter.filament #pluginClass: FilamentPlugin ios: - pluginClass: HolovoxFilamentPlugin \ No newline at end of file + pluginClass: PolyvoxFilamentPlugin \ No newline at end of file diff --git a/test/mimetic_filament_test.dart b/test/mimetic_filament_test.dart index b77f8916..20fc1dcc 100644 --- a/test/mimetic_filament_test.dart +++ b/test/mimetic_filament_test.dart @@ -2,7 +2,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - const MethodChannel channel = MethodChannel('holovox_filament'); + const MethodChannel channel = MethodChannel('polyvox_filament'); TestWidgetsFlutterBinding.ensureInitialized();