keyframeSvgPoint.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import * as React from "react";
  2. import { Vector2 } from 'babylonjs/Maths/math.vector';
  3. import { AnchorSvgPoint } from './anchorSvgPoint';
  4. const keyInactive = require("./assets/keyInactiveIcon.svg") as string;
  5. //const keyActive = require("./assets/keyActiveIcon.svg") as string; uncomment when setting active multiselect
  6. const keySelected = require("./assets/keySelectedIcon.svg") as string;
  7. export interface IKeyframeSvgPoint {
  8. keyframePoint: Vector2;
  9. rightControlPoint: Vector2 | null;
  10. leftControlPoint: Vector2 | null;
  11. id: string;
  12. selected: boolean;
  13. isLeftActive: boolean;
  14. isRightActive: boolean;
  15. curveId?: ICurveMetaData;
  16. }
  17. export interface ICurveMetaData {
  18. id: number;
  19. animationName: string;
  20. property: string;
  21. }
  22. interface IKeyframeSvgPointProps {
  23. keyframePoint: Vector2;
  24. leftControlPoint: Vector2 | null;
  25. rightControlPoint: Vector2 | null;
  26. id: string;
  27. selected: boolean;
  28. selectKeyframe: (id: string) => void;
  29. selectedControlPoint: (type: string, id: string) => void;
  30. isLeftActive: boolean;
  31. isRightActive: boolean;
  32. }
  33. export class KeyframeSvgPoint extends React.Component<IKeyframeSvgPointProps>{
  34. constructor(props: IKeyframeSvgPointProps) {
  35. super(props);
  36. }
  37. select() {
  38. this.props.selectKeyframe(this.props.id);
  39. }
  40. render() {
  41. return (
  42. <>
  43. <svg className="draggable" x={this.props.keyframePoint.x} y={this.props.keyframePoint.y} style={{ overflow: 'visible', cursor: 'pointer' }} >
  44. <image data-id={this.props.id} className="draggable" x="-1" y="-1.5" width="3" height="3" href={this.props.selected ? keySelected : keyInactive} onClick={() => this.select()} />
  45. </svg>
  46. {this.props.leftControlPoint && <AnchorSvgPoint type="left" index={this.props.id} control={this.props.leftControlPoint} anchor={this.props.keyframePoint} active={this.props.selected} selected={this.props.isLeftActive} selectControlPoint={(type: string) => this.props.selectedControlPoint(type, this.props.id)} />}
  47. {this.props.rightControlPoint && <AnchorSvgPoint type="right" index={this.props.id} control={this.props.rightControlPoint} anchor={this.props.keyframePoint} active={this.props.selected} selected={this.props.isRightActive} selectControlPoint={(type: string) => this.props.selectedControlPoint(type, this.props.id)} />}
  48. </>
  49. )
  50. }
  51. }