package name changes and fixes

This commit is contained in:
Nick Fisher
2021-12-06 17:19:52 +08:00
parent 61e3ed179c
commit 77a68a11de
20 changed files with 121 additions and 208 deletions

View File

@@ -1,11 +1,9 @@
import 'dart:math'; import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:async'; import 'package:polyvox_filament/filament_controller.dart';
import 'package:polyvox_filament/gesture_detecting_filament_view.dart';
import 'package:flutter/services.dart'; import 'package:polyvox_filament/view/filament_widget.dart';
import 'package:holovox_filament/filament_controller.dart';
import 'package:holovox_filament/view/filament_widget.dart';
void main() { void main() {
runApp(const MyApp()); runApp(const MyApp());
@@ -19,9 +17,8 @@ class MyApp extends StatefulWidget {
} }
class _MyAppState extends State<MyApp> { class _MyAppState extends State<MyApp> {
final FilamentController _filamentController = HolovoxFilamentController(); final FilamentController _filamentController = PolyvoxFilamentController();
bool _rotate = false;
int _primitiveIndex = 0; int _primitiveIndex = 0;
final weights = List.filled(255, 0.0); final weights = List.filled(255, 0.0);
List<String> _targets = []; List<String> _targets = [];
@@ -35,126 +32,108 @@ class _MyAppState extends State<MyApp> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
home: Scaffold( home: Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Plugin example app'), title: const Text('Plugin example app'),
), ),
body: GestureDetector( body: Stack(children: [
behavior: HitTestBehavior.opaque, GestureDetectingFilamentView(
onPanDown: (details) { controller: _filamentController,
_rotate ),
? _filamentController.rotateStart( Positioned.fill(
details.localPosition.dx, details.localPosition.dy) child: Wrap(
: _filamentController.panStart( alignment: WrapAlignment.end,
details.localPosition.dx, details.localPosition.dy); crossAxisAlignment: WrapCrossAlignment.end,
}, children: [
onPanUpdate: (details) { ElevatedButton(
_rotate child: const Text('load skybox'),
? _filamentController.rotateUpdate( onPressed: () async {
details.localPosition.dx, details.localPosition.dy) await _filamentController.loadSkybox(
: _filamentController.panUpdate( 'assets/default_env/default_env_skybox.ktx',
details.localPosition.dx, details.localPosition.dy); 'assets/default_env/default_env_ibl.ktx');
}, }),
onPanEnd: (d) { ElevatedButton(
_rotate child: const Text('load cube'),
? _filamentController.rotateEnd() onPressed: () async {
: _filamentController.panEnd(); await _filamentController.loadGltf(
}, 'assets/cube.gltf', 'assets');
child: Stack(children: [ await _filamentController.createMorpher('Cube', [0]);
FilamentWidget(controller: _filamentController), }),
Positioned.fill( ElevatedButton(
top: 200, child: const Text('stretch'),
child: SingleChildScrollView( onPressed: () async {
child: Column( await _filamentController
mainAxisSize: MainAxisSize.min, .applyWeights(List.filled(8, 1.0));
children: [ }),
SizedBox( ElevatedButton(
height: 100, child: const Text('squeeze'),
child: Row(children: [ onPressed: () async {
ElevatedButton( await _filamentController
child: Text("initialize"), .applyWeights(List.filled(8, 0));
onPressed: () async { }),
await _filamentController.loadSkybox( ElevatedButton(
"assets/default_env/default_env_skybox.ktx", child: const Text('load caleb'),
"assets/default_env/default_env_ibl.ktx"); onPressed: () async {
await _filamentController.loadGltf( await _filamentController.loadGltf(
"assets/caleb_mouth_morph_target.gltf", 'assets/caleb_mouth_morph_target.gltf', 'assets');
"assets"); _targets = await _filamentController
_targets = await _filamentController .getTargetNames('CC_Base_Body');
.getTargetNames("CC_Base_Body"); setState(() {});
setState(() {});
_filamentController.createMorpher( _filamentController
"CC_Base_Body", [1, 7, 8]); .createMorpher('CC_Base_Body', [1, 7, 8]);
}), }),
Checkbox( ElevatedButton(
value: _rotate, onPressed: () => _filamentController.playAnimation(0),
onChanged: (v) { child: const Text('Play'))
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(),
)
],
),
)),
])),
),
); );
} }
} }
// ElevatedButton( // ElevatedButton(
// child: Text("load skybox"), // child: Text('load skybox'),
// onPressed: () { // onPressed: () {
// _filamentController.loadSkybox( // _filamentController.loadSkybox(
// "assets/default_env/default_env_skybox.ktx", // 'assets/default_env/default_env_skybox.ktx',
// "assets/default_env/default_env_ibl.ktx"); // 'assets/default_env/default_env_ibl.ktx');
// }), // }),
// ElevatedButton( // ElevatedButton(
// child: Text("load gltf"), // child: Text('load gltf'),
// onPressed: () { // onPressed: () {
// _filamentController.loadGltf( // _filamentController.loadGltf(
// "assets/guy.gltf", "assets", "Material"); // 'assets/guy.gltf', 'assets', 'Material');
// }), // }),
// ElevatedButton( // ElevatedButton(
// child: Text("create morpher"), // child: Text('create morpher'),
// onPressed: () { // onPressed: () {
// _filamentController.createMorpher( // _filamentController.createMorpher(
// "CC_Base_Body.003", "CC_Base_Body.003", // 'CC_Base_Body.003', 'CC_Base_Body.003',
// materialName: "Material"); // 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(),
// )

View File

@@ -8,7 +8,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:holovox_filament_example/main.dart'; import 'package:polyvox_filament_example/main.dart';
void main() { void main() {
testWidgets('Verify Platform version', (WidgetTester tester) async { testWidgets('Verify Platform version', (WidgetTester tester) async {

View File

@@ -1,4 +0,0 @@
#import <Flutter/Flutter.h>
@interface HolovoxFilamentPlugin : NSObject<FlutterPlugin>
@end

View File

@@ -0,0 +1,4 @@
#import <Flutter/Flutter.h>
@interface PolyvoxFilamentPlugin : NSObject<FlutterPlugin>
@end

View File

@@ -1,9 +1,9 @@
#import "HolovoxFilamentPlugin.h" #import "PolyvoxFilamentPlugin.h"
#import "filament/FilamentNativeViewFactory.h" #import "FilamentNativeViewFactory.h"
FilamentNativeViewFactory* factory; FilamentNativeViewFactory* factory;
@implementation HolovoxFilamentPlugin @implementation PolyvoxFilamentPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar { + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
factory = factory =
[[FilamentNativeViewFactory alloc] initWithRegistrar:registrar]; [[FilamentNativeViewFactory alloc] initWithRegistrar:registrar];

View File

@@ -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 <jni.h>
#include <gltfio/MaterialProvider.h>
#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;
};

View File

@@ -1,9 +1,9 @@
# #
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. # 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| Pod::Spec.new do |s|
s.name = 'holovox_filament' s.name = 'polyvox_filament'
s.version = '0.0.1' s.version = '0.0.1'
s.summary = 'A new flutter plugin project.' s.summary = 'A new flutter plugin project.'
s.description = <<-DESC s.description = <<-DESC
@@ -13,8 +13,9 @@ A new flutter plugin project.
s.license = { :file => '../LICENSE' } s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' } s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' } s.source = { :path => '.' }
s.source_files = 'Classes/**/*', 'src/*.*', 'src/morph/*.*', 'src/morph/UbershaderLoader.cpp' s.source_files = 'Classes/**/*', 'src/*.*', 'src/morph/*.*', 'src/morph/UbershaderLoader.cpp' #, "include/**/*"
#s.dependency 'Filament', '~> 1.12.8' #s.header_dir = "include"
#s.header_mappings_dir = "include"
s.dependency 'Flutter' s.dependency 'Flutter'
s.platform = :ios, '12.1' s.platform = :ios, '12.1'
s.static_framework = true s.static_framework = true
@@ -24,21 +25,22 @@ A new flutter plugin project.
s.user_target_xcconfig = { s.user_target_xcconfig = {
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES', 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
'ALWAYS_SEARCH_USER_PATHS' => '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"', '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', 'OTHER_CXXFLAGS' => '"--std=c++17" "-fmodules" "-fcxx-modules" "$(inherited)"',
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17", "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++" #"CLANG_CXX_LIBRARY" => "libc++"
} }
s.pod_target_xcconfig = { s.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES', 'DEFINES_MODULE' => 'YES',
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386',
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17", "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', "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', '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' s.swift_version = '5.0'

View File

@@ -30,13 +30,13 @@ abstract class FilamentController {
Future zoom(double z); Future zoom(double z);
} }
class HolovoxFilamentController extends FilamentController { class PolyvoxFilamentController extends FilamentController {
late int _id; late int _id;
late MethodChannel _channel; late MethodChannel _channel;
final Function(int id)? onFilamentViewCreatedHandler; final Function(int id)? onFilamentViewCreatedHandler;
HolovoxFilamentController({this.onFilamentViewCreatedHandler}); PolyvoxFilamentController({this.onFilamentViewCreatedHandler});
@override @override
void onFilamentViewCreated(int id) async { void onFilamentViewCreated(int id) async {
@@ -55,8 +55,8 @@ class HolovoxFilamentController extends FilamentController {
@override @override
Future _initialize() async { Future _initialize() async {
await _channel.invokeMethod("initialize", [ await _channel.invokeMethod("initialize", [
"packages/holovox_filament/assets/lit_opaque.filamat", "packages/polyvox_filament/assets/lit_opaque.filamat",
"packages/holovox_filament/assets/lit_fade.filamat" "packages/polyvox_filament/assets/lit_fade.filamat"
]); ]);
} }

View File

@@ -1,5 +1,5 @@
import 'package:flutter/widgets.dart'; 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'; import 'package:plugin_platform_interface/plugin_platform_interface.dart';
typedef void FilamentViewCreatedCallback(int id); typedef void FilamentViewCreatedCallback(int id);

View File

@@ -1,5 +1,5 @@
name: holovox_filament name: polyvox_filament
description: The 3D rendering layer for the Holovox app. description: The 3D rendering layer for the Polyvox app.
version: 0.0.1 version: 0.0.1
homepage: homepage:
@@ -31,4 +31,4 @@ flutter:
#package: com.thepipecat.flutter.filament #package: com.thepipecat.flutter.filament
#pluginClass: FilamentPlugin #pluginClass: FilamentPlugin
ios: ios:
pluginClass: HolovoxFilamentPlugin pluginClass: PolyvoxFilamentPlugin

View File

@@ -2,7 +2,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
const MethodChannel channel = MethodChannel('holovox_filament'); const MethodChannel channel = MethodChannel('polyvox_filament');
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();