Fix brush on mobile
This commit is contained in:
parent
058d6014b7
commit
a7b14b9fbb
1 changed files with 11 additions and 5 deletions
|
|
@ -36,7 +36,7 @@ export default class GameLoop {
|
||||||
private readonly canvas: HTMLCanvasElement,
|
private readonly canvas: HTMLCanvasElement,
|
||||||
private readonly device: GPUDevice
|
private readonly device: GPUDevice
|
||||||
) {
|
) {
|
||||||
const context = this.canvas.getContext('webgpu') as any;
|
const context = this.canvas.getContext('webgpu') as any as GPUCanvasContext;
|
||||||
context.configure({
|
context.configure({
|
||||||
device: this.device,
|
device: this.device,
|
||||||
format: navigator.gpu.getPreferredCanvasFormat(),
|
format: navigator.gpu.getPreferredCanvasFormat(),
|
||||||
|
|
@ -82,15 +82,17 @@ export default class GameLoop {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.brushPipeline.addSwipe(
|
const position = vec2.fromValues(
|
||||||
vec2.fromValues(event.clientX, this.canvas.height - event.clientY)
|
event.clientX * this.devicePixelRatio,
|
||||||
|
this.canvas.height - event.clientY * this.devicePixelRatio
|
||||||
);
|
);
|
||||||
|
this.brushPipeline.addSwipe(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private resize() {
|
private resize() {
|
||||||
const devicePixelRatio = window.devicePixelRatio || 1;
|
const devicePixelRatio = window.devicePixelRatio || 1;
|
||||||
this.canvas.width = this.canvas.clientWidth * devicePixelRatio;
|
this.canvas.width = this.canvas.clientWidth * this.devicePixelRatio;
|
||||||
this.canvas.height = this.canvas.clientHeight * devicePixelRatio;
|
this.canvas.height = this.canvas.clientHeight * this.devicePixelRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async render(time: DOMHighResTimeStamp) {
|
private async render(time: DOMHighResTimeStamp) {
|
||||||
|
|
@ -167,4 +169,8 @@ export default class GameLoop {
|
||||||
private get canvasSize(): vec2 {
|
private get canvasSize(): vec2 {
|
||||||
return vec2.fromValues(this.canvas.width, this.canvas.height);
|
return vec2.fromValues(this.canvas.width, this.canvas.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private get devicePixelRatio(): number {
|
||||||
|
return window.devicePixelRatio || 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue