Could a Three.js mesh with fewer morph targets be influenced by another mesh with a greater number of morph targets?

It's quite strange that an Object3D with fewer morph targets can be influenced by another one with more morph targets.

To demonstrate this issue, I replicated the error here by introducing a cube with 4 morph targets into the Three.js official example webgl_morphtargets. The original example featured only one cube with 8 morph targets.

In the updated example, adjusting the values in the top 8 input bars affects the morphTargetInfluences of the gray cube, while changing the bottom 4 bars influences the blue cube. Despite having different geometries and materials, tweaking the top 8 input bars still impacts the blue cube.

The snippet of code related to morphTargets is displayed below. I've been struggling with this issue for some time now and haven't been able to solve it. Any guidance on this matter would be greatly appreciated. Thank you!

            // creating the first cube
            var geometry = new THREE.BoxGeometry(100, 100, 100);
            var material = new THREE.MeshLambertMaterial({color: 0xffffff, morphTargets: true});

            // generating 8 blend shapes
            for (var i = 0; i < geometry.vertices.length; i++) {
                var vertices = [];
                for (var v = 0; v < geometry.vertices.length; v++) {
                    vertices.push(geometry.vertices[v].clone());
                    if (v === i) {
                        vertices[vertices.length - 1].x *= 2;
                        vertices[vertices.length - 1].y *= 2;
                        vertices[vertices.length - 1].z *= 2;
                    }
                }
                geometry.morphTargets.push({name: "target" + i, vertices: vertices});
            }
            mesh = new THREE.Mesh(geometry, material);
            scene.add(mesh);

            // creating the second cube
            var geometry2 = new THREE.BoxGeometry(100, 100, 100);
            var material2 = new THREE.MeshLambertMaterial({color: 0x00ffff, morphTargets: true});

            // generating 4 blend shapes
            for (var i = 0; i < geometry2.vertices.length/2; i++) {
                var vertices = [];
                for (var v = 0; v < geometry2.vertices.length; v++) {
                    vertices.push(geometry2.vertices[v].clone());
                    if (v === i) {
                        vertices[vertices.length - 1].x *= 2;
                        vertices[vertices.length - 1].y *= 2;
                        vertices[vertices.length - 1].z *= 2;
                    }
                }
                geometry2.morphTargets.push({name: "target" + i, vertices: vertices});
            }
            geometry2.computeMorphNormals();
            mesh2 = new THREE.Mesh(geometry2, material2);
            mesh2.position.x = 200;
            scene.add(mesh2);

Answer №1

The issue has been identified and resolved with the latest version of the library.

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

Updating Icons in HTML Using Local Storage and Implementing a Dark Mode Feature Using JavaScript

My latest project involved creating a dark mode button along with a custom dark theme. The theme is stored in Local Storage to ensure consistency. However, I have encountered an issue where, upon page reload, the site remains in dark mode but the button ic ...

Setting up a basic webhook server with Node and Express

I'm struggling to locate comprehensive tutorials on webhooks for beginners. Being new to this concept, I have only come across basic explanations of how they operate. Our current requirement is to inform users of our APIs about new records. With Kafk ...

What is the best way to apply typography theme defaults to standard tags using Material-UI?

After reading the documentation on https://material-ui.com/style/typography/ and loading the Roboto font, I expected a simple component like this: const theme = createMuiTheme(); const App = () => { return ( <MuiThemeProvider theme={theme}> ...

Create a div element that can be expanded on smaller devices

Is it possible to expand a div while hovering on a small or x-small device? I want to achieve something like this: https://i.sstatic.net/doJKa.png Currently, I can only hide the yellow div when the page is displayed on a small device. I am looking for a ...

How can I extract the domain name using a regular expression in JavaScript?

I am struggling with creating a regular expression to extract the main domain name from a URL. The URLs I have are: http://domain.com/return/java.php?hello.asp http://www.domain.com/return/java.php?hello.asp http://blog.domain.net/return/java.php?hello.as ...

Exploring and extracting values from nested arrays of objects in JavaScript and React

Hey there, I am having trouble getting the data from the backend server to display on a chart library. Can you please take a look at my code and help me out? const data = [ { id: "americano", data: [{x: "10",y: 10,}, {x: &quo ...

Encountering a problem with the scope of child_process in Node

When utilizing the child_process module in Node.js with the fork method, I am able to send data to a specific file and receive a response. However, I am not logging this data to the console after receiving it from the execution process. The code in first. ...

Information has been extracted from the source, however, no content is being shown

Recently, I developed a web application with an AngularJS frontend and Rails backend. I uploaded my frontend code to JSFIDDLE. Meanwhile, the rails backend on the index page is returning some JSON: [{"id":1,"name":null,"user_id":null,"created_at":"2013-1 ...

Phone Validation for Contact Form 7

Recently, I was tasked with creating a landing page for a job interview. The challenge was to include validation on the phone number field so that it has to be between 9 and 10 numbers in length, along with another validation requiring the phone number t ...

What is the best way to create shared scope and transmit data within an Angular directive?

In my angular directive, I have the following code: app.directive('myDir', function () { return { restrict: 'E', scope: true, template:'<div>{{myindex}}</div>', link: function(scope, element, att ...

What steps are needed to enable autocomplete for input fields in React Native Elements on iOS?

I'm currently working on fine-tuning the autocomplete suggestions for my registration form. Within the react native elements input, I've already implemented fields for username, email, and password. Specifically for the email field, I have config ...

What are the differences between a Django/React app API when in production versus during development?

Recently, I created a React app that relies on Axios for fetching APIs. During the development phase, I noticed an issue with the API URL configuration. Since my ReactApp was hosted on localhost:3000 but making API calls to 127.0.0.1 - I encountered some e ...

Angular/Typescript ESLint rule for enforcing pure functions

Are there specific ESLint rules to ensure that only pure functions are written in TypeScript? I am looking to strictly write only pure functions in my code. Could someone please provide guidance on how to accomplish this? Appreciate any help in advance ...

Tips for sending information to an Express API through AJAX

While working on a website using Express and EJS, I encountered an issue with calling an API via AJAX. The problem arises when passing two values to the AJAX data upon button click, resulting in errors. Despite trying various solutions, I'm still stru ...

Issue with $watch function causing $scope variable to remain undefined, even though it is being explicitly

I've been encountering an issue while trying to insert data into my Firebase database using a user's uid. It seems to be coming out as undefined for some reason. Here's a closer look at the code snippet causing the problem: The primary cont ...

Use jQuery Ajax to fetch an image and display it on the webpage

Currently, I am working on an application that is designed to browse through a large collection of images. The initial phase of the project involved sorting, filtering, and loading the correct images, as well as separating them into different pages for imp ...

Is it possible to incorporate a label within a dropdown menu (<select>)?

How can I add a label inside a select box using Bootstrap? Here is an example: Before selecting an option After selecting an option, the label should appear in a small size like this: After selecting an option : <div class="form-group"> & ...

Customize your select element's background using jQuery when the content changes

Here is a select element with different options to choose from: <select class="state"> <option value="1">Done</option> <option value="2">Closed</option> <option value="2">Open</option> <option v ...

Click a button to dynamically create a div element with jQuery

Whenever I click the button to add an address, I want to dynamically create a new div structure using jQuery <div id="container"> <div class="address"> <div class="input-reg rb-item input-group"> <sp ...

Ajax fails to transmit information

Currently, I am in the process of familiarizing myself with the usage of ajax. An issue that I am encountering is that clicking a submit button in a form does not effectively send data. Below you can find the JQuery code I am using: $('input[name=" ...