One of the more recent updates to Papervision3D 2 was the introduction of Google SketchUp support. So, I decided to prod this new functionality with a stick. Turns out it still has some growing to do. Never the less the basic functionality is there and waiting for a sprinkling of Miracle Grow.
Modeling School
First we need a SketchUp model. Just so happens that KMZ files are just ZIP files. Also, MKZ version 4 files already contain a DAE file. Perfect. So all you have to do is:
- Export your SketchUp file as a Google Earth 4 (*.kmz)
- Rename the .kmz file to .zip
- Open the ZIP
- Extract the DAE file from the models folder
If you don’t wanna make your own I’ve included one that I made for testing at the end of this post.
Coding Time
I like to embed my DAE files (you don’t have to, it’s just XML), so that’s what we’re gonna do first:
[Embed(source="../../../../../embedded/skull.dae", mimeType="application/octet-stream")] private static const daeSkull:Class;
Not a big deal, just like embedding any other file. Now all we have to do is instantiate it and add it to a scene:
var collada:SketchupCollada = new SketchupCollada(XML(new SketchUpView.daeSkull()), null, 0.01); this.scene.addChild(collada);
Bringin’ It Home
That’s pretty much all there is to it. You’ll probably notice a few things right off the bat like: “Where the f are all my materials?” Well, they’re not there, and you can’t apply new ones at runtime. At least, that’s how it stands as of the 709 build.
Here’s the example (click and drag to orbit the camera around the model):
3 Comments
Hi Jason,
Great bog. Nice and simple. I’ve been trying to use your sample code above but I cannot find “SketchUpView”.
Thanks, Dean
wonderful post))
what a nice story..