Exclusive Aframe Billboarding Limitation on the Y Axis

Currently, I am utilizing this particular component in my Aframe scene to ensure an image always stays facing the camera. While it functions correctly, I am looking to adjust the billboarding to only operate on the Y axis. Think of the image as a person who should pivot around to follow the camera, rather than tilting back and looking up as the camera gets closer.

Does anyone have suggestions on how to customize this component to achieve that effect?

Answer №1

To achieve proper billboarding, synchronize the Y coordinate of the target with the object by using:

this.vector.y = object3D.position.y;  //added for alignment
return object3D.lookAt(this.vector);

Answer №2

A discussion resulted in a clever approach to rotate an object only on the y-axis. Here is the code presented as a self-contained component:

AFRAME.registerComponent('look-at-y', {
  schema: {
    target: {type: 'string', default: 'camera'}
  },
  init: function () { },
  update: function () { },
  tick: function () {
    const targetEl = document.getElementById(this.data.target).object3D;
    const el = this.el.object3D;
    const vec = new THREE.Vector3();
    targetEl.getWorldDirection(vec);
    vec.y = 0;
    vec.add(el.position)
    el.lookAt(vec);
  }
});

This method works by disregarding the Y position of the target entity during the vector calculation for orientation.

By changing vec.y = 0 to vec.x or vec.z, you can achieve billboard effects along different axes too. To enhance it further, one could potentially modify this component to accept an "axis" schema parameter and dynamically switch between them!

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

Having trouble fetching the value with the designated ID

I'm encountering an issue with retrieving a value using an id. In my code, I have it set up like this: view <input type="text" value="<?php echo $add->class;?>" name="cls_<?php echo $add->id;?>" id="cls_<?php echo $add->id ...

No search results found when using Vue.js searchbar filter

Today I delved into the world of VUEjs for the first time, experimenting with extracting data from a URL in JSON format. Initially, this process went smoothly, but my curiosity led me to attempt adding a search feature. I followed online tutorials, which u ...

Issue with unbinding events in Angular directive persists despite efforts to completely unbind

Our directive features a popup that loads a template with a directive to capture all clicks in the document. When a click is detected, it sends an event to close the popup and unbinds the event on the $document. This directive effectively captures docume ...

Verify that a Checkbox has been selected

I'm attempting to determine if a checkbox has been checked, and if it has, adjust the visibility of a specific DIV element. Unfortunately, my check is not working as expected. Despite placing an alert before the "if" statement and confirming that it ...

What could be causing my webGL page to fail loading the second time following a refresh?

My friend and I are working on a JavaScript page together. Initially, the page loads smoothly when opened in a tab, although it may be a bit slow. However, upon refreshing the tab, the WebGl canvas appears completely blank while the HTML elements are stil ...

AngularJS - where each client maintains their own MongoDB database

After spending hours on this task, I'm still struggling to find a solution. I have a mean stack application that caters to multiple clients, and I am looking to assign each client their own database. Is this possible? For Example var client_name = ...

Struggling to generate a TrackballControls instance

Every time I try to create a TrackballControls object, I encounter an error message stating "THREE.TrackballControls is not a constructor". Here's a simple example: <!doctype html> <html> <head> <title>Trackball Contr ...

Vue's emission system, accessed through this.$emits, unexpectedly ceases functioning mid-function call

Within my Vue frontend, I have a function designed to emit updates to the parent component before and after sending a request to the server. The function in question is as follows: saveUpdates: async function () { const component = { doc: ...

What is the best way to create a filter function that continues past the first false value?

Looking for a solution to successfully filter an array of objects by comparing it to another array through looping over its values. The issue arises when the filter function stops at the first false, preventing the full comparison. Any suggestions on how ...

What is the process for determining the overall cost of a column in Angular 9?

I am facing a challenge in calculating the total price, total quantity, and total counted(#) of each column in a table. | Item | Price | Quantity | 1 | Mouse | 500 | 1 | 2 | Wire | 100 | 2 | TI:3 | |TP:600 | TQ:3 | < ...

eliminate the gap in the MUI Accordion when it is expanded

How can I prevent the Accordion MUI component from moving and applying top and bottom margins to summary elements in expanded mode? I added the following code to the summary element but it doesn't seem to be working. Any suggestions on how to fix this ...

"Troubleshooting Problem with jQuery UI Autocomplete and JSON Data

I have implemented the jQuery UI Autocomplete feature using the code below. <script> $(function() { $( "#city" ).autocomplete({ source: function( request, response ) { $.post('<?php echo base_url()?>records/get_villa ...

What does the reportProgress function do in HTTP services with JavaScript?

Can someone explain the functionality of reportProgress in JavaScript, specifically when used with Angular Typescript? I am having trouble finding documentation on this. return this.httpClient.request<ProductResponse>('get',`${this.basePath ...

The console is not displaying the data from the useForm

I am working on a project to create a Gmail clone. I have implemented the useForm library for data validation. However, when I input data into the form and try to print it to the console, nothing is being displayed. const onSubmit = (data) => { ...

Conceal location labels in maps provided by tilehosting.com

I am currently in the initial stages of developing a maps web application and I want to incorporate maps from tilehosting.com along with the leaflet library (leafletjs.com). Overall, it seems to be working fine, but I'm struggling with hiding the def ...

Is it possible to utilize JavaScript to send HTML content to a fresh tab or window while ensuring that the CSS is properly loaded?

On a webpage, I have JavaScript code that fetches HTML from a server and I want to display it in a new browser tab or window. When using window.document.write(myHTML) to insert the HTML into the new container, the CSS and JavaScript includes within the HTM ...

What is the process for animating elements on the Mountain Dew website?

After searching extensively, I was unable to locate a JavaScript library that can animate elements in a similar manner as demonstrated here. Take a moment to explore the website beyond the introduction, experiment with applying different filters from the t ...

Troubleshooting issue with jQuery validation functionality not functioning properly with select dropdown

My default validator settings include displaying a red error message when validation fails. However, it works on Input and textareas, but not on select. $.validator.setDefaults({ ignore: "", errorPlacement: function(error, element) { ...

Is there a way to collaborate on a shared canvas during a video call?

Currently, I am developing a video application and my goal is to ensure that all participants are viewing the same canvas simultaneously during calls. It seems that each participant has their own instance of the canvas instead of a shared one, which is n ...

How can I track the number of correct answers in a ReactJS quiz with an auto-submit feature and a timer that stops?

The auto-submit feature is not functioning correctly. Although the code works fine when I manually submit the quiz at the end, if the time runs out, the score will always be 0/3 which is incorrect. // React and Material-UI imports omitted for brevity // ...