Sketchup-Model shown in Webdialog?
-
Hi there,
my name ist Steffen, I´m from Germany and currently developing a Sketchup-Plugin as a bachelor thesis. As I don´t have any experience in using Sketchup or ruby, I´ll probably have a "few" questions in the near future...and here´s already the first one: in my Plugin (which btw. will be about generating civil-engineering-construction-parts out of templates by specifying numerical parameters) I use a WebDialog as a GUI. Not much of a surprise, I guess. In this GUI the user will be able to specify some numerical parameters, like height, width, length and so on. Before generating the final model from this values and place it in Sketchup, I would like to show a little preview of the model in an area within the WebDialog. I certainly could do this via Javascript and some library like "three.js", but since I will "build" the model for Sketchup anyway, it would be a work-safer to use this model as a preview, too.
Is there a common way to display real-time-generated models within a WebDialog?
-
Hi,
you have to consider that WebDialogs use the operating-system-provided html/js engine (that is Internet Explorer or Safari). Last time I heard of, Microsoft did not intend to support WebGL because they say it gives very low-level access to the hardware (potentially insecure). That excludes WebGL from any WebDialogs in the Windows version of SketchUp. There are a couple of analogue javascript libraries for 3d that use pure 2d vector drawing methods on the HTML5 canvas element, but this is only supported by IE9 and above (excluding Windows XP, maybe possible with a compatibility library explorercanvas).I think Chris has experience with using the HTML5 canvas in WebDialogs (you may contact him).
Also (better) take a look at the
View.draw
methods of the SketchUp Ruby API. Those are used for displaying interactive tools and previews without doing changes to Drawingelements (Faces, Edges etc.). If you have tried Fredo's CurviLoft you might have noticed its "preview window" and onscreen toolbars. That is all done with the draw methods. You need to create a Tool class for that. -
Thank you for your detailed answer. I think I will go with the seperate View solution. although it might be a bit confusing to have a preview in a different window which might get lost behind other windows and stuff. But on the other hand it seems far more attractive than dealing with javascript behaviour on different browsers (versions). Maybe the model in the preview View is even natively zoom- and rotateable? That would certainly be a nice feature. I will catch up on that, thank you so far.
Advertisement