aboutsummaryrefslogtreecommitdiffhomepage
path: root/public/bluebey-studio/src/clip.js
diff options
context:
space:
mode:
authorYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-10-03 15:44:38 +0900
committerYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-10-03 15:44:38 +0900
commitfbaf2cc671fed23b555e218499301af0f50327b0 (patch)
treedbdbf5bca92004085feebec920019800472672e5 /public/bluebey-studio/src/clip.js
parent4cf9c37ecd568dab470b5714bff4ff9f860a5377 (diff)
public/bluebey-studio: 移動範囲と影・壁の追従、看板の文字
移動スライダーの範囲を広げ、キーライトと影カメラがぶるべーに追従するようにした(遠くへ動かしても影が切れない)。地面も広げた。 足もとの丸い影は既定で非表示にし、「足もとの丸い影」で切り替えられるようにした。原点に取り残されないよう、ぶるべーに追従させる。 見えない壁は体の向き(master のY回転と見る先の体向き)にも追従するようにした。 「舞台」をやめ、「小物」「擬音」「見えない壁」をそれぞれ独立したメニューにした。看板に文字を書けるようにした(複数行可)。
Diffstat (limited to 'public/bluebey-studio/src/clip.js')
-rw-r--r--public/bluebey-studio/src/clip.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/public/bluebey-studio/src/clip.js b/public/bluebey-studio/src/clip.js
index b5b03f4..4fdcfd9 100644
--- a/public/bluebey-studio/src/clip.js
+++ b/public/bluebey-studio/src/clip.js
@@ -138,16 +138,22 @@ export function createClipper({ scene, renderer, model }) {
* @param {{x?:number,y?:number,z?:number}} [offset] the character's own
* translation. A wall's position is stored *relative to the character*, so
* adding this makes the walls travel with the body when it is moved.
+ * @param {number} [yaw] the character's own turn about Y, in radians. The stored
+ * position is rotated by it (and added to the wall's own `yaw`), so a wall
+ * stays glued to the body when the character is turned.
*
* The guide is drawn only when `wall.guide` is on, which is also when the wall
* can be grabbed in the viewport. Off, the wall is invisible: the cut still
* applies, so you can see the character half-hidden with nothing in the way.
*/
- function apply(walls, offset) {
+ function apply(walls, offset, yaw = 0) {
const list = Array.isArray(walls) ? walls : [walls];
const ox = offset?.x ?? 0;
const oy = offset?.y ?? 0;
const oz = offset?.z ?? 0;
+ const cos = Math.cos(yaw);
+ const sin = Math.sin(yaw);
+ const yawDeg = (yaw * 180) / Math.PI;
slots.forEach((slot, index) => {
const wall = list[index];
if (!wall || wall.on !== true) {
@@ -155,10 +161,14 @@ export function createClipper({ scene, renderer, model }) {
slot.guide.visible = false;
return;
}
- const x = (wall.x ?? 0) + ox;
+ // The stored position is relative to the character, so it turns with the
+ // body: rotate (x, z) about Y by the character's yaw, then add the offset.
+ const lx = wall.x ?? 0;
+ const lz = wall.z ?? 0;
+ const x = cos * lx + sin * lz + ox;
const y = (wall.y ?? 0) + oy;
- const z = (wall.z ?? 0) + oz;
- const { normal } = wallPlane({ yaw: wall.yaw, tilt: wall.tilt, x, y, z });
+ const z = -sin * lx + cos * lz + oz;
+ const { normal } = wallPlane({ yaw: (wall.yaw ?? 0) + yawDeg, tilt: wall.tilt, x, y, z });
slot.normal.set(normal[0], normal[1], normal[2]);
const span = guideSpan * Math.max(0.05, wall.size ?? 1);
// The wall and its guide are the same rectangle, turned to face along the