Skip to content

Commit

Permalink
Example controls updates (#7093)
Browse files Browse the repository at this point in the history
* Updated controls interface to use observer correctly

* Converted all examples to use controls as arrow functions

* Added semicolons
  • Loading branch information
kpal81xd committed Nov 11, 2024
1 parent 79ad1d6 commit aaf329f
Show file tree
Hide file tree
Showing 34 changed files with 102 additions and 97 deletions.
4 changes: 2 additions & 2 deletions examples/src/examples/animation/blend-trees-1d.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx }) {
export const controls = ({ observer, ReactPCUI, React, jsx }) => {
const { BindingTwoWay, LabelGroup, SliderInput } = ReactPCUI;
class JsxControls extends React.Component {
render() {
Expand All @@ -15,4 +15,4 @@ export function controls({ observer, ReactPCUI, React, jsx }) {
}
}
return jsx(JsxControls);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ React, jsx, fragment }) {
export const controls = ({ React, jsx, fragment }) => {
const { createRef, Component } = React;
class JsxControls extends Component {
position = new pc.Vec2();
Expand Down Expand Up @@ -140,4 +140,4 @@ export function controls({ React, jsx, fragment }) {
}
}
return jsx(JsxControls);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ React, jsx, fragment }) {
export const controls = ({ React, jsx, fragment }) => {
const { useEffect, useRef } = React;
/** @type {React.MutableRefObject<HTMLCanvasElement>} */
const canvasRef = useRef(null);
Expand Down Expand Up @@ -80,4 +80,4 @@ export function controls({ React, jsx, fragment }) {
canvas.addEventListener('mousedown', mouseEvent);
});
return fragment(jsx('canvas', { ref: canvasRef }));
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { Button } = ReactPCUI;
return fragment(
jsx(Button, {
Expand All @@ -12,4 +12,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
}
})
);
}
};
4 changes: 2 additions & 2 deletions examples/src/examples/animation/layer-masks.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, LabelGroup, Panel, BooleanInput, SelectInput, SliderInput } = ReactPCUI;
return fragment(
jsx(
Expand Down Expand Up @@ -98,4 +98,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
4 changes: 2 additions & 2 deletions examples/src/examples/animation/locomotion.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, LabelGroup, BooleanInput, Button } = ReactPCUI;
const binding = new BindingTwoWay();
const link = {
Expand All @@ -26,4 +26,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
})
)
);
}
};
7 changes: 4 additions & 3 deletions examples/src/examples/gizmos/transform-rotate.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, LabelGroup, Panel, ColorPicker, SliderInput, SelectInput, BooleanInput } = ReactPCUI;
const { useState } = React;

const [proj, setProj] = React.useState(pc.PROJECTION_PERSPECTIVE);
const [proj, setProj] = useState(pc.PROJECTION_PERSPECTIVE);

return fragment(
jsx(
Expand Down Expand Up @@ -176,4 +177,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
7 changes: 4 additions & 3 deletions examples/src/examples/gizmos/transform-scale.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, LabelGroup, Panel, ColorPicker, SliderInput, SelectInput, BooleanInput } = ReactPCUI;
const { useState } = React;

const [proj, setProj] = React.useState(pc.PROJECTION_PERSPECTIVE);
const [proj, setProj] = useState(pc.PROJECTION_PERSPECTIVE);

return fragment(
jsx(
Expand Down Expand Up @@ -198,4 +199,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
7 changes: 4 additions & 3 deletions examples/src/examples/gizmos/transform-translate.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, LabelGroup, Panel, ColorPicker, SliderInput, SelectInput, BooleanInput } = ReactPCUI;
const { useState } = React;

const [proj, setProj] = React.useState(pc.PROJECTION_PERSPECTIVE);
const [proj, setProj] = useState(pc.PROJECTION_PERSPECTIVE);

return fragment(
jsx(
Expand Down Expand Up @@ -218,4 +219,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
4 changes: 2 additions & 2 deletions examples/src/examples/graphics/asset-viewer.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { Panel, Button } = ReactPCUI;
return jsx(
Panel,
Expand All @@ -16,4 +16,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
onClick: () => observer.emit('next')
})
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, LabelGroup, Panel, SliderInput } = ReactPCUI;
return fragment(
jsx(
Expand Down Expand Up @@ -32,4 +32,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, BooleanInput, LabelGroup, Panel, SelectInput, SliderInput } = ReactPCUI;
return jsx(
Panel,
Expand Down Expand Up @@ -55,4 +55,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
})
)
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, BooleanInput, Button, Label, LabelGroup, Panel, SelectInput, SliderInput } = ReactPCUI;
return fragment(
jsx(
Expand Down Expand Up @@ -138,4 +138,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, LabelGroup, Panel, SliderInput, SelectInput, BooleanInput } = ReactPCUI;
return fragment(
jsx(
Expand Down Expand Up @@ -163,4 +163,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, LabelGroup, Panel, SliderInput, BooleanInput, SelectInput } = ReactPCUI;
return fragment(
jsx(
Expand Down Expand Up @@ -62,4 +62,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
4 changes: 2 additions & 2 deletions examples/src/examples/graphics/ground-fog.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, BooleanInput, LabelGroup } = ReactPCUI;
return jsx(
LabelGroup,
Expand All @@ -16,4 +16,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
}
})
);
}
};
4 changes: 2 additions & 2 deletions examples/src/examples/graphics/integer-textures.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, jsx, fragment }) => {
const { BindingTwoWay, Container, Button, InfoBox, LabelGroup, Panel, SliderInput, SelectInput } = ReactPCUI;

return fragment(
Expand Down Expand Up @@ -55,4 +55,4 @@ export function controls({ observer, ReactPCUI, jsx, fragment }) {
)
)
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, BooleanInput, LabelGroup, Panel, SliderInput } = ReactPCUI;
return fragment(
jsx(
Expand Down Expand Up @@ -132,4 +132,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
4 changes: 2 additions & 2 deletions examples/src/examples/graphics/lights-baked-a-o.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, BooleanInput, Label, LabelGroup, Panel, SliderInput } = ReactPCUI;
return fragment(
jsx(
Expand Down Expand Up @@ -186,4 +186,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
4 changes: 2 additions & 2 deletions examples/src/examples/graphics/lights.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, BooleanInput, LabelGroup, Panel, SliderInput } = ReactPCUI;
return fragment(
jsx(
Expand Down Expand Up @@ -109,4 +109,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
4 changes: 2 additions & 2 deletions examples/src/examples/graphics/multi-view.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, LabelGroup, Panel, SelectInput } = ReactPCUI;
return fragment(
jsx(
Expand Down Expand Up @@ -34,4 +34,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
4 changes: 2 additions & 2 deletions examples/src/examples/graphics/post-effects.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, BooleanInput, LabelGroup, Panel, SelectInput, SliderInput } = ReactPCUI;
return fragment(
jsx(
Expand Down Expand Up @@ -192,4 +192,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
4 changes: 2 additions & 2 deletions examples/src/examples/graphics/post-processing.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, BooleanInput, LabelGroup, Panel, SelectInput, SliderInput } = ReactPCUI;
return fragment(
jsx(
Expand Down Expand Up @@ -248,4 +248,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
4 changes: 2 additions & 2 deletions examples/src/examples/graphics/reflection-box.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, LabelGroup, Panel, SelectInput, SliderInput } = ReactPCUI;
return fragment(
jsx(
Expand Down Expand Up @@ -69,4 +69,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
4 changes: 2 additions & 2 deletions examples/src/examples/graphics/shadow-cascades.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as pc from 'playcanvas';
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
const { BindingTwoWay, BooleanInput, LabelGroup, Panel, SelectInput, SliderInput } = ReactPCUI;
return fragment(
jsx(
Expand Down Expand Up @@ -83,4 +83,4 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
)
)
);
}
};
Loading

0 comments on commit aaf329f

Please sign in to comment.