|
| 1 | +import React from "react"; |
| 2 | +import Source, { SignalSource, SignalSourceOptions } from "../../objects/source"; |
| 3 | +import Container from "../../objects/container"; |
| 4 | +import { useContainer } from "../../store"; |
| 5 | +import { filteredMapObject, pickProps } from "../../common/helpers"; |
| 6 | +import PropertyRow from "./property-row/PropertyRow"; |
| 7 | +import PropertyRowFolder from "./property-row/PropertyRowFolder"; |
| 8 | +import { createPropertyInputs, useContainerProperty } from "./ContainerComponents"; |
| 9 | +import useToggle from "../hooks/use-toggle"; |
| 10 | +import PropertyRowLabel from "./property-row/PropertyRowLabel"; |
| 11 | +import PropertyRowCheckbox from "./property-row/PropertyRowCheckbox"; |
| 12 | +import PropertyButton from "./property-row/PropertyButton"; |
| 13 | + |
| 14 | +const { PropertyTextInput, PropertyNumberInput, PropertyCheckboxInput, PropertyVectorInput, PropertySelect } = createPropertyInputs<Source>( |
| 15 | + "SOURCE_SET_PROPERTY" |
| 16 | +); |
| 17 | + |
| 18 | +const General = ({ uuid }: { uuid: string }) => { |
| 19 | + const [open, toggle] = useToggle(true); |
| 20 | + return ( |
| 21 | + <PropertyRowFolder label="General" open={open} onOpenClose={toggle}> |
| 22 | + <PropertyTextInput uuid={uuid} label="Name" property="name" tooltip="Sets the name of this container" /> |
| 23 | + </PropertyRowFolder> |
| 24 | + ); |
| 25 | +}; |
| 26 | + |
| 27 | +const Visual = ({ uuid }: { uuid: string }) => { |
| 28 | + const [open, toggle] = useToggle(true); |
| 29 | + return ( |
| 30 | + <PropertyRowFolder label="Visual" open={open} onOpenClose={toggle}> |
| 31 | + <PropertyCheckboxInput |
| 32 | + uuid={uuid} |
| 33 | + label="Visible" |
| 34 | + property="visible" |
| 35 | + tooltip="Toggles the visibility of this container" |
| 36 | + /> |
| 37 | + </PropertyRowFolder> |
| 38 | + ); |
| 39 | +}; |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +const Transform = ({ uuid }: { uuid: string }) => { |
| 45 | + const [open, toggle] = useToggle(true); |
| 46 | + return ( |
| 47 | + <PropertyRowFolder label="Transform" open={open} onOpenClose={toggle}> |
| 48 | + <PropertyVectorInput |
| 49 | + uuid={uuid} |
| 50 | + label="Position" |
| 51 | + property={["x", "y", "z"]} |
| 52 | + tooltip="Sets the container's position" |
| 53 | + /> |
| 54 | + <PropertyVectorInput |
| 55 | + uuid={uuid} |
| 56 | + label="Scale" |
| 57 | + property={["scalex", "scaley", "scalez"]} |
| 58 | + tooltip="Sets the container's scale" |
| 59 | + /> |
| 60 | + <PropertyVectorInput |
| 61 | + uuid={uuid} |
| 62 | + label="Rotation" |
| 63 | + property={["rotationx", "rotationy", "rotationz"]} |
| 64 | + tooltip="Sets the container's rotation" |
| 65 | + /> |
| 66 | + </PropertyRowFolder> |
| 67 | + ); |
| 68 | +}; |
| 69 | + |
| 70 | + |
| 71 | +const Configuration = ({ uuid }: { uuid: string }) => { |
| 72 | + const [open, toggle] = useToggle(true); |
| 73 | + return ( |
| 74 | + <PropertyRowFolder label="Configuration" open={open} onOpenClose={toggle}> |
| 75 | + <PropertyNumberInput |
| 76 | + uuid={uuid} |
| 77 | + label="θ Theta" |
| 78 | + property="theta" |
| 79 | + tooltip="Sets theta" |
| 80 | + /> |
| 81 | + <PropertyNumberInput |
| 82 | + uuid={uuid} |
| 83 | + label="φ Phi" |
| 84 | + property="phi" |
| 85 | + tooltip="Sets phi" |
| 86 | + /> |
| 87 | + </PropertyRowFolder> |
| 88 | + ); |
| 89 | +}; |
| 90 | + |
| 91 | +const FDTDConfig =({ uuid }: { uuid: string }) => { |
| 92 | + const [open, toggle] = useToggle(true); |
| 93 | + return ( |
| 94 | + <PropertyRowFolder label="FDTD Config" open={open} onOpenClose={toggle}> |
| 95 | + <PropertySelect |
| 96 | + uuid={uuid} |
| 97 | + label="Signal Source" |
| 98 | + tooltip="The source thats generating it's signal" |
| 99 | + property="signalSource" |
| 100 | + options={SignalSourceOptions} |
| 101 | + /> |
| 102 | + <PropertyNumberInput uuid={uuid} label="Frequency" property="frequency" tooltip="The source's frequency" /> |
| 103 | + <PropertyNumberInput uuid={uuid} label="Amplitude" property="amplitude" tooltip="The source's amplitude" /> |
| 104 | + <PropertyButton label="Signal Data" tooltip="The source's signal data" event="SOURCE_CALL_METHOD" args={{ uuid, method: "saveSamples" }} /> |
| 105 | + </PropertyRowFolder> |
| 106 | + ) |
| 107 | +} |
| 108 | + |
| 109 | + |
| 110 | +// const StyleProperties = ({ uuid }: { uuid: string }) => { |
| 111 | +// const [open, toggle] = useToggle(true); |
| 112 | +// return ( |
| 113 | +// <PropertyRowFolder label="Style Properties" open={open} onOpenClose={toggle}> |
| 114 | +// <PropertyNumberInput |
| 115 | +// uuid={uuid} |
| 116 | +// label="Point Size" |
| 117 | +// property="pointSize" |
| 118 | +// tooltip="Sets the size of each interection point" |
| 119 | +// /> |
| 120 | +// <PropertyCheckboxInput |
| 121 | +// uuid={uuid} |
| 122 | +// label="Rays Visible" |
| 123 | +// property="raysVisible" |
| 124 | +// tooltip="Toggles the visibility of the rays" |
| 125 | +// /> |
| 126 | +// <PropertyCheckboxInput |
| 127 | +// uuid={uuid} |
| 128 | +// label="Points Visible" |
| 129 | +// property="pointsVisible" |
| 130 | +// tooltip="Toggles the visibility of the intersection points" |
| 131 | +// /> |
| 132 | +// </PropertyRowFolder> |
| 133 | +// ); |
| 134 | +// }; |
| 135 | +// const ContainerControls = ({ uuid }: { uuid: string }) => { |
| 136 | +// const [open, toggle] = useToggle(true); |
| 137 | +// return ( |
| 138 | +// <PropertyRowFolder label="Container Controls" open={open} onOpenClose={toggle}> |
| 139 | +// <PropertyCheckboxInput uuid={uuid} label="Running" property="isRunning" tooltip="Starts/stops the raytracer" /> |
| 140 | +// <PropertyButton event="RAYTRACER_CLEAR_RAYS" args={uuid} label="Clear Rays" tooltip="Clears all of the rays" /> |
| 141 | +// </PropertyRowFolder> |
| 142 | +// ); |
| 143 | +// }; |
| 144 | + |
| 145 | +export const SourceTab = ({ uuid }: { uuid: string }) => { |
| 146 | + return ( |
| 147 | + <div> |
| 148 | + <General uuid={uuid} /> |
| 149 | + <Visual uuid={uuid} /> |
| 150 | + <Transform uuid={uuid} /> |
| 151 | + </div> |
| 152 | + ); |
| 153 | +}; |
| 154 | + |
| 155 | +export default SourceTab; |
0 commit comments