All prompts › Simulations & physics
Firecracker box chain reaction in three.js
What it tests: A long, number-heavy three.js spec: 100 colliding firecrackers, timed fuses, shock waves, fire-radius ignition with random delays, particles, dynamic lights and three required classes. It tests whether the model keeps every number and mechanic straight.
Prompt length: 2,500 characters, roughly 1,670 tokens (estimate). Set a large context in your runner so the prompt and a long answer both fit.
请使用 three.js 实现一个逼真的"鞭炮箱子"3D爆炸连锁反应演示。所有代码(包括HTML, CSS, JavaScript)都必须封装在一个独立的HTML文件中。
**场景设置:**
1. **平面:** 创建一个尺寸为1000×1000的灰色、光滑的水平平面,能接收阴影。地面材质使用```{color: 0x808080, roughness: 0.8, metalness: 0.1}```。
2. **鞭炮建模:**
- **主体:** 红色圆柱体,高度1,直径0.2,材质使用```{color: 0xff0000, roughness: 0.6, metalness: 0.2}```
- **封土:** 圆柱体顶部和底部各有一个土黄色的小圆柱,高度0.05,材质```{color: 0xdaa520, roughness: 0.8}```
- **引线:** 从顶部封土中心伸出的蓝绿色细圆柱,长度0.5,直径0.05,材质```{color: 0x20b2aa, roughness: 0.4}```
- **碰撞体积:** 鞭炮之间有碰撞体积, 防止模型互相重叠
- **燃烧状态:** 引线顶端需要能显示小的橙红色发光球体模拟火星
3. **透明箱子:**
- 尺寸:10×10×8的透明玻璃箱子, 顶部没有碰撞体积, 其他面则有碰撞体积,材质```{color: 0xffffff, transparent: true, opacity: 0.15, roughness: 0.1, metalness: 0.0}```
- **箱子内部:** 动画开始时随机从箱子顶部5的聚集开始按照每组10个生成鞭炮, 生成总计10组, 鞭炮自由落体到箱子内部
- **箱子位置:** 放置在平面中心偏后的位置
**爆炸与连锁反应模拟:**
1. **触发机制:**
- 页面底部提供"开始燃放"按钮触发动画
- 一个已燃烧的鞭炮从屏幕上方以抛物线轨迹落入箱子中
2. **引线燃烧效果:**
- **燃烧动画:** 引线在2秒内从顶端向下逐渐缩短,燃烧部分显示橙红色发光效果
3. **爆炸效果:**
- **瞬间替换:** 鞭炮爆炸瞬间消失,替换为大量彩色纸屑碎片
- **纸屑系统:** 生成50-80个小的彩色方形/矩形碎片,颜色为红色
- **爆炸冲击波:** 产生球形扩散的透明冲击波效果,影响周围鞭炮
- **碎片物理:** 纸屑具有初始向外的速度,受重力影响,有随机旋转动画
4. **冲击力与弹射:**
- **影响范围:** 爆炸中心半径2-3单位内的鞭炮受到冲击
- **弹射动画:** 被冲击的鞭炮以随机方向和力度弹开1-5单位距离
- **旋转效果:** 弹射的鞭炮具有随机的翻滚旋转动画
- **碰撞检测:** 弹射的鞭炮与箱壁、地面产生反弹效果
5. **火光传播与连锁反应:**
- **火光范围:** 每次爆炸产生半径3单位的火光球形区域,持续0.5-1秒
- **引燃机制:** 火光范围内未爆炸鞭炮的引线自动点燃,开始1秒燃烧倒计时
- **传播延迟:** 不同鞭炮的引燃有0.1-0.3秒的随机延迟,避免同时爆炸
- **连锁扩散:** 形成真实的多米诺骨牌式连锁反应
6. **环境交互效果:**
- **地面冲击:** 落地的鞭炮和碎片在地面产生小的冲击反弹
- **碎片堆积:** 纸屑碎片最终散落在地面和箱子周围,形成堆积效果
**高级视觉效果:**
1. **粒子系统增强:**
- **火花粒子:** 燃烧引线和爆炸时产生明亮的火花,有拖尾效果
- **烟雾效果:** 爆炸后产生灰白色烟雾粒子,缓慢上升并逐渐消散
- **光晕效果:** 爆炸瞬间产生明亮的光晕,照亮周围区域
2. **动态光照:**
- **爆炸闪光:** 每次爆炸时创建瞬间的点光源,模拟爆炸闪光
- **引线火光:** 燃烧的引线产生小的动态点光源
- **颜色温度:** 光源颜色从橙红色到亮白色变化
**光照与渲染设置:**
1. **光源配置:**
- **主光源:** 45度角的定向光```DirectionalLight```,强度1.2,能投射阴影
- **环境光:** 强度0.4的环境光,确保场景无纯黑区域
- **动态光源:** 爆炸和燃烧产生的临时点光源
2. **阴影系统:**
- 启用渲染器阴影贴图```renderer.shadowMap.enabled = true```
- 所有鞭炮、箱子能投射阴影```castShadow = true```
- 地面接收阴影```receiveShadow = true```
- 动态阴影更新以体现运动物体
3. **后期效果:**
- 爆炸时启用临时的屏幕闪白效果
- 可选择性添加轻微的镜头震动效果
**摄像机与控制:**
- 摄像机从斜45度角俯视整个场景,距离箱子约15单位
- 可鼠标控制
- 确保能完整观察到连锁反应的全过程和碎片散落效果
**代码结构要求:**
- 创建独立的```Firecracker```类管理单个鞭炮状态
- 创建```ExplosionSystem```类管理爆炸效果和粒子
- 创建```ChainReactionManager```类控制连锁反应逻辑
- 所有物理计算使用简化但真实的运动方程
- 代码中添加详细注释,特别是爆炸传播和物理模拟部分
- 性能优化:合理控制粒子数量
**交互控制:**
- 提供"重置场景"按钮重新开始演示
- 可选择添加"单个引爆"模式,点击特定鞭炮进行局部引爆测试
- 显示当前未爆炸鞭炮数量和已发生爆炸次数的统计信息English translation (English summary translation by BranoLabs (CC BY-NC-SA 4.0). The original gives exact materials and numbers; use it for comparable results.)
In a single HTML file with three.js, build a realistic 3D chain reaction in a box of firecrackers. A grey 1000×1000 ground plane receives shadows. Each firecracker is a red cylinder (height 1, diameter 0.2) with clay caps and a teal fuse, with collision volumes. A transparent 10×10×8 glass box (open top, solid sides) gets 10 groups of 10 firecrackers dropped in at the start. A 'start' button throws a lit firecracker in on a parabola. Fuses burn down over 2 s; an exploding firecracker is replaced by 50–80 red paper fragments with gravity and spin, plus a spherical shock wave that knocks firecrackers within 2–3 units 1–5 units away, tumbling and bouncing off the walls and ground. Each blast creates a fire sphere of radius 3 for 0.5–1 s that ignites fuses inside it after a random 0.1–0.3 s delay, followed by a 1 s fuse countdown, giving a domino-like chain. Add sparks with trails, rising smoke, flash point lights, a 45° directional light with shadows, ambient light at 0.4, a brief white flash and optional camera shake, a mouse-controlled camera at 45° about 15 units away, Firecracker, ExplosionSystem and ChainReactionManager classes, a reset button, an optional click-to-detonate mode, and counters for remaining firecrackers and explosions.
How to grade it
Checklist from the prompt: 100 firecrackers fall into the box and come to rest without overlapping; the start button throws a lit one in on a parabola; the fuse visibly shortens over 2 s; an explosion swaps the model for 50–80 fragments; nearby firecrackers are knocked away and tumble; ignition spreads with random delays (not one simultaneous blast); lights, shadows, smoke and sparks are present; the three named classes exist; reset works; counters are correct; the frame rate stays usable.
Scorecard tick what the model got right: 0/11
Runs in your browser; nothing is saved or sent.
Where models usually fail
Everything explodes at once; firecrackers fall through the box floor; particles never cleaned up, so FPS collapses; the named classes missing; the given materials ignored.
Running it
KCORES runs each model 3 times, keeps the best run and scores it visually at 2K full screen. Temperature 0 makes your own runs comparable.
Source
- Author
- karminski-牙医
- From
- KCORES prompt collection (gist)
- Exact file or post
- https://gist.github.com/karminski/d71b4c83b761538002593dec0014a21a/60dd0d73ec50ef4e027c17b5c3efd282ffac6c18
- Licence
- CC BY-NC-SA 4.0
- How we use it
- Full text (licence allows reuse)
Testing a local model? Check first whether it fits your hardware with Can I run this LLM?