|
15 | 15 | // }
|
16 | 16 |
|
17 | 17 | 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", |
21 | 21 | streamingAssetsUrl: "StreamingAssets",
|
22 | 22 | companyName: "DefaultCompany",
|
23 | 23 | productName: "campfire",
|
24 | 24 | productVersion: "1.0",
|
25 | 25 | // matchWebGLToCanvasSize: false, // Uncomment this to separately control WebGL canvas render size and DOM element size.
|
26 | 26 | // devicePixelRatio: 1, // Uncomment this to override low DPI rendering on high DPI displays.
|
27 | 27 | });
|
| 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 ** |
0 commit comments