immersive2/src/gizmos/ResizeGizmo/index.ts
Michael Mainguy 26b48b26c8 Implement WebXR resize gizmo with virtual stick scaling and extract adapter to integration layer
- Implement comprehensive WebXR resize gizmo system with three handle types:
  - Corner handles: uniform scaling (all axes)
  - Edge handles: two-axis planar scaling
  - Face handles: single-axis scaling
- Use "virtual stick" metaphor for intuitive scaling:
  - Fixed-length projection from controller to handle intersection
  - Distance-ratio based scaling from mesh pivot point
  - Works naturally with controller rotation and movement
- Add world-space coordinate transformations for VR rig parenting
- Implement manual ray picking for utility layer handle detection
- Add motion controller initialization handling for grip button
- Fix color persistence bug in diagram entities:
  - DiagramEntityAdapter now uses toDiagramEntity() converter
  - Store color in mesh metadata for persistence
  - Add dependency injection for loose coupling
- Extract DiagramEntityAdapter to integration layer:
  - Move from src/gizmos/ResizeGizmo/ to src/integration/gizmo/
  - Add dependency injection for mesh-to-entity converter
  - Keep ResizeGizmo pure and reusable without diagram dependencies
- Add closest color matching for missing toolbox colors
- Handle size now relative to bounding box (20% of avg dimension)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-13 17:52:23 -06:00

62 lines
1.6 KiB
TypeScript

/**
* WebXR Resize Gizmo
* Self-contained, reusable resize gizmo system for BabylonJS with WebXR support
*
* @example Basic usage:
* ```typescript
* import { ResizeGizmoManager, ResizeGizmoMode } from './gizmos/ResizeGizmo';
*
* const gizmo = new ResizeGizmoManager(scene, {
* mode: ResizeGizmoMode.ALL,
* enableSnapping: true
* });
*
* gizmo.attachToMesh(myMesh);
*
* xr.input.onControllerAddedObservable.add((controller) => {
* gizmo.registerController(controller);
* });
*
* scene.onBeforeRenderObservable.add(() => {
* gizmo.update();
* });
* ```
*
* @example With event callbacks:
* ```typescript
* gizmo.onScaleEnd((event) => {
* console.log('New scale:', event.scale);
* // Persist changes, update UI, etc.
* });
* ```
*
* @note For DiagramEntity integration, see src/integration/gizmo/DiagramEntityAdapter
*/
// Main manager
export { ResizeGizmoManager } from "./ResizeGizmoManager";
// Configuration
export { ResizeGizmoConfigManager } from "./ResizeGizmoConfig";
// Types
export {
ResizeGizmoMode,
HandleType,
InteractionState,
ResizeGizmoEventType,
ResizeGizmoConfig,
ResizeGizmoEvent,
ResizeGizmoEventCallback,
HandlePosition,
DEFAULT_RESIZE_GIZMO_CONFIG
} from "./types";
// Internal classes (exported for advanced usage)
export { ResizeGizmoVisuals } from "./ResizeGizmoVisuals";
export { ResizeGizmoInteraction } from "./ResizeGizmoInteraction";
export { ResizeGizmoSnapping } from "./ResizeGizmoSnapping";
export { ResizeGizmoFeedback } from "./ResizeGizmoFeedback";
export { ScalingCalculator } from "./ScalingCalculator";
export { HandleGeometry } from "./HandleGeometry";