this.position.add is not a function

来源:7-16 斜上抛运动代码开发

慕粉1405101

2018-12-10

bottle.js/下的_jump方法/的这行代码this.obj.translateY(translateY)报错了
代码段为:

_jump (tickTime) {
const t =tickTime / 1000
this.flyingTime = this.flyingTime + t
const translateH = this.velocity.vx * t
const translateY = this.velocity.vy * t - 0.5 * gamekConf.gravity * t * t - gamekConf.gravity * this.flyingTime * t

this.obj.translateY(translateY)
this.obj.translateOnAxis(this.axis, translateH)

}
报错信息为:

this.position.add is not a function
TypeError: this.position.add is not a function
at Object3D.translateOnAxis (http://127.0.0.1:64645/game/libs/three.js:8371:19)
at Object3D.translateY (http://127.0.0.1:64645/game/libs/three.js:8397:17)
at Bottle._jump (http://127.0.0.1:64645/game/src/objects/bottle.js:195:22)
at Bottle.update (http://127.0.0.1:64645/game/src/objects/bottle.js:145:22)
at GamePage.render (http://127.0.0.1:64645/game/src/pages/game-page.js:105:29)

写回答

2回答

慕盖茨2021568

2019-04-01

在不 老哥 请问你解决了吗

0
0

千迦

2018-12-14

这个错是从threejs的源码中报出来的,这种源码里的报错,大概率还是调用的时候某些值给的不对,一个方法就是打断点之后,查一下这个函数调用的时候,this.obj的情况,还有this.axis以及translateH,如果还是看不出来可以考虑debug一下threejs的源码了,我看了一下源码,直接看没看出什么错误,this.position是个vector3,正常是有add方法的,不太好查的话,确实得debug一下源码,你可以看看,有什么问题再发出来

0
3
慕粉1405101
Object.getPrototypeOf(o)) } catch (e) {} try { c(window.__global.canvas2dContextProto, Object.getPrototypeOf(n)) } catch (e) {} for (var r in window.__global.document = {}, window.document) try { window.__global.document[r] = "function" == typeof window.document[r] ? window.document[r].bind(document) : window.document[r] } catch (e) {} const l = console.error.bind(console) , s = console.warn.bind(console); console.error = function(...e) { try { if (1 >= e.length) return l(...e); for (const t of e) if ("object" == typeof t) return l(...e); return l(e.join(" "))
2018-12-14
共3条回复

three.js-打造微信小游戏跳一跳 快速掌握3D游戏开发

three.js+WebGL+微信小游戏API, 带你进入3D的游戏世界

793 学习 · 147 问题

查看课程