location on an item within THREE.JS

After successfully loading an .obj file, I am looking to anchor a point on the brain within the image. This point should remain stationary regardless of camera movement, always staying in the same position as depicted in the image below:

https://i.sstatic.net/L2OWp.jpg

var loader = new THREE.OBJLoader( manager );
        /* */
loader.load( 'freesurf.OBJ', function ( object ) {

 brain = object;
 object.position.y = 0;
 scene.add( object );

} );

https://plnkr.co/edit/iAr4Rl4Ohlq6bQIqdbJ6?p=preview

Answer №1

Below is a solution utilizing the SphereGeometry https://plnkr.co/edit/Y15PFd2Fietq5cjQLJjw?p=preview

I made an alteration to this portion of the code.

    var mat = new THREE.MeshBasicMaterial({color:'blue',transparent:true,opacity:0.5,

      depthFunc:THREE.LessDepth,side:THREE.FrontSide,})

      var sphr = new THREE.Mesh(new THREE.SphereGeometry(1,16,16),mat);
      sphr.position.set(1.3, 1.3, 0 );
      brain.add(sphr);


    } );

This solution may not be flawless but functions using a ball-based method. To enhance it, experimentation with pixel shader or generating geometry based on the background object is advisable.

A helpful project for addressing your issue can be found at https://github.com/tomtung/chameleon.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

I aim to conceal the Spinner feature within the service layer of Vue JS

I have a basic bootstrap Spinner.vue component <template> <div class="modal" v-if="start"> <div class="spinner-border text-info" role="status" style="width: 3rem; height: 3rem;" ...

Searching for a specific match in JSON data using React streaming technology: encountering issues with the .find method as

Having experience with functional programming in Java, I recently ventured into JavaScript. My current task involves streaming through a JSON output structured like this: { "originatingRequest": { "clientId": 1, "simulationName": "Sea ...

What could be causing jQuery to fail to detect changes in the HTML code?

Whenever I trigger an Ajax request and update an attribute value, the DOM reflects the changes as expected. However, upon clicking the button again, the console displays the old attribute value. It seems like the markup isn't recognizing the change an ...

UI changes are not appearing until after the synchronous ajax call

I have two JavaScript functions that are called one after the other, as shown below. updateUI(event); syncCall(); function updateUI(event) { formSubmitBtn = $(event.target).find('[type=submit]:not(".disabled")'); formSubmitBtn.attr('di ...

Capturing errors during function declaration in JavaScript

A problem has arisen in the below function definition due to a script error function foo () { try { var bar = function() { ERROR } } catch (exception) { console.debug("exception"); } } foo(); However, th ...

Upon initiating a fresh project with npm create vite@latest and proceeding with npm install, an error message promptly surfaces

semver <7.5.2 Severity: moderate Potential vulnerability in semver due to Regular Expression Denial of Service - https://github.com/advisories/GHSA-c2qf-rxjj-qqgw A fix is available by using the command npm audit fix --force Running this may install [e ...

Save the value entered into an input field using JavaScript and store it in a PHP variable

For a question, I'm developing a dynamic text field where the answer will be displayed based on the user's selection from the answer field. Once the user submits their answer, the PHP code saves it in a PHP variable named $ans1. However, when the ...

Having trouble getting React.js to work with browserify imports?

Currently, I'm in the process of studying React.js and struggling to get my initial component to render. The structure of my project is as follows: javascript | --components | | | ---- searchbar.jsx | | --app.jsx Here is the co ...

When attempting to call an XML node with JavaScript in an HTML file within Dreamweaver, the functionality works as expected. However, upon testing the same code on a server

As a beginner in Javascript, I am attempting to use document.write to display some XML data in an HTML format. Below is the code that I have been working on: <script> function loadXMLDoc() { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest( ...

What is the best way to access a custom object in JavaScript that was created in a different function?

Currently working with JavaScript and jQuery technology. In one of my functions that runs on document ready, I am creating objects with different attributes. While I can easily access these object attributes within the same function, I'm facing diff ...

efforts to activate a "click" with the enter key are unsuccessful

I'm attempting to enhance user experience on my site by triggering the onclick event of a button when the enter key is pressed. I've tried various methods below, but all seem to have the same issue. Here is my HTML (using Pug): input#userIntere ...

The POST request functions smoothly in Postman, however, encounters an error when executed in node.js

Just recently I began learning about node.js and attempted to send a post request to an external server, specifically Oracle Commmerce Cloud, in order to export some data. Check out this screenshot of the request body from Postman: View Request Body In Pos ...

A guide to JavaScript: Fetching and Parsing JSON Data from an API

Hey there! I've been working on using this code snippet in my defult.js file to call an API, but I'm having trouble figuring out how to read the output. It always seems to end up in the last else part. function fetchDataDist(APPID, flag, call ...

Obtaining an element in the Document Object Model (DOM) following

There are numerous questions and answers regarding this issue, but I am struggling to adapt it to my specific case. My extension fetches positions (1,2,...100) on the scores pages of a game. Upon initial page load, I receive the first 100 positions. Howev ...

Troubleshooting issues with calculator operators in JavaScript for beginners

As a beginner in JavaScript, I've taken on the challenge of building a calculator to enhance my skills. However, I'm having trouble getting the operator buttons (specifically the plus and equal buttons) to function properly. Can someone please as ...

Ways to Randomly Flip Divs

I have developed an application where all divs flip vertically on hover. I am looking for a way to make the flipping random without requiring a hover. Any ideas on how to achieve this? .vertical.flip-container { position: relative; float: left; ma ...

karma plugin dependencies could not be located

Every time I execute karma start, the following issues arise: C:\devl\JS\myProject>karma start 06 09 2015 11:30:19.133:WARN [plugin]: Cannot find plugin "karma-chrome-launcher". Did you forget to install it ? npm install karma-chrome ...

Ways to make the submenu display underneath the main menu

Click here to view the menu It is important to note that you may need to expand the Result Box in order to see the full menu. The issue I am currently facing involves fixing a submenu that appears when hovering over the Men and Women <li> elements. ...

The attribute @Validation.For("orderName") is not recognized

Attempting to extract the Order Form from the Bakery Template for use on my website has resulted in an error in the code: "@Validation.For("orderName")" attribute is unknown. <div class="fieldcontainer" data-role="fieldcontain"> ...

Sending data from PHP to a text file upon clicking a button

I have been struggling with AJAX and despite my efforts to research on Stack Overflow and other online resources, I still can't get it to work. Any help would be greatly appreciated. My issue involves a formatted JSON file that I am able to parse usi ...