Class: Nebula::WebClient::Viewer
- Inherits:
-
Object
- Object
- Nebula::WebClient::Viewer
- Defined in:
- lib/nebula/webclient/viewer.rb
Overview
The main class of generating HTML code for Nebula Viewer.
Constant Summary collapse
- SampleModel =
An address of a sample model.
'http://nebula.gems8.com/Home/Sample/Apple'
Class Method Summary collapse
-
.html(args) ⇒ String
Generate code of an iframe containing the viewer of the specified model.
-
.javascript(args) ⇒ String
Generate a javascript statement to load the viewer to the specified HTML element container, with the specified model address and advanced settings.
-
.javascript_section(args) ⇒ String
Generate a javascript tag to load the viewer to the specified HTML element container, with the specified model address and advanced settings.
-
.thumbnail(args) ⇒ Object
Create a img tag of a thumbnail to preview a 3D model.
-
.thumbnail_url(args) ⇒ Object
Create a unescaped url of a thumbnail to preview a 3D model.
Class Method Details
.html(args) ⇒ String
Generate code of an iframe containing the viewer of the specified model.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nebula/webclient/viewer.rb', line 28 def self.html(args) uri = args[:uri] id, klass = selector(args) setting = setting(args) s = '' s << '<iframe src="' << ServiceHostAddress << '/EmbeddedViewer' s << setting.to_url_parameters(uri) s << '" width="' << Encoder.str(setting.width) s << '" height="' << Encoder.str(setting.height) s << '" class="' << Encoder.str(klass) if !klass.blank? s << '" id=' << Encoder.str(id) if !id.blank? s << '" scrolling="no" frameBorder="0"></iframe>' end |
.javascript(args) ⇒ String
Generate a javascript statement to load the viewer to the specified HTML element container, with the specified model address and advanced settings.
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/nebula/webclient/viewer.rb', line 46 def self.javascript(args) uri = args[:uri] selector = args[:selector] s = '' s << 'new NebulaViewer(' s << Encoder.js(selector) s << ',' s << setting(args).to_json(uri) s << ');' end |
.javascript_section(args) ⇒ String
Generate a javascript tag to load the viewer to the specified HTML element container, with the specified model address and advanced settings.
61 62 63 |
# File 'lib/nebula/webclient/viewer.rb', line 61 def self.javascript_section(args) '<script type="text/javascript">' << javascript(args) << '</script>' end |
.thumbnail(args) ⇒ Object
Create a img tag of a thumbnail to preview a 3D model.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/nebula/webclient/viewer.rb', line 68 def self.thumbnail(args) uri = args[:uri] id, klass = selector(args) width = args[:width] height = args[:height] s = '' s << '<img src="' << thumbnail_url(args) s << '" width="' << Encoder.str(width) s << '" height="' << Encoder.str(height) s << '" id="' << Encoder.str(id) if !id.blank? s << '" class="' << Encoder.str(klass) if !klass.blank? s << '" />' end |
.thumbnail_url(args) ⇒ Object
Create a unescaped url of a thumbnail to preview a 3D model.
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/nebula/webclient/viewer.rb', line 86 def self.thumbnail_url(args) uri = args[:uri] uri = 'image/jpeg@' << uri if !uri.index('@') render = RenderSetting.new(args[:width], args[:height]) s = '' s << ServiceHostAddress s << '/Render?u=' << Encoder.url(uri) s << '&c=d' s << '&s=' << Encoder.url(render.to_json) s << '×tamp=thumbnail' end |