melowntech / vts-browser-js

JavaScript WebGL 3D map rendering engine
BSD 2-Clause "Simplified" License
218 stars 42 forks source link

map-update #144

Closed OlegYarko closed 5 years ago

OlegYarko commented 5 years ago

Hello! The map-update event is triggered every time after the map element has been rendered. But how do I know that the whole map (i.e. all elements) is updated? https://imgur.com/a/RZchhyJ

davidmtech commented 5 years ago

Hello,

there are several types of events:

tick - internal heart beat. This event is called non stop. Its frequency is platform depended (usually 50 Hz)

map-update - this event is called when map is rendered / updated. Update can be triggered when new map resource is loaded or by user interaction. In your video are update events generated only during the load. That is the reason why there are many event calls. This event is called when whole maps is rendered. This event is not related to rendering of map element. When some part of the map is changed we have to render whole map. This event can be also triggered grammatically by calling browser.map.redraw();

Then there are user interaction related events: map-position-panned, map-position-rotated, map-position-zoomed

OlegYarko commented 5 years ago

David, thank for you answer ) I would like to clarify my question - how do I know that all resources are loaded ? Some events when whole map is displayed in maximum quality.
I think that this is not an easy task but maybe you can show a workaround?

Why do I need this? I'm trying to create a plugin for Adobe After Effects something like this https://vimeo.com/191694776 . I'm going to transfer a camera position from After Effects to your browser, then capture the screen and save it frame by frame. That's why I need to know exactly when to take a screenshot.

And I apologize if my question is not relevant here (on github).But I don't know where else I can ask about )

davidmtech commented 5 years ago

Now I understand. It is little bit more complicated, but you can try this.

browser.on("tick", (function(event){

    var stats = browser.map.getStats();

    if (stats["processingTasks"] == 0 && stats["downloading"] == 0 &&
        stats["busyWorkers"] == 0 && stats["dirty"] == false &&
       stats["lastDownload"] > 0) {

           // export frame
    }
 }));

You can take inspiration from this app which use vts for similar purpose (press load, then press set for the fist position, then press set for the second position, then you can press preview or export ).

https://www.melown.com/demo/video-capture/

Code for this app:

view-source:https://www.melown.com/demo/video-capture/

OlegYarko commented 5 years ago

David, this is exactly what I was looking for, thank you so much !