npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ooomap-navi

v1.0.8

Published

ooomap 导航功能实现类

Downloads

29

Readme

Navigator 导航类使用文档

ooomap 导航功能实现类

1. 引入 navigator 类

  • 方式一: 引入 ooomapNavi
// om.Navigator om.CoordProjection
import 'ooomapNavi'

2. 实例化Navigator类

先创建两点间的路线之后, 再实例化 Navigator 类

    glo.building.findPath(from, to, {
        // 楼梯优先, lt: 楼梯, zt: 直梯 ft: 扶梯, 值越小优先级越高, 默认值为1
        lt: .1,
    }).then(routeResult => {

        // 1. 创建导航实例
        glo.navi = new om.Navigator(map, routeResult)

        // 也可以设置一些参数
        let options = {
            // 是否跟随位置
            followPosition: true,
            // 是否跟随角度
            followDirection: true,
            // 是否自动切换楼层
            autoChangeFloor: true,
            // 在导航完成时, 是否视角放大到整个楼层
            zoomOutOnComplete: true,
            // 当偏移大于此值时, 会触发 navi-return-to-line 事件, (一般提示 "您已偏离路线")
            offsetDistance: 3,
            // 当偏移大于此值时, 会触发 navi-new-path 事件, (重新计算路线)
            newPathDistance: 5,
            // 在地图无操作后. 恢复视角跟随的时间
            idleTime: 3000,
            // 离终点或梯点多大距离时表示完成, 默认为1.5米
            complateDistace: 1.5,
        }

        glo.navi = new glo.Navigator(map, routeResult, options)

        //
        // 开启导航 
        //
        glo.navi.start()

        //
        // 注册导航事件
        //

        // 移动事件, 在 glo.navi.update( position ) 时触发
        glo.navi.on('walk', walkResult => {
            console.log('walk', walkResult)
        })

        /**
         * walkResult 的类型
         * @typedef {{
         * description: string              描述文字如: "向左前步行9.6米后到达终点"
         * text: string                     方向文字如: 左前
         * remain: number                   此路段还剩多少米
         * leave: number                    此路段已经走过多少米
         * nextText: string                 下一段文字如: 终点
         * position: om.thr.Vector3         定位的原始点 Vector3
         * linePoint: om.thr.Vector3        与定位点最进处 "路线上" 的点, 使用此点,可以将位置绑定在路线上
         * distance: number                 定位点与路线之间的距离
         * next: WalkResult                 下一段的 WalkResult
         * }} WalkResult
         */

        // 与路线的偏移值大于offsetDistance时会触发此事件
        glo.navi.on('navi-return-to-line', () => {})

        // 与路线的偏移值大于newPathDistance时会触发此事件
        glo.navi.on('navi-new-path', () => {})

        // 当导航到终点时触发
        glo.navi.on('navi-complete' () => {})

        // 在跨域楼层时触发
        glo.navi.on('focusFloors', floorNumbers => {})

    })

walk 事件数据预览 Alt text

3. 在接收到新的定位点时,更新位置

定位点的数据格式

let location = {
    ...
    x: number,          // x轴上的像素坐标
    y: number,          // y轴上的像素坐标
    floorId: number     // 楼层id, 此值可能与地图中的floorNumber不一至, 需要注意
}

需要将定位的像素坐标转化为场景坐标, 此比例会根据不同的地图而不同, 左下角为原点 如: 定位像素坐标大小为 2000 x 1600, 而对应场景中的矩形范围是 100米 x 80米

所以转化坐标为:


let x = location.x / 2000 * 100
let y = location.y / 1600 * 80

// 构建为一个 Vector3
let pos = new om.thr.Vector3(x, y, 0)

// update navi, 会触发 walk 事件
glo.navi.update( pos )

4. Navigator 的注销

在自然的走到终点完成导航时, Navigator会自动的进行销毁, 如果在导航的过程中直接结束导航就需要手动的进行销毁

glo.navi.dispose()

在重新计算路线后, 需要重新创建Navigator, 参考上面的第2步