Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
concefly committed Aug 29, 2023
1 parent 15d103e commit d9df0ca
Showing 1 changed file with 4 additions and 63 deletions.
67 changes: 4 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,19 @@
![workflow](https://github.com/AwesomeXR/xr-editor/actions/workflows/ci.yml/badge.svg)

![](https://rshop.tech/gw/assets/upload/202308292230998.png)
![](https://rshop.tech/gw/assets/upload/202308292258070.png)

一个开源的 3D 编辑器。

- 基于 Babylon.js、React 和 antd
- 基于 [Babylon.js](https://www.babylonjs.com/)、React 和 antd
- 可外部扩展的面板系统
- 内建 H5、apng 导出功能

## 在项目中使用

```
npm install xr-editor
```
参见示例:[demo/page/XREdtiroPage.tsx](demo/page/XREdtiroPage.tsx)

```jsx
import React, { useContext, useEffect, useRef, useState } from 'react';
import ReactDOM from 'react-dom';
import { IBuiltinWBKeyItem, XREditor, XRProjectModel, XRSetup, UserLevelEnum } from 'xr-editor';
import XRRuntimeStartupManifest from 'xr-editor/esm/XRRuntimeStartup.manifest.json';
import { ExternalImpl, MemoryFS } from 'ah-memory-fs';
import { IndexedDBAdapter } from 'ah-memory-fs-indexed-db';

ExternalImpl.ArrayBufferToString = data => new TextDecoder().decode(data);
ExternalImpl.StringToArrayBuffer = data => new TextEncoder().encode(data);

XRSetup();


export const EntryApp = () => {
const ctx = useContext(AppContext);

const [ready, setReady] = useState<boolean>(false);
const projectRef = useRef<XRProjectModel>();

useEffect(() => {
launch();

return () => {
projectRef.current?.dispose();
};
}, []);

const launch = async () => {
const attachTo = 'XR-PLAYGROUND';
const mfs = await MemoryFS.create(() => IndexedDBAdapter.attach(attachTo));

const _uploadDist = async (data: Blob, path: string) => {
return ''; // 自定义 data 上传 URL
};

const _projModel = new XRProjectModel(mfs, XRRuntimeStartupManifest.js[0], _uploadDist);
await _projModel.reload();

projectRef.current = _projModel;
setReady(true);
};


return ready && projectRef.current ? (
<>
<XREditor
style={{ width: '100vw', height: '100vh' }}
project={projectRef.current}
/>
</>
) : null;
};

ReactDOM.render(
<EntryApp />,
document.getElementById('__app')
);
```
- 扩展面板:参见 [src/xr/BuiltinExtension/ModelDesignOutline](src/xr/BuiltinExtension/ModelDesignOutline)

## 本地启动

Expand Down

0 comments on commit d9df0ca

Please sign in to comment.