「空き時間グリッド」は Pro に含まれます。解除するとプレビューが表示されます。
「反射の法則」は Pro に含まれます。解除するとプレビューが表示されます。
仕組み
反射の法則を示す教科書風の図です。アクセント色の光源が部屋に淡い扇形の光線を出し、平面鏡に届いた光線は反射します(破線)。光源から鏡の中心へ向かう光線は太く描き、鏡の位置に法線(破線)と二つの弧、入射光線と法線の間の θᵢ、法線と反射光線の間の θᵣ を描きます。反射光線は届いた壁まで伸びます。天井の右側に三つのゾーンがあり、目標ゾーンはアクセント色で縁取られ、光線が入ると緑に変わります。鏡の中心をドラッグすると移動し、端をドラッグすると回転し、空いた所を押すとそこへ置きます。矢印キーと傾きスライダーでも操作できます。図の下の行に光線の届く場所と θᵢ = θᵣ の値を示します。
向いている場面
- 反射の法則を教えるときに、鏡をどう置いても法線から測った二つの角が等しいことを確かめてもらいます。
- 光をセンサーや窓へ届けるような小さな狙いの課題を出し、当てずっぽうではなく角度の考え方で答えを出してもらいます。
向かない場面
- 曲面鏡、屈折、複数回の反射には向きません。この図は平面鏡一枚で、一回の反射だけを追います。
使い方
import React, { useState } from 'react'
import { ShowcaseBouncePanel } from './ShowcaseBouncePanel.jsx'
export function ReflectionLesson() {
const [target, setTarget] = useState('B')
return (
<ShowcaseBouncePanel
target={target}
onTargetChange={setTarget}
defaultMirror={{ x: 46, y: 85, tilt: 0 }}
onMirrorChange={(mirror, { hit }) => hit && console.log('On target', mirror)}
labels={{ title: 'Bounce the light into the target' }}
/>
)
}プロパティ
| プロパティ | 型 | 既定値 | 説明 |
|---|---|---|---|
mirror | { x: number, y: number, tilt: number } | — | 鏡を外部から指定します。中心 x・y は部屋の幅と高さに対する百分率(y は下向き)、tilt は −90〜90 の整数度で右端が高いと正です。鏡は部屋の中に収まり、光源から離れた位置に保たれます。 |
defaultMirror | { x: number, y: number, tilt: number } | { x: 46, y: 85, tilt: 0 } | 内部状態の初期の鏡です。どちらの使い方でもリセットはこの状態に戻ります。 |
onMirrorChange | (mirror, details) => void | — | 新しい鏡と { reason('press'、'drag'、'tap'、'key'、'cancel'、'reset')、incidence(入射角、度)、zone('A'、'B'、'C'、null)、hit(目標ゾーンなら true)} を受け取ります。 |
target | 'A' | 'B' | 'C' | — | 天井にある目標ゾーンを外部から指定します。 |
defaultTarget | 'A' | 'B' | 'C' | 'B' | 内部状態の最初の目標ゾーンです。 |
onTargetChange | (zone) => void | — | 目標ボタンを押したときに呼ばれます。目標を選んでも鏡は動きません。 |
labels | object | — | 組み込みの文言を置き換えます:title、formula、lamp、incidence、reflection、angles('{angle}')、mirror、movable、mirrorText('{x}'、'{y}')、help、tilt、tiltText('{tilt}'、'{angle}')、target、zoneNames(三つ)、hit('{zone}')、lands('{zone}')、miss、reset。 |
locale | string | 'en' | 数値の表示に使う言語タグです。 |
className | string | — | カードに追加するクラス名です。幅の指定などに使います(既定は 30rem、コンテナより広くなりません)。 |
アクセシビリティ
- The mirror's centre is a focusable movable button: the arrow keys move it, Shift with an arrow moves it four times as far. Its name gives the position.
- The tilt is a slider: arrows turn the mirror by one degree, Shift with an arrow or Page Up and Page Down by ten, Home and End go to −90° and +90°. Its value text reads the tilt and the angle of incidence.
- Where the ray lands is a polite live region, read when it changes. The target buttons are toggle buttons; Reset is a button marked unavailable while nothing has changed.
- Dragging uses pointer capture. A finger on the mirror's centre or an end drags at once; on empty space a finger changes nothing until it moves or lifts, so a vertical scroll is not caught, and a cancelled gesture restores the mirror it started from.
- Colour is not the only key: a hit also shows a check mark and the words of the status.
モーション
キー操作、タップ、リセットの後は、鏡と光線が --ds-duration-base で新しい位置へなめらかに移り、近い向きに回ります。ドラッグ中はポインターにそのまま追従します。視差効果を減らす設定では、すべての変化がすぐに反映されます。
プロジェクトに追加
Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。
ShowcaseBouncePanel.jsxshowcase-bounce-panel.csstokens.cssREADME.md
2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。
同じカテゴリ
フォーム入力「図形のブール演算」は Pro に含まれます。解除するとプレビューが表示されます。
「カスケード選択」は Pro に含まれます。解除するとプレビューが表示されます。







