# Learn ShapeJS

Discussion in 'ShapeJS' started by AlanHudson, Mar 22, 2016.

1. AlanHudson Shapeways Employee Dev Team
2. AlanHudson Shapeways Employee Dev Team
3. AlanHudson Shapeways Employee Dev Team
4. AlanHudson Shapeways Employee Dev Team
5. AlanHudson Shapeways Employee Dev Team
6. twoshay Well-Known Member
Hey... in the upcoming discussion on 2- and 3-period wrappings, will you have the code for the 'waffle'? I'm really curious how you handled the outer ring where the grid merges with the border. Like... is it a square grid cut by a cylinder, then an oval torus is wrapped around, or is the grid constrained so that it's a circle right from the start?

Thx!
Tim

7. bulatov Shapeways Employee Dev Team
here is that example code
Code:
```function main(args) {

var w =30*MM; // scene size
var a = 5*MM; // period of wrap
var r = 1*MM;

var s1 = new Cylinder(new Vector3d(a/2, -a/2, 0), new Vector3d(a/2, 3*a/2, 0), r);
var s2 = new Cylinder(new Vector3d(-a/2, a/2, 0), new Vector3d(3*a/2, a/2, 0), r);
var pw = new PeriodicWrap(new Vector3d(a,0,0),new Vector3d(0,a,0));
var grid = new Union(s1, s2);
grid.setTransform(pw);
var croppedGrid = new Intersection(grid, new Sphere(0,0,0,w-r));
var shape = new Union(croppedGrid, new Torus(w-r, r));

return new Scene(shape,new Bounds(-w,w,-w,w,-w,w));
}
```

Last edited: May 11, 2016
8. AlanHudson Shapeways Employee Dev Team
9. twoshay Well-Known Member
Thanks! This helps a lot. I always find it fascinating how such complex objects can be put together by arranging/sequencing simple components.