Keine Beschreibung

L3odr0id e5e8a3c5e4 Update README.md vor 2 Jahren
src 912236d154 Use std calc lib vor 2 Jahren
.gitignore 055fdd968e EXAMPLE: call p3d_process from CMD vor 2 Jahren
Cargo.lock f728acbb3f Adjust dependecies vor 2 Jahren
Cargo.toml 912236d154 Use std calc lib vor 2 Jahren
LICENSE ef6081bdbe Initial commit vor 2 Jahren
README.md e5e8a3c5e4 Update README.md vor 2 Jahren
cbindgen.toml 10622210d6 FEATURE: FFI vor 2 Jahren
makefile 10622210d6 FEATURE: FFI vor 2 Jahren

README.md

p3d

3D object shape recognition tools for WASM, which not only has the same functionality to pass3d, but also it's compatible to Substrate. Now, it's used as a part of 3Dpass network Node.

How to update library in threedpass

  • Make your changes.
  • Check the lib name is calc see the source, the exported functions have bindable types. Also make sure to annotate your exported functions with #[no_mangle] and pub extern so the function names can be matched from Dart. See working bindable function example.
  • Compile the library. There is a makefile copied from brickpop's example. So follow his instruction.
    • Make sure that the Android NDK is installed
    • You might also need LLVM from the SDK manager
    • Ensure that the env variable $ANDROID_NDK_HOME points to the NDK base folder
    • It may look like /Users/brickpop/Library/Android/sdk/ndk-bundle on MacOS
    • And look like /home/brickpop/dev/android/ndk-bundle on Linux
    • On the rust folder:
    • Run make to see the available actions
    • Run make init to install the Rust targets
    • Run make all to build the libraries and the .h file
    • Update the name of your library in Cargo.toml
    • You'll need to update the symlinks to target the new file names. See iOS and Android below. Generated artifacts:
    • Android libraries
    • target/aarch64-linux-android/release/libexample.so
    • target/armv7-linux-androideabi/release/libexample.so
    • target/i686-linux-android/release/libexample.so
    • target/x86_64-linux-android/release/libexample.so
    • iOS library
    • target/universal/release/libexample.a
    • Bindings header
    • target/bindings.h
  • Place artifacts to the threedpass project. Follow this structure in threedpass/packages/calc/android: src └── main └── jniLibs ├── arm64-v8a │ └── libexample.so -> p3d/target/aarch64-linux-android/release/libexample.so ├── armeabi-v7a │ └── libexample.so@ -> p3d/target/armv7-linux-androideabi/release/libexample.so ├── x86 │ └── libexample.so@ -> p3d/target/i686-linux-android/release/libexample.so └── x86_64 └── libexample.so@ -> p3d/target/x86_64-linux-android/release/libexample.so
  • Update the ios folder. Place p3d/target/aarch64-apple-ios/release/libcalc.a into threedpass/packages/calc/ios
  • If you have changed the interface, follow next steps also. Otherwise you can compile the app and check the functionality.
    • Copy p3d/target/bindings.h to threedpass/rust/target/bindings.h.
    • Generate bindings. Check the ffigen section in threedpass/packages/calc/pubspec.yaml. To use ffigen install llvm

On MacOS:

  brew install llvm

On Linux:

  sudo apt-get install -y clang libclang-dev

Write path to llvm for your system in pubspec.yaml.

  llvm-path:
    - /usr/local/opt/llvm/bin # For MacOS. Set path for your system

And generate lib/generated/bindings.dart:

  flutter pub run ffigen
  • Setup on iOS. Append the p3d/target/bindings.h to threedpass/packages/calc/ios/Classes/CalcPlugin.h. In ios/Classes/SwiftCalcPlugin.swift call your functions, so the compiler won't remove them.
  • Use bindings and write Dart code you need.


Thank you for contribution!