Error: Execution of 'texImage2D' on 'WebGLRenderingContext' failed due to overload resolution issues

I am currently working on developing a 3D customizer by using fabricjs as the canvas texture for my three js model. The method I use to load the obj file is as follows:

function loadObj() {
    canvasTexture.anisotropy = renderer.capabilities.getMaxAnisotropy();
    textureMaterial = new THREE.MeshPhongMaterial({ map: canvasTexture });
    texture.needsUpdate = true;
    var loader = new THREE.OBJLoader2(manager);
    loader.load('assets/men/cat1/model1.obj', function (data) {
        if (object != null) {
            scene.remove(object);
        }
        object = null;
        object = data.detail.loaderRootNode;
        materials = [];
        object.traverse(function (child) {
            if (child.isMesh) {
                child.material.map = textureMaterial;
            };
        });
        console.log(object.children[0].material)
        object.children[0].material = textureMaterial;
        render();
        var scale = height / 5;
        object.scale.set(scale, scale, scale);
        object.position.set(0, -scale * 1.25, 0);
        object.rotation.set(0, Math.PI / 2, 0);
        object.receiveShadow = true;
        object.castShadow = true;
        scene.add(object);
    });
}

Furthermore, here is how I have implemented fabricjs:

var canvas = new fabric.Canvas("canvas");
canvas.backgroundColor = "#FFBE9F";
var text = new fabric.IText('Three.js\n+\nFaBric.js', {
    fontSize: 100,
    textAlign: 'center',
    fontWeight: 'bold',
    left: 500,
    top: 500,
    originX: 'center',
    originY: 'center',
    selectable: true // make this object selectable
});
fabric.loadSVGFromURL('assets/men/cat1/prod1/pattern.svg', function (objects, options) {
    var svgData = fabric.util.groupSVGElements(objects, { selectable: false,crossOrigin: 'anonymous' });
    svgData.top = 420;
    svgData.left = 70;
    canvas.add(svgData);
    canvas.sendToBack(svgData);
});
canvas.add(text);
var texture = new THREE.Texture(document.getElementById("canvas"));
fabric.Image.fromURL('assets/men/cat1/texture.png', function (myImg) {
    var img1 = myImg.set({ left: 0, top: 0, selectable: false,crossOrigin: 'anonymous' });
    
    canvas.add(img1);
    canvas.sendToBack(img1);
});

However, when viewing my 3D model, it appears to be all black like in this image. Does anyone have any suggestions on how to resolve this issue? My goal is to wrap the fabricjs canvas around my 3D model seamlessly.

Answer №1

Upon exploring various solutions, I discovered that the issue at hand actually shares a solution with this particular discussion thread: how to load fabricjs as texture for obj using threejs

The problem stemmed from my usage of a fabricjs canvas as an argument for THREE.Texture, which only supports images. By switching it to a canvas tag instead, as detailed in the aforementioned post, I hope this information proves beneficial to others facing a similar dilemma.

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

Leveraging PHP variables to determine the image location, implement an onclick function to cycle through the image gallery

I am facing an issue with a database query that is supposed to display multiple images. These images are stored in a PHP variable and shown one at a time using a JavaScript gallery with an onclick function to navigate through them. Unfortunately, the funct ...

A guide for finding a specific string within a subset of an array

I have an array containing various substrings, and I want to pass if at least one of those substrings contains the specific value I am searching for. Value1 = [ "Grape | 100 |Food Catering Service", "Apple | 100,000m |Food Catering Servi ...

Creating a Copy to Clipboard feature in React can be achieved by transferring data from an h1 tag to an input field

I'm trying to extract data from an API into an h1 tag in my app. Is there a way for me to easily copy this data and paste it into an input field? Any help would be greatly appreciated. Thanks! ...

Converting a Matrix4 to a Matrix3 in ThreeJS: A Step-by-Step Guide

Seeking guidance on converting a Matrix4 to a Matrix3 in ThreeJS. Attempting to obtain the 'inverse view rotation' matrix. My understanding is that the following steps are required: 1) Convert the camera.matrixWorldInverse to a Matrix3 2) In ...

Encountering a next-i18next 404 error while attempting to access pages with localeSubpaths configuration enabled

I have encountered a 404 error while trying to access any page of my Next.js application. The application functions properly when the localeSubpaths configuration is not provided. However, upon implementing the localeSubpaths config in next.config.js: co ...

My component reference seems to have gone missing in angular2

Trying to load my Angular 2 app, I encountered this error: https://i.stack.imgur.com/FmgZE.png Despite having all the necessary files in place. https://i.stack.imgur.com/kj9cP.png Any suggestions on how to resolve this issue? Here is a snippet from ap ...

Utilizing a class function within the static method `getDerivatedPropsFromState`

I've been updating the deprecated life-cycle method componentWillRecieveProps() to its new replacement static getDerivatedPropsFromState(). The issue I'm encountering with this update is that componentWillRecieveProps() uses a class function int ...

When attempting to use Arabic characters in my PDF file with LIP, I encounter an error: "TypeError: font must be of type PDFFont or n, but was actually of type NaN"

all I am facing an issue with Arabic characters when trying to use different fonts in my project. I have attempted to encode the Arabic letters using various npm packages, but I keep receiving a TypeError: font must be of type PDFFont or n but was actuall ...

Experiencing issues with references while trying to import tone.js

I am facing an issue with my express.js server setup on my Mac. I am trying to incorporate Tone.js, which can be found at , following the provided instructions. npm install tone To integrate Tone.js successfully: import * as Tone from 'tone' Ho ...

Sender receives a response from Socket.io

My goal is to have a socket respond only to the sender. Currently, I am working on having the user connect to the server using JavaScript when they visit any webpage. However, I am unsure whether the connection will be reset each time the user reloads th ...

Verifying the format of an object received from an HTTP service using a TypeScript interface

Ensuring that the structure of the http JSON response aligns with a typescript interface/type is crucial for our javascript integration tests against the backend. Take, for example, our CurrentUser interface: export interface CurrentUser { id: number; ...

Manage form submission seamlessly without redirecting. Capture information without needing to prevent the default action, then proceed with redirection. Avoid redirecting when using preventDefault, but be aware that data may not

Currently stuck in a tricky situation. I've implemented a custom form submission to prevent redirecting when an express route is triggered by form submission. However, the issue arises when I lose the data being sent without redirection. document.get ...

Easily visualize the JSON object hierarchy within Eclipse using JavaScript

Is there a way to view the JSON parse objects structure in Eclipse without using console.log() in Chrome due to cross domain issues? I need assistance with how to view the [object Object] returned structure from Json.Parse. ...

Warning: Promise rejection was not handled (rejection id: 3)

As a newcomer to the world of await, I'm struggling to handle errors and rejections properly. The unhandled rejections from the shopify-api.js function keep cropping up, and I can't seem to print all the errors that are coming from my middleware ...

Form submission using AJAX is failing to send the data correctly

I've been struggling with this particular piece of code for days now, and any assistance would be greatly appreciated. The issue I'm facing is that the script successfully calls the PHP file upon hitting the submit key, but it fails to post the ...

In React version 16 and d3 version 4, if you try to use the mouse functionality from d3-selection, you may encounter a TypeError stating that it cannot read the property 'sourceEvent' of

Exploring the integration of d3 with React by incorporating the mouse feature from d3-selection module import { selectAll, select, mouse } from 'd3-selection'; Encountering an issue while attempting to utilize : mouse(e.target) or mouse(select( ...

Issues with storing data in localStorage have been identified in the Facebook browser for iOS

When our web app (built using React) is accessed through the Facebook browser on iOS and Android, we have noticed some unusual behavior with the local storage. Our authentication process relies on storing a token in local storage and then retrieving it. Th ...

Discover the underlying element that is being blurred when clicked

Is there a method to determine which element triggered the blur event when clicked outside? I want to update a ui-select value to match what the user typed in if they click outside of the dropdown. However, if they click on a dropdown item, I want to disc ...

Looped jQuery setTimeout not functioning correctly

I am facing an issue with processing a JSON file that contains a list of serialized objects. My goal is to walk through this JSON and display the messages from it one at a time, with a delay of 2 seconds between each message before ultimately stopping. I a ...

React file viewer failing to display content via Firebase storage URLs

This code snippet is designed to display PDF files uploaded to Firebase storage using React. Here is a sample of the code: import ReactDOM from "react-dom"; import FileViewer from "react-file-viewer"; import "./styles.css"; ...