Repeating Sprite Textures in THREEJS

I have a sprite and I am attempting to make the texture repeat continuously.

Despite using what I believe are the correct settings, it doesn't seem to be working as expected. Is there something I am missing?

Here is the outcome I am seeing: https://i.sstatic.net/s1I1Y.png

This is the code I am using:

    var bgTexture = new THREE.TextureLoader().load('/bg.png');
    var spriteMaterial = new THREE.SpriteMaterial({ map: bgTexture });

    spriteMaterial.wrapS = spriteMaterial.wrapT = THREE.RepeatWrapping;
    spriteMaterial.map.offset.set( 0, 0 );
    spriteMaterial.map.repeat.set( 10, 1 );

    var sprite = new THREE.Sprite(spriteMaterial);
    sprite.position.y = 0;
    sprite.position.x = 0;
    sprite.scale.x = 10;
    sprite.scale.y = 1;
    this.scene.add(sprite);

Answer №1

In order to properly configure the wrapping of textures in your code, ensure that you are setting the properties .wrapS and .wrapT to the Texture object instead of the SpriteMaterial:

spriteMaterial.wrapS = spriteMaterial.wrapT = THREE.RepeatWrapping;

spriteMaterial.map.wrapS = spriteMaterial.map.wrapT = THREE.RepeatWrapping;

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

Unraveling the complexities of NodeJS: Exploring the concepts of nonblocking operations,

Exploring the concept of Node's non-blocking nature as a newcomer. I've put together a simplified diagram below illustrating how requests flow. From what I gather, all processes for a single user in an app operate on one thread. My curiosity ...

What is the best way to pass a VueJS object to be stored in a Laravel controller?

I am facing an issue with my methods where the data is not getting stored in the database. I am unsure why the information is not being sent to the controller. Even though I input the correct data, it fails to load into the database. However, it does pass ...

Attempting to develop a server component that will transmit a JSON result set from a MySQL database located on the local server. What is the best method to send the server object (RowDataPacket) to the

After successfully rendering server-side pages and creating forms with react hooks for database updates, I encountered a challenge in integrating Ag-Grid into my application. Despite being able to retrieve data from the database using the mysql2 module and ...

Determining height of an element in AngularJS directive prior to rendering the view

As I dive into the world of Angular, any assistance is greatly welcomed. My goal is to vertically align a div based on screen size (excluding the header and footer) when the page loads, the window resizes, and during a custom event triggered by the user ex ...

Prestashop: Eliminate user uploaded files with AJAX for seamless experience

By default, a user uploaded image will display with a small black X indicating it can be deleted: <a href="path/to/yourproduct?deletePicture=1" title="Delete" > When the user clicks on this button, the page 'reloads' and the uploaded file ...

Having trouble loading AngularJS 2 router

I'm encountering an issue with my Angular 2 project. Directory : - project - dev - api - res - config - script - js - components - blog.components.js ...

What could be the reason for the malfunction of my error handler in ExpressJS?

Currently, I am in the process of constructing an API using ExpressJS for one of my projects and am keen on incorporating error handling. Despite consulting various online resources for guidance, I have experimented with different approaches to implement e ...

Implementing a JSON array to object conversion in an Express REST API

After conducting a test on a REST API using Postman, the outcome was as follows: { "success": true, "message": "success", "data": [ { "id_buku": 9, "judul_bu ...

Transmit information from a bean to JavaScript using JSON in JavaServer Faces

I need help transferring my arraylist from a managedBean to JavaScript code. The bean code is shown below: public void getDataAsJson(){ String [] dizi={"Tokyo","Jakarta","New York","Seoul", "Manila","Mumbai","Sao Paulo","Mexico City", ...

Stop unauthorized access to PHP files by utilizing AJAX

Is there a way to prevent direct access to a specific PHP file named prevented.php? My approach involves a main file called index.php, which generates and stores a token in a $_SESSION variable. Additionally, there is another file called def.php that is ac ...

Uploading files in javascript and PHP

I am currently utilizing an audio recorder provided by this source , However, instead of storing the file locally, I am interested in uploading it back to the server. My attempt involved adjusting the Recorder.setupDownload function within the recording. ...

Access the blob file saved in the indexedDB on an iOS device or iPad

Greetings, I am currently fetching a file using axios in the following manner: return axios({ method: "get", url: URL, responseType: "blob", }) .then((response) => { return { ...val, ...

Is there a common method for generating complex identifiers to be used as the HTML element's id, class, or name attributes

Is there a recommended method for "encoding" complex identifiers such as {Source:"ARCH.1", Code: "456-789.456 A+", SubNumber:##2} to be used in HTML elements' id, class, and name attributes? I could come up with something myself, but perhaps there is ...

Is it possible to showcase dates within input text boxes prior to POSTing the form?

I am currently working on a form that posts to a PHP script by selecting a date range. For a better understanding, you can check out my visual representation here. Before the data is posted, I would like to display the selected dates in empty boxes or inpu ...

Limit access to route in ExpressJS only to internal redirects

I'm managing an ExpressJS application that includes specific routes which I intend to only function when redirected to from my code, rather than input directly into the URL. Essentially, if a user attempts to enter "myapp.com/url" it should not be ac ...

The Bootstrap drop-down feature refuses to open

I seem to be having trouble with a basic issue. I used the standard template from the bootstrap website, but for some reason, when I click on the dropdown menu in the navbar, it's not opening. Can someone help me figure out what's going wrong? & ...

Utilizing Vue and Prismic rich text: incorporating an event listener onto a span element

In my Vue app, I am retrieving content from Prismic using an API CMS. Within this content, there are certain sections enclosed in span tags with a unique class. My goal is to target those specific span nodes in Vue and apply an event listener to them. Whe ...

Update a div container using jQuery

Hey there, I need some help with a specific part of my code snippet: <div class="tags-column" id="tags"> <h2>Tags</h2> <ul> <% @presenter.tag_counters.each do |tag_counter| %> <li class=" ...

Fixing the problem of digest overflow in AngularJS

I've been working on a code to display a random number in my view, but I keep encountering the following error message: Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! It seems to be related to a digest outflow issue, and I&apo ...

Steps to create a personalized material-ui element

I am looking to create a custom time duration component by modifying the TextField component. https://i.stack.imgur.com/fLsFs.png https://i.stack.imgur.com/SdpdH.png If anyone has any advice or assistance, it would be greatly appreciated. Thank you! ...