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 dd643d5 commit b021fd5
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: ci

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 14.x ]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Run ci
run: npm ci
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# XR Editor

![workflow](https://github.com/ch-real3d/xr-editor/actions/workflows/ci.yml/badge.svg)

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

一个开源的 3D 编辑器。

- 基于 Babylon.js、React 和 antd
- 可外部扩展的面板系统
- 内建 H5、apng 导出功能

## 在项目中使用

```
npm install xr-editor
```

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

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();

_projModel.setUserLevel(UserLevelEnum.Anonymous); // 游客模式
_projModel.setMetaInfo({ title: '本地项目' });

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')
);
```
## 本地启动
```bash
npm install
npm run app:dev
```
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@ant-design/cssinjs": "^1.17.0",
"@ant-design/icons": "^5.2.5",
"@antv/x6": "^2.13.1",
"@antv/x6-react-components": "^3.0.0",
"@codemirror/autocomplete": "^6.9.0",
"@codemirror/commands": "^6.2.5",
"@codemirror/lang-javascript": "^6.2.1",
Expand Down

0 comments on commit b021fd5

Please sign in to comment.