3D Part Preview added to Parts Tracker


RE: 3D Part Preview added to Parts Tracker
#12
I can see a lot of the current waiting time is largely caused by the renderer guessing wrongly when trying to find the right location of a file (is the file a primitive, a part, official or unofficial). I would like to improve this and have made the following improved "guesser" available in the code base:

Code:
        if(id.startsWith('48/') || id.startsWith('8/')) {
          return [OFFICIAL_DIR + '/p/' + id,
                  UNOFFICIAL_DIR + '/p/' + id];
        }
        else if(id.startsWith('s/')) {
          return [OFFICIAL_DIR + '/parts/' + id,
                  UNOFFICIAL_DIR + '/parts/' + id];
        }
        else if(id.match(/[a-z][a-z].*\.dat/)) {
          return [OFFICIAL_DIR + '/p/' + id,
                  OFFICIAL_DIR + '/parts/' + id,
                  UNOFFICIAL_DIR + '/p/' + id,
                  UNOFFICIAL_DIR + '/parts/' + id];
        }
        else {
          return [OFFICIAL_DIR + '/parts/' + id,
                  OFFICIAL_DIR + '/p/' + id,
                  UNOFFICIAL_DIR + '/parts/' + id,
                  UNOFFICIAL_DIR + '/p/' + id];
        }

The first two branches are easy: If a part starts with "48/" then it is a high res primitive, and similarly for "8/" and "s/" being low-res primitives and sub parts, respectively. This is the same as the current code.

The trick is for other files: Is the file we want to load a primitive or a part?
The crude regular expression (where it says "match") tries to detect primitives. It triggers for any part name where two letters are adjacent, that is, without numbers between them.

Primitives, such as "4-4cyli.dat", "1-2disc.dat", "stud.dat" etc. all have two letters in their part id.

while parts are typically something along the lines of "3001.dat", "2461a.dat", etc. They very rarely have more than one letter next to each other (disregarding the ".dat" suffix).

This method is extremely crude, so I would like if anyone can make a better "guesser". I have tested it locally and the loading time more than halves!
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: 3D Part Preview added to Parts Tracker - by Lasse Deleuran - 2019-07-12, 23:34

Forum Jump:


Users browsing this thread: 18 Guest(s)