我不确定这是否是正确的问题,但我的devicemotion
脚本有问题.
我有一些代码在加载页面时运行,以检查是否有陀螺仪可用.我通过以下方式执行此操作:
function check_user_hardware(){
if (mobile_size <= 600) {
hidden = true;
}
console.log("checking hardware");
giro_timer = setTimeout(update_gyro_value, 30);
window.addEventListener("devicemotion", function(event){
console.log("device motion?");
if(event.rotationRate.alpha || event.rotationRate.beta || event.rotationRate.gamma){
calculate_rotation_mesh_pos(event.rotationRate.beta, event.rotationRate.gamma);
if (!gyroscope) {
gyroscope = true;
console.log("gyroscope here");
current_interaction_mode = 'gyroscope_option';
set_user_ui_elements();
}
}else{
followMouse = true;
console.log("no gyroscope here");
current_interaction_mode = 'followMouse_option';
set_user_ui_elements();
window.addEventListener('mousemove', get_user_mouse_pos);
}
});
}
Run Code Online (Sandbox Code Playgroud)
这几周前工作得很好......但现在它不再工作了......当我检查控制台时,我看到以下打印件:
checking hardware
Run Code Online (Sandbox Code Playgroud)
那就是..为什么我的devicemotion事件没有被解雇?即使在我的网站上使用基本的SSL加密,它也无法正常工作?我需要某种特殊的SSL加密吗?
怎么了??
欢迎所有建议!
如果需要更多信息,我很乐意提供.
你可以在这里看到有问题的网站:gravient.thomashoek.com
我试图brew install python3
在Mac上安装do ,但我不断收到以下错误:
这是第一个错误:
没有这样的文件或目录@ dir_chdir-/ usr / local / Cellar
然后过一会儿我得到这个错误:
子进程中发生异常:Errno :: EPERM:不允许操作@ dir_s_mkdir-/ usr / local / Cellar
我已经跑brew update
那么brew doctor
的brew cleanup
但不断收到错误。
我还检查了xcode是否是最新的,但是根据appstore的介绍,我所有的应用程序都是最新的。
我该如何解决这个问题?
PS我尝试从brew安装其他软件包时也会出现这些错误。
我正在寻找有关浏览器如何在屏幕上呈现/绘制实际像素的解释。
我发现这个答案包含关于浏览器如何从 html 和 css 到屏幕上的实际表示的伟大图像。
但这并没有向我解释实际的绘画步骤是如何实现的。那么实际的框架树是如何绘制的呢?
它是用顶点缓冲区和着色器完成的吗?
例如:一个 div 可以通过创建一个四边形来渲染,然后用一个着色器渲染这个四边形,例如根据样式向 div 添加边框、圆角等?
或者是否使用了其他技术?
这将如何处理长文本?为每个字母生成一个四边形听起来不是很高效?
如果需要额外的上下文或说明,请告诉我!
我有一段代码,我有两个按钮,当我按下一个按钮时,我想要一个div在y轴上翻转,当我按下另一个按钮时,我希望相同的div在x轴上翻转.即使前一个翻转位于x轴上,当我使用y轴按钮时,这也可以正常工作.但是当我想从y轴切换到x轴时,我需要按两次x按钮,因为第一次没有任何反应.
所以期望的行为是:
单击y按钮在y轴上翻转div.
单击x按钮在x轴上翻转div.
目前的行为是:
单击y按钮div翻转y轴.
单击x按钮没有任何反应单击x按钮再次在x轴上翻转div.
我不知道问题是什么,这是我到目前为止所做的最好的.所有帮助表示赞赏.
var ax = 'x';
$(document).ready(function() {
$('#card').flip({
trigger: 'manual',
axis: 'x'
});
$('#left').click(function() {
if (ax != 'y') {
$("#card").flip({
axis: 'y'
});
$("#card").on('flip:change', function() {
$('#card').flip('toggle');
});
ax = 'y';
} else {
$("#card").flip('toggle');
}
});
$('#right').click(function() {
if (ax != 'x') {
$("#card").flip({
axis: 'x'
});
$("#card").on('flip:change', function() {
$('#card').flip('toggle');
});
ax = 'x';
} else {
$("#card").flip('toggle');
}
});
});
Run Code Online (Sandbox Code Playgroud)
#card {
position: fixed;
left: 50px;
top: 50px;
width: …
Run Code Online (Sandbox Code Playgroud)我正在尝试用 C# 制作一个小型 GUI 库,但是在对矩阵变换进行了一些研究之后,我发现我需要一个 Matrix3x3 来存储 Vector2 的旋转、缩放和平移。但在 C# System.Numerics 中只有 Matrix3x2 或 Matrix4x4?我可以使用其中之一吗?如果是这样我该怎么办?为什么标准库中没有Matrix3x3?
我对矩阵和向量编程非常陌生,如果这是一个愚蠢的问题,我很抱歉。
提前致谢。
我有这段 css 来设置网格的列:
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
Run Code Online (Sandbox Code Playgroud)
这工作正常,但我想扩展它,这样我就可以使用最大像素数的百分比值,如下所示:
grid-template-columns: repeat(auto-fill, minmax(minmax(15%, 180px), 1fr));
Run Code Online (Sandbox Code Playgroud)
但这只给了我 100% 宽度的列。这绝对不是我想要的。
我该如何实现这个目标?
我知道您可以在JavaScript中执行以下操作,以在一个内衬中切换布尔值。
var toggle = false;
if(true) toggle != toggle;
Run Code Online (Sandbox Code Playgroud)
但这也可以用字符串吗?我知道可以通过某些if语句来完成。但是有可能在一个内衬中做到吗?像这样的东西:
var string_toggle = "CAT";
if(true) "CAT" = "ESP" || "ESP" = "CAT";
Run Code Online (Sandbox Code Playgroud)
如果不清楚我在问什么,请告诉我,以便我改善问题。
我有一个类,我想在编辑器中更改其属性。所以我创建了我的类 System.Serializable 并公开了我希望能够更改的变量。
像这样:
[System.Serializable]
public class UIOptionsRing
{
public float Radius, DistanceBetweenPoints, StartOffset, GapInDegrees;
public int? GapAfterElementNumer = 3; //this var doesnt show up
public Vector3 CircleCenter;
public GameObject CircleElementsContainer;
}
Run Code Online (Sandbox Code Playgroud)
但我遇到的问题是 GapAfterElementNumer 没有显示在编辑器中,而所有其他字段都是。我怎样才能让它int?
也显示出来?
我有以下类和接口定义:
import { Component } from 'react';
type KeysMatching<T, V> = {
[K in keyof T]-?: T[K] extends V ? K : never
}[keyof T];
interface SearchListProps<T extends object, K extends KeysMatching<T, string>> {
data: T[];
sort_and_filter_key: K;
}
class SearchList<ItemDataT extends object, K extends KeysMatching<ItemDataT, string>> extends Component<SearchListProps<ItemDataT, K>> {
constructor(props: SearchListProps<ItemDataT, K>) {
super(props);
const value = props.data[0][props.sort_and_filter_key]; // ItemDataT[K] -> should be string
}
}
// exmple case:
interface DataExample {
name: string,
city: string,
id: number, …
Run Code Online (Sandbox Code Playgroud)