mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 06:53:19 -10:00
BL40, GD14: open .blend files and Godot projects come into raea by the guide, and the Blender and Godot guides teach the round trips and shots. bevy/blend-files: contents.py lists a .blend's meshes, collections, node groups and materials; take.py writes named objects and collections as one .glb with modifiers applied and a licence sidecar, now linking each taken object's parents into its scene (glTF's export walks down from the top objects, so a parented object came out as an empty 132-byte .glb). bevy/godot-projects: godot/scene-glb.ts writes a Godot scene's meshes, materials, skins and clips as one .glb, its cameras and lights left behind and the tracks that moved them dropped (glTF's export reported them as an error); type-checked as sdk/godot/test/guide-scene-glb.ts and run on Godot's 3d/platformer demo (2,923 meshes). bevy/sources: the open libraries and their licences, routed from bevy/assets. bevy/blender: raea blender open and back for the person's hands, and <BlenderShot>. bevy/godot: --scene and --frames, <GodotShot>, raea godot export and back. convert.py: a packed image isn't a missing texture
This commit is contained in:
1 parent
b85ce4f97d
commit
d4e23b602a
10 files changed
+778
-6
No files matched your search
@@ -0,0 +1,50 @@
|
||||
// The script in sdk/guides/craft/bevy/godot-projects.md ("Example"), type-checked with the tests (tsc -p .)
|
||||
// godot/scene-glb.ts: one scene (or mesh resource) of a Godot project as one .glb
|
||||
// raea godot run godot/scene-glb.ts --project KIT res://objects/platform.tscn media/platform.glb
|
||||
import { AnimationMixer, Camera3D, GLTFDocument, GLTFState, Light3D, Mesh, MeshInstance3D, Node, PackedScene, ResourceLoader, resolve, type SceneTree } from "raea/godot";
|
||||
|
||||
// the scene's cameras and lights stay behind: in raea those are the TSX's
|
||||
function strip(node: Node) {
|
||||
for (const child of node.get_children()) {
|
||||
if (child instanceof Camera3D || child instanceof Light3D) {
|
||||
node.remove_child(child);
|
||||
child.free();
|
||||
} else strip(child);
|
||||
}
|
||||
}
|
||||
|
||||
// a clip that moved a camera or light now points at nothing, which glTF's export reports as an error: drop those tracks
|
||||
function prune(node: Node) {
|
||||
if (node instanceof AnimationMixer) {
|
||||
const base = node.get_node_or_null(node.root_node);
|
||||
const names = node.get_animation_list();
|
||||
for (let n = 0; n < names.size(); n++) {
|
||||
const clip = node.get_animation(names.get(n));
|
||||
for (let i = (clip?.get_track_count() ?? 0) - 1; i >= 0; i--)
|
||||
if (!base?.get_node_or_null(clip!.track_get_path(i))) clip!.remove_track(i);
|
||||
}
|
||||
}
|
||||
for (const child of node.get_children()) prune(child);
|
||||
}
|
||||
|
||||
export default async function (_tree: SceneTree, [from, out]: string[]) {
|
||||
if (!from || !out) throw new Error("usage: raea godot run godot/scene-glb.ts --project DIR res://SCENE.tscn OUT.glb");
|
||||
const res = ResourceLoader.load(from);
|
||||
if (!res) throw new Error(`${from}: Godot can't load it`);
|
||||
let root: Node;
|
||||
if (res instanceof PackedScene) root = res.instantiate()!; // never added to the tree, so its scripts don't run
|
||||
else if (res instanceof Mesh) {
|
||||
const one = new MeshInstance3D();
|
||||
one.mesh = res;
|
||||
root = one;
|
||||
} else throw new Error(`${from}: a ${res.get_class()}, not a scene or a mesh`);
|
||||
strip(root);
|
||||
prune(root);
|
||||
const doc = new GLTFDocument();
|
||||
const state = new GLTFState();
|
||||
let err = doc.append_from_scene(root, state);
|
||||
if (err === 0) err = doc.write_to_filesystem(state, resolve(out));
|
||||
root.free();
|
||||
if (err !== 0) throw new Error(`${from}: glTF export failed (Godot error ${err})`);
|
||||
console.log(`wrote ${out}`);
|
||||
}
|
||||
@@ -30,6 +30,9 @@
|
||||
- Models are loaded once before the first frame is drawn; there's no loading state to handle.
|
||||
- Where a model comes from is the scene's routing (`bevy/scenes`): built in code when it's exact or architectural,
|
||||
a library or the person's file when one exists, generated with `raea gen mesh` (Tripo) when it has character.
|
||||
The open libraries, their licences and how to fetch from each are `bevy/sources`; open `.blend` files are
|
||||
`bevy/blend-files`, and Godot demos and kits `bevy/godot-projects`. Every model from outside carries a licence
|
||||
sidecar (`chair.glb.json`).
|
||||
Generation costs money: quote it first (`raea gen plan`), and every generated mesh goes through `raea gen check`
|
||||
(size, facing, pivot, triangles) before a scene uses it.
|
||||
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
# Blend files: open .blend material and how to take from it
|
||||
|
||||
Licences here were read at the source on 2026-11-10, except the rows under "Not checked". The licence rule and the
|
||||
sidecar are `bevy/sources`'; Blender's place in the work is `bevy/blender`'s: an asset passes through it on its way
|
||||
into `media/`, and the scene stays TSX.
|
||||
|
||||
## What to do — HEADLESS
|
||||
|
||||
- **Read the file's own licence line.** blender.org lists a licence beside each demo file, and they differ: CC0,
|
||||
CC BY, CC BY-SA. Only CC0 and CC BY files come in. Write the sidecar beside the `.blend` before any script runs:
|
||||
`cube_diorama.blend.json` holding `{"source": URL, "license": "CC0", "credit": "Blender Studio"}`.
|
||||
- **Download from `https://download.blender.org/demo/...`.** The links on blender.org's demo page
|
||||
(`https://www.blender.org/download/demo/...`) answer with a page that picks a mirror; the same path under
|
||||
`download.blender.org` is the file.
|
||||
- **List it first:** `raea blender run blender/contents.py src/FILE.blend` prints each mesh object with its
|
||||
triangles, modifiers and collections, each collection, each geometry-node group, and each material with whether it
|
||||
has image textures.
|
||||
- **Take one thing:** `raea blender run blender/take.py src/FILE.blend media/OUT.glb NAME [NAME ...]`, each NAME an
|
||||
object or a collection. The whole file as one model is `convert.py src/FILE.blend media/OUT.glb`, right for a file
|
||||
that is one object.
|
||||
- **Check and fit it:** `raea gen check media/OUT.glb --h HEIGHT -o media/OUT-fit.glb`. A library lays its assets out
|
||||
in a row, so the origin is rarely under the object; `-o` puts it at the bottom centre.
|
||||
- **What comes across**, as run for this guide:
|
||||
- Meshes with their modifiers applied. A teapot of 1,562 triangles with a subdivision modifier arrived as 25,376.
|
||||
Decimate to what its distance needs (`decimate.py`, `raea gen check --seen M`).
|
||||
- Materials built on image textures, with their maps.
|
||||
- A material built from nodes alone (noise, ramps, mixes) arrives as its plain factors, without even a colour. Bake
|
||||
it (`bake.py`), or set the look in the TSX with a material inside the `<Model>` (`bevy/materials`, "Re-covering a
|
||||
model's materials").
|
||||
- A geometry-node scatter arrives as every copy it makes: one pebble-strewn ground came to 10.6 million triangles
|
||||
in 40,759 pieces. Take the source meshes (the pebbles' collection: 7 meshes, 3,152 triangles) and scatter them in
|
||||
the scene with `<Instances>` and `scatter()` (`bevy/meshes`).
|
||||
- Lights, cameras, the world and the compositor stay behind. Those are the TSX's.
|
||||
- **A node tree is worth reading even when it can't come across.** A geometry-node or shader setup shows how an
|
||||
effect is built. Open the file with the live MCP to look (`bevy/blender`, "Live"), then build the effect in raea:
|
||||
a scatter as `<Instances>`, a growth as `grow.*`, a surface as a material.
|
||||
|
||||
## Where open .blend files are
|
||||
|
||||
| source | licence | what it has | fetch |
|
||||
|---|---|---|---|
|
||||
| blender.org demo files (`blender.org/download/demo-files`) | per file: CC0, CC BY or CC BY-SA, printed beside each | asset bundles, geometry-node demos, splash scenes, benchmark scenes | `https://download.blender.org/demo/PATH` |
|
||||
| the CC0 ones there | CC0 | Human Base Meshes bundle (49 MB), Cube Diorama asset bundle (11 MB, 28 furnishings marked as assets), Classroom (72 MB), Fishy Cat (32 MB), and the geometry-node demos by Blender Studio: pebble and flower scattering, tree and moss, fracturing, fur | the same |
|
||||
| Blender Studio (`studio.blender.org`): the open films' production files | CC BY 4.0 "unless notified otherwise" (its terms and conditions) | whole film sets, characters and rigs | the film's page; credit Blender Studio and the film |
|
||||
| extensions.blender.org, asset libraries | CC0, required by the platform | asset libraries published as extensions | the extension's page |
|
||||
| extensions.blender.org, add-ons | GPL-3.0-or-later, required by the platform | tools that run inside Blender | install into Blender; see below |
|
||||
| Poly Haven and ambientCG | CC0 | each model also as a `.blend` | `bevy/sources` |
|
||||
| BlenderKit | CC0 or its own "Royalty Free" | models, materials, node groups | its add-on; take only CC0 into a project (`bevy/sources`) |
|
||||
|
||||
**Add-ons are GPL, and that is fine for a tool.** Blender and its add-ons run as their own program, which raea
|
||||
starts and never bundles (`bevy/blender`, "Setting it up"). Blender's licence page says what you make with it is
|
||||
yours: "What you create with Blender is your sole property." So a mesh an add-on helped make carries the licence of
|
||||
its sources, not the add-on's. An add-on's code is never copied into a raea project or the skill.
|
||||
|
||||
**Not CC BY-SA.** Several splash scenes on the demo page are share-alike. A film that used one would have to carry
|
||||
that licence itself. Leave them.
|
||||
|
||||
## The live MCP — BLENDER
|
||||
|
||||
The `blender` MCP server (`bevy/blender`, "Live") can search and import from Poly Haven, Sketchfab and Poly Pizza
|
||||
into the running Blender. Use that to look and to choose. What a scene uses is fetched again by a saved script with
|
||||
its sidecar (`bevy/sources`), so the asset can be rebuilt from its source.
|
||||
|
||||
## Not checked
|
||||
|
||||
- Whether a Blender Studio film's production files download without a paid membership.
|
||||
- A rigged character taken from a `.blend` with its actions: `take.py` was run on meshes only.
|
||||
- Hair, simulation caches, and anything driven by a driver or a constraint.
|
||||
- The licence of the Essentials assets that ship inside Blender.
|
||||
|
||||
## Why
|
||||
|
||||
A `.blend` is a working file: modifiers not yet applied, node materials Blender alone can draw, a view layer that
|
||||
leaves its library collections out, and lights and cameras for its own render. raea loads glTF, so what comes in is
|
||||
what glTF can hold: meshes, UVs, image-textured PBR materials, skins and clips. `take.py` exports the named things
|
||||
from a scene of their own, with the rest of the file still loaded, so what their modifiers read from still works.
|
||||
|
||||
## Common mistakes
|
||||
|
||||
- Converting a whole library file: `convert.py` stops on the first object the view layer leaves out, and a file of
|
||||
thirty assets isn't one model anyway. Name what you want with `take.py`.
|
||||
- Taking the scattered ground instead of the things scattered on it.
|
||||
- Expecting a node material's look to arrive. Run `contents.py`: a material it marks "nodes only" needs baking or
|
||||
a material in the TSX.
|
||||
- Placing a taken asset without `-o`: it sits where the library file had it, most of a metre from its own origin.
|
||||
- A sidecar that names the demo page but the wrong licence. The licence is the one printed beside that file.
|
||||
- Rebuilding the file's lighting in raea from its lights: light the scene in the TSX (`bevy/lights`).
|
||||
|
||||
## Example: a teapot out of Blender Studio's Cube Diorama bundle (CC0)
|
||||
|
||||
Run end to end for this guide on 2026-11-10: `take.py` wrote 25,376 triangles, `raea gen check` warned that its
|
||||
origin was 0.86 m from its bottom centre, and the fitted copy passed with 0 errors and 0 warnings. Its porcelain is
|
||||
a node material, so it arrives without one and the scene gives it its glaze.
|
||||
|
||||
```sh
|
||||
mkdir -p src/cube-diorama && cd src/cube-diorama
|
||||
curl -fsSL -A my-project-name -O https://download.blender.org/demo/bundles/bundles-3.0/asset-demo-bundle-3.0-cube-diorama.zip
|
||||
unzip -q asset-demo-bundle-3.0-cube-diorama.zip && cd ../..
|
||||
echo '{"source": "https://www.blender.org/download/demo-files/", "license": "CC0", "credit": "Blender Studio: Cube Diorama"}' \
|
||||
> src/cube-diorama/cube_diorama/cube_diorama.blend.json
|
||||
raea blender run blender/contents.py src/cube-diorama/cube_diorama/cube_diorama.blend
|
||||
raea blender run blender/take.py src/cube-diorama/cube_diorama/cube_diorama.blend media/teapot.glb "Tea Pot"
|
||||
raea gen check media/teapot.glb --h 0.17 -o media/teapot-fit.glb
|
||||
```
|
||||
|
||||
```tsx
|
||||
import { AbsoluteFill, Composition, registerRoot, staticFile } from "raea";
|
||||
import { Model } from "raea/3d";
|
||||
import { StandardMaterial } from "raea/pbr";
|
||||
import { Cuboid, Mesh3d } from "raea/mesh";
|
||||
import { AmbientLight, DirectionalLight } from "raea/light";
|
||||
import { Transform } from "raea/transform";
|
||||
import { Camera3d } from "raea/camera";
|
||||
|
||||
function Teapot() {
|
||||
return (
|
||||
<AbsoluteFill style={{ background: "#e9e4da" }}>
|
||||
<Camera3d transform={Transform.fromXyz(0, 0.32, 0.85).lookingAt([0, 0.08, 0])} projection={{ Perspective: { fov: (40 * Math.PI) / 180 } }} />
|
||||
<AmbientLight brightness={300} />
|
||||
<DirectionalLight transform={Transform.fromXyz(3, 6, 4).lookingAt([0, 0, 0])} illuminance={9600} shadow_maps_enabled />
|
||||
<Mesh3d transform={Transform.fromXyz(0, -0.05, 0)}>
|
||||
<Cuboid half_size={[5, 0.05, 5]} />
|
||||
<StandardMaterial base_color="#cfc8ba" perceptual_roughness={0.9} />
|
||||
</Mesh3d>
|
||||
<Model src={staticFile("teapot-fit.glb")}>
|
||||
<StandardMaterial material="Porcelain - White" base_color="#f4f1ea" perceptual_roughness={0.25} />
|
||||
</Model>
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
registerRoot(() => <Composition id="teapot" component={Teapot} width={1280} height={720} fps={30} durationInFrames={30} />);
|
||||
```
|
||||
@@ -19,8 +19,8 @@ Go to Blender only when a check names a script. Each of these findings carries i
|
||||
| the brief says it moves, and it has no skeleton | `raea gen check --rig` | `rig.py` |
|
||||
| a cloth lies on or hangs from something | the brief | `cloth.py` |
|
||||
|
||||
Never use Blender for layout, cameras, lights, final materials or animation timing: those are TSX, where they are
|
||||
frame-pure and checked (`raea scene lint`, `raea scene light`, the review sheets). "I know bpy" is no reason to model
|
||||
Never use Blender yourself for layout, cameras, lights, final materials or animation timing: those are TSX, where
|
||||
they are frame-pure and checked (`raea scene lint`, `raea scene light`, the review sheets). "I know bpy" is no reason to model
|
||||
something in Blender: a thing defined by numbers is a solid, and one defined by its looks is generated or downloaded.
|
||||
|
||||
A gap in solids (a fillet it can't make, real UVs) goes through `raea solid export`, then a script. Log it in the
|
||||
@@ -109,7 +109,8 @@ Points and boxes are in raea's frame (metres, y up, z toward the viewer, the mod
|
||||
- `convert.py IN OUT.glb [--textures DIR] [--unit auto|m|cm|mm] [--max-texture 2048]`: FBX, OBJ, .blend, STL or
|
||||
PLY to `.glb`. Applies rotation and scale. `auto` takes a model whose biggest side is over 50 as centimetres. Maps
|
||||
named diff, nor_gl, rough, metal or ao in `textures/` beside the file are wired in and written as 8-bit PNG no
|
||||
bigger than `--max-texture`.
|
||||
bigger than `--max-texture`. It also unpacks a Draco-compressed `.glb`. It is for a model that holds still: on one
|
||||
whose clips move its parts, the applied rotation and scale change the poses.
|
||||
- `decimate.py IN OUT TARGET [--lods 0.5,0.25]`: down to TARGET triangles (or a ratio, at 1 or under). Fails if it
|
||||
lands over 1.15 × the target. `--lods` also writes `OUT.lodN.glb`.
|
||||
- `repair.py IN OUT [--debris 0.005] [--voxel SIZE] [--keep-pieces]`: merges doubled vertices, drops pieces under the
|
||||
@@ -126,6 +127,11 @@ Points and boxes are in raea's frame (metres, y up, z toward the viewer, the mod
|
||||
bones, weights and named pose clips (plus `Rest`). `rigid` is for parts that don't bend (a lamp, a machine); `auto`
|
||||
is for a creature. Fails if a bone gets no vertices. A bone gets the vertices nearest its segment, so run a base's
|
||||
bone across the base, not up its middle.
|
||||
- `contents.py IN.blend`: what a `.blend` holds, and nothing written: each mesh object with its triangles, modifiers
|
||||
and collections, each collection, each geometry-node group, each material and whether it has image textures.
|
||||
- `take.py IN.blend OUT.glb NAME [NAME ...]`: the named objects and collections of a `.blend` as one `.glb`, modifiers
|
||||
applied, lights and cameras left behind. For a library or production file that holds many things
|
||||
(`bevy/blend-files`); convert.py takes a whole file.
|
||||
- `cloth.py IN OUT (--sheet W,D,X,Y,Z | --cloth NAME) [--pin box] [--frames 60] [--stiff 5] [--bend 0.05]
|
||||
[--crumple 0] [--no-floor]`: a cloth simulated onto what IN holds and a floor at y 0, baked into the clip `Drape`.
|
||||
Also writes `OUT.settled.glb`. A flat sheet lands flat: a rag wants `--stiff 1 --bend 0.01 --crumple 0.035` (soft,
|
||||
@@ -134,6 +140,50 @@ Points and boxes are in raea's frame (metres, y up, z toward the viewer, the mod
|
||||
In the scene, raea decides when a clip plays: `<Model src="media/lamp.glb" animation="Reach" time={t} loop={false}>`
|
||||
eases in over the clip and holds its last pose past the end. Timing is the Sequence's, never Blender's.
|
||||
|
||||
## The scene in Blender and back, for the person's hands — HEADLESS (then a window)
|
||||
|
||||
When the person wants to place, light or frame the scene by hand in Blender, the TSX stays the scene and Blender is
|
||||
where they move things. Its changes come back as edits you make:
|
||||
|
||||
1. `raea blender open EDIT.tsx [--at 0-90]` exports the composition's 3D (`raea scene export`), builds it in a
|
||||
headless Blender, saves `out/blender/EDIT/EDIT.blend` and opens it in a new Blender window (`--no-window` leaves
|
||||
it closed). Each primitive is Blender's own mesh, each model its glTF, each material one Principled BSDF, each
|
||||
light in watts, the camera's lens at raea's field of view, and `--at`'s frames are keys. Everything sits under an
|
||||
empty named `raea`; inside it the numbers are raea's (y up, metres).
|
||||
2. The person changes it in Blender and saves.
|
||||
3. `raea blender back out/blender/EDIT/EDIT.blend` prints one line per change at its TSX line:
|
||||
`"crate" (edit.tsx:14:7): moved by [0.4, 0, 0] to [1.4, 0.5, 0] (world)`. Parts moved, turned, scaled, recoloured,
|
||||
made rougher or more metal, relit, deleted; the camera's move and lens. A mesh made in Blender is written as
|
||||
`media/NAME.glb` with its sidecar, and its line is the `<Model>` that places it. `--json` gives the same as data.
|
||||
4. Make the edits in the TSX; raea changes nothing itself. Placements are world positions: inside a moved group,
|
||||
take the group's transform away first.
|
||||
|
||||
Only the first frame sent is compared, and only what the line names comes back: a modifier, a node material past
|
||||
Principled's colour, roughness, metalness and emission, or a re-parenting is said nowhere. `raea blender open` on a
|
||||
`.blend`, `.glb`, `.gltf`, `.obj` or `.fbx` opens the file as it is.
|
||||
|
||||
## Blender's own pictures in a composition: `<BlenderShot>` — HEADLESS
|
||||
|
||||
When a layer must be drawn by Blender itself (Cycles, Geometry Nodes, a `.blend` the person brought with its own
|
||||
look), render it as a shot. Frame N of the composition (or its Sequence) shows frame N of the shot:
|
||||
|
||||
```tsx
|
||||
import { BlenderShot } from "raea/blender/shot";
|
||||
|
||||
// a raea/blender script whose default export builds the scene and its camera, or file= a .blend with its own
|
||||
<Sequence from={30} durationInFrames={90}>
|
||||
<BlenderShot script="blender/orbit.ts" engine="cycles" samples={64} transparent />
|
||||
</Sequence>
|
||||
```
|
||||
|
||||
- Paths are the composition folder's. The shot takes the composition's size, fps and length unless given
|
||||
(`width`, `height`, `frames`); `args` reach the script's `sys.argv`.
|
||||
- It is rendered once and kept in the asset store, made again when the script's folder, the `.blend`, the props or
|
||||
raea change. The first render of a long Cycles shot is slow; keep samples low while iterating.
|
||||
- Outside a composition: `raea blender shot SCRIPT.ts|FILE.blend -o DIR --frames 90 [--fps 30] [--size 1920x1080]
|
||||
[--engine eevee|cycles|workbench] [--samples N] [--transparent] [-- ARGS]` writes `DIR/0000.png` and on.
|
||||
- A script sets the scene; `shoot()` from `raea/blender/shoot` is what draws it, so a script never renders itself.
|
||||
|
||||
## Setting it up — HEADLESS
|
||||
|
||||
- `raea setup blender` finds a Blender (`git config --global raea.blender PATH`, `/Applications/Blender.app`, then
|
||||
@@ -159,11 +209,13 @@ In the raea app, a workspace gives it to the feed's agents with a controller's s
|
||||
|
||||
Only permissive assets (CC0, CC BY with its credit, MIT). Every script refuses a source without a sidecar
|
||||
(`chair.fbx.json` or `chair.json`: `{"source": URL, "license": "CC0", "credit": ""}`) and carries it through to its
|
||||
output, with the step added. `raea solid export` writes its own.
|
||||
output, with the step added. `raea solid export` writes its own. Which libraries fall under the rule, and how to
|
||||
fetch from each, is `bevy/sources`.
|
||||
|
||||
## Common mistakes
|
||||
|
||||
- Building, lighting or framing the scene in Blender: export one asset, build the scene in TSX.
|
||||
- Building, lighting or framing the scene in Blender yourself: export one asset, build the scene in TSX. When the
|
||||
person wants their hands on it, `raea blender open` and `raea blender back` (above).
|
||||
- Fixing an asset live and moving on: the next source change loses the fix. Put it in the script.
|
||||
- Modelling a box, a shelf or a bracket in bpy: it's a solid.
|
||||
- Decimating without `--seen`: the budget is for the distance it's seen from, not a number picked by eye.
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# contents.py: what a .blend holds, read before anything is taken from it.
|
||||
# raea blender run blender/contents.py IN.blend
|
||||
# One line for each mesh object (its triangles as modelled, its modifiers, the collections it is in, whether it is
|
||||
# marked as an asset), each collection, each geometry-node group and each material (image textures or nodes only).
|
||||
# It writes nothing. Then: raea blender run blender/take.py IN.blend OUT.glb NAME.
|
||||
import bpy, sys, os
|
||||
|
||||
NAME = "contents.py"
|
||||
|
||||
|
||||
def fail(why):
|
||||
print(f"FAILED {NAME}: {why}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def argv():
|
||||
return sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
||||
|
||||
|
||||
def main():
|
||||
a = argv()
|
||||
if len(a) < 1:
|
||||
fail("usage: contents.py IN.blend")
|
||||
src = os.path.abspath(a[0])
|
||||
if not os.path.isfile(src):
|
||||
fail(f"no file {src}")
|
||||
bpy.ops.wm.open_mainfile(filepath=src)
|
||||
seen = {o.name for o in bpy.context.view_layer.objects}
|
||||
for o in sorted(bpy.data.objects, key=lambda o: o.name):
|
||||
if o.type != "MESH":
|
||||
continue
|
||||
tris = sum(len(p.vertices) - 2 for p in o.data.polygons)
|
||||
mods = ",".join(m.type.lower() for m in o.modifiers) or "none"
|
||||
cols = ",".join(c.name for c in o.users_collection) or "none"
|
||||
marks = (" asset" if o.asset_data else "") + ("" if o.name in seen else " outside the view layer")
|
||||
print(f"object {o.name!r} {tris} triangles modifiers {mods} in {cols}{marks}")
|
||||
for c in sorted(bpy.data.collections, key=lambda c: c.name):
|
||||
meshes = sum(1 for o in c.all_objects if o.type == "MESH")
|
||||
print(f"collection {c.name!r} {meshes} meshes" + (" asset" if c.asset_data else ""))
|
||||
for g in sorted(bpy.data.node_groups, key=lambda g: g.name):
|
||||
if g.bl_idname == "GeometryNodeTree":
|
||||
print(f"geometry nodes {g.name!r}" + (" asset" if g.asset_data else ""))
|
||||
for m in sorted(bpy.data.materials, key=lambda m: m.name):
|
||||
images = sum(1 for n in m.node_tree.nodes if n.type == "TEX_IMAGE" and n.image) if m.node_tree else 0
|
||||
kind = f"{images} image textures" if images else "nodes only (exports as flat factors: bake.py, or set it in the TSX)"
|
||||
print(f"material {m.name!r} {kind}" + (" asset" if m.asset_data else ""))
|
||||
print(f"APPLIED {NAME}: {src} read, nothing written")
|
||||
|
||||
|
||||
main()
|
||||
@@ -151,7 +151,8 @@ def main():
|
||||
found = maps(folder) if os.path.isdir(folder) else {}
|
||||
wired = sum(wire(m, found) for m in {s.material for o in meshes for s in o.material_slots if s.material}) if found else 0
|
||||
shrunk = shrink(int(opt(a, "--max-texture", "2048")))
|
||||
missing = [i.filepath for i in bpy.data.images if i.source == "FILE" and not os.path.isfile(bpy.path.abspath(i.filepath))]
|
||||
# an image packed in the file (a .glb's own textures) has no path and isn't missing
|
||||
missing = [i.filepath for i in bpy.data.images if i.source == "FILE" and not i.packed_file and not os.path.isfile(bpy.path.abspath(i.filepath))]
|
||||
if missing and not found:
|
||||
fail(f"textures it names are missing ({', '.join(missing[:3])}): give --textures DIR")
|
||||
save(out, src, side, {"script": NAME, "from": os.path.basename(src), "scale": s, "texturesWired": wired, "texturesShrunk": shrunk})
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
# take.py: the named objects and collections of a .blend as one .glb, the rest of the file left behind.
|
||||
# raea blender run blender/take.py IN.blend OUT.glb NAME [NAME ...]
|
||||
# For a library or production .blend that holds many things (contents.py lists them). Each NAME is an object (its
|
||||
# children come with it) or a collection. Modifiers are applied, so a subdivided mesh comes out at its subdivided
|
||||
# count and a geometry-node setup as the mesh it makes on the file's frame: take a scatter's source meshes, not the
|
||||
# scattered ground. The rest of the file stays loaded while it exports, so what the named things read from still
|
||||
# works, and they export from a scene of their own, so a collection the file's view layer leaves out still exports.
|
||||
# Lights and cameras aren't written. Then: raea gen check OUT.glb --h HEIGHT -o FIXED.glb (a library lays its assets
|
||||
# out in a row, so the origin is rarely under the object).
|
||||
import bpy, sys, os, json
|
||||
|
||||
NAME = "take.py"
|
||||
|
||||
|
||||
def fail(why):
|
||||
print(f"FAILED {NAME}: {why}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def argv():
|
||||
return sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
||||
|
||||
|
||||
def sidecar(src):
|
||||
for c in (src + ".json", os.path.splitext(src)[0] + ".json"):
|
||||
if os.path.isfile(c):
|
||||
return json.load(open(c))
|
||||
fail(f"no licence sidecar for {src}: write {src}.json as {{\"source\": URL, \"license\": \"CC0\", \"credit\": \"\"}}")
|
||||
|
||||
|
||||
def main():
|
||||
a = argv()
|
||||
if len(a) < 3:
|
||||
fail("usage: take.py IN.blend OUT.glb NAME [NAME ...]")
|
||||
src, out, names = os.path.abspath(a[0]), os.path.abspath(a[1]), a[2:]
|
||||
if not os.path.isfile(src):
|
||||
fail(f"no file {src}")
|
||||
side = sidecar(src)
|
||||
bpy.ops.wm.open_mainfile(filepath=src)
|
||||
want = []
|
||||
for n in names:
|
||||
if n in bpy.data.collections:
|
||||
want += list(bpy.data.collections[n].all_objects)
|
||||
elif n in bpy.data.objects:
|
||||
o = bpy.data.objects[n]
|
||||
want += [o, *o.children_recursive]
|
||||
else:
|
||||
have = sorted([o.name for o in bpy.data.objects if o.type == "MESH"] + [c.name for c in bpy.data.collections])
|
||||
fail(f"nothing named {n!r} in {src}; it has: {', '.join(have)}")
|
||||
# each one's parents come too (as empty nodes), or the exporter, which walks down from the scene's top objects,
|
||||
# finds none to start from and writes an empty file; their other children stay behind
|
||||
for o in list(want):
|
||||
p = o.parent
|
||||
while p is not None:
|
||||
want.append(p)
|
||||
p = p.parent
|
||||
scene = bpy.data.scenes.new("take")
|
||||
for o in dict.fromkeys(want):
|
||||
scene.collection.objects.link(o)
|
||||
o.hide_viewport = o.hide_render = False
|
||||
meshes = [o for o in scene.objects if o.type == "MESH"]
|
||||
if not meshes:
|
||||
fail(f"no mesh among {', '.join(names)}")
|
||||
with bpy.context.temp_override(scene=scene, view_layer=scene.view_layers[0]):
|
||||
bpy.ops.export_scene.gltf(filepath=out, export_format="GLB", use_active_scene=True, export_apply=True, export_yup=True,
|
||||
export_gn_mesh=True, export_cameras=False, export_lights=False)
|
||||
steps = list(side.get("steps", [])) + [{"script": NAME, "from": os.path.basename(src), "took": names}]
|
||||
json.dump({**side, "steps": steps}, open(out + ".json", "w"), indent=2)
|
||||
print(f"APPLIED {NAME}: {out} ({len(meshes)} meshes), licence in {out}.json")
|
||||
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,187 @@
|
||||
# Godot projects: open demos and kits, and what of them comes into raea
|
||||
|
||||
Licences here were read at the source on 2026-11-10. The licence rule and the sidecar are `bevy/sources`'; running
|
||||
Godot from raea (`raea setup godot`, `raea godot run`) is `bevy/godot`'s.
|
||||
|
||||
## What to do — HEADLESS
|
||||
|
||||
- **Read two licences.** A Godot repository's LICENSE covers its code. Its models, textures and sounds often carry
|
||||
another, said in the README or a licence file's second half. The sidecar takes the art's licence and its credit.
|
||||
- **Fetch the project into `src/`**, never into `media/`. One demo out of a large repository is a sparse checkout
|
||||
(the example below).
|
||||
- **Then take what you need by the route its kind has:**
|
||||
|
||||
| in the project | route | arrives as |
|
||||
|---|---|---|
|
||||
| a model file that doesn't move (`.glb`, `.gltf`, `.fbx`, `.obj`, `.blend`) | `raea blender run blender/convert.py KIT/models/X.glb media/X.glb`, run on the file where it sits | one `.glb` with its textures inside |
|
||||
| a model file with clips | the scene that holds it (`res://objects/character.tscn`), by the next row | one `.glb` with its textures inside and its clips as Godot plays them |
|
||||
| a scene (`.tscn`, `.scn`), with whatever it holds: imported models, Godot's own mesh resources (`.res`, `.tres`, `.mesh`), a GridMap, CSG shapes | `raea godot run godot/scene-glb.ts --project KIT res://PATH.tscn media/X.glb` (the script is below) | one `.glb`: the node tree, meshes, StandardMaterial3D colours and textures, AnimationPlayer clips |
|
||||
| one mesh resource | the same script, given `res://PATH.res` | one `.glb` |
|
||||
| a shader (`.gdshader`), particles, a sky, post effects, anything a script builds when the game runs | no asset route. Record it as footage (`raea godot run ... --movie`, `bevy/godot`), or build the effect in raea | frames a composition shows |
|
||||
|
||||
- **Write the sidecar and check:** `raea gen check media/X.glb`. A whole level arrives with its origin wherever
|
||||
Godot's was and a warning for it; a level is placed once, so that is usually right as it is.
|
||||
- Prefer one object's scene (`objects/platform.tscn`) over the whole level. raea's scene is still the TSX: a level
|
||||
taken whole is for a Godot project the person wants shown as it is.
|
||||
|
||||
## What the Godot path can't do yet
|
||||
|
||||
- raea has no reader of its own for `.tscn`, `.tres` or `.res`. Every route above runs Godot, so it needs
|
||||
`raea setup godot`, and a project Godot never opened is imported first.
|
||||
- **Shaders don't cross.** A mesh with a ShaderMaterial exports with an empty material, and nothing turns Godot's
|
||||
shading language into a raea material. Read the shader and write the look again (`bevy/materials`).
|
||||
- **Particles don't cross.** A GPUParticles3D exports as an empty node.
|
||||
- **GDScript doesn't run in raea,** and the export script never adds the scene to Godot's tree, so the scene's own
|
||||
scripts don't run either: what a script builds or moves at run time isn't in the `.glb`.
|
||||
- **Physics doesn't cross as physics.** Bodies and collision shapes are written as glTF extensions that raea's
|
||||
loader doesn't use. A game's collisions are rebuilt in raea (`bevy/games`).
|
||||
- The other way, raea to Godot, is `raea godot export` (`bevy/godot`): a composition's 3D as a project Godot runs,
|
||||
and `raea godot back` reads Godot's changes to it as edits to the TSX. Those are raea's own scenes; this guide is
|
||||
about bringing other people's projects in.
|
||||
- A stock Godot can't run these scripts; `raea setup godot` installs the GodotJS build (`bevy/godot`).
|
||||
|
||||
## Where open Godot material is
|
||||
|
||||
| source | licence, as read | what it has | fetch |
|
||||
|---|---|---|---|
|
||||
| Godot's demo projects (`github.com/godotengine/godot-demo-projects`) | MIT for the repository (its LICENSE.md) | 139 small projects; the 33 under `3d/` include a platformer, a truck town, material testers, lights and shadows, CSG and navigation | a sparse checkout of one folder; the whole repository is over 500 MB |
|
||||
| Godot's third-person shooter demo (`github.com/godotengine/tps-demo`) | code MIT; all assets CC BY 3.0, "Juan Linietsky, Fernando Miguel Calabró"; music CC BY 3.0, Christian Fernando Perucchi | a robot, a level, PBR materials | clone; credit as its LICENSE.md says |
|
||||
| Kenney's starter kits (`github.com/KenneyNL/Starter-Kit-3D-Platformer`; also FPS, Racing, City-Builder, Basic-Scene) | code MIT; in the platformer kit, read for this guide, models, sprites and sounds are CC0 | a small Godot 4.6 project with `.glb` models and one scene per object | clone, or the branch's tarball from codeload.github.com (5 MB) |
|
||||
| Kenney, Quaternius and KayKit packs | CC0 | low-poly kits, many with glTF files that Godot and raea both read | `bevy/sources` |
|
||||
| the Godot Asset Library (`godotengine.org/asset-library`) | per asset; the API's `cost` field holds it (MIT, CC0, GPL ...) | mostly editor add-ons and scripts; 417 projects, templates and demos for Godot 4.6, 15 of them CC0 | `https://godotengine.org/asset-library/api/asset?type=project&godot_version=4.6&cost=CC0` lists them; `/api/asset/ID` gives `download_url` (a zip of the repository at one commit) and `browse_url` |
|
||||
| Godot Shaders (`godotshaders.com`) | per shader: CC0, MIT or GPL v3, chosen by its author; the licence covers the code, not the pictures beside it | shaders to read and write again in raea | the shader's page. Don't work from a GPL one. |
|
||||
|
||||
**Don't take:** GDQuest's demos (`github.com/gdquest-demos`): their code is MIT and their art (textures and models)
|
||||
is CC BY-NC-SA 4.0, which is outside the rule.
|
||||
|
||||
## Why
|
||||
|
||||
Godot imports a model into its own resources and builds scenes from them, so a scene file names things only Godot
|
||||
can open. Godot can also write any scene it has loaded as glTF (`GLTFDocument`), and glTF is what raea loads. So the
|
||||
bridge is a short script run inside Godot. It carries what glTF can hold, which is geometry, PBR materials, skins
|
||||
and clips, and leaves behind what is Godot's alone.
|
||||
|
||||
## Common mistakes
|
||||
|
||||
- **Copying a kit's `.glb` straight into `media/`.** Kenney's models name `Textures/colormap.png` beside them:
|
||||
`raea gen check` passes the bare copy and the render refuses it for the missing file. Export the model's scene
|
||||
through Godot, which packs the texture in, or copy the model with the folder it names, kept at the same place
|
||||
beside it.
|
||||
- **convert.py on a model animated by moving its parts.** It applies each part's rotation and scale, and the clips
|
||||
then pose the parts wrongly: the kit character's antenna sank into its head. convert.py is for models that hold
|
||||
still.
|
||||
- **Taking a repository's MIT for its art.** Read the README's last lines and the licence file to its end.
|
||||
- **An add-on from the Asset Library taken for an asset.** Most entries are GDScript tools for Godot's editor. Nothing
|
||||
of those comes into raea.
|
||||
- **Expecting the game's look.** The sky, the fog, the glow and every shader stay in Godot. Light the `.glb` in the TSX.
|
||||
- **A relative output path.** Godot runs in the project's folder; the script's `resolve(out)` names the file where
|
||||
raea ran (`bevy/godot`, "Paths").
|
||||
- **Exporting a scene whose root is a script-driven spawner.** Its children don't exist until the game runs. Export
|
||||
the scenes it spawns, one by one.
|
||||
|
||||
## Example: a platform and a character out of Kenney's Godot starter kit
|
||||
|
||||
Run end to end for this guide on 2026-11-10 with Godot 4.6.1: the platform's scene exported as 144 triangles
|
||||
(2 x 0.55 x 2 m) and the character's as 550 triangles with its texture inside and its clips `idle`, `jump`, `static`
|
||||
and `walk`; `raea gen check` found 0 errors and 0 warnings in both, and the composition rendered with the character
|
||||
posed as the kit's own file poses it. The kit's whole level
|
||||
(`res://scenes/main.tscn`: 9,038 triangles, four clips) and the stage of Godot's own platformer demo
|
||||
(`res://stage/stage.tscn`, built from `.res` meshes: 15,008 triangles) went through the same script.
|
||||
|
||||
```sh
|
||||
mkdir -p src && cd src
|
||||
curl -fsSL https://codeload.github.com/KenneyNL/Starter-Kit-3D-Platformer/tar.gz/refs/heads/main | tar xz && cd ..
|
||||
KIT=src/Starter-Kit-3D-Platformer-main
|
||||
SIDE='{"source": "https://github.com/KenneyNL/Starter-Kit-3D-Platformer", "license": "CC0", "credit": "Kenney (kenney.nl)"}'
|
||||
|
||||
raea godot run godot/scene-glb.ts --project $KIT res://objects/platform.tscn media/platform.glb
|
||||
raea godot run godot/scene-glb.ts --project $KIT res://objects/character.tscn media/character.glb
|
||||
echo "$SIDE" > media/platform.glb.json
|
||||
echo "$SIDE" > media/character.glb.json
|
||||
|
||||
raea gen check media/platform.glb && raea gen check media/character.glb
|
||||
```
|
||||
|
||||
One demo out of Godot's own repository:
|
||||
|
||||
```sh
|
||||
git clone --depth 1 --filter=blob:none --sparse https://github.com/godotengine/godot-demo-projects.git src/godot-demos
|
||||
git -C src/godot-demos sparse-checkout set 3d/platformer
|
||||
raea godot run godot/scene-glb.ts --project src/godot-demos/3d/platformer res://stage/stage.tscn media/stage.glb
|
||||
```
|
||||
|
||||
`godot/scene-glb.ts`, the project's step (type-checked as `sdk/godot/test/guide-scene-glb.ts`):
|
||||
|
||||
```ts
|
||||
// godot/scene-glb.ts: one scene (or mesh resource) of a Godot project as one .glb
|
||||
// raea godot run godot/scene-glb.ts --project KIT res://objects/platform.tscn media/platform.glb
|
||||
import { AnimationMixer, Camera3D, GLTFDocument, GLTFState, Light3D, Mesh, MeshInstance3D, Node, PackedScene, ResourceLoader, resolve, type SceneTree } from "raea/godot";
|
||||
|
||||
// the scene's cameras and lights stay behind: in raea those are the TSX's
|
||||
function strip(node: Node) {
|
||||
for (const child of node.get_children()) {
|
||||
if (child instanceof Camera3D || child instanceof Light3D) {
|
||||
node.remove_child(child);
|
||||
child.free();
|
||||
} else strip(child);
|
||||
}
|
||||
}
|
||||
|
||||
// a clip that moved a camera or light now points at nothing, which glTF's export reports as an error: drop those tracks
|
||||
function prune(node: Node) {
|
||||
if (node instanceof AnimationMixer) {
|
||||
const base = node.get_node_or_null(node.root_node);
|
||||
const names = node.get_animation_list();
|
||||
for (let n = 0; n < names.size(); n++) {
|
||||
const clip = node.get_animation(names.get(n));
|
||||
for (let i = (clip?.get_track_count() ?? 0) - 1; i >= 0; i--)
|
||||
if (!base?.get_node_or_null(clip!.track_get_path(i))) clip!.remove_track(i);
|
||||
}
|
||||
}
|
||||
for (const child of node.get_children()) prune(child);
|
||||
}
|
||||
|
||||
export default async function (_tree: SceneTree, [from, out]: string[]) {
|
||||
if (!from || !out) throw new Error("usage: raea godot run godot/scene-glb.ts --project DIR res://SCENE.tscn OUT.glb");
|
||||
const res = ResourceLoader.load(from);
|
||||
if (!res) throw new Error(`${from}: Godot can't load it`);
|
||||
let root: Node;
|
||||
if (res instanceof PackedScene) root = res.instantiate()!; // never added to the tree, so its scripts don't run
|
||||
else if (res instanceof Mesh) {
|
||||
const one = new MeshInstance3D();
|
||||
one.mesh = res;
|
||||
root = one;
|
||||
} else throw new Error(`${from}: a ${res.get_class()}, not a scene or a mesh`);
|
||||
strip(root);
|
||||
prune(root);
|
||||
const doc = new GLTFDocument();
|
||||
const state = new GLTFState();
|
||||
let err = doc.append_from_scene(root, state);
|
||||
if (err === 0) err = doc.write_to_filesystem(state, resolve(out));
|
||||
root.free();
|
||||
if (err !== 0) throw new Error(`${from}: glTF export failed (Godot error ${err})`);
|
||||
console.log(`wrote ${out}`);
|
||||
}
|
||||
```
|
||||
|
||||
```tsx
|
||||
import { AbsoluteFill, Composition, registerRoot, staticFile } from "raea";
|
||||
import { Model } from "raea/3d";
|
||||
import { AmbientLight, DirectionalLight } from "raea/light";
|
||||
import { Transform } from "raea/transform";
|
||||
import { Camera3d } from "raea/camera";
|
||||
|
||||
function Kit() {
|
||||
return (
|
||||
<AbsoluteFill style={{ background: "#bfd8ee" }}>
|
||||
<Camera3d transform={Transform.fromXyz(0, 2.2, 5).lookingAt([0, 0.7, 0])} projection={{ Perspective: { fov: (40 * Math.PI) / 180 } }} />
|
||||
<AmbientLight brightness={300} />
|
||||
<DirectionalLight transform={Transform.fromXyz(3, 6, 4).lookingAt([0, 0, 0])} illuminance={9600} shadow_maps_enabled />
|
||||
<Model src={staticFile("platform.glb")} />
|
||||
<Model src={staticFile("character.glb")} animation="walk" position={[0, 0.55, 0]} scale={0.6} />
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
registerRoot(() => <Composition id="kit" component={Kit} width={1280} height={720} fps={30} durationInFrames={60} />);
|
||||
```
|
||||
@@ -8,6 +8,9 @@ the project run headless to check it, and what it draws recorded as frames a com
|
||||
Godot's whole API (Godot 4.6.1, through GodotJS, MIT), typed: tsc refuses a class or member that isn't there and a
|
||||
wrong argument type before Godot runs anything.
|
||||
|
||||
A Godot project's scenes and meshes as `.glb` models for a raea scene, and which open Godot demos and kits may be
|
||||
used, are `bevy/godot-projects`.
|
||||
|
||||
## Setting it up — HEADLESS
|
||||
|
||||
- `raea setup godot` downloads Godot 4.6.1 with GodotJS into `~/.raea/tools/godot` (JavaScriptCore on the Mac,
|
||||
@@ -106,6 +109,45 @@ export default class Turn extends SceneTree {
|
||||
A composition shows frame `f` of the recording with
|
||||
``<Img src={staticFile(`turn/f${String(f).padStart(8, "0")}.png`)} />`` (`staticFile` names a file in `media/`).
|
||||
|
||||
`--frames N` stops after N frames and `--scene res://PATH.tscn` adds a scene to the tree before the script runs. The
|
||||
script can be left out, so a project's own scene records as it is: `raea godot run --project KIT --scene
|
||||
res://level.tscn --movie media/level/f.png --frames 120`.
|
||||
|
||||
## Godot's frames in a composition: `<GodotShot>` — HEADLESS (a window opens)
|
||||
|
||||
The recording above, made and kept for you. Frame N of the composition (or its Sequence) shows frame N of the shot:
|
||||
|
||||
```tsx
|
||||
import { GodotShot } from "raea/godot/shot";
|
||||
|
||||
<Sequence from={0} durationInFrames={120}>
|
||||
<GodotShot project="kit" scene="res://level.tscn" /> {/* or script="godot/turn.ts", with or without a project */}
|
||||
</Sequence>
|
||||
```
|
||||
|
||||
- Paths are the composition folder's. The shot takes the composition's size, fps and length unless given; with a
|
||||
project, raea sets the project's window size for the run and puts it back after.
|
||||
- It is recorded once and kept in the asset store, made again when the project, the script's folder or the props
|
||||
change. Godot's sound, when the game makes any, is kept beside the frames as `sound.wav`.
|
||||
- Outside a composition: `raea godot shot SCRIPT.ts|res://SCENE.tscn -o DIR --frames 120 [--project DIR] [--fps 30]
|
||||
[--size 1920x1080] [-- ARGS]` writes `DIR/0000.png` and on.
|
||||
|
||||
## raea's scene as a Godot project, and back — HEADLESS
|
||||
|
||||
`raea godot export EDIT.tsx [-o DIR] [--at 0-90]` writes the composition's 3D as a project Godot runs and edits
|
||||
(`out/godot/EDIT/` unless `-o`): `project.godot` at the composition's size and `main.tscn`, where each primitive is
|
||||
Godot's own mesh (BoxMesh, SphereMesh, CylinderMesh, PlaneMesh), a solid its mesh, a model its glTF, each material a
|
||||
StandardMaterial3D, each light and the camera Godot's, and `--at`'s frames an AnimationPlayer that plays on start.
|
||||
Godot's axes are raea's, so the numbers carry over as they are. Each node keeps its part's id as `raea_id` metadata.
|
||||
|
||||
- Open it in Godot's editor: `raea godot open out/godot/EDIT`. Play it: `raea godot run --project out/godot/EDIT
|
||||
--scene res://main.tscn --window` (it plays until the window is closed), or add a script of yours.
|
||||
- `raea godot back out/godot/EDIT` prints each change made in Godot as an edit at its TSX line, the same lines as
|
||||
`raea blender back` (`bevy/blender`). A node added there is written as `media/NAME.glb` with its sidecar, and its
|
||||
line is the `<Model>` that places it. `--json` gives the same as data. Make the edits in the TSX; raea changes
|
||||
nothing itself.
|
||||
- What the export leaves out (instanced parts, effects, 2D) is counted in the line it prints, by kind.
|
||||
|
||||
## Common mistakes
|
||||
|
||||
- A path read relative to where raea ran: Godot is in the project's folder. Use `resolve(path)`.
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
# Sources: open 3D libraries, their licences and how to fetch from them
|
||||
|
||||
Every licence and access line here was read at the source on 2026-11-10, except the rows under "Not checked".
|
||||
Licences change: read the source's own licence page again on the day you take from it.
|
||||
|
||||
## What to do
|
||||
|
||||
- **The rule.** raea takes an asset only under CC0 (public domain), CC BY with its credit, or MIT-like terms (MIT,
|
||||
BSD, Apache-2.0). Not share-alike (CC BY-SA), not non-commercial (NC), not "research only", not a marketplace's own
|
||||
licence when the file will sit in a project other people can download.
|
||||
- **Every asset carries a sidecar** beside it: `chair.glb.json` holding
|
||||
`{"source": URL, "license": "CC0", "credit": ""}`. `source` is the asset's own page, `license` is what that page
|
||||
says, and `credit` is the line a CC BY licence asks for. The Blender scripts refuse a source without one and carry it
|
||||
to their output (`bevy/blender`).
|
||||
- **Fetch with a saved script**, never by hand: the download goes into the project's `src/` folder, the script writes
|
||||
the sidecar from the source's own data, and `media/` gets one `.glb`. Send a User-Agent that names the project.
|
||||
- **Then route by what arrived:**
|
||||
|
||||
| what arrived | do |
|
||||
|---|---|
|
||||
| one `.glb` with its textures inside | copy it to `media/` with its sidecar |
|
||||
| a `.gltf` with loose files, a `.glb` that names a texture outside itself, a Draco-compressed `.glb`, OBJ, FBX, STL, PLY, `.blend`: a model that holds still | `raea blender run blender/convert.py IN media/OUT.glb` |
|
||||
| any of those with clips that move its parts | not convert.py, which applies each part's rotation and scale and so changes the poses: keep the file as it is with the files it names beside it, or take it through its Godot scene (`bevy/godot-projects`) |
|
||||
| one object out of a `.blend` that holds many | `bevy/blend-files` |
|
||||
| a Godot scene or mesh resource | `bevy/godot-projects` |
|
||||
| USD only | convert.py doesn't read USD: take the glTF or FBX download where the source offers one |
|
||||
|
||||
- **Check every one:** `raea gen check media/OUT.glb --h REAL_HEIGHT`. Scans come in the scanner's units, so give the
|
||||
real height; `-o FIXED.glb` writes it fitted, standing on its origin.
|
||||
- **Credits.** A film or page that uses CC BY assets lists each sidecar's `credit` and `license` where its credits go.
|
||||
|
||||
## CC0: use freely
|
||||
|
||||
| source | what it has | fetch |
|
||||
|---|---|---|
|
||||
| Poly Haven (polyhaven.com) | 521 models, texture sets, HDRIs; scanned and hand-made, realistic | API, no key: `https://api.polyhaven.com/assets?t=models` lists them, `/info/ID` gives authors and size, `/files/ID` gives every file with its url, size and md5. The API's terms ask for a User-Agent or Referer naming your software, and a visible credit naming Poly Haven in a product that shows its content through the live API. The assets themselves need no credit. |
|
||||
| ambientCG (ambientcg.com) | PBR materials and HDRIs; only 34 models | API, no key: `https://ambientcg.com/api/v3/assets?type=3d-model&include=downloads` gives each asset's zips (`https://ambientcg.com/get?file=ID_LQ-1K-JPG.zip`): an OBJ, a .blend, a .usdc and the maps. convert.py takes the OBJ. |
|
||||
| Smithsonian Open Access 3D (3d.si.edu) | about 3,400 scans: furniture, fossils, aircraft, spacecraft, sculpture | API, no key: `https://3d-api.si.edu/api/v1.0/content/file/search?q=WORDS&file_type=glb&quality=Thumb` (or `Low`, `Medium`); each row's `content.uri` is the file. The rows carry no licence field: only items marked CC0 on their 3d.si.edu page are open, the rest have "usage conditions". The .glb files are Draco-compressed and in the scanner's units. |
|
||||
| The Base Mesh (thebasemesh.com) | 1,250+ untextured base meshes of everyday things | the site's download buttons; no API found |
|
||||
| Polygonal Mind's sets (opensource3dassets.com) | 18 themed sets of stylised .glb props | a registry on GitHub: `https://raw.githubusercontent.com/ToxSam/open-source-3d-assets/main/data/projects.json` lists the sets with each one's `license` and `asset_data_file`, which holds direct links |
|
||||
| Kenney (kenney.nl), Quaternius (quaternius.com), KayKit (kaylousberg.com) | low-poly game props, kits and characters | zips from each site; KayKit's packs are also repositories under `github.com/KayKit-Game-Assets`, each with its licence file. Low-poly by design: for games, not for realism. |
|
||||
| Sketchfab, CC0 filter | a slice of its downloadable models; quality varies | search, no key: `https://api.sketchfab.com/v3/search?type=models&downloadable=true&license=cc0&q=WORDS`; each result names its licence and uploader. Downloading needs the person's Sketchfab login (an OAuth token). The licence is the uploader's choice: prefer a museum's or a studio's own account. |
|
||||
|
||||
## CC BY: use with the credit in the sidecar
|
||||
|
||||
| source | what it has | fetch | credit |
|
||||
|---|---|---|---|
|
||||
| Amazon Berkeley Objects | 7,953 real products as .glb with PBR maps up to 4K: chairs, sofas, lamps, tables, shelves | no account: `https://amazon-berkeley-objects.s3.amazonaws.com/3dmodels/metadata/3dmodels.csv.gz` lists each model's `path`, faces and extents; the file is `.../3dmodels/original/PATH` (or `aws s3 cp --no-sign-request s3://amazon-berkeley-objects/3dmodels/original/PATH .`) | CC BY 4.0; "Amazon.com" for the data, and the dataset's authors as its README lists them |
|
||||
| Google Scanned Objects | scanned household things: toys, shoes, kitchenware, boxes | Gazebo Fuel, no key: `https://fuel.gazebosim.org/1.0/GoogleResearch/models?per_page=100` lists them with each one's `license_name`; `https://fuel.gazebosim.org/1.0/GoogleResearch/models/NAME.zip` is an OBJ with one texture | CC BY 4.0, Google Research |
|
||||
| Objaverse (Hugging Face `allenai/objaverse`) | 800K+ objects gathered from Sketchfab | per-object metadata | each object's own: 721K CC BY 4.0, 3.5K CC0, the rest NC or SA. Keep only CC BY and CC0 rows, and the author for the credit. |
|
||||
| Amazon Lumberyard Bistro | a Paris street (2.8M triangles) and a bistro interior (1M), FBX | NVIDIA ORCA's page: `developer.nvidia.com/orca/amazon-lumberyard-bistro` | CC BY 4.0 |
|
||||
| Intel Sponza (2022) and Jungle Ruins | the atrium as glTF, FBX and USD (3.7 GB); a rainforest ruin as .blend and USD (4 GB) | Intel's graphics research samples page | "Creative Commons Attribution"; the page states no version |
|
||||
|
||||
`bevy/blend-files` lists Blender's own open files (CC0 and CC BY), and `bevy/godot-projects` Godot's.
|
||||
|
||||
## Free, but not to pass on
|
||||
|
||||
Usable in a render. Never placed in a public project, a shared library or a skill, because the licence forbids handing
|
||||
the file itself to anyone else.
|
||||
|
||||
| source | the term that limits it |
|
||||
|---|---|
|
||||
| Fab's Standard License (Quixel Megascans and other listings sold under it) | commercial use in any tool, no credit; "may not resell or redistribute the asset for free on a standalone basis". Needs an Epic account, so the person downloads. |
|
||||
| BlenderKit | two licences: CC0, and "Royalty Free", which allows commercial use and forbids selling the asset on as an asset. Filter to CC0 for anything a project ships. |
|
||||
| ShareTextures | a "Custom CC0": no redistribution on other sites, in plugins or in collections, and "no automated downloads". By hand from the site, or not at all. |
|
||||
|
||||
## Don't use
|
||||
|
||||
| source | why |
|
||||
|---|---|
|
||||
| ALab (Netflix Animation Studios, on ASWF) | the ASWF Digital Assets License allows use "solely for education, training, research, software and hardware development, performance benchmarking ... or software and hardware product demonstrations". A film or an ad is none of those. |
|
||||
| Pixar's Kitchen Set | "only for your personal, non-commercial testing of Pixar's Universal Scene Description technology" |
|
||||
| NVIDIA Emerald Square | CC BY-NC-SA 3.0 |
|
||||
| Sketchfab "Standard" and "Editorial" licences | no making the file available on its own; Editorial also forbids commercial use |
|
||||
| anything CC BY-SA, CC BY-NC or CC BY-ND | outside the rule |
|
||||
|
||||
## Make it instead
|
||||
|
||||
- **Infinigen** (Princeton, BSD 3-Clause): procedural nature and furnished rooms made in Blender. Heavy to run; not
|
||||
run for this guide.
|
||||
- **ProcTHOR and ProcTHOR-10K** (Allen Institute, Apache-2.0): procedurally laid-out houses. Layouts more than looks.
|
||||
- `raea gen mesh` for one object with character (`motion/gen`), and solids, `sdf` and `grow` for anything defined by
|
||||
numbers or a rule (`bevy/scenes`).
|
||||
|
||||
## Not checked
|
||||
|
||||
Stated by others, or not reachable when this was written. Read each at its source before first use.
|
||||
|
||||
- The Met's 3D models: its Open Access policy puts images of public-domain works under CC0 and names "2D and 3D
|
||||
images", but no licence on a downloadable model file was found.
|
||||
- SMK (National Gallery of Denmark): its scans are on MyMiniFactory through Scan the World; the licence there wasn't read.
|
||||
- grab3d.com states CC0 for everything and doesn't say who made the models.
|
||||
- Megascans being free of charge on Fab since 2026-11-05 comes from news reports; Fab's listings weren't read.
|
||||
- Disney's Moana Island, 3D-FRONT and Unreal-only content were not read again: an earlier survey found them research-only,
|
||||
non-commercial and Unreal-only.
|
||||
- Poly Pizza (the Blender MCP can search it), and how many models Google Scanned Objects holds.
|
||||
|
||||
## Why
|
||||
|
||||
A render is published, and a raea project is often a public repository, so an asset's licence has to cover both
|
||||
showing it and handing its file on. CC0, CC BY and MIT-like terms do; a marketplace's "free" usually covers only the
|
||||
first. The sidecar is what lets anyone check that later, and what a film's credits are built from.
|
||||
|
||||
## Common mistakes
|
||||
|
||||
- **Free taken as open.** Megascans, BlenderKit's Royalty Free and ShareTextures are free to use and forbidden to
|
||||
pass on.
|
||||
- **One licence assumed for a whole library.** Objaverse, Sketchfab, the Godot Asset Library and blender.org's demo
|
||||
files are licensed per item. Read the item's own field and put that in the sidecar.
|
||||
- **A CC0 scan of a branded product.** CC0 and CC BY cover the scan's copyright, not the logo on it. The Smithsonian
|
||||
says so itself ("a third party may claim rights ... such as trademark, privacy, or publicity rights"), and Amazon's
|
||||
and Google's scans are of real retail products. Pick unbranded ones, or cover the label with a decal
|
||||
(`bevy/materials`).
|
||||
- **A repository's licence taken for its art.** MIT on a demo's code says nothing about its models
|
||||
(`bevy/godot-projects` has two that differ).
|
||||
- **A research licence that reads like an open one.** ALab and the Kitchen Set download freely and forbid production use.
|
||||
- **A `.glb` that isn't whole.** A game kit's `.glb` can name a texture file beside it. `raea gen check` passes it and
|
||||
the render then refuses it for the missing path. Run convert.py on it where it sits in the kit, which packs the
|
||||
texture in, unless it has clips (the table above).
|
||||
- **A compressed `.glb`.** `raea gen check` reports `KHR_draco_mesh_compression` as an error and names convert.py.
|
||||
- **A scan placed at the size it came.** A Smithsonian chair measured 9.6 m tall as downloaded. Pass `--h`.
|
||||
- **`curl` without `-L` on blender.org's demo links,** which answer with a page: the files are under
|
||||
`https://download.blender.org/demo/`.
|
||||
|
||||
## Example: a Poly Haven stool, fetched, converted and checked
|
||||
|
||||
Run end to end for this guide on 2026-11-10 (676 triangles, 0.385 x 0.579 x 0.406 m, `raea gen check`: 0 errors).
|
||||
The same steps were run on an ambientCG apple (its OBJ) and a Smithsonian side chair (Draco-compressed, 9.6 m as
|
||||
downloaded).
|
||||
|
||||
`blender/polyhaven.sh`, the project's fetch step (it needs `curl` and `jq`):
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
# polyhaven.sh ID [RES]: one Poly Haven model as glTF with its textures in src/ID, and its licence sidecar
|
||||
set -euo pipefail
|
||||
id=$1 res=${2:-1k} ua="my-project-name"
|
||||
mkdir -p "src/$id" && cd "src/$id"
|
||||
curl -fsS -A "$ua" "https://api.polyhaven.com/files/$id" -o files.json
|
||||
curl -fsS -A "$ua" -O "$(jq -r --arg r "$res" '.gltf[$r].gltf.url' files.json)"
|
||||
jq -r --arg r "$res" '.gltf[$r].gltf.include | to_entries[] | "\(.key)\t\(.value.url)"' files.json |
|
||||
while IFS=$'\t' read -r rel url; do mkdir -p "$(dirname "$rel")"; curl -fsS -A "$ua" -o "$rel" "$url"; done
|
||||
curl -fsS -A "$ua" "https://api.polyhaven.com/info/$id" |
|
||||
jq --arg id "$id" '{source: ("https://polyhaven.com/a/" + $id), license: "CC0", credit: ("Poly Haven: " + (.authors | keys | join(", ")))}' \
|
||||
> "${id}_${res}.gltf.json"
|
||||
```
|
||||
|
||||
```sh
|
||||
bash blender/polyhaven.sh painted_wooden_stool 1k
|
||||
raea blender run blender/convert.py src/painted_wooden_stool/painted_wooden_stool_1k.gltf media/stool.glb --max-texture 1024
|
||||
raea gen check media/stool.glb --h 0.58
|
||||
```
|
||||
|
||||
`media/stool.glb.json` then reads
|
||||
`{"source": "https://polyhaven.com/a/painted_wooden_stool", "license": "CC0", "credit": "Poly Haven: Kirill Sannikov", "steps": [...]}`.
|
||||
|
||||
```tsx
|
||||
import { AbsoluteFill, Composition, registerRoot, staticFile } from "raea";
|
||||
import { Model } from "raea/3d";
|
||||
import { StandardMaterial } from "raea/pbr";
|
||||
import { Cuboid, Mesh3d } from "raea/mesh";
|
||||
import { AmbientLight, DirectionalLight } from "raea/light";
|
||||
import { Transform } from "raea/transform";
|
||||
import { Camera3d } from "raea/camera";
|
||||
|
||||
function Stool() {
|
||||
return (
|
||||
<AbsoluteFill style={{ background: "#e9e4da" }}>
|
||||
<Camera3d transform={Transform.fromXyz(0, 0.9, 2.4).lookingAt([0, 0.3, 0])} projection={{ Perspective: { fov: (40 * Math.PI) / 180 } }} />
|
||||
<AmbientLight brightness={300} />
|
||||
<DirectionalLight transform={Transform.fromXyz(3, 6, 4).lookingAt([0, 0, 0])} illuminance={9600} shadow_maps_enabled />
|
||||
<Mesh3d transform={Transform.fromXyz(0, -0.05, 0)}>
|
||||
<Cuboid half_size={[5, 0.05, 5]} />
|
||||
<StandardMaterial base_color="#cfc8ba" perceptual_roughness={0.9} />
|
||||
</Mesh3d>
|
||||
<Model src={staticFile("stool.glb")} position={[0, 0, 0]} />
|
||||
</AbsoluteFill>
|
||||
);
|
||||
}
|
||||
|
||||
registerRoot(() => <Composition id="stool" component={Stool} width={1280} height={720} fps={30} durationInFrames={30} />);
|
||||
```
|
||||
Reference in new issue
Block a user