Ethscriptions commited on
Commit
55311f3
·
verified ·
1 Parent(s): 71ce0f9

v9:远光改为整幅均匀提亮、去掉方块高光;Roadster 车尾比例加高

Browse files
README.md CHANGED
@@ -262,3 +262,4 @@ npm run build && npm start # 生产(http://localhost:3000)
262
  - Drop2 喷射气体重做为粒子模型 `gas.ts`:气体从四个推力口高速喷出,受空气阻力减速,撞到路面后沿地面向四周翻滚扩散,再受浮力缓慢上升、膨胀、消散;向后喷射时形成长长的尾流;用缓存的柔和云团贴图(带自阴影、边缘不规则)以常规混合绘制,不发光;气体在车身前后正确分层;侧面镜头使用同一套粒子;
263
  - 新增动感歌词 `lyrics.ts` + 页面「02 歌词」区:支持粘贴 LRC(含 offset)或纯文本,「打轴」模式下音乐从头播放,每唱到一句按 Enter / J 自动生成时间轴,可 ±0.1 s 微调、复制 LRC;歌词逐字弹出(回弹)、已唱部分红橙渐变填色、鼓点时整句缩放、字符抖动并出现红青色散、结束时逐字上飘消失;歌词会画进画面,导出 MP4 时一并带上;首次使用时按需加载含 6763 个常用汉字的歌词字体(约 950 KB);
264
  - 说明:歌词受版权保护,项目不内置歌词原文,需要使用者自行粘贴。
 
 
262
  - Drop2 喷射气体重做为粒子模型 `gas.ts`:气体从四个推力口高速喷出,受空气阻力减速,撞到路面后沿地面向四周翻滚扩散,再受浮力缓慢上升、膨胀、消散;向后喷射时形成长长的尾流;用缓存的柔和云团贴图(带自阴影、边缘不规则)以常规混合绘制,不发光;气体在车身前后正确分层;侧面镜头使用同一套粒子;
263
  - 新增动感歌词 `lyrics.ts` + 页面「02 歌词」区:支持粘贴 LRC(含 offset)或纯文本,「打轴」模式下音乐从头播放,每唱到一句按 Enter / J 自动生成时间轴,可 ±0.1 s 微调、复制 LRC;歌词逐字弹出(回弹)、已唱部分红橙渐变填色、鼓点时整句缩放、字符抖动并出现红青色散、结束时逐字上飘消失;歌词会画进画面,导出 MP4 时一并带上;首次使用时按需加载含 6763 个常用汉字的歌词字体(约 950 KB);
264
  - 说明:歌词受版权保护,项目不内置歌词原文,需要使用者自行粘贴。
265
+ - **步骤 14(v9)** ✅ 58–62 秒远光:去掉照亮红车时叠加的长方形高光块,以及路面上分段的光带,改为整幅画面均匀提亮(强度跟随远光 / 鼓点)+ 白闪;红车自身车头灯光晕缩小。01:56 正后方视角:Roadster 车尾 / 车头的高宽比从 0.42 提高到 0.56(圆润的玻璃顶、更厚的车身、更宽的轮胎),不再显得扁。全时间轴扫描无报错。
src/mv/engine/cars.ts CHANGED
@@ -772,7 +772,7 @@ export function rivalCarFront(ctx: C2D, cx: number, groundY: number, w: number,
772
  ctx.lineTo(hx - w * 0.11, hy + w * 0.03)
773
  ctx.closePath()
774
  ink(ctx, head > 0.1 ? '#eaf6ff' : '#6a727c', lw)
775
- if (head > 0.1) glowBlob(ctx, hx, hy, w * 0.3, '#dff0ff', 0.75 * head)
776
  }
777
  ctx.restore()
778
  // lit by 阿飞's high beams
@@ -918,59 +918,77 @@ export function roadsterSide(ctx: C2D, x: number, y: number, L: number, pitch: n
918
  /** rear view. (cx, groundY) bottom centre, w width px. jet: rear thrusters firing */
919
  export function roadsterRear(ctx: C2D, cx: number, groundY: number, w: number, o: { brake?: number; jet?: number; t?: number } = {}) {
920
  const lw = Math.max(1, w * 0.007)
921
- const top = groundY - w * 0.42
922
  ctx.save()
923
  ctx.lineJoin = 'round'
924
  ctx.fillStyle = 'rgba(0,0,0,0.5)'
925
  ctx.beginPath()
926
- ctx.ellipse(cx, groundY, w * 0.6, w * 0.06, 0, 0, Math.PI * 2)
927
  ctx.fill()
928
- ctx.fillStyle = '#0a0a0c'
929
- ctx.fillRect(cx - w * 0.5, groundY - w * 0.17, w * 0.17, w * 0.17)
930
- ctx.fillRect(cx + w * 0.33, groundY - w * 0.17, w * 0.17, w * 0.17)
931
- // glass dome
 
 
 
932
  ctx.beginPath()
933
- ctx.moveTo(cx - w * 0.36, top + w * 0.17)
934
- ctx.quadraticCurveTo(cx, top - w * 0.03, cx + w * 0.36, top + w * 0.17)
935
  ctx.closePath()
936
  ink(ctx, RD.glass, lw)
 
 
 
 
937
  ctx.fillStyle = HERO.hair
938
  ctx.beginPath()
939
- ctx.arc(cx - w * 0.12, top + w * 0.12, w * 0.06, 0, Math.PI * 2)
940
  ctx.fill()
941
- // wide hips
942
  ctx.beginPath()
943
- ctx.moveTo(cx - w * 0.5, groundY - w * 0.08)
944
- ctx.lineTo(cx - w * 0.52, top + w * 0.2)
945
- ctx.quadraticCurveTo(cx, top + w * 0.12, cx + w * 0.52, top + w * 0.2)
946
- ctx.lineTo(cx + w * 0.5, groundY - w * 0.08)
 
 
947
  ctx.closePath()
948
  ink(ctx, RD.body, lw)
 
 
949
  // full-width light bar
950
  const br = o.brake ?? 0
951
  ctx.beginPath()
952
- ctx.roundRect(cx - w * 0.46, top + w * 0.21, w * 0.92, w * 0.025, w * 0.01)
953
  ink(ctx, br > 0.3 ? '#ff5a70' : '#e0102e', lw)
954
- glowBlob(ctx, cx, top + w * 0.225, w * (0.35 + 0.2 * br), '#ff2040', 0.55 + 0.3 * br)
955
  ctx.fillStyle = RD.stripe
956
- ctx.fillRect(cx - w * 0.5, top + w * 0.27, w * 0.06, w * 0.02)
957
- ctx.fillRect(cx + w * 0.44, top + w * 0.27, w * 0.06, w * 0.02)
958
- // diffuser + plate (the thrusters hide behind it)
 
 
 
959
  ctx.beginPath()
960
- ctx.rect(cx - w * 0.4, groundY - w * 0.11, w * 0.8, w * 0.06)
961
  ink(ctx, RD.trim, lw)
 
 
962
  ctx.beginPath()
963
- ctx.rect(cx - w * 0.11, top + w * 0.27, w * 0.22, w * 0.06)
964
- ink(ctx, '#e8e2d6', lw)
 
 
 
965
  const jet = o.jet ?? 0
966
  if (jet > 0.02) {
967
- // cold gas: white vapour at the ports, not light
968
  for (const sd of [-1, 1]) {
969
- const g = ctx.createRadialGradient(cx + sd * w * 0.06, top + w * 0.3, 0, cx + sd * w * 0.06, top + w * 0.3, w * 0.22 * jet)
970
  g.addColorStop(0, `rgba(215,220,230,${0.6 * jet})`)
971
  g.addColorStop(1, 'rgba(215,220,230,0)')
972
  ctx.fillStyle = g
973
- ctx.fillRect(cx + sd * w * 0.06 - w * 0.22, top + w * 0.08, w * 0.44, w * 0.44)
974
  }
975
  }
976
  ctx.restore()
@@ -979,7 +997,7 @@ export function roadsterRear(ctx: C2D, cx: number, groundY: number, w: number, o
979
  /** front view with slim LED headlights */
980
  export function roadsterFront(ctx: C2D, cx: number, groundY: number, w: number, o: { head?: number; t?: number } = {}) {
981
  const lw = Math.max(1, w * 0.007)
982
- const top = groundY - w * 0.4
983
  ctx.save()
984
  ctx.fillStyle = 'rgba(0,0,0,0.5)'
985
  ctx.beginPath()
 
772
  ctx.lineTo(hx - w * 0.11, hy + w * 0.03)
773
  ctx.closePath()
774
  ink(ctx, head > 0.1 ? '#eaf6ff' : '#6a727c', lw)
775
+ if (head > 0.1) glowBlob(ctx, hx, hy, w * 0.18, '#dff0ff', 0.5 * head)
776
  }
777
  ctx.restore()
778
  // lit by 阿飞's high beams
 
918
  /** rear view. (cx, groundY) bottom centre, w width px. jet: rear thrusters firing */
919
  export function roadsterRear(ctx: C2D, cx: number, groundY: number, w: number, o: { brake?: number; jet?: number; t?: number } = {}) {
920
  const lw = Math.max(1, w * 0.007)
921
+ const top = groundY - w * 0.56
922
  ctx.save()
923
  ctx.lineJoin = 'round'
924
  ctx.fillStyle = 'rgba(0,0,0,0.5)'
925
  ctx.beginPath()
926
+ ctx.ellipse(cx, groundY, w * 0.6, w * 0.07, 0, 0, Math.PI * 2)
927
  ctx.fill()
928
+ // fat rear tyres
929
+ for (const sd of [-1, 1]) {
930
+ ctx.beginPath()
931
+ ctx.roundRect(cx + sd * w * 0.42 - w * 0.1, groundY - w * 0.22, w * 0.2, w * 0.22, w * 0.03)
932
+ ink(ctx, '#0a0a0c', lw)
933
+ }
934
+ // rounded glass canopy with the driver's curly head
935
  ctx.beginPath()
936
+ ctx.moveTo(cx - w * 0.37, top + w * 0.25)
937
+ ctx.bezierCurveTo(cx - w * 0.36, top + w * 0.02, cx + w * 0.36, top + w * 0.02, cx + w * 0.37, top + w * 0.25)
938
  ctx.closePath()
939
  ink(ctx, RD.glass, lw)
940
+ ctx.fillStyle = rgba(RD.glassHi, 0.35)
941
+ ctx.beginPath()
942
+ ctx.ellipse(cx + w * 0.12, top + w * 0.1, w * 0.12, w * 0.04, -0.2, 0, Math.PI * 2)
943
+ ctx.fill()
944
  ctx.fillStyle = HERO.hair
945
  ctx.beginPath()
946
+ ctx.arc(cx - w * 0.13, top + w * 0.16, w * 0.075, 0, Math.PI * 2)
947
  ctx.fill()
948
+ // muscular rear haunches
949
  ctx.beginPath()
950
+ ctx.moveTo(cx - w * 0.49, groundY - w * 0.1)
951
+ ctx.lineTo(cx - w * 0.52, top + w * 0.36)
952
+ ctx.quadraticCurveTo(cx - w * 0.5, top + w * 0.22, cx - w * 0.3, top + w * 0.24)
953
+ ctx.lineTo(cx + w * 0.3, top + w * 0.24)
954
+ ctx.quadraticCurveTo(cx + w * 0.5, top + w * 0.22, cx + w * 0.52, top + w * 0.36)
955
+ ctx.lineTo(cx + w * 0.49, groundY - w * 0.1)
956
  ctx.closePath()
957
  ink(ctx, RD.body, lw)
958
+ ctx.fillStyle = rgba(RD.shade, 0.55)
959
+ ctx.fillRect(cx - w * 0.49, groundY - w * 0.2, w * 0.98, w * 0.1)
960
  // full-width light bar
961
  const br = o.brake ?? 0
962
  ctx.beginPath()
963
+ ctx.roundRect(cx - w * 0.46, top + w * 0.3, w * 0.92, w * 0.03, w * 0.012)
964
  ink(ctx, br > 0.3 ? '#ff5a70' : '#e0102e', lw)
965
+ glowBlob(ctx, cx, top + w * 0.315, w * (0.32 + 0.2 * br), '#ff2040', 0.5 + 0.3 * br)
966
  ctx.fillStyle = RD.stripe
967
+ ctx.fillRect(cx - w * 0.51, top + w * 0.38, w * 0.07, w * 0.025)
968
+ ctx.fillRect(cx + w * 0.44, top + w * 0.38, w * 0.07, w * 0.025)
969
+ // plate (the thrusters hide behind it) + diffuser
970
+ ctx.beginPath()
971
+ ctx.rect(cx - w * 0.11, top + w * 0.37, w * 0.22, w * 0.065)
972
+ ink(ctx, '#e8e2d6', lw)
973
  ctx.beginPath()
974
+ ctx.rect(cx - w * 0.4, groundY - w * 0.13, w * 0.8, w * 0.06)
975
  ink(ctx, RD.trim, lw)
976
+ ctx.strokeStyle = '#2a2d34'
977
+ ctx.lineWidth = lw
978
  ctx.beginPath()
979
+ for (let k = -3; k <= 3; k++) {
980
+ ctx.moveTo(cx + k * w * 0.1, groundY - w * 0.13)
981
+ ctx.lineTo(cx + k * w * 0.1, groundY - w * 0.07)
982
+ }
983
+ ctx.stroke()
984
  const jet = o.jet ?? 0
985
  if (jet > 0.02) {
 
986
  for (const sd of [-1, 1]) {
987
+ const g = ctx.createRadialGradient(cx + sd * w * 0.06, top + w * 0.4, 0, cx + sd * w * 0.06, top + w * 0.4, w * 0.22 * jet)
988
  g.addColorStop(0, `rgba(215,220,230,${0.6 * jet})`)
989
  g.addColorStop(1, 'rgba(215,220,230,0)')
990
  ctx.fillStyle = g
991
+ ctx.fillRect(cx + sd * w * 0.06 - w * 0.22, top + w * 0.18, w * 0.44, w * 0.44)
992
  }
993
  }
994
  ctx.restore()
 
997
  /** front view with slim LED headlights */
998
  export function roadsterFront(ctx: C2D, cx: number, groundY: number, w: number, o: { head?: number; t?: number } = {}) {
999
  const lw = Math.max(1, w * 0.007)
1000
+ const top = groundY - w * 0.52
1001
  ctx.save()
1002
  ctx.fillStyle = 'rgba(0,0,0,0.5)'
1003
  ctx.beginPath()
src/mv/engine/road3d.ts CHANGED
@@ -228,6 +228,7 @@ export interface Actor {
228
  jet?: { power: number; angle: number }
229
  jetKit?: boolean
230
  shield?: number
 
231
  }
232
 
233
  const LEN: Record<CarKind, number> = { hero: 4.0, rival: 4.5, roadster: 4.3, truck: 16 }
@@ -281,7 +282,7 @@ export function drawBeams(s: SceneCtx, c: Cam, actors: Actor[]) {
281
  const toCamX = c.x - ox
282
  const toCamZ = c.z - oz
283
  const facing = (toCamX * fx + toCamZ * fz) / (Math.hypot(toCamX, toCamZ) || 1)
284
- if (facing > 0.2) glowBlob(ctx, p.x, p.y, Math.min(s.W * 0.18, p.k * (0.6 + 1.6 * high)), '#fff4dc', (0.35 + 0.45 * high) * facing * clamp((p.z - 1.5) / 4))
285
  }
286
  }
287
  ctx.restore()
@@ -334,7 +335,7 @@ export function drawActors(s: SceneCtx, c: Cam, actors: Actor[]) {
334
  carRear(ctx, a.kind, g.x, g.y, w, { brake: a.brake, pop: a.pop, jet: a.jet && a.jet.angle > 2.4 ? a.jet.power : 0, t })
335
  } else if (Math.abs(diff) > Math.PI - 0.7) {
336
  if (a.kind === 'hero') heroCarFront(ctx, g.x, g.y, w, { head: a.head ?? 1, high: a.high ?? 0, t })
337
- else rivalCarFront(ctx, g.x, g.y, w, { head: a.head ?? 1, t, shield: a.shield ?? 0, lit: a.shield ?? 0 })
338
  } else {
339
  const L = LEN[a.kind] * g.k
340
  const fs = Math.abs(Math.sin(diff))
 
228
  jet?: { power: number; angle: number }
229
  jetKit?: boolean
230
  shield?: number
231
+ lit?: number
232
  }
233
 
234
  const LEN: Record<CarKind, number> = { hero: 4.0, rival: 4.5, roadster: 4.3, truck: 16 }
 
282
  const toCamX = c.x - ox
283
  const toCamZ = c.z - oz
284
  const facing = (toCamX * fx + toCamZ * fz) / (Math.hypot(toCamX, toCamZ) || 1)
285
+ if (facing > 0.2) glowBlob(ctx, p.x, p.y, Math.min(s.W * 0.1, p.k * (0.5 + 1.2 * high)), '#fff4dc', (0.35 + 0.45 * high) * facing * clamp((p.z - 1.5) / 4))
286
  }
287
  }
288
  ctx.restore()
 
335
  carRear(ctx, a.kind, g.x, g.y, w, { brake: a.brake, pop: a.pop, jet: a.jet && a.jet.angle > 2.4 ? a.jet.power : 0, t })
336
  } else if (Math.abs(diff) > Math.PI - 0.7) {
337
  if (a.kind === 'hero') heroCarFront(ctx, g.x, g.y, w, { head: a.head ?? 1, high: a.high ?? 0, t })
338
+ else rivalCarFront(ctx, g.x, g.y, w, { head: a.head ?? 1, t, shield: a.shield ?? 0, lit: a.lit ?? 0 })
339
  } else {
340
  const L = LEN[a.kind] * g.k
341
  const fs = Math.abs(Math.sin(diff))
src/mv/engine/scenesCar.ts CHANGED
@@ -599,7 +599,7 @@ function heroPOV(s: SceneCtx, st: CarState, lookYaw = 0, pitch = 0, fov = 1, rol
599
  function actorsDuel(tau: number, high = 0, shield = 0): Actor[] {
600
  const st = duelState(tau)
601
  return [
602
- { kind: 'rival', x: st.rival.x, z: st.rival.z, h: 0, brake: st.rival.brake, head: 1, pop: 0, shield, look: 0 },
603
  { kind: 'hero', x: st.hero.x, z: st.hero.z, h: st.hero.h, head: 1, high },
604
  ]
605
  }
@@ -726,33 +726,14 @@ export function sDuel(s: SceneCtx) {
726
  let beam = 0
727
  if (sinceOn >= 0 && bar <= 9) beam = Math.max(clamp(1 - sinceOn / 0.6), bar >= 7 ? clamp(a.kick * 1.2 + a.low * 0.4 + a.high * 0.15) : 0.85)
728
  const whiteOut = (sinceOn >= 0 && sinceOn < 1.2 ? Math.exp(-sinceOn * 3.2) : 0) + (bar >= 7 && bar <= 9 && a.beat % 2 === 0 ? clamp((beam - 0.72) * 3) * 0.85 : 0)
729
- const flood = (c: Cam) => {
730
- // light thrown over the entire road surface in the direction the car faces
 
731
  if (beam <= 0.02) return
732
- const h = st.hero
733
- const fz = Math.cos(h.h)
734
- const z0 = h.z + fz * 2
735
  ctx.save()
736
  ctx.globalCompositeOperation = 'lighter'
737
- for (let d = 0; d < 90; d += 3) {
738
- const fall = 1 / (1 + d / 22)
739
- const za = z0 + fz * d
740
- const zb = z0 + fz * (d + 3.05)
741
- poly3(ctx, c, s, [
742
- [-7.4, 0.02, za],
743
- [7.4, 0.02, za],
744
- [7.4, 0.02, zb],
745
- [-7.4, 0.02, zb],
746
- ], `rgba(255,246,228,${0.42 * beam * fall})`)
747
- // guard rails catch the light too
748
- for (const sd of [-1, 1])
749
- poly3(ctx, c, s, [
750
- [sd * 7.6, 0.55, za],
751
- [sd * 7.6, 0.9, za],
752
- [sd * 7.6, 0.9, zb],
753
- [sd * 7.6, 0.55, zb],
754
- ], `rgba(255,246,228,${0.5 * beam * fall})`)
755
- }
756
  ctx.restore()
757
  }
758
  const flashScreen = () => {
@@ -767,9 +748,10 @@ export function sDuel(s: SceneCtx) {
767
  const c = heroPOV(s, st.hero, 0, 0.02, 1, roll)
768
  drawHighway(s, c)
769
  flood(c)
770
- const acts = actorsDuel(tau, beam, beam)
771
  drawPuffs(s, c, spinSmoke(tau))
772
  drawActors(s, c, acts)
 
773
  windshield(s, false)
774
  if (spinning) {
775
  ctx.fillStyle = 'rgba(220,225,235,0.12)'
@@ -791,7 +773,8 @@ export function sDuel(s: SceneCtx) {
791
  drawHighway(s, c)
792
  flood(c)
793
  drawPuffs(s, c, spinSmoke(tau))
794
- drawActors(s, c, actorsDuel(tau, beam, beam))
 
795
  windshield(s, false)
796
  flashScreen()
797
  return
 
599
  function actorsDuel(tau: number, high = 0, shield = 0): Actor[] {
600
  const st = duelState(tau)
601
  return [
602
+ { kind: 'rival', x: st.rival.x, z: st.rival.z, h: 0, brake: st.rival.brake, head: 1, pop: 0, shield, look: 0, lit: 0 },
603
  { kind: 'hero', x: st.hero.x, z: st.hero.z, h: st.hero.h, head: 1, high },
604
  ]
605
  }
 
726
  let beam = 0
727
  if (sinceOn >= 0 && bar <= 9) beam = Math.max(clamp(1 - sinceOn / 0.6), bar >= 7 ? clamp(a.kick * 1.2 + a.low * 0.4 + a.high * 0.15) : 0.85)
728
  const whiteOut = (sinceOn >= 0 && sinceOn < 1.2 ? Math.exp(-sinceOn * 3.2) : 0) + (bar >= 7 && bar <= 9 && a.beat % 2 === 0 ? clamp((beam - 0.72) * 3) * 0.85 : 0)
729
+ // high beams light the whole frame evenly (no patches), plus the white flash
730
+ const flood = (_c: Cam) => {}
731
+ const evenLight = () => {
732
  if (beam <= 0.02) return
 
 
 
733
  ctx.save()
734
  ctx.globalCompositeOperation = 'lighter'
735
+ ctx.fillStyle = `rgba(255,244,226,${0.32 * beam})`
736
+ ctx.fillRect(0, 0, W, H)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
737
  ctx.restore()
738
  }
739
  const flashScreen = () => {
 
748
  const c = heroPOV(s, st.hero, 0, 0.02, 1, roll)
749
  drawHighway(s, c)
750
  flood(c)
751
+ const acts = actorsDuel(tau, 0, beam)
752
  drawPuffs(s, c, spinSmoke(tau))
753
  drawActors(s, c, acts)
754
+ evenLight()
755
  windshield(s, false)
756
  if (spinning) {
757
  ctx.fillStyle = 'rgba(220,225,235,0.12)'
 
773
  drawHighway(s, c)
774
  flood(c)
775
  drawPuffs(s, c, spinSmoke(tau))
776
+ drawActors(s, c, actorsDuel(tau, 0, beam))
777
+ evenLight()
778
  windshield(s, false)
779
  flashScreen()
780
  return