git auto update

This commit is contained in:
lhy6305 2025-04-18 20:40:33 +08:00
parent 017ca0b8a8
commit 1e0246507f
2 changed files with 57 additions and 47 deletions

View File

@ -3,52 +3,52 @@
(async function() { (async function() {
if(typeof PIXI!="object") { if(typeof PIXI!="object") {
if(typeof loadfail=="function") { if(typeof loadfail=="function") {
loadfail("libmain.js: object PIXI(type of "+(typeof PIXI)+") is not defined"); loadfail("libmain.js: PIXI(type of "+(typeof PIXI)+") is not an object");
} else { } else {
window.alert("libmain.js: object PIXI(type of "+(typeof PIXI)+") is not defined"); window.alert("libmain.js: PIXI(type of "+(typeof PIXI)+") is not an object");
} }
return; return;
} }
var main_stage= {}; var libmain= {};
main_stage.settings= {}; libmain.settings= {};
main_stage.api= {}; libmain.api= {};
/////////////////////////////////////// set default settings /////////////////////////////////////// set default settings
main_stage.settings.fixed_ratio=16/9; libmain.settings.fixed_ratio=16/9;
main_stage.settings.use_fixed_aspect_ratio=true; libmain.settings.use_fixed_aspect_ratio=true;
/////////////////////////////////////// init canvas and frame /////////////////////////////////////// init canvas and frame
console.log("[libmain] setting up basic pixi application..."); console.log("[libmain] setting up basic pixi application...");
// set up main canvas element // set up main canvas element
main_stage.mainframe=document.getElementById("mainframe"); libmain.mainframe=document.getElementById("mainframe");
main_stage.canvas=document.getElementById("maincanvas"); libmain.canvas=document.getElementById("maincanvas");
if(main_stage.mainframe==null) { if(libmain.mainframe==null) {
main_stage.mainframe=document.createElement("div"); libmain.mainframe=document.createElement("div");
main_stage.mainframe.id="mainframe"; libmain.mainframe.id="mainframe";
document.body.appendChild(main_stage.mainframe); document.body.appendChild(libmain.mainframe);
} }
main_stage.mainframe.style.display="inline-block"; libmain.mainframe.style.display="inline-block";
main_stage.mainframe.style.zIndex=0; libmain.mainframe.style.zIndex=0;
main_stage.mainframe.style.backgroundColor="#000000"; libmain.mainframe.style.backgroundColor="#000000";
if(main_stage.canvas==null) { if(libmain.canvas==null) {
main_stage.canvas=document.createElement("canvas"); libmain.canvas=document.createElement("canvas");
main_stage.canvas.id="maincanvas"; libmain.canvas.id="maincanvas";
main_stage.mainframe.appendChild(main_stage.canvas); libmain.mainframe.appendChild(libmain.canvas);
} }
main_stage.canvas.style.width="100%"; libmain.canvas.style.width="100%";
main_stage.canvas.style.height="100%"; libmain.canvas.style.height="100%";
main_stage.canvas.style.display="inline-block"; libmain.canvas.style.display="inline-block";
main_stage.canvas.style.position="absolute"; libmain.canvas.style.position="absolute";
main_stage.canvas.style.zIndex=1; libmain.canvas.style.zIndex=1;
// document resize handler // document resize handler
main_stage.resize=function() { libmain.resize=function() {
var res=[document.body.clientWidth, document.body.clientHeight, 0, 0]; var res=[document.body.clientWidth, document.body.clientHeight, 0, 0];
if(main_stage.settings.use_fixed_aspect_ratio) { if(libmain.settings.use_fixed_aspect_ratio) {
res=libutil.calcresize(document.body.clientWidth, document.body.clientHeight, main_stage.settings.fixed_ratio); res=libutil.calcresize(document.body.clientWidth, document.body.clientHeight, libmain.settings.fixed_ratio);
} }
mainframe.style.width=res[0]+"px"; mainframe.style.width=res[0]+"px";
mainframe.style.height=res[1]+"px"; mainframe.style.height=res[1]+"px";
@ -56,29 +56,39 @@
mainframe.style.top=res[3]+"px"; mainframe.style.top=res[3]+"px";
}; };
window.addEventListener("resize", main_stage.resize); window.addEventListener("resize", libmain.resize);
main_stage.resize(); libmain.resize();
// setup pixi application // setup pixi application
main_stage.renderer=await PIXI.autoDetectRenderer({ libmain.renderer=await PIXI.autoDetectRenderer({
"preference":"webgpu", "preference":"webgpu",
"canvas":main_stage.canvas, "canvas":libmain.canvas,
"antialias":true, "antialias":true,
"backgroundAlpha":0, "backgroundAlpha":0,
"width":main_stage.width, "width":libmain.width,
"height":main_stage.height "height":libmain.height
}); });
main_stage.stage=new PIXI.Container(); libmain.stageroot=new PIXI.Container();
main_stage.stage.sortableChildren=true; libmain.stageroot.sortableChildren=true;
main_stage.render=function() { libmain.render=function() {
requestAnimationFrame(main_stage.render); try {
main_stage.renderer.render(main_stage.stage); libmain.renderer.render(libmain.stageroot);
} catch(e) {
console.error(e);
if(typeof loadfail=="function") {
loadfail(e.message+"\n"+e.stack);
} else {
window.alert(e.message+"\n"+e.stack);
}
return;
}
requestAnimationFrame(libmain.render);
}; };
requestAnimationFrame(main_stage.render); requestAnimationFrame(libmain.render);
/////////////////////////////////////// end of setup /////////////////////////////////////// end of setup
window.main_stage=main_stage; window.libmain=libmain;
console.log("[libmain] all components initialized successfully."); console.log("[libmain] all components initialized successfully.");
})(); })();

View File

@ -2,27 +2,27 @@
if(typeof libutil!="object") { if(typeof libutil!="object") {
if(typeof loadfail=="function") { if(typeof loadfail=="function") {
loadfail("libtransition.js: object libutil(type of "+(typeof libutil)+") is not defined"); loadfail("libtransition.js: libutil(type of "+(typeof libutil)+") is not an object");
} else { } else {
window.alert("libtransition.js: object libutil(type of "+(typeof libutil)+") is not defined"); window.alert("libtransition.js: libutil(type of "+(typeof libutil)+") is not an object");
} }
return; return;
} }
if(typeof Bezier!="function") { if(typeof Bezier!="function") {
if(typeof loadfail=="function") { if(typeof loadfail=="function") {
loadfail("libtransition.js: class Bezier(type of "+(typeof Bezier)+") is not defined"); loadfail("libtransition.js: Bezier(type of "+(typeof Bezier)+") is not a function");
} else { } else {
window.alert("libtransition.js: class Bezier is not defined"); window.alert("libtransition.js: Bezier(type of "+(typeof Bezier)+") is not a function");
} }
return; return;
} }
if(typeof requestAnimationFrame!="function") { if(typeof requestAnimationFrame!="function") {
if(typeof loadfail=="function") { if(typeof loadfail=="function") {
loadfail("libtransition.js: function requestAnimationFrame(type of "+(typeof requestAnimationFrame)+") is not defined"); loadfail("libtransition.js: requestAnimationFrame(type of "+(typeof requestAnimationFrame)+") is not a function");
} else { } else {
window.alert("libtransition.js: function requestAnimationFrame is not defined"); window.alert("libtransition.js: requestAnimationFrame(type of "+(typeof requestAnimationFrame)+") is not a function");
} }
return; return;
} }