Restrict the vertical camera rotation

Utilizing JSModeler for showcasing OBJ files. The software integrates THREE.JS and generates a PerspectiveCamera. My goal is to restrict the camera's Y-axis movement to prevent it from going beneath the object. While I am familiar with achieving this using THREE.OrbitControls, it seems incompatible with JSModeler. Is there a method to directly oversee the camera's movements? Appreciate any advice.

Answer №1

When using jsmodeler, it creates its own unique set of controls that are stored within the JSM.navigation object.

viewer = new JSM.ThreeViewer ();
camera_object = viewer.navigation.camera

The drawLoop function is responsible for taking values from viewer.navigation.camera and displaying them on the canvas. By modifying the values in viewer.navigation.camera and then calling drawCallback(), you can see these changes reflected visually.

viewer.navigation.camera.eye.x = 1; // Edit this value as needed
viewer.navigation.camera.eye.y = 1; // Modify this value as desired
viewer.navigation.camera.eye.z = 1; // Adjust this value as necessary
viewer.navigation.drawCallback();

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

Fixing Half Screen Sidebars

I have a query regarding my coding problem. I am trying to create two pop-ups that occupy half of each screen. As I am new to JavaScript and jQuery, I want to ensure that I am doing it correctly. Is there a way for the left side to slide out from the left ...

Updating the cx and cy attributes dynamically based on screen size changes in D3.js integrated with React

I'm facing an issue with the dynamic adjustment of cx and cy attributes based on window.innerHeight/window.innerWidth. I am passing window.innerHeight/window.innerWidth as height/width to the component, and here is the implementation: const UpdatedCha ...

When the submit button is clicked, I wish to receive a success notification. After clicking "OK", I should be directed to a new PHP page

When submitting data to the database in PHP, I want to display an alert confirming successful submission. After clicking OK on the alert, I aim to redirect to a new page showing the submitted data. However, I am having trouble as I am getting redirected ...

Modify the appearance of a specific side of a CircleGeometry shape over a set period of time

As a novice in the world of Three.js, I recently completed a crash course and now have a basic understanding of its capabilities. I managed to create a rotating disc on my website with my own image/texture, but I would like to change the texture/image on ...

Using asynchronous method calls to create arrays in ES6

In my current task, I am working on completing the following method: collectAllResults: function (callback) { this.getTotalCount((count) => { // the count typically is 5 let results = [] for (var i = 0; i < count; i++) { th ...

jQuery Draggable Slider Scale

Seeking a draggable ruler (meaning it scrolls on double click) similar to the one showcased in the following link: I would greatly appreciate any assistance in finding a library that can provide this same functionality. View image here: https://i.sstatic ...

The issue of Gimbal Lock in rotation within Three JS

It appears that the quaternion rotation in Three JS can still experience Gimbal Lock. To replicate the issue, follow these steps: 1) Go to the Three JS Editor. 2) Add a Cylinder and set the z value to 1.57 (the middle text box for rotation). 3) Try chang ...

Is the JSON data missing from the POST request?

I'm having trouble inserting data into the database using a POST request. Here is how I'm making the request: 127.0.0.1:3000/api/users?fname=asd&lname=edc&<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1d7870 ...

Is it possible for me to open an object URL in Internet Explorer?

Using Blob and URL.createObjectURL(), I have obtained an "object URL" (blob:) for some binary PDF data. In Chrome and FireFox, when I add an <A/> link HTML element with the programmatically set href attribute as the object URL, clicking on the link ...

What could be causing the hang when attempting to insert a script using Bookshelf.js?

Can anyone help me understand why the Node.js script refuses to exit? // myscript.js var Model = bookshelf.Model.extend({ tableName: 'models' }); var m = Model.forge({name: 'hello'}); m.save(); console.log("End"); Even after running ...

Why doesn't WebStorm display TypeScript inspection errors in real-time?

I'm currently utilizing WebStorm 2017.2.4 in conjunction with Angular 4.3 - I am facing an issue where TypeScript errors are not being displayed: https://i.sstatic.net/pcLQX.png Query How can I enable real-time inspections to occur immediately? (I ...

How to dynamically apply the orderBy filter in AngularJS

Attempting to input ordering criteria from a text box and dynamically order the content. The current code is functioning properly, but when attempting to change: orderBy:'age' to orderBy:'{{criteria}}' the functionality breaks. Her ...

Adjusting the size of a popup window using resizeTo method functions properly when entering commands directly into the console, but encounters issues when executed within

I have researched this issue extensively and attempted various solutions, but I am still unable to grasp why resizeTo is not functioning in my particular scenario. I discovered that resizeTo works when the popup is generated by window.open, and I followed ...

When displaying multiple images using HTML5 Canvas in a for loop, only the final set of images is drawn

I'm facing an issue with drawing images using an image loader inside a for loop. The images are only being drawn on the last iteration. The console is not displaying "draw -> 0" or "draw -> 1", it only shows "draw -> 2" Any assistance would ...

What are some effective ways to prevent mistakes when using three.js?

I am working on a basic three.js sample using Visual Studio Code with live preview server without using node.js. HTML CODE: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Person Jumping in Three.js&l ...

Ignore missing values when performing an upsert operation

I'm currently utilizing pg-promise to manage my Postgres queries, but I've hit a roadblock with the following query conundrum: My goal is to develop a single method that can batch upsert multiple rows simultaneously. Here's the code snippet ...

Does this Spread Operator Usage Check Out?

Upon reviewing Angular's API documentation, I came across the declaration for the clone() method in HttpRequest as follows: clone(update: { headers?: HttpHeaders; reportProgress?: boolean; params?: HttpParams; responseType?: "arraybuffer" ...

What is the best way to refresh my view after loading a new JavaScript file that is required to generate the correct HTML elements?

When I use $http.get() to retrieve my model $scope.workoutData, the object appears fine in the console.log(data) output. However, my view does not load as if it has received the model. Once the model is updated, I also need to trigger the owlCarousel() fun ...

Simply drag and drop the image from your browser window into the file input

Is there a way to drag an image from a browser window into a file input that I developed? Looking for assistance in creating an event that allows me to get the image when dragging it to an input. While I have successfully created an event to obtain the i ...

Showing both SubTotal and Total simultaneously in a JavaScript powered interface

Recently diving into Javasript, I came across the code snippet below from a different source that I tweaked to suit my needs. My goal is to show the subtotal in the third column for each benefit while displaying the total of the entire form. However, I&apo ...