- 2019-06-14 at 11:58 pm #15671
As you may know already, I’m working on a configurator. We’re doing some final tweaks right now. This is one of them. We’re applying several changes to geometry (hide/show) and materials based on user interaction in the HTML page that holds the verge3d file, and they are applied one by one via runCode calls. The problem is that we don’t like to be able to see each of those steps reflected in the 3d viewport. We’d prefer to see all the changes applied together. Apparently, because we are making several calls via runCode, there is some delay when executing them, and we are able to tell each of the visual changes. So, for example, we have two types of beds. Via interaction in the html page, we need to be able to change the type of bed (regular bed to crib) and material (oak to beech). We’d like both to change at the same time, and pass from a regular oak bed, to a beech crib. Instead of that, we’re seeing how the bed is hidden and replaced by the crib, and just after that, the material is changed.
I hope the explanation makes sense, and thank you for your help in advance!2019-06-15 at 12:49 am #15672
Yuri KovelenovDeveloper2019-06-15 at 11:48 am #15679
Ahh, I think i got the camera rotation to update while in “render disabled” mode, so I wrongly assumed that other stuff would update to. Thanks for clarifying that Yuri.2019-06-15 at 1:03 pm #15681
Thanks Elk and Yuri! So there is no way to do what we need? Not even through three.js code?2019-06-15 at 1:48 pm #15682
Elk, thank you for your suggestions. I should have said that we figured out a way to use runCode function AFTER the initial load, which lets us communicate with the puzzles when some events happen at the HTML side. We actually use prepareExternalInterface function for communications in the other way, when an event in the 3D view needs something from the HTML page that holds it.2019-06-16 at 12:05 pm #15688
Hmm, ok. As you are going against conventions here, it is kinda hard to figure out what might be wrong. If you are somehow using events or something to call code in run my first thought is that it somehow gets queud so it will only update on consecutive frames, is it just like a one frame “flash” for each thing you update? Maybe try to using fewer calls and do all updates in the same block of code. Even if that is not an option in the final product just try with some conciser code that will update a product 10 seconds after app has loaded for instance, just to try and isolate the issue. If you can reproduce how you have set this up in a smaller example, and post it on the network with some screenshots and stuff it might be easier to see what is going on.2019-06-17 at 12:24 pm #15692
Hi elk, unfortunately, it is not easy to create a small example for this, as it needs interaction with the e-commerce part which runs based on html/php.
Here is another idea: would it be possible to create a screenshot of the 3d view before we start with the changes, and use it as a mask that we would display on top of everything else, covering the changes that are done to the geometry/materials until we’re done with that, and then we remove it to be able to see the changes that were done? I know that screenshots can be taken, but I’m not sure of how to display them and make them match the 3d viewport size. Any ideas?
Thanks again!2019-06-17 at 5:19 pm #15695
I see. Well in esence this is exactly what the disable/enable rendering should do. All it does, and the Verge team might correct me on the fine details here, is to not update the buffer or whatever aslong as the rendering is disabled, basicaly holding the last frame as a screenshot. As long as you don’t clear the buffer or write anything new to it it should stay unchanged until you re-enable rendering. But that is neither here nor there if disabled renderer will prevent the scene form being updated like Yuri said. Then you would probably have to manualy stor the buffer and force it as the last update before finalising the renderloop, or even map it to a shaderless mesh right in front of your camera or something.
A quicker and maybe not so elegant way would be to have your changes made to an object of screen, if you can hide it under the floor or somewhere out of sight whiles you make the changes, even scaling it down to make it fit inside something else, and then swap it with the old object in one go, when all is set up ? basicaly just set position of new object to the old objects position, and the old object position to the of screen location where the new one was set up. Doing this in two cosecutive lines of code should make the change in location between the same two consecutive render loops/frames.
Might that be a posible solution? Not very elegant, but then again 3D stuff is mostyly about cheating your way around limitations anyway ;)2019-06-17 at 6:02 pm #15696
But that is neither here nor there if disabled renderer will prevent the scene form being updated like Yuri said.
Exactly. Based on what Yuri said, it would work as long as you don’t make any changes to the object in the 3d view, which is exactly what we need to do.
Your idea about swaping objects is a good one. Visually, it would perform in the same way as the disable/enable rendering should, but I’m concerned about the additional coding we would have to create, because we need this to work dynamically, and adapt to any product in the store, not just for a fixed product like the scooter example, where just one product is customizable and all the references to objects have been hardcoded in the puzzles.
So I think I would prefer to go with the manipulation of the buffer or the creation of a screenshot that covers what is being changed until everything is done. I hope Verge3D team can chime in about that.
Thanks a lot!2019-06-17 at 6:14 pm #15697
The buffer stuff was not really a serious suggestion, but yeah, If you have names and stuff hardcoded in puzzles, depending on how you set it up, that might become a problem. Always a good idea to make procedures or functions when you do more than 2-3 of anything, that way you only need to update the procedures/functions to add functionality. And that is where puzzles falls a bit short, for my taste anyway, when it comes to bigger projects.
But good luck whatever you deside. Hope you figure out a solution that works for you.
2019-06-18 at 1:44 am #15710
- This reply was modified 1 month ago by elk.
OK, first attempt with the “manual” screenshot and I’m getting a weird result. I’ve created a quick example, with two cubes. Nothing fancy. A div of 500×500 pixels that shows the 3d viewport, and another div with red background, with the same size, 100 pixels to the right (I made it red to make it really clear that the background would change)
When you click on the cube on the right (the one that shows at the right when you open the app.), the puzzle takes a snapshot, and sets it as background image for the div at the right. But instead of “repeating” the viewport as a static image, I just get a black background.
I assume that if I manage to make this work, I should be able to display a div on top of the viewport, matching its size, with the snapshot as a background. Doing so, I would not have to worry about being able to display the snapshot as a texture for an object inside the 3d viewport.
I’m using this as an example: https://www.soft8soft.com/docs/manual/en/introduction/Puzzles.html#take_screenshot
I’ve also tried to view the generated snapshot using these tools:
but none of them was able to display an image.
Attaching the full app.
Yuri and team, can you please tell me if I missing something? Thank you!
- This reply was modified 1 month ago by scalare.
Attachments:You must be logged in to view attached files.2019-06-20 at 3:44 pm #15769
Hi Yuri, any chance you can take a look at the example I uploaded a few days ago? Thank you!2019-06-24 at 6:59 am #15812
Sorry for not replying earlier. A thorough investigating of this question would require diverting one of the developers from their work. We, however, would be happy to assist you under the terms of technical support plan (also available as part of the Enterprise option).2019-06-24 at 12:12 pm #15822
But I’m concerned about the “take snapshot” puzzle that did not create a valid image (which is the alternate route we think may come up handy for us). I did not test that with previous versions, but could it be possible it is not working right in the latest verge3d version?
You must be logged in to reply to this topic.