在摄影机前面的三个集合对象在移动式摄影车

时间:2017-06-15 05:10:58

标签: 3d three.js quaternions 360-virtual-reality

我正在使用

将物体放在相机前面
$connect = mysqli_connect($host,$user,$password,$database) or die ("Couldn't connect database");
if(isset($_GET['id']) && !empty($_GET['id'])){

 $currentID = $_GET['id'];
$sql    =   "SELECT * FROM ad WHERE id=$currentID";
$result =   mysqli_query($connect,$sql) or die("Couldn't execute query.");
$row=   mysqli_fetch_array($result);
extract($row);
echo    "<div id='ad_header'>";
echo    "<h2>
 $training_name</h2>";
echo    "<p>Trainer/Training Center:</p> $trainer_name ";
echo    "<p>Training Date(s):  </p>$training_start - $training_end";
echo    "<p>Registration starts:  </p>$reg_start";
echo "<p>Phone: </p>$mobile";
if($email!=''){echo "<p>Email: </p><a href='mailto:$email'>$email</a>";}
if($website!=''){echo "<p>Web Site: </p><a href='http://$website' target='_blank'>$website</a>";}

echo    "</br>";

echo    "</div>";
echo    "<div id='ad_main'>";

echo    "<p>Training details:</p> </br>"?> <form action="<?php echo htmlspecialchars('personal_ad_details.php')?><?php echo "?id=".$currentID?>" method="post"> <textarea  style="position:relative; left:0%" rows="10" cols="25"  name="Telim_Melumatlari" ><?php echo $training_details; ?></textarea>
<?php 
echo    "</div>";

}
?>
<input style="margin:10px" type="submit" name="update" value="UPDATE"></form>

<?php
if(isset($_POST['update']))
{

    include('misc.inc');


    $connect    =   mysqli_connect($host,$user,$password,$database)
                    or die ("Couldn't connect to database.");
    $sql        =   "UPDATE ad SET training_details='$_POST[Telim_Melumatlari]' WHERE id=$currentID ";
    mysqli_query($connect,$sql) or die("Couldn't execute query");
    $url="personal_ad_list.php";
    echo '<script type="text/javascript">'; 
          echo 'window.location.href="'.$url.'";'; 
          echo '</script>'; 
          echo '<noscript>'; 
          echo '<meta http-equiv="refresh" content="0;url='.$url.'" />'; 
          echo '</noscript>'; exit;

}

?>
<form action="<?php echo htmlspecialchars('personal_ad_details.php')?><?php echo "?id=".$currentID?>" onSubmit="return confirm('Are you sure you want to delete the Ad?');" method="post"><input style="margin:10px; background-color:red" type="submit" name="delete"  value="DELETE AD"></form>
<?php
if(isset($_POST['delete']))
{

    include('misc.inc');


    $connect    =   mysqli_connect($host,$user,$password,$database)
                    or die ("Couldn't connect to database.");
    $sql        =   "DELETE FROM ad WHERE id=$currentID ";
    mysqli_query($connect,$sql) or die("Couldn't execute query");
    $url="personal_ad_list.php";
    echo '<script type="text/javascript">'; 
          echo 'window.location.href="'.$url.'";'; 
          echo '</script>'; 
          echo '<noscript>'; 
          echo '<meta http-equiv="refresh" content="0;url='.$url.'" />'; 
          echo '</noscript>'; exit;

}

?>

这非常有效。

我现在不得不旋转相机(用于VR视频播放器)来设置它的起始位置并且这样做仍然可以使用WebVR样板,我将视频添加到小车对象并旋转它。

        var dist = -100;
        var vec = new THREE.Vector3( 0,  0, dist );
        vec.applyQuaternion( camera.quaternion );
        object.position.copy( vec );
        object.lookAt(camera.position);

现在物体不在相机前面。我正在尝试将小车旋转应用于矢量以考虑该角度。

    dolly = new THREE.Group();
    dolly.position.set( 0, 0, 0 );
    scene.add( dolly );

    camera.up.set( 0, 1, 0 );
    dolly.add( camera );

这主要适用于相机是特定角度但有时不是,并且物体也在其x轴上旋转。

我假设 var rotation = new THREE.Euler().setFromQuaternion( camera.quaternion, camera.rotation.order ); rotation.y += dolly.rotation.y; var quat = new THREE.Quaternion().setFromEuler(rotation, camera.rotation.order); vec.applyQuaternion( quat ); ;是错的,但我不确定合并数字的更好方法。

1 个答案:

答案 0 :(得分:0)

@WestLangleys在这里回答 three.js tween object to front of camera

回答了我的问题

      var pLocal = new THREE.Vector3( 0, 0, dist );

        var target = pLocal.applyMatrix4( camera.matrixWorld );

        object.position.copy( target );
        object.lookAt(camera.position);