Sketchup Parser

What is a Sketchup file?

While I was unable to get this parser to properly read the kmz file, I was able to extract the content of the kmz and load the Sketchup DAE file without a probem. To do this, just follow the instructions from the DAE parser above.

Sketchup Parsing Example

  1. package {
  2.  import flash.events.Event;
  3.  import org.papervision3d.lights.PointLight3D;
  4.  import org.papervision3d.materials.shadematerials.GouraudMaterial;
  5.  import org.papervision3d.materials.utils.MaterialsList;
  6.  import org.papervision3d.objects.parsers.DAE;
  7.  import org.papervision3d.view.BasicView;
  8.  
  9.  public class SketchupParser_v1 extends BasicView {
  10.   // create a class-level var for the collada scene
  11.   private var _dae:DAE;
  12.   // create the light
  13.   private var _light:PointLight3D;
  14.  
  15.   public function SketchupParser_v1() {
  16.    lights();
  17.    init3d();
  18.   }
  19.  
  20.   private function lights():void {
  21.    // create the light to the scene
  22.    _light = new PointLight3D(true, true);
  23.    // place it in the same position as the camera (0, 0, -1000);
  24.    _light.copyPosition(camera);
  25.   }
  26.  
  27.   private function init3d():void {
  28.    // create a materials list and add the wireframe material
  29.    var knotMaterialsList:MaterialsList = new MaterialsList();
  30.    // we are now going to use a gouraud material for shading
  31.    var knotMaterial:GouraudMaterial = new GouraudMaterial(_light);
  32.    knotMaterialsList.addMaterial(knotMaterial, "all");
  33.    // instantiate the DAE obj and load the knot object
  34.    // apply the material and scale to 0.05
  35.    _dae = new DAE();
  36.    _dae.load("assets/sketchup/knot.dae", knotMaterialsList);
  37.    _dae.scale = 1;
  38.    camera.z = -5;
  39.    // add the DAE file to the scene
  40.    scene.addChild(_dae);
  41.    // start rendering (activated onRenderTick)
  42.    startRendering();
  43.   }
  44.  
  45.   override protected function onRenderTick(event:Event = null):void {
  46.    // rotate the object
  47.    _dae.yaw(1);
  48.    super.onRenderTick();
  49.   }
  50.  }
  51. }

This, you may notice, is identical to the DAE loader. That is because it is just loading the DAE extracted from the Sketchup kmz file.

Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 Page 9