The application of textures in Three.js models is not working correctly on the entire object

I am encountering an issue with applying textures on both the top and bottom faces of a surfboard obj file. The texture seems to split in the middle instead of being applied seamlessly across the face, and it also gets applied on the inside of the mesh. I am unsure if this problem is related to the model itself or if there is something missing in my code.

var loader = new THREE.OBJLoader();

    var texture = new THREE.Texture();
    var ImageLoader = new THREE.ImageLoader();
    ImageLoader.load("models/white.jpg", function (image) {
        texture.image = image;
        texture.needsUpdate = true;
    });

    var custom = new THREE.Texture();
    var customLoader = new THREE.ImageLoader();
    customLoader.load("models/UV_Grid_Sm.jpg", function(image) {
        custom.image = image;
        custom.mapping = THREE.UVMapping;
        custom.needsUpdate = true;
    });


    loader.load("models/Hidden 5'4-19'5-2 (Holes_Patched).obj", function(object){
        object.traverse(function(child) {

            if (child instanceof THREE.Mesh) {

                if(child.name === 'Bottom') {
                    child.material = new THREE.MeshStandardMaterial({ map: custom});

                }
                else if(child.name === 'Top') {
                    child.material = new THREE.MeshStandardMaterial({ map: custom});

                }
                else  {
                    child.material = new THREE.MeshStandardMaterial({ map: texture});

                }
            }

        });

download obj file here The object has two group named "Top" but I can change that later.

Answer №1

Make sure to define UV coordinates for the model in your 3D software, such as 3DS Max.
Additionally, consider refining and optimizing your model by eliminating unnecessary edges and vertices (134 thousand verts seems excessive).

https://i.sstatic.net/Uzh6B.gif

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

Guide to adding items to an array in json-server using a JavaScript-created database

I built a JSON-server app that dynamically generates the database using JavaScript when it starts running. The data I create is organized within a 'users' object, as illustrated below: { "users": [ { "id": "user_id_0", ...

Exploring the possibilities with New Relic and React

I am working with a react-router layout which currently contains a string that includes the New Relic javascript snippet. Now, I want to utilize the Browser Agent and set a custom attribute. newrelic.setCustomAttribute(name, value) The global variable n ...

Implement the maskmoney library in your input fields

In the form below, I am automatically adding inputs using a JavaScript function like this: $('.Preco1').maskMoney({ decimal: '.', thousands: ' ', precision: 2 }); $('.Preco1').focus(); $('#sub').maskMon ...

Alter the properties based on the size of the window

I am working with React-Spring and I need to adjust the offset of a component when the window size changes. I attempted the following solution, but it is not functioning correctly and requires me to refresh the browser each time. <ParallaxLayer ...

How to mock nested functions within sinon

There are several questions similar to this one, but none of them quite match the scenario I'm dealing with. The situation involves a function that takes another function as a parameter: var myfunc = (func_outer) => { return func_outer().func ...

Updating content with jQuery based on radio button selection

Looking for assistance with a simple jQuery code that will display different content when different radio buttons are clicked. Check out the code here. This is the HTML code: <label class="radio inline"> <input id="up_radio" type="radio" n ...

Leveraging JavaScript and Thymeleaf to manipulate a list

I am trying to access an object from a list in JavaScript, which is being passed from the controller. Currently, I am working with Thymeleaf and Spring Boot. The list is named ${collaborateurs}. The following code snippet is functional: <script th: ...

Is the function failing to return a value?

I'm facing an issue with a certain piece of code that doesn't seem to be working as expected. Essentially, I have an array containing the accepted file types for a specific component. The code is designed to iterate over this array and check if t ...

Having trouble modifying the fields in the formArray

https://i.sstatic.net/B4uTq.pngWorking with reactive forms, I have a UI feature that displays radioButton options which, when selected, reveals details about the chosen value within the form. Once a button is selected, the form fetches data from the backen ...

Dividing the JSON dataset into smaller segments

Here is an example demonstrating how to split the JSON data: var data = [ { BankName: 'SBI', IFSC: 'SBIN0002688' }, { BankName: 'ICICI', IFSC: 'ICIC0003931', MICR: '500229094'}, { BankName: 'RBI ...

What is the best way to compare dates in PostgreSQL timestamp with time zone?

In my PostgreSQL database, there is a field labeled as "timestamp with time zone compare" Currently, I am trying to implement a data range comparison using JavaScript var start = Date.UTC(2012,02,30);//1333065600000 var end = Date.UTC(2013,02,30); //136 ...

After inserting the Telerik component, the code <% ... %> is throwing an error

I have a webpage with ASPX that utilizes JavaScript and ASP components without issues. However, after adding a Telerik combobox, I encountered an error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %& ...

Leveraging the power of AngularJS' ngAnimate for smooth transitions when deleting an item from the scope

I have a basic question: How can I utilize ngAnimate in AngularJS 1.2.x to trigger animations when removing an item from the scope? Here is an example Plunker for reference: http://plnkr.co/edit/tpl:FrTqqTNoY8BEfHs9bB0f?p=preview Code snippet: <bo ...

What is the process for verifying the ongoing sessions within a particular set of classes?

I have a list of 10 items with varying active classes based on user interactions. I need to determine the number of sets of 3 consecutive active classes within the list. In the given example, there are 2 sets of 3 consecutive active classes: 4,5,6 and 8,9, ...

Dynamic translation routing with Next.js

My goal is to create dynamic translation routes for specific pages in next js using i18next. While the following code works well, it currently routes to all pages and generates errors during next build. const router = useRouter(); const path = router.route ...

consolidating express routes in one consolidated file

I am attempting to consolidate routes into a single file using app.use app.js import express from 'express' import testRouter from 'testRouter' const app = express() app.use('/testRouter', testRouter) app.listen(3000) tes ...

Enable a VueJS directive on-the-fly from a separate directive

My goal is to simplify the process of binding a form control to vuejs by creating a directive that handles all necessary events for tracking changes in a form field. Rather than manually adding multiple event listeners like this: <input type="text" na ...

Strategies for transmitting computed variables from a controller to JavaScript once the computation is complete?

Within my application, I have a button that triggers an action called "method" present in the UserController. This particular action involves executing some specific tasks. def method ***performing necessary calculations and operations*** @my_variable ...

A guide on retrieving the selected option from a dropdown menu with React Material UI

Utilizing Material UI React, I am constructing a dropdown menu containing various options. My concern is: if I choose two options from different dropdowns within the menu, how can I intercept or store which option was selected? Below is a snippet of my co ...

Converting a function to an ES6 class-based style

Hello, I am new to ES6 and eventEmitter. I have created a module in Node.js with an event-based style and now I am trying to convert it to ES6 class style. This is my code: // eventStyle.js const events = require('events'); const util = require ...