Three Vue3Three Vue3
指南
  • English
  • 简体中文
GitHub
指南
  • English
  • 简体中文
GitHub
    • 快速开始
    • 场景
    • 天空盒
    • 模型加载器

      • 组件加载器
      • 函数加载器
    • 弹出窗口
    • 动态元素
    • 动画
    • 网格模型

      • 波动圆
      • 流动线网格
        • 默认用法
        • 自定义选项
        • 构造函数参数
    • 效果

      • 泛光

type

Class

默认用法

点击查看代码
<template>
  <tv-scene class="flow-line" @created="created"></tv-scene>
</template>

<script lang="ts" setup>
import { FlowLineMesh, AxisType } from 'three-vue3'
import * as THREE from 'three'

const points = [
  new THREE.Vector3(-2, 0, 0),
  new THREE.Vector3(-1.5, 0.3, 0),
  new THREE.Vector3(-1, 0.5, 0),
  new THREE.Vector3(-0.5, 0.6, 0),
  new THREE.Vector3(0, 0.6, 0),
  new THREE.Vector3(0.5, 0.6, 0),
  new THREE.Vector3(1, 0.5, 0),
  new THREE.Vector3(1.5, 0.3, 0),
  new THREE.Vector3(2, 0, 0)
]
const mesh = new FlowLineMesh({ 
  points,
  width: 0.3,
  axis: AxisType.Z,
  textureRepeat: 8,
  speed: 16,
  color: [0.0, 1.0, 1.0, 1]
})
const created = (scene, { camera }) => {
  camera.position.set(0, 0, 3)
  camera.lookAt(0, 0, 0)

  // 添加网格到场景
  scene.add(mesh)
}
</script>

<style>
.flow-line {
  margin-top: 10px;
  width: 100%;
  height: 300px;
}
</style>

自定义选项

点击查看代码
<template>
  <tv-scene class="flow-line" @created="created"></tv-scene>
</template>

<script lang="ts" setup>
import { FlowLineMesh } from 'three-vue3'
import * as THREE from 'three'

const points = [
  new THREE.Vector3(-2, 0, 0),
  new THREE.Vector3(2, 0, 0)
]
const mesh = new FlowLineMesh({
  points,
  color: [0.0, 1.0, 1.0, 1],
  speed: 16,
  width: 0.4,
  axis: AxisType.Z,
  textureRepeat: 10
})
const created = (scene, { camera }) => {
  camera.position.set(0, 0, 3)
  camera.lookAt(0, 0, 0)

  // 添加网格到场景
  scene.add(mesh)
}
</script>

<style>
.flow-line {
  margin-top: 10px;
  width: 100%;
  height: 300px;
}
</style>

构造函数参数

参数属性类型默认值描述
optionspointsTHREE.Vector3[][-1,0,0], [0,0.5,0], [1,0,0]可选 定义线路径的所有 3D 坐标点数组。
color[number, number, number, number][0.6, 0.96, 0.98, 1]可选 流动线的颜色(RGBA)。
speednumber1可选 流动动画的速度。
widthnumber0.05可选 线的宽度。
axisAxisTypeAxisType.Z可选 线的朝向轴。X、Y 或 Z。
在 GitHub 上编辑此页
Last Updated:
Contributors: Shing Rui
Prev
波动圆