mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-26 07:30:51 +01:00
Add rotate & state click on room previewer
This commit is contained in:
parent
ff46a89e79
commit
d0145cc0ed
@ -1,5 +1,5 @@
|
|||||||
import { ColorConverter, IRoomRenderingCanvas, RoomPreviewer, TextureUtils } from '@nitrots/nitro-renderer';
|
import { ColorConverter, IRoomRenderingCanvas, RoomPreviewer, TextureUtils } from '@nitrots/nitro-renderer';
|
||||||
import { FC, useCallback, useEffect, useRef, useState } from 'react';
|
import { FC, MouseEvent, useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { GetNitroInstance } from '../../api';
|
import { GetNitroInstance } from '../../api';
|
||||||
|
|
||||||
export interface LayoutRoomPreviewerViewProps
|
export interface LayoutRoomPreviewerViewProps
|
||||||
@ -14,6 +14,20 @@ export const LayoutRoomPreviewerView: FC<LayoutRoomPreviewerViewProps> = props =
|
|||||||
const [ renderingCanvas, setRenderingCanvas ] = useState<IRoomRenderingCanvas>(null);
|
const [ renderingCanvas, setRenderingCanvas ] = useState<IRoomRenderingCanvas>(null);
|
||||||
const elementRef = useRef<HTMLDivElement>();
|
const elementRef = useRef<HTMLDivElement>();
|
||||||
|
|
||||||
|
const onClick = (event: MouseEvent<HTMLDivElement>) =>
|
||||||
|
{
|
||||||
|
if(!roomPreviewer) return;
|
||||||
|
|
||||||
|
if(event.shiftKey)
|
||||||
|
{
|
||||||
|
roomPreviewer.changeRoomObjectDirection();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
roomPreviewer.changeRoomObjectState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const update = useCallback((time: number) =>
|
const update = useCallback((time: number) =>
|
||||||
{
|
{
|
||||||
if(!roomPreviewer || !renderingCanvas || !elementRef.current) return;
|
if(!roomPreviewer || !renderingCanvas || !elementRef.current) return;
|
||||||
@ -83,7 +97,7 @@ export const LayoutRoomPreviewerView: FC<LayoutRoomPreviewerViewProps> = props =
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="room-preview-container">
|
<div className="room-preview-container">
|
||||||
<div ref={ elementRef } className="room-preview-image" style={ { height } } />
|
<div ref={ elementRef } className="room-preview-image" style={ { height } } onClick={ onClick } />
|
||||||
{ props.children }
|
{ props.children }
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user