2017-01-31 5 views
1

three.jsを使用して、表示可能なものと同様の効果を得るにはどうすればいいですか?herethree.jsl - インタラクティブなマウス制御360画像の作成方法

私たちが見た他の解決策は、カメラの角度を制御するためにドラッグを&ドロップする必要があるようです - カメラが指し示しているマウスコントロールの位置を探しています。たとえば、左上隅にあるマウスは常にカメラを同じ場所に向けます。これはオープンソースの実装ですか?

+1

このサイトのコードは質問されていませんが、このthree.jsの例であるhttps:// threejsのバックグラウンドコードの組み合わせになります.org/examples /#webgl_materials_cubemap_refractionとhistory.jsとjqueryスクロールスクロールプラグインを組み合わせたものです。 3つのサンプルコードを見直す価値があります。 – Sam0

答えて

2

複雑ではありません。

あなたはXY軸、画面上のマウスの位置を聞いて、0-1に再計算することができます。この後

var mouse = new THREE.Vector2(); 

function onDocumentMouseMove(event) { 
     event.preventDefault(); 
     mouse.x = (event.clientX/window.innerWidth) * 2 - 1; 
     mouse.y = - (event.clientY/window.innerHeight) * 2 + 1;  
} 

をあなたが計算し、カメラの回転RAD設定することができます:あなたは、

function onDocumentMouseMove(event) { 
     event.preventDefault(); 
     mouse.x = (event.clientX/window.innerWidth) * 2 - 1; 
     mouse.y = - (event.clientY/window.innerHeight) * 2 + 1; 

     //default_x = your default camera x rotation 
     //default_y = your default camera y rotation 
     //s = sensitivity coeficient default 1 for 360° rotation, 0.1 for smaller angle 
     camera.rotation.x = (default_x*mouse.x)*s; 
     camera.rotation.y = (default_y*mouse.y)*s; 
} 

と確認をテクスチャで球の内側にカメラを置くだけでいいです...

+0

ありがとうございます - 同時にデバイスの動きを統合する方法はありますか?デバイスのみの実装がここに表示されています:http://richtr.github.io/three.js/examples/misc_controls_deviceorientation.html – Sekoul

+0

はい、しかし、新しい質問を投稿する必要があります – Martin

関連する問題