Let Spawn take an asset over an edge and find a child by name (#237)

An asset could only be picked as a setting on the Spawn node. It could
not be wired in, held in a variable or put into a list. Finding an
object below the own one needed a scene-wide search by name.

- "Asset" is now a kind like Animation or Sound: port, variable, list
  item and a new "Asset" literal node, with its own cube icon.
- Spawn and Is asset have an `asset` input. It uses the key of the old
  setting, so a saved asset reads as the value of the input and older
  projects keep spawning without a migration.
- New node "Child by name" searches below an object level by level.
  A child wins over a grandchild of the same name. Nothing found or no
  object gives null.

Tests:
- ./check.sh: 168 files, 2453 tests, CHECK EXIT 0.
- 9 new unit tests in tests/core/asset-kind.test.ts, catalog cases for
  Spawn, Is asset, Child by name and the literal.
- e2e 6z-ii (2 checks): node rows and a real drag of the literal onto
  `asset`. e2e 6: 119 checks passed. Spawn checks in 3 and 9 passed.
- Counter-checks: depth-first search fails 1, Spawn reading only the
  old setting fails 3, runtime ignoring the parent fails 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-09-26 19:36:49 +02:00
1 parent 1b3cb625a3
commit 923baf2557
18 files changed
+345 -24

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import type { NodeDef } from '../../NodeRegistry';
import { asEntity, asString } from '../../values';
import { obj, str } from '../shared';
export const ChildByName: NodeDef = {
type: 'ChildByName',
label: 'Child by name',
category: 'data',
description:
'Finds an object by its name below the given one – among its children, their children and so on. ' +
'The nearest level wins; within a level, the first in hierarchy order. Nothing when none is called so.',
inputs: [obj('object'), str('name')],
outputs: [obj('child')],
params: [],
run: (ctx, inputs) => {
const parent = asEntity(inputs.object);
const name = asString(inputs.name);
return { outputs: { child: parent ? ctx.childByName(parent, name) : null } };
},
};
+6 -7
View File
@@ -1,18 +1,17 @@
import type { NodeDef } from '../../NodeRegistry';
import { asEntity } from '../../values';
import { assetParam, bool, obj } from '../shared';
import { asEntity, asString } from '../../values';
import { assetPort, bool, obj } from '../shared';
import { textOf } from '../../../model/Properties';
export const IsAsset: NodeDef = {
type: 'IsAsset',
label: 'Is asset',
category: 'data',
description: 'Whether an object is an instance of the chosen asset – the way to tell what you collided with.',
inputs: [obj('object')],
inputs: [obj('object'), assetPort()],
outputs: [bool('result')],
params: [assetParam],
run: (_ctx, inputs, params) => {
const assetId = textOf(params.asset ?? '');
params: [],
run: (_ctx, inputs) => {
const assetId = asString(inputs.asset);
return { outputs: { result: Boolean(assetId) && asEntity(inputs.object)?.assetId === assetId } };
},
};
+5
View File
@@ -50,6 +50,11 @@ export const AnimationLiteral = literal(
'animation',
'A constant animation, for a "Play animation", "Pause animation" or "Stop animation" to work on.',
);
export const AssetLiteral = literal(
'Asset',
'asset',
'A constant placeable asset, for a "Spawn" to place or an "Is asset" to compare with.',
);
export const ListLiteral = literal(
'List',
'list',