Restore item controls and guard placement asset bounds
This commit is contained in:
@@ -607,7 +607,7 @@ const ViewerSceneContent = memo(function ViewerSceneContent({
|
||||
<ThumbnailGenerator onThumbnailCapture={onThumbnailCapture} />
|
||||
<PresetThumbnailGenerator />
|
||||
{!isFirstPersonMode && <SiteEdgeLabels />}
|
||||
{isFirstPersonMode && <InteractiveSystem />}
|
||||
<InteractiveSystem />
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { AssetInput } from '@pascal-app/core'
|
||||
import { sfxEmitter } from '../../../lib/sfx-bus'
|
||||
import useEditor from '../../../store/use-editor'
|
||||
import { useDraftNode } from './use-draft-node'
|
||||
import { usePlacementCoordinator } from './use-placement-coordinator'
|
||||
|
||||
export const ItemTool: React.FC = () => {
|
||||
const selectedItem = useEditor((state) => state.selectedItem)
|
||||
function ItemPlacementContent({ selectedItem }: { selectedItem: AssetInput }) {
|
||||
const draftNode = useDraftNode()
|
||||
|
||||
const cursor = usePlacementCoordinator({
|
||||
@@ -21,6 +21,12 @@ export const ItemTool: React.FC = () => {
|
||||
},
|
||||
})
|
||||
|
||||
if (!selectedItem) return null
|
||||
return <>{cursor}</>
|
||||
}
|
||||
|
||||
export const ItemTool: React.FC = () => {
|
||||
const selectedItem = useEditor((state) => state.selectedItem)
|
||||
|
||||
if (!selectedItem) return null
|
||||
return <ItemPlacementContent selectedItem={selectedItem} />
|
||||
}
|
||||
|
||||
@@ -116,10 +116,10 @@ function expandBoundsToGrid(
|
||||
|
||||
function getFallbackPreviewBounds(
|
||||
item: import('@pascal-app/core').ItemNode | null,
|
||||
asset: AssetInput,
|
||||
attachTo: AssetInput['attachTo'],
|
||||
asset: AssetInput | null | undefined,
|
||||
attachTo: AssetInput['attachTo'] | null | undefined,
|
||||
): PreviewBounds {
|
||||
const dims = item ? getScaledDimensions(item) : (asset.dimensions ?? DEFAULT_DIMENSIONS)
|
||||
const dims = item ? getScaledDimensions(item) : (asset?.dimensions ?? DEFAULT_DIMENSIONS)
|
||||
return {
|
||||
min: [-dims[0] / 2, 0, attachTo === 'wall-side' ? -dims[2] : -dims[2] / 2],
|
||||
max: [dims[0] / 2, dims[1], attachTo === 'wall-side' ? 0 : dims[2] / 2],
|
||||
@@ -1341,7 +1341,7 @@ export function usePlacementCoordinator(config: PlacementCoordinatorConfig): Rea
|
||||
const dims = getGridAlignedDimensions(rawDims, initialAttachTo, gridSnapStep)
|
||||
const wallSideZOffset = initialAttachTo === 'wall-side' ? -dims[2] / 2 : 0
|
||||
const initialDimensionBounds = expandBoundsToGrid(
|
||||
getFallbackPreviewBounds(initialDraft, config.asset!, initialAttachTo),
|
||||
getFallbackPreviewBounds(initialDraft, config.asset, initialAttachTo),
|
||||
initialAttachTo,
|
||||
gridSnapStep,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user