Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8694357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:46:08+00:00 2026-06-13T00:46:08+00:00

I have a problem with my Three.js Json-Loader. I have some object their path

  • 0

I have a problem with my Three.js Json-Loader. I have some object their path is saved in an array.
Now I want to load them and sort them in a List so that I can select them.
But the order they are loaded is a different than they are in my array after loading because they have different size so the small one are first and the bigger are last. So after loading them I don’t know the name of the object ( the name is the path ).

My code :

for(var j=0;j<21;j++){
        var path = objPath[j];
        loader.load( path, function( geometry ) { save(geometry, path); } );
    }

with this code the path is given to the save methode but there is always the last (objPath[20]) path because the for-loop is faster than the loading methode.
What can I do that the path is the right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:46:10+00:00Added an answer on June 13, 2026 at 12:46 am

    You are being bitten by a rather common mistake involving JavaScript closure rules, see this link. In short, to get the correct path passed to the save function, you need to wrap it into a helper function factory, like this: (or as shown in the above link)

    function saveHelper(path) {
        return function(geometry) {
            save(geometry, path);
        }
    }
    
    for(var j=0;j<21;j++){
        var path = objPath[j];
        loader.load( path, saveHelper(path) );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a great problem about the rotation in three.js I want to rotate
i have one problem with handling list,i have three class named as UserInf,userData,userProcess,i created
I have the next problem: TabControl has three TabPages. Every TabPage has its own
I have a problem where I have to add thirty-three integer vectors of equal
I have a problem with sorting NSTableColumn contents. In my NSTableView there are three
I have the following problem. I have three classes, A, B and C. A
I have three tables being used for this problem: songs, blacklist, and whitelist. The
My problem is that I have three different stock sizes for each product that
In this problem, I have three (identically-structured) lists. Two have all numbers and the
Here's a tricky iPhone problem I've been working on. I have three UIScrollViews on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.