- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
http://codepen.io/AlexKM/pen/JGEMjZ
turnTo: function (X, Y) {
var angleDiff = 0,
targetA = this.angleToPoint({
x: X,
y: Y
}),
dronA = this.angle;
/// If the angle difference can't be reached in a frame
if (Math.abs(targetA - dronA) > this.turnSpeed * 1.25) {
this.workingAngle = true;
angleDiff = targetA - dronA;
while (angleDiff < 0)
angleDiff += 2 * Math.PI;
while (angleDiff > 2 * Math.PI)
angleDiff -= 2 * Math.PI;
if (angleDiff >= Math.PI) {
this.turningLeft = true;
} else {
this.turningRight = true;
}
} else /// if the diff is negligible, reach it to save CPU
this.angle = targetA;
},
更新处理实际车削的函数片段:
// apply turning
if (this.turningLeft) {
this.angle -= this.turnSpeed;
}
else if (this.turningRight) {
this.angle += this.turnSpeed;
}
红点 - 面向无人机
橙色圆点 - 表示无人机正在左转或右转
青色点 - 无人机是否正在重新计算 Angular/进行三 Angular 学的信号
代码确实包含一个帮助其平滑的部分,基本上通过简单地设置鼠标的 Angular (如果可以在 testDrone.turnSpeed 变量的帧内到达)来实现。
大约一半的时间,它会转动并顺利工作。另一半则神经兮兮,左右交替,不断计算三 Angular 函数。
这可能是什么原因?
最佳答案
不错的剧本。 :)
我认为抖动可能是(帧率(fps
)+处理时间)和显示器刷新率之间差异的函数。我这样说是因为有时它看起来很光滑,有时它有点凹凸不平,而且就鼠标位置/移动而言,似乎没有特定的模式。
您是否考虑过使用 requestAnimationFrame()
而不是 setTimeout()
? See MDN HERE ,其中指出...
This will request that your animation function be called before the browser performs the next repaint. The number of callbacks is usually 60 times per second, but will generally match the display refresh rate in most web browsers as per W3C recommendation.
参见markE的回复this StackOverflow question关于限制对特定帧速率的 requestAnimationFrame
调用。
希望有帮助。 :)
关于javascript - 是什么导致 "drone"在以特定 Angular 转动时出现抖动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34682294/
我构建了一个没有修饰的 Java Swing 对话框。我已经通过 MouseListener 和 MouseMotionListener 接口(interface)使用拖放实现了对话框移动。 但是,在
我在 Linux 2.6 上使用 clock_gettime()(来自 time.h)来控制线程循环中的计时。我需要在 +/- 5mS 时间范围内有 500mS。它似乎给了我 500 毫秒,然后开始漂
有没有办法抖动 geom_line() 中的线条? ?我知道这有点违背了这个情节的目的,但是如果你有一个只有几行的情节并且希望他们都展示它可能会很方便。也许有一些其他解决方案可以解决这个可见性问题。
所以我有一些物体(我可以在运行时创建越来越多的物体),我需要它们被磁化到屏幕中心。让它在世界空间中为 (480/2/WORLD_SCALE, 320/2/WORLD_SCALE)。我是 box2d 的
我终于制作了一个可以按照我想要的方式运行的股票代码,但现在唯一的问题是它看起来有点不稳定,看起来像是在旧电视上显示的。如何让它看起来更平滑? 这是我的代码: import java.awt.Color
所以我的游戏几乎完成了...但是当我将手指按住屏幕时会出现这种小故障或抖动,现在我已经注意到了,我无法不注意到... 它发生得非常快,并且只有在调用一个函数来处理点击和按住(长按)时才会发生。这会在使
我接手了一个半成品的网站开发,这个网站上有一些使用jquery 1.3.2的 slider 。突然间,今天,我第一次看到 slider 在到达内容末尾时摇晃。这是带有问题 slider 的站点: ht
正如您从下面的屏幕截图中看到的那样,“标题栏”在带有文本的区域中出现了这些丑陋的 strip ,这些 strip 延伸了整个屏幕的宽度。它在真实设备上更加明显。 有什么办法可以解决这个问题吗? 最佳答
我创建了一个 UICollectionView 并希望所有单元格都像 iPhone 上跳板的编辑模式一样摇动。我已经创建了我的 shake 代码,但不知道如何实现它。我有自定义单元格,所以我假设它在那
我正在尝试将列表传递给有状态小部件的构造函数,但是在 main.dart 中添加小部件时,它不需要任何参数。 class Appointments extends StatefulWidget {
我最初在 gamedev 上问过这个问题,但没有一个答案有助于解决问题,我仍然不知道真正的原因是什么。我在常见问题解答中没有看到任何关于在 SE 中重新发布问题的内容,所以我只能希望这没问题。此外,回
我的数据看起来像这样: df1 <- structure( list( y = c(-0.19, 0.3,-0.05, 0.15,-0.05, 0.15), lb
我目前的工作需要在 Intel Core 系列的 CPU 上生成指定数量的 TLB 未命中,但进展并不顺利。我尝试了很多方法,但所有方法的 TLB 命中率都非常高。有谁知道一些关于 x86 TLB 如
我知道有一种方法可以将图像转换为 Icon通过 ImageIcon .但我正在使用 FancyBottomNavigation这是必需的 TabData具有参数 iconData类型 IconData
我想像在js中的示例一样实现视频到 Canvas 应用程序:http://jsfiddle.net/Ls9kfwot/2/ 但是我的问题是如何在特定区域拍摄视频播放器的屏幕截图? 就像drawImag
如果 onTap: changeName, void changeName() { setState(() { name = "Your own codes"; }
我正在尝试为从api中获取的list实现延迟加载。我为ListView实现了一个侦听器,以检查它何时到达底部。我在这里的问题是: 1)如何为列表设置初始加载项数? 2)如何在调用loadMore()方
我正在使用流从REST API检索数据,但是当数据库中的数据更新时,流不会刷新应用程序中的数据。 StreamController _productsController = new StreamCo
我还没有看到这个问题在 SO 中被提及,所以就这样吧。我有一个搜索栏,可以防止搜索超出次要进度(在本例中为音乐缓冲)。假设这首歌长 5 分钟,已缓冲 4 分钟,并且正在一分钟标记处播放。当我去拖动
我的应用程序基于 GPS 数据,为此我使用了 Fused-location-provider。从现在开始,我看到有一个 gps 抖动,一些 GPS 坐标偏离了道路。这是无法接受的。我试图做的是实现 K
我是一名优秀的程序员,十分优秀!