|
HTMLMaterial
The HTMLMaterial
class is used to create a Material consisting of a rendered HTML page
which can then be applied to an mesh like a regular Material.
To create
an instance of the HTMLMaterial class use the Scene.createHTMLMaterial()
method which allows you to specify the material name the URL of the HTML
page to be rendered and the page size. When you have finished with the
HTMLMaterial call the Scene.destroyHTMLMaterial() method.
Pages containing
the following content should work (see caveat 1 below) html, dhtml, xml,
.swf, .flv, .png, .jpg, .gif, .gif (animated), .wmv, .avi, .qt, .mpeg.
There are
some caveats to using Web pages as materials:
1. Not all
Web pages will be rendered. What makes some pages render and others not
has not yet been determined, so some trial and error may be required.
For testing http://www.google.com and http://www.yahoo.com are both known
to work well. Note that Microsoft IE is used for the rendering and there
may be differences between the way IE 6 and IE7 render a page.
2. The amount of the page that is used for the material is controlled
by the Page Width and Page Height properties and by the screen resolution
of the users computer. The higher the users screen resolution the less
of the Web page that will be used for the Material.
3. Be aware of any web page that requires interaction from the user in
order to display correctly. This is most often the case with Video that
only plays when the user clicks on the Play button.
4. Most Web page plugins are supported. However, not all users will have
the plugin you need.
5. Not all Flash animations are created equal. Some Flash animations on
a Web page will cause a slow down in the frame rate, while other things
like video will run much faster.
6. Do
not use a Web page that contains another Blink 3D environment.
The Web pages are rendered in real time. This of course can put a strain
on the frame rate of the environment. So by default the staticImage property
is set to True. This means that the Web page is only rendered once and
then used as a texture. Any subsequent changes to the Web page will not
be seen. If the Web page changes infrequently you can use the forceUpdate()
method to re-render the page. If the Web page contains dynamic content
such as Flash animations, video Dynamic HTML or animated Gif files then
you may want to set the Static Image option to False. Doing so will allow
you to see the changes to the Web page in real time in the Blink environment.
If you experience jerkiness in video or animations try adjusting the updateFactor
property. Lowering the number will cause the Web page to be rendered more
frequently. However, this may have an even more negative effect on the
frame rate. The default value of 20 seems to work well across most system.
Unless you are sure that your users have a high end video card increasing
this value is probably not advisable and may have a detrimental effect
to the frame rate.
NOTE: In the future this functionality may not be available across all
operating systems or it may work differently.
Properties
type
| |
Usage |
String
= HTMLMaterial.type |
| |
Description |
Obtains
the type of the object which is HTMLMaterial. (Read Only) |
| |
Return
Value |
Returns
the type of the object as a string. |
| |
Example
|
// Get the type of the object
if ( oHTMLMaterial.type == "HTMLMaterial" )
Chat.print( "Object is of type HTMLMaterial" ); |
materialName
| |
Usage |
String
= HTMLMaterial.materialName |
| |
Description |
Determines
the name of the Material. Using Scene.getMaterial() This name can
be used to obtain a reference to the underlying Material class and
its Techniques and Passes. The name of the Material was specified
when the HTMLMaterial was created with Scene.createHTMLMaterial()
(Read Only) |
| |
Return
Value |
Returns
the name of the Material. |
| |
Example
|
// Get a reference to the underlying material
oMaterial = Scene.getMaterial( oHTMLMaterial.materialName ); |
updateFactor
| |
Usage |
Integer
= HTMLMaterial.updateFactor |
| |
Description |
Determines
the frequency that the HTML page is rendered to an image and the underlying
Material updated. The value is a fact which when decreased will increase
the number of times per frame that the HTML page is rendered. Default
is 20. |
| |
Return
Value |
Returns
the update factor that controls how often the HTML is rendered. |
| |
Example
|
// Increase the frequency the HTML is rendered
oHTMLMaterial.updateFactor = 15; |
staticImage
| |
Usage |
Boolean
= HTMLMaterial.staticImage |
| |
Description |
Enables
or disable using the HTML page as a static image. When set to true
the HTML page is rendered once and the underlying Material is updated.
If a change occurs to the HTML the change will not be seen unless
a call to HTMLMaterial.forceUpdate() is made. This option should
be set to false when working with dynamic web pages or pages containing
Flash animations, movies or animated Gif files. |
| |
Return
Value |
Returns
true if the HTML page is treated as a static image, otherwise returns
false. |
| |
Example
|
// Enable static image to speed up the frame rate
oHTMLMaterial.staticImage = true; |
Methods
setURLHTML()
| |
Usage |
Boolean
= HTMLMaterial.setURLHTML( sURLHTML
) |
| |
Description |
Changes
the URL of the HTML page being rendered to the one specified. If the
parameter is not determined to be a URL or a path to a local file
it will be treated as raw HTML and rendered accordingly. |
| |
Parameters |
sURLHTML
The new URL to the HTML page to be rendered or raw HTML. |
| |
Return
Value |
Returns
true on success, otherwise returns false. |
| |
Example
|
// Change the URL
oHTMLMaterial.setURLHTML( "http://www.google.com" ); |
getURLHTML()
| |
Usage |
String
= HTMLMaterial.getURLHTML() |
| |
Description |
Obtains
the URL of the HTML page currently being rendered or the raw HTML. |
| |
Parameters |
None |
| |
Return
Value |
Returns
the URL or the raw HTML being rendered. |
| |
Example
|
// Get the URL of the HTML page being rendered
sURL = oHTMLMaterial.getURLHTML(); |
forceUpdate()
| |
Usage |
Boolean
= HTMLMaterial.forceUpdate() |
| |
Description |
Forces
the immediate re-rendering of the HTML page and the subsequent updating
of the underlying Material. This method should only be used if HTMLMaterial.staticImage
is set to true. |
| |
Parameters |
None |
| |
Return
Value |
Returns
true on success, otherwise returns false. |
| |
Example
|
// Force the HTML page to be re-rendered
oHTMLMaterial.forceUpdate(); |
sendJS()
| |
Usage |
Boolean
= HTMLMaterial.sendJS( sJavaScript ) |
| |
Description |
Sends
JavaScript to the HTML page that is being rendered. Care should
be taken to ensure that the string is formatted correctly. Particular
attention should be given to using single and double quotes.
One
approach is to encompass the entire command string in double quotes
and only use single quotes within the string, as in the first example
below.
The
other approach is to escape the quotes using the backslash character
\, as in the second example below. |
| |
Parameters |
sJavaScript
The JavaScript to send to the HTML page being rendered. |
| |
Return
Value |
If
the method succeeds, it returns true otherwise, it returns false. |
| |
Example
|
// Display the native JavaScript alert dialog box oHTMLMaterial.sendJS( "alert(\"Hello World!\");" ); |
sendMouseClick()
| |
Usage |
Boolean
= HTMLMaterial.sendMouseClick( iButton,
iXPos, iYPos [,bDoubleCLick] ) |
| |
Description |
Sends
a mouse click to the Web page. |
| |
Parameters |
iButton
The mouse button that was pressed.
iXPos
The position of the click in the Web page window along the X axis.
iYPos
The position of the click in the Web page window along the Y axis.
bDoubleClick
When set to Treu the mouse click is treated as a double click, default
if the not specified is False. (Optional)
|
| |
Return
Value |
If
the method succeeds, it returns true otherwise, it returns false. |
| |
Example
|
// Send a mouse click to the Web page oHTMLMaterial.sendMouseCLick( oHTMLMaterial.MOUSE_BUTTON1,
215, 213 ); |
setFocus()
| |
Usage |
Boolean
= HTMLMaterial.setFocus( bFocus ) |
| |
Description |
Sets input focus
to the window rendering the HTML.
|
| |
Parameters |
bFocus
When set to true focus is given to the window rendering the HTML
and wehn set to flase focus is given to the main Blink 3D window
|
| |
Return
Value |
If
the method succeeds, it returns true otherwise, it returns false. |
| |
Example
|
// Set focus to the HTML window oHTMLMaterial.setFocus( true ); |
Constants
Mouse
Button Constants
| Constant |
Description |
MOUSE_BUTTON1
MOUSE_BUTTON2
MOUSE_BUTTON3
|
Left
mouse button
Right mouse button
Middle mouse button
|
|