Methods
The rhinoartisan-web-3d web component exposes the following methods that can be called directly on the element.
📋 Method Categories
Materials
Items
Camera & Controls
Capture
Selection
Model Loading & Cache
Presets
Configuration
Material Customization
Materials
setMaterialByName(materialName)
setMaterialByName(materialName)Sets the material for the currently selected item(s). If no item is selected, applies to the last selected item.
Parameters:
materialName(string): Name of the material to apply (e.g., "gold-polished", "silver-polished", "diamond")
Returns: void
Example:
setMaterialByUuidAndName(uuid, materialName)
setMaterialByUuidAndName(uuid, materialName)Sets the material for a specific item by its UUID.
Parameters:
uuid(string): UUID of the itemmaterialName(string): Name of the material to apply
Returns: void
Example:
Items
getItems()
getItems()Returns an array of all items/parts in the loaded model.
Returns: Array of item objects with properties:
uuid(string): Unique identifiermaterial(string): Current material nameselected(boolean): Selection state
Example:
getSelectedItems()
getSelectedItems()Returns an array of currently selected items.
Returns: Array of selected item objects
Example:
getItemByUuid(uuid)
getItemByUuid(uuid)Gets a specific item by its UUID.
Parameters:
uuid(string): UUID of the item
Returns: Item object or undefined if not found
Example:
Camera & Controls
zoomExtents()
zoomExtents()Fits the camera view to show the entire model with appropriate padding.
Returns: void
Example:
zoomIn()
zoomIn()Zooms the camera in (closer to the model).
Returns: void
Example:
zoomOut()
zoomOut()Zooms the camera out (farther from the model).
Returns: void
Example:
setAutorotate(enabled)
setAutorotate(enabled)Enables or disables automatic rotation of the model.
Parameters:
enabled(boolean): True to enable, false to disable
Returns: void
Example:
getCameraView()
getCameraView()Gets the current camera view configuration.
Returns: Object with:
position(array): [x, y, z] camera positiontarget(array): [x, y, z] look-at targetfov(number): Field of view in degrees
Example:
setCameraView({ position, target, fov })
setCameraView({ position, target, fov })Sets the camera view configuration.
Parameters:
position(array): [x, y, z] camera positiontarget(array): [x, y, z] look-at targetfov(number): Field of view in degrees
Returns: void
Example:
Capture
getScreenshot(format, quality, width, height)
getScreenshot(format, quality, width, height)Captures a screenshot of the current view.
Parameters:
format(string, optional): Image format. Default: "image/png". Options: "image/png", "image/jpeg", "image/webp"quality(number, optional): Image quality (0-1). Default: 0.92width(number, optional): Output width in pixels. Default: 1920height(number, optional): Output height in pixels. Default: 1080
Returns: Data URL string of the image
Example:
downloadImage(filename)
downloadImage(filename)Downloads a screenshot of the current view.
Parameters:
filename(string, optional): Name of the file. Default: "screenshot.png"
Returns: void
Example:
startVideoRecording(duration)
startVideoRecording(duration)Starts recording a video of the viewer (turntable animation).
Parameters:
duration(number, optional): Duration in seconds. Default: 5
Returns: void
Example:
stopVideoRecording()
stopVideoRecording()Stops the current video recording and downloads the file.
Returns: void
Example:
Selection
setObjectSelectionEnabled(enabled)
setObjectSelectionEnabled(enabled)Enables or disables the ability to select objects by clicking.
Parameters:
enabled(boolean): True to enable, false to disable
Returns: void
Example:
Model Loading & Cache
setModelUrl(url)
setModelUrl(url)Loads a new 3D model from the specified URL.
Parameters:
url(string): URL of the GLTF/GLB model to load
Returns: boolean - True if successful, false on error
Example:
preloadModel(url)
preloadModel(url)Preloads a model into cache without displaying it.
Parameters:
url(string): URL of the model to preload
Returns: Promise
Example:
clearModelCache(url)
clearModelCache(url)Clears a specific model from the cache.
Parameters:
url(string, optional): URL of the model to clear. If not provided, clears all models.
Returns: void
Example:
Presets
loadPreset(presetName)
loadPreset(presetName)Loads a predefined visual preset (combination of lights, shadows, environment, etc.).
Parameters:
presetName(string): Name of the preset to load
Returns: boolean - True if successful, false if preset not found
Available Presets:
studio-bright- Bright studio lightingstudio-soft- Soft, diffused studio lightingoutdoor-sunset- Warm sunset lightingoutdoor-overcast- Cloudy day lightingdramatic-dark- High contrast, dramatic lightingminimal-clean- Minimal, clean aesthetic
Example:
getAvailablePresets()
getAvailablePresets()Gets a list of all available presets.
Returns: Array of preset objects with:
name(string): Preset identifierdisplayName(string): Human-readable namedescription(string): Preset descriptioncategory(string): Preset category
Example:
getCurrentPreset()
getCurrentPreset()Gets the currently active preset (if any).
Returns: Preset object or null if no preset matches current configuration
Example:
Configuration
exportConfiguration()
exportConfiguration()Exports the current viewer configuration as a JSON object.
Returns: Configuration object containing:
version(string): Configuration format versiontimestamp(string): ISO timestampitems(array): All items with their materialscamera(object): Camera view configurationviewerOptions(object): Viewer settings
Example:
importConfiguration(config)
importConfiguration(config)Imports a previously exported configuration.
Parameters:
config(object): Configuration object fromexportConfiguration()
Returns: boolean - True if successful, false on error
Example:
downloadConfiguration(filename)
downloadConfiguration(filename)Downloads the current configuration as a JSON file.
Parameters:
filename(string, optional): Name of the file. Default: "viewer-config.json"
Returns: void
Example:
Material Customization
updateMaterialProperties(uuid, properties)
updateMaterialProperties(uuid, properties)Updates specific material properties for an item.
Parameters:
uuid(string): UUID of the itemproperties(object): Properties to update:color(string): Hex color (e.g., "#ff0000")metalness(number): 0-1roughness(number): 0-1emissive(string): Hex coloremissiveIntensity(number): 0-1+normalScale(number): Normal map intensityenvMapIntensity(number): Environment reflection intensityopacity(number): 0-1
Returns: boolean - True if successful
Example:
getMaterialProperties(uuid)
getMaterialProperties(uuid)Gets the current material properties of an item.
Parameters:
uuid(string): UUID of the item
Returns: Object with material properties or null
Example:
saveCustomMaterial(name, properties)
saveCustomMaterial(name, properties)Saves custom material properties to localStorage for later use.
Parameters:
name(string): Name for the custom materialproperties(object): Material properties (same asupdateMaterialProperties)
Returns: boolean - True if successful
Example:
getCustomMaterials()
getCustomMaterials()Gets all saved custom materials from localStorage.
Returns: Array of custom material objects
Example:
deleteCustomMaterial(name)
deleteCustomMaterial(name)Deletes a saved custom material from localStorage.
Parameters:
name(string): Name of the custom material to delete
Returns: boolean - True if successful
Example:
💡 Usage Tips
Accessing Methods
All methods are directly accessible on the web component element:
Method Chaining
Some methods return values, but most return void. You can still execute multiple operations:
Error Handling
Methods that can fail (like setModelUrl, loadPreset) return boolean values:
🔗 See Also
Events - Available events
Configuration - Configuration options
Examples - Usage examples
Last updated
Was this helpful?