LDraw Model Viewer and Online Tools


LDraw Model Viewer and Online Tools
#1
A model viewer has been added to the LDraw.org website. This new tool will allow you to upload a model and view it in your browser. It's fairly basic at the moment but functionality will continue to be added.

It can be found in the Tools menu on the LDraw.org main site (click the red brick logo above) or directly here:
https://www.ldraw.org/tools/ldraw-model-viewer.html

This new feature is a continuation of an effort started with the LDCad PBG Generator to bring a series of useful tools to the LDraw.org website. Future plans include an model OMRizer and a part error checker.

As always, feature requests and improvements can be posted in the Website Suggestions forums.
Reply
RE: LDraw Model Viewer and Online Tools
#2
(2020-07-01, 16:22)Orion Pobursky Wrote: A model viewer has been added to the LDraw.org website. This new tool will allow you to upload a model and view it in your browser. It's fairly basic at the moment but functionality will continue to be added.

It can be found in the Tools menu on the LDraw.org main site (click the red brick logo above) or directly here:
https://www.ldraw.org/tools/ldraw-model-viewer.html

This new feature is a continuation of an effort started with the LDCad PBG Generator to bring a series of useful tools to the LDraw.org website. Future plans include an model OMRizer and a part error checker.

As always, feature requests and improvements can be posted in the Website Suggestions forums.

OK, nice! Works quite smoothly.
What happens to the files you submit? Are they kept or temporary and deleted after viewing?
One suggestion if possible would be to adjust the lighting.
Jaco van der Molen
lpub.binarybricks.nl
Reply
RE: LDraw Model Viewer and Online Tools
#3
(2020-07-01, 18:01)Jaco van der Molen Wrote: What happens to the files you submit? Are they kept or temporary and deleted after viewing?

Nothing. Everything is handled in browser and it never leaves your computer.

This may change slightly in the future. For the PT, I send the part number to be displayed to the server and it sends back a list of the parts and primitives used in the file. This helps speed the processing of the file since the viewer doesn't need to ping 2/3/4 separate address to figure out where the part data is (official/unofficial parts/p/textures). For models, the script used will get the model data but it won't be saved anywhere, only used internally by the script.
Reply
RE: LDraw Model Viewer and Online Tools
#4
(2020-07-01, 19:27)Orion Pobursky Wrote: Nothing. Everything is handled in browser and it never leaves your computer.

This may change slightly in the future. For the PT, I send the part number to be displayed to the server and it sends back a list of the parts and primitives used in the file. This helps speed the processing of the file since the viewer doesn't need to ping 2/3/4 separate address to figure out where the part data is (official/unofficial parts/p/textures). For models, the script used will get the model data but it won't be saved anywhere, only used internally by the script.

Really looks nice, and I like the way it is construction the model.

But is it loading unofficial Parts properly? I tried a model using part 24121 (unoff), it did not show this part.


PS: On the main page, the part images don't show
Reply
RE: LDraw Model Viewer and Online Tools
#5
(2020-07-01, 20:30)Gerald Lasser Wrote: But is it loading unofficial Parts properly? I tried a model using part 24121 (unoff), it did not show this part.

It's not scanning for unofficial parts at all right now. That would slow down loading even more. Once I implement the script I mention above, it will.
Reply
RE: LDraw Model Viewer and Online Tools
#6
It works really smoothly. Well done. You can get stud logos if you include the texture loading. The default textures are fairly small for performance, but I can generate some that are larger if you think that would be worth the effort.
Reply
RE: LDraw Model Viewer and Online Tools
#7
(2020-07-01, 19:27)Orion Pobursky Wrote: This may change slightly in the future. For the PT, I send the part number to be displayed to the server and it sends back a list of the parts and primitives used in the file. This helps speed the processing of the file since the viewer doesn't need to ping 2/3/4 separate address to figure out where the part data is (official/unofficial parts/p/textures). For models, the script used will get the model data but it won't be saved anywhere, only used internally by the script.

Scratch all this. The way I'm going to implement will not require sending model data to the server. Therefore any model you use will never go anywhere but your browser.
Reply
RE: LDraw Model Viewer and Online Tools
#8
(2020-07-01, 22:08)Lasse Deleuran Wrote: You can get stud logos if you include the texture loading..

I basically copied your sample code so if that doesn't load textures then the model viewer won't either. 
As for logos, this is the bug I reported. When I do stud logos, the loader want 3-4disc but never actually tries to load it.
Reply
RE: LDraw Model Viewer and Online Tools
#9
(2020-07-01, 22:35)Orion Pobursky Wrote: I basically copied your sample code so if that doesn't load textures then the model viewer won't either. 
As for logos, this is the bug I reported. When I do stud logos, the loader want 3-4disc but never actually tries to load it.
I see. I have fixed the bug so that 3-4disc is loaded using Generator. Or rather. You fixed it in your bug report and I just verified and applied it.
Reply
RE: LDraw Model Viewer and Online Tools
#10
I've updated the model viewer. It now pulls unofficial parts If they're not included in the model. Additionally, I've implemented a part path prefetch (like is used on the PT) to speed up loading. There is a note about how the model data is used at the bottom of the page.
Reply
RE: LDraw Model Viewer and Online Tools
#11
(2020-07-01, 16:22)Orion Pobursky Wrote: A model viewer has been added to the LDraw.org website. This new tool will allow you to upload a model and view it in your browser. It's fairly basic at the moment but functionality will continue to be added.

It can be found in the Tools menu on the LDraw.org main site (click the red brick logo above) or directly here:
https://www.ldraw.org/tools/ldraw-model-viewer.html

This new feature is a continuation of an effort started with the LDCad PBG Generator to bring a series of useful tools to the LDraw.org website. Future plans include an model OMRizer and a part error checker.

As always, feature requests and improvements can be posted in the Website Suggestions forums.

Model viewer has been update to add:
- The ability to change the background color
- The ability to switch between the cell shaded view and the photo render style
- Also added a bunch of under the hood improvements.
Reply
RE: LDraw Model Viewer and Online Tools
#12
I am trying to submit and view a model that does not load.
The process stalls at loading 3-16cyls.dat?
Another model that has kind of the same bricks does load.
At least, I think it also has 3-16cyls.dat in a brick somewhere, because I briefly see it loading.

What could cause this?
Jaco van der Molen
lpub.binarybricks.nl
Reply
RE: LDraw Model Viewer and Online Tools
#13
(2021-06-03, 10:52)Jaco van der Molen Wrote: I am trying to submit and view a model that does not load.
The process stalls at loading 3-16cyls.dat?
Another model that has kind of the same bricks does load.
At least, I think it also has 3-16cyls.dat in a brick somewhere, because I briefly see it loading.

What could cause this?

Sorry for the delay.  Can you post or PM the model  in question so can test it?
Reply
RE: LDraw Model Viewer and Online Tools
#14
(2021-06-07, 23:27)Orion Pobursky Wrote: Sorry for the delay.  Can you post or PM the model  in question so can test it?

Np

I have PMd you.
Jaco van der Molen
lpub.binarybricks.nl
Reply
RE: LDraw Model Viewer and Online Tools
#15
(2021-06-08, 5:45)Jaco van der Molen Wrote: Np

I have PMd you.

This report has uncovered a much deeper bug. Some models load, others don't.  There doesn't seem to be any discernible pattern. Apparently all my test files didn't have whatever problem is causing buildinginstructions.js to crash but figuring out what that is will take some more digging.
Reply
RE: LDraw Model Viewer and Online Tools
#16
(2021-06-09, 15:43)Orion Pobursky Wrote: This report has uncovered a much deeper bug. Some models load, others don't.  There doesn't seem to be any discernible pattern. Apparently all my test files didn't have whatever problem is causing buildinginstructions.js to crash but figuring out what that is will take some more digging.

OK, strange. But good luck bughunting. I'm afraid I cannot help you with that, but if you need any testing done, let me know!
Jaco van der Molen
lpub.binarybricks.nl
Reply
RE: LDraw Model Viewer and Online Tools
#17
(2021-06-09, 18:06)Jaco van der Molen Wrote: OK, strange. But good luck bughunting. I'm afraid I cannot help you with that, but if you need any testing done, let me know!

I think I've fixed the issue. I'm still not sure what the problem was but my fix bypasses all the issues (I think) by totally regenerating the model object. I did find another bug involving changing background color but that doesn't affect the rendering of the model.
Reply
RE: LDraw Model Viewer and Online Tools
#18
(2021-06-11, 3:01)Orion Pobursky Wrote: I think I've fixed the issue. I'm still not sure what the problem was but my fix bypasses all the issues (I think) by totally regenerating the model object. I did find another bug involving changing background color but that doesn't affect the rendering of the model.

Great. I have tested with my model and it works like a charm. Even on my iPhone! Very fast and smooth! TNX
Jaco van der Molen
lpub.binarybricks.nl
Reply
RE: LDraw Model Viewer and Online Tools
#19
Hey @Orion Pobursky,

I would like to use the Viewer for a small university webpage for a lego lab (a lego lab made with school children, only for educational purpose).

We have a few own models (as .ldr files, converted from Lego Studio .io) and we would only need a basic simple viewer to show/zoom/rotate the 3D models as a motivation for the kids how the final model looks like.

Is there a copyright?

Or did you just used the ldraw viewer docs from ThreeJS for building it ?

Any code you would like to share (basic functionality around ldraw viewer) ?
Reply
RE: LDraw Model Viewer and Online Tools
#20
(2023-10-09, 14:30)Eduard Wrote: Hey @Orion Pobursky,

I would like to use the Viewer for a small university webpage for a lego lab (a lego lab made with school children, only for educational purpose).

We have a few own models (as .ldr files, converted from Lego Studio .io) and we would only need a basic simple viewer to show/zoom/rotate the 3D models as a motivation for the kids how the final model looks like.

Is there a copyright?

Or did you just used the ldraw viewer docs from ThreeJS for building it ?

Any code you would like to share (basic functionality around ldraw viewer) ?

Hi Eduard,

We are using buildinginstructions.js (which in turn is using ThreeJS) found here:
https://github.com/LasseD/buildinginstructions.js

There is some custom code involved but that's just to make things easier on the back end. Lasse's instructions can be used as is.

Our code can be found here:
https://github.com/ldraw-org/ldraworg-li...js/ldbi.js
https://github.com/ldraw-org/ldraworg-li...rgscene.js
Reply
RE: LDraw Model Viewer and Online Tools
#21
(2021-06-11, 3:01)Orion Pobursky Wrote: I think I've fixed the issue.

"File(s)" upload form does not work.Tested in few various browsers, and results are the same for all the cases.
Reply
RE: LDraw Model Viewer and Online Tools
#22
This feature is currently somewhat broken and slated to be moved to the library site.
Reply
RE: LDraw Model Viewer and Online Tools
#23
I've patched it up and the viewer is now here:
https://library.ldraw.org/model-viewer

I didn't extensively test it so there might be quirks.
Reply
RE: LDraw Model Viewer and Online Tools
#24
something i noticed: edgelines in inside corners are hard to see...
(which then sometimes looks like a missed one)
Reply
RE: LDraw Model Viewer and Online Tools
#25
(2024-10-18, 10:29)Rene Rechthaler Wrote: something i noticed: edgelines in inside corners are hard to see...
(which then sometimes looks like a missed one)

This is a known problem with lines in WebGL. I vaguely remember a discussion here on the forums if you want to dig for it.
Reply
RE: LDraw Model Viewer and Online Tools
#26
When I toggle Photo Mode, I can then see the (red) Technic Half-Pins w/ Friction in the connectors. 

Thanks, 
Franklin

   

   
Reply
RE: LDraw Model Viewer and Online Tools
#27
I made a few tweaks to the part fetch routine. Using your model, I'm not seeing the problem you mention. Is it fixed on your end?
Reply
RE: LDraw Model Viewer and Online Tools
#28
(2024-10-18, 16:13)Orion Pobursky Wrote: This is a known problem with lines in WebGL. I vaguely remember a discussion here on the forums if you want to dig for it.

Normally a program would polygonOffset to push the solid polygons back in the Z-Buffer a little bit so that when the edge lines are drawn, they don't get hidden like this. (LDView does the equivalent with OpenGL.) I'm not sure if this is compatible with modern WebGL, but I don't see any indication that it isn't. (Note: polygonOffset must push back the solid polygons; it cannot be used to pull the edge lines forward.)
Reply
RE: LDraw Model Viewer and Online Tools
#29
There are various issues: fully transparent parts, visible hidden edges, Z-fighting in opaque parts, Milky White looks incorrectly in Photo mode, etc.

Test MPD-model and screenshots of issues in LeoCAD and LDView are here:

               
Reply
RE: LDraw Model Viewer and Online Tools
#30
This is a rendering software issue (transparency can be tricky).

Open an issue with buildinginstructions.js:
https://github.com/LasseD/buildinginstructions.js/


Edit: I take this back for now as the 3D preview for the tracker doesn't do this.
Reply
RE: LDraw Model Viewer and Online Tools
#31
(2024-10-18, 21:47)Orion Pobursky Wrote: This is a rendering software issue (transparency can be tricky).

Open an issue with buildinginstructions.js:
https://github.com/LasseD/buildinginstructions.js/


Edit: I take this back for now as the 3D preview for the tracker doesn't do this.

As you can see, among other issues, there is an issue that shortcut part is rendered a bit different (and has different glitches) than if stack its subparts manually and place alongside.

The same issue has both LeoCAD and LDView: https://forums.ldraw.org/thread-26372-po...l#pid55313
Reply
RE: LDraw Model Viewer and Online Tools
#32
(2024-10-18, 19:10)Orion Pobursky Wrote: I made a few tweaks to the part fetch routine. Using your model, I'm not seeing the problem you mention. Is it fixed on your end?

Sorry, they still show.  :-(  

FWIW, you are probably using a previous version of my model, where those parts were still color-72, Dark Grey, which is why you won't see this problem. Here is the relevant segment of DAT code, updated: 

Code:
0 FILE joint.ldr
1  71    0    0    0  0  0 -1  0 -1  0 -1  0  0 32016.dat
0 STEP
1   4    0    0  -10  0  0  1  0  1  0 -1  0  0 89678.dat
0 STEP
1  16    0    0    0  1  0  0  0  1  0  0  0  1 joint-pt01.ldr
0 //
1  16    0    0    0 -0.924 -0.383  0  0.383 -0.924  0  0  0  1 joint-pt01.ldr
0 STEP
1  16    0    0  -10  0.981  0  0.195 -0.195  0  0.981  0  1  0 joint-pt02.ldr
0 NOFILE

0 FILE joint-pt01.ldr
1   1   30    0    0 -1  0  0  0  1  0  0  0 -1 43093.dat
0 NOFILE

0 FILE joint-pt02.ldr
1  72    0    8  -20  1  0  0  0  1  0  0  0  1 85861.dat
0 STEP
1  71    0    0  -20  0  0  1  0  1  0 -1  0  0 15712.dat
0 STEP
1  72    0   -8    0  1  0  0  0  1  0  0  0  1 26047.dat
0 STEP
1  71    0  -16    0  0  0 -1  0  1  0  1  0  0 32828.dat
0 NOFILE

Thanks! 
Franklin
Reply
RE: LDraw Model Viewer and Online Tools
#33
I've confirmed that there is a difference between the tracker and the model viewer. 

Also, FWIW, LDCad renders the boat motor test file with no obvious problems.
Reply
RE: LDraw Model Viewer and Online Tools
#34
(2024-10-18, 23:19)Orion Pobursky Wrote: Also, FWIW, LDCad renders the boat motor test file with no obvious problems.

Confirms, in LDCad all looks good.

   
Reply
RE: LDraw Model Viewer and Online Tools
#35
(2024-10-19, 0:52)Eugen Wrote: Confirms, in LDCad all looks good.

UPDATE: There is at least one issue in LDCad too.

(its not observable with "default" GUI Template, due to background color match in issue zone, but with "dark" GUI Template it clearly visible and diffirentiate shortcut rendering from the same but assembled manually from subparts).

   
Reply
RE: LDraw Model Viewer and Online Tools
#36
I went to troubleshoot the above problem. On my work computer I got some similar to the screenshot you posted but I can't replicate on my home computer.

Here's the Firefox screenshot:
   

Here's the Chrome screenshot:
   

This leads me to believe this some sort of external graphics issue and beyond my ability to fix.
Reply
RE: LDraw Model Viewer and Online Tools
#37
(2024-10-18, 22:44)Franklin W. Cain Wrote: Sorry, they still show.  :-(  

FWIW, you are probably using a previous version of my model, where those parts were still color-72, Dark Grey, which is why you won't see this problem. Here is the relevant segment of DAT code, updated: 

Code:
0 FILE joint.ldr
1  71    0    0    0  0  0 -1  0 -1  0 -1  0  0 32016.dat
0 STEP
1   4    0    0  -10  0  0  1  0  1  0 -1  0  0 89678.dat
0 STEP
1  16    0    0    0  1  0  0  0  1  0  0  0  1 joint-pt01.ldr
0 //
1  16    0    0    0 -0.924 -0.383  0  0.383 -0.924  0  0  0  1 joint-pt01.ldr
0 STEP
1  16    0    0  -10  0.981  0  0.195 -0.195  0  0.981  0  1  0 joint-pt02.ldr
0 NOFILE

0 FILE joint-pt01.ldr
1   1   30    0    0 -1  0  0  0  1  0  0  0 -1 43093.dat
0 NOFILE

0 FILE joint-pt02.ldr
1  72    0    8  -20  1  0  0  0  1  0  0  0  1 85861.dat
0 STEP
1  71    0    0  -20  0  0  1  0  1  0 -1  0  0 15712.dat
0 STEP
1  72    0   -8    0  1  0  0  0  1  0  0  0  1 26047.dat
0 STEP
1  71    0  -16    0  0  0 -1  0  1  0  1  0  0 32828.dat
0 NOFILE

Thanks! 
Franklin

Your using a mirrored matrix on this line:
Code:
1  16    0    0  -10  0.981  0  0.195 -0.195  0  0.981  0  1  0 joint-pt02.ldr
It causes problem in LDCad as well.
Reply
RE: LDraw Model Viewer and Online Tools
#38
(2024-10-19, 3:15)Orion Pobursky Wrote: This leads me to believe this some sort of external graphics issue and beyond my ability to fix.

You may try to test all the same apps & browsers with sandboxing them from external graphics by forcing to use software OpenGL

On Linux:

Code:
$ env LIBGL_ALWAYS_SOFTWARE=1 <program>

On Windows and Mac use appropriate Mesa3D builds and instruction.
Reply
RE: LDraw Model Viewer and Online Tools
#39
It's not worth the trouble since the problem will lie with WebGL render package which I didn't write and don't have the knowledge, skills, or time to try to fix.
Reply
RE: LDraw Model Viewer and Online Tools
#40
(2024-10-19, 3:32)Orion Pobursky Wrote: You're using a mirrored matrix on this line:
Code:
1  16    0    0  -10  0.981  0  0.195 -0.195  0  0.981  0  1  0 joint-pt02.ldr
It causes problem in LDCad as well.

Sweet!  ^_^  This worked: 

Code:
1  16    0    0  -10 -0.981  0  0.195  0.195  0  0.981  0  1  0 joint-pt02.ldr

Thanks again!  ;-)  
Franklin
Reply
RE: LDraw Model Viewer and Online Tools
#41
(2024-10-19, 4:09)Orion Pobursky Wrote: It's not worth the trouble since the problem will lie with WebGL render package which I didn't write and don't have the knowledge, skills, or time to try to fix.

OK, lets leave external graphics issues to its software developers.

But why there is a difference between shortcut and the manually assembled model from subparts?

This difference looks like LDraw-specific issue, as it appears more or less in all the programs and in online viewer too.
Reply
RE: LDraw Model Viewer and Online Tools
#42
(2024-10-19, 4:50)Eugen Wrote: OK, lets leave external graphics issues to its software developers.

But why there is a difference between shortcut and the manually assembled model from subparts?

This difference looks like LDraw-specific issue, as it appears more or less in all the programs and in online viewer too.

This is most likely a difference between how a viewer handles a "model" vs a "part" vs a "subpart". I know, for example, that if seams are turned on then LDView shrinks "parts" slightly but not "models". "Subparts" are shrunk with their parent parts. Try turning off seams and see if that changes things in LDView.
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 14 Guest(s)