仅供参考:随机==伪随机
A.当生成均匀随机数时,我可以指定范围,即:
(Math.random()-Math.random())*10+5
//generates numbers between -5 and 15
Run Code Online (Sandbox Code Playgroud)
B.使用高斯式正态随机性版本生成一组随机值:
//pass in the mean and standard deviation
function randomNorm(mean, stdev) {
return Math.round((Math.random()*2-1)+(Math.random()*2-1)+(Math.random()*2-1))*stdev+mean);
}
//using the following values:
{
mean:400,
standard_deviation:1
//results in a range of 397-403, or +-range of 3
},
{
mean:400,
standard_deviation:10
//results in a range of 372-429, or +-range of 30
},
{
mean:400,
standard_deviation:25
//results in a range of 326-471, or +-range of 75
}
Run Code Online (Sandbox Code Playgroud)
每一个给我一系列近似standard_deviation*(+ - 3)(假设我让程序运行时间更长).
C.我可以按如下方式计算这个范围:
笔: https: //codepen.io/jaredstanley/pen/gvmNye
var canvas = document.getElementById('c');
var ctx = canvas.getContext("2d");
var centerw = canvas.width/2;
var centerh = canvas.height/2;
var sq_w = 80;
//
ctx.beginPath();
//draw rectangle
ctx.rect(this.centerw-(sq_w/2), 0,sq_w, canvas.height);
//draw circle
ctx.arc(this.centerw, this.centerh, 185, 0, Math.PI * 2, true);
//fill
ctx.fill();
Run Code Online (Sandbox Code Playgroud)
两个形状都绘制出来,但形状的交集是空白的。
想要拥有一个单一的填充形状,但得到以下结果:[
要求:不能使用CanvasRenderingContext2D.globalCompositeOperation,因为我正在将其用于其他用途;这需要用作单个形状,以便我可以使用该形状来...clip()。
注意:当使用两个 rect() 调用时,它可以工作,当使用两个 arc() 调用时,它可以工作,但混合它们似乎会导致问题。
看起来应该很容易,但我很困惑,缺少一些我认为基本的东西。谢谢!
我一直使用 .obj 文件将模型加载到 Three.js 中。我在某处读到,首选方法是现在使用 .gltf。
当我开始这样做时,我意识到虽然使用 gltf 加载对象看起来确实很简单,但一旦对象放入内部, obj 似乎会更加灵活。
像:
这些似乎都很难/在 gltf 中不受支持,您可以使用 obj 轻松完成它们。
gltf具体有什么好处?我假设文件大小,但似乎你必须放弃很多控制才能获得这种好处。