feature/网络管理和Web部署系统 #2
45
export_presets.cfg
Normal file
45
export_presets.cfg
Normal file
@@ -0,0 +1,45 @@
|
||||
[preset.0]
|
||||
|
||||
name="Web"
|
||||
platform="Web"
|
||||
runnable=true
|
||||
advanced_options=false
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="web_assets/index.html"
|
||||
patches=PackedStringArray()
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
seed=0
|
||||
encrypt_pck=false
|
||||
encrypt_directory=false
|
||||
script_export_mode=2
|
||||
|
||||
[preset.0.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
variant/extensions_support=false
|
||||
variant/thread_support=false
|
||||
vram_texture_compression/for_desktop=true
|
||||
vram_texture_compression/for_mobile=false
|
||||
html/export_icon=true
|
||||
html/custom_html_shell=""
|
||||
html/head_include=""
|
||||
html/canvas_resize_policy=2
|
||||
html/focus_canvas_on_start=true
|
||||
html/experimental_virtual_keyboard=false
|
||||
progressive_web_app/enabled=true
|
||||
progressive_web_app/ensure_cross_origin_isolation_headers=true
|
||||
progressive_web_app/offline_page=""
|
||||
progressive_web_app/display=1
|
||||
progressive_web_app/orientation=0
|
||||
progressive_web_app/icon_144x144="uid://bwy5r7soxi76a"
|
||||
progressive_web_app/icon_180x180="uid://drpllpsjdiaex"
|
||||
progressive_web_app/icon_512x512="uid://dt817lem3dwee"
|
||||
progressive_web_app/background_color=Color(0.19215687, 0.42352942, 1, 1)
|
||||
threads/emscripten_pool_size=8
|
||||
threads/godot_pool_size=4
|
||||
235
scripts/build_web.bat
Normal file
235
scripts/build_web.bat
Normal file
@@ -0,0 +1,235 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo ========================================
|
||||
echo 鲸鱼镇 Web版本导出工具 v1.0
|
||||
echo ========================================
|
||||
echo.
|
||||
|
||||
REM 配置变量 - 请根据实际情况修改
|
||||
set "PROJECT_NAME=whaleTown"
|
||||
set "BUILD_DIR=build\web"
|
||||
set "GODOT_PATH=D:\technology\biancheng\Godot\Godot_v4.5.1-stable_win64.exe"
|
||||
set "EXPORT_PRESET=Web"
|
||||
set "VERSION=1.0.0"
|
||||
|
||||
REM 颜色代码(Windows 10+)
|
||||
set "RED=[91m"
|
||||
set "GREEN=[92m"
|
||||
set "YELLOW=[93m"
|
||||
set "BLUE=[94m"
|
||||
set "RESET=[0m"
|
||||
|
||||
REM 检查Godot是否存在
|
||||
echo %BLUE%[检查]%RESET% 验证Godot安装...
|
||||
if not exist "%GODOT_PATH%" (
|
||||
echo %RED%[错误]%RESET% 未找到Godot可执行文件: %GODOT_PATH%
|
||||
echo 请修改脚本中的GODOT_PATH变量或安装Godot 4.5+
|
||||
echo 下载地址: https://godotengine.org/download
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 检查项目文件
|
||||
echo %BLUE%[检查]%RESET% 验证项目文件...
|
||||
if not exist "project.godot" (
|
||||
echo %RED%[错误]%RESET% 未找到project.godot文件!
|
||||
echo 请在项目根目录运行此脚本
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 显示项目信息
|
||||
echo %GREEN%[信息]%RESET% 项目信息:
|
||||
echo 项目名称: %PROJECT_NAME%
|
||||
echo 版本号: %VERSION%
|
||||
echo Godot路径: %GODOT_PATH%
|
||||
echo 导出预设: %EXPORT_PRESET%
|
||||
echo 输出目录: %BUILD_DIR%
|
||||
echo.
|
||||
|
||||
REM 创建构建目录结构
|
||||
echo %BLUE%[构建]%RESET% 准备构建环境...
|
||||
if not exist "build" mkdir "build"
|
||||
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
|
||||
if not exist "scripts" mkdir "scripts"
|
||||
|
||||
REM 备份旧版本(如果存在)
|
||||
if exist "%BUILD_DIR%\index.html" (
|
||||
echo %YELLOW%[备份]%RESET% 备份旧版本...
|
||||
set "BACKUP_DIR=build\backup\%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%"
|
||||
set "BACKUP_DIR=!BACKUP_DIR: =0!"
|
||||
mkdir "!BACKUP_DIR!" 2>nul
|
||||
xcopy "%BUILD_DIR%\*" "!BACKUP_DIR%\" /Y /Q >nul 2>&1
|
||||
echo 备份位置: !BACKUP_DIR!\
|
||||
)
|
||||
|
||||
REM 清理旧文件
|
||||
echo %BLUE%[清理]%RESET% 清理旧的导出文件...
|
||||
if exist "%BUILD_DIR%\*" del /q "%BUILD_DIR%\*" >nul 2>&1
|
||||
|
||||
REM 检查导出预设
|
||||
echo %BLUE%[验证]%RESET% 检查导出预设...
|
||||
"%GODOT_PATH%" --headless --export-debug "%EXPORT_PRESET%" --check-only >nul 2>&1
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo %RED%[错误]%RESET% 导出预设 "%EXPORT_PRESET%" 不存在或配置错误!
|
||||
echo 请在Godot编辑器中创建Web导出预设
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 导出项目
|
||||
echo %GREEN%[导出]%RESET% 开始导出Web版本...
|
||||
echo 目标文件: %BUILD_DIR%\index.html
|
||||
echo 请稍候...
|
||||
echo.
|
||||
|
||||
"%GODOT_PATH%" --headless --export-release "%EXPORT_PRESET%" "%BUILD_DIR%\index.html"
|
||||
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo %RED%[失败]%RESET% 导出失败!错误代码: %ERRORLEVEL%
|
||||
echo.
|
||||
echo 可能的原因:
|
||||
echo 1. 导出模板未安装
|
||||
echo 2. 项目配置错误
|
||||
echo 3. 资源文件损坏
|
||||
echo.
|
||||
pause
|
||||
exit /b %ERRORLEVEL%
|
||||
)
|
||||
|
||||
REM 验证导出文件
|
||||
echo %BLUE%[验证]%RESET% 验证导出文件...
|
||||
set "REQUIRED_FILES=index.html index.js index.wasm index.pck"
|
||||
set "MISSING_FILES="
|
||||
|
||||
for %%f in (%REQUIRED_FILES%) do (
|
||||
if not exist "%BUILD_DIR%\%%f" (
|
||||
set "MISSING_FILES=!MISSING_FILES! %%f"
|
||||
)
|
||||
)
|
||||
|
||||
if not "!MISSING_FILES!"=="" (
|
||||
echo %RED%[错误]%RESET% 缺少必要文件:!MISSING_FILES!
|
||||
echo 导出可能不完整,请检查Godot配置
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 复制额外资源
|
||||
echo %BLUE%[复制]%RESET% 复制额外资源...
|
||||
if exist "assets\web\favicon.ico" copy "assets\web\favicon.ico" "%BUILD_DIR%\" >nul 2>&1
|
||||
if exist "assets\web\manifest.json" copy "assets\web\manifest.json" "%BUILD_DIR%\" >nul 2>&1
|
||||
if exist "assets\web\service-worker.js" copy "assets\web\service-worker.js" "%BUILD_DIR%\" >nul 2>&1
|
||||
if exist "assets\web\custom_shell.html" copy "assets\web\custom_shell.html" "%BUILD_DIR%\" >nul 2>&1
|
||||
|
||||
REM 生成部署信息
|
||||
echo %BLUE%[生成]%RESET% 生成部署信息...
|
||||
(
|
||||
echo {
|
||||
echo "project": "%PROJECT_NAME%",
|
||||
echo "version": "%VERSION%",
|
||||
echo "build_time": "%date% %time%",
|
||||
echo "platform": "web",
|
||||
echo "godot_version": "4.5",
|
||||
echo "export_preset": "%EXPORT_PRESET%",
|
||||
echo "build_machine": "%COMPUTERNAME%",
|
||||
echo "build_user": "%USERNAME%"
|
||||
echo }
|
||||
) > "%BUILD_DIR%\deploy_info.json"
|
||||
|
||||
REM 生成.htaccess文件
|
||||
echo %BLUE%[配置]%RESET% 生成Apache配置文件...
|
||||
(
|
||||
echo # 鲸鱼镇 Web版本 Apache配置
|
||||
echo # 自动生成于 %date% %time%
|
||||
echo.
|
||||
echo # MIME类型配置
|
||||
echo AddType application/wasm .wasm
|
||||
echo AddType application/octet-stream .pck
|
||||
echo AddType application/javascript .js
|
||||
echo.
|
||||
echo # 启用压缩
|
||||
echo ^<IfModule mod_deflate.c^>
|
||||
echo AddOutputFilterByType DEFLATE text/html text/css application/javascript application/wasm
|
||||
echo AddOutputFilterByType DEFLATE application/json application/xml
|
||||
echo ^</IfModule^>
|
||||
echo.
|
||||
echo # 缓存控制
|
||||
echo ^<IfModule mod_expires.c^>
|
||||
echo ExpiresActive On
|
||||
echo ExpiresByType application/wasm "access plus 1 month"
|
||||
echo ExpiresByType application/octet-stream "access plus 1 month"
|
||||
echo ExpiresByType application/javascript "access plus 1 week"
|
||||
echo ExpiresByType text/html "access plus 1 hour"
|
||||
echo ^</IfModule^>
|
||||
echo.
|
||||
echo # CORS配置
|
||||
echo ^<IfModule mod_headers.c^>
|
||||
echo Header set Access-Control-Allow-Origin "*"
|
||||
echo Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
|
||||
echo Header set Access-Control-Allow-Headers "Content-Type, Authorization"
|
||||
echo Header set Cross-Origin-Embedder-Policy "require-corp"
|
||||
echo Header set Cross-Origin-Opener-Policy "same-origin"
|
||||
echo ^</IfModule^>
|
||||
) > "%BUILD_DIR%\.htaccess"
|
||||
|
||||
REM 计算文件大小
|
||||
echo %BLUE%[统计]%RESET% 计算文件大小...
|
||||
set "TOTAL_SIZE=0"
|
||||
for %%f in ("%BUILD_DIR%\*") do (
|
||||
set /a "TOTAL_SIZE+=%%~zf"
|
||||
)
|
||||
set /a "TOTAL_MB=TOTAL_SIZE/1024/1024"
|
||||
|
||||
REM 显示构建结果
|
||||
echo.
|
||||
echo ========================================
|
||||
echo %GREEN% 导出成功!%RESET%
|
||||
echo ========================================
|
||||
echo.
|
||||
echo %GREEN%[完成]%RESET% 构建统计:
|
||||
echo 导出位置: %BUILD_DIR%\
|
||||
echo 总文件大小: %TOTAL_MB% MB
|
||||
echo 构建时间: %date% %time%
|
||||
echo.
|
||||
echo %BLUE%[文件]%RESET% 导出文件列表:
|
||||
for %%f in ("%BUILD_DIR%\*") do (
|
||||
set "size=%%~zf"
|
||||
set /a "size_mb=!size!/1024/1024"
|
||||
if !size_mb! gtr 0 (
|
||||
echo %%~nxf: !size_mb! MB
|
||||
) else (
|
||||
set /a "size_kb=!size!/1024"
|
||||
echo %%~nxf: !size_kb! KB
|
||||
)
|
||||
)
|
||||
|
||||
echo.
|
||||
echo %YELLOW%[下一步]%RESET% 部署选项:
|
||||
echo 1. 本地测试: scripts\serve_web.bat
|
||||
echo 2. 上传到服务器: 将 %BUILD_DIR%\ 目录上传
|
||||
echo 3. 查看文档: docs\web_deployment_guide.md
|
||||
echo.
|
||||
echo %GREEN%[提示]%RESET% 部署前请确保:
|
||||
echo - 服务器支持WASM MIME类型
|
||||
echo - 配置了正确的CORS头
|
||||
echo - 启用了文件压缩
|
||||
echo.
|
||||
|
||||
REM 询问是否启动本地服务器
|
||||
set /p "START_SERVER=是否启动本地测试服务器?(y/N): "
|
||||
if /i "!START_SERVER!"=="y" (
|
||||
echo.
|
||||
echo %GREEN%[启动]%RESET% 启动本地服务器...
|
||||
call "scripts\serve_web.bat"
|
||||
) else (
|
||||
echo.
|
||||
echo 构建完成!可以手动运行 scripts\serve_web.bat 进行测试
|
||||
)
|
||||
|
||||
pause
|
||||
238
scripts/build_web.sh
Normal file
238
scripts/build_web.sh
Normal file
@@ -0,0 +1,238 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 鲸鱼镇 Web版本导出工具 (Linux/macOS)
|
||||
# 版本: 1.0.0
|
||||
|
||||
# 颜色定义
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 配置变量 - 请根据实际情况修改
|
||||
PROJECT_NAME="whaleTown"
|
||||
BUILD_DIR="build/web"
|
||||
GODOT_PATH="/usr/local/bin/godot" # macOS Homebrew默认路径
|
||||
# GODOT_PATH="/usr/bin/godot" # Linux包管理器默认路径
|
||||
# GODOT_PATH="$HOME/Applications/Godot.app/Contents/MacOS/Godot" # macOS应用程序路径
|
||||
EXPORT_PRESET="Web"
|
||||
VERSION="1.0.0"
|
||||
|
||||
echo "========================================"
|
||||
echo " 鲸鱼镇 Web版本导出工具 v1.0"
|
||||
echo "========================================"
|
||||
echo
|
||||
|
||||
# 检查Godot是否存在
|
||||
echo -e "${BLUE}[检查]${NC} 验证Godot安装..."
|
||||
if [ ! -f "$GODOT_PATH" ]; then
|
||||
echo -e "${RED}[错误]${NC} 未找到Godot: $GODOT_PATH"
|
||||
echo
|
||||
echo "请修改脚本中的GODOT_PATH变量或安装Godot 4.5+"
|
||||
echo "安装方法:"
|
||||
echo " macOS: brew install godot"
|
||||
echo " Ubuntu: sudo apt install godot3"
|
||||
echo " 或从官网下载: https://godotengine.org/download"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查项目文件
|
||||
echo -e "${BLUE}[检查]${NC} 验证项目文件..."
|
||||
if [ ! -f "project.godot" ]; then
|
||||
echo -e "${RED}[错误]${NC} 未找到project.godot文件!"
|
||||
echo "请在项目根目录运行此脚本"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 显示项目信息
|
||||
echo -e "${GREEN}[信息]${NC} 项目信息:"
|
||||
echo " 项目名称: $PROJECT_NAME"
|
||||
echo " 版本号: $VERSION"
|
||||
echo " Godot路径: $GODOT_PATH"
|
||||
echo " 导出预设: $EXPORT_PRESET"
|
||||
echo " 输出目录: $BUILD_DIR"
|
||||
echo
|
||||
|
||||
# 创建构建目录结构
|
||||
echo -e "${BLUE}[构建]${NC} 准备构建环境..."
|
||||
mkdir -p "$BUILD_DIR"
|
||||
mkdir -p "scripts"
|
||||
|
||||
# 备份旧版本(如果存在)
|
||||
if [ -f "$BUILD_DIR/index.html" ]; then
|
||||
echo -e "${YELLOW}[备份]${NC} 备份旧版本..."
|
||||
BACKUP_DIR="build/backup/$(date +%Y%m%d_%H%M%S)"
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
cp -r "$BUILD_DIR"/* "$BACKUP_DIR/" 2>/dev/null
|
||||
echo " 备份位置: $BACKUP_DIR/"
|
||||
fi
|
||||
|
||||
# 清理旧文件
|
||||
echo -e "${BLUE}[清理]${NC} 清理旧的导出文件..."
|
||||
rm -f "$BUILD_DIR"/*
|
||||
|
||||
# 检查导出预设
|
||||
echo -e "${BLUE}[验证]${NC} 检查导出预设..."
|
||||
"$GODOT_PATH" --headless --export-debug "$EXPORT_PRESET" --check-only >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}[错误]${NC} 导出预设 \"$EXPORT_PRESET\" 不存在或配置错误!"
|
||||
echo "请在Godot编辑器中创建Web导出预设"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 导出项目
|
||||
echo -e "${GREEN}[导出]${NC} 开始导出Web版本..."
|
||||
echo " 目标文件: $BUILD_DIR/index.html"
|
||||
echo " 请稍候..."
|
||||
echo
|
||||
|
||||
"$GODOT_PATH" --headless --export-release "$EXPORT_PRESET" "$BUILD_DIR/index.html"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}[失败]${NC} 导出失败!"
|
||||
echo
|
||||
echo "可能的原因:"
|
||||
echo "1. 导出模板未安装"
|
||||
echo "2. 项目配置错误"
|
||||
echo "3. 资源文件损坏"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 验证导出文件
|
||||
echo -e "${BLUE}[验证]${NC} 验证导出文件..."
|
||||
REQUIRED_FILES="index.html index.js index.wasm index.pck"
|
||||
MISSING_FILES=""
|
||||
|
||||
for file in $REQUIRED_FILES; do
|
||||
if [ ! -f "$BUILD_DIR/$file" ]; then
|
||||
MISSING_FILES="$MISSING_FILES $file"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$MISSING_FILES" ]; then
|
||||
echo -e "${RED}[错误]${NC} 缺少必要文件:$MISSING_FILES"
|
||||
echo "导出可能不完整,请检查Godot配置"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 复制额外资源
|
||||
echo -e "${BLUE}[复制]${NC} 复制额外资源..."
|
||||
[ -f "assets/web/favicon.ico" ] && cp "assets/web/favicon.ico" "$BUILD_DIR/"
|
||||
[ -f "assets/web/manifest.json" ] && cp "assets/web/manifest.json" "$BUILD_DIR/"
|
||||
[ -f "assets/web/service-worker.js" ] && cp "assets/web/service-worker.js" "$BUILD_DIR/"
|
||||
[ -f "assets/web/custom_shell.html" ] && cp "assets/web/custom_shell.html" "$BUILD_DIR/"
|
||||
|
||||
# 生成部署信息
|
||||
echo -e "${BLUE}[生成]${NC} 生成部署信息..."
|
||||
cat > "$BUILD_DIR/deploy_info.json" << EOF
|
||||
{
|
||||
"project": "$PROJECT_NAME",
|
||||
"version": "$VERSION",
|
||||
"build_time": "$(date)",
|
||||
"platform": "web",
|
||||
"godot_version": "4.5",
|
||||
"export_preset": "$EXPORT_PRESET",
|
||||
"build_machine": "$(hostname)",
|
||||
"build_user": "$(whoami)",
|
||||
"build_os": "$(uname -s)"
|
||||
}
|
||||
EOF
|
||||
|
||||
# 生成.htaccess文件
|
||||
echo -e "${BLUE}[配置]${NC} 生成Apache配置文件..."
|
||||
cat > "$BUILD_DIR/.htaccess" << 'EOF'
|
||||
# 鲸鱼镇 Web版本 Apache配置
|
||||
# 自动生成
|
||||
|
||||
# MIME类型配置
|
||||
AddType application/wasm .wasm
|
||||
AddType application/octet-stream .pck
|
||||
AddType application/javascript .js
|
||||
|
||||
# 启用压缩
|
||||
<IfModule mod_deflate.c>
|
||||
AddOutputFilterByType DEFLATE text/html text/css application/javascript application/wasm
|
||||
AddOutputFilterByType DEFLATE application/json application/xml
|
||||
</IfModule>
|
||||
|
||||
# 缓存控制
|
||||
<IfModule mod_expires.c>
|
||||
ExpiresActive On
|
||||
ExpiresByType application/wasm "access plus 1 month"
|
||||
ExpiresByType application/octet-stream "access plus 1 month"
|
||||
ExpiresByType application/javascript "access plus 1 week"
|
||||
ExpiresByType text/html "access plus 1 hour"
|
||||
</IfModule>
|
||||
|
||||
# CORS配置
|
||||
<IfModule mod_headers.c>
|
||||
Header set Access-Control-Allow-Origin "*"
|
||||
Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
|
||||
Header set Access-Control-Allow-Headers "Content-Type, Authorization"
|
||||
Header set Cross-Origin-Embedder-Policy "require-corp"
|
||||
Header set Cross-Origin-Opener-Policy "same-origin"
|
||||
</IfModule>
|
||||
EOF
|
||||
|
||||
# 计算文件大小
|
||||
echo -e "${BLUE}[统计]${NC} 计算文件大小..."
|
||||
TOTAL_SIZE=$(du -sb "$BUILD_DIR" | cut -f1)
|
||||
TOTAL_MB=$((TOTAL_SIZE / 1024 / 1024))
|
||||
|
||||
# 显示构建结果
|
||||
echo
|
||||
echo "========================================"
|
||||
echo -e "${GREEN} 导出成功!${NC}"
|
||||
echo "========================================"
|
||||
echo
|
||||
echo -e "${GREEN}[完成]${NC} 构建统计:"
|
||||
echo " 导出位置: $BUILD_DIR/"
|
||||
echo " 总文件大小: ${TOTAL_MB} MB"
|
||||
echo " 构建时间: $(date)"
|
||||
echo
|
||||
|
||||
echo -e "${BLUE}[文件]${NC} 导出文件列表:"
|
||||
for file in "$BUILD_DIR"/*; do
|
||||
if [ -f "$file" ]; then
|
||||
filename=$(basename "$file")
|
||||
size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null)
|
||||
size_mb=$((size / 1024 / 1024))
|
||||
if [ $size_mb -gt 0 ]; then
|
||||
echo " $filename: ${size_mb} MB"
|
||||
else
|
||||
size_kb=$((size / 1024))
|
||||
echo " $filename: ${size_kb} KB"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo
|
||||
echo -e "${YELLOW}[下一步]${NC} 部署选项:"
|
||||
echo " 1. 本地测试: ./scripts/serve_web.sh"
|
||||
echo " 2. 上传到服务器: 将 $BUILD_DIR/ 目录上传"
|
||||
echo " 3. 查看文档: docs/web_deployment_guide.md"
|
||||
echo
|
||||
|
||||
echo -e "${GREEN}[提示]${NC} 部署前请确保:"
|
||||
echo " - 服务器支持WASM MIME类型"
|
||||
echo " - 配置了正确的CORS头"
|
||||
echo " - 启用了文件压缩"
|
||||
echo
|
||||
|
||||
# 询问是否启动本地服务器
|
||||
echo -n "是否启动本地测试服务器?(y/N): "
|
||||
read -r START_SERVER
|
||||
if [[ $START_SERVER =~ ^[Yy]$ ]]; then
|
||||
echo
|
||||
echo -e "${GREEN}[启动]${NC} 启动本地服务器..."
|
||||
./scripts/serve_web.sh
|
||||
else
|
||||
echo
|
||||
echo "构建完成!可以手动运行 ./scripts/serve_web.sh 进行测试"
|
||||
fi
|
||||
173
scripts/serve_web.bat
Normal file
173
scripts/serve_web.bat
Normal file
@@ -0,0 +1,173 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo ========================================
|
||||
echo 鲸鱼镇 本地Web服务器 v1.0
|
||||
echo ========================================
|
||||
echo.
|
||||
|
||||
REM 配置变量
|
||||
set "BUILD_DIR=build\web"
|
||||
set "PORT=8000"
|
||||
set "FALLBACK_PORT=8080"
|
||||
|
||||
REM 颜色代码
|
||||
set "RED=[91m"
|
||||
set "GREEN=[92m"
|
||||
set "YELLOW=[93m"
|
||||
set "BLUE=[94m"
|
||||
set "RESET=[0m"
|
||||
|
||||
REM 检查导出文件
|
||||
echo %BLUE%[检查]%RESET% 验证Web导出文件...
|
||||
if not exist "%BUILD_DIR%\index.html" (
|
||||
echo %RED%[错误]%RESET% 未找到Web导出文件!
|
||||
echo.
|
||||
echo 请先运行以下命令导出项目:
|
||||
echo scripts\build_web.bat
|
||||
echo.
|
||||
echo 或在Godot编辑器中导出Web版本到: %BUILD_DIR%\
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 检查必要文件
|
||||
echo %BLUE%[验证]%RESET% 检查必要文件...
|
||||
set "REQUIRED_FILES=index.html index.js index.wasm index.pck"
|
||||
set "MISSING_FILES="
|
||||
|
||||
for %%f in (%REQUIRED_FILES%) do (
|
||||
if not exist "%BUILD_DIR%\%%f" (
|
||||
set "MISSING_FILES=!MISSING_FILES! %%f"
|
||||
)
|
||||
)
|
||||
|
||||
if not "!MISSING_FILES!"=="" (
|
||||
echo %RED%[错误]%RESET% 缺少必要文件:!MISSING_FILES!
|
||||
echo 请重新导出项目
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 检查Python
|
||||
echo %BLUE%[检查]%RESET% 验证Python环境...
|
||||
python --version >nul 2>&1
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo %RED%[错误]%RESET% 未找到Python!
|
||||
echo.
|
||||
echo 请安装Python 3.x:
|
||||
echo 下载地址: https://python.org/downloads
|
||||
echo 或使用包管理器: winget install Python.Python.3
|
||||
echo.
|
||||
echo 安装后请重启命令提示符
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 获取Python版本
|
||||
for /f "tokens=2" %%i in ('python --version 2^>^&1') do set "PYTHON_VERSION=%%i"
|
||||
echo %GREEN%[信息]%RESET% Python版本: %PYTHON_VERSION%
|
||||
|
||||
REM 显示文件信息
|
||||
echo.
|
||||
echo %GREEN%[信息]%RESET% Web文件统计:
|
||||
set "TOTAL_SIZE=0"
|
||||
for %%f in ("%BUILD_DIR%\*") do (
|
||||
set "size=%%~zf"
|
||||
set /a "TOTAL_SIZE+=size"
|
||||
set /a "size_mb=size/1024/1024"
|
||||
if !size_mb! gtr 0 (
|
||||
echo %%~nxf: !size_mb! MB
|
||||
) else (
|
||||
set /a "size_kb=size/1024"
|
||||
echo %%~nxf: !size_kb! KB
|
||||
)
|
||||
)
|
||||
set /a "TOTAL_MB=TOTAL_SIZE/1024/1024"
|
||||
echo 总大小: %TOTAL_MB% MB
|
||||
|
||||
REM 检查端口占用
|
||||
echo.
|
||||
echo %BLUE%[网络]%RESET% 检查端口占用...
|
||||
netstat -an | find ":%PORT%" >nul 2>&1
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
echo %YELLOW%[警告]%RESET% 端口 %PORT% 已被占用,尝试使用 %FALLBACK_PORT%
|
||||
set "PORT=%FALLBACK_PORT%"
|
||||
|
||||
netstat -an | find ":%PORT%" >nul 2>&1
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
echo %RED%[错误]%RESET% 端口 %PORT% 也被占用!
|
||||
echo 请手动指定端口: python -m http.server [端口号]
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
REM 获取本机IP地址
|
||||
for /f "tokens=2 delims=:" %%i in ('ipconfig ^| find "IPv4"') do (
|
||||
set "LOCAL_IP=%%i"
|
||||
set "LOCAL_IP=!LOCAL_IP: =!"
|
||||
goto :ip_found
|
||||
)
|
||||
:ip_found
|
||||
|
||||
REM 显示启动信息
|
||||
echo.
|
||||
echo %GREEN%[启动]%RESET% 启动HTTP服务器...
|
||||
echo 端口: %PORT%
|
||||
echo 目录: %BUILD_DIR%
|
||||
echo Python: %PYTHON_VERSION%
|
||||
echo.
|
||||
echo ========================================
|
||||
echo %GREEN% 访问地址%RESET%
|
||||
echo ========================================
|
||||
echo 本地访问: http://localhost:%PORT%
|
||||
echo 局域网访问: http://!LOCAL_IP!:%PORT%
|
||||
echo.
|
||||
echo %YELLOW%[控制]%RESET% 服务器控制:
|
||||
echo 停止服务器: Ctrl+C
|
||||
echo 重启服务器: 关闭后重新运行脚本
|
||||
echo.
|
||||
echo %BLUE%[调试]%RESET% 调试工具:
|
||||
echo 开发者工具: F12
|
||||
echo 控制台日志: 查看浏览器Console
|
||||
echo 网络请求: 查看Network标签
|
||||
echo.
|
||||
echo ========================================
|
||||
|
||||
REM 尝试自动打开浏览器
|
||||
echo %BLUE%[浏览器]%RESET% 尝试打开默认浏览器...
|
||||
start http://localhost:%PORT% >nul 2>&1
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo %YELLOW%[提示]%RESET% 无法自动打开浏览器,请手动访问上述地址
|
||||
)
|
||||
|
||||
echo.
|
||||
echo %GREEN%[就绪]%RESET% 服务器启动中...
|
||||
echo.
|
||||
|
||||
REM 切换到构建目录并启动服务器
|
||||
cd "%BUILD_DIR%"
|
||||
|
||||
REM 创建简单的服务器日志
|
||||
echo [%date% %time%] 服务器启动 - 端口:%PORT% >> server.log
|
||||
|
||||
REM 启动Python HTTP服务器
|
||||
python -m http.server %PORT%
|
||||
|
||||
REM 服务器停止后的清理
|
||||
echo.
|
||||
echo %YELLOW%[停止]%RESET% 服务器已停止
|
||||
echo [%date% %time%] 服务器停止 >> server.log
|
||||
|
||||
REM 返回原目录
|
||||
cd ..\..
|
||||
|
||||
echo.
|
||||
echo %GREEN%[完成]%RESET% 感谢使用鲸鱼镇Web服务器!
|
||||
echo.
|
||||
pause
|
||||
188
scripts/serve_web.sh
Normal file
188
scripts/serve_web.sh
Normal file
@@ -0,0 +1,188 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 鲸鱼镇 本地Web服务器 (Linux/macOS)
|
||||
# 版本: 1.0.0
|
||||
|
||||
# 颜色定义
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 配置变量
|
||||
BUILD_DIR="build/web"
|
||||
PORT=8000
|
||||
FALLBACK_PORT=8080
|
||||
|
||||
echo "========================================"
|
||||
echo " 鲸鱼镇 本地Web服务器 v1.0"
|
||||
echo "========================================"
|
||||
echo
|
||||
|
||||
# 检查导出文件
|
||||
echo -e "${BLUE}[检查]${NC} 验证Web导出文件..."
|
||||
if [ ! -f "$BUILD_DIR/index.html" ]; then
|
||||
echo -e "${RED}[错误]${NC} 未找到Web导出文件!"
|
||||
echo
|
||||
echo "请先运行以下命令导出项目:"
|
||||
echo " ./scripts/build_web.sh"
|
||||
echo
|
||||
echo "或在Godot编辑器中导出Web版本到: $BUILD_DIR/"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查必要文件
|
||||
echo -e "${BLUE}[验证]${NC} 检查必要文件..."
|
||||
REQUIRED_FILES="index.html index.js index.wasm index.pck"
|
||||
MISSING_FILES=""
|
||||
|
||||
for file in $REQUIRED_FILES; do
|
||||
if [ ! -f "$BUILD_DIR/$file" ]; then
|
||||
MISSING_FILES="$MISSING_FILES $file"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$MISSING_FILES" ]; then
|
||||
echo -e "${RED}[错误]${NC} 缺少必要文件:$MISSING_FILES"
|
||||
echo "请重新导出项目"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查Python
|
||||
echo -e "${BLUE}[检查]${NC} 验证Python环境..."
|
||||
if ! command -v python3 &> /dev/null && ! command -v python &> /dev/null; then
|
||||
echo -e "${RED}[错误]${NC} 未找到Python!"
|
||||
echo
|
||||
echo "请安装Python 3.x:"
|
||||
echo " macOS: brew install python"
|
||||
echo " Ubuntu: sudo apt install python3"
|
||||
echo " 或访问: https://python.org/downloads"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 确定Python命令
|
||||
PYTHON_CMD="python3"
|
||||
if ! command -v python3 &> /dev/null; then
|
||||
PYTHON_CMD="python"
|
||||
fi
|
||||
|
||||
# 获取Python版本
|
||||
PYTHON_VERSION=$($PYTHON_CMD --version 2>&1 | cut -d' ' -f2)
|
||||
echo -e "${GREEN}[信息]${NC} Python版本: $PYTHON_VERSION"
|
||||
|
||||
# 显示文件信息
|
||||
echo
|
||||
echo -e "${GREEN}[信息]${NC} Web文件统计:"
|
||||
TOTAL_SIZE=$(du -sb "$BUILD_DIR" | cut -f1)
|
||||
TOTAL_MB=$((TOTAL_SIZE / 1024 / 1024))
|
||||
|
||||
for file in "$BUILD_DIR"/*; do
|
||||
if [ -f "$file" ]; then
|
||||
filename=$(basename "$file")
|
||||
size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null)
|
||||
size_mb=$((size / 1024 / 1024))
|
||||
if [ $size_mb -gt 0 ]; then
|
||||
echo " $filename: ${size_mb} MB"
|
||||
else
|
||||
size_kb=$((size / 1024))
|
||||
echo " $filename: ${size_kb} KB"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo " 总大小: ${TOTAL_MB} MB"
|
||||
|
||||
# 检查端口占用
|
||||
echo
|
||||
echo -e "${BLUE}[网络]${NC} 检查端口占用..."
|
||||
if lsof -Pi :$PORT -sTCP:LISTEN -t >/dev/null 2>&1; then
|
||||
echo -e "${YELLOW}[警告]${NC} 端口 $PORT 已被占用,尝试使用 $FALLBACK_PORT"
|
||||
PORT=$FALLBACK_PORT
|
||||
|
||||
if lsof -Pi :$PORT -sTCP:LISTEN -t >/dev/null 2>&1; then
|
||||
echo -e "${RED}[错误]${NC} 端口 $PORT 也被占用!"
|
||||
echo "请手动指定端口: $PYTHON_CMD -m http.server [端口号]"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# 获取本机IP地址
|
||||
LOCAL_IP=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -1)
|
||||
if [ -z "$LOCAL_IP" ]; then
|
||||
LOCAL_IP=$(hostname -I | cut -d' ' -f1 2>/dev/null)
|
||||
fi
|
||||
if [ -z "$LOCAL_IP" ]; then
|
||||
LOCAL_IP="localhost"
|
||||
fi
|
||||
|
||||
# 显示启动信息
|
||||
echo
|
||||
echo -e "${GREEN}[启动]${NC} 启动HTTP服务器..."
|
||||
echo " 端口: $PORT"
|
||||
echo " 目录: $BUILD_DIR"
|
||||
echo " Python: $PYTHON_VERSION"
|
||||
echo
|
||||
|
||||
echo "========================================"
|
||||
echo -e "${GREEN} 访问地址${NC}"
|
||||
echo "========================================"
|
||||
echo " 本地访问: http://localhost:$PORT"
|
||||
echo " 局域网访问: http://$LOCAL_IP:$PORT"
|
||||
echo
|
||||
|
||||
echo -e "${YELLOW}[控制]${NC} 服务器控制:"
|
||||
echo " 停止服务器: Ctrl+C"
|
||||
echo " 重启服务器: 关闭后重新运行脚本"
|
||||
echo
|
||||
|
||||
echo -e "${BLUE}[调试]${NC} 调试工具:"
|
||||
echo " 开发者工具: F12"
|
||||
echo " 控制台日志: 查看浏览器Console"
|
||||
echo " 网络请求: 查看Network标签"
|
||||
echo
|
||||
|
||||
echo "========================================"
|
||||
|
||||
# 尝试自动打开浏览器
|
||||
echo -e "${BLUE}[浏览器]${NC} 尝试打开默认浏览器..."
|
||||
if command -v open &> /dev/null; then
|
||||
# macOS
|
||||
open "http://localhost:$PORT" 2>/dev/null
|
||||
elif command -v xdg-open &> /dev/null; then
|
||||
# Linux
|
||||
xdg-open "http://localhost:$PORT" 2>/dev/null
|
||||
else
|
||||
echo -e "${YELLOW}[提示]${NC} 无法自动打开浏览器,请手动访问上述地址"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo -e "${GREEN}[就绪]${NC} 服务器启动中..."
|
||||
echo
|
||||
|
||||
# 切换到构建目录并启动服务器
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
# 创建简单的服务器日志
|
||||
echo "[$(date)] 服务器启动 - 端口:$PORT" >> server.log
|
||||
|
||||
# 设置信号处理
|
||||
trap 'echo -e "\n${YELLOW}[停止]${NC} 服务器已停止"; echo "[$(date)] 服务器停止" >> server.log; exit 0' INT
|
||||
|
||||
# 启动Python HTTP服务器
|
||||
$PYTHON_CMD -m http.server $PORT
|
||||
|
||||
# 服务器停止后的清理
|
||||
echo
|
||||
echo -e "${YELLOW}[停止]${NC} 服务器已停止"
|
||||
echo "[$(date)] 服务器停止" >> server.log
|
||||
|
||||
# 返回原目录
|
||||
cd ../..
|
||||
|
||||
echo
|
||||
echo -e "${GREEN}[完成]${NC} 感谢使用鲸鱼镇Web服务器!"
|
||||
echo
|
||||
BIN
web_assets/index.144x144.png
Normal file
BIN
web_assets/index.144x144.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
40
web_assets/index.144x144.png.import
Normal file
40
web_assets/index.144x144.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://uf8drvqidoi0"
|
||||
path="res://.godot/imported/index.144x144.png-0d5b24e0c76fefb9d754f032ac858a25.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://web_assets/index.144x144.png"
|
||||
dest_files=["res://.godot/imported/index.144x144.png-0d5b24e0c76fefb9d754f032ac858a25.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
web_assets/index.180x180.png
Normal file
BIN
web_assets/index.180x180.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
40
web_assets/index.180x180.png.import
Normal file
40
web_assets/index.180x180.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://d06i73eh8o16l"
|
||||
path="res://.godot/imported/index.180x180.png-bacb5004c344d341977d8297b824924e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://web_assets/index.180x180.png"
|
||||
dest_files=["res://.godot/imported/index.180x180.png-bacb5004c344d341977d8297b824924e.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
web_assets/index.512x512.png
Normal file
BIN
web_assets/index.512x512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
40
web_assets/index.512x512.png.import
Normal file
40
web_assets/index.512x512.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bugrvdm26up5g"
|
||||
path="res://.godot/imported/index.512x512.png-efc23e90264d95a2448c6ba710e02cd3.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://web_assets/index.512x512.png"
|
||||
dest_files=["res://.godot/imported/index.512x512.png-efc23e90264d95a2448c6ba710e02cd3.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
web_assets/index.apple-touch-icon.png
Normal file
BIN
web_assets/index.apple-touch-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
40
web_assets/index.apple-touch-icon.png.import
Normal file
40
web_assets/index.apple-touch-icon.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bghq8uhuguae7"
|
||||
path="res://.godot/imported/index.apple-touch-icon.png-0c47f79c975cb77ea5a20ae9b7487b23.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://web_assets/index.apple-touch-icon.png"
|
||||
dest_files=["res://.godot/imported/index.apple-touch-icon.png-0c47f79c975cb77ea5a20ae9b7487b23.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
66
web_assets/index.audio.position.worklet.js
Normal file
66
web_assets/index.audio.position.worklet.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/**************************************************************************/
|
||||
/* 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);
|
||||
213
web_assets/index.audio.worklet.js
Normal file
213
web_assets/index.audio.worklet.js
Normal file
@@ -0,0 +1,213 @@
|
||||
/**************************************************************************/
|
||||
/* 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);
|
||||
221
web_assets/index.html
Normal file
221
web_assets/index.html
Normal file
@@ -0,0 +1,221 @@
|
||||
<!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>whaleTown</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: #242424;
|
||||
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="index.icon.png" />
|
||||
<link rel="apple-touch-icon" href="index.apple-touch-icon.png"/>
|
||||
<link rel="manifest" href="index.manifest.json">
|
||||
|
||||
</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--true fullsize--true use-filter--true" src="index.png" alt="">
|
||||
<progress id="status-progress"></progress>
|
||||
<div id="status-notice"></div>
|
||||
</div>
|
||||
|
||||
<script src="index.js"></script>
|
||||
<script>
|
||||
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"emscriptenPoolSize":8,"ensureCrossOriginIsolationHeaders":true,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":35119676,"index.wasm":36145869},"focusCanvas":true,"gdextensionLibs":[],"godotPoolSize":4,"serviceWorker":"index.service.worker.js"};
|
||||
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>
|
||||
|
||||
BIN
web_assets/index.icon.png
Normal file
BIN
web_assets/index.icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
40
web_assets/index.icon.png.import
Normal file
40
web_assets/index.icon.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://chcbrmqo5svb8"
|
||||
path="res://.godot/imported/index.icon.png-bcd850718c00fc2a39f7b69162877ab8.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://web_assets/index.icon.png"
|
||||
dest_files=["res://.godot/imported/index.icon.png-bcd850718c00fc2a39f7b69162877ab8.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
927
web_assets/index.js
Normal file
927
web_assets/index.js
Normal file
File diff suppressed because one or more lines are too long
1
web_assets/index.manifest.json
Normal file
1
web_assets/index.manifest.json
Normal file
@@ -0,0 +1 @@
|
||||
{"background_color":"#316cff","display":"standalone","icons":[{"sizes":"144x144","src":"index.144x144.png","type":"image/png"},{"sizes":"180x180","src":"index.180x180.png","type":"image/png"},{"sizes":"512x512","src":"index.512x512.png","type":"image/png"}],"name":"whaleTown","orientation":"any","start_url":"./index.html"}
|
||||
41
web_assets/index.offline.html
Normal file
41
web_assets/index.offline.html
Normal file
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>You are offline</title>
|
||||
<style>
|
||||
html {
|
||||
background-color: #000000;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||
margin: 2rem;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-block: 1rem;
|
||||
}
|
||||
|
||||
button {
|
||||
display: block;
|
||||
padding: 1rem 2rem;
|
||||
margin: 3rem auto 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>You are offline</h1>
|
||||
<p>This application requires an Internet connection to run for the first time.</p>
|
||||
<p>Press the button below to try reloading:</p>
|
||||
<button type="button">Reload</button>
|
||||
<script>
|
||||
document.querySelector('button').addEventListener('click', () => {
|
||||
window.location.reload();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
BIN
web_assets/index.pck
Normal file
BIN
web_assets/index.pck
Normal file
Binary file not shown.
BIN
web_assets/index.png
Normal file
BIN
web_assets/index.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
40
web_assets/index.png.import
Normal file
40
web_assets/index.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cj0tify76qrst"
|
||||
path="res://.godot/imported/index.png-d064c09a6315f5da70b1876a63391d16.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://web_assets/index.png"
|
||||
dest_files=["res://.godot/imported/index.png-d064c09a6315f5da70b1876a63391d16.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
166
web_assets/index.service.worker.js
Normal file
166
web_assets/index.service.worker.js
Normal file
@@ -0,0 +1,166 @@
|
||||
// This service worker is required to expose an exported Godot project as a
|
||||
// Progressive Web App. It provides an offline fallback page telling the user
|
||||
// that they need an Internet connection to run the project if desired.
|
||||
// Incrementing CACHE_VERSION will kick off the install event and force
|
||||
// previously cached resources to be updated from the network.
|
||||
/** @type {string} */
|
||||
const CACHE_VERSION = '1766673973|3863914';
|
||||
/** @type {string} */
|
||||
const CACHE_PREFIX = 'whaleTown-sw-cache-';
|
||||
const CACHE_NAME = CACHE_PREFIX + CACHE_VERSION;
|
||||
/** @type {string} */
|
||||
const OFFLINE_URL = 'index.offline.html';
|
||||
/** @type {boolean} */
|
||||
const ENSURE_CROSSORIGIN_ISOLATION_HEADERS = true;
|
||||
// Files that will be cached on load.
|
||||
/** @type {string[]} */
|
||||
const CACHED_FILES = ["index.html","index.js","index.offline.html","index.icon.png","index.apple-touch-icon.png","index.audio.worklet.js","index.audio.position.worklet.js"];
|
||||
// Files that we might not want the user to preload, and will only be cached on first load.
|
||||
/** @type {string[]} */
|
||||
const CACHEABLE_FILES = ["index.wasm","index.pck"];
|
||||
const FULL_CACHE = CACHED_FILES.concat(CACHEABLE_FILES);
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(caches.open(CACHE_NAME).then((cache) => cache.addAll(CACHED_FILES)));
|
||||
});
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
event.waitUntil(caches.keys().then(
|
||||
function (keys) {
|
||||
// Remove old caches.
|
||||
return Promise.all(keys.filter((key) => key.startsWith(CACHE_PREFIX) && key !== CACHE_NAME).map((key) => caches.delete(key)));
|
||||
}
|
||||
).then(function () {
|
||||
// Enable navigation preload if available.
|
||||
return ('navigationPreload' in self.registration) ? self.registration.navigationPreload.enable() : Promise.resolve();
|
||||
}));
|
||||
});
|
||||
|
||||
/**
|
||||
* Ensures that the response has the correct COEP/COOP headers
|
||||
* @param {Response} response
|
||||
* @returns {Response}
|
||||
*/
|
||||
function ensureCrossOriginIsolationHeaders(response) {
|
||||
if (response.headers.get('Cross-Origin-Embedder-Policy') === 'require-corp'
|
||||
&& response.headers.get('Cross-Origin-Opener-Policy') === 'same-origin') {
|
||||
return response;
|
||||
}
|
||||
|
||||
const crossOriginIsolatedHeaders = new Headers(response.headers);
|
||||
crossOriginIsolatedHeaders.set('Cross-Origin-Embedder-Policy', 'require-corp');
|
||||
crossOriginIsolatedHeaders.set('Cross-Origin-Opener-Policy', 'same-origin');
|
||||
const newResponse = new Response(response.body, {
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
headers: crossOriginIsolatedHeaders,
|
||||
});
|
||||
|
||||
return newResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls fetch and cache the result if it is cacheable
|
||||
* @param {FetchEvent} event
|
||||
* @param {Cache} cache
|
||||
* @param {boolean} isCacheable
|
||||
* @returns {Response}
|
||||
*/
|
||||
async function fetchAndCache(event, cache, isCacheable) {
|
||||
// Use the preloaded response, if it's there
|
||||
/** @type { Response } */
|
||||
let response = await event.preloadResponse;
|
||||
if (response == null) {
|
||||
// Or, go over network.
|
||||
response = await self.fetch(event.request);
|
||||
}
|
||||
|
||||
if (ENSURE_CROSSORIGIN_ISOLATION_HEADERS) {
|
||||
response = ensureCrossOriginIsolationHeaders(response);
|
||||
}
|
||||
|
||||
if (isCacheable) {
|
||||
// And update the cache
|
||||
cache.put(event.request, response.clone());
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
self.addEventListener(
|
||||
'fetch',
|
||||
/**
|
||||
* Triggered on fetch
|
||||
* @param {FetchEvent} event
|
||||
*/
|
||||
(event) => {
|
||||
const isNavigate = event.request.mode === 'navigate';
|
||||
const url = event.request.url || '';
|
||||
const referrer = event.request.referrer || '';
|
||||
const base = referrer.slice(0, referrer.lastIndexOf('/') + 1);
|
||||
const local = url.startsWith(base) ? url.replace(base, '') : '';
|
||||
const isCacheable = FULL_CACHE.some((v) => v === local) || (base === referrer && base.endsWith(CACHED_FILES[0]));
|
||||
if (isNavigate || isCacheable) {
|
||||
event.respondWith((async () => {
|
||||
// Try to use cache first
|
||||
const cache = await caches.open(CACHE_NAME);
|
||||
if (isNavigate) {
|
||||
// Check if we have full cache during HTML page request.
|
||||
/** @type {Response[]} */
|
||||
const fullCache = await Promise.all(FULL_CACHE.map((name) => cache.match(name)));
|
||||
const missing = fullCache.some((v) => v === undefined);
|
||||
if (missing) {
|
||||
try {
|
||||
// Try network if some cached file is missing (so we can display offline page in case).
|
||||
const response = await fetchAndCache(event, cache, isCacheable);
|
||||
return response;
|
||||
} catch (e) {
|
||||
// And return the hopefully always cached offline page in case of network failure.
|
||||
console.error('Network error: ', e); // eslint-disable-line no-console
|
||||
return caches.match(OFFLINE_URL);
|
||||
}
|
||||
}
|
||||
}
|
||||
let cached = await cache.match(event.request);
|
||||
if (cached != null) {
|
||||
if (ENSURE_CROSSORIGIN_ISOLATION_HEADERS) {
|
||||
cached = ensureCrossOriginIsolationHeaders(cached);
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
// Try network if don't have it in cache.
|
||||
const response = await fetchAndCache(event, cache, isCacheable);
|
||||
return response;
|
||||
})());
|
||||
} else if (ENSURE_CROSSORIGIN_ISOLATION_HEADERS) {
|
||||
event.respondWith((async () => {
|
||||
let response = await fetch(event.request);
|
||||
response = ensureCrossOriginIsolationHeaders(response);
|
||||
return response;
|
||||
})());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
self.addEventListener('message', (event) => {
|
||||
// No cross origin
|
||||
if (event.origin !== self.origin) {
|
||||
return;
|
||||
}
|
||||
const id = event.source.id || '';
|
||||
const msg = event.data || '';
|
||||
// Ensure it's one of our clients.
|
||||
self.clients.get(id).then(function (client) {
|
||||
if (!client) {
|
||||
return; // Not a valid client.
|
||||
}
|
||||
if (msg === 'claim') {
|
||||
self.skipWaiting().then(() => self.clients.claim());
|
||||
} else if (msg === 'clear') {
|
||||
caches.delete(CACHE_NAME);
|
||||
} else if (msg === 'update') {
|
||||
self.skipWaiting().then(() => self.clients.claim()).then(() => self.clients.matchAll()).then((all) => all.forEach((c) => c.navigate(c.url)));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
BIN
web_assets/index.wasm
Normal file
BIN
web_assets/index.wasm
Normal file
Binary file not shown.
Reference in New Issue
Block a user