# @aibee/vr-label-tool

> 基于@aibee/vr-workshop-devkit组装的带接口的VR标注工具

Latest version **0.5.17** (published 2021-04-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install @aibee/vr-label-tool
pnpm add @aibee/vr-label-tool
yarn add @aibee/vr-label-tool
bun add @aibee/vr-label-tool
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.17 |
| Published | 2021-04-13 |
| First published | 2021-04-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 21.1 MB |
| Known vulnerabilities | 0 (+25 in 3 direct dependencies) |
| Install scripts | no |
| Author | hujingn jyfang |
| Maintainers | hujingn, jyfang |
| Keywords | vr, owlly, vr-workshop-devkit |

## Links

- npm: https://www.npmjs.com/package/@aibee/vr-label-tool
- Repository: https://code.aibee.cn/ued/vr-label-tool
- npm.io page: https://npm.io/package/@aibee/vr-label-tool

## Dependencies (10)

- [vue](https://npm.io/package/vue.md) ^2.6.11
- [axios](https://npm.io/package/axios.md) ^0.21.0
- [three](https://npm.io/package/three.md) ^0.120.1
- [core-js](https://npm.io/package/core-js.md) ^3.6.5
- [element-ui](https://npm.io/package/element-ui.md) ^2.13.2
- [vue-router](https://npm.io/package/vue-router.md) ^3.2.0
- [lodash.debounce](https://npm.io/package/lodash.debounce.md) ^4.0.8
- [browser-md5-file](https://npm.io/package/browser-md5-file.md) ^1.1.1
- [javascript-state-machine](https://npm.io/package/javascript-state-machine.md) ^3.1.0
- [@aibee/vr-workshop-devkit](https://npm.io/package/@aibee/vr-workshop-devkit.md) ^0.5.16

## Recent versions

- 0.5.17 (latest) — 2021-04-13
- 0.5.16 — 2021-04-13
- 0.5.15-rc1 — 2021-04-07

## README

# vr-label-tool

通用VR标注工具

## Install

```shell
# $ npm config set @aibee:registry https://npm.aibee.cn
$ npm i -S @aibee/vr-label-tool
```

## Usage Use Component
使用组件的方式
使用示例  
https://code.aibee.cn/ued/vr-label-tool/-/tree/master/examples

1、组件注册和配置
```javascript
import VRLabelTool from "@aibee/vr-label-tool";

// 这里可以重写接口请求 https://code.aibee.cn/ued/vr-label-tool/-/tree/master/src/labeling-tool/api
import * as api from "@/api/label-tools";
// 自定义内容弹框配置数组, 参考(https://code.aibee.cn/robot-fe/owlly/vr-workshop-devkit)customContentTypes
import contentEditor from './content-editor'; 
// 自定义内容弹框预览组件，组件内type=内容配置contentEditor类型type，例如：14
import contentViews from './content-views';
// defaultTool 默认显示的工具类型
// omitTools 隐藏的工具类型列表
Vue.use(LabelTool, {
  api,
  defaultTool: 'imgTextLabel',
  omitTools: [],
  contentEditor,
  contentViews,
  // 点击工具左下角预览按钮弹出链接 ${xxx} xxx为getProjectVrId项目接口字段
  previewUrl: 'https://xxx.aibee.cn/preview/${id}?floor_id=${floor_id}',
});
```
工具类型列表
```code
{ name: 'viewingAngle', text: '视角设置' },
{ name: 'pointVisibility', text: '可见性' },
{ name: 'hotspot', text: '漫游热点' },
{ name: 'imgTextLabel', text: '标签标注' },
{ name: 'signLabel', text: '标牌标注' },
{ name: 'ruler', text: '标尺标注' },
```
重写api接口，所有请求详见 examples/api-test.js
```javascript
import request from '@/utils/request';

// 基础接口，所有请求都会基于此请求
export async function baseRequest(path, payload, method) {
  return request({
    url: `/admin/${path}`,
    method,
    data: ['get', 'delete'].includes(method) ? null : payload,
    params: ['get', 'delete'].includes(method) ? payload : null,
  });
}
// 上传base64图片
export function uploadThumb(filename, base64) {
  console.log(filename, base64);
  return { data: {"url": 'xxx'} };
}
// 项目查询接口，需组装成结构{data:[{id,vrId,title}]}
export function queryProjectList(params) {
  return baseRequest('expo/query/v1', params, 'get').then((res) => ({ data: res.data.list }));
}
// 模拟小地图数据（提供此接口后可显示小地图）
export function queryPlaceMap(params) {
  return {
    data: {
      floor_cmap: 'https://....svg',
      floor_cmap_align_param: '{"scale2D": 1,...}',
    },
    error_msg: '',
    error_no: 0,
  };
}
```

2、添加路由
```javascript
import { VRLabelTool, VRPreview } from "@aibee/vr-label-tool";
import TestLabelTool from './TestLabelTool.vue';
// 不使用自定义组件，使用params参数:projectId，组件内部使用了projectId
// 其他query参数可选version、disabled等
// 使用自定义组件，使用api-params传参
{
  path: "/:projectId",
  name: "Project",
  component: VRLabelTool
},
{
  path: "/preview/:projectId",
  name: "Preview",
  component: VRPreview
}
{
  path: '/test',
  component: TestLabelTool,
},
```

3、使用自定义组件
```vue
<template>
  <div>
    <VRLabelTool :api-params="apiParams">
      <template v-slot:resource2="{srcType, visible, closeResource, loadResource}">
        <ElementSelector v-if="visible"
                         :src-type="srcType"
                         :visible="visible"
                         :close-resource="closeResource"
                         :load-resource="loadResource"
        ></ElementSelector>
      </template>
    </VRLabelTool>
  </div>
</template>

<script>
import { VRLabelTool, EventHub } from '../src/index';
import ElementSelector from './components/element-selector.vue';

export default {
  components: { VRLabelTool, ElementSelector },
  data() {
    return {
      apiParams: {
        projectId: 'f-80-353',
      },
    };
  },
  mounted() {
    // VR组件加载完成事件
    EventHub.$on('stageInited', this.stageInited);
    // 标注组件加载完成事件
    EventHub.$on('labelingToolInited', this.labelingToolInited);
    // 保存事件前置事件，可return Promise.reject();阻止保存
    EventHub.onBeforeEvent = this.onBeforeEvent;
    // 保存事件完成后的事件
    EventHub.onAfterEvent = this.onAfterEvent;
  },
  methods: {
    async onBeforeEvent(name, data) {
      console.log('onBeforeEvent', name, data);
      // 如果想阻止保存 return Promise.reject();
      return Promise.resolve();
    },
    async onAfterEvent(name, data) {
      // 更新或者创建初始视角时，更新封面
      console.log('onAfterEvent', name, data);
    },
    labelingToolInited(tool) {
      console.log(tool);
    },
    // VR加载完成事件
    stageInited(stage) {
      console.log(stage);
    },
  },
};
</script>
```

4、资源位选择，需要提供 作用域插槽 v-slot:resource="{srcType, visible, closeResource, loadResource}"

|参数|说明|属性/方法参数|
|:--|:--|:--|
|srcType|资源类型（image、video、model）|-|
|visible|弹框可见性|-|
|closeResource|关闭弹框事件|-|
|loadResource|确定选择资源|{ srcType: '资源类型', url: '资源地址', thumbnailUrl: '资源缩略图', title: '资源标题' }|

## Update

```shell
$ npm i @aibee/vr-label-tool@latest
```

---
_Source: https://npm.io/package/@aibee/vr-label-tool · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
