显示调整
This commit is contained in:
1 parent
178a7d8412
commit
b5ac9552a1
9 files changed
+1064
-81
No files matched your search
+27
-13
@@ -275,8 +275,15 @@ export interface EmitterConfig {
|
||||
/** 开启路径跟随(预留) */
|
||||
pathFollow: boolean
|
||||
emitterFollow: boolean
|
||||
emitterFollowMode: 'none' | 'path'
|
||||
emitterFollowMode: 'none' | 'path' | 'bone'
|
||||
emitterFollowPathId: number
|
||||
emitterFollowSpineId: number
|
||||
emitterFollowBoneName: string
|
||||
emitterFollowBoneOffsetX: number
|
||||
emitterFollowBoneOffsetY: number
|
||||
emitterFollowBoneRotation: number
|
||||
emitterFollowBoneScaleX: number
|
||||
emitterFollowBoneScaleY: number
|
||||
emitterAngleMode: 'fixed' | 'direction'
|
||||
emitterFollowCurve: CurvePoint[]
|
||||
emitterFollowDuration: number
|
||||
@@ -504,6 +511,13 @@ export function defaultConfig(): EmitterConfig {
|
||||
emitterFollow: false,
|
||||
emitterFollowMode: 'none',
|
||||
emitterFollowPathId: 0,
|
||||
emitterFollowSpineId: 0,
|
||||
emitterFollowBoneName: '',
|
||||
emitterFollowBoneOffsetX: 0,
|
||||
emitterFollowBoneOffsetY: 0,
|
||||
emitterFollowBoneRotation: 0,
|
||||
emitterFollowBoneScaleX: 1,
|
||||
emitterFollowBoneScaleY: 1,
|
||||
emitterAngleMode: 'fixed',
|
||||
emitterFollowCurve: [{ x: 0, y: 0 }, { x: 1, y: 1 }],
|
||||
emitterFollowDuration: 2,
|
||||
@@ -734,7 +748,7 @@ export class ParticleEmitter extends Container {
|
||||
private followSpawnX = 0
|
||||
private followSpawnY = 0
|
||||
private followSpawnAngle = 0
|
||||
private simulationTransform: { centerX: number; centerY: number; rotation: number } | null = null
|
||||
private simulationTransform: { centerX: number; centerY: number; rotation: number; scaleX?: number; scaleY?: number } | null = null
|
||||
|
||||
constructor(config: EmitterConfig, maxParticles = MAX_PARTICLES) {
|
||||
super()
|
||||
@@ -795,8 +809,8 @@ export class ParticleEmitter extends Container {
|
||||
this.followSpawnY = y
|
||||
this.followSpawnAngle = angleDegrees
|
||||
}
|
||||
setSimulationTransform(centerX: number, centerY: number, rotation: number) {
|
||||
this.simulationTransform = { centerX, centerY, rotation }
|
||||
setSimulationTransform(centerX: number, centerY: number, rotation: number, scaleX?: number, scaleY?: number) {
|
||||
this.simulationTransform = { centerX, centerY, rotation, scaleX, scaleY }
|
||||
}
|
||||
|
||||
private applyColliders(p: Particle, particleIndex: number) {
|
||||
@@ -1543,10 +1557,10 @@ export class ParticleEmitter extends Container {
|
||||
|
||||
function lerp(a: number, b: number, t: number) { return a + (b - a) * t }
|
||||
function finite(value: number, fallback: number) { return Number.isFinite(value) ? value : fallback }
|
||||
type SimulationTransform = { centerX: number; centerY: number; rotation: number } | null
|
||||
type SimulationTransform = { centerX: number; centerY: number; rotation: number; scaleX?: number; scaleY?: number } | null
|
||||
function localToWorldMath(cfg: EmitterConfig, localX: number, localY: number, transform: SimulationTransform = null) {
|
||||
const scaleX = Math.max(0.0001, Math.abs(cfg.rootScaleX))
|
||||
const scaleY = Math.max(0.0001, Math.abs(cfg.rootScaleY))
|
||||
const scaleX = Math.max(0.0001, Math.abs(transform?.scaleX ?? cfg.rootScaleX))
|
||||
const scaleY = Math.max(0.0001, Math.abs(transform?.scaleY ?? cfg.rootScaleY))
|
||||
const angle = -(transform?.rotation ?? cfg.rootRotation) * Math.PI / 180
|
||||
const cos = Math.cos(angle), sin = Math.sin(angle)
|
||||
const centerX = transform?.centerX ?? cfg.centerX
|
||||
@@ -1556,8 +1570,8 @@ function localToWorldMath(cfg: EmitterConfig, localX: number, localY: number, tr
|
||||
return { x: screenX, y: -screenY }
|
||||
}
|
||||
function worldMathToLocal(cfg: EmitterConfig, worldX: number, worldY: number, transform: SimulationTransform = null) {
|
||||
const scaleX = Math.max(0.0001, Math.abs(cfg.rootScaleX))
|
||||
const scaleY = Math.max(0.0001, Math.abs(cfg.rootScaleY))
|
||||
const scaleX = Math.max(0.0001, Math.abs(transform?.scaleX ?? cfg.rootScaleX))
|
||||
const scaleY = Math.max(0.0001, Math.abs(transform?.scaleY ?? cfg.rootScaleY))
|
||||
const angle = -(transform?.rotation ?? cfg.rootRotation) * Math.PI / 180
|
||||
const cos = Math.cos(angle), sin = Math.sin(angle)
|
||||
const screenX = worldX - (transform?.centerX ?? cfg.centerX)
|
||||
@@ -1568,8 +1582,8 @@ function worldMathToLocal(cfg: EmitterConfig, worldX: number, worldY: number, tr
|
||||
}
|
||||
}
|
||||
function localVelocityToWorldMath(cfg: EmitterConfig, vx: number, vy: number, transform: SimulationTransform = null) {
|
||||
const scaleX = Math.max(0.0001, Math.abs(cfg.rootScaleX))
|
||||
const scaleY = Math.max(0.0001, Math.abs(cfg.rootScaleY))
|
||||
const scaleX = Math.max(0.0001, Math.abs(transform?.scaleX ?? cfg.rootScaleX))
|
||||
const scaleY = Math.max(0.0001, Math.abs(transform?.scaleY ?? cfg.rootScaleY))
|
||||
const angle = -(transform?.rotation ?? cfg.rootRotation) * Math.PI / 180
|
||||
const cos = Math.cos(angle), sin = Math.sin(angle)
|
||||
const screenX = cos * scaleX * vx - sin * scaleY * vy
|
||||
@@ -1577,8 +1591,8 @@ function localVelocityToWorldMath(cfg: EmitterConfig, vx: number, vy: number, tr
|
||||
return { x: screenX, y: -screenY }
|
||||
}
|
||||
function worldVelocityToLocalMath(cfg: EmitterConfig, vx: number, vy: number, transform: SimulationTransform = null) {
|
||||
const scaleX = Math.max(0.0001, Math.abs(cfg.rootScaleX))
|
||||
const scaleY = Math.max(0.0001, Math.abs(cfg.rootScaleY))
|
||||
const scaleX = Math.max(0.0001, Math.abs(transform?.scaleX ?? cfg.rootScaleX))
|
||||
const scaleY = Math.max(0.0001, Math.abs(transform?.scaleY ?? cfg.rootScaleY))
|
||||
const angle = -(transform?.rotation ?? cfg.rootRotation) * Math.PI / 180
|
||||
const cos = Math.cos(angle), sin = Math.sin(angle)
|
||||
const screenY = -vy
|
||||
|
||||
Reference in new issue
Block a user