“Hugo,” an enchantment from Martin Scorsese, is the 3-D children’s movie that you might expect from the director of “Raging Bull” and “Goodfellas.” It’s serious, beautiful, wise to the absurdity of life and in the embrace of a piercing longing. No one gets clubbed to death, but shadows loom, and a ferocious Doberman nearly lands in your lap. The movie is based on the book “The Invention of Hugo Cabret,” but is also very much an expression of the filmmaker’s movie love. Surely the name of its author, Brian Selznick, caught his eye: Mr. Selznick is related to David O. Selznick, the producer of “Gone With the Wind” — kismet for a cinematic inventor like Mr. Scorsese.Mr. Scorsese’s fidelity to Mr. Selznick’s original story is very nearly complete, though this is also, emphatically, his own work. Gracefully adapted by John Logan, the movie involves a lonely, melancholic orphan, Hugo (Asa Butterfield), who in the early 1930s tends all the clocks in a Parisian train station. Seemingly abandoned by his uncle, the station’s official timekeeper (Ray Winstone), Hugo lives alone, deep in the station’s interior, in a dark, dusty, secret apartment that was built for employees. There, amid clocks, gears, pulleys, jars and purloined toys, he putters and sleeps and naturally dreams, mostly of fixing a delicate automaton that his dead father, a clockmaker (Jude Law), found once upon a time. The automaton is all that remains of a happy past.Hugo has been repairing the automaton with mechanical parts salvaged from the toys he has stolen from a toy store in the station. All that he needs now to bring the windup figure to life — it sits frozen, with a pen at the ready, as if waiting for inspiration — is the key that will open its heart-shaped lock. After assorted stops and starts and quick getaways, Hugo finds the key during an adventure involving the toy-store owner and his goddaughter, Isabelle (Chloë Grace Moretz). A beloved, wanted child, she brings Hugo into her life, which is how he discovers that the cantankerous shopkeeper with the white goatee and sad, watchful eyes is Georges Méliès (a touching Ben Kingsley).The name means nothing to Hugo and may not mean much to most contemporary viewers, but it means a great deal to this lovely movie. A magician turned moving-picture pioneer, Méliès (1861-1938) began his new career after seeing one of the first public film projections in Paris on Dec. 28, 1895. Until then, early moving pictures had been commercially exhibited on Kinetoscopes, peephole machines that enabled viewers to watch brief films, one person at a time. The image was tiny — less than two inches wide — and moving pictures didn’t become cinema as we know it until wizards like the French brothers Auguste and Louis Lumière created machines like the cinématographe, which projected larger-than-life images on screens that people watched as an audience.While the Lumières dazzled with nonfiction films that they called actualités, Méliès enthralled with fantasies and trick films like “A Trip to the Moon” (1902). In this comic 16-minute science-fiction masterwork, a gaggle of scientists in knee breeches fly in a rocket to the Moon, where they encounter acrobatic creatures with lobster claws amid puffs of smoke and clever cinematic sleights of hand. In the film’s most famous image, the rocket lands splat in the eye of the Man in the Moon, causing him to squeeze out a fat tear. It was perhaps a prophetic image for Méliès, who, after falling out of fashion and into obscurity, ran a toy store in the Montparnasse station in Paris, which is where he was later rediscovered.Mr. Selznick opens and closes his book with some soft pencil drawings of Earth’s Moon, that luminous disk on which so many human fantasies (the Man in the Moon included) have been projected. In the book the Moon is something of a screen against which Méliès’s most celebrated cinematic fantasy unfolds. Mr. Scorsese doesn’t exploit this lunar metaphor (perhaps he believes the Moon belongs to Méliès), yet he locates plenty of cinematic poetry here, particularly in the clock imagery, which comes to represent moviemaking itself. The secret is in the clockwork, Hugo’s father says to him in flashback, sounding like an auteurist. Time counts in “Hugo,” yes, but what matters more is that clocks are wound and oiled so that their numerous parts work together as one.The movie itself is a well-lubricated machine, a trick entertainment and a wind-up toy, and it springs to life instantly in a series of sweeping opening aerial shots that plunge you into the choreographed bustle of the train station. The first time you see Hugo he’s peering out from behind a large wall clock at the human comedy in the station. He’s staring through a cutout in the clock face, an aperture through which he watches several characters who play supporting roles in a spectacle that is by turns slapstick, mystery, melodrama and romance, including the menacing station inspector (Sacha Baron Cohen), a friendly flower vendor (Emily Mortimer), a woman with a dachshund (Frances de la Tour) and her suitor (Richard Griffiths). When Hugo gazes at them, he’s viewer and director both.