Turtle shapes and demo

This commit is contained in:
Tony Garnock-Jones 2023-02-13 17:39:13 +01:00
parent 4bee2be4f0
commit 7fba434a0d
4 changed files with 68 additions and 14 deletions

View File

@ -5,7 +5,7 @@ Variable = <variable @spriteName string @variable symbol @value any> .
Shape = Mesh / Light / Scale / Move / Rotate / @many [Shape ...] / Texture / Color / Sound / Name / Floor / Nonphysical / Touchable / CSG / Skybox .
Mesh = Sphere / Box / Ground / Plane / External .
Mesh = Sphere / Box / Ground / Plane / External / @turtle turtle.Shape .
Sphere = <sphere> .
Box = <box> .

View File

@ -0,0 +1,7 @@
version 1 .
Program = Block .
Block = [Token ...] .
Token = @i int / @d double / @b bool / @s string / @v symbol / @block Block .
Shape = <turtle @program Program> .

View File

@ -92,18 +92,58 @@
; <scale <v 0.01 0.01 0.01>
; <external "objects/IKE020001_obj/IKEA-Arild_2_Seat_Sofa-3D.obj">>>>
<sprite "x" []
<move <v 10.0 1.6 -5.0>
<texture ["textures/oak-herringbone-5e80fb40b00c9-1200.jpg"
<v 1.0 3.0 1.0>
<v 0.0 0.0 0.0>]
<sound <stream "https://streams.95bfm.com/stream95">
<csg
<subtract [
<move <v 0.0 0.0 0.5> <scale <v 1.1 3.1 1.1> <mesh <box>>>>
<move <v 0.0 0.0 0.5> <scale <v 1.0 3.0 1.0> <mesh <box>>>>
]>
>>>>>
; <sprite "x" []
; <move <v 10.0 1.6 -5.0>
; <texture ["textures/oak-herringbone-5e80fb40b00c9-1200.jpg"
; <v 1.0 3.0 1.0>
; <v 0.0 0.0 0.0>]
; <sound <stream "https://streams.95bfm.com/stream95">
; <csg
; <subtract [
; <move <v 0.0 0.0 0.5> <scale <v 1.1 3.1 1.1> <mesh <box>>>>
; <move <v 0.0 0.0 0.5> <scale <v 1.0 3.0 1.0> <mesh <box>>>>
; ]>
; >>>>>
; <sprite "tt" []
; <move <v 0.0 1.6 0.0>
; <turtle [
; 1 to slen
; 0.025 to dlen
; 90 U
; dlen 10 * F
; PenDown
; 90 L
; [12 L dlen 2 * F] 30 times
; 90 R
; slen F
; SetPen
; Home
; PenDown
; [6 CW dlen F] 240 times
; PenUp
; ]>>>
<sprite "tt" []
<move <v 0.0 0.01 0.75>
<turtle [
1.0 to wallHeight
0.1 to wallDepth
90 U
PenDown
[wallHeight F 90 L wallDepth F 90 L] 2 times
SetPen
Home
[ 10 to k k / [dup F] k times drop ] to ff
1 CornerDivisions
1 1 1 PenScale
PenDown
1 ff 90 R 1 ff 90 R 1 ff 90 R 1 ff 90 R
PenUp
]>>>
; <Exit "y" "lobby">
; <sprite "y" []

View File

@ -20,9 +20,10 @@ import {
Vector2,
Vector3,
} from '@babylonjs/core/Legacy/legacy';
import { Dataflow, IdentityMap, KeyedDictionary, Ref, Value, is } from "@syndicate-lang/core";
import { Dataflow, IdentityMap, KeyedDictionary, Ref, Value, is, fromJS } from "@syndicate-lang/core";
import * as Shapes from './gen/shapes.js';
import { TurtleVM } from './turtle.js';
export class Environment {
fields = new IdentityMap<symbol, Dataflow.Field<Value<Ref>>>();
@ -260,6 +261,12 @@ export function buildMesh(
}),
};
}
case "turtle": {
const t = new TurtleVM(name, scene, meshSpec.value.program.map(fromJS));
t.debug = true;
t.exec();
return { rootnode: t.container };
}
}
}