ここは Interior Wall Layer の“可動要素”として最も面白いところ。
片開き・引き戸は Geometry Layer・Interaction Layer・UI Layerまで影響するので、
OS として破綻しないように 構造 → 形状 → 動作 → Roblox 実装の順で整理するね。
🟦 Interior Door Layer:OS 的に扱うべき 2 種類
室内ドアは OS 的に次の 2 種類に分類できる:
| 種類 | 特徴 | 必要データ | Roblox 実装難度 |
|---|---|---|---|
| 片開き(Swing Door) | 回転して開く | 開く方向(left/right)、開く側(push/pull) | ★★★ |
| 引き戸(Sliding Door) | 横にスライド | スライド方向、スライド量 | ★★ |
どちらも Structure Layer の opening に追加情報を持たせるだけで成立する。
🟩 Structure Layer に追加するべき情報
片開きドア(Swing)
{
"id": "d1",
"type": "swing",
"roomA": "living",
"roomB": "hall",
"offset": 1.2,
"width": 0.9,
"hinge": "left", // left / right
"direction": "push" // push / pull
}
引き戸(Sliding)
{
"id": "d2",
"type": "sliding",
"roomA": "kitchen",
"roomB": "hall",
"offset": 0.8,
"width": 1.0,
"slide": "left" // left / right
}
これだけで Geometry Layer と Interaction Layer が自動生成できる。
🟧 Geometry Layer:Roblox での形状生成
① 片開きドア(Swing Door)
片開きドアは:
- ドア本体(DoorPart)
- ヒンジ(HingeConstraint)
- 壁の opening(CSG)
で構成される。
Roblox コード(片開きドア)
local function createSwingDoor(opening, wall, thickness)
local p1 = Vector3.new(opening.from[1], 0, opening.from[2])
local p2 = Vector3.new(opening.to[1], 0, opening.to[2])
local width = (p1 - p2).Magnitude
local height = 2.0
-- ドア本体
local door = Instance.new("Part")
door.Size = Vector3.new(width, height, 0.1)
door.Anchored = false
door.Name = "SwingDoor_" .. opening.id
door.Position = (p1 + p2)/2 + Vector3.new(0, height/2, 0)
door.Parent = workspace.InteriorDoors
-- ヒンジ位置
local hingePos = opening.hinge == "left" and p1 or p2
local hinge = Instance.new("Part")
hinge.Size = Vector3.new(0.1, 0.1, 0.1)
hinge.Position = hingePos + Vector3.new(0, height/2, 0)
hinge.Anchored = true
hinge.Transparency = 1
hinge.Parent = workspace.InteriorDoors
-- HingeConstraint
local hc = Instance.new("HingeConstraint")
hc.Attachment0 = Instance.new("Attachment", hinge)
hc.Attachment1 = Instance.new("Attachment", door)
hc.Parent = hinge
-- 開く方向
if opening.direction == "push" then
hc.LimitsEnabled = true
hc.LowerAngle = 0
hc.UpperAngle = 90
else
hc.LimitsEnabled = true
hc.LowerAngle = -90
hc.UpperAngle = 0
end
return door
end
② 引き戸(Sliding Door)
引き戸は:
- ドア本体(DoorPart)
- スライドレール(Attachment)
- LinearConstraint(スライド制御)
で構成される。
Roblox コード(引き戸)
local function createSlidingDoor(opening, wall, thickness)
local p1 = Vector3.new(opening.from[1], 0, opening.from[2])
local p2 = Vector3.new(opening.to[1], 0, opening.to[2])
local width = (p1 - p2).Magnitude
local height = 2.0
local door = Instance.new("Part")
door.Size = Vector3.new(width, height, 0.1)
door.Anchored = false
door.Name = "SlidingDoor_" .. opening.id
door.Position = (p1 + p2)/2 + Vector3.new(0, height/2, 0)
door.Parent = workspace.InteriorDoors
-- レール方向
local slideDir = (opening.slide == "left") and -1 or 1
local slideVector = (p2 - p1).Unit * slideDir * width
-- レール(固定)
local rail = Instance.new("Part")
rail.Size = Vector3.new(0.1, 0.1, 0.1)
rail.Position = door.Position
rail.Anchored = true
rail.Transparency = 1
rail.Parent = workspace.InteriorDoors
-- LinearConstraint
local lc = Instance.new("LinearConstraint")
lc.Attachment0 = Instance.new("Attachment", rail)
lc.Attachment1 = Instance.new("Attachment", door)
lc.LimitsEnabled = true
lc.LowerLimit = 0
lc.UpperLimit = width
lc.Parent = rail
return door
end
🟦 Interior Door Layer の OS 的ポイント
✔ Structure Layer に最小限の追加情報だけで成立
→ JSON が肥大化しない
→ 拡張性が高い
✔ Geometry Layer で形状が自動生成
→ 壁 opening と完全同期
→ 室内壁の CSG と矛盾しない
✔ Interaction Layer(開閉動作)まで自動生成
→ Swing:HingeConstraint
→ Sliding:LinearConstraint
✔ Roblox 側は Part ベースで軽量
→ CSG は opening のみ
→ ドア本体は物理オブジェクトとして自然に動く
🎯 Interior Door Layer の完成
これで住環境 OS の内部構造は:
- Interior Wall Layer
- Interior Door Layer(Swing / Sliding)
- Stair Layer
- Floor / Ceiling Layer
- Exterior Layer
- Roof Layer
が揃い、
内部構造の“可動要素”まで OS として完成した。
次はどれを進める?
- 引き戸の“壁内収納”バージョン(Pocket Door)
- 両開きドア(Double Swing)
- 自動ドア(Sliding Auto)
- ドアの UI(開閉インタラクション)
- Roblox Plugin 化(GUI でドアタイプ選択)
どのレイヤーでも続けられるよ。