question

Fiona Kattenstroth avatar image
0 Likes"
Fiona Kattenstroth asked Jacob E2 commented

How can I display a website in a plane in the 3D model?

I want to display a website with graphs and figures directly in the 3D model. The object in which it will be displayed in the 3D model isn't important, just the fact that you can see the website directly. I've been able to show a website in a GUI, but that is not excatly what I'm looking for, because the model is huge and I need to display several sides at different positions. I hope someone can help me. Thank you in advance

FlexSim 20.1.0
flexsim 20.1.0guiconnectionswebsite
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Phil BoBo avatar image
1 Like"
Phil BoBo answered Jacob E2 commented

If you want to display a rendered website on a texture in the 3D model, then you can first render the website on an HTML view, then save that view to a file, then load that image, and finally set an object's texture to that loaded image.

Attached is an example model (RenderWebsiteToTexture.fsm) demonstrating this with two user commands and a custom GUI.


· 11
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Phil BoBo avatar image Phil BoBo ♦♦ commented ·

If there are certain pages that you cannot display, then you need to figure out why those pages don't display.

Here is an image showing what is happening in what order:

1. You call the renderWebViewToTexture() user command.

2. That user command calls createview() to open the RenderTextureView custom GUI and load the page.

3. The OnLoad of that GUI calls finishedWebViewRender() user command.

4. That user command repaints the view, saves it to a file, and loads it into a texture on the object.

If the page finishes loading early and then uses JavaScript to load additional information asynchronously, then the OnLoad may be firing before the page is ready. Comment out line 19 of finishedWebViewRender() in order to leave the window open and verify that the page is being rendered correctly at all. Then comment out the call to finishedWebViewRender() command from OnLoad and call it yourself once the page has actually finished loading.

This will split the process into pieces and you can determine what is wrong and how to fix it for the site you want to display.

treenode view = node("/active/RenderTextureView/HTMLView", views());
if (objectexists(view)) {
    finishedWebViewRender(view);
}
0 Likes 0 ·
Fiona Kattenstroth avatar image Fiona Kattenstroth commented ·

@phil.bobo thanks, that really helped me! The only problem left is that I want to display multiple pages and they have to be opened to show the right content in the plane. It'd be better if they'd be open in the background. Therefore I put them behind the model (the unnamed tabs right to the view):

But then I don't know how to select and show them just to make the picture and after that to show the Model again. Do you have an idea?

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Fiona Kattenstroth commented ·

You don't need to leave the window open after it has been saved to a file. Also, you can save multiple files with multiple names and set them on different objects. Just adjust the code according to your needs.

Don't try to open them as separate tabs, just open the window, render it to a texture, and close it.

The point of commenting out the postclosewindowmessage() was so that you could debug the timing of what is happening to understand the code. You don't need to leave it open after you've rendered the image to a file.

0 Likes 0 ·
Fiona Kattenstroth avatar image Fiona Kattenstroth commented ·

@phil.bobo I see your point, but the problem appears when I want to refresh the websites. Therefore the Render Texture View has to be open and in the foreground. I commented out the postclosewindowmessage() so that there won't be so many views recreated during the model run. The update is made by calling the finishedWebViewRender user command after defined times.

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Fiona Kattenstroth commented ·

Instead of closing the window or trying to tab it behind other windows, you could use the movewindow() command to just move it off the screen when you aren't rendering to it.

0 Likes 0 ·
1594391181263.png (144.3 KiB)
Jacob E2 avatar image Jacob E2 commented ·

Hey @Phil BoBo,

I'm trying to link a webpage to my 3D model as well and I came across this question that seems to do exactly what I need. However, the model you posted doesn't seem to be working for me in FlexSim 2022, specifically 22.0.1. I assumed that I would be able to download the model and run the Script and it would display the webpage, but it is showing up blank for me. I apologize in advance if I'm missing something simple since I am not very familiar with the programming side, my background is more involved with design and process improvement.

1650458582017.png

Thanks,

Jacob

0 Likes 0 ·
1650458582017.png (170.0 KiB)
Phil BoBo avatar image Phil BoBo ♦♦ Jacob E2 commented ·

In FlexSim 21.0, we changed the HTML views from using WebKit to using Chromium.

With this change, the command webcommand("loadurl") no longer does anything. Instead, you can just set the html and refresh the view. Attached is the model with those commands adjusted accordingly.

renderwebsitetotexture_1.fsm

(While debugging what was happening, I realized that we are no longer rendering file:/// protocol urls as we were before. I've added a case to the dev list to fix that. So currently, the model above only works in the "synchronous" case with the last parameter as 0 and not the "async" case that saves the page to a local file. That issue will be fixed in a future FlexSim release.)

1 Like 1 ·
Jacob E2 avatar image Jacob E2 Phil BoBo ♦♦ commented ·
Thank you, Phil! Works like a charm now!
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Jacob E2 commented ·
Try a different url and make sure your model is saved on a local, not network, drive so that the filepath evaluation will be compatible.
0 Likes 0 ·
Jacob E2 avatar image Jacob E2 Jason Lightfoot ♦ commented ·
@Jason Lightfoot, I've tried a few different urls, and saved the model on my (C:) drive. I still can't get FlexSim to display a webpage.
0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.