Children missing from camera view

Creating a camera is crucial in this scenario:

camera = new THREE.PerspectiveCamera(90, width / height, 0.001, 1000);
camera.position.set(0, 15, 0);
scene.add(camera);

I have an interesting object that I want to attach to the camera as its child

var handGeometry = new THREE.SphereGeometry(0.1, 32, 32 );
var handMaterial = new THREE.MeshBasicMaterial({color: "#eac086"});
hand = new THREE.Mesh(handGeometry, handMaterial);
hand.position.set(1, 14, camera.position.z / 2);

Next step is to set this object as a child of the camera

camera.add(hand)

Unfortunately, the scene remains empty and the child object is nowhere to be seen. The intention here is to have my hand object rotate synchronously with the camera's movements, considering the use of OrbitControls.

Answer №1

When incorporating a renderable object as a child of the camera, it is crucial to include the camera in the scene graph:

scene.add( camera );

Afterwards, adjust your child's position relative to the camera's position. Since the camera consistently looks down its local negative-z axis, consider using:

child.position.set( 0, 0, -10 );

This pertains to version r.73 of three.js

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

Controlling Fabric in Three.JS

(I'm still learning so forgive me if this is a beginner question.) I'm currently working on fitting a cloth material to a character model in Three.JS. What would be the most effective approach for this? Should I create a complete garment as cloth ...

Detecting the combination of Shift key and Enter key in ReactJS using the onKeyPress event

How can I detect when the user presses 'Shift + Enter' in a ReactJS component using the onKeyPress event? Does anyone have any ideas or suggestions on how to achieve this? Check out this helpful resource for more information class App extends ...

Is it possible to load HTML content within a Sweet Alert pop-up

Below is the code I am using to call Swal: window.swal({ title: "Checking...", text: "Please wait", imageUrl: "{{ asset('media/photos/loaderspin.gif') }}", showConfirmButton: false, allowOutsideClick: false }); $.ajax({ t ...

A JavaScript function that fetches the color name based on either the RGB value or the Hexadecimal value

Looking for a JavaScript function that can determine the name of a color. Would like the JavaScript function to be structured as shown below: function getColorName(r, g, b) { .... return <color name>; // such as blue, cyan, magenta, etc. } ...

React useEffect alert: Exceeding maximum update depth limit. Any solutions to bypass this issue?

In the code snippet below, I am utilizing the useEffect hook to monitor changes to a percentage variable and then initiating a timer to increment that variable every second. This process starts as soon as the page loads. The percentage variable is crucial ...

There seems to be an issue with creating cookies in the browser using Express.js

When using res.cookie(), I encountered an issue where the cookie was created but not showing in the browser. Although the cookie was not stored, it was visible when using Postman. I attempted to set the cookie using res.cookie("access_token", token, {sec ...

Shift the content downwards within an 'a' snippet located in the sidebar when it reaches the edge of the right border

I'm having an issue with my style.css file. As a beginner in programming, I am trying to position text next to an image attached in the sidebar. However, the text is overflowing past the border. Here's the HTML code: Please see this first to ide ...

The vertical navigation pills in Bootstrap 4 are not functioning properly as anticipated

I've been referring to the bootstrap 4 documentation for my project. After copying and pasting the code snippet for vertical pills, I noticed it wasn't functioning correctly. Instead of displaying text next to the buttons, it was appearing belo ...

Create PDFs using PhantomJS when the HTML content is fully loaded and ready

I am a newcomer to utilizing phantomjs and encountering difficulties in rendering my website as a PDF file. Although I can successfully render a simple version of the page, issues arise when multiple images and web fonts are involved, causing the DOM not t ...

The ion-slide-box does not function properly the first time the HTML page is loaded

Upon loading the page, my ion-slide-box does not function correctly. However, if I refresh the page, it works as expected. I have tried referring to some links but have been unable to resolve this issue on my own. Any assistance would be greatly appreciate ...

Transferring information to PHP script using only JavaScript (Ajax)

I have a good understanding of jQuery: $.ajax({ method: 'POST', url: 'send-data-to.php', data: {data:"data"} }) However, I am unsure of how to send data that is accessible via $_POST using pure JavaScript. The reason for my inqu ...

Error in Discord.JS: The function message.author.hasPermission is not recognized

As I was working on creating a new command for my discord.js bot to toggle commands on/off, I ran into some issues. Specifically, when I attempted to use the .hasPermission function, I encountered the following error message: TypeError: message.author.ha ...

Modify appearance of text depending on input (HTML & JS)

I am currently working on building an HTML table using Django. My goal is to dynamically change the color of numbers in the table to red when they are negative and green when they are positive. I understand that JavaScript is required for this functionalit ...

Exploring the Power of Namespaces in ECMAScript 6 Classes

My goal is to create a class within the namespace TEST using ECMAScript 6. Previously, I achieved this in "old" JavaScript with: var TEST=TEST || {}; TEST.Test1 = function() { } Now, I am attempting the following approach: var TEST=TEST || {}; class TES ...

import the AJAX response into a table format

With over 10000 rows in Data-table 1.10, I am looking to populate the table body using ajax response. Currently, I am returning the data as an array and iterating over it on the frontend in HTML. This results in the data-table rendering all the rows regard ...

Locate a specific sequence of characters within an array of objects using JavaScript

I am working with an array of objects, where each object contains a string value. My task is to search for a specific substring within the string. [ { "link": "https://www.sec.gov/Archives/edgar/data/1702510/000170251022000084/00 ...

Error: Attempting to access 'devolucionItems' property of undefined object which may be caused by usage of .map() method

I'm fairly new to working with JavaScript and currently facing an issue with displaying information from an order return on the DeliveryReturnScreen.js page. This particular page can be accessed by clicking a button/handler on my OrderHistoryScreen.js ...

Diving deep into the reasons behind a test's failure

Currently, I am using Postman to test the API that I am developing with express. In this process, I am creating a series of tests. Below is a brief example: tests["Status code is 200"] = responseCode.code === 200; // Verifying the expected board var expe ...

Tips for retrieving data from a Node.js server with a POST request in a React application

I'm currently working on a MERN authentication project, but I've hit a roadblock. Whenever the information is submitted on my register page, it triggers an add user function on the front end. async function addUser(user) { const config = { ...

Nuxt 3.11 - Best Practices for Integrating the `github/relative-time-element` Dependency

I'm encountering some difficulties while attempting to integrate github/relative-time-element with Nuxt 3.11.2 and Nitro 2.9.6. This is my current progress: I added the library through the command: $ npm install @github/time-elements. I adjusted nux ...