Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

5.5 KB
Raw Blame

Playable ads: raea/playable and raea playable

A playable ad is a short game served in place of a video ad inside other apps (AppLovin, Unity, Google, Meta, Moloco, Mintegral, TikTok, Liftoff). It ends on a card that opens the store. In raea it is a game written the usual way (games), and the same file is both ads: raea render makes the video ad, because nobody touches it and it plays itself, and raea playable makes the playable for each network.

The shape

  • It plays itself until the first touch. Before anyone touches it, the step plays (a hand, a ghost finger, the computer making the best move each second). The first touch hands control over, and the hand goes. This is also what the video ad shows.
  • The move is clear in two seconds. One gesture: drag, tap a group, swipe a lane. Show it with the hand, not words. A line of instructions is the rut.
  • A fail moment comes early. Somewhere between 10 and 30 seconds the player nearly wins or just loses ("So close!", a tower one short). That is what sends people to the store.
  • The card comes within 30 to 60 seconds. End on <EndCard> when the game is over, won or lost, and never later than the composition's last frame (the host shows its own card there).
  • Both orientations. Register a portrait composition (1080x1920) and a landscape one (1920x1080) from the same game. The host plays the one nearest the screen's shape; with one only, the other is letterboxed. Unity, AppLovin, Moloco and Mintegral want both.
  • Words stay big. A phone shows the composition scaled down: titles at 80 px and more, nothing under 36 px at 1080 wide.

The store

import { EndCard, InstallButton, install } from "raea/playable";

<EndCard show={g.over !== ""} title={g.over === "won" ? "Wall cleared!" : "So close!"} subtitle="Can you clear the wall?" cta="Try again" />
  • <EndCard show> covers the game, and a tap anywhere on it opens the store (end() is called when it first shows). title, subtitle, icon (an imported picture), cta, background, font, color and button set it; what you put inside it (a logo, a product) goes between the words and the button.
  • <InstallButton> is a button anywhere in the game; install() opens the store from your own tap handler.
  • Outside an export (a render, a preview) they draw but do nothing. The store links come from the export's --ios and --android.

Input

  • Read the pointer and touches from the frame's input as in any game: input.pointer (x, y in composition px, down) and input.touches. Keys work too, for testing in a browser.
  • The host samples input once a frame. A tap shorter than a frame can be missed, so act on the press (down becoming true), not on a quick down-and-up within one frame.

What a playable can't have

raea playable refuses these before it bundles:

  • staticFile(). Import the file instead (import icon from "./icon.png"), and the export carries it in the page.
  • Any URL, fetch, XHR or WebSocket. Networks refuse a page that makes a request.
  • Modules that need the native engine: raea/native, raea/ml, raea/character, raea/physics, raea/media, raea/matchmove and raea/modelling.
  • <Video> and <Audio>, until sound comes to playables.
  • 3D outside what the host draws: meshes (box, sphere, plane, cylinder, cone, torus, capsule, circle, ring), the standard, physical and basic materials, perspective and orthographic cameras, the five light kinds, fog, tone mapping, shadows and anti-aliasing. Models, splats and water stay in the video ad.

A font is carried the same way: import it (import arvo from "./Arvo-Bold.ttf") and name it in an @font-face in a <style>, src: url(${arvo}). A font named but not imported isn't there on a phone, which draws its own sans-serif. <EndCard> takes font, color and button (a style for its button), so a brand's card is in the brand's type.

Export and check

raea add [email protected]                     # once per project: the playable's 3D renderer
raea render game.tsx -o out/video-ad.mp4   # the video ad
raea playable game.tsx -o out/playable --ios https://apps.apple.com/app/id123 --android https://play.google.com/store/apps/details?id=com.example

It prints each network's file and its size against the 5 MB cap; a page is usually 1.3 to 1.5 MB, most of it three.js. --networks applovin,google,preview makes fewer, --title and --cta set the host's own card, and --orientation sets what Google and TikTok are told.

Play the preview page yourself before handing it over: open it at a phone's size, drag, lose, and tap the card. In raea's own checkout, bun sdk/playable/tools/check.ts PAGE.html OUT plays it in WebKit, as an iPhone's ad view does, and fails on an error, a request, or a card that opens nothing.

How it fails

What you see Why What to change
nothing moves until it's touched the step only reads input let the step play itself when nobody has touched it
the hand keeps playing after a touch touched isn't kept in the state set it in the step on the first press, and stop the hand from then
a tap does nothing the press lasted less than a frame, or the step waits for the release act on down
the page is refused for a request a URL or staticFile in the source, or a font from the web import the file; take the URL out
it's letterboxed on a phone one orientation registered register the other shape
the video ad shows the end card early the self-play loses too fast tune the self-play so it nearly wins