Prevent Camera from Rotating Outside of Set Time Frame

In my current VR game project using THREE.js, I am attempting to constrain the camera rotation on the y-axis within specific angles to prevent users from seeing behind them. Instead, they should only be able to look left and right. Although I am uncertain about how the coordinate system functions for the camera, a visual representation of my goal can be seen in this image:

https://i.sstatic.net/V0lxZ.png

Since the threeVR tool lacks max and min settings, I am manually trying to lock the camera's rotation within the `update` function of my program. Unfortunately, I am unsure of the correct approach to achieve this.

Answer №1

Is it possible to restrict the angle by setting boundaries within the update loop?

camera.rotation.y = Math.max(startAngle, Math.min(endAngle, camera.rotation.y));

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing Grunt-express and static routes: The server must include a method named 'listen' that functions in the same way as http.Server.listen

I've been working on setting up Grunt to launch my express server using grunt-express. Even after reviewing the documentation and a related Stack Overflow post, I'm still having trouble figuring it out. I've tested various configurations in ...

Exploring how to integrate a jQuery ajax request within Javascript's XmlHttpRequest technique

My current setup involves an ajax call structured like this: var data = {"name":"John Doe"} $.ajax({ dataType : "jsonp", contentType: "application/json; charset=utf-8", data : JSON.stringify(data), success : function(result) { alert(result.success); // re ...

Ensure the page is always updated by automatically refreshing it with JavaScript each time it

I'm currently working on a web application that makes use of JQuery. Within my javascript code, there's a function triggered by an onclick event in the HTML which executes this line: $('#secondPage').load('pages/calendar.html&apos ...

Is it appropriate to use localStorage in the createSlice "reducers" parameter of React Redux Toolkit?

I'm working on implementing a basic favorites list feature. Currently, there is no backend functionality in place so this will be stored in the localStorage. It might potentially switch to an API call in the future. Would it be considered acceptable ...

Tips for showing outcome in the main window after form submission in a showModelDialog box through ajax

I find myself in a challenging situation where the parent window triggers a showModalDialog box to submit a form. Upon submission, the form is sent to a struts2 action which performs some tasks and then redirects back to the parent page, causing a full ref ...

Steps to create a zigzagging line connecting two elements

Is it possible to create a wavy line connecting two elements in HTML while making them appear connected because of the line? I want it to look something like this: Take a look at the image here The HTML elements will be structured as follows: <style&g ...

php utilizing javascript to generate encrypted data for a hidden file

Within my MVC application, I have implemented Raty for rating images. Below is the code snippet: <div class="container"> <form method="post" class='form' role='form' action="?section=photo&view=addVote"> <input t ...

The function is not explicitly declared within the instance, yet it is being cited during the rendering process in a .vue

import PageNav from '@/components/PageNav.vue'; import PageFooter from '@/components/PageFooter.vue'; export default { name: 'Groups', components: { PageNav, PageFooter, }, data() { return { groups: ...

Is there a way to modify the dimensions of this container? (CSS)

After performing a search and clicking on a result, a white bubble pops up on the map. I am looking to use CSS to make this bubble smaller as it is currently too large. Can anyone provide guidance on how to achieve this? ...

Is there anyone who can assist me with integrating leap controls into TrackballControls.js?

Exploring the world of Leap Motion controls and seeking guidance on integrating Leap controls into Trackballcontrols.js. You can find the link provided below for TrackballControls.js: ...

Javascript function that adjusts dynamically

I have arrays within an array that are created and passed as arguments in a method of an object like this: myObject.method([ { id: "mystring", myfun: function(g) { return 'Value: ' + g.value + g.rows[0][&ap ...

Enhancing the appearance of dropdown menus for WooCommerce Variable products with custom CSS styling

I currently have a Wordpress website with WooCommerce and several variable products. Each product's variation has a dropdown menu that displays different options when clicked. My main concern is how to customize the appearance of these dropdown menus ...

When rotating a Mesh in Threejs with the PhysiJs physics engine, the updates are not properly applied

As a novice in Threejs, I have created a Box Mesh and a Sphere Mesh and added physics using physiJs. My goal is to hit the ball as the Box Mesh rotates and passes through it. However, the ball is not being hit when the box mesh rotates, suggesting that the ...

Automatic execution of expressions in browserify upon initialization

Utilizing browserify alongside node.js allows me to utilize require() in my JavaScript files. Within my game.js file, I have the following code: var game = new Phaser.Game(800, 600, Phaser.AUTO, 'snakeGame'); var menuState = require('./me ...

Attempting to assign an active class to a menu item

I've been struggling for 2 hours to create a dynamic menu, but unfortunately, I haven't had any success. That's why I decided to seek some assistance. I have an HTML menu along with some JS and CSS... $(function() { var pgurl = window.l ...

Encountered a type error while attempting to render and define table columns within a material table component in

Hey there! I'm currently using the Material table to create a table view, and here are the columns that I have defined: const columns: TableColumn[] = [ { title: 'TYPE', field: 'type_of_action', highligh ...

Storing binary data uploaded via AJAX in PHP on the server is essential for maintaining

I successfully imported a .png image file as an Array Buffer. var readSingleFile = function(e) { var file = e.target.files[0]; if (!file) { return; } var reader = new FileReader(); ...

Utilizing FontAwsome Icons within a CSS2DObject using VueJS

As an aspiring coder, I am determined to display a FontAwsome User Icon similar to the example here within a VueJS component. I have diligently attempted to replicate the same example showcased in this codesandbox, exploring the two approaches recommended ...

The jQuery Date Picker popup appears beneath a different element on the webpage

The Datepicker is functioning properly. https://i.sstatic.net/DKQcq.png Issue with Datepicker overlapping search box with auto-complete feature. https://i.sstatic.net/pj6T7.png I'm baffled as to why my JQuery Datepicker works flawlessly in most ca ...

When a fresh tile is loaded in Mapbox, an event is triggered

As I work with the Mapbox GL JS API to manipulate maps, I find myself wondering if there is an event that can inform me whenever a new tile HTTP request is made. My code snippet looks like this: map.on("dataloading", e => { if(e.dataType ...