graphics - TypeError:THREE.Math.lerp 不是函数
问题描述
我正在搜索 WEBGL Three.js Games 的在线参考资料。遇到了一款游戏,它的源代码对于提供它的人来说可以正常工作,但我遇到了一个错误
TypeError:THREE.Math.lerp 不是函数
使用此函数的代码段是:
function update(){
//stats.update();
//animate
rollingGroundSphere.rotation.x += rollingSpeed;
heroSphere.rotation.x -= heroRollingSpeed;
if(heroSphere.position.y<=heroBaseY){
jumping=false;
bounceValue=(Math.random()*0.04)+0.005;
}
heroSphere.position.y+=bounceValue;
heroSphere.position.x=THREE.Math.lerp(heroSphere.position.x,currentLane, 2*clock.getDelta());//clock.getElapsedTime());
bounceValue-=gravity;
if(clock.getElapsedTime()>treeReleaseInterval){
clock.start();
addPathTree();
if(!hasCollided){
score+=2*treeReleaseInterval;
scoreText.innerHTML=score.toString();
}
}
doTreeLogic();
doExplosionLogic();
render();
requestAnimationFrame(update);//request next update
}
解决方案
Math
已重命名为MathUtils
with r113
。所以试试下面的代码:
heroSphere.position.x=THREE.MathUtils.lerp(heroSphere.position.x,currentLane, 2*clock.getDelta());//clock.getElapsedTime());
推荐阅读
- spring-boot - 返回一个空对象 Java Spring Boot REST
- typescript - 发送电子邮件时 MODULE_NOT_FOUND 错误
- c# - 等待信号量可能仍在同一线程上执行代码
- c# - 用 \ 替换字符串在 Visual Studio 2019 中不起作用
- reactjs - 部署我的 React 应用程序时应该使用哪种 AWS 服务?
- python - 如何使用nlp获取句子中单词之间的关系
- python - 将列表与 JSON 进行比较并计算出现次数
- android - 如何在 Kotlin 库中使用协程
- python - 在 Pandas DataFrame 中解析 JSON
- python - 我如何将循环打印值存储在变量或列表中