docs
Getting Started
Tutorials
How-To Guides
Explanation
Reference
Help
Getting Started
Tutorials
How-To Guides
Explanation
Reference
Help

Attributes of the Needle Engine Web Component

Needle Engine is typically used as a web component: <needle-engine>. This component can be used to load and display 3D scenes, models, and more in a web browser. It comes with a set of attributes that allow you to configure its behavior, look and feel. All those settings can be overwritten by code, but the attributes are a convenient way to set them up in HTML. The tables below show a list of available attributes and what they do.

The web component is in index.html

Whether creating a project via Unity or Blender, or directly in code, you can use and adjust the <needle-engine> web component. Usually, you will find it in the index.html file of your web project.

File Loading and Events

srcPath to one or multiple glTF or glb files.
Supported types are string, string[] or a stringified array (comma-separated).
loadstartName of the function to call when loading starts. Note that the arguments are (ctx:Context, evt:Event). You can call evt.preventDefault() to hide the default loading overlay
progressName of the function to call when loading updates. onProgress(ctx:Context, evt: {detail: {context:Context, name:string, index:number, count:number, totalProgress01:number, progress:ProgressEvent}) { ... }
loadfinishedName of the function to call when loading finishes

Custom Branding

Available attributes to change the Needle Engine loading and custom branding

loading-blurOptional: Blur the scene until LODs are loaded (if any). Default: disabled
posterOptional: Set the poster attribute to show a placeholder image while loading. Example: <needle-engine poster="https://yourdomain.com/poster.png">. By just using the attribute without a url the poster in include/poster.webp will be used if it exists (e.g. <needle-engine poster>)
loading-backgroundChange the loading background color (e.g. #dd5500 or transparent). By default the loader shows a theme-dependent semi-transparent scrim with a backdrop blur so the progress bar stays readable over the scene; when a poster is set the default is transparent. See the CSS variables below for a fully transparent loader
hide-loading-overlayDo not show the loading overlay
logo-srcPRO — Change the logo image (e.g. https://yourdomain.com/logo.png or /logo.png). This logo will then be used in the QR code and XR session loading
qrcode-logo-srcPRO – Change the logo image for the QR code (e.g. https://yourdomain.com/logo.png or /logo.png). If not provided the logo-src attribute will be used.

Visual Settings

background-coloroptional, hex color to be used as a background color. Examples: rgb(255, 200, 100), #dddd00
background-imageoptional, URL to a skybox image (background image) or a preset string: studio, blurred-skybox, quicklook, quicklook-ar. Supports FastHDR
background-blurrinessoptional, bluriness value between 0 (no blur) and 1 (max blur) for the background-image. Example: background-blurriness="0.5"
environment-imageoptional, URL to a environment image (environment light) or a preset string: studio, blurred-skybox, quicklook, quicklook-ar. Supports FastHDR
contactshadowsoptional, render contact shadows
tone-mappingoptional, supported values are none, linear, neutral, agx
tone-mapping-exposureoptional number e.g. increase exposure with tone-mapping-exposure="1.5", requires tone-mapping to be set

Interaction and Camera

autoplayadd or set to true to auto play animations e.g. <needle-engine autoplay
camera-controlsadd or set to true to automatically add OrbitControls if no camera controls are found in the scene
auto-rotateadd to enable auto-rotate (only used with camera-controls)
focus-rectQuery string to select an HTML element on your website to be used as the camera-focus-rect - Demo. Note that you can also set it programmatically with ctx.setCameraFocusRect(<element>|DOMRect)

Decoder Settings

For files that require a decoder (e.g. Draco compressed glb files), we automatically load an efficient decoder from the Needle CDN. If you want to create fully self-contained projects, can specify the path to the decoder with the following attributes.

dracoDecoderPathURL to the draco decoder e.g. ./include/draco/ to use the local Draco decoder
dracoDecoderTypedraco decoder type. Options are wasm or js. See three.js documentation
ktx2DecoderPathURL to the KTX2 decoder e.g. ./include/ktx2/ to use the local KTX2 decoder

Other

hashUsed internally, is appended to the files being loaded to force an update (e.g. when the browser has cached a GLB file). Should not be edited manually.

Loading screen (Needle Engine 6)

Preview — Needle Engine 6 (alpha)

The loading screen was redesigned in Needle Engine 6 (currently in alpha) and the options in this section are in preview — attribute names, CSS variables and defaults may still change before the stable release. Everything above this section applies to the current stable release.

Needle Engine 6 renders an animated progress bar (with an optional logo) that can be themed via HTML attributes or CSS custom properties.

Attribute
loading-styleColor theme of the loading overlay: auto (default — follows the OS prefers-color-scheme), light, or dark
loading-layoutcentered (default — bar centered, max 50% width) or minimal (thin bar pinned to the top edge)
loading-logoShow the logo on the loading overlay: true / false (off by default). The image comes from loading-logo-src or logo-src, otherwise the Needle logo
loading-logo-srcPRO — Custom loading logo image (URL, data: or blob: URL). Falls back to logo-src, then the Needle logo. Mirrors qrcode-logo-src

CSS custom properties — set any of these on the <needle-engine> element (inline style or in your CSS) to restyle the loader. A consumer value always wins over the built-in theme default:

VariableControlsDefault
--needle-loading-barprogress bar fill colorper theme
--needle-loading-bar-trackunfilled track colorper theme
--needle-loading-bar-donefill color once completesame as fill
--needle-loading-bar-sheenanimated highlight colorper theme
--needle-loading-sheen-sizesheen tile width (smaller = more bands)per layout
--needle-loading-sheen-speedtime to scroll one sheen bandper layout
--needle-loading-backgroundscrim color behind the loaderper theme
--needle-loading-blurbackdrop blur behind the loader6px
--needle-loading-colortext colorper theme

For example, to remove the scrim entirely so the page shows through while loading:

needle-engine {
    --needle-loading-background: transparent;
    --needle-loading-blur: 0px;
}

The poster image can be styled via CSS variables, or fully via needle-engine::part(poster):

VariableControlsDefault
--needle-loading-poster-overlaycolor painted over the image (darken/tint)transparent
--needle-loading-poster-blurblur amount0 (url) / 50px (bare poster)
--needle-loading-poster-sizecover / contain / …cover
--needle-loading-poster-positionbackground positioncenter
--needle-loading-poster-opacityposter opacity1

Example — a centered dark loader with a custom bar color and a darkened poster:

<needle-engine
  loading-style="dark"
  loading-layout="centered"
  poster="/poster.jpg"
  style="--needle-loading-bar:#78e08f; --needle-loading-poster-overlay:rgba(0,0,0,.5)">
</needle-engine>

Or restyle the loading bar from your stylesheet — set the variables on the <needle-engine> element (they win over the built-in theme):

needle-engine {
  --needle-loading-bar: #c9d497;                      /* fill color */
  --needle-loading-bar-track: rgba(85, 87, 12, 0.18); /* unfilled track */
  --needle-loading-bar-sheen: rgba(255, 255, 255, .5); /* animated highlight */
  --needle-loading-sheen-size: 400px;                  /* smaller = more/tighter bands */
  --needle-loading-sheen-speed: 1s;                  /* smaller = faster */
}

/* Optionally give dark mode its own bar color */
@media (prefers-color-scheme: dark) {
  needle-engine { --needle-loading-bar: #dbe6a8; }
}

Setting poster="0" disables the poster (same as omitting it). A poster automatically turns off the scrim/backdrop blur, since it becomes the background.

Upgrade notice:

  • Needle Engine 4.x–5.x: loading-style, loading-background-color, loading-text-color, primary-color, secondary-color were removed in 4.5.0, and the loading display rendered no logo since 4.10.0.
  • Needle Engine 6 (alpha) reintroduces a redesigned, themeable loading screen — see Loading screen (Needle Engine 6) above. loading-style returns with a new meaning (color theme: auto/light/dark), the logo is available again (opt-in via loading-logo), and loading-logo-src becomes the loading-specific logo source (mirroring qrcode-logo-src).

Examples

<!-- Setting the path to a custom glb to be loaded -->
<needle-engine src="path/to/your.glb"></needle-engine>
<!-- Overriding where the draco decoder is located -->
<needle-engine src="path/to/your.glb" dracoDecoderPath="./include/draco/"></needle-engine>

Setting environment images, playing animation and automatic camera controls. See it live on stackblitz

<needle-engine
      camera-controls
      auto-rotate
      autoplay
      skybox-image="https://dl.polyhaven.org/file/ph-assets/HDRIs/hdr/1k/industrial_sunset_puresky_1k.hdr"
      environment-image="https://dl.polyhaven.org/file/ph-assets/HDRIs/hdr/1k/industrial_sunset_puresky_1k.hdr"
      src="https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/DamagedHelmet/glTF-Embedded/DamagedHelmet.gltf"
      >
      </needle-engine>

Receiving loading events:

<needle-engine progress="onProgress" loadfinished="onLoadFinished"> </needle-engine>
<script>
    function onProgress(ctx, event) {
        const progress01 = evt.detail.totalProgress01;
        console.log(progress01);
    }

    function onLoadFinished() {
        console.log("Needle Engine has finished loading");
    }
</script>

Need more control?

For further customization or callbacks see the scripting documentation or Needle Engine hooks. Needle Engine is fully scriptable.

Prefer working visually?

These attributes can also be changed from within our Editor integrations, like Unity and Blender.

Suggest changes
Last Updated: 8/4/26, 12:54 PM

Extras

Needle AI Ask Needle AI
Copy Markdown

Navigation

  • Getting Started
  • Tutorials
  • How-To Guides
  • Explanation
  • Reference
  • Help

Extras

Needle AI Ask Needle AI
Copy Markdown