auto-git:
[unlink] playwright.config.js [unlink] src/app/App.js [unlink] src/app/editor-store.js [unlink] src/app/use-editor-store.js [unlink] src/assets/audio-assets.js [unlink] src/assets/gltf-model-import.js [unlink] src/assets/image-assets.js [unlink] src/assets/model-instance-labels.js [unlink] src/assets/model-instance-rendering.js [unlink] src/assets/model-instances.js [unlink] src/assets/project-asset-storage.js [unlink] src/assets/project-assets.js [unlink] src/commands/brush-command-helpers.js [unlink] src/commands/command-history.js [unlink] src/commands/command.js [unlink] src/commands/commit-transform-session-command.js [unlink] src/commands/create-box-brush-command.js [unlink] src/commands/delete-box-brush-command.js [unlink] src/commands/delete-entity-command.js [unlink] src/commands/delete-interaction-link-command.js [unlink] src/commands/delete-model-instance-command.js [unlink] src/commands/duplicate-selection-command.js [unlink] src/commands/import-audio-asset-command.js [unlink] src/commands/import-background-image-asset-command.js [unlink] src/commands/import-model-asset-command.js [unlink] src/commands/move-box-brush-command.js [unlink] src/commands/resize-box-brush-command.js [unlink] src/commands/rotate-box-brush-command.js [unlink] src/commands/set-box-brush-face-material-command.js [unlink] src/commands/set-box-brush-face-uv-state-command.js [unlink] src/commands/set-box-brush-name-command.js [unlink] src/commands/set-box-brush-transform-command.js [unlink] src/commands/set-box-brush-volume-settings-command.js [unlink] src/commands/set-entity-name-command.js [unlink] src/commands/set-model-instance-name-command.js [unlink] src/commands/set-player-start-command.js [unlink] src/commands/set-scene-name-command.js [unlink] src/commands/set-world-settings-command.js [unlink] src/commands/upsert-entity-command.js [unlink] src/commands/upsert-interaction-link-command.js [unlink] src/commands/upsert-model-instance-command.js [unlink] src/core/ids.js [unlink] src/core/selection.js [unlink] src/core/tool-mode.js [unlink] src/core/transform-session.js [unlink] src/core/vector.js [unlink] src/core/whitebox-selection-feedback.js [unlink] src/core/whitebox-selection-mode.js [unlink] src/document/brushes.js [unlink] src/document/migrate-scene-document.js [unlink] src/document/scene-document-validation.js [unlink] src/document/scene-document.js [unlink] src/document/world-settings.js [unlink] src/entities/entity-instances.js [unlink] src/entities/entity-labels.js [unlink] src/geometry/box-brush-components.js [unlink] src/geometry/box-brush-mesh.js [unlink] src/geometry/box-brush.js [unlink] src/geometry/box-face-uvs.js [unlink] src/geometry/grid-snapping.js [unlink] src/geometry/model-instance-collider-debug-mesh.js [unlink] src/geometry/model-instance-collider-generation.js [unlink] src/interactions/interaction-links.js [unlink] src/main.js [unlink] src/materials/starter-material-library.js [unlink] src/materials/starter-material-textures.js [unlink] src/rendering/advanced-rendering.js [unlink] src/rendering/fog-material.js [unlink] src/rendering/planar-reflection.js [unlink] src/rendering/water-material.js [unlink] src/runner-web/RunnerCanvas.js [unlink] src/runtime-three/first-person-navigation-controller.js [unlink] src/runtime-three/navigation-controller.js [unlink] src/runtime-three/orbit-visitor-navigation-controller.js [unlink] src/runtime-three/player-collision.js [unlink] src/runtime-three/rapier-collision-world.js [unlink] src/runtime-three/runtime-audio-system.js [unlink] src/runtime-three/runtime-host.js [unlink] src/runtime-three/runtime-interaction-system.js [unlink] src/runtime-three/runtime-scene-build.js [unlink] src/runtime-three/runtime-scene-validation.js [unlink] src/runtime-three/underwater-fog.js [unlink] src/serialization/local-draft-storage.js [unlink] src/serialization/scene-document-json.js [unlink] src/shared-ui/HierarchicalMenu.js [unlink] src/shared-ui/Panel.js [unlink] src/shared-ui/world-background-style.js [unlink] src/viewport-three/ViewportCanvas.js [unlink] src/viewport-three/ViewportPanel.js [unlink] src/viewport-three/viewport-entity-markers.js [unlink] src/viewport-three/viewport-focus.js [unlink] src/viewport-three/viewport-host.js [unlink] src/viewport-three/viewport-layout.js [unlink] src/viewport-three/viewport-transient-state.js [unlink] src/viewport-three/viewport-view-modes.js [unlink] vite.config.js [unlink] vitest.config.js
This commit is contained in:
@@ -1,130 +0,0 @@
|
||||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { getWhiteboxSelectionFeedbackLabel } from "../core/whitebox-selection-feedback";
|
||||
import { getWhiteboxSelectionModeLabel } from "../core/whitebox-selection-mode";
|
||||
import { createWorldBackgroundStyle } from "../shared-ui/world-background-style";
|
||||
import { getViewportPanelLabel } from "./viewport-layout";
|
||||
import { getViewportViewModeLabel } from "./viewport-view-modes";
|
||||
import { ViewportHost } from "./viewport-host";
|
||||
export function ViewportCanvas({ panelId, world, sceneDocument, projectAssets, loadedModelAssets, loadedImageAssets, whiteboxSelectionMode, whiteboxSnapEnabled, whiteboxSnapStep, selection, toolMode, toolPreview, transformSession, cameraState, viewMode, displayMode, layoutMode, isActivePanel, focusRequestId, focusSelection, onSelectionChange, onCommitCreation, onCameraStateChange, onToolPreviewChange, onTransformSessionChange, onTransformCommit, onTransformCancel }) {
|
||||
const containerRef = useRef(null);
|
||||
const hostRef = useRef(null);
|
||||
const shouldRenderPanel = layoutMode === "quad" || isActivePanel;
|
||||
const [viewportMessage, setViewportMessage] = useState(null);
|
||||
const [hoveredWhiteboxLabel, setHoveredWhiteboxLabel] = useState(null);
|
||||
useEffect(() => {
|
||||
const container = containerRef.current;
|
||||
if (container === null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const viewportHost = new ViewportHost();
|
||||
hostRef.current = viewportHost;
|
||||
viewportHost.setPanelId(panelId);
|
||||
viewportHost.setRenderEnabled(shouldRenderPanel);
|
||||
viewportHost.mount(container);
|
||||
setViewportMessage(null);
|
||||
return () => {
|
||||
viewportHost.dispose();
|
||||
hostRef.current = null;
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
const message = error instanceof Error ? error.message : "Viewport initialization failed.";
|
||||
setViewportMessage(`Viewport initialization failed: ${message}`);
|
||||
return;
|
||||
}
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setRenderEnabled(shouldRenderPanel);
|
||||
}, [shouldRenderPanel]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setPanelId(panelId);
|
||||
}, [panelId]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.updateWorld(world);
|
||||
}, [world]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.updateAssets(projectAssets, loadedModelAssets, loadedImageAssets);
|
||||
}, [projectAssets, loadedModelAssets, loadedImageAssets]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setWhiteboxSnapSettings(whiteboxSnapEnabled, whiteboxSnapStep);
|
||||
}, [whiteboxSnapEnabled, whiteboxSnapStep]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setWhiteboxSelectionMode(whiteboxSelectionMode);
|
||||
}, [whiteboxSelectionMode]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.updateDocument(sceneDocument, selection);
|
||||
}, [sceneDocument, selection]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setViewMode(viewMode);
|
||||
}, [viewMode]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setDisplayMode(displayMode);
|
||||
}, [displayMode]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setCameraState(cameraState);
|
||||
}, [cameraState]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setBrushSelectionChangeHandler(onSelectionChange);
|
||||
}, [onSelectionChange]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setWhiteboxHoverLabelChangeHandler(setHoveredWhiteboxLabel);
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setCameraStateChangeHandler(onCameraStateChange);
|
||||
}, [onCameraStateChange]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setCreationPreviewChangeHandler((nextToolPreview) => {
|
||||
onToolPreviewChange(nextToolPreview.kind === "create"
|
||||
? {
|
||||
...nextToolPreview,
|
||||
sourcePanelId: panelId
|
||||
}
|
||||
: nextToolPreview);
|
||||
});
|
||||
}, [onToolPreviewChange, panelId]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setCreationCommitHandler(onCommitCreation);
|
||||
}, [onCommitCreation]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setTransformSessionChangeHandler(onTransformSessionChange);
|
||||
}, [onTransformSessionChange]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setTransformCommitHandler(onTransformCommit);
|
||||
}, [onTransformCommit]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setTransformCancelHandler(onTransformCancel);
|
||||
}, [onTransformCancel]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setToolMode(toolMode);
|
||||
}, [toolMode]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setCreationPreview(toolMode === "create" && toolPreview.kind === "create" ? toolPreview : null);
|
||||
}, [toolMode, toolPreview]);
|
||||
useEffect(() => {
|
||||
hostRef.current?.setTransformSession(transformSession);
|
||||
}, [transformSession]);
|
||||
useEffect(() => {
|
||||
if (focusRequestId === 0) {
|
||||
return;
|
||||
}
|
||||
hostRef.current?.focusSelection(sceneDocument, focusSelection);
|
||||
}, [focusRequestId, focusSelection, sceneDocument]);
|
||||
const previewVisible = toolMode === "create" && toolPreview.kind === "create" && toolPreview.center !== null;
|
||||
const transformPreviewVisible = transformSession.kind === "active";
|
||||
const selectionModeVisible = toolMode === "select";
|
||||
const selectedWhiteboxLabel = selectionModeVisible ? getWhiteboxSelectionFeedbackLabel(sceneDocument, selection) : null;
|
||||
const showViewModeOverlay = layoutMode === "quad";
|
||||
const showOverlay = showViewModeOverlay || selectionModeVisible || previewVisible || transformPreviewVisible || selectedWhiteboxLabel !== null || hoveredWhiteboxLabel !== null;
|
||||
return (_jsxs("div", { ref: containerRef, className: `viewport-canvas viewport-canvas--${toolMode} viewport-canvas--${viewMode} viewport-canvas--${displayMode} viewport-canvas--${layoutMode}`, "data-testid": `viewport-canvas-${panelId}`, "data-active": isActivePanel ? "true" : "false", "aria-label": `${getViewportPanelLabel(panelId)} editor viewport`, style: displayMode !== "normal"
|
||||
? {
|
||||
backgroundColor: "#000000",
|
||||
backgroundImage: "none"
|
||||
}
|
||||
: createWorldBackgroundStyle(world.background, world.background.mode === "image" ? loadedImageAssets[world.background.assetId]?.sourceUrl ?? null : null), children: [!showOverlay ? null : (_jsxs("div", { className: "viewport-canvas__overlay", "data-testid": `viewport-overlay-${panelId}`, children: [!showViewModeOverlay ? null : (_jsxs("div", { className: "viewport-canvas__overlay-badges", children: [_jsx("div", { className: "viewport-canvas__overlay-badge viewport-canvas__overlay-badge--view", children: getViewportViewModeLabel(viewMode) }), !selectionModeVisible ? null : (_jsx("div", { className: "viewport-canvas__overlay-badge viewport-canvas__overlay-badge--selection", "data-testid": `viewport-selection-mode-${panelId}`, children: getWhiteboxSelectionModeLabel(whiteboxSelectionMode) }))] })), showViewModeOverlay || !selectionModeVisible ? null : (_jsx("div", { className: "viewport-canvas__overlay-badges", children: _jsx("div", { className: "viewport-canvas__overlay-badge viewport-canvas__overlay-badge--selection", "data-testid": `viewport-selection-mode-${panelId}`, children: getWhiteboxSelectionModeLabel(whiteboxSelectionMode) }) })), !previewVisible ? null : (_jsxs("div", { className: "viewport-canvas__overlay-preview", "data-testid": `viewport-snap-preview-${panelId}`, children: ["Preview: ", toolPreview.center.x, ", ", toolPreview.center.y, ", ", toolPreview.center.z] })), !transformPreviewVisible ? null : (_jsx("div", { className: "viewport-canvas__overlay-preview", "data-testid": `viewport-transform-preview-${panelId}`, children: transformSession.kind !== "active"
|
||||
? null
|
||||
: `${transformSession.operation}${transformSession.axisConstraint === null ? "" : ` · ${transformSession.axisConstraint.toUpperCase()}`}` })), selectedWhiteboxLabel === null ? null : (_jsxs("div", { className: "viewport-canvas__overlay-preview", "data-testid": `viewport-selected-whitebox-${panelId}`, children: ["Selected: ", selectedWhiteboxLabel] })), hoveredWhiteboxLabel === null ? null : (_jsxs("div", { className: "viewport-canvas__overlay-preview", "data-testid": `viewport-hovered-whitebox-${panelId}`, children: ["Hover: ", hoveredWhiteboxLabel] }))] })), viewportMessage === null ? null : (_jsxs("div", { className: "viewport-canvas__fallback", role: "status", children: [_jsx("div", { className: "viewport-canvas__fallback-title", children: "Viewport Unavailable" }), _jsx("div", { children: viewportMessage }), toolMode !== "create" || toolPreview.kind !== "create" ? null : (_jsx("button", { className: "toolbar__button toolbar__button--accent", type: "button", "data-testid": `viewport-fallback-create-${panelId}`, onClick: () => {
|
||||
onCommitCreation(toolPreview);
|
||||
}, children: "Commit Creation Preview" }))] }))] }));
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||
import { ViewportCanvas } from "./ViewportCanvas";
|
||||
import {
|
||||
VIEWPORT_LAYOUT_MODES,
|
||||
getViewportDisplayModeLabel,
|
||||
getViewportLayoutModeLabel,
|
||||
getViewportPanelLabel
|
||||
} from "./viewport-layout";
|
||||
import { VIEWPORT_VIEW_MODES, getViewportViewModeLabel } from "./viewport-view-modes";
|
||||
import {
|
||||
WHITEBOX_SELECTION_MODES,
|
||||
getWhiteboxSelectionModeLabel
|
||||
} from "../core/whitebox-selection-mode";
|
||||
const VIEWPORT_DISPLAY_MODES = ["normal", "authoring", "wireframe"];
|
||||
function getPanelScopedTestId(panelId, name) {
|
||||
return `viewport-panel-${panelId}-${name}`;
|
||||
}
|
||||
function getSharedControlTestId(panelId, isActive, sharedId, fallbackId = sharedId) {
|
||||
return isActive ? sharedId : getPanelScopedTestId(panelId, fallbackId);
|
||||
}
|
||||
export function ViewportPanel({ panelId, panelState, layoutMode, isActive, className, style, world, sceneDocument, projectAssets, loadedModelAssets, loadedImageAssets, whiteboxSelectionMode, whiteboxSnapEnabled, whiteboxSnapStepDraft, whiteboxSnapStep, viewportGridVisible, selection, toolMode, toolPreview, transformSession, canTranslateSelectedTarget, canRotateSelectedTarget, canScaleSelectedTarget, cameraState, focusRequestId, focusSelection, isAddMenuOpen, onActivatePanel, onOpenAddMenu, onSetViewportLayoutMode, onSetPanelViewMode, onSetPanelDisplayMode, onCommitCreation, onCameraStateChange, onToolPreviewChange, onBeginTransformOperation, onWhiteboxSelectionModeChange, onViewportGridToggle, onWhiteboxSnapToggle, onWhiteboxSnapStepDraftChange, onWhiteboxSnapStepBlur, onTransformSessionChange, onTransformCommit, onTransformCancel, onSelectionChange }) {
|
||||
const shouldShow = layoutMode === "quad" || isActive;
|
||||
const panelStyle = shouldShow ? style : { ...(style ?? {}), display: "none" };
|
||||
const transformButtonsDisabled = toolMode !== "select";
|
||||
return (_jsxs("section", { className: `viewport-panel ${layoutMode === "single" ? "viewport-panel--single" : "viewport-panel--quad"} ${className ?? ""}`.trim(), "data-testid": `viewport-panel-${panelId}`, "data-active": isActive ? "true" : "false", "data-viewport-panel-id": panelId, "aria-hidden": shouldShow ? undefined : true, "aria-label": `${getViewportPanelLabel(panelId)} viewport panel`, style: panelStyle, onPointerDownCapture: () => onActivatePanel(panelId), onFocusCapture: () => onActivatePanel(panelId), children: [_jsx(ViewportCanvas, { panelId: panelId, world: world, sceneDocument: sceneDocument, projectAssets: projectAssets, loadedModelAssets: loadedModelAssets, loadedImageAssets: loadedImageAssets, whiteboxSelectionMode: whiteboxSelectionMode, whiteboxSnapEnabled: whiteboxSnapEnabled, whiteboxSnapStep: whiteboxSnapStep, viewportGridVisible: viewportGridVisible, selection: selection, toolMode: toolMode, toolPreview: toolPreview, transformSession: transformSession, cameraState: cameraState, viewMode: panelState.viewMode, displayMode: panelState.displayMode, layoutMode: layoutMode, isActivePanel: isActive, focusRequestId: focusRequestId, focusSelection: focusSelection, onSelectionChange: onSelectionChange, onCommitCreation: onCommitCreation, onCameraStateChange: onCameraStateChange, onToolPreviewChange: onToolPreviewChange, onTransformSessionChange: onTransformSessionChange, onTransformCommit: onTransformCommit, onTransformCancel: onTransformCancel }), _jsx("div", { className: "viewport-panel__overlay viewport-panel__overlay--top", children: _jsxs("div", { className: "viewport-panel__overlay-scroll", children: [_jsx("button", { className: "viewport-panel__button viewport-panel__button--accent", type: "button", "data-testid": getSharedControlTestId(panelId, isActive, "outliner-add-button", "add-button"), "aria-haspopup": "menu", "aria-expanded": isAddMenuOpen, onClick: onOpenAddMenu, children: "Add" }), _jsx("div", { className: "viewport-panel__control-group", role: "group", "aria-label": "Viewport layout mode", children: VIEWPORT_LAYOUT_MODES.map((mode) => (_jsx("button", { className: `viewport-panel__button ${layoutMode === mode ? "viewport-panel__button--active" : ""}`, type: "button", "data-testid": getSharedControlTestId(panelId, isActive, `viewport-layout-${mode}`, `layout-${mode}`), "aria-pressed": layoutMode === mode, onClick: () => onSetViewportLayoutMode(mode), children: getViewportLayoutModeLabel(mode) }, mode))) }), _jsx("div", { className: "viewport-panel__control-group", role: "group", "aria-label": `${getViewportPanelLabel(panelId)} view mode`, children: VIEWPORT_VIEW_MODES.map((viewMode) => (_jsx("button", { className: `viewport-panel__button ${panelState.viewMode === viewMode ? "viewport-panel__button--active" : ""}`, type: "button", "data-testid": `viewport-panel-${panelId}-view-${viewMode}`, "aria-pressed": panelState.viewMode === viewMode, onClick: () => onSetPanelViewMode(panelId, viewMode), children: getViewportViewModeLabel(viewMode) }, viewMode))) }), _jsx("div", { className: "viewport-panel__control-group", role: "group", "aria-label": `${getViewportPanelLabel(panelId)} display mode`, children: VIEWPORT_DISPLAY_MODES.map((displayMode) => (_jsx("button", { className: `viewport-panel__button ${panelState.displayMode === displayMode ? "viewport-panel__button--active" : ""}`, type: "button", "data-testid": `viewport-panel-${panelId}-display-${displayMode}`, "aria-pressed": panelState.displayMode === displayMode, onClick: () => onSetPanelDisplayMode(panelId, displayMode), children: getViewportDisplayModeLabel(displayMode) }, displayMode))) }), _jsxs("div", { className: "viewport-panel__control-group", role: "group", "aria-label": "Whitebox snap settings", children: [_jsx("button", { className: `viewport-panel__button ${viewportGridVisible ? "viewport-panel__button--active" : ""}`, type: "button", "data-testid": getSharedControlTestId(panelId, isActive, "viewport-grid-toggle"), "aria-pressed": viewportGridVisible, onClick: onViewportGridToggle, children: viewportGridVisible ? "Grid On" : "Grid Off" }), _jsx("button", { className: `viewport-panel__button ${whiteboxSnapEnabled ? "viewport-panel__button--active" : ""}`, type: "button", "data-testid": getSharedControlTestId(panelId, isActive, "whitebox-snap-toggle"), "aria-pressed": whiteboxSnapEnabled, onClick: onWhiteboxSnapToggle, children: whiteboxSnapEnabled ? "Snap On" : "Snap Off" }), _jsxs("label", { className: "viewport-panel__inline-field", children: [_jsx("span", { className: "viewport-panel__inline-label", children: "Step" }), _jsx("input", { "data-testid": getSharedControlTestId(panelId, isActive, "whitebox-snap-step"), className: "text-input viewport-panel__inline-input", type: "number", min: "0.01", step: "0.1", value: whiteboxSnapStepDraft, onChange: (event) => onWhiteboxSnapStepDraftChange(event.currentTarget.value), onBlur: onWhiteboxSnapStepBlur, onKeyDown: (event) => {
|
||||
if (event.key === "Enter") {
|
||||
onWhiteboxSnapStepBlur();
|
||||
}
|
||||
} })] })] })] }) }), _jsxs("div", { className: "viewport-panel__overlay viewport-panel__overlay--left", children: [_jsxs("div", { className: "viewport-panel__control-group viewport-panel__control-group--stack", role: "group", "aria-label": "Transform operations", children: [_jsx("button", { className: `viewport-panel__button ${transformSession.kind === "active" && transformSession.operation === "translate" ? "viewport-panel__button--active" : ""}`, type: "button", "data-testid": getSharedControlTestId(panelId, isActive, "transform-translate-button"), "aria-pressed": transformSession.kind === "active" && transformSession.operation === "translate", disabled: transformButtonsDisabled || !canTranslateSelectedTarget, onClick: () => onBeginTransformOperation("translate"), children: "Move" }), _jsx("button", { className: `viewport-panel__button ${transformSession.kind === "active" && transformSession.operation === "rotate" ? "viewport-panel__button--active" : ""}`, type: "button", "data-testid": getSharedControlTestId(panelId, isActive, "transform-rotate-button"), "aria-pressed": transformSession.kind === "active" && transformSession.operation === "rotate", disabled: transformButtonsDisabled || !canRotateSelectedTarget, onClick: () => onBeginTransformOperation("rotate"), children: "Rotate" }), _jsx("button", { className: `viewport-panel__button ${transformSession.kind === "active" && transformSession.operation === "scale" ? "viewport-panel__button--active" : ""}`, type: "button", "data-testid": getSharedControlTestId(panelId, isActive, "transform-scale-button"), "aria-pressed": transformSession.kind === "active" && transformSession.operation === "scale", disabled: transformButtonsDisabled || !canScaleSelectedTarget, onClick: () => onBeginTransformOperation("scale"), children: "Scale" })] }), _jsx("div", { className: "viewport-panel__control-group viewport-panel__control-group--stack", role: "group", "aria-label": "Whitebox selection mode", children: WHITEBOX_SELECTION_MODES.map((mode) => (_jsx("button", { className: `viewport-panel__button ${whiteboxSelectionMode === mode ? "viewport-panel__button--active" : ""}`, type: "button", "data-testid": getSharedControlTestId(panelId, isActive, `whitebox-selection-mode-${mode}`), "aria-pressed": whiteboxSelectionMode === mode, onClick: () => onWhiteboxSelectionModeChange(mode), children: getWhiteboxSelectionModeLabel(mode) }, mode))) })] })] }));
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import { BoxGeometry, CylinderGeometry, Mesh, MeshStandardMaterial, TorusGeometry } from "three";
|
||||
const SOUND_EMITTER_CABINET_SIZE = {
|
||||
x: 0.38,
|
||||
y: 0.5,
|
||||
z: 0.18
|
||||
};
|
||||
const SOUND_EMITTER_FRONT_OFFSET = 0.1;
|
||||
const SOUND_EMITTER_TWEETER_RADIUS = 0.045;
|
||||
const SOUND_EMITTER_TWEETER_Y = 0.15;
|
||||
const SOUND_EMITTER_WOOFER_RADIUS = 0.11;
|
||||
const SOUND_EMITTER_WOOFER_Y = -0.08;
|
||||
function createSpeakerMaterial(color, selected, emissiveIntensity, roughness, metalness) {
|
||||
return new MeshStandardMaterial({
|
||||
color,
|
||||
emissive: color,
|
||||
emissiveIntensity: selected ? emissiveIntensity : emissiveIntensity * 0.35,
|
||||
roughness,
|
||||
metalness
|
||||
});
|
||||
}
|
||||
export function createSoundEmitterMarkerMeshes(markerColor, selected) {
|
||||
const cabinet = new Mesh(new BoxGeometry(SOUND_EMITTER_CABINET_SIZE.x, SOUND_EMITTER_CABINET_SIZE.y, SOUND_EMITTER_CABINET_SIZE.z), createSpeakerMaterial(0x23272e, selected, 0.08, 0.88, 0.02));
|
||||
const tweeterRing = new Mesh(new TorusGeometry(SOUND_EMITTER_TWEETER_RADIUS, 0.012, 8, 18), createSpeakerMaterial(markerColor, selected, 0.22, 0.4, 0.04));
|
||||
tweeterRing.rotation.x = Math.PI * 0.5;
|
||||
tweeterRing.position.set(0, SOUND_EMITTER_TWEETER_Y, SOUND_EMITTER_FRONT_OFFSET);
|
||||
const tweeterCone = new Mesh(new CylinderGeometry(SOUND_EMITTER_TWEETER_RADIUS * 0.58, SOUND_EMITTER_TWEETER_RADIUS * 0.58, 0.028, 18), createSpeakerMaterial(0x14171c, selected, 0.08, 0.68, 0.01));
|
||||
tweeterCone.rotation.x = Math.PI * 0.5;
|
||||
tweeterCone.position.set(0, SOUND_EMITTER_TWEETER_Y, SOUND_EMITTER_FRONT_OFFSET + 0.006);
|
||||
const wooferRing = new Mesh(new TorusGeometry(SOUND_EMITTER_WOOFER_RADIUS, 0.016, 8, 20), createSpeakerMaterial(markerColor, selected, 0.22, 0.42, 0.04));
|
||||
wooferRing.rotation.x = Math.PI * 0.5;
|
||||
wooferRing.position.set(0, SOUND_EMITTER_WOOFER_Y, SOUND_EMITTER_FRONT_OFFSET);
|
||||
const wooferCone = new Mesh(new CylinderGeometry(SOUND_EMITTER_WOOFER_RADIUS * 0.6, SOUND_EMITTER_WOOFER_RADIUS * 0.6, 0.032, 20), createSpeakerMaterial(0x14171c, selected, 0.08, 0.72, 0.01));
|
||||
wooferCone.rotation.x = Math.PI * 0.5;
|
||||
wooferCone.position.set(0, SOUND_EMITTER_WOOFER_Y, SOUND_EMITTER_FRONT_OFFSET + 0.007);
|
||||
return [cabinet, tweeterRing, tweeterCone, wooferRing, wooferCone];
|
||||
}
|
||||
@@ -1,294 +0,0 @@
|
||||
import { getSingleSelectedBrushId, getSingleSelectedEntityId, getSingleSelectedModelInstanceId } from "../core/selection";
|
||||
import { getBoxBrushBounds } from "../geometry/box-brush";
|
||||
const PLAYER_START_FOCUS_HALF_EXTENTS = {
|
||||
x: 0.35,
|
||||
y: 0.3,
|
||||
z: 0.55
|
||||
};
|
||||
const TELEPORT_TARGET_FOCUS_HALF_EXTENTS = {
|
||||
x: 0.42,
|
||||
y: 0.28,
|
||||
z: 0.42
|
||||
};
|
||||
function createEmptyBoundsAccumulator() {
|
||||
return {
|
||||
min: {
|
||||
x: Number.POSITIVE_INFINITY,
|
||||
y: Number.POSITIVE_INFINITY,
|
||||
z: Number.POSITIVE_INFINITY
|
||||
},
|
||||
max: {
|
||||
x: Number.NEGATIVE_INFINITY,
|
||||
y: Number.NEGATIVE_INFINITY,
|
||||
z: Number.NEGATIVE_INFINITY
|
||||
}
|
||||
};
|
||||
}
|
||||
function includeBounds(bounds, min, max) {
|
||||
bounds.min.x = Math.min(bounds.min.x, min.x);
|
||||
bounds.min.y = Math.min(bounds.min.y, min.y);
|
||||
bounds.min.z = Math.min(bounds.min.z, min.z);
|
||||
bounds.max.x = Math.max(bounds.max.x, max.x);
|
||||
bounds.max.y = Math.max(bounds.max.y, max.y);
|
||||
bounds.max.z = Math.max(bounds.max.z, max.z);
|
||||
}
|
||||
function finishBounds(bounds) {
|
||||
if (!Number.isFinite(bounds.min.x) || !Number.isFinite(bounds.max.x)) {
|
||||
return null;
|
||||
}
|
||||
const center = {
|
||||
x: (bounds.min.x + bounds.max.x) * 0.5,
|
||||
y: (bounds.min.y + bounds.max.y) * 0.5,
|
||||
z: (bounds.min.z + bounds.max.z) * 0.5
|
||||
};
|
||||
const radius = Math.max(0.5, Math.hypot(bounds.max.x - bounds.min.x, bounds.max.y - bounds.min.y, bounds.max.z - bounds.min.z) * 0.5);
|
||||
return {
|
||||
center,
|
||||
radius
|
||||
};
|
||||
}
|
||||
function createBrushFocusTarget(brush) {
|
||||
return {
|
||||
center: {
|
||||
...brush.center
|
||||
},
|
||||
radius: Math.max(0.5, Math.hypot(brush.size.x, brush.size.y, brush.size.z) * 0.5)
|
||||
};
|
||||
}
|
||||
function includeBrush(bounds, brush) {
|
||||
const brushBounds = getBoxBrushBounds(brush);
|
||||
includeBounds(bounds, brushBounds.min, brushBounds.max);
|
||||
}
|
||||
function includePlayerStart(bounds, position) {
|
||||
includeBounds(bounds, {
|
||||
x: position.x - PLAYER_START_FOCUS_HALF_EXTENTS.x,
|
||||
y: position.y,
|
||||
z: position.z - PLAYER_START_FOCUS_HALF_EXTENTS.z
|
||||
}, {
|
||||
x: position.x + PLAYER_START_FOCUS_HALF_EXTENTS.x,
|
||||
y: position.y + PLAYER_START_FOCUS_HALF_EXTENTS.y * 2,
|
||||
z: position.z + PLAYER_START_FOCUS_HALF_EXTENTS.z
|
||||
});
|
||||
}
|
||||
function createBoundsFocusTarget(center, halfExtents, minimumRadius) {
|
||||
return {
|
||||
center,
|
||||
radius: Math.max(minimumRadius, Math.hypot(halfExtents.x, halfExtents.y, halfExtents.z))
|
||||
};
|
||||
}
|
||||
function createPlayerStartFocusTarget(position) {
|
||||
return createBoundsFocusTarget({
|
||||
x: position.x,
|
||||
y: position.y + PLAYER_START_FOCUS_HALF_EXTENTS.y,
|
||||
z: position.z
|
||||
}, PLAYER_START_FOCUS_HALF_EXTENTS, 0.45);
|
||||
}
|
||||
function includeTeleportTarget(bounds, position) {
|
||||
includeBounds(bounds, {
|
||||
x: position.x - TELEPORT_TARGET_FOCUS_HALF_EXTENTS.x,
|
||||
y: position.y,
|
||||
z: position.z - TELEPORT_TARGET_FOCUS_HALF_EXTENTS.z
|
||||
}, {
|
||||
x: position.x + TELEPORT_TARGET_FOCUS_HALF_EXTENTS.x,
|
||||
y: position.y + TELEPORT_TARGET_FOCUS_HALF_EXTENTS.y * 2,
|
||||
z: position.z + TELEPORT_TARGET_FOCUS_HALF_EXTENTS.z
|
||||
});
|
||||
}
|
||||
function createTeleportTargetFocusTarget(position) {
|
||||
return createBoundsFocusTarget({
|
||||
x: position.x,
|
||||
y: position.y + TELEPORT_TARGET_FOCUS_HALF_EXTENTS.y,
|
||||
z: position.z
|
||||
}, TELEPORT_TARGET_FOCUS_HALF_EXTENTS, 0.45);
|
||||
}
|
||||
function getModelInstanceBoundingBox(modelInstance, asset) {
|
||||
if (asset?.kind === "model" && asset.metadata.boundingBox !== null) {
|
||||
const boundingBox = asset.metadata.boundingBox;
|
||||
const scaledMin = {
|
||||
x: boundingBox.min.x * modelInstance.scale.x,
|
||||
y: boundingBox.min.y * modelInstance.scale.y,
|
||||
z: boundingBox.min.z * modelInstance.scale.z
|
||||
};
|
||||
const scaledMax = {
|
||||
x: boundingBox.max.x * modelInstance.scale.x,
|
||||
y: boundingBox.max.y * modelInstance.scale.y,
|
||||
z: boundingBox.max.z * modelInstance.scale.z
|
||||
};
|
||||
return {
|
||||
center: {
|
||||
x: modelInstance.position.x + (scaledMin.x + scaledMax.x) * 0.5,
|
||||
y: modelInstance.position.y + (scaledMin.y + scaledMax.y) * 0.5,
|
||||
z: modelInstance.position.z + (scaledMin.z + scaledMax.z) * 0.5
|
||||
},
|
||||
size: {
|
||||
x: Math.abs(scaledMax.x - scaledMin.x),
|
||||
y: Math.abs(scaledMax.y - scaledMin.y),
|
||||
z: Math.abs(scaledMax.z - scaledMin.z)
|
||||
}
|
||||
};
|
||||
}
|
||||
return {
|
||||
center: {
|
||||
...modelInstance.position
|
||||
},
|
||||
size: {
|
||||
x: modelInstance.scale.x,
|
||||
y: modelInstance.scale.y,
|
||||
z: modelInstance.scale.z
|
||||
}
|
||||
};
|
||||
}
|
||||
function includeModelInstance(bounds, modelInstance, asset) {
|
||||
const modelBounds = getModelInstanceBoundingBox(modelInstance, asset);
|
||||
const halfSize = {
|
||||
x: modelBounds.size.x * 0.5,
|
||||
y: modelBounds.size.y * 0.5,
|
||||
z: modelBounds.size.z * 0.5
|
||||
};
|
||||
includeBounds(bounds, {
|
||||
x: modelBounds.center.x - halfSize.x,
|
||||
y: modelBounds.center.y - halfSize.y,
|
||||
z: modelBounds.center.z - halfSize.z
|
||||
}, {
|
||||
x: modelBounds.center.x + halfSize.x,
|
||||
y: modelBounds.center.y + halfSize.y,
|
||||
z: modelBounds.center.z + halfSize.z
|
||||
});
|
||||
}
|
||||
function createModelInstanceFocusTarget(modelInstance, asset) {
|
||||
const modelBounds = getModelInstanceBoundingBox(modelInstance, asset);
|
||||
return createBoundsFocusTarget(modelBounds.center, {
|
||||
x: modelBounds.size.x * 0.5,
|
||||
y: modelBounds.size.y * 0.5,
|
||||
z: modelBounds.size.z * 0.5
|
||||
}, 0.5);
|
||||
}
|
||||
function includeSphereEntity(bounds, position, radius) {
|
||||
includeBounds(bounds, {
|
||||
x: position.x - radius,
|
||||
y: position.y - radius,
|
||||
z: position.z - radius
|
||||
}, {
|
||||
x: position.x + radius,
|
||||
y: position.y + radius,
|
||||
z: position.z + radius
|
||||
});
|
||||
}
|
||||
function createSphereEntityFocusTarget(position, radius, minimumRadius) {
|
||||
return {
|
||||
center: {
|
||||
x: position.x,
|
||||
y: position.y,
|
||||
z: position.z
|
||||
},
|
||||
radius: Math.max(minimumRadius, radius)
|
||||
};
|
||||
}
|
||||
function includeTriggerVolume(bounds, position, size) {
|
||||
const halfSize = {
|
||||
x: size.x * 0.5,
|
||||
y: size.y * 0.5,
|
||||
z: size.z * 0.5
|
||||
};
|
||||
includeBounds(bounds, {
|
||||
x: position.x - halfSize.x,
|
||||
y: position.y - halfSize.y,
|
||||
z: position.z - halfSize.z
|
||||
}, {
|
||||
x: position.x + halfSize.x,
|
||||
y: position.y + halfSize.y,
|
||||
z: position.z + halfSize.z
|
||||
});
|
||||
}
|
||||
function createTriggerVolumeFocusTarget(position, size) {
|
||||
const halfSize = {
|
||||
x: size.x * 0.5,
|
||||
y: size.y * 0.5,
|
||||
z: size.z * 0.5
|
||||
};
|
||||
return createBoundsFocusTarget({
|
||||
x: position.x,
|
||||
y: position.y,
|
||||
z: position.z
|
||||
}, halfSize, 0.75);
|
||||
}
|
||||
function includeEntity(bounds, entity) {
|
||||
switch (entity.kind) {
|
||||
case "pointLight":
|
||||
includeSphereEntity(bounds, entity.position, Math.max(0.5, entity.distance));
|
||||
break;
|
||||
case "spotLight":
|
||||
includeSphereEntity(bounds, entity.position, Math.max(0.75, entity.distance));
|
||||
break;
|
||||
case "playerStart":
|
||||
includePlayerStart(bounds, entity.position);
|
||||
break;
|
||||
case "soundEmitter":
|
||||
includeSphereEntity(bounds, entity.position, Math.max(0.4, entity.maxDistance));
|
||||
break;
|
||||
case "triggerVolume":
|
||||
includeTriggerVolume(bounds, entity.position, entity.size);
|
||||
break;
|
||||
case "teleportTarget":
|
||||
includeTeleportTarget(bounds, entity.position);
|
||||
break;
|
||||
case "interactable":
|
||||
includeSphereEntity(bounds, entity.position, Math.max(0.4, entity.radius));
|
||||
break;
|
||||
}
|
||||
}
|
||||
function createEntityFocusTarget(entity) {
|
||||
switch (entity.kind) {
|
||||
case "pointLight":
|
||||
return createSphereEntityFocusTarget(entity.position, Math.max(0.6, entity.distance), 0.75);
|
||||
case "spotLight":
|
||||
return createSphereEntityFocusTarget(entity.position, Math.max(0.8, entity.distance), 0.9);
|
||||
case "playerStart":
|
||||
return createPlayerStartFocusTarget(entity.position);
|
||||
case "soundEmitter":
|
||||
return createSphereEntityFocusTarget(entity.position, entity.maxDistance, 0.75);
|
||||
case "triggerVolume":
|
||||
return createTriggerVolumeFocusTarget(entity.position, entity.size);
|
||||
case "teleportTarget":
|
||||
return createTeleportTargetFocusTarget(entity.position);
|
||||
case "interactable":
|
||||
return createSphereEntityFocusTarget(entity.position, entity.radius, 0.65);
|
||||
}
|
||||
}
|
||||
function getSceneFocusTarget(document) {
|
||||
const bounds = createEmptyBoundsAccumulator();
|
||||
for (const brush of Object.values(document.brushes)) {
|
||||
includeBrush(bounds, brush);
|
||||
}
|
||||
for (const modelInstance of Object.values(document.modelInstances)) {
|
||||
includeModelInstance(bounds, modelInstance, document.assets[modelInstance.assetId]);
|
||||
}
|
||||
for (const entity of Object.values(document.entities)) {
|
||||
includeEntity(bounds, entity);
|
||||
}
|
||||
return finishBounds(bounds);
|
||||
}
|
||||
export function resolveViewportFocusTarget(document, selection) {
|
||||
const selectedBrushId = getSingleSelectedBrushId(selection);
|
||||
if (selectedBrushId !== null) {
|
||||
const brush = document.brushes[selectedBrushId];
|
||||
if (brush !== undefined && brush.kind === "box") {
|
||||
return createBrushFocusTarget(brush);
|
||||
}
|
||||
}
|
||||
const selectedEntityId = getSingleSelectedEntityId(selection);
|
||||
if (selectedEntityId !== null) {
|
||||
const entity = document.entities[selectedEntityId];
|
||||
if (entity !== undefined) {
|
||||
return createEntityFocusTarget(entity);
|
||||
}
|
||||
}
|
||||
const selectedModelInstanceId = getSingleSelectedModelInstanceId(selection);
|
||||
if (selectedModelInstanceId !== null) {
|
||||
const modelInstance = document.modelInstances[selectedModelInstanceId];
|
||||
if (modelInstance !== undefined) {
|
||||
return createModelInstanceFocusTarget(modelInstance, document.assets[modelInstance.assetId]);
|
||||
}
|
||||
}
|
||||
return getSceneFocusTarget(document);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,126 +0,0 @@
|
||||
export const VIEWPORT_LAYOUT_MODES = ["single", "quad"];
|
||||
export const VIEWPORT_PANEL_IDS = ["topLeft", "topRight", "bottomLeft", "bottomRight"];
|
||||
const DEFAULT_PERSPECTIVE_CAMERA_POSITION = {
|
||||
x: 10,
|
||||
y: 9,
|
||||
z: 10
|
||||
};
|
||||
export const DEFAULT_VIEWPORT_LAYOUT_STATE = {
|
||||
layoutMode: "single",
|
||||
activePanelId: "topLeft",
|
||||
panels: {
|
||||
topLeft: {
|
||||
viewMode: "perspective",
|
||||
displayMode: "normal",
|
||||
cameraState: createDefaultViewportPanelCameraState()
|
||||
},
|
||||
topRight: {
|
||||
viewMode: "top",
|
||||
displayMode: "authoring",
|
||||
cameraState: createDefaultViewportPanelCameraState()
|
||||
},
|
||||
bottomLeft: {
|
||||
viewMode: "front",
|
||||
displayMode: "authoring",
|
||||
cameraState: createDefaultViewportPanelCameraState()
|
||||
},
|
||||
bottomRight: {
|
||||
viewMode: "side",
|
||||
displayMode: "authoring",
|
||||
cameraState: createDefaultViewportPanelCameraState()
|
||||
}
|
||||
},
|
||||
viewportQuadSplit: {
|
||||
x: 0.5,
|
||||
y: 0.5
|
||||
}
|
||||
};
|
||||
function createDefaultPerspectiveOrbitState() {
|
||||
const { x, y, z } = DEFAULT_PERSPECTIVE_CAMERA_POSITION;
|
||||
const radius = Math.sqrt(x * x + y * y + z * z);
|
||||
return {
|
||||
radius,
|
||||
theta: Math.atan2(x, z),
|
||||
phi: Math.acos(y / radius)
|
||||
};
|
||||
}
|
||||
export function createDefaultViewportPanelCameraState() {
|
||||
return {
|
||||
target: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
perspectiveOrbit: createDefaultPerspectiveOrbitState(),
|
||||
orthographicZoom: 1
|
||||
};
|
||||
}
|
||||
export function cloneViewportPanelCameraState(cameraState) {
|
||||
return {
|
||||
target: {
|
||||
...cameraState.target
|
||||
},
|
||||
perspectiveOrbit: {
|
||||
...cameraState.perspectiveOrbit
|
||||
},
|
||||
orthographicZoom: cameraState.orthographicZoom
|
||||
};
|
||||
}
|
||||
export function areViewportPanelCameraStatesEqual(a, b) {
|
||||
return (a.target.x === b.target.x &&
|
||||
a.target.y === b.target.y &&
|
||||
a.target.z === b.target.z &&
|
||||
a.perspectiveOrbit.radius === b.perspectiveOrbit.radius &&
|
||||
a.perspectiveOrbit.theta === b.perspectiveOrbit.theta &&
|
||||
a.perspectiveOrbit.phi === b.perspectiveOrbit.phi &&
|
||||
a.orthographicZoom === b.orthographicZoom);
|
||||
}
|
||||
export function cloneViewportPanelState(panelState) {
|
||||
return {
|
||||
viewMode: panelState.viewMode,
|
||||
displayMode: panelState.displayMode,
|
||||
cameraState: cloneViewportPanelCameraState(panelState.cameraState)
|
||||
};
|
||||
}
|
||||
export function cloneViewportLayoutState(layoutState) {
|
||||
return {
|
||||
layoutMode: layoutState.layoutMode,
|
||||
activePanelId: layoutState.activePanelId,
|
||||
panels: {
|
||||
topLeft: cloneViewportPanelState(layoutState.panels.topLeft),
|
||||
topRight: cloneViewportPanelState(layoutState.panels.topRight),
|
||||
bottomLeft: cloneViewportPanelState(layoutState.panels.bottomLeft),
|
||||
bottomRight: cloneViewportPanelState(layoutState.panels.bottomRight)
|
||||
},
|
||||
viewportQuadSplit: {
|
||||
...layoutState.viewportQuadSplit
|
||||
}
|
||||
};
|
||||
}
|
||||
export function createDefaultViewportLayoutState() {
|
||||
return cloneViewportLayoutState(DEFAULT_VIEWPORT_LAYOUT_STATE);
|
||||
}
|
||||
const VIEWPORT_PANEL_LABELS = {
|
||||
topLeft: "Top Left",
|
||||
topRight: "Top Right",
|
||||
bottomLeft: "Bottom Left",
|
||||
bottomRight: "Bottom Right"
|
||||
};
|
||||
const VIEWPORT_LAYOUT_MODE_LABELS = {
|
||||
single: "Single View",
|
||||
quad: "4-Panel"
|
||||
};
|
||||
const VIEWPORT_DISPLAY_MODE_LABELS = {
|
||||
normal: "Normal",
|
||||
authoring: "Authoring",
|
||||
wireframe: "Wireframe"
|
||||
};
|
||||
export function getViewportPanelLabel(panelId) {
|
||||
return VIEWPORT_PANEL_LABELS[panelId];
|
||||
}
|
||||
export function getViewportLayoutModeLabel(layoutMode) {
|
||||
return VIEWPORT_LAYOUT_MODE_LABELS[layoutMode];
|
||||
}
|
||||
export function getViewportDisplayModeLabel(displayMode) {
|
||||
return VIEWPORT_DISPLAY_MODE_LABELS[displayMode];
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
import { areTransformSessionsEqual, cloneTransformSession, createInactiveTransformSession } from "../core/transform-session";
|
||||
export function createDefaultViewportTransientState() {
|
||||
return {
|
||||
toolPreview: {
|
||||
kind: "none"
|
||||
},
|
||||
transformSession: createInactiveTransformSession()
|
||||
};
|
||||
}
|
||||
export function cloneViewportToolPreview(toolPreview) {
|
||||
if (toolPreview.kind === "none") {
|
||||
return toolPreview;
|
||||
}
|
||||
return {
|
||||
kind: "create",
|
||||
sourcePanelId: toolPreview.sourcePanelId,
|
||||
target: toolPreview.target.kind === "entity"
|
||||
? {
|
||||
kind: "entity",
|
||||
entityKind: toolPreview.target.entityKind,
|
||||
audioAssetId: toolPreview.target.audioAssetId
|
||||
}
|
||||
: toolPreview.target.kind === "model-instance"
|
||||
? {
|
||||
kind: "model-instance",
|
||||
assetId: toolPreview.target.assetId
|
||||
}
|
||||
: {
|
||||
kind: "box-brush"
|
||||
},
|
||||
center: toolPreview.center === null ? null : { ...toolPreview.center }
|
||||
};
|
||||
}
|
||||
export function areViewportToolPreviewsEqual(left, right) {
|
||||
if (left.kind !== right.kind) {
|
||||
return false;
|
||||
}
|
||||
if (left.kind === "none" || right.kind === "none") {
|
||||
return true;
|
||||
}
|
||||
if (left.kind !== "create" || right.kind !== "create") {
|
||||
return false;
|
||||
}
|
||||
if (left.sourcePanelId !== right.sourcePanelId) {
|
||||
return false;
|
||||
}
|
||||
if (left.target.kind !== right.target.kind) {
|
||||
return false;
|
||||
}
|
||||
if (left.target.kind === "entity" && right.target.kind === "entity") {
|
||||
if (left.target.entityKind !== right.target.entityKind || left.target.audioAssetId !== right.target.audioAssetId) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (left.target.kind === "model-instance" && right.target.kind === "model-instance" && left.target.assetId !== right.target.assetId) {
|
||||
return false;
|
||||
}
|
||||
if (left.center === null || right.center === null) {
|
||||
return left.center === right.center;
|
||||
}
|
||||
return left.center.x === right.center.x && left.center.y === right.center.y && left.center.z === right.center.z;
|
||||
}
|
||||
export function isViewportToolPreviewCompatible(toolMode, toolPreview) {
|
||||
if (toolPreview.kind === "none") {
|
||||
return true;
|
||||
}
|
||||
return toolMode === "create" && toolPreview.kind === "create";
|
||||
}
|
||||
export function cloneViewportTransientState(transientState) {
|
||||
return {
|
||||
toolPreview: cloneViewportToolPreview(transientState.toolPreview),
|
||||
transformSession: cloneTransformSession(transientState.transformSession)
|
||||
};
|
||||
}
|
||||
export function areViewportTransientStatesEqual(left, right) {
|
||||
return areViewportToolPreviewsEqual(left.toolPreview, right.toolPreview) && areTransformSessionsEqual(left.transformSession, right.transformSession);
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
export const VIEWPORT_VIEW_MODES = ["perspective", "top", "front", "side"];
|
||||
const VIEWPORT_VIEW_MODE_DEFINITIONS = {
|
||||
perspective: {
|
||||
id: "perspective",
|
||||
label: "Perspective",
|
||||
cameraType: "perspective",
|
||||
cameraDirection: null,
|
||||
cameraUp: {
|
||||
x: 0,
|
||||
y: 1,
|
||||
z: 0
|
||||
},
|
||||
gridPlane: "xz",
|
||||
snapAxis: "y",
|
||||
controlHint: "Middle-drag orbits, Shift + middle-drag pans, wheel zooms, and Numpad Comma frames the selection."
|
||||
},
|
||||
top: {
|
||||
id: "top",
|
||||
label: "Top",
|
||||
cameraType: "orthographic",
|
||||
cameraDirection: {
|
||||
x: 0,
|
||||
y: 1,
|
||||
z: 0
|
||||
},
|
||||
cameraUp: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: -1
|
||||
},
|
||||
gridPlane: "xz",
|
||||
snapAxis: "y",
|
||||
controlHint: "Middle-drag pans, wheel zooms, and Numpad Comma frames the selection."
|
||||
},
|
||||
front: {
|
||||
id: "front",
|
||||
label: "Front",
|
||||
cameraType: "orthographic",
|
||||
cameraDirection: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 1
|
||||
},
|
||||
cameraUp: {
|
||||
x: 0,
|
||||
y: 1,
|
||||
z: 0
|
||||
},
|
||||
gridPlane: "xy",
|
||||
snapAxis: "z",
|
||||
controlHint: "Middle-drag pans, wheel zooms, and Numpad Comma frames the selection."
|
||||
},
|
||||
side: {
|
||||
id: "side",
|
||||
label: "Side",
|
||||
cameraType: "orthographic",
|
||||
cameraDirection: {
|
||||
x: -1,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
cameraUp: {
|
||||
x: 0,
|
||||
y: 1,
|
||||
z: 0
|
||||
},
|
||||
gridPlane: "yz",
|
||||
snapAxis: "x",
|
||||
controlHint: "Middle-drag pans, wheel zooms, and Numpad Comma frames the selection."
|
||||
}
|
||||
};
|
||||
export function getViewportViewModeDefinition(viewMode) {
|
||||
return VIEWPORT_VIEW_MODE_DEFINITIONS[viewMode];
|
||||
}
|
||||
export function getViewportViewModeLabel(viewMode) {
|
||||
return VIEWPORT_VIEW_MODE_DEFINITIONS[viewMode].label;
|
||||
}
|
||||
export function getViewportViewModeGridPlaneLabel(viewMode) {
|
||||
return VIEWPORT_VIEW_MODE_DEFINITIONS[viewMode].gridPlane.toUpperCase();
|
||||
}
|
||||
export function getViewportViewModeControlHint(viewMode) {
|
||||
return VIEWPORT_VIEW_MODE_DEFINITIONS[viewMode].controlHint;
|
||||
}
|
||||
export function getViewportViewModeSnapAxis(viewMode) {
|
||||
return VIEWPORT_VIEW_MODE_DEFINITIONS[viewMode].snapAxis;
|
||||
}
|
||||
export function isOrthographicViewportViewMode(viewMode) {
|
||||
return viewMode !== "perspective";
|
||||
}
|
||||
Reference in New Issue
Block a user