diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 index ecbacf50..dc2d6f8e 100644 --- a/entry/build-profile.json5 +++ b/entry/build-profile.json5 @@ -8,7 +8,7 @@ }, "externalNativeOptions": { "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "-DCMAKE_BUILD_TYPE=Release -DOHOS_STL=c++_shared ", + "arguments": "-DCMAKE_BUILD_TYPE=Release", "cppFlags": "", "abiFilters": [ "x86_64" @@ -17,7 +17,7 @@ "arkOptions": { "runtimeOnly" : { "packages": [ - "libnativeocct.so" + "libopencax.so" ] } } diff --git a/entry/libs/x86_64/libTKBO.so.7.9 b/entry/libs/x86_64/libTKBO.so.7.9 new file mode 100644 index 00000000..a5693c68 Binary files /dev/null and b/entry/libs/x86_64/libTKBO.so.7.9 differ diff --git a/entry/libs/x86_64/libTKBRep.so.7.9 b/entry/libs/x86_64/libTKBRep.so.7.9 new file mode 100644 index 00000000..c98ddc22 Binary files /dev/null and b/entry/libs/x86_64/libTKBRep.so.7.9 differ diff --git a/entry/libs/x86_64/libTKBin.so.7.9 b/entry/libs/x86_64/libTKBin.so.7.9 new file mode 100644 index 00000000..0b16e150 Binary files /dev/null and b/entry/libs/x86_64/libTKBin.so.7.9 differ diff --git a/entry/libs/x86_64/libTKBinL.so.7.9 b/entry/libs/x86_64/libTKBinL.so.7.9 new file mode 100644 index 00000000..161b676d Binary files /dev/null and b/entry/libs/x86_64/libTKBinL.so.7.9 differ diff --git a/entry/libs/x86_64/libTKBinTObj.so.7.9 b/entry/libs/x86_64/libTKBinTObj.so.7.9 new file mode 100644 index 00000000..1b198d71 Binary files /dev/null and b/entry/libs/x86_64/libTKBinTObj.so.7.9 differ diff --git a/entry/libs/x86_64/libTKBinXCAF.so.7.9 b/entry/libs/x86_64/libTKBinXCAF.so.7.9 new file mode 100644 index 00000000..b2446939 Binary files /dev/null and b/entry/libs/x86_64/libTKBinXCAF.so.7.9 differ diff --git a/entry/libs/x86_64/libTKBool.so.7.9 b/entry/libs/x86_64/libTKBool.so.7.9 new file mode 100644 index 00000000..c620c0e4 Binary files /dev/null and b/entry/libs/x86_64/libTKBool.so.7.9 differ diff --git a/entry/libs/x86_64/libTKCAF.so.7.9 b/entry/libs/x86_64/libTKCAF.so.7.9 new file mode 100644 index 00000000..4149045a Binary files /dev/null and b/entry/libs/x86_64/libTKCAF.so.7.9 differ diff --git a/entry/libs/x86_64/libTKCDF.so.7.9 b/entry/libs/x86_64/libTKCDF.so.7.9 new file mode 100644 index 00000000..cc433e1d Binary files /dev/null and b/entry/libs/x86_64/libTKCDF.so.7.9 differ diff --git a/entry/libs/x86_64/libTKDE.so.7.9 b/entry/libs/x86_64/libTKDE.so.7.9 new file mode 100644 index 00000000..0558ed88 Binary files /dev/null and b/entry/libs/x86_64/libTKDE.so.7.9 differ diff --git a/entry/libs/x86_64/libTKDECascade.so.7.9 b/entry/libs/x86_64/libTKDECascade.so.7.9 new file mode 100644 index 00000000..89811331 Binary files /dev/null and b/entry/libs/x86_64/libTKDECascade.so.7.9 differ diff --git a/entry/libs/x86_64/libTKDEGLTF.so.7.9 b/entry/libs/x86_64/libTKDEGLTF.so.7.9 new file mode 100644 index 00000000..b9f77727 Binary files /dev/null and b/entry/libs/x86_64/libTKDEGLTF.so.7.9 differ diff --git a/entry/libs/x86_64/libTKDEIGES.so.7.9 b/entry/libs/x86_64/libTKDEIGES.so.7.9 new file mode 100644 index 00000000..fd0b3636 Binary files /dev/null and b/entry/libs/x86_64/libTKDEIGES.so.7.9 differ diff --git a/entry/libs/x86_64/libTKDEOBJ.so.7.9 b/entry/libs/x86_64/libTKDEOBJ.so.7.9 new file mode 100644 index 00000000..8cccb9e2 Binary files /dev/null and b/entry/libs/x86_64/libTKDEOBJ.so.7.9 differ diff --git a/entry/libs/x86_64/libTKDEPLY.so.7.9 b/entry/libs/x86_64/libTKDEPLY.so.7.9 new file mode 100644 index 00000000..b65e667c Binary files /dev/null and b/entry/libs/x86_64/libTKDEPLY.so.7.9 differ diff --git a/entry/libs/x86_64/libTKDESTEP.so.7.9 b/entry/libs/x86_64/libTKDESTEP.so.7.9 new file mode 100644 index 00000000..e49e3ac6 Binary files /dev/null and b/entry/libs/x86_64/libTKDESTEP.so.7.9 differ diff --git a/entry/libs/x86_64/libTKDESTL.so.7.9 b/entry/libs/x86_64/libTKDESTL.so.7.9 new file mode 100644 index 00000000..255b53e5 Binary files /dev/null and b/entry/libs/x86_64/libTKDESTL.so.7.9 differ diff --git a/entry/libs/x86_64/libTKDEVRML.so.7.9 b/entry/libs/x86_64/libTKDEVRML.so.7.9 new file mode 100644 index 00000000..12539208 Binary files /dev/null and b/entry/libs/x86_64/libTKDEVRML.so.7.9 differ diff --git a/entry/libs/x86_64/libTKFeat.so.7.9 b/entry/libs/x86_64/libTKFeat.so.7.9 new file mode 100644 index 00000000..3cdc4196 Binary files /dev/null and b/entry/libs/x86_64/libTKFeat.so.7.9 differ diff --git a/entry/libs/x86_64/libTKFillet.so.7.9 b/entry/libs/x86_64/libTKFillet.so.7.9 new file mode 100644 index 00000000..55317bfc Binary files /dev/null and b/entry/libs/x86_64/libTKFillet.so.7.9 differ diff --git a/entry/libs/x86_64/libTKG2d.so.7.9 b/entry/libs/x86_64/libTKG2d.so.7.9 new file mode 100644 index 00000000..a3cce573 Binary files /dev/null and b/entry/libs/x86_64/libTKG2d.so.7.9 differ diff --git a/entry/libs/x86_64/libTKG3d.so.7.9 b/entry/libs/x86_64/libTKG3d.so.7.9 new file mode 100644 index 00000000..c52c533e Binary files /dev/null and b/entry/libs/x86_64/libTKG3d.so.7.9 differ diff --git a/entry/libs/x86_64/libTKGeomAlgo.so.7.9 b/entry/libs/x86_64/libTKGeomAlgo.so.7.9 new file mode 100644 index 00000000..130293bd Binary files /dev/null and b/entry/libs/x86_64/libTKGeomAlgo.so.7.9 differ diff --git a/entry/libs/x86_64/libTKGeomBase.so.7.9 b/entry/libs/x86_64/libTKGeomBase.so.7.9 new file mode 100644 index 00000000..37260bfa Binary files /dev/null and b/entry/libs/x86_64/libTKGeomBase.so.7.9 differ diff --git a/entry/libs/x86_64/libTKHLR.so.7.9 b/entry/libs/x86_64/libTKHLR.so.7.9 new file mode 100644 index 00000000..b25c357a Binary files /dev/null and b/entry/libs/x86_64/libTKHLR.so.7.9 differ diff --git a/entry/libs/x86_64/libTKLCAF.so.7.9 b/entry/libs/x86_64/libTKLCAF.so.7.9 new file mode 100644 index 00000000..440bf9d1 Binary files /dev/null and b/entry/libs/x86_64/libTKLCAF.so.7.9 differ diff --git a/entry/libs/x86_64/libTKMath.so.7.9 b/entry/libs/x86_64/libTKMath.so.7.9 new file mode 100644 index 00000000..5b94b28d Binary files /dev/null and b/entry/libs/x86_64/libTKMath.so.7.9 differ diff --git a/entry/libs/x86_64/libTKMesh.so.7.9 b/entry/libs/x86_64/libTKMesh.so.7.9 new file mode 100644 index 00000000..cea5129b Binary files /dev/null and b/entry/libs/x86_64/libTKMesh.so.7.9 differ diff --git a/entry/libs/x86_64/libTKMeshVS.so.7.9 b/entry/libs/x86_64/libTKMeshVS.so.7.9 new file mode 100644 index 00000000..97cc4a93 Binary files /dev/null and b/entry/libs/x86_64/libTKMeshVS.so.7.9 differ diff --git a/entry/libs/x86_64/libTKOffset.so.7.9 b/entry/libs/x86_64/libTKOffset.so.7.9 new file mode 100644 index 00000000..ddf08b0d Binary files /dev/null and b/entry/libs/x86_64/libTKOffset.so.7.9 differ diff --git a/entry/libs/x86_64/libTKOpenGles.so.7.9 b/entry/libs/x86_64/libTKOpenGles.so.7.9 new file mode 100644 index 00000000..e67563a9 Binary files /dev/null and b/entry/libs/x86_64/libTKOpenGles.so.7.9 differ diff --git a/entry/libs/x86_64/libTKPrim.so.7.9 b/entry/libs/x86_64/libTKPrim.so.7.9 new file mode 100644 index 00000000..8fd97f4d Binary files /dev/null and b/entry/libs/x86_64/libTKPrim.so.7.9 differ diff --git a/entry/libs/x86_64/libTKRWMesh.so.7.9 b/entry/libs/x86_64/libTKRWMesh.so.7.9 new file mode 100644 index 00000000..9dee1b75 Binary files /dev/null and b/entry/libs/x86_64/libTKRWMesh.so.7.9 differ diff --git a/entry/libs/x86_64/libTKService.so.7.9 b/entry/libs/x86_64/libTKService.so.7.9 new file mode 100644 index 00000000..16f2b3d0 Binary files /dev/null and b/entry/libs/x86_64/libTKService.so.7.9 differ diff --git a/entry/libs/x86_64/libTKShHealing.so.7.9 b/entry/libs/x86_64/libTKShHealing.so.7.9 new file mode 100644 index 00000000..63180e86 Binary files /dev/null and b/entry/libs/x86_64/libTKShHealing.so.7.9 differ diff --git a/entry/libs/x86_64/libTKStd.so.7.9 b/entry/libs/x86_64/libTKStd.so.7.9 new file mode 100644 index 00000000..f2aab953 Binary files /dev/null and b/entry/libs/x86_64/libTKStd.so.7.9 differ diff --git a/entry/libs/x86_64/libTKStdL.so.7.9 b/entry/libs/x86_64/libTKStdL.so.7.9 new file mode 100644 index 00000000..ece2be82 Binary files /dev/null and b/entry/libs/x86_64/libTKStdL.so.7.9 differ diff --git a/entry/libs/x86_64/libTKTObj.so.7.9 b/entry/libs/x86_64/libTKTObj.so.7.9 new file mode 100644 index 00000000..1194029f Binary files /dev/null and b/entry/libs/x86_64/libTKTObj.so.7.9 differ diff --git a/entry/libs/x86_64/libTKTopAlgo.so.7.9 b/entry/libs/x86_64/libTKTopAlgo.so.7.9 new file mode 100644 index 00000000..a9fc40d1 Binary files /dev/null and b/entry/libs/x86_64/libTKTopAlgo.so.7.9 differ diff --git a/entry/libs/x86_64/libTKV3d.so.7.9 b/entry/libs/x86_64/libTKV3d.so.7.9 new file mode 100644 index 00000000..5b319c6b Binary files /dev/null and b/entry/libs/x86_64/libTKV3d.so.7.9 differ diff --git a/entry/libs/x86_64/libTKVCAF.so.7.9 b/entry/libs/x86_64/libTKVCAF.so.7.9 new file mode 100644 index 00000000..a76807fd Binary files /dev/null and b/entry/libs/x86_64/libTKVCAF.so.7.9 differ diff --git a/entry/libs/x86_64/libTKXCAF.so.7.9 b/entry/libs/x86_64/libTKXCAF.so.7.9 new file mode 100644 index 00000000..35b8774f Binary files /dev/null and b/entry/libs/x86_64/libTKXCAF.so.7.9 differ diff --git a/entry/libs/x86_64/libTKXMesh.so.7.9 b/entry/libs/x86_64/libTKXMesh.so.7.9 new file mode 100644 index 00000000..ace70a00 Binary files /dev/null and b/entry/libs/x86_64/libTKXMesh.so.7.9 differ diff --git a/entry/libs/x86_64/libTKXSBase.so.7.9 b/entry/libs/x86_64/libTKXSBase.so.7.9 new file mode 100644 index 00000000..28057222 Binary files /dev/null and b/entry/libs/x86_64/libTKXSBase.so.7.9 differ diff --git a/entry/libs/x86_64/libTKXml.so.7.9 b/entry/libs/x86_64/libTKXml.so.7.9 new file mode 100644 index 00000000..f3fedfd4 Binary files /dev/null and b/entry/libs/x86_64/libTKXml.so.7.9 differ diff --git a/entry/libs/x86_64/libTKXmlL.so.7.9 b/entry/libs/x86_64/libTKXmlL.so.7.9 new file mode 100644 index 00000000..16d57e49 Binary files /dev/null and b/entry/libs/x86_64/libTKXmlL.so.7.9 differ diff --git a/entry/libs/x86_64/libTKXmlTObj.so.7.9 b/entry/libs/x86_64/libTKXmlTObj.so.7.9 new file mode 100644 index 00000000..7b6282ff Binary files /dev/null and b/entry/libs/x86_64/libTKXmlTObj.so.7.9 differ diff --git a/entry/libs/x86_64/libTKXmlXCAF.so.7.9 b/entry/libs/x86_64/libTKXmlXCAF.so.7.9 new file mode 100644 index 00000000..89738eda Binary files /dev/null and b/entry/libs/x86_64/libTKXmlXCAF.so.7.9 differ diff --git a/entry/libs/x86_64/libTKernel.so.7.9 b/entry/libs/x86_64/libTKernel.so.7.9 new file mode 100644 index 00000000..6a7b71ff Binary files /dev/null and b/entry/libs/x86_64/libTKernel.so.7.9 differ diff --git a/entry/libs/x86_64/libbrotlicommon.so.1 b/entry/libs/x86_64/libbrotlicommon.so.1 new file mode 100644 index 00000000..2a79804c Binary files /dev/null and b/entry/libs/x86_64/libbrotlicommon.so.1 differ diff --git a/entry/libs/x86_64/libbrotlidec.so.1 b/entry/libs/x86_64/libbrotlidec.so.1 new file mode 100644 index 00000000..bce04483 Binary files /dev/null and b/entry/libs/x86_64/libbrotlidec.so.1 differ diff --git a/entry/libs/x86_64/libbrotlienc.so.1 b/entry/libs/x86_64/libbrotlienc.so.1 new file mode 100644 index 00000000..55af6b42 Binary files /dev/null and b/entry/libs/x86_64/libbrotlienc.so.1 differ diff --git a/entry/libs/x86_64/libbz2.so.1.0 b/entry/libs/x86_64/libbz2.so.1.0 new file mode 100644 index 00000000..e945be82 Binary files /dev/null and b/entry/libs/x86_64/libbz2.so.1.0 differ diff --git a/entry/libs/x86_64/libexpat.so.1 b/entry/libs/x86_64/libexpat.so.1 new file mode 100644 index 00000000..a2703820 Binary files /dev/null and b/entry/libs/x86_64/libexpat.so.1 differ diff --git a/entry/libs/x86_64/libfontconfig.so.1 b/entry/libs/x86_64/libfontconfig.so.1 new file mode 100644 index 00000000..0480535d Binary files /dev/null and b/entry/libs/x86_64/libfontconfig.so.1 differ diff --git a/entry/libs/x86_64/libfreetype.so.6 b/entry/libs/x86_64/libfreetype.so.6 new file mode 100644 index 00000000..dbd514fc Binary files /dev/null and b/entry/libs/x86_64/libfreetype.so.6 differ diff --git a/entry/libs/x86_64/libpng16.so.16 b/entry/libs/x86_64/libpng16.so.16 new file mode 100644 index 00000000..7664a931 Binary files /dev/null and b/entry/libs/x86_64/libpng16.so.16 differ diff --git a/entry/libs/x86_64/libz.so.1 b/entry/libs/x86_64/libz.so.1 new file mode 100644 index 00000000..190094a9 Binary files /dev/null and b/entry/libs/x86_64/libz.so.1 differ diff --git a/entry/oh-package-lock.json5 b/entry/oh-package-lock.json5 index 6e11548f..02b3d542 100644 --- a/entry/oh-package-lock.json5 +++ b/entry/oh-package-lock.json5 @@ -6,13 +6,13 @@ "lockfileVersion": 3, "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "specifiers": { - "libnativeocct.so@src/main/cpp/types/libnativeocct": "libnativeocct.so@src/main/cpp/types/libnativeocct" + "libopencax.so@src/main/cpp/types/libopencax": "libopencax.so@src/main/cpp/types/libopencax" }, "packages": { - "libnativeocct.so@src/main/cpp/types/libnativeocct": { - "name": "libnativeocct.so", + "libopencax.so@src/main/cpp/types/libopencax": { + "name": "libopencax.so", "version": "1.0.0", - "resolved": "src/main/cpp/types/libnativeocct", + "resolved": "src/main/cpp/types/libopencax", "registryType": "local" } } diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 index 230ed243..e452ac9d 100644 --- a/entry/oh-package.json5 +++ b/entry/oh-package.json5 @@ -6,6 +6,6 @@ "author": "", "license": "", "dependencies": { - "libnativeocct.so": "file:./src/main/cpp/types/libnativeocct" + "libopencax.so": "file:./src/main/cpp/types/libopencax" } } \ No newline at end of file diff --git a/entry/src/main/cpp/CMakeLists.txt b/entry/src/main/cpp/CMakeLists.txt index aae586a5..6884218d 100644 --- a/entry/src/main/cpp/CMakeLists.txt +++ b/entry/src/main/cpp/CMakeLists.txt @@ -1,6 +1,6 @@ # the minimum version of CMake. cmake_minimum_required(VERSION 3.18.1) -project(OpenCAX) +project(opencax) set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) add_definitions(-DOHOS_PLATFORM) @@ -36,40 +36,18 @@ endforeach() #THIRD_PARTY_LIBS set(THIRD_PARTY_LIBS - freetype fontconfig expat z bz2 png16 brotlicommon brotlidec brotlienc + ${OCCT_LIB_DIR}/libfreetype.so.6 + ${OCCT_LIB_DIR}/libexpat.so.1 + ${OCCT_LIB_DIR}/libfontconfig.so.1 + ${OCCT_LIB_DIR}/libbrotlidec.so.1 + ${OCCT_LIB_DIR}/libbrotlicommon.so.1 + ${OCCT_LIB_DIR}/libbrotlienc.so.1 + ${OCCT_LIB_DIR}/libpng16.so.16 + ${OCCT_LIB_DIR}/libbz2.so.1.0 + ${OCCT_LIB_DIR}/libz.so.1 ) -foreach(LIB_NAME ${THIRD_PARTY_LIBS}) - if(LIB_NAME STREQUAL "z") - set(LIB_FILE "libz.so.1") - elseif(LIB_NAME STREQUAL "bz2") - set(LIB_FILE "libbz2.so.1.0") - elseif(LIB_NAME STREQUAL "png16") - set(LIB_FILE "libpng16.so.16") - elseif(LIB_NAME STREQUAL "brotlicommon") - set(LIB_FILE "libbrotlicommon.so.1") - elseif(LIB_NAME STREQUAL "brotlidec") - set(LIB_FILE "libbrotlidec.so.1") - elseif(LIB_NAME STREQUAL "brotlienc") - set(LIB_FILE "libbrotlienc.so.1") - elseif(LIB_NAME STREQUAL "fontconfig") - set(LIB_FILE "libfontconfig.so.1") - elseif(LIB_NAME STREQUAL "freetype") - set(LIB_FILE "libfreetype.so.6") - elseif(LIB_NAME STREQUAL "expat") - set(LIB_FILE "libexpat.so.1") - endif() - - add_library(tp_${LIB_NAME} SHARED IMPORTED) - set_target_properties(tp_${LIB_NAME} PROPERTIES - IMPORTED_LOCATION ${OCCT_LIB_DIR}/${LIB_FILE} - IMPORTED_SONAME ${LIB_FILE} - ) - list(APPEND OCCT_IMPORTED_LIBS tp_${LIB_NAME}) -endforeach() - # 添加源文件 -add_library(nativeocct SHARED - napi_init.cpp +add_library(opencax SHARED # Header EGLCore/EGLCore.h OCCTRender/OCCTRender.h @@ -78,6 +56,8 @@ add_library(nativeocct SHARED EGLCore/EGLCore.cpp OCCTRender/OCCTRender.cpp OCCTRenderThread/OCCTRenderThread.cpp + + napi_init.cpp ) # 查找系统库 @@ -88,7 +68,7 @@ find_library(libace-lib ace_ndk.z) find_library(libuv-lib uv) # 链接系统库 -target_link_libraries(nativeocct PUBLIC +target_link_libraries(opencax PUBLIC # EGL Hilog 库 ${EGL-lib} ${GLES-lib} @@ -99,5 +79,6 @@ target_link_libraries(nativeocct PUBLIC libace_napi.z.so #OCCT核心库 ${OCCT_IMPORTED_LIBS} + ${THIRD_PARTY_LIBS} ) diff --git a/entry/src/main/cpp/napi_init.cpp b/entry/src/main/cpp/napi_init.cpp index 84105738..fb77f12a 100644 --- a/entry/src/main/cpp/napi_init.cpp +++ b/entry/src/main/cpp/napi_init.cpp @@ -132,17 +132,18 @@ static napi_value Init(napi_env env, napi_value exports) { EXTERN_C_END // 编写接口的描述信息,根据实际需要可以修改对应参数 -static napi_module occtmodel = { +static napi_module OpenCAXModel = { .nm_version = 1, .nm_flags = 0, .nm_filename = nullptr, .nm_register_func = Init, - .nm_modname = "occtrender", + .nm_modname = "opencax", .nm_priv = ((void*)0), .reserved = { 0 } }; -extern "C" __attribute__((constructor)) void RegisterModule(void) +extern "C" __attribute__((constructor)) +void RegisterOpenCAXModule(void) { - napi_module_register(&occtmodel); -} \ No newline at end of file + napi_module_register(&OpenCAXModel); +} diff --git a/entry/src/main/cpp/types/libnativeocct/Index.d.ts b/entry/src/main/cpp/types/libopencax/Index.d.ts similarity index 100% rename from entry/src/main/cpp/types/libnativeocct/Index.d.ts rename to entry/src/main/cpp/types/libopencax/Index.d.ts diff --git a/entry/src/main/cpp/types/libnativeocct/oh-package.json5 b/entry/src/main/cpp/types/libopencax/oh-package.json5 similarity index 77% rename from entry/src/main/cpp/types/libnativeocct/oh-package.json5 rename to entry/src/main/cpp/types/libopencax/oh-package.json5 index 7030cea1..402cc366 100644 --- a/entry/src/main/cpp/types/libnativeocct/oh-package.json5 +++ b/entry/src/main/cpp/types/libopencax/oh-package.json5 @@ -1,5 +1,5 @@ { - "name": "libnativeocct.so", + "name": "libopencax.so", "types": "./Index.d.ts", "version": "1.0.0", "description": "Please describe the basic information." diff --git a/entry/src/main/ets/pages/modelView.ets b/entry/src/main/ets/pages/modelView.ets index abf14332..d188ab39 100644 --- a/entry/src/main/ets/pages/modelView.ets +++ b/entry/src/main/ets/pages/modelView.ets @@ -5,21 +5,34 @@ import { Context } from '@kit.AbilityKit'; //import OCCTRender from 'libocctrender.so'; const DOMAIN = 0x0000; +const TAG = 'ModelView'; @Component export struct ModelView { private displayController: XComponentController = new XComponentController(); - private displayContrId: string = 'OCCTRenderer'; + private displayContrId: string = 'OCCTRenderer' @State modelPath: string = ''; @State modelName:string='model.step'; @State nativeWindow:string=''; @State loadStatus: string = '未测试'; + aboutToAppear() { this.copyRawFileToSandbox(); } + async loadNativeLibrary() { + try { + let NaviteOCCT = await import("libopencax.so") + console.info(`[NDK] 模块类型: ${typeof NaviteOCCT}`); + console.info(`[NDK] 模块值: ${JSON.stringify(NaviteOCCT)}`); + console.info(`[NDK] 所有属性: ${Object.keys(NaviteOCCT).join(', ')}`); + if (!NaviteOCCT) throw new Error("模块为 undefined"); + } catch (e) { + console.error(`[NDK] 加载失败: ${e.message}`, e); + // 此处会触发你看到的错误 + } + } async copyRawFileToSandbox() { try { - const context = getContext(this); this.modelPath = `${context.filesDir}/${this.modelName}`; const arrayBuffer:Uint8Array = await context.resourceManager.getRawFileContent(this.modelName); @@ -50,12 +63,6 @@ export struct ModelView { Row(){ Button('加载模型').onClick(()=>{ try { - // 调用 native 初始化渲染器 - console.log('displayContrId:', this.displayContrId); - console.log('NativeWindow:', this.nativeWindow); - console.log('ModelPath:', this.modelPath); - hilog.info(0x0000, 'ModelView', 'Load Model'); - // 复制模型文件并获取路径 console.info('Model copied to:', this.modelPath); // 调用 native 加载 //OCCTRender.loadModel(this.displayContrId, this.modelPath); @@ -63,17 +70,8 @@ export struct ModelView { hilog.error(0x0000, 'ModelView', `LoadModel Failed: ${JSON.stringify(e)}`); } }) - Button('测试库加载').onClick(async()=>{ - try { - const nativeocct = await import("libnativeocct.so") - console.info(`[NDK] 模块类型: ${typeof nativeocct}`); - console.info(`[NDK] 模块值: ${JSON.stringify(nativeocct)}`); - console.info(`[NDK] 所有属性: ${Object.keys(nativeocct).join(', ')}`); - if (!nativeocct) throw new Error("模块为 undefined"); - } catch (e) { - console.error(`[NDK] 加载失败: ${e.message}`, e); - // 此处会触发你看到的错误 - } + Button('测试模块加载').onClick(async()=>{ + this.loadNativeLibrary(); }) } XComponent({