Skip to content

绘制

new Draw()

实例化

  • 返回:

    • 实例化Draw对象
  • 详情:

    实例化Draw对象,可以调用绘制模块中的方法

  • 示例:

js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )

const draw = new kapi.Draw()
console.log(draw)

openDrawPoint()

打开绘制点功能

  • 返回:

    • 打开绘制点功能后的回调
  • 详情:

    打开绘制点功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )

const draw = new kapi.Draw()
const status = await draw.openDrawPoint()
console.log(status)

drawPoint()

绘制点功能

  • 返回:

    • 绘制点功能后的回调
  • 详情:

    绘制点功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )

const draw = new kapi.Draw()
const status = await draw.openDrawPoint()
const response = await draw.drawPoint()
console.log(response)

showPoint()

显示点功能

  • 参数:

    • {String} id 点的唯一标识
    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器
  • 返回:

    • 显示点功能后的回调
  • 详情:

    显示绘制点功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )

const draw = new kapi.Draw()
const response = await draw.showPoint('123')
console.log(response)

hidePoint()

隐藏点功能

  • 参数:

    • {String} id 点的唯一标识
    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器
  • 返回:

    • 隐藏点功能后的回调
  • 详情:

    隐藏绘制点功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )

const draw = new kapi.Draw()
const response = await draw.hidePoint('123')
console.log(response)

deletePoint()

删除点功能

  • 参数:

    • {String} id 点的唯一标识
    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器
  • 返回:

    • 删除点功能后的回调
  • 详情:

    删除绘制点功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )

const draw = new kapi.Draw()
const response = await draw.deletePoint('123')
console.log(response)

getPointList()

获取点列表

  • 参数:

    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器
  • 返回:

    • 获取点列表后的回调
  • 详情:

    获取点列表

  • 示例:

js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )

const draw = new kapi.Draw()
const response = await draw.getPointList()
console.log(response)

TIP

功能需要完善

closeDrawPoint()

关闭绘制点功能

  • 返回:

    • 关闭绘制点功能后的回调
  • 详情:

    关闭绘制点功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const draw = new kapi.Draw()
const status = await draw.openDrawPoint()

// 10秒后关闭绘制点
setTimeout(async e => {
  const response = await draw.closeDrawPoint()
  console.log(status)
}, 1000 * 10)

drawPath()

开启绘制路径功能

  • 参数:

    • {String} path 路径参数
    • {String} option 绘制参数
    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器

option参数如下表

参数类型描述
idstring路径唯一id
isGraphicboolean是否是地理坐标
  • 返回:

    • 开启绘制路径功能后的回调
  • 详情:

    开启绘制路径功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const draw = new kapi.Draw()
draw.addLightFlowEventListener(response => {
  console.log(response)
})

clearPath()

清空路径功能

  • 参数:

    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器
  • 返回:

    • 清空路径功能后的回调
  • 详情:

    清空路径功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const draw = new kapi.Draw()
let response = await draw.clearPath()
console.log(response)

drawDecal()

绘制贴花功能

  • 参数:

    • {Object} option 绘制参数
    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器

option参数如下表

参数类型描述
typestring绘制贴花【straight 直行引导线;straightright 直行加右转引导线;straightleft 直行加左转引导线;right 右转引导线;left 左转引导线;manholecover 圆形井盖】
isGraphicboolean是否是地理坐标
locationobject绘制贴花坐标
    xnumberx
    ynumbery
    znumberz
rotationobject姿态
    rollnumberroll
    pitchnumberpitch
    yawnumberyaw
  • 返回:

    • 绘制贴花功能后的回调
  • 详情:

    绘制贴花功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const draw = new kapi.Draw()
let response = await draw.drawDecal()
console.log(response)

removeDecal()

删除贴花功能

  • 参数:

    • {String} id 点的唯一标识
    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器
  • 返回:

    • 删除贴花功能后的回调
  • 详情:

    删除贴花功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const draw = new kapi.Draw()
const status = await draw.removeDecal('123')
console.log(status)

drawContour()

绘制区域轮廓功能

  • 参数:

    • {String} contour 点数组
    • {Object} option 绘制参数
    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器

option参数如下表

参数类型描述
idstring路径唯一id
isGraphicboolean是否是地理坐标
  • 返回:

    • 绘制区域轮廓功能后的回调
  • 详情:

    绘制区域轮廓功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const draw = new kapi.Draw()
let response = await draw.drawContour()
console.log(response)

removeContour()

删除区域轮廓功能

  • 参数:

    • {String} id 点的唯一标识
    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器
  • 返回:

    • 删除区域轮廓功能后的回调
  • 详情:

    删除区域轮廓功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const draw = new kapi.Draw()
const status = await draw.removeContour('123')
console.log(status)

drawCircularContour()

绘制圆形区域轮廓功能

  • 参数:

    • {String} contour 点数组
    • {Object} option 绘制参数
    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器

option参数如下表

参数类型描述
radiusnumber半径
isGraphicboolean是否是地理坐标
locationobject坐标
    xnumberx
    ynumbery
    znumberz
  • 返回:

    • 绘制圆形区域轮廓功能后的回调
  • 详情:

    绘制圆形区域轮廓功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const draw = new kapi.Draw()
let response = await draw.drawContour()
console.log(response)

removeCircularContour()

删除原形区域轮廓功能

  • 参数:

    • {String} id 点的唯一标识
    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器
  • 返回:

    • 删除圆形区域轮廓功能后的回调
  • 详情:

    删除圆形区域轮廓功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const draw = new kapi.Draw()
const status = await draw.removeCircularContour('123')
console.log(status)

drawLightFlow()

开始绘制光流线功能

  • 参数:

    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器
  • 返回:

    • 开始绘制光流线功能后的回调
  • 详情:

    开始绘制光流线功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const draw = new kapi.Draw()
const status = await draw.drawLightFlow()
console.log(status)

removeLightFlow()

删除光流线功能

  • 参数:

    • {String} id 点的唯一标识
    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器
  • 返回:

    • 绘制光流线功能后的回调
  • 详情:

    绘制光流线功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const draw = new kapi.Draw()
const status = await draw.drawLightFlow()
console.log(status)

closeDrawLightFlow()

关闭绘制光流线功能

  • 参数:

    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器
  • 返回:

    • 关闭绘制光流线功能后的回调
  • 详情:

    关闭绘制光流线功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const draw = new kapi.Draw()
const status = await draw.drawLightFlow()

// 10秒后关闭绘制光流线
setTimeout(async e => {
  const response = await draw.closeDrawLightFlow()
  console.log(status)
}, 1000 * 10)

getAllByWindow()

全选视窗物体

  • 参数:

    • {String} type 物体类型【staticmesh 静态网格体;tree 树木;car 车辆】
    • {Boolean} sync [可选]是否要多客户端同步场景,需要开启同步服务器
  • 返回:

    • 全选视窗物体功能后的回调
  • 详情:

    全选视窗物体

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const draw = new kapi.Draw()

let all = await draw.getAllByWindow('staticmesh')
console.log(all)

LightFlowEventListener

新增光流线生成监听功能

  • 返回:

    • 新增光流线生成监听功能后的回调
  • 详情:

    新增光流线生成监听功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const event = new kapi.Event()
event.addEventListener(KAPI_CONST.EVENT.DRAW_LIGHT_FLOW, response => {
  console.log(response)
})

移除光流线生成监听功能

  • 返回:

    • 移除光流线生成监听功能后的回调
  • 详情:

    移除光流线生成监听功能

  • 示例:

js
import KAPI from '@ibrucekong/kapi'

const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })

const event = new kapi.Event()
event.removeEventListener(KAPI_CONST.EVENT.DRAW_LIGHT_FLOW)
绘制 has loaded