// // Created on 2026/2/18. // // Node APIs are not fully supported. To solve the compilation error of the interface cannot be found, // please include "napi/native_api.h". #ifndef OCCT_RENDER_THREAD_H #define OCCT_RENDER_THREAD_H #include #include #include #include #include #include #include "EGLCore/EGLCore.h" #include "OCCTRender/OCCTRender.h" namespace OCCTRenderer { class OCCTRenderThread { public: OCCTRenderThread(); ~OCCTRenderThread(); bool start(OHNativeWindow* window); void stop(); void loadModel(const std::string& filePath); void setRotation(float xAngle, float yAngle); void setTranslation(float x, float y); void resetView(); void setClearColor(float r, float g, float b, float a); void resizeWindow(int width, int height); using Callback = std::function; void registerRenderCompleteCallback(Callback callback); private: void renderLoop(); std::thread renderThread_; std::atomic isRunning_; OHNativeWindow* nativeWindow_; EGLCore eglCore_; OCCTRender renderer_; std::mutex commandMutex_; std::condition_variable commandCondition_; enum CommandType { CMD_LOAD_MODEL, CMD_SET_ROTATION, CMD_SET_TRANSLATION, CMD_RESET_VIEW, CMD_SET_CLEAR_COLOR, CMD_RESIZE, CMD_EXIT }; struct RenderCommand { CommandType type; std::string param1; // For file path float param2, param3, param4, param5; RenderCommand() : type(CMD_EXIT), param1(""), param2(0.0f), param3(0.0f), param4(0.0f), param5(0.0f) {} RenderCommand(CommandType t) : type(t), param1(""), param2(0), param3(0), param4(0), param5(0) {} }; std::queue commandQueue_; std::mutex callbackMutex_; Callback renderCompleteCallback_; int windowWidth_; int windowHeight_; }; } // namespace OCCTRenderer #endif //OCCT_RENDER_THREAD_H