m = s => 1 if s == '#' else 0 // material_pat = [ // "### # # #", // " # # # # ", // "# # ### #", // " ### # # ", // "# # ### #", // " # ### ", // "# # # ##", // " ### # # ", // "# # ### #", // ] material_pat = [ "# # # # #", " # # # # ", "# # # # #", " # # # # ", "# # # # #", " # # # # ", "# # # # #", " # # # # ", "# # # # #", ] HVS_to_string = (HVSArray) { HVSstr = HVSArray[0] as @string + 'a' + HVSArray[1] as @string + 'a' + HVSArray[2] as @string + 'a0a0' return HVSstr } type @fullcube impl @fullcube { new: ( s, scaling, vert, dir, ref_grid, ref_grid_main, ref_grid_center, follow_frame, offset, side1, side2, move_group, ) { box = @voxel::new([[?c, ?c], [?c, ?c]], [?g, ?g, ?g], ?g, dir, vert, scaling) make_letter_cube = (side1, side2, vert) { let cube = [] for x in ..s { let layer = [] for y in ..s { let strip = [] for z in ..s { if vert { strip.push( side1[s-y-1][x] == '#' && side2[(s-z-1) if dir == -1 else z][x] == '#' ) } else { strip.push( side1[s-y-1][x] == '#' && side2[s-y-1][(s-z-1) if dir == 1 else z] == '#' ) } } layer.push(strip) } cube.push(layer) } return cube } cube = make_letter_cube(side1, side2, vert) for x in ..s { for y in ..s { for z in ..s { if cube[x][y][z] { box.make( [offset[0] + x * 30 * scaling, offset[1] + y * 30 * scaling], z + (y * dir if vert else x * dir), [ follow_frame[y][z] if vert else follow_frame[x][z], move_group ], m(material_pat[x][y]), m(material_pat[x][z] if vert else material_pat[z][y]), ) } } } } return @fullcube::{ s, dir, ref_grid, ref_grid_main, ref_grid_center, follow_frame, vert, box, } }, animate: (self, t) { s = self.s for x in ..s { for y in ..s { g = self.follow_frame[(s-x-1) if self.dir == -1 else x][y] -> g.pulse(0, 1, 0.4 + 0.6*((y + 1) / s), 0.1 * t * 2, 0, 1.1 * t * 2, hsv = true) -> g.pulse(0, 1, 0.4 + 0.6*((x + 1) / s), 1.1 * t * 2, 0, 0.1 * t * 2, hsv = true) if self.vert { g.follow(self.ref_grid[y][x], x_mod = 0, y_mod = 1 * self.dir, duration = t * 2 + 0.2) } else { g.follow(self.ref_grid[x][y], x_mod = 1 * self.dir, y_mod = 0, duration = t * 2 + 0.2) } } } wait(0.1) -> self.ref_grid_main.rotate(self.ref_grid_center, 90 if self.vert else -90, t * 2, EASE_IN_OUT) -> self.box.animate(t) wait(t * 2 + 0.15) -> self.ref_grid_main.rotate(self.ref_grid_center, -90 if self.vert else 90) } }