Skip to content

Commit 08cde08

Browse files
committed
Scrolling rotates campfire
1 parent 8b1391b commit 08cde08

10 files changed

+38
-5
lines changed

Diff for: assets/campfire/Build/campfire1.data.unityweb

-2.85 MB
Binary file not shown.
-66.4 KB
Binary file not shown.

Diff for: assets/campfire/Build/campfire1.wasm.unityweb

-5.18 MB
Binary file not shown.

Diff for: assets/campfire/Build/campfire3.data.unityweb

2.85 MB
Binary file not shown.
66.4 KB
Binary file not shown.

Diff for: assets/campfire/Build/campfire3.wasm.unityweb

5.18 MB
Binary file not shown.

Diff for: assets/campfire/MyCampfireLoader.js

+36-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,46 @@
1515
// }
1616

1717
createUnityInstance(document.querySelector("#unity-canvas"), {
18-
dataUrl: "../../assets/campfire/Build/campfire1.data.unityweb",
19-
frameworkUrl: "../../assets/campfire/Build/campfire1.framework.js.unityweb",
20-
codeUrl: "../../assets/campfire/Build/campfire1.wasm.unityweb",
18+
dataUrl: "../../assets/campfire/Build/campfire3.data.unityweb",
19+
frameworkUrl: "../../assets/campfire/Build/campfire3.framework.js.unityweb",
20+
codeUrl: "../../assets/campfire/Build/campfire3.wasm.unityweb",
2121
streamingAssetsUrl: "StreamingAssets",
2222
companyName: "DefaultCompany",
2323
productName: "campfire",
2424
productVersion: "1.0",
2525
// matchWebGLToCanvasSize: false, // Uncomment this to separately control WebGL canvas render size and DOM element size.
2626
// devicePixelRatio: 1, // Uncomment this to override low DPI rendering on high DPI displays.
2727
});
28+
29+
// *** BEGIN fix scroll isues **
30+
31+
// this forwards scroll events into the WebGL canvas,
32+
// even if the mouse is not above the canvas
33+
const canvas = document.getElementById('unity-canvas');
34+
document.addEventListener('wheel', function(event) {
35+
if (event.target === canvas) {
36+
return;
37+
}
38+
39+
const newEvent = new WheelEvent('wheel', event);
40+
canvas.dispatchEvent(newEvent);
41+
});
42+
43+
44+
// this converts touch scroll events into wheel events
45+
let previousTouchY;
46+
document.addEventListener('touchstart', function(event) {
47+
previousTouchY = event.touches[0].clientY;
48+
}, false);
49+
50+
document.addEventListener('touchmove', function(event) {
51+
let currentTouchY = event.touches[0].clientY;
52+
let deltaY = previousTouchY - currentTouchY;
53+
54+
let newEvent = new WheelEvent('wheel', {deltaY: deltaY * 10}); // You can adjust multiplier to suit your scroll speed preference
55+
canvas.dispatchEvent(newEvent);
56+
57+
previousTouchY = currentTouchY; //Store the current Y-coordinate for next comparison
58+
}, false);
59+
60+
// *** END fix scroll isues **

Diff for: index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ <h2>Stuff</h2>
7272
<section class="centered-section">
7373
<canvas id="unity-canvas" width=312 height=256 tabindex="-1"
7474
style="width: 312px; height: 256px; background: #231F20"></canvas>
75-
<script src="assets/campfire/Build/campfire1.loader.js"></script>
75+
<script src="assets/campfire/Build/campfire3.loader.js"></script>
7676
<script src="assets/campfire/MyCampfireLoader.js"></script>
7777
</section>
7878
<section id="versionBox">

Diff for: stuff/campfire/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</head>
99
<body style="text-align: center; padding: 0; border: 0; margin: 0;">
1010
<canvas id="unity-canvas" width=312 height=256 tabindex="-1" style="width: 312px; height: 256px; background: #231F20"></canvas>
11-
<script src="../../assets/campfire/Build/campfire1.loader.js"></script>
11+
<script src="../../assets/campfire/Build/campfire3.loader.js"></script>
1212
<script>
1313
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
1414
// Mobile device style: fill the whole browser client area with the game canvas:

0 commit comments

Comments
 (0)