3D Interaction Canvas (LWC)

Powerful, Salesforce Native, event-driven 3D Canvas

The 3D Interaction Canvas is a custom Lightning Web Component that allows users to interact with 3D models within Salesforce. It provides a high-quality visualization environment and can be used in both Salesforce flows and record pages.

Action Menu

The 3D Interaction Canvas includes an action menu that provides several options for users to interact with the 3D models and the environment.

Here's an overview of each option:

  • Reset Camera: This option allows the user to reset the camera view to its original state.

  • Show Explosion Handle: When selected, a slider appears that allows the user to "explode" the 3D model, separating its components in space to view them individually.

  • Slice: Enables the user to "slice" through the 3D model along the X or Y axis. This is useful for examining the interior of complex models.

  • Take Snapshot: This option allows the user to take a snapshot of the current view of the 3D model. The snapshot is saved as a .png image.

  • Auto Rotate: When selected, the 3D model slowly rotates around a central axis, giving the user a 360-degree view of the model.

  • Environment Color: Allows the user to change the background color of the environment in which the 3D model is displayed.

  • Outline: This option gives all components of the 3D model an outline, making it easier to distinguish individual parts.

  • Shine: Adds a "shine" effect to the 3D model, making it appear glossy.

  • Technical Drawing: Enables a "technical drawing" mode, which renders the model with a simplified schematic appearance.

  • Show All Labels: If the model has labels, this option will display all of them.

  • Show Label Editor: If all labels are being shown, this option will enable the user to edit these labels.

Developer Options

The following options are available when you press the Alt key. Releasing the Alt key will hide the options again. These are meant to be used during implementation or to debug an issue.

  • Show Debugger: If developer options are enabled, this option will open a debugger. (only enabled when

  • Log 3D Node Structure: Logs the 3D node structure of the model to the console for debugging purposes.

  • Get Camera Position: Logs the camera's current position to the console for debugging purposes.

Interactions

Click Events

We automatically highlight the selected component in the 3D scene, we then raise an event for component (componentselected) and also raise a lightning

On selection, we will attempt to lookup related records based on the Child_Node_Related_Object Child_Node_Lookup_Field. These should at least be a partial match for a selected component’s name. If found, we raise a rendererrelatedrecordfetched event with a property of foundRecord, if the record was found. If the record was found, we pass the selected record & it’s Standard Fieldset along for you to handle. If displayActionInformationPaneOnSelection is set to true, we automatically expand that slot, exposing whatever components are passed in, with the expectation that a handler will set the context to the selected record.

To clear the selection, simply press the clear selection button or click on any empty space in the scene to refocus on the entire model and remove highlighting.

Hover Events

When a component is hovered, We'll raise componenthovered with the name, as well as the position of the hover. If showComponentInformationOnHover is set to true, we'll attempt to lookup the appropriate record based on the name of the component selected. With this option selected, we'll show the Name field of the related record.

If you choose to use the showRelatedRecordDetailsOnHover we will show the related record Id for the found record inline in a popover component.

Metadata lookup

Linkage for both hover and click actions are available on the Custom Metadata RenderDraw relationship record for the object you are looking into

Slots

The component contains multiple slots, conditionally rendered sections, and nested components.

Slots

The Canvas3D component exposes the following slots:

  1. contextDetailContent slot: It allows you to pass custom content to be displayed in the 'context detail' area. You can pass any HTML or LWC component to this slot as per your requirement.

    Example:

  2. contextContent slot: Similar to contextDetailContent slot, this slot is designed to pass the content that should be displayed in the 'context' area.

    Example:

  3. actionInformationPane slot: This slot is used to pass information regarding various actions. You can place an HTML or a LWC component inside this slot as per your requirement.

    Example:

  4. sidebarContent slot: If you need to pass custom content to be displayed in the sidebar, this slot is for you.

    Example:

Showing/Hiding Slots

To control the visibility of the slots, there are boolean properties:

  1. displaySidebar - controls the visibility of sidebarContent slot.

  2. displayContext - controls the visibility of contextContent slot.

  3. displayContextDetails - controls the visibility of contextDetailContent slot.

  4. displayActionInformationPane - controls the visibility of actionInformationPane slot.

You can toggle these properties to control the visibility of the respective slots.

Passing Information

Information can be passed into these slots using attributes/properties and events.

Attributes/Properties:

  • size, contextSize, sidebarSize - control the size of the overall layout and individual sections.

  • contextDetailHeaderText - sets the text of the context detail header.

Events:

  • handleCloseContextDetails - handles the action when the context details are closed.

Properties
Methods
Events

contextdetailsclose: Dispatched when the context details pane is closed.

hidemedia: Dispatched when the media display is hidden.

explosionamountchanged: Dispatched when the explosion amount changes.

toggleslicing: Dispatched when slicing is toggled.

clipXChanged: Dispatched when the slice value for the X-axis changes.

clipYChanged: Dispatched when the slice value for the Y-axis changes.

environmentcolorchanged: Dispatched when the environment color changes.

clearselection: Dispatched when the selected components are cleared.

popovermouseover: Dispatched when the mouse hovers over a popover.

popovermouseout: Dispatched when the mouse moves out of a popover.

screenshottaken: Dispatched when a screenshot is taken.

  • data: The base64 string of the taken screenshot.

finishedloading: Dispatched when the rendering has finished loading.

hierarchyfetched: Dispatched when the component hierarchy has been fetched from the 3D renderer.

  • data: The structure of the component hierarchy.

getcamerapostionandtarget: Dispatched when the camera position and target are updated.

  • data: The object containing updated camera position and target.

elementadded: Dispatched when a new element is added to the scene.

  • elementType: The type of the added element.

  • name: The name of the added element.

  • uniqueId: The unique ID of the added element.

componenttransformed: Dispatched when a component has been transformed.

  • name: The name of the transformed component.

  • id: The ID of the transformed component.

  • uniqueId: The unique ID of the transformed component.

  • type: The type of the transformed component.

  • data: The data of the transformed component.

componentverified: Dispatched when a component has been verified.

  • name: The name of the verified component.

  • isLoaded: The loaded status of the verified component.

  • isVisible: The visibility status of the verified component.

  • isFullyVisible: The full visibility status of the verified component.

  • visibility: The visibility level of the verified component.

  • isEnabled: The enabled status of the verified component.

labelstylingclosed: Dispatched when the label styling dialog is closed.

labelstylingupdated: Dispatched when the label settings have been saved.

  • lineColor: The color of the line for the label.

  • labelBold: The boldness of the label.

  • fontSize: The font size of the label.

  • lineThickness: The thickness of the line for the label.

  • align: The alignment of the label.

  • hideable: The hideability of the label.

  • draggable: The draggable status of the label.

componenthovered: Dispatched when a component is hovered.

  • data: The data of the hovered component.

componenthoverreleased: Dispatched when a hover is released from a component.

  • data: The data of the released hover component.

camerachanged: Dispatched when the camera has been moved or rotated.

  • positionX: The x-position of the camera.

  • positionY: The y-position of the camera.

  • positionZ: The z-position of the camera.

  • alpha: The rotation of the camera around the y-axis.

  • beta: The rotation of the camera around the x-axis.

  • radius: The distance of the camera from the target.

Developing with 3D Interaction Canvas

Add the Component to the HTML: In the HTML file of the parent component, include the Canvas3D component and pass any necessary attributes or public properties:

In the above code, {recordId}, {size}, {salesforceContent}, {useDigitalExperience}, and {allowSelection} You'll need to define the properties in your parent component's JavaScript file.

Wait for the finishedloading event before attempting to interact or call methods on the 3D Canvas

Listen to Events: If your parent component needs to react to events emitted by the Canvas3D component, you can add event listeners:

In your parent component's JavaScript file, handle the event:

End-User Usage

The 3D Interaction Canvas component can be added to a Flow or a Record Page in your Salesforce organization. It offers several customizable properties to configure its behavior and interaction with data.

As a Flow Screen Component

When using this component in a Flow, you have the following input properties available:

  • recordId: This property accepts a String that corresponds to the Salesforce record Id you want to interact with.

  • size: This property accepts a String that sets the size of the component. It could be Small, Medium or Large.

  • salesforceContent: This property accepts a String that corresponds to the Salesforce Content Id for the 3D model to be displayed.

  • useDigitalExperience: This property is a Boolean. If it's set to true, the component will be configured to be used in Salesforce's Digital Experience (previously known as Community).

  • allowSelection: This property is a Boolean. If it's set to true, users will be allowed to select individual components of the 3D model.

To use the 3D Interaction Canvas in a Flow, add a new Screen, then add a custom component to the Screen. From the list of available components, choose the 3D Interaction Canvas.

As a Record Page Component

When using this component on a Record Page, you have the following properties available:

  • recordId: This property is automatically filled by Salesforce with the Id of the current record.

  • size: This property accepts a String that sets the size of the component. It could be Small, Medium or Large.

To use the 3D Interaction Canvas on a Record Page, simply edit your Lightning Page, drag the 3D Interaction Canvas component from the Custom - Managed section of the Lightning Components list and drop it in the desired place on your Lightning Page. Click on the component to see the property options available.

Supported Form Factors

The 3D Interaction Canvas supports both Small and Large form factors, making it adaptable for usage on various devices and screen sizes.

Last updated