diff --git a/templates/template-creation-web/src/engine/engine.ts b/templates/template-creation-web/src/engine/engine.ts index e39c851..ea01278 100644 --- a/templates/template-creation-web/src/engine/engine.ts +++ b/templates/template-creation-web/src/engine/engine.ts @@ -14,6 +14,7 @@ import manifest from "../manifest.json"; import { CreationAudioPlugin } from "./audio/AudioPlugin"; import { CreationNavigationPlugin } from "./navigation/NavigationPlugin"; import { CreationResizePlugin } from "./resize/ResizePlugin"; +import { getResolution } from "./utils/getResolution"; extensions.remove(ResizePlugin); extensions.add(CreationResizePlugin); @@ -36,6 +37,9 @@ export class CreationEngine extends Application { /** Initialize the application */ public async init(opts: Partial): Promise { opts.resizeTo ??= window; + opts.resolution ??= getResolution(); + opts.antialias ??= true; + await super.init(opts); // Append the application canvas to the document body @@ -55,7 +59,7 @@ export class CreationEngine extends Application { public override destroy( rendererDestroyOptions: RendererDestroyOptions = false, - options: DestroyOptions = false, + options: DestroyOptions = false ): void { document.removeEventListener("visibilitychange", this.visibilityChange); super.destroy(rendererDestroyOptions, options); diff --git a/templates/template-creation-web/src/engine/utils/getResolution.ts b/templates/template-creation-web/src/engine/utils/getResolution.ts new file mode 100644 index 0000000..fb4aa4b --- /dev/null +++ b/templates/template-creation-web/src/engine/utils/getResolution.ts @@ -0,0 +1,9 @@ +export function getResolution(): number { + let resolution = Math.max(window.devicePixelRatio, 2); + + if (resolution % 1 !== 0) { + resolution = 2; + } + + return resolution; +}