Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweaks to bus bunching and temple photo op #48

Merged
merged 16 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ __pycache__/
*.webm
node_modules/
build/
devbox.*
devbox.*
.devbox/
182 changes: 149 additions & 33 deletions experiences/bus-bunching/controls/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @jsxImportSource @emotion/react */
import { css } from "@emotion/react"
import React, { useCallback } from "react"
import { useMessaging } from "@footron/controls-client"
import { Slider } from "@material-ui/core"
import { css } from "@emotion/react";
import React, { useCallback, useState } from "react";
import { useMessaging } from "@footron/controls-client";
import { Slider, Box, Button } from "@material-ui/core";

const containerStyle = css`
padding: 16px;
Expand All @@ -11,51 +11,167 @@ const containerStyle = css`
p {
margin: 0 0 16px;
}
`
`;
const stopSymbols = ["■", "▲", "●", "♥"];
const stopColors = ["#EE6352", "#08B2E3", "#57A773", "#8657a7", "#2222AA"];

const sectionWrapperStyle = {
justifyContent: "center",
padding: "2em 0 0 0",
margin: "auto",
};

const buttonWrapperStyle = {
display: "grid",
gap: "10px",
gridTemplateColumns: "repeat(5, minmax(70px, 1fr))",
};

const buttonStyle = {
position: "relative",
width: "100%",
paddingTop: "100%",
borderRadius: "50%",
};

const contentStyle = {
position: "absolute",
top: "0",
left: "0",
right: "0",
bottom: "0",
display: "flex",
alignItems: "center",
justifyContent: "center",
color: "white",
fontSize: "500%",

}

const ControlsComponent = () => {
const { sendMessage } = useMessaging()
const { sendMessage } = useMessaging();
const [buttonCount, setButtonCount] = useState(3);

const updateBusCount = useCallback(
async (event, value) => {
await sendMessage({ type: "numBuses", value: value })
await sendMessage({ type: "numBuses", value: value });
},
[sendMessage]
)
);

const updateStopCount = useCallback(
async (event, value) => {
await sendMessage({ type: "numStops", value: value })
setButtonCount(value);
await sendMessage({ type: "numStops", value: value });
},
[sendMessage]
)
);

const restart = useCallback(
async (event, value) => {
await sendMessage({ type: "restart", value: value });
},
[sendMessage]
);

const pauseStart = useCallback(
async (value) => {
console.log(value);
await sendMessage({ type: "delayStop", value: value });
},
[sendMessage]
);

const pauseEnd = useCallback(
async (value) => {
console.log(value);
await sendMessage({ type: "freeStop", value: value });
},
[sendMessage]
);

const busStopSymbol = (index) => {
let stopStyle = {
...contentStyle,
color: stopColors[index % stopColors.length],
};
return (
<span style={stopStyle}>{stopSymbols[index % stopSymbols.length]}</span>
);
};

const buttons = Array.from({ length: buttonCount }, (_, index) => (
<Button
key={index}
style={buttonStyle}
variant="outlined"
color="primary"
onMouseDown={() => pauseStart(index)}
onMouseUp={() => pauseEnd(index)}
onTouchStart={() => pauseStart(index)}
onTouchEnd={() => pauseEnd(index)}
>
{busStopSymbol(index)}
</Button>
));

return (
<div css={containerStyle}>
<h1>Bus Bunching</h1>
<p>
<b>Change the number of buses!</b>
Learn more about bus bunching here:{' '}
<a href="https://en.wikipedia.org/wiki/Bus_bunching">
Wikipedia &quot;Bus Bunching&quot;
</a>
</p>
<Slider
min={1}
max={10}
onChange={updateBusCount}
step={1}
marks
defaultValue={3}
/>
<p>
<b>Change the number of bus stops!</b>
</p>
<Slider
min={2}
max={20}
onChange={updateStopCount}
step={1}
marks
defaultValue={5}
/>
<Box style={sectionWrapperStyle}>
<p>
<b>Change the number of buses!</b>
</p>
<Slider
min={1}
max={10}
valueLabelDisplay="auto"
onChange={updateBusCount}
step={1}
marks
defaultValue={3}
/>
<p>
<b>Change the number of bus stops!</b>
</p>
<Slider
min={2}
max={20}
valueLabelDisplay="auto"
onChange={updateStopCount}
step={1}
marks
defaultValue={5}
/>
</Box>
<Box style={sectionWrapperStyle}>
<Box style={{ textAlign: "center" }}>
<Button
style={{ margin: "0 auto" }}
variant="contained"
color="primary"
onClick={restart}
>
<b>Restart</b>
</Button>
</Box>
</Box>
<Box style={sectionWrapperStyle}>
<p>
<b>
Create a delay by clicking and holding any of the bus stops below.
</b>
</p>
<Box style={buttonWrapperStyle}>{buttons}</Box>
</Box>
</div>
)
}
);
};

export default ControlsComponent
export default ControlsComponent;
1 change: 1 addition & 0 deletions experiences/bus-bunching/web/assets/index-CO6LLJQy.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6,518 changes: 6,518 additions & 0 deletions experiences/bus-bunching/web/assets/index-Drcr_JpC.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion experiences/bus-bunching/web/index-DfisqMx5.css

This file was deleted.

5 changes: 3 additions & 2 deletions experiences/bus-bunching/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
<title>Bus Bunching: UVX</title>

<script src="./footron-messaging.development.js" type="text/javascript"></script>
<script>if (typeof module === 'object') { window.module = module; module = undefined; }</script>
<script src="./jquery-3.6.0.min.js" type="text/javascript"></script>
<script src="./fader.js" type="text/javascript"></script>
<script type="module" crossorigin src="index-DUfHmJ6Z.js"></script>
<link rel="stylesheet" crossorigin href="index-DfisqMx5.css">
<script type="module" crossorigin src="/assets/index-Drcr_JpC.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CO6LLJQy.css">
</head>

<body>
Expand Down
1 change: 1 addition & 0 deletions experiences/bus-bunching/web/models/library.gltf

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file added experiences/bus-bunching/web/models/stop.glb
Binary file not shown.
Binary file added experiences/bus-bunching/web/models/uvx-back.glb
Binary file not shown.
Binary file added experiences/bus-bunching/web/models/uvx-front.glb
Binary file not shown.
Binary file modified experiences/temple-photo-op/web/imgs/Bentonville, Arkansas.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading