簡體   English   中英

特定位置的相機。 three.js所

[英]camera in position specific. three.js

我想將相機放置在特定位置,然后我要做的是移動相機並將其調整到您想知道坐標的位置,將其放置在“更新”中

console.log (camera.position);

然后我編寫這些值以在例如下次運行我的應用程序時定位攝像機。 在console.log中的值是

x: 2.4457938219139463, y: 0, z: 17.37913738929295

然后在我的代碼中設置新值。

camera.position.set (2.4457938219139463, 0, 17.37913738929295)
camera.lookAt (scene.position);

但是,位置與先前放置的位置不同,相機看起來或多或少地位於近點,但位於靜止點上方的那一點

問題是javascript浮點精度-如果是32OS,則點后為7位,如果是64OS,則為點后13位。 因此,您不需要使用超過7位的精度,而需要使用舍入。 像這樣lat.toFixed(7)/1;

看到以下輸出:

var x = 2.44579380000034;
var y = 0.0000000000001;

console.log(x);
console.log(x+y);

var x = 0.1;
console.log(x);
console.log(x*x);
console.log(x*x*x);
console.log(x*x*x*x);
console.log(x*x*x*x*x);
console.log(x*x*x*x*x*x);

產量

2.44579380000034
2.4457938000004398

0.1
0.010000000000000002
0.0010000000000000002
0.00010000000000000003
0.000010000000000000004
0.0000010000000000000004

http://jsfiddle.net/ssznwn4m/

PS https://zh.wikipedia.org/wiki/Double-precision_floating-point_format

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM