extends SceneTree const OUTPUT = "res://assets/balls/shared/previews/material-style-v1/" const BALLS = ["iron_ball", "ceramic_ball", "wood_ball"] func _initialize() -> void: call_deferred("capture") func capture() -> void: var args := OS.get_cmdline_user_args() if args.size() != 1 or args[0] not in ["before", "after"]: push_error("Pass either before or after as the capture name.") quit(1) return var app = load("res://playtest/tutorial/scenes/tutorial.tscn").instantiate() root.add_child(app) var pieces: Array = [] var balls: Array = [] for i in range(BALLS.size()): var at := Vector3(1.5, 0, -1.0) * (i - 1) pieces.append({"id": "lane_%d" % i, "kind": "straight", "position": [at.x, at.y, at.z], "quarter": 0}) var center: Vector3 = at + app.lib.ball_on_surface("straight", 0.5) balls.append({"id": BALLS[i], "ballTypeId": BALLS[i], "position": [center.x, center.y, center.z]}) app.apply_data({"schemaVersion": 2, "pieces": pieces, "entities": [], "balls": balls}) for child in app.get_children(): if child is CanvasLayer: child.hide() for tag in app.tags: tag.hide() app.slots_view.hide() app.preview_view.hide() app.selection.hide() app.ball_marker.hide() app.camera.h_offset = 0 app.camera.v_offset = 0 app.camera_size = 6.2 app.target = Vector3(0, 0.56, 0) app.update_camera() for i in range(8): await process_frame RenderingServer.force_draw(false) RenderingServer.force_sync() var screenshot := root.get_texture().get_image() var path := ProjectSettings.globalize_path(OUTPUT + args[0] + ".png") var result := screenshot.save_png(path) if result != OK: push_error("Could not save material comparison to " + path) quit(0 if result == OK else 1)