Cartoon movie about a boy named Nikko who travels into his dreams on his bed
I'm looking for the name of a cartoon movie that was about a boy named Nikko(?) who travels into his dreams by riding on his bed. He meets a girl in a ballerina dress(?) and she turns out to be the princess of his dream world. They play with a trainset in the king's playroom. The King tells Nikko not to open a certain door in the playroom because something evil will come out, but he opens it out of curiosity and lets an evil guy out. The evil guy traps his bear friends and the princess in glass tubes. And that's all I remember.