ThreeJS is giving an error message stating that it cannot find a corresponding function for 'mapTexelToLinear'

Currently grappling with a challenge in ThreeJS as I embark on a basic crash course. My hurdle lies within the Shader, specifically when attempting to texture a cube. Here's a snippet of my code where I create the cube:

var geometry = new THREE.BoxGeometry(1, 1, 1);

var cubeTexture = new THREE.TextureLoader();
cubeTexture.load("img/texture01.jpg");
var cubeMaterials = [
    new THREE.MeshBasicMaterial({map: cubeTexture, side: THREE.DoubleSide}), // Right
    new THREE.MeshBasicMaterial({map: cubeTexture, side: THREE.DoubleSide}), // Left
    new THREE.MeshBasicMaterial({map: cubeTexture, side: THREE.DoubleSide}), // Top
    new THREE.MeshBasicMaterial({map: cubeTexture, side: THREE.DoubleSide}), // Bottom
    new THREE.MeshBasicMaterial({map: cubeTexture, side: THREE.DoubleSide}), // Front
    new THREE.MeshBasicMaterial({map: cubeTexture, side: THREE.DoubleSide}) // Back
]

var cube = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(cubeMaterials));

Upon execution, an error surfaces:

three.min.js:49 THREE.WebGLShader: gl.getShaderInfoLog() fragment ERROR: 0:262: 'mapTexelToLinear' : no matching overloaded function found
ERROR: 0:262: '=' : dimension mismatch
...
// Truncated for brevity
...
D            = min( floor( D ) / 255.0, 1.0 );
74:     return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );
75: }
76: const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184);
// More shader-related errors follow after this... 

Even after experimenting by using only the material array and ditching THREE.MeshFaceMaterial, the issue persists. It seems likely that this error is tied to either the Shader or perhaps my webGL setup. Unfortunately, I'm at a loss on how to rectify it.

Your insights and guidance would be greatly appreciated. Thank you!

Answer №1

MeshFaceMaterial has been marked as deprecated. The ThreeJS Deprecated List advises to "use an array instead".

Instead of creating a new MeshFaceMaterial with an array in it, simply pass the array as the second argument:

var cubeMaterials = [
new THREE.MeshBasicMaterial({map: cubeTexture, side: THREE.DoubleSide}), // Right
new THREE.MeshBasicMaterial({map: cubeTexture, side: THREE.DoubleSide}), // Left
new THREE.MeshBasicMaterial({map: cubeTexture, side: THREE.DoubleSide}), // Top
new THREE.MeshBasicMaterial({map: cubeTexture, side: THREE.DoubleSide}), // Bottom
new THREE.MeshBasicMaterial({map: cubeTexture, side: THREE.DoubleSide}), // Front
new THREE.MeshBasicMaterial({map: cubeTexture, side: THREE.DoubleSide}) // Back
]

var cube = new THREE.Mesh(geometry, cubeMaterials);

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

Challenges encountered when attempting to download a file using jQuery's GET method

I am working with an API Server that responds to requests in the following format: http://localhost:8080/slim3/public/api/v1/files/Test1.jpg http://localhost:8080/slim3/public/api/v1/files/Test2.txt ... When I enter such a URL into my browser, I receive ...

The function is triggered only on resize, not on initial load

Is there a way to ensure that the carouselPartialView function runs automatically when the page loads? I've noticed that it doesn't run when directly called, but works fine when called with the resizeWitdthOnly function. How can I make sure it ru ...

Error: CSRF token not found or invalid. What is the procedure for transmitting a CSRF token from the frontend to the backend?

In my Django project, I have a task that involves sending a date string from the frontend to the backend. On the frontend, I am utilizing JavaScript's fetch method. async function getCustomerInDeliveryDate(deliveryDate : String) { con ...

Is there a way to make a NodeJS Transform stream produce multiple records for each input chunk?

Currently, I am working on a Transform stream that has the capability to receive an incoming stream of XML data and then emit a subset of that in the form of JavaScript objects. <item> <name>some name</name> <files> <fil ...

What is the reason behind Express exporting a function instead of an object in the initial stages?

In Node.js, when utilizing express, we start by using const express = require('express') to bring in the express module, which will then yield a function. Afterward, we proceed with const app = express() My inquiry is as follows: What exactly ...

In what scenarios would implementing the JS Switch case statement be more efficient than using numerous If/Else statements?

Greetings and thank you in advance for any help or guidance. I am currently developing a Space Battle game and I am curious to know if there is a way to utilize a JavaScript SWITCH case statement to streamline the numerous If/Else statements that are curr ...

Jquery animation is dragging its feet on Explorer, while other browsers are zipping along

Hey everyone, I am facing an issue with a simple jquery plugin I created for an animated menu. You can check out the entire site here: Main website My Library the "bootstrap" file The problem is that the red rectangle animates smoothly in Firefox, Op ...

Upgrade to Bootstrap 5 - Implement Video Modal Feature

I need to update a modal with a video inside from Bootstrap 4 to Bootstrap 5 without jQuery. The issue lies in the JavaScript code below: <script> // codepen.io/JacobLett/pen/xqpEYE $(document).ready(function() { var $videoSrc; $(&a ...

Is it possible to create a single button that, upon clicking, fades in one image while simultaneously fading out another?

My goal is to have the blue square fade in on the first button click, then fade out while the red square fades in on the second click. Unfortunately, it seems that my current code is not achieving this effect. I'm open to any suggestions or help on h ...

Vue 2.0: Exploring the Power of Directive Parameter Attributes

It has come to my attention that directive param attributes have been phased out in Vue.js 2.0. As a result, I am unable to use syntax like v-model="msg" number within an input tag. Are there alternative methods to achieve the same outcomes without relyi ...

Loading Collada files with a progress callback function can help track the

Is there a proper way to incorporate a loading bar while using the ColladaLoader? The code indicates that the loader requires three parameters, with one being a progressCallback. progressCallback( { total: length, loaded: request.responseText.length } ); ...

Having trouble grouping data on website due to duplicate names

Currently in the process of scraping data from various websites and looping through it. Specifically focusing on scraping the head section. This is an example illustrating the structure of the data: const head = { rel_data: [ { rel: &quo ...

The emulator failed to launch because it could not find any emulators listed as an output of the `emulator -list-avds` command

Hello everyone, I've recently ventured into the world of React Native and managed to successfully install and launch the emulator. However, I encountered a problem when attempting to run the command react-native run-android. The console output display ...

Determine whether an array is void, then proceed to deactivate a button

I am attempting to prevent a button from being clickable if an array is empty, but I am encountering difficulties. <button [disabled]="(users.length ==0 )?true:false">Send mass emails</button> Within the TypeScript file: users: UsersModel[]; ...

Ways to add elements to the DOM using jQuery from the local storage?

I'm facing a challenge where I have an input field and store the inputs in local storage. When I click on 'add', I want to immediately append the new inputs to my ul element. However, simply appending the current input won't work as it ...

I successfully implemented an obj model in threejs. What is the best method to delete it from the scene?

let ready = new THREE.OBJMTLLoader(); ready.addEventListener( 'load', function ( data ) { let item = data.node; item.position.z = -700; scene.add( item ); }); ready.load( 'obj/male02/male02.obj', 'obj/male02/male ...

What could be the reason for the xtk.js nrrd loader successfully loading my file on a local asp.net-core site, but encountering issues when deployed to production on

In my ASP.NET Core development local environment, I have no trouble loading and viewing my .nrrd file. However, once I deploy to Azure and try to view the site, I encounter an error saying "Uncaught TypeError: can't access property 'split', ...

What could be causing the computed property in Vue 2 component to not return the expected state?

I'm encountering an issue with my Vue component where it fails to load due to one of its computed properties being undefined: Error: Cannot read properties of undefined (reading 'map') Here is the snippet of the computed property causing ...

Highcharts, put a halt to the dynamic spline graph rendering

Utilizing Angular, I successfully implemented a Dynamical Spline Graph by following the guidelines outlined in the HighCharts documentation. An important feature I would like to incorporate is the ability for the chart to pause rendering upon clicking a d ...

What could be causing the custom aside or slide panel to not slide properly when using Angular Strap?

I recently tried creating a slide panel and came across the Angular Strap library. After studying the documentation, I attempted to implement the slide panel using this library. However, I encountered an issue where my side panel did not slide as demonst ...