Skip to content

Commit 4257ba5

Browse files
mvaligurskyMartin Valigursky
andauthored
Shader Effects framework + example for gaussian splatting (playcanvas#8105)
Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
1 parent 8b4c1f9 commit 4257ba5

11 files changed

Lines changed: 1028 additions & 187 deletions

examples/src/examples/gaussian-splatting/reveal.controls.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
2424
observer.emit('restart');
2525
}
2626
}),
27+
jsx(Button, {
28+
text: 'Prev',
29+
onClick: () => {
30+
observer.emit('prev');
31+
}
32+
}),
2733
jsx(Button, {
2834
text: 'Next',
2935
onClick: () => {

examples/src/examples/gaussian-splatting/reveal.example.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ assetListLoader.load(() => {
167167
createEffect(currentEffect);
168168
});
169169

170+
// Prev button - cycle to previous effect in the list
171+
data.on('prev', () => {
172+
const currentEffect = data.get('effect');
173+
const currentIndex = effects.indexOf(currentEffect);
174+
const prevIndex = (currentIndex - 1 + effects.length) % effects.length;
175+
const prevEffect = effects[prevIndex];
176+
data.set('effect', prevEffect);
177+
});
178+
170179
// Next button - cycle to next effect in the list
171180
data.on('next', () => {
172181
const currentEffect = data.get('effect');
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* @param {import('../../app/components/Example.mjs').ControlOptions} options - The options.
3+
* @returns {JSX.Element} The returned JSX Element.
4+
*/
5+
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
6+
const { BindingTwoWay, LabelGroup, SelectInput, BooleanInput, Button } = ReactPCUI;
7+
return fragment(
8+
jsx(
9+
LabelGroup,
10+
{ text: 'Effect' },
11+
jsx(SelectInput, {
12+
options: [
13+
{ v: 'hide', t: 'Statue Hide' },
14+
{ v: 'reveal', t: 'Statue Reveal' },
15+
{ v: 'tint', t: 'Statue Tint' },
16+
{ v: 'untint', t: 'Statue Untint' },
17+
{ v: 'roomHide', t: 'Room Hide' },
18+
{ v: 'roomReveal', t: 'Room Reveal' },
19+
{ v: 'roomTint', t: 'Room Tint' },
20+
{ v: 'roomUntint', t: 'Room Untint' }
21+
],
22+
binding: new BindingTwoWay(),
23+
link: { observer, path: 'effect' }
24+
})
25+
),
26+
jsx(Button, {
27+
text: 'Restart',
28+
onClick: () => {
29+
observer.emit('restart');
30+
}
31+
}),
32+
jsx(Button, {
33+
text: 'Prev',
34+
onClick: () => {
35+
observer.emit('prev');
36+
}
37+
}),
38+
jsx(Button, {
39+
text: 'Next',
40+
onClick: () => {
41+
observer.emit('next');
42+
}
43+
}),
44+
jsx(
45+
LabelGroup,
46+
{ text: 'Enabled' },
47+
jsx(BooleanInput, {
48+
type: 'toggle',
49+
binding: new BindingTwoWay(),
50+
link: { observer, path: 'enabled' }
51+
})
52+
)
53+
);
54+
};

0 commit comments

Comments
 (0)