A帧轨道控制可重置相机位置

时间:2019-07-26 11:43:27

标签: javascript aframe virtual-reality

我正在使用超帧的轨道控制(https://github.com/supermedium/superframe/tree/master/components/orbit-controls),并且有一个场景,其中包含两个实体,用户可以通过按钮来打开/关闭。每当用户单击按钮时,我都希望将相机位置重置为其初始状态。

我已经尝试过像通常不使用轨道控制那样重置摄像机的世界位置,但是到目前为止我还没有碰到任何运气。 这是情况的摘要:https://jsfiddle.net/e7akdgf1/5/

package url_request;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;


public class Send_Get_Basic_Auth {

    public static void main(String[] args) {

        String usernameColonPassword = "uname:pass";
        String basicAuthPayload = "Basic " + Base64.getEncoder().encodeToString(usernameColonPassword.getBytes());

        BufferedReader httpResponseReader = null;
        try {
            // Connect to the web server endpoint
            URL serverUrl = new URL("https://ucf6-zfon-fa-ext.oracledemos.com/hcmRestApi/scim/Users");
            HttpURLConnection urlConnection = (HttpURLConnection) serverUrl.openConnection();

            // Set HTTP method as GET
            urlConnection.setRequestMethod("GET");

            // Include the HTTP Basic Authentication payload
            urlConnection.addRequestProperty("Authorization", basicAuthPayload);

            // Read response from web server, which will trigger HTTP Basic Authentication request to be sent.
            httpResponseReader =
                    new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
            String lineRead;
            while((lineRead = httpResponseReader.readLine()) != null) {
                System.out.println(lineRead);
            }

        } catch (IOException ioe) {
            ioe.printStackTrace();
        } finally {

            if (httpResponseReader != null) {
                try {
                    httpResponseReader.close();
                } catch (IOException ioe) {
                    // Close quietly
                }
            }
        }

    }

}

1 个答案:

答案 0 :(得分:1)

您可以像这样更改位置

// check what setting the initial position does in the source code 
cam.getObject3D('camera').position.set(0, 0, 5)

提琴here


有一个

this.el.components['orbit-controls'].controls.reset()

在源代码中,但是我没有运气。