Ai
1 Star 0 Fork 23

途客/Ploy3D

forked from Miaokit/Ploy3D 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.js 2.15 KB
一键复制 编辑 原始数据 按行查看 历史
Miaokit 提交于 2024-07-05 10:07 +08:00 . 初始化项目
/** 导入PLOY3D引擎。 */
import * as ploycloud from "./dist/esm/mod.js"
/** 导入应用实现[base_ui]。 */
import * as app_base_ui from "./examples/base_ui.js"
/** 需要存在Deno定义。 */
globalThis.Deno = undefined;
/**
* 入口函数。
* @param {FileSystemDirectoryHandle} fs_root 如果非未定义,则启用本地文件系统。
* @returns 返回事件处理协程。
*/
async function Main(fs_root) {
if (fs_root !== undefined) {
if (fs_root == null && window.showDirectoryPicker) {
fs_root = await (new Promise(function (resolve) {
const button = document.createElement("button");
button.innerText = "打开站点根目录";
button.style.position = "absolute";
button.style.zIndex = "999";
button.onclick = function () {
window.showDirectoryPicker({
id: "LocalFileSystem",
mode: "readwrite",
startIn: "documents"
}).then(function (root) {
document.body.removeChild(button);
resolve(root);
}).catch(function () {
if (window.confirm("确定不读写本地文件系统目录么?")) {
console.info("用户未授权读写本地文件系统目录。");
document.body.removeChild(button);
resolve(null);
}
});
};
document.body.appendChild(button);
}));
}
}
if (fs_root) {
console.info("用户已授权读写本地文件系统目录。");
}
const engine = new ploycloud.Ploy3D({
JSZip,
config: {
web: true
},
rootFS: fs_root,
appLut: {
"base_ui": app_base_ui.PloyApp_base_ui
}
});
return ploycloud.Start(engine, "base_ui", "PLOY3D引擎", 1280, 720);
}
Main(null).then(() => {
console.log("应用运行中,按ESC键结束运行 ...")
}).catch((e) => {
console.error(e);
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tuke-code/ploy3d.git
git@gitee.com:tuke-code/ploy3d.git
tuke-code
ploy3d
Ploy3D
master

搜索帮助