Build unique 3D user experiences with Phasma3D Viewer
Embedding a 3D model into your website is as simple as the markup below. To help with that, the
<phasma-viewer>
web component lets you declaratively add a 3D model to a web page, while hosting the model on your own site.
Step 1: Include the JS Library
Include the "Phasma3DViewer" library in the <head> section of your HTML file:
<head>
<!-- Other head elements -->
<script type="module" src="https://phasmatic.com/viewer/dist/phasmaviewer.js">
</script>
</head>
Step 2: Add the Element
Create a <phasma-viewer>
element in the body of your HTML file. Set the src
attribute to the path of your 3D model file. Here's a basic example:
<body>
<!-- Other HTML content -->
<phasma-viewer
src="path/to/your/model.glb"
poster="path/to/your/poster_image.jpg"
alt="alternative text explaining the 3D model"
camera-enable-controls
background-color="#ffffff"
>
</phasma-viewer>
<!-- Other HTML content -->
</body>
Next, configure it's styling as a regular HTML Element:
phasma-viewer {
width: 512px;
height: 512px;
}
Step 3: Customize and Add Options
The
<phasma-viewer>
supports various attributes to customize its behavior. In the example above, we've added the following attributes:
src
: Set this to the path of your 3D model file.
poster
: Displays an image instead of the model.
alt
: Provide a text description for accessibility.
camera-controls
: Allows users to interact with the model using mouse and touch input.
background-color
: Sets the background color of the viewer.
Refer to the following table for a full list of attributes and options you can use to customize the appearance and behavior of the 3D viewer.
customerID
|
The unique activation identifier of client. (Mandatory value)
|
Any legal ID.
|
src
|
The path to the 3D model. (Mandatory value)
|
Supported 3D formats "gltf/glb" and Phasmatic's "pha".
|
alt
|
Specifies an alternate text for the viewer who use a screen reader.
|
Any description
|
poster
|
The path to the poster image. Display an image until the model is ready.
|
Supported 2D formats "jpg", "png", "webp", "gif".
|
env-image
|
The path to the environmental image.
|
Supported 2D formats "jpg", "png", "hdr" and Phasmatic's "pha". If not specified, default environment lighting will be applied.
|
env-intensity
|
Controls the exposure of the environment image.
|
Any positive floating point value. Default "1.0".
|
env-image-rotation
|
Controls the rotation of the environment image.
|
Any positive floating point value between 0.0 and 180.0 for X and Y axes. Default "0.0, 0.0".
|
env-blur
|
Enables the blurring of the displayed environment image.
|
Boolean value. Default "true".
|
loading
|
Specifies how the model should be preloaded.
|
The supported values are "prefetch", "lazy" and "eager". Lazy loads the model after interaction, Eager loads the model immediately and Prefetch preloads the model in background before interaction. Default "lazy".
|
variant
|
Specifies the material variant of the model.
|
Any valid material variant of the model.
|
animation
|
Specifies the animation track. Animation is played after loading.
|
Any valid animation track.
|
camera-enable-controls
|
Enables camera controls via mouse/touch.
|
Any positive floating point value. Default "1.0".
|
camera-disable-zoom
|
Disables user zoom.
|
-
|
camera-invert-zoom
|
Inverse the mouse wheel scrolling direction.
|
-
|
camera-fov
|
Specifies the vertical field of view of the camera. Accepts values in degrees.
|
Any positive floating point value between "0.0" and "180.0". Default "60.0".
|
camera-smooth-rotation
|
Specifies the continuation of the camera rotation.
|
Any positive floating point value. Default "0.05".
|
camera-orbit-limits
|
Specifies the minimum and maximum permitted orbit angles of the camera Yaw and Pitch rotation actions in degrees.
Additionally, specifies the minimum permitted zoom distance of the camera movement in meters.
|
Any floating point value between 0.0 and 180.0 for Yaw and -180.0 and 180.0 for Pitch respectively. For minimum distance, any positive floating point value. Default "0.0:180.0, -180.0:180.0, 0.1:auto".
|
camera-target
|
Specifies the target axis that the camera will orbit around.
|
"X Y Z", here units are in meters. Default: "auto, auto, auto", which corresponds to the default position at the center of the model.
|
camera-auto-rotate
|
Enables the auto rotation of the 3D model.
|
-
|
camera-auto-rotate-speed
|
Specifies the Yaw and Pitch auto-rotation speed in degrees.
|
"Yaw, Pitch". Default: "10, 0".
|
camera-interpolate
|
Enables the camera interpolation from the default point of view to a user-specified. Camera animation starts after the model has been loaded.
|
-
|
camera-interpolate-duration
|
Specifies the time duration of the camera interpolation in seconds.
|
Any positive floating point value. Default "5".
|
camera-interpolate-cycle
|
Specifies the camera interpolation rotation angles and ending zoom position.
|
"Yaw, Pitch, Zoom", where Yaw and Pitch are in degrees, Zoom is meters from the center of the model. Default: "360, 0, 1".
|
background-color
|
Specifies the background color.
|
"rgb(r,g,b)" or "rgba(r,g,b,a)", where r/g/b/a are in [0,255] range. "#xxxxxx" hex color can be used instead. Default: "rgb(209,207,206)".
|
gradient-color-A
|
Specifies the background gradient color A.
|
"rgb(r,g,b)" or "rgba(r,g,b,a)", where r/g/b/a are in [0,255] range. "#xxxxxx" hex color can be used instead. Default: "rgb(209,207,206)".
|
gradient-color-B
|
Specifies the background gradient color B.
|
"rgb(r,g,b)" or "rgba(r,g,b,a)", where r/g/b/a are in [0,255] range. "#xxxxxx" hex color can be used instead. Default: "rgb(0,0,0)".
|
gradient-color-A
|
Specifies the background gradient location A.
|
Any positive floating point value in the range [0,1]. Default "0.0".
|
gradient-color-B
|
Specifies the background gradient location B.
|
Any positive floating point value in the range [0,1]. Default "1.0".
|
gradient-direction
|
Specifies the background gradient direction.
|
Acceptance values are "horizontal" or "vertical". Default "horizontal".
|
background-image
|
The path to the background image.
|
Supported 2D formats "jpg", "png", "webp", and "gif".
|
pp-sharpen
|
Enables the sharpening post process filter. Specifies the strength of the effect.
|
Any positive floating point value in the range [0,1]. Default "0.0" (disabled).
|
pp-vignette
|
Enables the vignette post process filter. Specifies the strength of the effect.
|
Any positive floating point value in the range [0,1]. Default "0.0" (disabled).
|
pp-filmgrain
|
Enables the film grain post process filter. Specifies the strength of the effect.
|
Any positive floating point value in the range [0,1]. Default "0.0" (disabled).
|
pp-tonemapping
|
Enables the tone mapping post process filter and selects the function.
|
Accepted values are "gamma", "filmic", "aces_filmic", "reinhard", "uncharted". Default "gamma".
|
ground-shadow
|
Enables shadows. Specifies the strength of the effect.
|
Any positive floating point value in the range [1,10]. Default "1.1" .
|
ui-fullscreen
|
Allows users to enable full-screen functionality.
|
-
|
immersive
|
Allow users to enable the ability to launch Virtual and Augmented Reality experiences on supported devices.
|
Accepted values are "VR", "AR", and "XR". XR enables both VR & AR buttons.
|
ar-mode
|
Select the AR experience type.
|
Accepted values are "scene-viewer" and "webxr". Default "scene-viewer".
|
ar-resizable
|
Enables the scaling behavior in AR mode, which allows the model to be resized by pinch.
|
-
|
ar-enable-vertical-placement
|
Enable to place the object on the floor (horizontal surface) as well as on the wall (vertical surface) in AR.
Note that the different AR modes handle the placement UX differently.
|
-
|
ios-src
|
The path to the 3D model to support AR on iOS 12+ devices via AR Quick Look. (Optional value)
|
Supported 3D formats "uszd".
|