鿍奍;: ãã®æ©è½ã¯éæ¨å¥¨ã«ãªãã¾ãããã¾ã 対å¿ãã¦ãããã©ã¦ã¶ã¼ãããããããã¾ãããããã§ã«é¢é£ããã¦ã§ãæ¨æºããåé¤ããã¦ããããåé¤ã®æç¶ãä¸ã§ããããäºææ§ã®ããã ãã«æ®ããã¦ããå¯è½æ§ãããã¾ãã使ç¨ãé¿ããã§ããã°æ¢åã®ã³ã¼ãã¯æ´æ°ãã¦ãã ããããã®ãã¼ã¸ã®ä¸é¨ã«ããäºææ§ä¸è¦§è¡¨ãè¦ã¦å¤æãã¦ãã ããããã®æ©è½ã¯çªç¶åä½ããªããªãå¯è½æ§ããããã¨ã«æ³¨æãã¦ãã ããã
requestAnimationFrame()
㯠VRDisplay
ã¤ã³ã¿ã¼ãã§ã¤ã¹ã®ã¡ã½ããã§ã Window.requestAnimationFrame
ã®ç¹å¥ãªå®è£
ã§ãï¼ãã®ã¡ã½ãã㯠VRDisplay
ãã¬ã³ããªã³ã°ããã¦ããéãæ°ãããã¬ã¼ã ãæ¥ããã³ã«å¼ã³åºãããã³ã¼ã«ããã¯é¢æ°ãå«ã¿ã¾ãã
ã¡ã¢: ãã®ããããã£ã¯ãå¤ã WebVR API ã®ä¸é¨ã§ããã WebXR Device APIã«ç½®ãæãããã¾ããã
VRDisplay
ãã·ã¼ã³ã表示ãã¦ããªãã¨ãã¯ã Window.requestAnimationFrame
ã¨ç価ã«åä½ãã¾ããVRDisplay
ã表示ããã¦ããå ´åã¯ããã¤ãã£ãã®ãªãã¬ãã·ã¥ã¬ã¼ãã§ã³ã¼ã«ããã¯ãå¼ã³åºããã¾ããrequestAnimationFrame(callback);
弿°
callback
VRDisplay
ã®è¡¨ç¤ºã®æ°ãããã¬ã¼ã ãæç»ããããã³ã«å¼ã³åºãããã³ã¼ã«ããã¯é¢æ°ã§ãã
requestAnimationFrame()
å¼ã³åºãã®ãã³ãã«ã表ã long ã§ããããã VRDisplay.cancelAnimationFrame()
å¼ã³åºãã«æ¸¡ãã¨ãã³ã¼ã«ããã¯ã®ç»é²ãè§£é¤ããã¾ãã
var frameData = new VRFrameData();
var vrDisplay;
navigator.getVRDisplays().then(function(displays) {
vrDisplay = displays[0];
console.log('Display found');
// Starting the presentation when the button is clicked: It can only be called in response to a user gesture
btn.addEventListener('click', function() {
vrDisplay.requestPresent([{ source: canvas }]).then(function() {
drawVRScene();
});
});
});
// WebVR: Draw the scene for the WebVR display.
function drawVRScene() {
// WebVR: Request the next frame of the animation
vrSceneFrame = vrDisplay.requestAnimationFrame(drawVRScene);
// Populate frameData with the data of the next frame to display
vrDisplay.getFrameData(frameData);
// You can get the position, orientation, etc. of the display from the current frame's pose
var curFramePose = frameData.pose;
var curPos = curFramePose.position;
var curOrient = curFramePose.orientation;
// Clear the canvas before we start drawing on it.
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
// WebVR: Create the required projection and view matrix locations needed
// for passing into the uniformMatrix4fv methods below
var projectionMatrixLocation = gl.getUniformLocation(shaderProgram, "projMatrix");
var viewMatrixLocation = gl.getUniformLocation(shaderProgram, "viewMatrix");
// WebVR: Render the left eye's view to the left half of the canvas
gl.viewport(0, 0, canvas.width * 0.5, canvas.height);
gl.uniformMatrix4fv(projectionMatrixLocation, false, frameData.leftProjectionMatrix);
gl.uniformMatrix4fv(viewMatrixLocation, false, frameData.leftViewMatrix);
drawGeometry();
// WebVR: Render the right eye's view to the right half of the canvas
gl.viewport(canvas.width * 0.5, 0, canvas.width * 0.5, canvas.height);
gl.uniformMatrix4fv(projectionMatrixLocation, false, frameData.rightProjectionMatrix);
gl.uniformMatrix4fv(viewMatrixLocation, false, frameData.rightViewMatrix);
drawGeometry();
function drawGeometry() {
// draw the view for each eye
}
...
// WebVR: Indicate that we are ready to present the rendered frame to the VR display
vrDisplay.submitFrame();
}
ã¡ã¢: ãã®å®å ¨ãªã³ã¼ã㯠raw-webgl-example ã§è¦ããã¨ãã§ãã¾ãã
仿§æ¸ãã®ã¤ã³ã¿ã¼ãã§ã¤ã¹ã¯ãå¤ã WebVR API ã®ä¸é¨ã§ãããã WebXR Device API ã«ç½®ãæãããã¾ãããæ¨æºåãããäºå®ã¯ããã¾ããã
ãã¹ã¦ã®ãã©ã¦ã¶ã¼ãæ°ãã WebXR API ãå®è£ ããã¾ã§ããã¹ã¦ã®ãã©ã¦ã¶ã¼ã§åä½ãã WebXR ã¢ããªã±ã¼ã·ã§ã³ãéçºããã«ã¯ãA-Frame ã Babylon.js ã Three.js ãªã©ã®ãã¬ã¼ã ã¯ã¼ã¯ãå©ç¨ããããããªãã£ã«ãå©ç¨ãããããã¨è¯ãã§ããã [1]ã
ãã©ã¦ã¶ã¼ã®äºææ§ é¢é£æ å ±RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4