What is the size of objects in Three JS (specifically PlaneGeometry)?

I am curious about the dimensions:

    var geometry = new THREE.PlaneGeometry(50, 50);

    var plane = new THREE.Mesh(geometry, material);

    plane.doubleSided = true;
    plane.tile = tile;

My question is: are the dimensions of PlaneGeometry in pixels? If my canvas is around 500x500, will it end up being less than 50x50?

PS> Another question, how can I determine the size of an element once it's added to the scene? Thank you!

Answer №1

When we talk about 50x50, it's not referring to pixels but rather "units". These units can be defined based on the size of other objects in the environment.

If you need to resize an object in a controlled manner, you can achieve this by:

let geometry = new THREE.PlaneGeometry(1, 1);
let plane = new THREE.Mesh(geometry, material);

plane.scale.x = 50;
plane.scale.y = 50;

Answer №2

PS> I have another question: How can I determine the size of an element after it has been added to the scene? Thank you!

I've been using a thingiview js plugin and discovered that when an object is added to the scene, you can enclose it within a cube defined by the following coordinates:

p0 = [minx, miny,minz], p1 =[minx,miny,maxz], ..., p7 =[maxx, maxy,maxz];

, where:

var minx = object.geometry.min_x;
 var maxz = object.geometry.max_z;

and so on.

PS: I realize this question may be dated, but I struggled to find information on how to obtain the dimensions of an added object, hence my inquiry.

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

Retrieve JSON data with a GET request and populate an array with the results before returning

Recently, I delved into using the mobile framework LungoJS. Although my experience with JavaScript is limited, I am determined to make changes to the following original code: ORIGINAL.JS var mock = function() { var mock = []; for (var i=1 ...

immutable chrome sqlite data objects

I have been utilizing a sqlite DB as the storage system for a web application. I have been directly using the objects returned from queries in my application. For instance: function get_book_by_id(id,successCallback,errorCallback) { function _successC ...

Switch the dropdown menu to a button if it consists of only one option

I have been using a database within the Moodle Learning Management System that generates a bootstrap table. Here is an example of what it looks like: https://i.sstatic.net/UJc4M.png The last row in the table contains a dropdown menu. When viewing your ow ...

Discover a series of sequential numbers that result from being reduced by 1 using JavaScript

Trying to identify consecutive numbers from an array of numbers has been my latest coding challenge. Here's the snippet I've come up with: let arr = [4, 3, 5, 4, 3]; let new_arr = []; for (let i = 0; i < arr.length; i++) { let internalA ...

Implementing Custom Directive and Events in an Ongoing Application Process

As I design a custom directive for a third-party jQuery plugin, I encounter issues with updating data using events. My directive is set to listen for these events and use $apply to ensure proper data updates from the controller. Additionally, I aim to enab ...

Clicking on the button will instantly relocate the dynamically generated content to the top of the page, thanks to Vue

Here is some dynamically generated content in the left column: <div v-for="index in total" :key="index"> <h2>Dynamic content: <span v-text="index + ' of ' + total"></span></h2> </div> There is also a butt ...

Restrict the number of rows in a CSS grid

Hello there, I am in the process of creating an image gallery using CSS grid. Specifically, my goal is to initially show just one row of images and then allow users to click a "Show more" button to reveal additional images. You can see my progress here: ...

What is returned by jQuery when it fails to locate a specified class selector within the jQuery object?

Picture this scenario: var $letsTestA = $( '.lets-test-a' ), $letsTestB = $( '.lets-test-b' ); Then, consider this HTML: <div class="lets-test-a"></div> (I omitted .lets-test-b intentionally) Now, what happens if we ...

Watch F4V content using JWplayer on your iOS device

Having trouble playing a f4v file using JWplayer on an iOS device (specifically an iPhone). Check out the player setup code below: jwplayer(player).setup({ file: file, primary: "flash", autostart: false, aspectratio: "16:9", autostart: ...

Assign a value to a Select option using JavaScript

Is there a way to populate the options in a <select> tag with values from an AJAX response array? Here is my current code: $.ajax({ type: "GET", url: "http://.......api/1/AbsenceType", dataType: "json", success: function (data) { ...

Selenium: Ensure the element expands beyond a specific width threshold before proceeding

Currently, my webpage performs certain tasks and shows a progress bar. I need to implement a functionality where I can click on the cancel button only after the progress bar has filled at least 50% of its width. Is there a way for me to create a unique w ...

The map markers are nowhere to be found on the map when using Internet Explorer

Take a look at this code I wrote... var styles = [ { "featureType": "landscape", "stylers": [ {"weight": 0.1}, {"color": "#E7EDEF"} ] }, ... { "featureType": "poi.park", "elementType": "labels", "stylers": [ ...

JQueryMobile 1.3.2 encounters issues with popups following the installation of Chrome version 43.0.2357.65 m update

Is anyone else experiencing issues with the latest version of Chrome "43.0.2357.65 m" causing problems with JQueryMobile 1.3.2? When I try to click on a popup, it suddenly jumps to the top of the page and the scroll bar disappears. This was not an issue in ...

Utilize RSelenium to showcase all rows in the display

I am encountering an issue while trying to extract data from the following website: . On this website, there is a table consisting of 1874 rows. Despite my efforts to scrape it, I was only able to retrieve the first 10 rows due to the default lengthMenu ...

Discover the perfect gray hue using RGB color codes

I'm in the process of developing a filter for canvas that will generate a monochrome version of an image. The approach involves drawing the image, then going through its pixel data to convert the RGB values to shades of gray before placing it back on ...

Can the typical drag and drop cursors be ignored in an HTML drag operation?

I've been working with the HTML drag and drop API to allow users to resize columns in a table. However, I've noticed that when a user starts dragging a column, the cursor changes to one of the default drag and drop effects (such as move or none). ...

The Angular2 Renderer successfully renders the Svg rect element, but it is not displayed on the webpage

I am looking to generate a bar chart utilizing SVG with rectangles as the bars. Here is the relevant code: barchart-one.html <svg #svgone width="400" height="250" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 250"> <g #abcd>< ...

Determine the variance between two dates selected using the jQuery datepicker

I have a query regarding date calculations in JavaScript. I am trying to find the difference in days between two dates selected using jQuery datepickers. Although I am accessing the dates by their clientIDs and attempting to calculate the difference, my m ...

What is the process for rotating an object 90 degrees on the global x-axis?

I have the need to precisely adjust the rotation of an object along the world axis by a specific angle. At the moment, I am utilizing the rotateAroundWorldAxis function (which I came across in another discussion) in my attempts to accomplish this. functio ...

What is the best way to make a select tag read-only before the Ajax request is successful

Is there a way to make a select tag read-only before an Ajax success? I tried using this code, but it didn't work: $("#tower").prop('readonly', true); Then I tried this alternative, but I couldn't get the value from the select tag: ...