CenaForge: primeira versão pública
Gerador de vídeos narrativos (Godot + FFmpeg), painel Next.js, serviço de voz, Clipador de lives e Publicador para YouTube, TikTok e Instagram. Inclui a leitura das visualizações dos posts para o Dashboard e o botão "Publicar no <rede>" nos cartões das publicações. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+68
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "demo-street",
|
||||
"seed": 42,
|
||||
"video": {
|
||||
"width": 540,
|
||||
"height": 960,
|
||||
"fps": 30,
|
||||
"durationSeconds": 12
|
||||
},
|
||||
"world": {
|
||||
"streetLengthMeters": 100,
|
||||
"roadWidthMeters": 8,
|
||||
"nearHousesPerSide": 9,
|
||||
"backgroundMode": "cards",
|
||||
"lightingPreset": "warm_day"
|
||||
},
|
||||
"rider": {
|
||||
"assetId": "placeholder-rider",
|
||||
"bikeColor": "#D95437",
|
||||
"startPosition": [
|
||||
1.8,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"travelMeters": 32
|
||||
},
|
||||
"motion": {
|
||||
"startSeconds": 1,
|
||||
"brakeStartSeconds": 9,
|
||||
"stopSeconds": 10
|
||||
},
|
||||
"camera": {
|
||||
"preset": "third_person_follow",
|
||||
"offset": [
|
||||
1.2,
|
||||
2.7,
|
||||
5.4
|
||||
],
|
||||
"lookAtOffset": [
|
||||
-0.2,
|
||||
1.0,
|
||||
-2.5
|
||||
],
|
||||
"fovDegrees": 55,
|
||||
"endOffset": [
|
||||
1.9,
|
||||
1.15,
|
||||
4.6
|
||||
],
|
||||
"endLookAtOffset": [
|
||||
-0.3,
|
||||
0.13,
|
||||
-1.0
|
||||
]
|
||||
},
|
||||
"overlay": {
|
||||
"startSeconds": 10,
|
||||
"title": "Uma entrega inesperada.",
|
||||
"choiceA": "A — Aceitar",
|
||||
"choiceB": "B — Continuar a rota"
|
||||
},
|
||||
"audio": {
|
||||
"enabled": true,
|
||||
"file": null,
|
||||
"offsetSeconds": 0
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "demo-street",
|
||||
"seed": 42,
|
||||
"video": {
|
||||
"width": 540,
|
||||
"height": 960,
|
||||
"fps": 30,
|
||||
"durationSeconds": 12
|
||||
},
|
||||
"world": {
|
||||
"streetLengthMeters": 100,
|
||||
"roadWidthMeters": 8,
|
||||
"nearHousesPerSide": 9,
|
||||
"backgroundMode": "cards",
|
||||
"lightingPreset": "warm_day"
|
||||
},
|
||||
"rider": {
|
||||
"assetId": "placeholder-rider",
|
||||
"bikeColor": "#D95437",
|
||||
"startPosition": [
|
||||
1.8,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"travelMeters": 32
|
||||
},
|
||||
"motion": {
|
||||
"startSeconds": 5,
|
||||
"brakeStartSeconds": 4,
|
||||
"stopSeconds": 13
|
||||
},
|
||||
"camera": {
|
||||
"preset": "third_person_follow",
|
||||
"offset": [
|
||||
1.2,
|
||||
2.7,
|
||||
5.4
|
||||
],
|
||||
"lookAtOffset": [
|
||||
-0.2,
|
||||
1.0,
|
||||
-2.5
|
||||
],
|
||||
"fovDegrees": 55,
|
||||
"endOffset": [
|
||||
1.9,
|
||||
1.15,
|
||||
4.6
|
||||
],
|
||||
"endLookAtOffset": [
|
||||
-0.3,
|
||||
0.13,
|
||||
-1.0
|
||||
]
|
||||
},
|
||||
"overlay": {
|
||||
"startSeconds": 10,
|
||||
"title": "Uma entrega inesperada.",
|
||||
"choiceA": "A — Aceitar",
|
||||
"choiceB": "B — Continuar a rota"
|
||||
},
|
||||
"audio": {
|
||||
"enabled": false,
|
||||
"file": null,
|
||||
"offsetSeconds": 0
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{ "schemaVersion": 1, "id": "quebrado",
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "demo-street",
|
||||
"seed": 42,
|
||||
"video": {
|
||||
"width": 540,
|
||||
"height": 960,
|
||||
"fps": 30,
|
||||
"durationSeconds": 12
|
||||
},
|
||||
"world": {
|
||||
"streetLengthMeters": 100,
|
||||
"roadWidthMeters": 8,
|
||||
"nearHousesPerSide": 9,
|
||||
"backgroundMode": "cards",
|
||||
"lightingPreset": "warm_day",
|
||||
"script": "OS.execute(\"cmd\")"
|
||||
},
|
||||
"rider": {
|
||||
"assetId": "placeholder-rider",
|
||||
"bikeColor": "#D95437",
|
||||
"startPosition": [
|
||||
1.8,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"travelMeters": 32
|
||||
},
|
||||
"motion": {
|
||||
"startSeconds": 1,
|
||||
"brakeStartSeconds": 9,
|
||||
"stopSeconds": 10
|
||||
},
|
||||
"camera": {
|
||||
"preset": "third_person_follow",
|
||||
"offset": [
|
||||
1.2,
|
||||
2.7,
|
||||
5.4
|
||||
],
|
||||
"lookAtOffset": [
|
||||
-0.2,
|
||||
1.0,
|
||||
-2.5
|
||||
],
|
||||
"fovDegrees": 55,
|
||||
"endOffset": [
|
||||
1.9,
|
||||
1.15,
|
||||
4.6
|
||||
],
|
||||
"endLookAtOffset": [
|
||||
-0.3,
|
||||
0.13,
|
||||
-1.0
|
||||
]
|
||||
},
|
||||
"overlay": {
|
||||
"startSeconds": 10,
|
||||
"title": "$(rm -rf /)",
|
||||
"choiceA": "A — Aceitar",
|
||||
"choiceB": "B — Continuar a rota"
|
||||
},
|
||||
"audio": {
|
||||
"enabled": false,
|
||||
"file": null,
|
||||
"offsetSeconds": 0
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"schemaVersion": 99,
|
||||
"id": "demo-street",
|
||||
"seed": 42,
|
||||
"video": {
|
||||
"width": 540,
|
||||
"height": 960,
|
||||
"fps": 30,
|
||||
"durationSeconds": 12
|
||||
},
|
||||
"world": {
|
||||
"streetLengthMeters": 100,
|
||||
"roadWidthMeters": 8,
|
||||
"nearHousesPerSide": 9,
|
||||
"backgroundMode": "cards",
|
||||
"lightingPreset": "warm_day"
|
||||
},
|
||||
"rider": {
|
||||
"assetId": "placeholder-rider",
|
||||
"bikeColor": "#D95437",
|
||||
"startPosition": [
|
||||
1.8,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"travelMeters": 32
|
||||
},
|
||||
"motion": {
|
||||
"startSeconds": 1,
|
||||
"brakeStartSeconds": 9,
|
||||
"stopSeconds": 10
|
||||
},
|
||||
"camera": {
|
||||
"preset": "third_person_follow",
|
||||
"offset": [
|
||||
1.2,
|
||||
2.7,
|
||||
5.4
|
||||
],
|
||||
"lookAtOffset": [
|
||||
-0.2,
|
||||
1.0,
|
||||
-2.5
|
||||
],
|
||||
"fovDegrees": 55,
|
||||
"endOffset": [
|
||||
1.9,
|
||||
1.15,
|
||||
4.6
|
||||
],
|
||||
"endLookAtOffset": [
|
||||
-0.3,
|
||||
0.13,
|
||||
-1.0
|
||||
]
|
||||
},
|
||||
"overlay": {
|
||||
"startSeconds": 10,
|
||||
"title": "Uma entrega inesperada.",
|
||||
"choiceA": "A — Aceitar",
|
||||
"choiceB": "B — Continuar a rota"
|
||||
},
|
||||
"audio": {
|
||||
"enabled": false,
|
||||
"file": null,
|
||||
"offsetSeconds": 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
extends SceneTree
|
||||
## Testes pequenos da lógica que não precisa de GPU (roda em --headless):
|
||||
## validação do contrato e avaliação temporal.
|
||||
##
|
||||
## Uso: godot --headless --path godot --script res://tests/run_tests.gd
|
||||
## Sai com código 0 se tudo passar, 1 se algo falhar.
|
||||
|
||||
const SceneConfig := preload("res://scripts/core/scene_config.gd")
|
||||
const Timeline := preload("res://scripts/core/timeline_controller.gd")
|
||||
const RiderBuilder := preload("res://scripts/builders/rider_builder.gd")
|
||||
|
||||
var _passed := 0
|
||||
var _failed := 0
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
var root := ProjectSettings.globalize_path("res://").trim_suffix("/").get_base_dir()
|
||||
var fixtures := ProjectSettings.globalize_path("res://tests/fixtures")
|
||||
|
||||
# --- configurações válidas ---
|
||||
var demo := SceneConfig.load_file(root.path_join("config/demo-street.json"))
|
||||
_check(demo.ok, "demo-street.json é válida", demo.errors)
|
||||
var variant := SceneConfig.load_file(root.path_join("config/demo-street-variant.json"))
|
||||
_check(variant.ok, "demo-street-variant.json é válida", variant.errors)
|
||||
|
||||
# --- rejeições ---
|
||||
_expect_error(SceneConfig.load_file(fixtures.path_join("invalid-json.json")), "JSON inválido", "JSON malformado é rejeitado")
|
||||
_expect_error(SceneConfig.load_file(fixtures.path_join("impossible-times.json")), "startSeconds < brakeStartSeconds", "intervalo de tempo impossível é rejeitado")
|
||||
_expect_error(SceneConfig.load_file(fixtures.path_join("unknown-version.json")), "schemaVersion 99", "versão desconhecida é rejeitada")
|
||||
_expect_error(SceneConfig.load_file(fixtures.path_join("audio-without-file.json")), "audio.file", "áudio habilitado sem arquivo é rejeitado")
|
||||
_expect_error(SceneConfig.load_file(fixtures.path_join("unknown-field.json")), "world.script", "campo desconhecido é rejeitado")
|
||||
_expect_error(SceneConfig.load_file(fixtures.path_join("nao-existe.json")), "não encontrado", "arquivo inexistente é rejeitado")
|
||||
_expect_error(SceneConfig.parse_text("[1, 2]"), "objeto", "raiz que não é objeto é rejeitada")
|
||||
|
||||
if demo.ok:
|
||||
var raw: Dictionary = JSON.parse_string(FileAccess.get_file_as_string(root.path_join("config/demo-street.json")))
|
||||
_expect_error(SceneConfig.validate(_patched(raw, ["motion", "stopSeconds"], 13)), "durationSeconds", "parada depois do fim do vídeo é rejeitada")
|
||||
_expect_error(SceneConfig.validate(_patched(raw, ["motion", "brakeStartSeconds"], 1)), "startSeconds < brakeStartSeconds", "frenagem no mesmo instante da partida é rejeitada")
|
||||
_expect_error(SceneConfig.validate(_patched(raw, ["video", "fps"], 0)), "video.fps", "FPS zero é rejeitado")
|
||||
_expect_error(SceneConfig.validate(_patched(raw, ["video", "width"], -540)), "video.width", "largura negativa é rejeitada")
|
||||
_expect_error(SceneConfig.validate(_patched(raw, ["video", "width"], 541)), "par", "largura ímpar é rejeitada")
|
||||
_expect_error(SceneConfig.validate(_patched(raw, ["video", "fps"], "30")), "número finito", "número como texto é rejeitado")
|
||||
_expect_error(SceneConfig.validate(_patched(raw, ["video", "durationSeconds"], 12.01)), "inteiro de quadros", "duração sem número inteiro de quadros é rejeitada")
|
||||
_expect_error(SceneConfig.validate(_patched(raw, ["rider", "bikeColor"], "vermelho")), "#RRGGBB", "cor inválida é rejeitada")
|
||||
_expect_error(SceneConfig.validate(_patched(raw, ["rider", "travelMeters"], 95)), "fim da rua", "percurso que passa do fim da rua é rejeitado")
|
||||
_expect_error(SceneConfig.validate(_patched(raw, ["camera", "offset"], [0, -3, 2])), "altura", "câmera abaixo do chão é rejeitada")
|
||||
_expect_error(SceneConfig.validate(_patched(raw, ["overlay", "title"], "linha1\nlinha2")), "controle", "texto com caractere de controle é rejeitado")
|
||||
|
||||
_test_motion(demo.config)
|
||||
_test_determinism(raw)
|
||||
|
||||
print("\n%d passaram, %d falharam" % [_passed, _failed])
|
||||
quit(1 if _failed > 0 else 0)
|
||||
|
||||
|
||||
func _test_motion(cfg: Dictionary) -> void:
|
||||
var tl := Timeline.new(cfg, RiderBuilder.WHEEL_RADIUS)
|
||||
var start: Vector3 = cfg.rider.start_position
|
||||
var travel: float = cfg.rider.travel
|
||||
var m: Dictionary = cfg.motion
|
||||
|
||||
var s0 := tl.evaluate_at_time(0.0)
|
||||
_check(s0.rider_position == start, "posição inicial = startPosition", [str(s0.rider_position)])
|
||||
_check(tl.distance_at(m.start) == 0.0, "moto parada até startSeconds")
|
||||
var s_stop := tl.evaluate_at_time(m.stop)
|
||||
_check(is_equal_approx(s_stop.distance, travel), "distância = travelMeters no instante de parada", [str(s_stop.distance)])
|
||||
_check(tl.evaluate_at_time(cfg.video.duration).rider_position == start + Vector3(0, 0, -travel), "posição final exata e moto anda em -Z")
|
||||
_check(tl.speed_at(m.stop + 0.5) == 0.0 and tl.distance_at(m.stop + 0.5) == travel, "moto permanece parada após stopSeconds")
|
||||
|
||||
# Continuidade: com passo pequeno não pode haver salto de posição, e a
|
||||
# velocidade não pode mudar bruscamente nas fronteiras das fases.
|
||||
var dt := 0.0005
|
||||
var max_step := 0.0
|
||||
var max_speed_jump := 0.0
|
||||
var monotonic := true
|
||||
var prev_d := tl.distance_at(0.0)
|
||||
var prev_v := tl.speed_at(0.0)
|
||||
var t := dt
|
||||
while t <= cfg.video.duration:
|
||||
var d := tl.distance_at(t)
|
||||
var v := tl.speed_at(t)
|
||||
max_step = maxf(max_step, absf(d - prev_d))
|
||||
max_speed_jump = maxf(max_speed_jump, absf(v - prev_v))
|
||||
if d < prev_d - 1e-9:
|
||||
monotonic = false
|
||||
prev_d = d
|
||||
prev_v = v
|
||||
t += dt
|
||||
var v_cruise := tl.cruise_speed()
|
||||
_check(monotonic, "distância nunca diminui")
|
||||
_check(max_step <= v_cruise * dt * 1.01, "sem saltos de posição (maior passo %.5f m)" % max_step)
|
||||
_check(max_speed_jump < 0.01, "velocidade contínua nas fases (maior salto %.5f m/s)" % max_speed_jump)
|
||||
|
||||
# Em cada fronteira de fase, distância à esquerda e à direita coincidem.
|
||||
for boundary in [m.start, m.start + m.accel_seconds, m.brake_start, m.stop]:
|
||||
var left := tl.distance_at(boundary - 1e-6)
|
||||
var right := tl.distance_at(boundary + 1e-6)
|
||||
_check(absf(left - right) < 1e-4, "sem salto na fronteira t=%.3f" % boundary, [str(left), str(right)])
|
||||
|
||||
# Roda: ângulo = -distância / raio.
|
||||
var s4 := tl.evaluate_at_time(4.0)
|
||||
_check(is_equal_approx(s4.wheel_angle, -s4.distance / RiderBuilder.WHEEL_RADIUS), "ângulo da roda = distância / raio")
|
||||
_check(tl.evaluate_at_time(5.0).wheel_angle < s4.wheel_angle, "roda continua girando enquanto há deslocamento")
|
||||
|
||||
# Overlay
|
||||
_check(not tl.evaluate_at_time(cfg.overlay.start - 0.01).overlay.visible, "overlay oculto antes de startSeconds")
|
||||
_check(tl.evaluate_at_time(cfg.overlay.start + 1.5).overlay.choice_b == 1.0, "overlay completo após o fade")
|
||||
|
||||
|
||||
func _test_determinism(raw: Dictionary) -> void:
|
||||
var a := Timeline.new(SceneConfig.validate(raw.duplicate(true)).config, RiderBuilder.WHEEL_RADIUS)
|
||||
var b := Timeline.new(SceneConfig.validate(raw.duplicate(true)).config, RiderBuilder.WHEEL_RADIUS)
|
||||
var same := true
|
||||
for i in 361:
|
||||
var t := i / 30.0
|
||||
var sa := a.evaluate_at_time(t)
|
||||
var sb := b.evaluate_at_time(t)
|
||||
if var_to_str(sa) != var_to_str(sb):
|
||||
same = false
|
||||
break
|
||||
_check(same, "mesmo t produz o mesmo estado em duas instâncias")
|
||||
# Avaliar fora de ordem não pode alterar o resultado (sem estado acumulado).
|
||||
var forward := var_to_str(a.evaluate_at_time(7.3))
|
||||
a.evaluate_at_time(11.0)
|
||||
a.evaluate_at_time(0.0)
|
||||
_check(var_to_str(a.evaluate_at_time(7.3)) == forward, "avaliação não depende da ordem das chamadas")
|
||||
|
||||
|
||||
func _patched(raw: Dictionary, path: Array, value) -> Dictionary:
|
||||
var copy: Dictionary = raw.duplicate(true)
|
||||
var node: Dictionary = copy
|
||||
for i in path.size() - 1:
|
||||
node = node[path[i]]
|
||||
node[path[-1]] = value
|
||||
return copy
|
||||
|
||||
|
||||
func _expect_error(result: Dictionary, fragment: String, label: String) -> void:
|
||||
var found := false
|
||||
for e in result.errors:
|
||||
if e.contains(fragment):
|
||||
found = true
|
||||
_check(not result.ok and found, label, result.errors)
|
||||
|
||||
|
||||
func _check(condition: bool, label: String, details = []) -> void:
|
||||
if condition:
|
||||
_passed += 1
|
||||
print(" ok " + label)
|
||||
else:
|
||||
_failed += 1
|
||||
print(" FALHA " + label + (" " + str(details) if not details.is_empty() else ""))
|
||||
@@ -0,0 +1 @@
|
||||
uid://wi72iir0ra5v
|
||||
Reference in New Issue
Block a user