LDraw.org Discussion Forums
3D Part Preview added to Parts Tracker - Printable Version

+- LDraw.org Discussion Forums (https://forums.ldraw.org)
+-- Forum: General (https://forums.ldraw.org/forum-12.html)
+--- Forum: LDraw.org Announcements (https://forums.ldraw.org/forum-1.html)
+--- Thread: 3D Part Preview added to Parts Tracker (/thread-23540.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11


RE: 3D Part Preview added to Parts Tracker - Orion Pobursky - 2019-07-12

(2019-07-11, 8:39)Philippe Hurbain Wrote: Note: sometimes it works directly without reload.

Well my tweak didn’t work out. What’s odd is that it doesn’t work and then you refresh the page and it does. I’ll do some more google digging.


RE: 3D Part Preview added to Parts Tracker - Lasse Deleuran - 2019-07-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!


RE: 3D Part Preview added to Parts Tracker - Orion Pobursky - 2019-07-12

(2019-07-12, 23:34)Lasse Deleuran Wrote: 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!

Part of the "problem" is that for the PT I prioritize unofficial over official. Since most primitives aren't unofficial, that load has to fail before it'll try for the official version.


RE: 3D Part Preview added to Parts Tracker - Orion Pobursky - 2019-07-13

(2019-07-11, 1:14)Orion Pobursky Wrote: Doesn't work on Mobile Safari or Chrome for iOS. Does work on iOS Firefox.

This now seems to be fixed. I'm not sure what solved the problem since I only streamlined the code and didn't make any major changes.


RE: 3D Part Preview added to Parts Tracker - Michael Horvath - 2019-07-13

(2019-07-12, 23:34)Lasse Deleuran Wrote: 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!

If "p" were a sub-directory of "parts" it might help...


RE: 3D Part Preview added to Parts Tracker - Steffen - 2019-07-13

looks very good, thank you very much.


RE: 3D Part Preview added to Parts Tracker - Steffen - 2019-07-13

(2019-07-09, 16:36)Orion Pobursky Wrote: Others may disagree but I actually think the flat, instructions style is better for our uses.

I agree with you.
Our 3D viewer is not intended to make things beautiful and hide errors, but the opposite.
It needs to show everything in great clarity, to allow us to do what the PT is for:
finding glitches.


RE: 3D Part Preview added to Parts Tracker - Steffen - 2019-07-13

super cool


RE: 3D Part Preview added to Parts Tracker - Steffen - 2019-07-13

I suggest a different approach:
why not initially send a full list of all primitives available to the client before he starts to download individual files?
then he can know that everything else is a part. no more regex guessing.
the same goes for "unofficial files vs official file":
can't the client initially get a simple list of all unofficial (or: official) files?
he could even locally cache it.
then also no more guesswork with regexes would be needed.
Of course, if these lists get very large, the benefit would be spoiled, but currently I think:
- the download of such lists could be faster than N failed URL accesses
- the downloaded list could be cached on client side maybe
- it could be sent in compressed form
- it could be pre-calculated on the server

While I am writing this, I come to another idea:
the server knows everything about every file.
it knows what is a primitive and what is a part etc.,
and which one is official and which one is unofficial.
Thus, when a client requests to download some file, say 777.dat,
the server can help the client and compile a list of "meta" info for the client, telling him
which file is official and which one not, and the folder in which it is to be found.
The client would access something like
www.ldraw.org/get_list_of_required_files_for?777.dat
, and the server would reply with a JSON which could look like
Code:
{
   "official" :
   [
      { "s"    : [ "777s01.dat", "777s02.dat"   ] },
      { "p"    : [ "4-4disc.dat", "4-4cyli.dat" ] },
      { "p/48" : [ "2-4ndis.dat", "stud.dat"    ] },
      { "p/8"  : [ "2-4ndis.dat", "stud.dat"    ] }
   ],

   "unofficial" :
   [
      { "s" : [ "123s01.dat", "456s02.dat"   ] },
      { "p" : [ "3-4disc.dat", "3-4cyli.dat" ] }
   ]
}
This reply will make it easy for the client to construct the URL for downloading the required files.


RE: 3D Part Preview added to Parts Tracker - Lasse Deleuran - 2019-07-13

Those are all great ideas! It should be straight forward to make the guesser prioritize unofficial primitives over everything else when an unofficial element is being shown.

I have dug further into the idea of caching primitives client-side. Caching unofficial parts and primitives is a little troublesome since they might change, but caching official parts and primitives should be safe, right? This is what the ClientStorage.js does. I have updated the sample file to use this. It builds an "IndexedDB" store on the client with compressed geometries which are fetched before the code attempts to make a server call.

There is also an even more extreme measure (which can be turned off, of course): LDRGenerator.js. This generates the simplest of primitives directly in the code (like PrimGen2) and is even faster than the IndexedDB! Currently only 24 primitives are supported here, but this approach has great potential.

Oh. I almost forgot. The code not also supports high contrast studs and studs with logos (all 5 types of logos that are found in the LDraw unofficial primitives directory)

[Image: WneR0XW.png]
High contrast and logos can be configured using simple parameters:

ldrOptions.studHighContrast = 0; // Set to 1 for high contrast

ldrOptions.studLogo = 0; // 0 for no logo, 1 to 5 for logo types 1 to 5


I apologize for any typos. I was up the whole night because I got too deep into this... and it is quite fun.