西宁商城网站建设公司/竞价推广代运营公司
西宁商城网站建设公司,竞价推广代运营公司,南康做网站,河北建设工程招标网目录 说在前面setAgentTarget绘制寻路路径结果问题其他 说在前面 操作系统:windows 11浏览器:edge版本 124.0.2478.97recast-navigation-js版本:0.29.0golang版本:1.21.5上一篇:【recast-navigation-js】使用three.js辅…
目录 说在前面 setAgentTarget 绘制寻路路径 结果 问题 其他
说在前面
操作系统:windows 11 浏览器:edge版本 124.0.2478.97 recast-navigation-js版本:0.29.0 golang版本:1.21.5 上一篇:【recast-navigation-js】使用three.js辅助绘制Agent
setAgentTarget
绘制寻路路径
使用three.js
中的Line
绘制寻路路径private _updatePath ( scene: Scene) { if ( ! this . _agentTarget) { return } const path = [ ] path. push ( new Vector3 ( ) . set ( this . _agent. position ( ) . x, this . _agent. position ( ) . y, this . _agent. position ( ) . z) ) this . _agent. corners ( ) . forEach ( ( v) => { path. push ( new Vector3 ( ) . set ( v. x, v. y, v. z) ) } ) if ( path. length <= 1 ) { return } const spline = new CatmullRomCurve3 ( path) ; const samples = spline. getPoints ( path. length * 12 ) ; const geometrySpline = new BufferGeometry ( ) . setFromPoints ( samples) ; const line = new Line ( geometrySpline, new LineDashedMaterial ( { color: 0x66ccff , dashSize: 1 , gapSize: 0.5 } ) ) ; line. computeLineDistances ( ) ; if ( this . crowdPathLine) { scene. remove ( this . crowdPathLine) } this . crowdPathLine = linescene. add ( line)
}
CatmullRomCurve3
给定输入点,创建相对平滑的曲线(实际上可以不用这个,使用实际的寻路关键点更能反映寻路结果)LineDashedMaterial
虚线材质update,每帧重新绘制寻路路径public update ( delta: number , scene: Scene) { this . _crowd. update ( delta) this . crowdHelper. update ( ) this . _updatePath ( scene)
}
结果
鼠标右键设置agent起始位置 鼠标左键设置agent目标位置
问题
其他
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/25867.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!