Skip to content

Commit

Permalink
Merge pull request #3036 from moisesjpelaez/html5-fullscreen-revert
Browse files Browse the repository at this point in the history
Revert Kha's automatic size adjust for HTML5 fullscreen resizing.
  • Loading branch information
luboslenco authored Aug 29, 2024
2 parents 3b8f6ea + 8fa322b commit c61cc91
Showing 1 changed file with 4 additions and 45 deletions.
49 changes: 4 additions & 45 deletions blender/arm/write_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,6 @@ def write_khafilejs(is_play, export_physics: bool, export_navigation: bool, expo
if wrd.arm_winresize or state.target == 'html5':
assets.add_khafile_def('arm_resizable')

if get_winmode(wrd.arm_winmode) == 1 and state.target.startswith('html5'):
assets.add_khafile_def('kha_html5_disable_automatic_size_adjust')

# if bpy.data.scenes[0].unit_settings.system_rotation == 'DEGREES':
# assets.add_khafile_def('arm_degrees')

Expand Down Expand Up @@ -472,13 +469,6 @@ def write_mainhx(scene_name, resx, resy, is_play, is_publish):
"""// Auto-generated
package;\n""")

if winmode == 1 and state.target.startswith('html5'):
f.write("""
import js.Browser.document;
import js.Browser.window;
import js.html.CanvasElement;
import kha.Macros;\n""")

f.write("""
class Main {
public static inline var projectName = '""" + arm.utils.safestr(wrd.arm_project_name) + """';
Expand All @@ -499,10 +489,7 @@ class Main {

f.write("""\n
public static function main() {""")
if winmode == 1 and state.target.startswith('html5'):
f.write("""
setFullWindowCanvas();""")


if rpdat.arm_skin != 'Off':
f.write("""
iron.object.BoneAnimation.skinMaxBones = """ + str(rpdat.arm_skin_max_bones) + """;""")
Expand Down Expand Up @@ -546,37 +533,9 @@ class Main {
""" + ('true' if wrd.arm_vsync else 'false') + """,
""" + pathpack + """.renderpath.RenderPathCreator.get
);
}""")

if winmode == 1 and state.target.startswith('html5'):
f.write("""\n
static function setFullWindowCanvas(): Void {
document.documentElement.style.padding = "0";
document.documentElement.style.margin = "0";
document.body.style.padding = "0";
document.body.style.margin = "0";
final canvas: CanvasElement = cast document.getElementById(Macros.canvasId());
canvas.style.display = "block";
final resize = function() {
var w = document.documentElement.clientWidth;
var h = document.documentElement.clientHeight;
if (w == 0 || h == 0) {
w = window.innerWidth;
h = window.innerHeight;
}
canvas.width = Std.int(w * window.devicePixelRatio);
canvas.height = Std.int(h * window.devicePixelRatio);
if (canvas.style.width == "") {
canvas.style.width = "100%";
canvas.style.height = "100%";
}
}
window.onresize = resize;
resize();
}""")

f.write("""
}\n""")
}
}""")


def write_indexhtml(w, h, is_publish):
wrd = bpy.data.worlds['Arm']
Expand Down

0 comments on commit c61cc91

Please sign in to comment.