Skip to content

Custom Botball objects #556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/components/World/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,11 @@ class World extends React.PureComponent<Props, State> {
};

private onItemVisibilityChange_ = (id: string) => (visibility: boolean) => {
const originalNode = Async.previousValue(this.props.scene).nodes[id];
let originalNode = Async.previousValue(this.props.scene).nodes[id];
// Custom items do not appear in previousValue, which causes an error
if (!originalNode) {
originalNode = Async.latestValue(this.props.scene).nodes[id];
}

this.props.onNodeChange(id, {
...originalNode,
Expand Down Expand Up @@ -403,6 +407,7 @@ class World extends React.PureComponent<Props, State> {

const itemList: EditableList.Item[] = [];


const workingScene = Async.latestValue(scene);
for (const nodeId of Dict.keySet(workingScene.nodes)) {
const node = workingScene.nodes[nodeId];
Expand Down Expand Up @@ -548,4 +553,4 @@ class World extends React.PureComponent<Props, State> {

export default connect((state: ReduxState) => ({
locale: state.i18n.locale,
}))(World) as React.ComponentType<WorldPublicProps>;
}))(World) as React.ComponentType<WorldPublicProps>;
6 changes: 3 additions & 3 deletions src/simulator/definitions/nodes/2025gameTableTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ const frenchFryTemplate: Node.TemplatedNode<Node.Obj> = {
type: 'box',
restitution: .5,
friction: .6,
mass: Mass.grams(2),
inertia: [4, 4, 4]
mass: Mass.grams(8),
inertia: [4, 4, 4],
},
};
const hamburgerTemplate: Node.TemplatedNode<Node.Obj> = {
Expand Down Expand Up @@ -184,7 +184,7 @@ const potatoTemplate: Node.TemplatedNode<Node.Obj> = {
type: 'mesh',
restitution: .7,
friction: 1,
mass: Mass.grams(3),
mass: Mass.grams(8),
inertia: [2, 2, 2],
}
};
Expand Down
53 changes: 4 additions & 49 deletions src/simulator/definitions/scenes/tableSandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,80 +20,63 @@ const WARMING_X = 9;

const HAMBURGER_ORIGIN: ReferenceFramewUnits = {
position: Vector3wUnits.centimeters(WARMING_X, 24, 114),
orientation: RotationwUnits.eulerDegrees(0, 45, 0),
scale: { x: 100, y: 100, z: 100 }
};

const HOTDOG_ORIGIN: ReferenceFramewUnits = {
position: Vector3wUnits.centimeters(WARMING_X, 24, 102.5),
orientation: RotationwUnits.eulerDegrees(0, 90, 0),
scale: { x: 100, y: 100, z: 100 }
};

const TACO_ORIGIN: ReferenceFramewUnits = {
position: Vector3wUnits.centimeters(WARMING_X, 25, 93),
orientation: RotationwUnits.eulerDegrees(-60, 0, 0),
scale: { x: 100, y: 100, z: 100 }
};

const CUP_X = 8;
const CUP_Y = 6;
const CUP_PINK_ORIGIN: ReferenceFramewUnits = {
position: Vector3wUnits.centimeters(CUP_X, CUP_Y, 114.5),
scale: { x: 100, y: 100, z: 100 }
};

const CUP_BLUE_ORIGIN: ReferenceFramewUnits = {
position: Vector3wUnits.centimeters(CUP_X, CUP_Y, 102.5),
scale: { x: 100, y: 100, z: 100 }
};

const CUP_GREEN_ORIGIN: ReferenceFramewUnits = {
position: Vector3wUnits.centimeters(CUP_X, CUP_Y, 91),
scale: { x: 100, y: 100, z: 100 }
};

const POM_Y = 4;
const POM_BLUE_ORIGINS_BACK: ReferenceFramewUnits[] = [
{
position: Vector3wUnits.centimeters(18, POM_Y, 53),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(18, POM_Y, 43),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(23, POM_Y, 53),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(23, POM_Y, 43),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(28, POM_Y, 53),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(28, POM_Y, 43),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(15.5, POM_Y, 48),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(20.5, POM_Y, 48),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(25.5, POM_Y, 48),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(30.5, POM_Y, 48),
scale: { x: 100, y: 100, z: 100 },
},
];

Expand All @@ -108,116 +91,93 @@ const BOTTLE_Y = 7;
const BOTTLE_ORIGINS: ReferenceFramewUnits[] = [
{
position: Vector3wUnits.centimeters(29.5, BOTTLE_Y, 33.4),
scale: { x: 100, y: 100, z: 100 }
},
{
position: Vector3wUnits.centimeters(29.5, BOTTLE_Y, 26.3),
scale: { x: 100, y: 100, z: 100 }
},
{
position: Vector3wUnits.centimeters(29.5, BOTTLE_Y, 19.2),
scale: { x: 100, y: 100, z: 100 }
},
{
position: Vector3wUnits.centimeters(22.4, BOTTLE_Y, 33.4),
scale: { x: 100, y: 100, z: 100 }
},
{
position: Vector3wUnits.centimeters(22.4, BOTTLE_Y, 26.3),
scale: { x: 100, y: 100, z: 100 }
},
{
position: Vector3wUnits.centimeters(22.4, BOTTLE_Y, 19.2),
scale: { x: 100, y: 100, z: 100 }
},
];

const CENTER_LINE_X = 65.5;
const POM_RED_ORIGINS: ReferenceFramewUnits[] = [
{
position: Vector3wUnits.centimeters(CENTER_LINE_X, POM_Y, 0),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(CENTER_LINE_X, POM_Y, 45.72),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(CENTER_LINE_X, POM_Y, -45.72),
scale: { x: 100, y: 100, z: 100 },
},
];
const POM_ORANGE_ORIGINS: ReferenceFramewUnits[] = [
{
position: Vector3wUnits.centimeters(CENTER_LINE_X - 11.43, POM_Y, 0),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(CENTER_LINE_X, POM_Y, -15.24),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(CENTER_LINE_X, POM_Y, 30.48),
scale: { x: 100, y: 100, z: 100 },
},
];
const POM_YELLOW_ORIGINS: ReferenceFramewUnits[] = [
{
position: Vector3wUnits.centimeters(CENTER_LINE_X - (2 * 11.43), POM_Y, 0),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(CENTER_LINE_X, POM_Y, 15.24),
scale: { x: 100, y: 100, z: 100 },
},
{
position: Vector3wUnits.centimeters(CENTER_LINE_X, POM_Y, -30.48),
scale: { x: 100, y: 100, z: 100 },
},
];

const TOMATO_ORIGIN: ReferenceFramewUnits = {
position: Vector3wUnits.centimeters(29, 4, -14.3891),
scale: { x: 100, y: 100, z: 100 },
};

const PICKLE_ORIGIN: ReferenceFramewUnits = {
position: Vector3wUnits.centimeters(27, 2, -25.8191),
orientation: RotationwUnits.eulerDegrees(0, 90, 0),
scale: { x: 100, y: 100, z: 100 },
};

const POTATO_ORIGIN: ReferenceFramewUnits = {
position: Vector3wUnits.centimeters(35, 10, -85),
scale: { x: 100, y: 100, z: 100 },
orientation: RotationwUnits.eulerDegrees(-90, 180, 0),
};

const FRY_ORIGINS: ReferenceFramewUnits[] = [
{
position: Vector3wUnits.centimeters(115, 21, -87),
scale: { x: 100, y: 100, z: 100 }
},
{
position: Vector3wUnits.centimeters(115, 21, -88),
scale: { x: 100, y: 100, z: 100 }
},
{
position: Vector3wUnits.centimeters(115, 21, -89),
scale: { x: 100, y: 100, z: 100 }
},
{
position: Vector3wUnits.centimeters(115, 22.5, -87.5),
scale: { x: 100, y: 100, z: 100 }
},
{
position: Vector3wUnits.centimeters(115, 22.5, -88.5),
scale: { x: 100, y: 100, z: 100 }
},
];

const BOTGUY_ORIGIN: ReferenceFramewUnits = {
position: Vector3wUnits.centimeters(-4, 24, -3),
scale: { x: 100, y: 100, z: 100 },
};


Expand Down Expand Up @@ -358,18 +318,17 @@ const POMS_RANDOM: Dict<Node.FromBBTemplate> = {};
const choices = ['pom_red', 'pom_red', 'pom_red', 'pom_orange', 'pom_orange', 'pom_orange', 'pom_yellow', 'pom_yellow', 'pom_yellow'];
for (let i = 0; i < 9; i++) {
const n = Math.floor(Math.random() * choices.length);
const robot = choices[n];
const choice = choices[n];
choices.splice(n, 1);

const pos = {
position: Vector3wUnits.centimeters(91, POM_Y, (-45.72 + 11.43 * i)),
scale: { x: 100, y: 100, z: 100 },
};

POMS_RANDOM[`pom_random${i}`] = {
type: 'from-bb-template',
name: tr(`Random pom #${i}`),
templateId: robot,
templateId: choice,
visible: true,
editable: true,
startingOrigin: pos,
Expand Down Expand Up @@ -425,7 +384,6 @@ for (let i = 0; i < 6; i++) {
const pos = {
position: Vector3wUnits.centimeters(107.5, 3, (19.7 - 13.45 * i)),
orientation: RotationwUnits.eulerDegrees(0, 90, 0),
scale: { x: 100, y: 100, z: 100 },
};

TRAYS[`tray${i}`] = {
Expand Down Expand Up @@ -454,7 +412,6 @@ for (let i = 0; i < 5; i++) {
const pos: ReferenceFramewUnits = {
position: Vector3wUnits.centimeters(18.6, 2.54 + (5.17 * i), -102.55),
orientation: RotationwUnits.eulerDegrees(0, 45, 0),
scale: { x: 100, y: 100, z: 100 }
};
DRINKS_BLUE[`drink_blue${i}`] = {
type: 'from-bb-template',
Expand All @@ -472,7 +429,6 @@ for (let i = 0; i < 5; i++) {
const pos: ReferenceFramewUnits = {
position: Vector3wUnits.centimeters(0.4, 2.54 + (5.17 * i), 71.252),
orientation: RotationwUnits.eulerDegrees(0, 45, 0),
scale: { x: 100, y: 100, z: 100 }
};
DRINKS_GREEN[`drink_green${i}`] = {
type: 'from-bb-template',
Expand All @@ -490,7 +446,6 @@ for (let i = 0; i < 5; i++) {
const pos: ReferenceFramewUnits = {
position: Vector3wUnits.centimeters(0.4, 2.54 + (5.17 * i), -71.4),
orientation: RotationwUnits.eulerDegrees(0, 45, 0),
scale: { x: 100, y: 100, z: 100 }
};
DRINKS_PINK[`drink_pink${i}`] = {
type: 'from-bb-template',
Expand Down Expand Up @@ -552,4 +507,4 @@ export const Table_Sandbox: Scene = {
editable: true,
},
}
};
};
4 changes: 3 additions & 1 deletion src/state/State/Scene/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ namespace Node {
export const upcast = <T extends Base>(t: T): Base => ({
name: t.name,
origin: t.origin,
startingOrigin: t.startingOrigin,
scriptIds: t.scriptIds,
documentIds: t.documentIds,
editable: t.editable,
Expand Down Expand Up @@ -602,6 +603,7 @@ namespace Node {
case 'from-jbc-template': return FromJBCTemplate.from(node);
case 'from-rock-template': return FromRockTemplate.from(node);
case 'from-space-template': return FromSpaceTemplate.from(node);
case 'from-bb-template': return FromBBTemplate.from(node);
case 'robot': return Robot.from(node);
}
};
Expand All @@ -626,4 +628,4 @@ type Node = (
Node.Robot
);

export default Node;
export default Node;
4 changes: 2 additions & 2 deletions static/object_binaries/botguy.glb
Git LFS file not shown
4 changes: 2 additions & 2 deletions static/object_binaries/bottle.glb
Git LFS file not shown
4 changes: 2 additions & 2 deletions static/object_binaries/cup_blue.glb
Git LFS file not shown
4 changes: 2 additions & 2 deletions static/object_binaries/cup_green.glb
Git LFS file not shown
4 changes: 2 additions & 2 deletions static/object_binaries/cup_pink.glb
Git LFS file not shown
4 changes: 2 additions & 2 deletions static/object_binaries/drink_blue.glb
Git LFS file not shown
4 changes: 2 additions & 2 deletions static/object_binaries/drink_green.glb
Git LFS file not shown
4 changes: 2 additions & 2 deletions static/object_binaries/drink_pink.glb
Git LFS file not shown
2 changes: 1 addition & 1 deletion static/object_binaries/dropper.glb
Git LFS file not shown
4 changes: 2 additions & 2 deletions static/object_binaries/french_fry.glb
Git LFS file not shown
4 changes: 2 additions & 2 deletions static/object_binaries/hamburger.glb
Git LFS file not shown
Loading