anvaka / VivaGraphJS

Graph drawing library for JavaScript
Other
3.75k stars 425 forks source link

Rendering on iOS #21

Closed jexp closed 9 years ago

jexp commented 11 years ago

vivagraphjs_webgl_io_rendering_issue I enabled webgl support on my iOS browser and got it running but there seems to be a clear missing between drawing frames. Do you have any idea on how to solve that?

The app is running here: http://neo4waza.herokuapp.com

Thanks a lot

(Would you perhaps available for some paid support for vivagraphjs? We have to get this done by Thursday)

anvaka commented 11 years ago

Interesting. Have you tried setting clearColor and clearColorValue in webgl graphics?

 var graphics = Viva.Graph.View.webglGraphics({
    clearColor: true,
    clearColorValue: { r: 0, g: 0, b: 0, a: 1 }
  });

These values are used here and from what you picture looks like I'm guessing the webgl renderer needs to clear the surface.

PS: Is this Safari for iOS?

jexp commented 11 years ago

Yes safari for iOS.

Thanks a lot, that worked :) Interesting that it doesn't need that on the desktop (Chrome or Safari). Do you have any experience with using touch-events with vivagraph.js?

Cheers

anvaka commented 11 years ago

Glad to hear it fixed the problem!

I tried to implement touch events once, but something stopped me, don't remember what. If you'd like to try, here is how input works.

The renderer class is responsible for input processing. It's lame, and I should have made it into a separate input processing system, but when I just started the library it didn't sound as a bad idea. Anyways, the renderer differentiates when user drags a node and drags a canvas (container with nodes). Handling container events is simple. The container is always a DOM element, and the renderer leverages browser's input events via the dragndrop class. But handling nodes events is different - in case of WebGL there is no help from the browser at all, thus I made a new abstraction in the library, called inputmanager. The input manager is provided by specific graphics object (CSS, SVG or WebGL) and serves as an interface, to let renderer handle nodes events. In case of CSS and SVG graphics, I'm reusing mentioned above dragndrop class. In WebGL I manually track mouse events from entire canvas, translate their coordinates into the graph space, and then perform a node lookup (which is now implemented as a linear search function, but this was never a performance bottleneck of the library).

To summarize. If you want to implement touch events you would need to update dragndrop class and webglInputEvents class.

Cheers, Andrei