Home Browser Services
X_ite
Cancel

Browser Services

Browser Object

This section lists the methods available in the browser object, which allows scripts to get and set browser information.

Instance Creation Method(s)

None. This object cannot be instantiated by the user. One global instance of the object is available. The name of the instance is Browser.

Properties

name

A browser-implementation specific string describing the browser.

version

A browser-implementation specific string describing the browser version.

currentSpeed

The current speed of the avatar in m/s.

currentFrameRate

The current frame rate in frames per second.

description

A user-defined string which can be read and written.

supportedComponents

The property value cannot be changed, but the properties of the ComponentInfoArray can be.

supportedProfiles

The property value cannot be changed, but the properties of the ProfileInfoArray can be.

currentScene

The real type of this class is dependent on whether the user code is inside a prototype instance or not. If the user code is inside a prototype instance the property represent a X3DExecutionContext otherwise it represent a X3DScene.

Methods

Promise<void> replaceWorld (X3DScene)

Replace the current world with this new scene that has been loaded or constructed from somewhere. A Promise is returned that will be resolved when the scene is completely loaded.

X3DScene createX3DFromString (String x3dSyntax)

The string may be any valid X3D content in any language supported by the browser implementation. If the browser does not support the content encoding the appropriate exception will be thrown.

void|Promise<X3DScene> createX3DFromURL (MFString url [, Node node, String event])

Parse the passed URL into a X3D scene. When complete send the passed event to the passed node. The event is a string with the name of an MFNode inputOnly field of the passed node.

If event and node are omitted a Promise that resolves to a X3DScene object is returned.

Promise<void> loadURL (MFString url [, MFString parameter])

Load the passed URL, using the passed parameter string to possibly redirect it to another frame. If the destination is the frame containing the current scene, this method may never return. The return value is a Promise object, that is resolved when the new scene is loaded.

Promise<X3DScene> importDocument (DOMObject dom)

Imports a X3D XML DOM document or fragment, converts it, and returns a Promise that resolves to a X3DScene object.

Promise<X3DScene> importJS (Object json)

Imports a X3D JSON document or fragment, converts it, and returns a Promise that resolves to a X3DScene object.

String getBrowserProperty (String name)

Returns a browser property with the corresponding name.

Browser Properties
NameTypeDescription
ABSTRACT_NODESBooleanThe browser implementation supports the ability to describe each node type with interfaces that correspond to the abstract node types as defined in ISO/IEC 19775-1 in addition to the basic requirement to support the X3DBaseNode abstract type. This indicates that the browser supports at least Conformance Level 2.
CONCRETE_NODESBooleanThe browser implementation supports the ability to describe each node type with interfaces that correspond to the concrete node types as defined in ISO/IEC 19775-1 in addition to the requirement to support all of the abstract types. This indicates that the browser supports at least Conformance Level 3.
EXTERNAL_INTERACTIONSBooleanThis browser supports the additional services required by external interfaces. A browser provided to user code in internal interactions does not set this property.
PROTOTYPE_CREATEBooleanThe browser implementation supports the ability to dynamically create PROTO and EXTERNPROTO representations through service requests. The basic service capability only allows the ability to create instances of predefined PROTO structures read from a file format.
DOM_IMPORTBooleanThe browser implementation supports the importDocument service request.
XML_ENCODINGBooleanThe browser supports XML as a file format encoding.
CLASSIC_VRML_ENCODINGBooleanThe browser supports the Classic VRML encoding.
BINARY_ENCODINGBooleanThe browser supports the binary file format encoding.

String getBrowserOption (String name)

Returns a browser option with the corresponding name.

Browser Options
NameDescriptionType / valid rangeDefault
AntialiasedRender using hardware antialiasing if available.Booleanfalse
DashboardDisplay browser navigation user interface.Booleantrue
RubberbandDisplay a rubberband line when walk or fly.Booleantrue
EnableInlineViewpointsViewpoints from Inline nodes are included in list of viewpoints if made available by the Inline node.Booleantrue
MotionBlurRender animations with motion blur.Booleanfalse
PrimitiveQualityRender quality (tesselation level) for Box, Cone, Cylinder, Sphere.Low, Medium, HighMedium
QualityWhenMovingRender quality while camera is moving.Low, Medium, High, Same (as while stationary)Same
ShadingSpecify shading mode for all objects.Point, Wireframe, Flat, Gouraud, PhongGouraud
SplashScreenDisplay browser splash screen on startup.Booleantrue
TextureQualityQuality of texture map display.Low, Medium, HighMedium
CacheWhether or not files should be cached. (non standard)Booleantrue
ContentScaleFactor with which the internal canvas size should be scaled. If set to -1 window.devicePixelRatio is used. (non standard)Float1
ContextMenuWhether or not the context menu can be displayed. (non standard)Booleantrue
DebugWhether or not debug message should be printed into the console. (non standard)Booleanfalse
GravityDefault is gravity of Earth. (non standard)Float9.80665
LogarithmicDepthBufferWhether to use a logarithmic depth buffer. It may be necessary to use this if dealing with huge differences in scale in a single scene. It is automatically enabled if a GeoViewpoint is bound. (non standard).Booleanfalse
MultisamplingNumber of samples used for multisampling. (non standard)Integer4
NotificationsWhether or not notifications should be displayed. (non standard)Booleantrue
StraightenHorizonWhether the Examine viewer should straighten the horizon when navigating. (non standard)Booleantrue
TimingsWhether browser timings should be displayed. (non standard)Booleanfalse

void setBrowserOption (String name, Object value)

Sets a browser option with the corresponding name to the given value.

String getRenderingProperty (String name)

Returns a rendering property with the corresponding name.

Rendering Properties
NameTypeDescription
ShadingStringThe type of shading algorithm in use. Typical values are Flat, Gouraud, Phong, Wireframe, Point.
MaxTextureSizeIntegerThe maximum texture size supported.
TextureUnitsIntegerThe number of texture units supported for doing multitexture.
MaxLightsIntegerThe maximum number of lights supported.
AntialiasedBooleanTrue or false if the rendering is currently anti-aliased or not.
ColorDepthIntegerThe number of bits of color depth supported by the screen. Allows for optimized selection of textures, particularly for lower color depth screen capabilities.
TextureMemoryFloatThe amount of memory in megabytes available for textures to be placed on the video card.
ContentScaleBooleanCurrently used factor to scale content. (non standard)
MaxSamplesIntegerThe maximum number of samples supported for doing multisampling. (non standard)
MultisamplingIntegerNumber of samples currently used by multisampling. (non standard)
LogarithmicDepthBufferBooleanTrue or false if the logarithmic depth buffer is currently enabled or not. (non standard)

void addBrowserCallback (Any key, Function callback)

Adds a browser callback function associated with key, where key can be of any type. The callback function is called when a browser event has been occurred. The signature of the callback function is function (browserEvent), where browserEvent can be any value listed below:

  • X3DConstants .CONNECTION_ERROR
  • X3DConstants .BROWSER_EVENT
  • X3DConstants .INITIALIZED_EVENT
  • X3DConstants .SHUTDOWN_EVENT
  • X3DConstants .INITIALIZED_ERROR

void removeBrowserCallback (Any key)

Removes a browser callback function associated with key.

void viewAll ([SFNode layerNode])

Modifies the current view to show the entire visible scene. If layerNode is omitted, the active layer is used.

void nextViewpoint ([SFNode layerNode])

Changes the bound viewpoint node to the next viewpoint in the list of user viewpoints of layerNode. If layerNode is omitted, the active layer is used.

void previousViewpoint ([SFNode layerNode])

Changes the bound viewpoint node to the previous viewpoint in the list of user viewpoints of layerNode. If layerNode is omitted, the active layer is used.

void firstViewpoint ([SFNode layerNode])

Changes the bound viewpoint node to the first viewpoint in the list of user viewpoints of layerNode. If layerNode is omitted, the active layer is used.

void lastViewpoint ([SFNode layerNode])

Changes the bound viewpoint node to the last viewpoint in the list of user viewpoints of layerNode. If layerNode is omitted, the active layer is used.

void changeViewpoint ([SFNode layerNode,] name String)

Changes the bound viewpoint node to the viewpoint named name. The viewpoint must be available in layerNode. If layerNode is omitted, the active layer is used.

void print (Object object)

Prints object to the browser’s console without a newline character. Successive calls to this function append the descriptions on the same line. The output is the implicit call to the object’s toString () function.

void println (Object object)

Prints object to the browser’s console, inserting a newline character after the output. Successive calls to this function will result in each output presented on separate lines. The output is the implicit call to the object’s toString () function.

VRML Methods

String getName ()

String getVersion ()

Number getCurrentSpeed ()

Number getCurrentFrameRate ()

String getWorldURL ()

void replaceWorld (MFNode nodes)

MFNode createVrmlFromString (String vrmlSyntax)

void createVrmlFromURL (MFString url, SFNode node, String event)

void addRoute (SFNode sourceNode, String sourceField, SFNode destinationNode, String destinationField)

Add a route from the passed sourceField to the passed destinationField.

void deleteRoute (SFNode sourceNode, String sourceField, SFNode destinationNode, String destinationField)

Remove the route between the passed sourceField and passed destinationField, if one exists.

void loadURL (MFString url [, MFString parameter])

void setDescription (String description)

This post is licensed under CC BY 4.0 by the author.