new tma
This commit is contained in:
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
@@ -7,6 +7,6 @@ RUN go build -o main .
|
|||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=builder /app/main /app/main
|
COPY --from=builder /app/main /app/main
|
||||||
COPY --from=builder /app/templates /app/templates
|
COPY --from=builder /app/dist /app/dist
|
||||||
EXPOSE 8181
|
EXPOSE 8181
|
||||||
CMD ["/app/main"]
|
CMD ["/app/main"]
|
||||||
|
|||||||
13
index.html
Normal file
13
index.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>tma-front</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
80
main.go
80
main.go
@@ -1,83 +1,15 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
"text/template"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Game(w http.ResponseWriter, r *http.Request) {
|
|
||||||
if r.URL.Path != "/" {
|
|
||||||
http.NotFound(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles("templates/D.html")
|
|
||||||
if err != nil {
|
|
||||||
http.Error(w, fmt.Sprintf("Error parsing template: %v", err), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err = tmpl.Execute(w, nil)
|
|
||||||
if err != nil {
|
|
||||||
http.Error(w, fmt.Sprintf("Error executing template: %v", err), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func StaticFileHandler(w http.ResponseWriter, r *http.Request) {
|
|
||||||
path := strings.TrimPrefix(r.URL.Path, "/")
|
|
||||||
templatesPath := filepath.Join("templates", path)
|
|
||||||
|
|
||||||
if fileExists(templatesPath) {
|
|
||||||
http.ServeFile(w, r, templatesPath)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
http.NotFound(w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
func fileExists(path string) bool {
|
|
||||||
info, err := os.Stat(path)
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return !info.IsDir()
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
http.HandleFunc("/", Game)
|
fs := http.FileServer(http.Dir("./dist"))
|
||||||
|
http.Handle("/", fs)
|
||||||
|
|
||||||
http.HandleFunc("/D.icon.png", StaticFileHandler)
|
addr := ":8181"
|
||||||
http.HandleFunc("/D.apple-touch-icon.png", StaticFileHandler)
|
log.Println("Server started on", addr)
|
||||||
http.HandleFunc("/D.png", StaticFileHandler)
|
log.Fatal(http.ListenAndServe(addr, nil))
|
||||||
http.HandleFunc("/D.js", StaticFileHandler)
|
|
||||||
http.HandleFunc("/D.pck", StaticFileHandler)
|
|
||||||
http.HandleFunc("/D.wasm", StaticFileHandler)
|
|
||||||
http.HandleFunc("/D.audio.position.worklet.js", StaticFileHandler)
|
|
||||||
http.HandleFunc("/D.audio.worklet.js", StaticFileHandler)
|
|
||||||
|
|
||||||
http.HandleFunc("/templates/", func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
path := strings.TrimPrefix(r.URL.Path, "/templates/")
|
|
||||||
templatesPath := filepath.Join("templates", path)
|
|
||||||
|
|
||||||
if fileExists(templatesPath) {
|
|
||||||
http.ServeFile(w, r, templatesPath)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
http.NotFound(w, r)
|
|
||||||
})
|
|
||||||
|
|
||||||
port := ":8181"
|
|
||||||
fmt.Printf("Starting Go server on http://localhost%s\n", port)
|
|
||||||
fmt.Printf("Open http://localhost%s in your browser\n", port)
|
|
||||||
fmt.Printf("Serving files directly from templates directory\n")
|
|
||||||
|
|
||||||
if err := http.ListenAndServe(port, nil); err != nil {
|
|
||||||
fmt.Printf("Server error: %v\n", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
1138
package-lock.json
generated
Normal file
1138
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
18
package.json
Normal file
18
package.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "tma-front",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "tsc && vite build",
|
||||||
|
"preview": "vite preview"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "~5.9.3",
|
||||||
|
"vite": "^7.2.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"phaser": "^3.90.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
1
public/vite.svg
Normal file
1
public/vite.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||||
|
After Width: | Height: | Size: 1.5 KiB |
4
src/config/game.ts
Normal file
4
src/config/game.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export const GAME_WIDTH = 360;
|
||||||
|
export const GAME_HEIGHT = 640;
|
||||||
|
export const PLAYER_SIZE = 32;
|
||||||
|
export const TICK_RATE = 30;
|
||||||
9
src/counter.ts
Normal file
9
src/counter.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
export function setupCounter(element: HTMLButtonElement) {
|
||||||
|
let counter = 0
|
||||||
|
const setCounter = (count: number) => {
|
||||||
|
counter = count
|
||||||
|
element.innerHTML = `count is ${counter}`
|
||||||
|
}
|
||||||
|
element.addEventListener('click', () => setCounter(counter + 1))
|
||||||
|
setCounter(0)
|
||||||
|
}
|
||||||
26
src/entities/Player.ts
Normal file
26
src/entities/Player.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import Phaser from "phaser";
|
||||||
|
import { TouchInput } from "../input/TouchInput";
|
||||||
|
|
||||||
|
export class Player {
|
||||||
|
sprite: Phaser.GameObjects.Rectangle;
|
||||||
|
speed = 160; // пикселей в секунду
|
||||||
|
|
||||||
|
constructor(scene: Phaser.Scene, x: number, y: number) {
|
||||||
|
this.sprite = scene.add.rectangle(x, y, 32, 32, 0x00ff00);
|
||||||
|
}
|
||||||
|
|
||||||
|
update(delta: number, input: TouchInput) {
|
||||||
|
const dt = delta / 1000;
|
||||||
|
|
||||||
|
this.sprite.x += input.dx * this.speed * dt;
|
||||||
|
this.sprite.y += input.dy * this.speed * dt;
|
||||||
|
|
||||||
|
this.sprite.x = Phaser.Math.Clamp(this.sprite.x, 16, 360 - 16);
|
||||||
|
this.sprite.y = Phaser.Math.Clamp(this.sprite.y, 16, 640 - 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
setPosition(x: number, y: number) {
|
||||||
|
this.sprite.x = x;
|
||||||
|
this.sprite.y = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/entities/RemotePlayer.ts
Normal file
29
src/entities/RemotePlayer.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import Phaser from "phaser";
|
||||||
|
|
||||||
|
export class RemotePlayer {
|
||||||
|
sprite: Phaser.GameObjects.Rectangle;
|
||||||
|
|
||||||
|
targetX: number;
|
||||||
|
targetY: number;
|
||||||
|
|
||||||
|
constructor(scene: Phaser.Scene, x: number, y: number, color: number) {
|
||||||
|
this.sprite = scene.add.rectangle(x, y, 32, 32, color);
|
||||||
|
this.targetX = x;
|
||||||
|
this.targetY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTarget(x: number, y: number) {
|
||||||
|
this.targetX = x;
|
||||||
|
this.targetY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
// магия сглаживания
|
||||||
|
this.sprite.x = Phaser.Math.Linear(this.sprite.x, this.targetX, 0.15);
|
||||||
|
this.sprite.y = Phaser.Math.Linear(this.sprite.y, this.targetY, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
destroy() {
|
||||||
|
this.sprite.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/input/TouchInput.ts
Normal file
26
src/input/TouchInput.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import Phaser from "phaser";
|
||||||
|
|
||||||
|
export class TouchInput {
|
||||||
|
dx = 0;
|
||||||
|
dy = 0;
|
||||||
|
|
||||||
|
constructor(scene: Phaser.Scene) {
|
||||||
|
let start: Phaser.Math.Vector2 | null = null;
|
||||||
|
|
||||||
|
scene.input.on("pointerdown", (pointer: Phaser.Input.Pointer) => {
|
||||||
|
start = new Phaser.Math.Vector2(pointer.x, pointer.y);
|
||||||
|
});
|
||||||
|
|
||||||
|
scene.input.on("pointermove", (pointer: Phaser.Input.Pointer) => {
|
||||||
|
if (!start) return;
|
||||||
|
this.dx = Phaser.Math.Clamp((pointer.x - start.x) / 50, -1, 1);
|
||||||
|
this.dy = Phaser.Math.Clamp((pointer.y - start.y) / 50, -1, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
scene.input.on("pointerup", () => {
|
||||||
|
start = null;
|
||||||
|
this.dx = 0;
|
||||||
|
this.dy = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/main.ts
Normal file
16
src/main.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import Phaser from "phaser";
|
||||||
|
import { GameScene } from "./scenes/GameScene";
|
||||||
|
|
||||||
|
const config: Phaser.Types.Core.GameConfig = {
|
||||||
|
type: Phaser.AUTO,
|
||||||
|
width: 360,
|
||||||
|
height: 640,
|
||||||
|
scale: {
|
||||||
|
mode: Phaser.Scale.FIT,
|
||||||
|
autoCenter: Phaser.Scale.CENTER_BOTH,
|
||||||
|
},
|
||||||
|
backgroundColor: "#1e1e1e",
|
||||||
|
scene: [GameScene],
|
||||||
|
};
|
||||||
|
|
||||||
|
new Phaser.Game(config);
|
||||||
32
src/net/Socket.ts
Normal file
32
src/net/Socket.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
export class GameSocket {
|
||||||
|
private socket: WebSocket;
|
||||||
|
playerId: string | null = null;
|
||||||
|
onState?: (state: any) => void;
|
||||||
|
|
||||||
|
constructor(url: string) {
|
||||||
|
this.socket = new WebSocket(url);
|
||||||
|
|
||||||
|
this.socket.onmessage = (e) => {
|
||||||
|
const msg = JSON.parse(e.data);
|
||||||
|
|
||||||
|
if (msg.type === "init") {
|
||||||
|
this.playerId = msg.payload.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.type === "state") {
|
||||||
|
this.onState?.(msg.payload);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
sendInput(dx: number, dy: number) {
|
||||||
|
if (!this.playerId) return;
|
||||||
|
|
||||||
|
this.socket.send(
|
||||||
|
JSON.stringify({
|
||||||
|
dx,
|
||||||
|
dy,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
49
src/scenes/GameScene.ts
Normal file
49
src/scenes/GameScene.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import { RemotePlayer } from "../entities/RemotePlayer";
|
||||||
|
import { TouchInput } from "../input/TouchInput";
|
||||||
|
import { GameSocket } from "../net/Socket";
|
||||||
|
|
||||||
|
export class GameScene extends Phaser.Scene {
|
||||||
|
players = new Map<string, RemotePlayer>();
|
||||||
|
socket!: GameSocket;
|
||||||
|
inputCtrl!: TouchInput;
|
||||||
|
|
||||||
|
create() {
|
||||||
|
this.inputCtrl = new TouchInput(this);
|
||||||
|
this.socket = new GameSocket("ws://localhost:8080/ws");
|
||||||
|
|
||||||
|
this.socket.onState = (state) => {
|
||||||
|
this.syncPlayers(state.players);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
update() {
|
||||||
|
this.socket.sendInput(this.inputCtrl.dx, this.inputCtrl.dy);
|
||||||
|
|
||||||
|
for (const player of this.players.values()) {
|
||||||
|
player.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
syncPlayers(serverPlayers: Record<string, { x: number; y: number }>) {
|
||||||
|
for (const id in serverPlayers) {
|
||||||
|
const data = serverPlayers[id];
|
||||||
|
let player = this.players.get(id);
|
||||||
|
|
||||||
|
if (!player) {
|
||||||
|
const isMe = id === this.socket.playerId;
|
||||||
|
const color = isMe ? 0x00ff00 : 0xff4444;
|
||||||
|
player = new RemotePlayer(this, data.x, data.y, color);
|
||||||
|
this.players.set(id, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setTarget(data.x, data.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const [id, player] of this.players) {
|
||||||
|
if (!serverPlayers[id]) {
|
||||||
|
player.destroy();
|
||||||
|
this.players.delete(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
96
src/style.css
Normal file
96
src/style.css
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
:root {
|
||||||
|
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||||
|
line-height: 1.5;
|
||||||
|
font-weight: 400;
|
||||||
|
|
||||||
|
color-scheme: light dark;
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
background-color: #242424;
|
||||||
|
|
||||||
|
font-synthesis: none;
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
font-weight: 500;
|
||||||
|
color: #646cff;
|
||||||
|
text-decoration: inherit;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
color: #535bf2;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
display: flex;
|
||||||
|
place-items: center;
|
||||||
|
min-width: 320px;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 3.2em;
|
||||||
|
line-height: 1.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#app {
|
||||||
|
max-width: 1280px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 2rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo {
|
||||||
|
height: 6em;
|
||||||
|
padding: 1.5em;
|
||||||
|
will-change: filter;
|
||||||
|
transition: filter 300ms;
|
||||||
|
}
|
||||||
|
.logo:hover {
|
||||||
|
filter: drop-shadow(0 0 2em #646cffaa);
|
||||||
|
}
|
||||||
|
.logo.vanilla:hover {
|
||||||
|
filter: drop-shadow(0 0 2em #3178c6aa);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
padding: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.read-the-docs {
|
||||||
|
color: #888;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
padding: 0.6em 1.2em;
|
||||||
|
font-size: 1em;
|
||||||
|
font-weight: 500;
|
||||||
|
font-family: inherit;
|
||||||
|
background-color: #1a1a1a;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: border-color 0.25s;
|
||||||
|
}
|
||||||
|
button:hover {
|
||||||
|
border-color: #646cff;
|
||||||
|
}
|
||||||
|
button:focus,
|
||||||
|
button:focus-visible {
|
||||||
|
outline: 4px auto -webkit-focus-ring-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
:root {
|
||||||
|
color: #213547;
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
color: #747bff;
|
||||||
|
}
|
||||||
|
button {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/typescript.svg
Normal file
1
src/typescript.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="32" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path fill="#007ACC" d="M0 128v128h256V0H0z"></path><path fill="#FFF" d="m56.612 128.85l-.081 10.483h33.32v94.68h23.568v-94.68h33.321v-10.28c0-5.69-.122-10.444-.284-10.566c-.122-.162-20.4-.244-44.983-.203l-44.74.122l-.121 10.443Zm149.955-10.742c6.501 1.625 11.459 4.51 16.01 9.224c2.357 2.52 5.851 7.111 6.136 8.208c.08.325-11.053 7.802-17.798 11.988c-.244.162-1.22-.894-2.317-2.52c-3.291-4.795-6.745-6.867-12.028-7.233c-7.76-.528-12.759 3.535-12.718 10.321c0 1.992.284 3.17 1.097 4.795c1.707 3.536 4.876 5.649 14.832 9.956c18.326 7.883 26.168 13.084 31.045 20.48c5.445 8.249 6.664 21.415 2.966 31.208c-4.063 10.646-14.14 17.879-28.323 20.276c-4.388.772-14.79.65-19.504-.203c-10.28-1.828-20.033-6.908-26.047-13.572c-2.357-2.6-6.949-9.387-6.664-9.874c.122-.163 1.178-.813 2.356-1.504c1.138-.65 5.446-3.129 9.509-5.485l7.355-4.267l1.544 2.276c2.154 3.29 6.867 7.801 9.712 9.305c8.167 4.307 19.383 3.698 24.909-1.26c2.357-2.153 3.332-4.388 3.332-7.68c0-2.966-.366-4.266-1.91-6.501c-1.99-2.845-6.054-5.242-17.595-10.24c-13.206-5.69-18.895-9.224-24.096-14.832c-3.007-3.25-5.852-8.452-7.03-12.8c-.975-3.617-1.22-12.678-.447-16.335c2.723-12.76 12.353-21.659 26.25-24.3c4.51-.853 14.994-.528 19.424.569Z"></path></svg>
|
||||||
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
@@ -1,66 +0,0 @@
|
|||||||
/**************************************************************************/
|
|
||||||
/* godot.audio.position.worklet.js */
|
|
||||||
/**************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* https://godotengine.org */
|
|
||||||
/**************************************************************************/
|
|
||||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
||||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* */
|
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
||||||
/* a copy of this software and associated documentation files (the */
|
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
||||||
/* the following conditions: */
|
|
||||||
/* */
|
|
||||||
/* The above copyright notice and this permission notice shall be */
|
|
||||||
/* included in all copies or substantial portions of the Software. */
|
|
||||||
/* */
|
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
class GodotPositionReportingProcessor extends AudioWorkletProcessor {
|
|
||||||
static get parameterDescriptors() {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
name: 'reset',
|
|
||||||
defaultValue: 0,
|
|
||||||
minValue: 0,
|
|
||||||
maxValue: 1,
|
|
||||||
automationRate: 'k-rate',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(...args) {
|
|
||||||
super(...args);
|
|
||||||
this.position = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
process(inputs, _outputs, parameters) {
|
|
||||||
if (parameters['reset'][0] > 0) {
|
|
||||||
this.position = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inputs.length > 0) {
|
|
||||||
const input = inputs[0];
|
|
||||||
if (input.length > 0) {
|
|
||||||
this.position += input[0].length;
|
|
||||||
this.port.postMessage({ type: 'position', data: this.position });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
registerProcessor('godot-position-reporting-processor', GodotPositionReportingProcessor);
|
|
||||||
@@ -1,213 +0,0 @@
|
|||||||
/**************************************************************************/
|
|
||||||
/* audio.worklet.js */
|
|
||||||
/**************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* https://godotengine.org */
|
|
||||||
/**************************************************************************/
|
|
||||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
||||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* */
|
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
||||||
/* a copy of this software and associated documentation files (the */
|
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
||||||
/* the following conditions: */
|
|
||||||
/* */
|
|
||||||
/* The above copyright notice and this permission notice shall be */
|
|
||||||
/* included in all copies or substantial portions of the Software. */
|
|
||||||
/* */
|
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
class RingBuffer {
|
|
||||||
constructor(p_buffer, p_state, p_threads) {
|
|
||||||
this.buffer = p_buffer;
|
|
||||||
this.avail = p_state;
|
|
||||||
this.threads = p_threads;
|
|
||||||
this.rpos = 0;
|
|
||||||
this.wpos = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
data_left() {
|
|
||||||
return this.threads ? Atomics.load(this.avail, 0) : this.avail;
|
|
||||||
}
|
|
||||||
|
|
||||||
space_left() {
|
|
||||||
return this.buffer.length - this.data_left();
|
|
||||||
}
|
|
||||||
|
|
||||||
read(output) {
|
|
||||||
const size = this.buffer.length;
|
|
||||||
let from = 0;
|
|
||||||
let to_write = output.length;
|
|
||||||
if (this.rpos + to_write > size) {
|
|
||||||
const high = size - this.rpos;
|
|
||||||
output.set(this.buffer.subarray(this.rpos, size));
|
|
||||||
from = high;
|
|
||||||
to_write -= high;
|
|
||||||
this.rpos = 0;
|
|
||||||
}
|
|
||||||
if (to_write) {
|
|
||||||
output.set(this.buffer.subarray(this.rpos, this.rpos + to_write), from);
|
|
||||||
}
|
|
||||||
this.rpos += to_write;
|
|
||||||
if (this.threads) {
|
|
||||||
Atomics.add(this.avail, 0, -output.length);
|
|
||||||
Atomics.notify(this.avail, 0);
|
|
||||||
} else {
|
|
||||||
this.avail -= output.length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
write(p_buffer) {
|
|
||||||
const to_write = p_buffer.length;
|
|
||||||
const mw = this.buffer.length - this.wpos;
|
|
||||||
if (mw >= to_write) {
|
|
||||||
this.buffer.set(p_buffer, this.wpos);
|
|
||||||
this.wpos += to_write;
|
|
||||||
if (mw === to_write) {
|
|
||||||
this.wpos = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const high = p_buffer.subarray(0, mw);
|
|
||||||
const low = p_buffer.subarray(mw);
|
|
||||||
this.buffer.set(high, this.wpos);
|
|
||||||
this.buffer.set(low);
|
|
||||||
this.wpos = low.length;
|
|
||||||
}
|
|
||||||
if (this.threads) {
|
|
||||||
Atomics.add(this.avail, 0, to_write);
|
|
||||||
Atomics.notify(this.avail, 0);
|
|
||||||
} else {
|
|
||||||
this.avail += to_write;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class GodotProcessor extends AudioWorkletProcessor {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.threads = false;
|
|
||||||
this.running = true;
|
|
||||||
this.lock = null;
|
|
||||||
this.notifier = null;
|
|
||||||
this.output = null;
|
|
||||||
this.output_buffer = new Float32Array();
|
|
||||||
this.input = null;
|
|
||||||
this.input_buffer = new Float32Array();
|
|
||||||
this.port.onmessage = (event) => {
|
|
||||||
const cmd = event.data['cmd'];
|
|
||||||
const data = event.data['data'];
|
|
||||||
this.parse_message(cmd, data);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
process_notify() {
|
|
||||||
if (this.notifier) {
|
|
||||||
Atomics.add(this.notifier, 0, 1);
|
|
||||||
Atomics.notify(this.notifier, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_message(p_cmd, p_data) {
|
|
||||||
if (p_cmd === 'start' && p_data) {
|
|
||||||
const state = p_data[0];
|
|
||||||
let idx = 0;
|
|
||||||
this.threads = true;
|
|
||||||
this.lock = state.subarray(idx, ++idx);
|
|
||||||
this.notifier = state.subarray(idx, ++idx);
|
|
||||||
const avail_in = state.subarray(idx, ++idx);
|
|
||||||
const avail_out = state.subarray(idx, ++idx);
|
|
||||||
this.input = new RingBuffer(p_data[1], avail_in, true);
|
|
||||||
this.output = new RingBuffer(p_data[2], avail_out, true);
|
|
||||||
} else if (p_cmd === 'stop') {
|
|
||||||
this.running = false;
|
|
||||||
this.output = null;
|
|
||||||
this.input = null;
|
|
||||||
this.lock = null;
|
|
||||||
this.notifier = null;
|
|
||||||
} else if (p_cmd === 'start_nothreads') {
|
|
||||||
this.output = new RingBuffer(p_data[0], p_data[0].length, false);
|
|
||||||
} else if (p_cmd === 'chunk') {
|
|
||||||
this.output.write(p_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static array_has_data(arr) {
|
|
||||||
return arr.length && arr[0].length && arr[0][0].length;
|
|
||||||
}
|
|
||||||
|
|
||||||
process(inputs, outputs, parameters) {
|
|
||||||
if (!this.running) {
|
|
||||||
return false; // Stop processing.
|
|
||||||
}
|
|
||||||
if (this.output === null) {
|
|
||||||
return true; // Not ready yet, keep processing.
|
|
||||||
}
|
|
||||||
const process_input = GodotProcessor.array_has_data(inputs);
|
|
||||||
if (process_input) {
|
|
||||||
const input = inputs[0];
|
|
||||||
const chunk = input[0].length * input.length;
|
|
||||||
if (this.input_buffer.length !== chunk) {
|
|
||||||
this.input_buffer = new Float32Array(chunk);
|
|
||||||
}
|
|
||||||
if (!this.threads) {
|
|
||||||
GodotProcessor.write_input(this.input_buffer, input);
|
|
||||||
this.port.postMessage({ 'cmd': 'input', 'data': this.input_buffer });
|
|
||||||
} else if (this.input.space_left() >= chunk) {
|
|
||||||
GodotProcessor.write_input(this.input_buffer, input);
|
|
||||||
this.input.write(this.input_buffer);
|
|
||||||
} else {
|
|
||||||
// this.port.postMessage('Input buffer is full! Skipping input frame.'); // Uncomment this line to debug input buffer.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const process_output = GodotProcessor.array_has_data(outputs);
|
|
||||||
if (process_output) {
|
|
||||||
const output = outputs[0];
|
|
||||||
const chunk = output[0].length * output.length;
|
|
||||||
if (this.output_buffer.length !== chunk) {
|
|
||||||
this.output_buffer = new Float32Array(chunk);
|
|
||||||
}
|
|
||||||
if (this.output.data_left() >= chunk) {
|
|
||||||
this.output.read(this.output_buffer);
|
|
||||||
GodotProcessor.write_output(output, this.output_buffer);
|
|
||||||
if (!this.threads) {
|
|
||||||
this.port.postMessage({ 'cmd': 'read', 'data': chunk });
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// this.port.postMessage('Output buffer has not enough frames! Skipping output frame.'); // Uncomment this line to debug output buffer.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.process_notify();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static write_output(dest, source) {
|
|
||||||
const channels = dest.length;
|
|
||||||
for (let ch = 0; ch < channels; ch++) {
|
|
||||||
for (let sample = 0; sample < dest[ch].length; sample++) {
|
|
||||||
dest[ch][sample] = source[sample * channels + ch];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static write_input(dest, source) {
|
|
||||||
const channels = source.length;
|
|
||||||
for (let ch = 0; ch < channels; ch++) {
|
|
||||||
for (let sample = 0; sample < source[ch].length; sample++) {
|
|
||||||
dest[sample * channels + ch] = source[ch][sample];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
registerProcessor('godot-processor', GodotProcessor);
|
|
||||||
293
templates/D.html
293
templates/D.html
@@ -1,293 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0">
|
|
||||||
<title>D</title>
|
|
||||||
<style>
|
|
||||||
html, body, #canvas {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
color: white;
|
|
||||||
background-color: black;
|
|
||||||
overflow: hidden;
|
|
||||||
touch-action: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#canvas {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
#canvas:focus {
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#status, #status-splash, #status-progress {
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#status, #status-splash {
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#status {
|
|
||||||
background-color: #000000;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
#status-splash {
|
|
||||||
max-height: 100%;
|
|
||||||
max-width: 100%;
|
|
||||||
margin: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
#status-splash.show-image--false {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#status-splash.fullsize--true {
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
object-fit: contain;
|
|
||||||
}
|
|
||||||
|
|
||||||
#status-splash.use-filter--false {
|
|
||||||
image-rendering: pixelated;
|
|
||||||
}
|
|
||||||
|
|
||||||
#status-progress, #status-notice {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#status-progress {
|
|
||||||
bottom: 10%;
|
|
||||||
width: 50%;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
#status-notice {
|
|
||||||
background-color: #5b3943;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
border: 1px solid #9b3943;
|
|
||||||
color: #e0e0e0;
|
|
||||||
font-family: 'Noto Sans', 'Droid Sans', Arial, sans-serif;
|
|
||||||
line-height: 1.3;
|
|
||||||
margin: 0 2rem;
|
|
||||||
overflow: hidden;
|
|
||||||
padding: 1rem;
|
|
||||||
text-align: center;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<link id="-gd-engine-icon" rel="icon" type="image/png" href="D.icon.png" />
|
|
||||||
<link rel="apple-touch-icon" href="D.apple-touch-icon.png"/>
|
|
||||||
<script src="https://telegram.org/js/telegram-web-app.js?59"></script>
|
|
||||||
<script>
|
|
||||||
(function () {
|
|
||||||
function isTelegram() {
|
|
||||||
return typeof window.Telegram !== "undefined"
|
|
||||||
&& window.Telegram.WebApp;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getViewportSize() {
|
|
||||||
const root = document.documentElement;
|
|
||||||
|
|
||||||
// ширина ВСЕГДА из CSS layout
|
|
||||||
const width = root.clientWidth;
|
|
||||||
|
|
||||||
let height;
|
|
||||||
if (isTelegram()) {
|
|
||||||
const tg = window.Telegram.WebApp;
|
|
||||||
tg.expand();
|
|
||||||
height = tg.viewportStableHeight;
|
|
||||||
} else {
|
|
||||||
height = root.clientHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
return { width, height };
|
|
||||||
}
|
|
||||||
|
|
||||||
function resizeCanvas() {
|
|
||||||
const canvas = document.getElementById("canvas");
|
|
||||||
if (!canvas) return;
|
|
||||||
|
|
||||||
const { width, height } = getViewportSize();
|
|
||||||
const dpr = window.devicePixelRatio || 1;
|
|
||||||
|
|
||||||
// ВАЖНО: internal WebGL resolution
|
|
||||||
canvas.width = Math.floor(width * dpr);
|
|
||||||
canvas.height = Math.floor(height * dpr);
|
|
||||||
|
|
||||||
// CSS size
|
|
||||||
canvas.style.width = width + "px";
|
|
||||||
canvas.style.height = height + "px";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Telegram resize
|
|
||||||
if (isTelegram()) {
|
|
||||||
Telegram.WebApp.onEvent("viewportChanged", resizeCanvas);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Browser resize
|
|
||||||
window.addEventListener("resize", resizeCanvas);
|
|
||||||
|
|
||||||
// Initial
|
|
||||||
resizeCanvas();
|
|
||||||
})();
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
html, body {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
background: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
canvas {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<canvas id="canvas">
|
|
||||||
Your browser does not support the canvas tag.
|
|
||||||
</canvas>
|
|
||||||
|
|
||||||
<noscript>
|
|
||||||
Your browser does not support JavaScript.
|
|
||||||
</noscript>
|
|
||||||
|
|
||||||
<div id="status">
|
|
||||||
<img id="status-splash" class="show-image--false fullsize--true use-filter--true" src="D.png" alt="">
|
|
||||||
<progress id="status-progress"></progress>
|
|
||||||
<div id="status-notice"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="D.js"></script>
|
|
||||||
<script>
|
|
||||||
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"emscriptenPoolSize":8,"ensureCrossOriginIsolationHeaders":true,"executable":"D","experimentalVK":false,"fileSizes":{"D.pck":3161016,"D.wasm":38034280},"focusCanvas":true,"gdextensionLibs":[],"godotPoolSize":4};
|
|
||||||
const GODOT_THREADS_ENABLED = false;
|
|
||||||
const engine = new Engine(GODOT_CONFIG);
|
|
||||||
|
|
||||||
(function () {
|
|
||||||
const statusOverlay = document.getElementById('status');
|
|
||||||
const statusProgress = document.getElementById('status-progress');
|
|
||||||
const statusNotice = document.getElementById('status-notice');
|
|
||||||
|
|
||||||
let initializing = true;
|
|
||||||
let statusMode = '';
|
|
||||||
|
|
||||||
function setStatusMode(mode) {
|
|
||||||
if (statusMode === mode || !initializing) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mode === 'hidden') {
|
|
||||||
statusOverlay.remove();
|
|
||||||
initializing = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
statusOverlay.style.visibility = 'visible';
|
|
||||||
statusProgress.style.display = mode === 'progress' ? 'block' : 'none';
|
|
||||||
statusNotice.style.display = mode === 'notice' ? 'block' : 'none';
|
|
||||||
statusMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setStatusNotice(text) {
|
|
||||||
while (statusNotice.lastChild) {
|
|
||||||
statusNotice.removeChild(statusNotice.lastChild);
|
|
||||||
}
|
|
||||||
const lines = text.split('\n');
|
|
||||||
lines.forEach((line) => {
|
|
||||||
statusNotice.appendChild(document.createTextNode(line));
|
|
||||||
statusNotice.appendChild(document.createElement('br'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function displayFailureNotice(err) {
|
|
||||||
console.error(err);
|
|
||||||
if (err instanceof Error) {
|
|
||||||
setStatusNotice(err.message);
|
|
||||||
} else if (typeof err === 'string') {
|
|
||||||
setStatusNotice(err);
|
|
||||||
} else {
|
|
||||||
setStatusNotice('An unknown error occurred.');
|
|
||||||
}
|
|
||||||
setStatusMode('notice');
|
|
||||||
initializing = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const missing = Engine.getMissingFeatures({
|
|
||||||
threads: GODOT_THREADS_ENABLED,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (missing.length !== 0) {
|
|
||||||
if (GODOT_CONFIG['serviceWorker'] && GODOT_CONFIG['ensureCrossOriginIsolationHeaders'] && 'serviceWorker' in navigator) {
|
|
||||||
let serviceWorkerRegistrationPromise;
|
|
||||||
try {
|
|
||||||
serviceWorkerRegistrationPromise = navigator.serviceWorker.getRegistration();
|
|
||||||
} catch (err) {
|
|
||||||
serviceWorkerRegistrationPromise = Promise.reject(new Error('Service worker registration failed.'));
|
|
||||||
}
|
|
||||||
// There's a chance that installing the service worker would fix the issue
|
|
||||||
Promise.race([
|
|
||||||
serviceWorkerRegistrationPromise.then((registration) => {
|
|
||||||
if (registration != null) {
|
|
||||||
return Promise.reject(new Error('Service worker already exists.'));
|
|
||||||
}
|
|
||||||
return registration;
|
|
||||||
}).then(() => engine.installServiceWorker()),
|
|
||||||
// For some reason, `getRegistration()` can stall
|
|
||||||
new Promise((resolve) => {
|
|
||||||
setTimeout(() => resolve(), 2000);
|
|
||||||
}),
|
|
||||||
]).then(() => {
|
|
||||||
// Reload if there was no error.
|
|
||||||
window.location.reload();
|
|
||||||
}).catch((err) => {
|
|
||||||
console.error('Error while registering service worker:', err);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Display the message as usual
|
|
||||||
const missingMsg = 'Error\nThe following features required to run Godot projects on the Web are missing:\n';
|
|
||||||
displayFailureNotice(missingMsg + missing.join('\n'));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setStatusMode('progress');
|
|
||||||
engine.startGame({
|
|
||||||
'onProgress': function (current, total) {
|
|
||||||
if (current > 0 && total > 0) {
|
|
||||||
statusProgress.value = current;
|
|
||||||
statusProgress.max = total;
|
|
||||||
} else {
|
|
||||||
statusProgress.removeAttribute('value');
|
|
||||||
statusProgress.removeAttribute('max');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}).then(() => {
|
|
||||||
setStatusMode('hidden');
|
|
||||||
}, displayFailureNotice);
|
|
||||||
}
|
|
||||||
}());
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.6 KiB |
927
templates/D.js
927
templates/D.js
File diff suppressed because one or more lines are too long
BIN
templates/D.pck
BIN
templates/D.pck
Binary file not shown.
BIN
templates/D.png
BIN
templates/D.png
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB |
BIN
templates/D.wasm
BIN
templates/D.wasm
Binary file not shown.
26
tsconfig.json
Normal file
26
tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2022",
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"module": "ESNext",
|
||||||
|
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||||
|
"types": ["vite/client"],
|
||||||
|
"skipLibCheck": true,
|
||||||
|
|
||||||
|
/* Bundler mode */
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"noEmit": true,
|
||||||
|
|
||||||
|
/* Linting */
|
||||||
|
"strict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"erasableSyntaxOnly": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"noUncheckedSideEffectImports": true
|
||||||
|
},
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user