Three Vue3Three Vue3
Guide
Demo
AI Agents
  • English
  • 简体中文
GitHub
Guide
Demo
AI Agents
  • English
  • 简体中文
GitHub
    • Getting Started
    • Scene
    • Parameter Bus
    • SkyBox
    • Model Loader

      • Component Loader
      • Function Loader
    • Popup
    • Callout
    • Movable Element
    • Animation
    • Model Rotator
    • Picker
    • Fit Camera
    • Mesh

      • Wave Circle Mesh
      • Flow Line Mesh
    • Effect

      • Nature

        • Rain
        • Snow
        • Water
        • Water Pool
        • Sandy Beach
      • Sky & Atmosphere

        • Sky Dome
        • HeightFog
        • Nebula Galaxy
      • Light

        • Bloom
        • Sweep Light
          • Default Usage
          • Options
          • Methods
          • Class usage
        • Light Gradient
        • Light Pillar
        • Radar Sweep
        • Signal Wave
        • Force Shield
      • Particles & Sprites

        • Fireworks
        • Text Fireworks
        • Glow Sprite
    • GIS

      • Geographic Reference
      • GeoObject
      • GeoJsonLayer
      • Tile Layer

type

Class

SweepLight sweeps an additive light band along one axis across every mesh of a target object. It clones the geometry of each mesh and draws it with a band shader, so the original materials stay untouched and the model keeps its look. The sweep runs from its own animation loop — no per-frame code is needed.

Default Usage

Click me to view the codes
<template>
  <tv-scene class="scene" bg-color="rgb(40, 42, 54)" @created="created"></tv-scene>
</template>

<script lang="ts" setup>
import { onBeforeUnmount } from 'vue'
import { GLTFLoader, SweepLight } from 'three-vue3'
import type * as THREE from 'three'

let effect: SweepLight | undefined
let model: THREE.Group | undefined

const created = async (scene, { camera }) => {
  if (!camera) return

  camera.position.set(0, 1.5, 3)
  camera.lookAt(0, 0, 0)

  model = await GLTFLoader('/models/perseverance.glb', true)
  model.scale.set(0.8, 0.8, 0.8)
  scene.add(model)

  // The sweep is drawn over the model's surface.
  effect = new SweepLight(model)
}

onBeforeUnmount(() => {
  effect?.dispose()
  effect = undefined
  if (model) {
    model.parent?.remove(model)
    model = undefined
  }
})
</script>

<style>
.scene {
  margin-top: 10px;
  margin-bottom: 16px;
  width: 100%;
  height: 300px;
}
</style>

Options

NameTypeDefaultDescription
colornumber0x00ffffoptional Sweep light color.
speednumber0.5optional Sweep speed, one pass takes 2 / speed secs.
widthnumber0.3optional Band width in the 0-1 range of the sweep axis.
intensitynumber1.5optional Light intensity.
directionnumber0optional Sweep axis: 0 = X, 1 = Y, 2 = Z.
loopLoopOnce / LoopRepeat / LoopPingPongLoopRepeatoptional Animation loop type.

Methods

NameParametersDescription
constructor(target: THREE.Object3D, options?)Create a sweep light on a mesh, group or scene object.
play() => voidPlay or resume the animation.
pause() => voidPause the animation at the current frame.
stop() => voidStop the animation and reset it to the initial state.
dispose() => voidDispose the sweep meshes and the shared material.

Class usage

import { SweepLight } from 'three-vue3'

const sweep = new SweepLight(model, { color: 0x00ffff, speed: 0.5 })
scene.add(model)

// The sweep runs from its own animation loop; on teardown:
sweep.dispose()
Edit this page on GitHub
Last Updated:
Contributors: Shing Rui
Prev
Bloom
Next
Light Gradient