Interactive 3D Hero Section powered by Three.js
Easy customization using simple HTML data-* attributes β no Three.js knowledge required.
Get the 3D Hero running in minutes:
#hero-container HTML markup to your page.glb model path using data-model-pathinit3DHero(container)π Done! Your interactive 3D hero is ready.
This template provides a complete interactive 3D Hero Section designed specifically for:
Because this template loads external GLB 3D models, it must be run in a web server environment.
β οΈ GLB models will NOT load via file:// protocol.
VS Code Recommendation: Install Live Server extension β Rightβclick index.html β Open with Live Server.
Ensure the following structure is preserved:
Add the scripts before the closing </body> tag.
β οΈ GSAP must be loaded before main.js.
Place this HTML where the 3D hero should appear:
β οΈ Do not remove the <canvas id="webgl"> element.
This final step initializes the 3D hero using the settings defined in the HTML container (#hero-container).
This script must be placed before the closing </body> tag to ensure all elements are fully loaded.
If you are using a blue-themed model such as:
model-coin-blue.glbmodel-bank-blue.glbYou must add the following class to your <body> tag for correct lighting and color harmony:
π¨ If using a Default Theme model (e.g., model-gold.glb), no additional class is required. (No class added = Default Theme)
All customization is handled directly in HTML.
| Attribute | Type | Description | Recommended Values |
|---|---|---|---|
data-model-path |
String | Path to .glb model (Required). |
./assets/static/models/... |
data-scale |
Number |
Adjusts the model's visual size. β’ 1.0 is the original export size.β’ Values below 1.0 shrink the model.
|
0.5 to 1.5 (Varies by model) |
data-position-x |
Number | Horizontal model offset | 0 (Recommended: -0.8 ~ 0.2) |
data-position-Y |
Number | Vertical model offset | 0 (Recommended: -0.2 ~ 0.5) |
data-camera-init-z |
Number | Initial camera distance | 3 β 6 |
data-auto-rotate |
Boolean | Enable auto rotation | true / false |
data-rotation-speed |
Number |
Controls speed and direction. β’ Positive (+): Default rotation direction β’ Negative (-): Reverse rotation direction β’ Higher value: Faster rotation speed |
-2.0 to 2.0 |
data-directional-color |
Hex | Main directional light color | 0xbcd6c5 |
The model will remain static until the user interacts with it.
Set data-auto-rotate="true" to enable this. Use a negative value (e.g., -3) to reverse the rotation direction.
Instead of manually configuring every attribute, the fastest way to build your hero section is to use our pre-configured HTML files.
To ensure 3D models load correctly, open any file from 01-bank-corporate-blue.html to 08-crypto-asset-gold-dark.html using a Live Server (e.g., VS Code Live Server extension).
Browse through the different themes such as Bank, Crypto, Blue, or Gold to find the design that perfectly matches your project.
Once you find a style you like, simply copy the <div id="hero-container" ...> block and paste it into your project.
<div class="textGroup">.
scale, lighting, and camera position, so you don't have to worry about the details.
When replacing the default 3D model, minor adjustments are usually required to ensure the model appears correctly within the canvas.
.glb file into the following directory:
/assets/static/models/
data-model-path attribute in your HTML to reference the new file.
Since every 3D model is exported with different dimensions, you may need to scale it to fit the hero area.
data-scale β Controls the physical size of the model.
(e.g., Use 0.6 if the model is too large, or 1.2 if it is too small.)
β οΈ Optional Fine-Tuning:
After loading a new model, you may also want to adjust the lighting and camera distance for optimal visual results:
data-camera-init-z β Adjusts how close or far the camera is from the modeldata-directional-color β Changes the primary light colorFor best results:
file://)data-model-pathdata-camera-init-z between 3β6GSAP is loaded before main.jsinit3DHero(container) is executedIf the model appears too small, too large, or poorly framed within the canvas:
data-camera-init-z (Recommended):
This is the most common way to fix framing. Increase the value to move the camera back (model looks smaller), or decrease it to move closer (model looks larger).
(Typical range: 3.0 to 6.0)
data-scale:
If the model itself is fundamentally too tiny or massive regardless of camera distance, use this to change the physical size of the object.
Β© 2025 OKHEE. All Rights Reserved.
Personal & Commercial Use Allowed
Redistribution or resale is strictly prohibited