merge
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -68,4 +68,5 @@ linux/lib/libtinyexr.a filter=lfs diff=lfs merge=lfs -text
|
||||
linux/lib/libz.a filter=lfs diff=lfs merge=lfs -text
|
||||
linux/lib/libmatdbg.a filter=lfs diff=lfs merge=lfs -text
|
||||
linux/lib/libSPIRV-Tools-opt.a filter=lfs diff=lfs merge=lfs -text
|
||||
windows/lib/** filter=lfs diff=lfs merge=lfs -text
|
||||
*.a filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
@@ -345,6 +345,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
OTHER_CFLAGS = "-fvisibility=default";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = app.polyvox.example;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -476,6 +477,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
OTHER_CFLAGS = "-fvisibility=default";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = app.polyvox.example;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -499,6 +501,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
OTHER_CFLAGS = "-fvisibility=default";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = app.polyvox.example;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
|
||||
@@ -119,11 +119,6 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
||||
kCVPixelFormatType_32BGRA, pixelBufferAttrs, &targetPixelBuffer) != kCVReturnSuccess) {
|
||||
print("Error allocating pixel buffer")
|
||||
}
|
||||
if(self.viewer != nil) {
|
||||
create_swap_chain(self.viewer, unsafeBitCast(targetPixelBuffer!, to: UnsafeMutableRawPointer.self))
|
||||
update_viewport_and_camera_projection(self.viewer!, Int32(width), Int32(height), 1.0);
|
||||
}
|
||||
|
||||
print("Pixel buffer created")
|
||||
}
|
||||
|
||||
@@ -136,12 +131,17 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
||||
freeResourcePtr = unsafeBitCast(freeResource, to: UnsafeMutableRawPointer.self)
|
||||
|
||||
viewer = filament_viewer_new_ios(
|
||||
unsafeBitCast(targetPixelBuffer!, to: UnsafeMutableRawPointer.self),
|
||||
nil,
|
||||
loadResourcePtr!,
|
||||
freeResourcePtr!,
|
||||
Unmanaged.passUnretained(self).toOpaque()
|
||||
)
|
||||
|
||||
create_swap_chain(
|
||||
self.viewer,
|
||||
unsafeBitCast(targetPixelBuffer!, to: UnsafeMutableRawPointer.self),
|
||||
UInt32(width), UInt32(height))
|
||||
|
||||
update_viewport_and_camera_projection(self.viewer!, Int32(width), Int32(height), 1.0);
|
||||
|
||||
createDisplayLink()
|
||||
@@ -285,6 +285,10 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
||||
let width = Int(args[0])
|
||||
let height = Int(args[1])
|
||||
createPixelBuffer(width: width, height:height)
|
||||
create_swap_chain(
|
||||
self.viewer,
|
||||
unsafeBitCast(targetPixelBuffer!, to: UnsafeMutableRawPointer.self),
|
||||
UInt32(width), UInt32(height))
|
||||
result("OK")
|
||||
case "rotateStart":
|
||||
let args = call.arguments as! Array<Any>
|
||||
|
||||
@@ -22,7 +22,7 @@ void* load_glb(void* viewer, const char* assetPath);
|
||||
void* load_gltf(void* viewer, const char* assetPath, const char* relativePath);
|
||||
bool set_camera(void* viewer, void* asset, const char* nodeName);
|
||||
void render(void* viewer, uint64_t frameTimeInNanos);
|
||||
void create_swap_chain(void* viewer, void* surface = nullptr, uint32_t width = 0, uint32_t height = 0);
|
||||
void create_swap_chain(void* viewer, void* surface, uint32_t width, uint32_t height);
|
||||
void destroy_swap_chain(void* viewer);
|
||||
void set_frame_interval(void* viewer, float interval);
|
||||
void* get_renderer(void* viewer);
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
void* filament_viewer_new_ios(void* texture, void* loadResource, void* freeResource, void* resources);
|
||||
void create_swap_chain(void* viewer, void* texture);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef SwiftPolyvoxFilamentPlugin_Bridging_Header_h
|
||||
#define SwiftPolyvoxFilamentPlugin_Bridging_Header_h
|
||||
|
||||
void* filament_viewer_new_ios(void* texture, void* loadResource, void* freeResource, void* resources);
|
||||
// void* filament_viewer_new_ios(void* texture, void* loadResource, void* freeResource, void* resources);
|
||||
|
||||
#import "PolyvoxFilamentIOSApi.h"
|
||||
#import "PolyvoxFilamentApi.h"
|
||||
|
||||
@@ -26,7 +26,4 @@ extern "C" {
|
||||
|
||||
return (void*)viewer;
|
||||
}
|
||||
void create_swap_chain(void* viewer, void* texture) {
|
||||
((FilamentViewer*)viewer)->createSwapChain(texture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,65 +83,61 @@ class _FilamentGestureDetectorState extends State<FilamentGestureDetector> {
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(children: [
|
||||
Positioned.fill(
|
||||
child: Listener(
|
||||
onPointerSignal: (pointerSignal) async {
|
||||
if (pointerSignal is PointerScrollEvent) {
|
||||
_scrollTimer?.cancel();
|
||||
// pinch zoom on mobile
|
||||
// couldn't find any equivalent for pointerCount in Listener so we use two widgets:
|
||||
// - outer is a GestureDetector only for pinch zoom
|
||||
// - inner is a Listener for all other gestures
|
||||
child: GestureDetector(
|
||||
onScaleStart: (d) async {
|
||||
if (d.pointerCount == 2) {
|
||||
await widget.controller.zoomEnd();
|
||||
await widget.controller.zoomBegin();
|
||||
await widget.controller.zoomUpdate(
|
||||
pointerSignal.scrollDelta.dy > 0 ? 100 : -100);
|
||||
_scrollTimer = Timer(Duration(milliseconds: 100), () {
|
||||
widget.controller.zoomEnd();
|
||||
_scrollTimer = null;
|
||||
});
|
||||
} else {
|
||||
print(pointerSignal);
|
||||
}
|
||||
},
|
||||
onPointerPanZoomStart: (pzs) {
|
||||
print(pzs);
|
||||
onScaleEnd: (d) async {
|
||||
if (d.pointerCount == 2) {
|
||||
_lastScale = 0;
|
||||
await widget.controller.zoomEnd();
|
||||
}
|
||||
},
|
||||
onPointerDown: (d) async {
|
||||
await _functionStart(d.localPosition.dx, d.localPosition.dy);
|
||||
onScaleUpdate: (d) async {
|
||||
if (d.pointerCount == 2) {
|
||||
if (_lastScale != 0) {
|
||||
await widget.controller
|
||||
.zoomUpdate(100 * (_lastScale - d.scale));
|
||||
}
|
||||
}
|
||||
_lastScale = d.scale;
|
||||
},
|
||||
onPointerMove: (d) async {
|
||||
await _functionUpdate(d.localPosition.dx, d.localPosition.dy);
|
||||
},
|
||||
onPointerUp: (d) async {
|
||||
await _functionEnd();
|
||||
},
|
||||
// on
|
||||
// onScaleStart: (d) async {
|
||||
// print("SCALE START");
|
||||
// if (d.pointerCount == 2) {
|
||||
// await widget.controller.zoomEnd();
|
||||
// await widget.controller.zoomBegin();
|
||||
// } else {
|
||||
// await _functionStart(d.focalPoint.dx, d.focalPoint.dy);
|
||||
// }
|
||||
// },
|
||||
// onScaleEnd: (d) async {
|
||||
// print("SCALE END");
|
||||
|
||||
// if (d.pointerCount == 2) {
|
||||
// _lastScale = 0;
|
||||
// await widget.controller.zoomEnd();
|
||||
// } else {
|
||||
// await _functionEnd();
|
||||
// }
|
||||
// },
|
||||
// onScaleUpdate: (d) async {
|
||||
// if (d.pointerCount == 2) {
|
||||
// if (_lastScale != 0) {
|
||||
// await widget.controller
|
||||
// .zoomUpdate(100 * (_lastScale - d.scale));
|
||||
// }
|
||||
// } else {
|
||||
// await _functionUpdate(d.focalPoint.dx, d.focalPoint.dy);
|
||||
// }
|
||||
// _lastScale = d.scale;
|
||||
// },
|
||||
child: widget.child)),
|
||||
child: Listener(
|
||||
onPointerSignal: (pointerSignal) async {
|
||||
// scroll-wheel zoom on desktop
|
||||
if (pointerSignal is PointerScrollEvent) {
|
||||
_scrollTimer?.cancel();
|
||||
await widget.controller.zoomBegin();
|
||||
await widget.controller.zoomUpdate(
|
||||
pointerSignal.scrollDelta.dy > 0 ? 100 : -100);
|
||||
_scrollTimer = Timer(Duration(milliseconds: 100), () {
|
||||
widget.controller.zoomEnd();
|
||||
_scrollTimer = null;
|
||||
});
|
||||
} else {
|
||||
print(pointerSignal);
|
||||
}
|
||||
},
|
||||
onPointerPanZoomStart: (pzs) {},
|
||||
onPointerDown: (d) async {
|
||||
await _functionStart(
|
||||
d.localPosition.dx, d.localPosition.dy);
|
||||
},
|
||||
onPointerMove: (d) async {
|
||||
await _functionUpdate(
|
||||
d.localPosition.dx, d.localPosition.dy);
|
||||
},
|
||||
onPointerUp: (d) async {
|
||||
await _functionEnd();
|
||||
},
|
||||
child: widget.child))),
|
||||
widget.showControls
|
||||
? Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
|
||||
Reference in New Issue
Block a user