Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/src/features/room/draggableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface DraggableItemProps {
onLockChange?: (isLocked: boolean) => void;
roomRef: React.RefObject<THREE.Group>;
placedItemsRef?: React.RefObject<THREE.Group>;
tableRef: React.RefObject<THREE.Group>;
}

// 回転のステップ(ラジアン)
Expand All @@ -31,6 +32,7 @@ export default function DraggableItem({
onLockChange,
roomRef,
placedItemsRef,
tableRef,
}: DraggableItemProps) {
const { camera, pointer, gl } = useThree();
const rigidBodyRef = useRef<RapierRigidBody>(null);
Expand Down Expand Up @@ -98,6 +100,7 @@ export default function DraggableItem({
const targets: THREE.Object3D[] = [];
if (roomRef.current) targets.push(roomRef.current);
if (placedItemsRef?.current) targets.push(placedItemsRef.current);
if (tableRef.current) targets.push(tableRef.current);

const intersects = raycaster.current.intersectObjects(targets, true);

Expand Down
3 changes: 3 additions & 0 deletions frontend/src/features/room/draggableSnowdome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface DraggableSnowdomeProps {
onLockChange?: (isLocked: boolean) => void;
roomRef: React.RefObject<THREE.Group>;
placedItemsRef?: React.RefObject<THREE.Group>;
tableRef: React.RefObject<THREE.Group>;
}

// 回転のステップ(ラジアン)
Expand All @@ -32,6 +33,7 @@ export default function DraggableSnowdome({
onLockChange,
roomRef,
placedItemsRef,
tableRef,
}: DraggableSnowdomeProps) {
const { camera, pointer, gl } = useThree();
const rigidBodyRef = useRef<RapierRigidBody>(null);
Expand Down Expand Up @@ -100,6 +102,7 @@ export default function DraggableSnowdome({
const targets: THREE.Object3D[] = [];
if (roomRef.current) targets.push(roomRef.current);
if (placedItemsRef?.current) targets.push(placedItemsRef.current);
if (tableRef.current) targets.push(tableRef.current);

const intersects = raycaster.current.intersectObjects(targets, true);

Expand Down
3 changes: 3 additions & 0 deletions frontend/src/features/room/itemPlacementMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export function PlacementDraggableItem({
onLockChange,
roomRef,
placedItemsRef,
tableRef,
}: {
calendarItem: CalendarItemWithItem;
onPositionChange: (
Expand All @@ -90,6 +91,7 @@ export function PlacementDraggableItem({
onLockChange?: (isLocked: boolean) => void;
roomRef: React.RefObject<THREE.Group>;
placedItemsRef?: React.RefObject<THREE.Group>;
tableRef: React.RefObject<THREE.Group>;
}) {
return (
<DraggableItem
Expand All @@ -101,6 +103,7 @@ export function PlacementDraggableItem({
setIsPlacementValid={setIsPlacementValid}
initialRotation={initialRotation}
onLockChange={onLockChange}
tableRef={tableRef}
/>
);
}
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/routes/$roomId/index.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function RouteComponent() {
} = useCalendarFocus();
const roomRef = useRef<THREE.Group>(null);
const placedItemsRef = useRef<THREE.Group>(null);
const tableRef = useRef<THREE.Group>(null);
// アイテム取得フロー
const {
phase,
Expand Down Expand Up @@ -358,9 +359,15 @@ function RouteComponent() {
<group position={[0, 0, 1]}>
<RigidBody
lockRotations
colliders="trimesh"
type={isAnyPlacementMode ? "kinematicPosition" : "dynamic"}
>
<Gltf src={tableUrl} scale={6} position={[0, 0, 0]} />
<Gltf
src={tableUrl}
ref={tableRef}
scale={6}
position={[0, 0, 0]}
/>
</RigidBody>
<RigidBody
lockRotations
Expand Down Expand Up @@ -406,6 +413,7 @@ function RouteComponent() {
placedItemsRef={
placedItemsRef as React.RefObject<THREE.Group>
}
tableRef={tableRef as React.RefObject<THREE.Group>}
calendarItem={targetCalendarItem}
onPositionChange={handlePositionChange}
isPlacementValid={isPlacementValid}
Expand All @@ -421,6 +429,7 @@ function RouteComponent() {
roomRef && (
<DraggableSnowdome
snowdomeParts={snowdomePartsForPlacement}
tableRef={tableRef as React.RefObject<THREE.Group>}
onPositionChange={handlePositionChange}
isPlacementValid={isPlacementValid}
setIsPlacementValid={setIsPlacementValid}
Expand Down