From 069c684376bc00111b6470ff468a2fd78d5c616e Mon Sep 17 00:00:00 2001
From: liqiang
Date: Mon, 20 Oct 2025 17:11:55 +0800
Subject: [PATCH] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A0BabylonReactNative?=
=?UTF-8?q?=E6=8C=87=E5=AF=BC=E6=96=87=E6=A1=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: liqiang
---
en/BabylonReactNative.md | 405 +++++++++++++++++++++++++++++++++++
en/README_EN.md | 2 +-
zh-cn/BabylonReactNative.md | 408 ++++++++++++++++++++++++++++++++++++
zh-cn/README.md | 1 +
4 files changed, 815 insertions(+), 1 deletion(-)
create mode 100644 en/BabylonReactNative.md
create mode 100644 zh-cn/BabylonReactNative.md
diff --git a/en/BabylonReactNative.md b/en/BabylonReactNative.md
new file mode 100644
index 00000000..7990774c
--- /dev/null
+++ b/en/BabylonReactNative.md
@@ -0,0 +1,405 @@
+> Template version: v0.2.2
+
+
+
BabylonReactNative
+
+
+
+
+
+
+
+
+
+
+> [!TIP] [Github address](https://github.com/react-native-oh-library/BabylonReactNative)
+
+## Installation and Usage
+
+Find the matching version information in the release address of a third-party library: [@react-native-oh-tpl/babylonjs-react-native and @react-native-oh-tpl/babylonjs-react-native-harmony Releases](https://github.com/react-native-oh-library/BabylonReactNative/releases).
+
+Go to the project directory and execute the following instruction:
+
+
+
+
+
+#### **npm**
+
+```bash
+npm install @react-native-oh-tpl/babylonjs-react-native
+npm install @react-native-oh-tpl/babylonjs-react-native-harmony
+```
+
+#### **yarn**
+
+```bash
+yarn add @react-native-oh-tpl/babylonjs-react-native
+yarn add @react-native-oh-tpl/babylonjs-react-native-harmony
+```
+
+
+
+The following code shows the basic use scenario of the repository:
+
+> [!WARNING] The name of the imported repository remains unchanged.
+
+```js
+import React, { useState, FunctionComponent, useEffect, useCallback } from 'react';
+import { StatusBar, Button, View, Text, ViewProps, Image } from 'react-native';
+import { SafeAreaView } from '@react-native-oh-tpl/react-native-safe-area-context';
+
+import { EngineView, useEngine, EngineViewCallbacks } from '@babylonjs/react-native';
+ import { Scene, Vector3, ArcRotateCamera, Camera, WebXRSessionManager, SceneLoader, TransformNode, DeviceSourceManager, DeviceType, PointerInput, WebXRTrackingState, IMouseEvent } from '@babylonjs/core';
+import '@babylonjs/loaders';
+import Slider from '@react-native-community/slider';
+
+const EngineScreen: FunctionComponent = (props: ViewProps) => {
+ const defaultScale = 1;
+ const enableSnapshots = false;
+ // const enableSnapshots = true;
+
+ const engine = useEngine();
+ const [toggleView, setToggleView] = useState(false);
+ const [camera, setCamera] = useState();
+ const [rootNode, setRootNode] = useState();
+ const [scene, setScene] = useState();
+ const [xrSession, setXrSession] = useState();
+ const [scale, setScale] = useState(defaultScale);
+ const [snapshotData, setSnapshotData] = useState();
+ const [engineViewCallbacks, setEngineViewCallbacks] = useState();
+ const [trackingState, setTrackingState] = useState();
+
+ useEffect(() => {
+ if (engine) {
+ const scene = new Scene(engine);
+ setScene(scene);
+ scene.createDefaultCamera(true);
+ (scene.activeCamera as ArcRotateCamera).beta -= Math.PI / 8;
+ setCamera(scene.activeCamera!);
+ scene.createDefaultLight(true);
+ const rootNode = new TransformNode('Root Container', scene);
+ setRootNode(rootNode);
+
+ const deviceSourceManager = new DeviceSourceManager(engine);
+ const handlePointerInput = (event: IMouseEvent) => {
+ if (event.inputIndex === PointerInput.Move && event.movementX) {
+ rootNode.rotate(Vector3.Down(), event.movementX * 0.005);
+ };
+ };
+
+ deviceSourceManager.onDeviceConnectedObservable.add(device => {
+ if (device.deviceType === DeviceType.Touch) {
+ const touch = deviceSourceManager.getDeviceSource(device.deviceType, device.deviceSlot)!;
+ touch.onInputChangedObservable.add(touchEvent => {
+ handlePointerInput(touchEvent);
+ });
+ } else if (device.deviceType === DeviceType.Mouse) {
+ const mouse = deviceSourceManager.getDeviceSource(device.deviceType, device.deviceSlot)!;
+ mouse.onInputChangedObservable.add(mouseEvent => {
+ if (mouse.getInput(PointerInput.LeftClick)) {
+ handlePointerInput(mouseEvent);
+ }
+ });
+ }
+ });
+
+ const transformContainer = new TransformNode('Transform Container', scene);
+ transformContainer.parent = rootNode;
+ transformContainer.scaling.scaleInPlace(0.2);
+ transformContainer.position.y -= .2;
+
+ scene.beforeRender = function () {
+ transformContainer.rotate(Vector3.Up(), 0.005 * scene.getAnimationRatio());
+ };
+
+ SceneLoader.ImportMeshAsync('', 'https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BoxAnimated/glTF-Binary/BoxAnimated.glb').then(result => {
+ const mesh = result.meshes[0];
+ mesh.parent = transformContainer;
+ });
+ }
+ }, [engine]);
+
+ useEffect(() => {
+ if (rootNode) {
+ rootNode.scaling = new Vector3(scale, scale, scale);
+ }
+ }, [rootNode, scale]);
+
+ const trackingStateToString = (trackingState: WebXRTrackingState | undefined) : string => {
+ return trackingState === undefined ? '' : WebXRTrackingState[trackingState];
+ };
+
+ const onToggleXr = useCallback(() => {
+ (async () => {
+ if (xrSession) {
+ await xrSession.exitXRAsync();
+ } else {
+ if (rootNode !== undefined && scene !== undefined) {
+ const xr = await scene.createDefaultXRExperienceAsync({ disableDefaultUI: true, disableTeleportation: true })
+ const session = await xr.baseExperience.enterXRAsync('immersive-ar', 'unbounded', xr.renderTarget);
+ setXrSession(session);
+ session.onXRSessionEnded.add(() => {
+ setXrSession(undefined);
+ setTrackingState(undefined);
+ })
+
+ setTrackingState(xr.baseExperience.camera.trackingState);
+ xr.baseExperience.camera.onTrackingStateChanged.add((newTrackingState) => {
+ setTrackingState(newTrackingState);
+ });
+
+ // TODO: Figure out why getFrontPosition stopped working
+ //box.position = (scene.activeCamera as TargetCamera).getFrontPosition(2);
+ const cameraRay = scene.activeCamera!.getForwardRay(1);
+ rootNode.position = cameraRay.origin.add(cameraRay.direction.scale(cameraRay.length));
+ rootNode.rotate(Vector3.Up(), 3.14159);
+ }
+ }
+ })();
+ }, [rootNode, scene, xrSession]);
+
+ const onInitialized = useCallback(async(engineViewCallbacks: EngineViewCallbacks) => {
+ setEngineViewCallbacks(engineViewCallbacks);
+ }, [engine]);
+
+ const onSnapshot = useCallback(async () => {
+ if (engineViewCallbacks) {
+ setSnapshotData('data:image/jpeg;base64,' + await engineViewCallbacks.takeSnapshot());
+ }
+ }, [engineViewCallbacks]);
+
+ return (
+ <>
+
+
+ >
+ );
+};
+
+const App = () => {
+ const [toggleScreen, setToggleScreen] = useState(false);
+
+ return (
+ <>
+
+
+ { !toggleScreen &&
+
+ }
+ { toggleScreen &&
+
+ EngineScreen has been removed.
+ Engine has been disposed, and will be recreated.
+
+ }
+ { setToggleScreen(!toggleScreen); }} />
+
+ >
+ );
+};
+
+export default App;
+```
+
+## Link
+
+Currently, HarmonyOS does not support AutoLink. Therefore, you need to manually configure the linking.
+
+Open the `harmony` directory of the HarmonyOS project in DevEco Studio.
+
+### 1. Adding the overrides Field to oh-package.json5 File in the Root Directory of the Project
+
+```json
+{
+ ...
+ "overrides": {
+ "@rnoh/react-native-openharmony" : "./react_native_openharmony"
+ }
+}
+```
+
+### 2. Introducing Native Code
+
+Currently, two methods are available:
+
+Method 1 (recommended): Use the HAR file.
+
+> [!TIP] The HAR file is stored in the `harmony` directory in the installation path of the third-party library.
+
+Open `entry/oh-package.json5` file and add the following dependencies:
+
+```json
+"dependencies": {
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
+
+ "@react-native-oh-tpl/babylonjs-react-native-harmony": "file:../../node_modules/@react-native-oh-tpl/babylonjs-react-native-harmony/harmony/bl.har"
+ }
+```
+
+Click the `sync` button in the upper right corner.
+
+Alternatively, run the following instruction on the terminal:
+
+```bash
+cd entry
+ohpm install
+```
+
+Method 2: Directly link to the source code.
+
+> [!TIP] For details, see [Directly Linking Source Code](/en/link-source-code.md).
+
+### 3. Configuring CMakeLists and Introducing BabylonPackage
+
+Open `entry/src/main/cpp/CMakeLists.txt ` and add the following code:
+
+```diff
+```diff
+project(rnapp)
+cmake_minimum_required(VERSION 3.4.1)
+set(CMAKE_SKIP_BUILD_RPATH TRUE)
+set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
+set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
+set(LOG_VERBOSITY_LEVEL 1)
+set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
+set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
+set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
+add_compile_definitions(WITH_HITRACE_SYSTRACE)
+
+add_subdirectory("${RNOH_CPP_DIR}" ./rn)
+
+# RNOH_BEGIN: manual_package_linking_1
+add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
++ add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/babylonjs-react-native-harmony/src/main/cpp" ./bl)
+# RNOH_END: manual_package_linking_1
+
+file(GLOB GENERATED_CPP_FILES "./generated/*.cpp")
+
+add_library(rnoh_app SHARED
+ ${GENERATED_CPP_FILES}
+ "./PackageProvider.cpp"
+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
+)
+target_link_libraries(rnoh_app PUBLIC rnoh)
+
+# RNOH_BEGIN: manual_package_linking_2
+target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
++ target_link_libraries(rnoh_app PUBLIC rnoh_babylon)
+# RNOH_END: manual_package_linking_2
+```
+
+Open `entry/src/main/cpp/PackageProvider.cpp` and add the following code:
+
+```diff
+#include "RNOH/PackageProvider.h"
+#include "generated/RNOHGeneratedPackage.h"
+#include "SamplePackage.h"
++ #include "BabylonPackage.h"
+
+using namespace rnoh;
+
+std::vector> PackageProvider::getPackages(Package::Context ctx) {
+ return {
+ std::make_shared(ctx),
+ std::make_shared(ctx),
++ std::make_shared(ctx),
+ };
+}
+```
+
+### 4. Introducing BabylonPackage to ArkTS
+
+Open the`entry/src/main/ets/RNPackagesFactory.ts` file and add the following code:
+
+```diff
+...
+
++ import {BabylonPackage} from '@react-native-oh-tpl/react-native-safe-area-context/ts';
+
+export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
+ return [
+ new SamplePackage(ctx),
++ new BabylonPackage(ctx)
+ ];
+}
+```
+
+### 5. Running
+
+Click the `sync` button in the upper right corner.
+
+Alternatively, run the following instruction on the terminal:
+
+```bash
+cd entry
+ohpm install
+```
+
+Then build and run the code.
+
+## Compatibility
+
+To use this repository, you need to use the correct React-Native and RNOH versions. In addition, you need to use DevEco Studio and the ROM on your phone.
+
+Check the release version information in the release address of the third-party library:[@react-native-oh-tpl/babylonjs-react-native and @react-native-oh-tpl/babylonjs-react-native-harmony Releases](https://github.com/react-native-oh-library/BabylonReactNative/releases)
+
+## Properties
+
+> [!TIP] The **Platform** column indicates the platform where the properties are supported in the original third-party library.
+
+> [!TIP] If the value of **HarmonyOS Support** is **yes**, it means that the HarmonyOS platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android.
+
+**EngineView**
+
+`EngineView` is a React Native component that renders the Babylon.js 3D scene.
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| ------------------ | --------------------------------------------------------------------------------------------------------------- | -------- | -------- | ----------- | ----------------- |
+| `camera` | Specifies the camera object used for rendering | Camera | No | iOS Android | Yes |
+| `displayFrameRate` | Whether to display the current frame rate (FPS) | boolean | No | iOS Android | Yes |
+| `isTransparent` | Whether to render with a transparent background | boolean | No | iOS Android | Yes |
+| `androidView` | Specifies which underlying View type to use for rendering | string | No | iOS Android | Yes |
+| `antiAliasing` | Anti-aliasing level; higher values provide smoother visuals but cost more performance. 0 disables anti-aliasing | number | No | iOS Android | Yes |
+| `onInitialized` | Callback function triggered after the engine has finished initializing | function | No | iOS Android | Yes |
+
+# API
+
+> [!TIP] The **Platform** column indicates the platform where the properties are supported in the original third-party library.
+
+> [!TIP] If the value of **HarmonyOS Support** is **yes**, it means that the HarmonyOS platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android.
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| ------------------------ | ----------------------------------------------------------------------------------------------------------------------- | -------- | -------- | ----------- | ----------------- |
+| `useEngine` | Creates and manages the lifecycle of an Engine instance, automatically releasing the Engine when the component unmounts | function | No | iOS Android | Yes |
+
+## Known Issues
+
+## Others
+
+## License
+
+This project is licensed under [The MIT License (MIT)](https://github.com/BabylonJS/BabylonReactNative/blob/master/LICENSE).
diff --git a/en/README_EN.md b/en/README_EN.md
index af46f1b2..2c397d6e 100644
--- a/en/README_EN.md
+++ b/en/README_EN.md
@@ -397,8 +397,8 @@ You can evaluate existing documentation, make simple changes, report quality iss
| 364 | [react-native-neomorph-shadows](https://github.com/tokkozhin/react-native-neomorph-shadows) | 1.1.2 | No | [@react-native-oh-tpl/react-native-neomorph-shadows](https://github.com/react-native-oh-library/react-native-neomorph-shadows) | [npm Link](https://www.npmjs.com/package/@react-native-oh-tpl/react-native-neomorph-shadows) | [Link](/en/react-native-neomorph-shadows.md) |
| 365 | [@ant-design/react-native](https://github.com/ant-design/ant-design-mobile-rn) | 5.1.0 | - | - | - | [Link](/en/ant-design-react-native.md) |
| 366 | [react-native-screens](https://github.com/software-mansion/react-native-screens) | 3.34.0 | Yes | [@react-native-oh-tpl/react-native-screens](https://github.com/react-native-oh-library/react-native-harmony-screens) | [npm Link](https://www.npmjs.com/package/@react-native-oh-tpl/react-native-screens) | [Link](/en/react-native-oh-tpl-react-native-screens.md) |
- |
| 367 | [ffmpeg-kit-react-native](https://github.com/arthenica/ffmpeg-kit/tree/main/react-native) | 6.0.2 | - | [@react-native-oh-tpl/react-native-ffmpeg-kit](https://github.com/react-native-oh-library/ffmpeg-kit/releases) - | [Link](/en/react-native-ffmpeg-kit.md) |
+| 368 | [BabylonReactNative](https://github.com/BabylonJS/BabylonReactNative) | 1.8.6 | - | [@react-native-oh-tpl/babylonjs-react-native and @react-native-oh-tpl/babylonjs-react-native-harmony](https://github.com/react-native-oh-library/BabylonReactNative/releases) - | - | [Link](/en/BabylonReactNative.md) |
## JS Third-Party Libraries
diff --git a/zh-cn/BabylonReactNative.md b/zh-cn/BabylonReactNative.md
new file mode 100644
index 00000000..5e52cd2a
--- /dev/null
+++ b/zh-cn/BabylonReactNative.md
@@ -0,0 +1,408 @@
+> 模板版本:v0.2.2
+
+
+
BabylonReactNative
+
+
+
+
+
+
+
+
+
+
+> [!TIP] [Github 地址](https://github.com/react-native-oh-library/BabylonReactNative)
+
+## 安装与使用
+
+请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/babylonjs-react-native和@react-native-oh-tpl/babylonjs-react-native-harmony Releases](https://github.com/react-native-oh-library/BabylonReactNative/releases)。
+
+进入到工程目录并输入以下命令:
+
+
+
+#### **npm**
+
+```bash
+npm install @react-native-oh-tpl/babylonjs-react-native
+npm install @react-native-oh-tpl/babylonjs-react-native-harmony
+```
+
+#### **yarn**
+
+```bash
+yarn add @react-native-oh-tpl/babylonjs-react-native
+yarn add @react-native-oh-tpl/babylonjs-react-native-harmony
+```
+
+
+
+下面的代码展示了这个库的基本使用场景:
+
+> [!WARNING] 使用时 import 的库名不变。
+
+```js
+import React, { useState, FunctionComponent, useEffect, useCallback } from 'react';
+import { StatusBar, Button, View, Text, ViewProps, Image } from 'react-native';
+import { SafeAreaView } from '@react-native-oh-tpl/react-native-safe-area-context';
+
+import { EngineView, useEngine, EngineViewCallbacks } from '@babylonjs/react-native';
+ import { Scene, Vector3, ArcRotateCamera, Camera, WebXRSessionManager, SceneLoader, TransformNode, DeviceSourceManager, DeviceType, PointerInput, WebXRTrackingState, IMouseEvent } from '@babylonjs/core';
+import '@babylonjs/loaders';
+import Slider from '@react-native-community/slider';
+
+const EngineScreen: FunctionComponent = (props: ViewProps) => {
+ const defaultScale = 1;
+ const enableSnapshots = false;
+ // const enableSnapshots = true;
+
+ const engine = useEngine();
+ const [toggleView, setToggleView] = useState(false);
+ const [camera, setCamera] = useState();
+ const [rootNode, setRootNode] = useState();
+ const [scene, setScene] = useState();
+ const [xrSession, setXrSession] = useState();
+ const [scale, setScale] = useState(defaultScale);
+ const [snapshotData, setSnapshotData] = useState();
+ const [engineViewCallbacks, setEngineViewCallbacks] = useState();
+ const [trackingState, setTrackingState] = useState();
+
+ useEffect(() => {
+ if (engine) {
+ const scene = new Scene(engine);
+ setScene(scene);
+ scene.createDefaultCamera(true);
+ (scene.activeCamera as ArcRotateCamera).beta -= Math.PI / 8;
+ setCamera(scene.activeCamera!);
+ scene.createDefaultLight(true);
+ const rootNode = new TransformNode('Root Container', scene);
+ setRootNode(rootNode);
+
+ const deviceSourceManager = new DeviceSourceManager(engine);
+ const handlePointerInput = (event: IMouseEvent) => {
+ if (event.inputIndex === PointerInput.Move && event.movementX) {
+ rootNode.rotate(Vector3.Down(), event.movementX * 0.005);
+ };
+ };
+
+ deviceSourceManager.onDeviceConnectedObservable.add(device => {
+ if (device.deviceType === DeviceType.Touch) {
+ const touch = deviceSourceManager.getDeviceSource(device.deviceType, device.deviceSlot)!;
+ touch.onInputChangedObservable.add(touchEvent => {
+ handlePointerInput(touchEvent);
+ });
+ } else if (device.deviceType === DeviceType.Mouse) {
+ const mouse = deviceSourceManager.getDeviceSource(device.deviceType, device.deviceSlot)!;
+ mouse.onInputChangedObservable.add(mouseEvent => {
+ if (mouse.getInput(PointerInput.LeftClick)) {
+ handlePointerInput(mouseEvent);
+ }
+ });
+ }
+ });
+
+ const transformContainer = new TransformNode('Transform Container', scene);
+ transformContainer.parent = rootNode;
+ transformContainer.scaling.scaleInPlace(0.2);
+ transformContainer.position.y -= .2;
+
+ scene.beforeRender = function () {
+ transformContainer.rotate(Vector3.Up(), 0.005 * scene.getAnimationRatio());
+ };
+
+ SceneLoader.ImportMeshAsync('', 'https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BoxAnimated/glTF-Binary/BoxAnimated.glb').then(result => {
+ const mesh = result.meshes[0];
+ mesh.parent = transformContainer;
+ });
+ }
+ }, [engine]);
+
+ useEffect(() => {
+ if (rootNode) {
+ rootNode.scaling = new Vector3(scale, scale, scale);
+ }
+ }, [rootNode, scale]);
+
+ const trackingStateToString = (trackingState: WebXRTrackingState | undefined) : string => {
+ return trackingState === undefined ? '' : WebXRTrackingState[trackingState];
+ };
+
+ const onToggleXr = useCallback(() => {
+ (async () => {
+ if (xrSession) {
+ await xrSession.exitXRAsync();
+ } else {
+ if (rootNode !== undefined && scene !== undefined) {
+ const xr = await scene.createDefaultXRExperienceAsync({ disableDefaultUI: true, disableTeleportation: true })
+ const session = await xr.baseExperience.enterXRAsync('immersive-ar', 'unbounded', xr.renderTarget);
+ setXrSession(session);
+ session.onXRSessionEnded.add(() => {
+ setXrSession(undefined);
+ setTrackingState(undefined);
+ })
+
+ setTrackingState(xr.baseExperience.camera.trackingState);
+ xr.baseExperience.camera.onTrackingStateChanged.add((newTrackingState) => {
+ setTrackingState(newTrackingState);
+ });
+
+ // TODO: Figure out why getFrontPosition stopped working
+ //box.position = (scene.activeCamera as TargetCamera).getFrontPosition(2);
+ const cameraRay = scene.activeCamera!.getForwardRay(1);
+ rootNode.position = cameraRay.origin.add(cameraRay.direction.scale(cameraRay.length));
+ rootNode.rotate(Vector3.Up(), 3.14159);
+ }
+ }
+ })();
+ }, [rootNode, scene, xrSession]);
+
+ const onInitialized = useCallback(async(engineViewCallbacks: EngineViewCallbacks) => {
+ setEngineViewCallbacks(engineViewCallbacks);
+ }, [engine]);
+
+ const onSnapshot = useCallback(async () => {
+ if (engineViewCallbacks) {
+ setSnapshotData('data:image/jpeg;base64,' + await engineViewCallbacks.takeSnapshot());
+ }
+ }, [engineViewCallbacks]);
+
+ return (
+ <>
+
+ { setToggleView(!toggleView) }} />
+
+ { !toggleView &&
+
+ { enableSnapshots &&
+
+
+
+
+ }
+
+
+ {trackingStateToString(trackingState)}
+
+ }
+ { toggleView &&
+
+ EngineView has been removed.
+ Render loop stopped, but engine is still alive.
+
+ }
+
+ >
+ );
+};
+
+const App = () => {
+ const [toggleScreen, setToggleScreen] = useState(false);
+
+ return (
+ <>
+
+
+ { !toggleScreen &&
+
+ }
+ { toggleScreen &&
+
+ EngineScreen has been removed.
+ Engine has been disposed, and will be recreated.
+
+ }
+ { setToggleScreen(!toggleScreen); }} />
+
+ >
+ );
+};
+
+export default App;
+```
+
+## Link
+
+目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。
+
+首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony`
+
+### 1.在工程根目录的 `oh-package.json5` 添加 overrides 字段
+
+```json
+{
+ ...
+ "overrides": {
+ "@rnoh/react-native-openharmony" : "./react_native_openharmony"
+ }
+}
+```
+
+### 2.引入原生端代码
+
+目前有两种方法:
+
+1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
+2. 直接链接源码。
+
+方法一:通过 har 包引入
+
+> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。
+
+打开 `entry/oh-package.json5`,添加以下依赖
+
+```json
+"dependencies": {
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
+
+ "@react-native-oh-tpl/babylonjs-react-native-harmony": "file:../../node_modules/@react-native-oh-tpl/babylonjs-react-native-harmony/harmony/bl.har"
+ }
+```
+
+点击右上角的 `sync` 按钮
+
+或者在终端执行:
+
+```bash
+cd entry
+ohpm install
+```
+
+方法二:直接链接源码
+
+> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md)
+
+### 3.配置 CMakeLists 和引入 BabylonPackage
+
+打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
+
+```diff
+```diff
+project(rnapp)
+cmake_minimum_required(VERSION 3.4.1)
+set(CMAKE_SKIP_BUILD_RPATH TRUE)
+set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
+set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
+set(LOG_VERBOSITY_LEVEL 1)
+set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
+set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
+set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
+add_compile_definitions(WITH_HITRACE_SYSTRACE)
+
+add_subdirectory("${RNOH_CPP_DIR}" ./rn)
+
+# RNOH_BEGIN: manual_package_linking_1
+add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
++ add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/babylonjs-react-native-harmony/src/main/cpp" ./bl)
+# RNOH_END: manual_package_linking_1
+
+file(GLOB GENERATED_CPP_FILES "./generated/*.cpp")
+
+add_library(rnoh_app SHARED
+ ${GENERATED_CPP_FILES}
+ "./PackageProvider.cpp"
+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
+)
+target_link_libraries(rnoh_app PUBLIC rnoh)
+
+# RNOH_BEGIN: manual_package_linking_2
+target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
++ target_link_libraries(rnoh_app PUBLIC rnoh_babylon)
+# RNOH_END: manual_package_linking_2
+```
+
+打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
+
+```diff
+#include "RNOH/PackageProvider.h"
+#include "generated/RNOHGeneratedPackage.h"
+#include "SamplePackage.h"
++ #include "BabylonPackage.h"
+
+using namespace rnoh;
+
+std::vector> PackageProvider::getPackages(Package::Context ctx) {
+ return {
+ std::make_shared(ctx),
+ std::make_shared(ctx),
++ std::make_shared(ctx),
+ };
+}
+```
+
+### 4.在 ArkTs 侧引入 BabylonPackage
+
+打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加:
+
+```diff
+...
+
++ import {BabylonPackage} from '@react-native-oh-tpl/babylonjs-react-native-harmony/ts';
+
+export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
+ return [
+ new SamplePackage(ctx),
++ new BabylonPackage(ctx)
+ ];
+}
+```
+
+### 5.运行
+
+点击右上角的 `sync` 按钮
+
+或者在终端执行:
+
+```bash
+cd entry
+ohpm install
+```
+
+然后编译、运行即可。
+
+## 约束与限制
+
+## 兼容性
+
+要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
+
+请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/babylonjs-react-native和@react-native-oh-tpl/babylonjs-react-native-harmony Releases](https://github.com/react-native-oh-library/BabylonReactNative/releases)
+
+## 属性
+
+> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。
+
+> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
+
+**组件 EngineView**
+
+`EngineView` is a React Native component that renders the Babylon.js 3D scene.
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| ------------------ | ----------------------------------------------------------- | -------- | -------- | ------------ | ----------------- |
+| `camera` | 指定渲染用的摄像机对象 | Camera | No | iOS Android | Yes |
+| `displayFrameRate` | 是否显示当前的帧率(FPS) | boolean | No | iOS Android | Yes |
+| `isTransparent` | 是否使用透明背景进行渲染 | boolean | No | iOS Android | Yes |
+| `androidView` | 指定底层使用哪种 View 类型进行渲染 | string | No | iOS Android | Yes |
+| `antiAliasing` | 抗锯齿等级,数值越大画面越平滑,但性能开销更大。0 表示关闭抗锯齿 | number | No | iOS Android | Yes |
+| `onInitialized` | 引擎初始化完成后的回调函数 | function | No | iOS Android | Yes |
+
+# API
+
+> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。
+
+> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| ------------------------ | ----------------------------------------------------------------- | -------- | -------- | ----------- | ----------------- |
+| `useEngine` | 用于创建并管理 Engine 实例的生命周期,自动在组件卸载时释放 Engine 资源 | function | No | iOS Android | Yes |
+
+## 遗留问题
+
+## 其他
+
+## 开源协议
+
+本项目基于 [The MIT License (MIT)](https://github.com/BabylonJS/BabylonReactNative/blob/master/LICENSE) ,请自由地享受和参与开源。
diff --git a/zh-cn/README.md b/zh-cn/README.md
index dd863f6b..4d7a6140 100644
--- a/zh-cn/README.md
+++ b/zh-cn/README.md
@@ -398,6 +398,7 @@
| 365 | [@ant-design/react-native](https://github.com/ant-design/ant-design-mobile-rn) | 5.1.0 | - | - | - | [链接](/zh-cn/ant-design-react-native.md) |
| 366 | [react-native-screens](https://github.com/software-mansion/react-native-screens) | 3.34.0 | 是 | [@react-native-oh-tpl/react-native-screens](https://github.com/react-native-oh-library/react-native-harmony-screens) | [npm地址](https://www.npmjs.com/package/@react-native-oh-tpl/react-native-screens) | [链接](/zh-cn/react-native-oh-tpl-react-native-screens.md) |
| 367 | [ffmpeg-kit-react-native](https://github.com/arthenica/ffmpeg-kit/tree/main/react-native) | 6.0.2 | - | [@react-native-oh-tpl/react-native-ffmpeg-kit](https://github.com/react-native-oh-library/ffmpeg-kit/releases) - | [链接](/zh-cn/react-native-ffmpeg-kit.md) |
+| 368 | [BabylonReactNative](https://github.com/BabylonJS/BabylonReactNative) | 1.8.6 | - | [@react-native-oh-tpl/babylonjs-react-native和@react-native-oh-tpl/babylonjs-react-native-harmony](https://github.com/react-native-oh-library/BabylonReactNative/releases) - | - | [链接](/zh-cn/BabylonReactNative.md) |
## JS 三方库
--
Gitee