增加涡流修改器

This commit is contained in:
tianmo committed 2026-09-22 15:58:28 +08:00
1 parent 3f2699a946
commit 5f3a4a33fe
10 files changed
+136 -7

No files matched your search

+5 -1
View File
@@ -28,7 +28,7 @@
<script setup lang="ts">
import { type BonePreview } from './stage/stageTypes'
import { drawAxis } from './stage/axisGuides'
import { drawOrigin, drawShapeRange, drawForceField, drawAttraction } from './stage/emitterGuides'
import { drawOrigin, drawShapeRange, drawForceField, drawVortex, drawAttraction } from './stage/emitterGuides'
import { drawBoneFollowTargets, drawGizmo, drawCollisionBodies, drawPaths } from './stage/sceneGuides'
import { appendStateBones, drawBones } from './stage/boneGuides'
@@ -84,6 +84,7 @@ let boneFollowTargetGfx: Graphics | null = null
let boneGfx: Graphics | null = null
let shapeGfx: Graphics | null = null
let forceFieldGfx: Graphics | null = null
let vortexGfx: Graphics | null = null
let attractionGfx: Graphics | null = null
let collisionGfx: Graphics | null = null
let pathGfx: Graphics | null = null
@@ -130,6 +131,8 @@ function createLayers() {
world.addChild(shapeGfx)
forceFieldGfx = new Graphics() // 选中系统的全局力场范围
world.addChild(forceFieldGfx)
vortexGfx = new Graphics() // 选中系统的全局漩涡范围
world.addChild(vortexGfx)
attractionGfx = new Graphics() // 选中系统的全局吸附范围
world.addChild(attractionGfx)
collisionGfx = new Graphics()
@@ -435,6 +438,7 @@ function loop() {
drawOrigin(store, emitterPreviewTransform, originGfx)
drawShapeRange(store, emitterPreviewTransform, shapeGfx)
drawForceField(store, forceFieldGfx)
drawVortex(store, vortexGfx)
drawAttraction(store, attractionGfx)
drawGizmo(activeTool, interactions.selectedTransformTarget.bind(interactions), gizmoGfx)
drawBones(collected, store, boneGfx)
@@ -82,6 +82,26 @@
<div class="modifier-hint">正数吸向中心 · 负数向外排斥 · 可在画布内拖动力场圆</div>
</div>
</div>
<div class="modifier-item">
<label class="switch-row modifier-switch">
<input type="checkbox" v-model="sys.config.vortex" />
<span class="switch-ui"></span><span>开启漩涡</span>
</label>
<div v-if="sys.config.vortex" class="modifier-params">
<NumSlider label="中心 X" :min="-5000" :max="5000" :step="1" v-model="sys.config.vortexCenterX" />
<NumSlider label="中心 Y" :min="-5000" :max="5000" :step="1" v-model="sys.config.vortexCenterY" />
<NumSlider label="力场强度" :min="-300" :max="300" :step="1" v-model="sys.config.vortexStrength" />
<NumSlider label="力场半径" :min="1" :max="2000" :step="1" v-model="sys.config.vortexRadius" />
<label class="row"><span>衰减模式</span>
<select v-model="sys.config.vortexFalloff" class="inp">
<option value="constant">恒定(范围内力度不变)</option>
<option value="linear">线性衰减(边缘为 0)</option>
<option value="inverse">距离反比(中心最强)</option>
</select>
</label>
<div class="modifier-hint">正数逆时针 · 负数顺时针</div>
</div>
</div>
<div class="modifier-item">
<label class="switch-row modifier-switch">
<input type="checkbox" v-model="sys.config.attraction" />
@@ -326,6 +326,7 @@ const MODULE_RESET_KEYS: Record<Exclude<ResetModule, 'export'>, string[]> = {
'useGravity', 'gravity', 'gravityMode', 'gravityMin', 'gravityMax', 'gravityDirection', 'gravityCurve',
'wind', 'windX', 'windY', 'windMode', 'windMin', 'windMax', 'windDirection', 'windCurve',
'forceField', 'forceStrength', 'forceRadius', 'forceCenterX', 'forceCenterY', 'forceFalloff',
'vortex', 'vortexStrength', 'vortexRadius', 'vortexCenterX', 'vortexCenterY', 'vortexFalloff',
'attraction', 'attractionCenterX', 'attractionCenterY', 'attractionRadius',
'attractionDuration', 'attractionDelay', 'attractionDelayMode', 'attractionPath',
'trail', 'trailConfigVersion', 'trailResources', 'trailResourceVersion',
+28
View File
@@ -132,6 +132,34 @@ export function drawForceField(store: EditorStore, forceFieldGfx: Graphics | nul
g.endFill()
}
/** 绘制当前选中系统的全局漩涡范围与旋转方向。 */
export function drawVortex(store: EditorStore, vortexGfx: Graphics | null) {
if (!vortexGfx) return
const g = vortexGfx
g.clear()
const sys = store.systems.find((item) => item.id === store.activeId)
if (sys?.visible === false) return
const cfg = sys?.config
if (!cfg?.vortex || cfg.vortexRadius <= 0) return
const x = cfg.vortexCenterX
const y = -cfg.vortexCenterY
const color = cfg.vortexStrength >= 0 ? 0xb97cff : 0xffa24c
g.lineStyle(2, color, 0.9)
g.beginFill(color, 0.07)
g.drawCircle(x, y, cfg.vortexRadius)
g.endFill()
g.beginFill(color, 0.95)
g.drawCircle(x, y, 4)
g.endFill()
const markerX = x + Math.min(cfg.vortexRadius * 0.65, 50)
const direction = cfg.vortexStrength >= 0 ? -1 : 1
const endY = y + direction * 14
g.lineStyle(2, color, 0.9)
g.moveTo(markerX, y + direction * -8); g.lineTo(markerX, endY)
g.moveTo(markerX, endY); g.lineTo(markerX - 4, endY - direction * 5)
g.moveTo(markerX, endY); g.lineTo(markerX + 4, endY - direction * 5)
}
/** 绘制全局吸附点与吸附完成半径;半径为 0 时显示为红色点。 */
export function drawAttraction(store: EditorStore, attractionGfx: Graphics | null) {
if (!attractionGfx) return