13.33DwithFlash 211
model.addEventListener(FileLoadEvent.LOAD_COMPLETE,
OnModelLoaded);
DAE(model).load("duck_triangulate.dae");
}
/**
* show model once loaded
*/
private function OnModelLoaded(e : FileLoadEvent) : void
{
e.target.removeEventListener(FileLoadEvent.LOAD_COMPLETE,
OnModelLoaded);
scene.addChild(model);
}
/**
* Render!
*/
private function handleRender(event : Event = null) : void
{
// orbit the camera
camera.orbit(_camTarget, _camPitch, _camYaw, _camDist);
// render
renderer.renderScene(scene, camera, viewport);
}
}
}
Listing 13.1. Papervision3D code snippet for loading and displaying a COLLADA model.
Even though the performance is limited to 10,000 to 20,000 triangles at 30
frames per second, this technology provides excellent results for games that do
not need to update the entire 3D display every frame, such as games mixing 2D
and 3D or games where the point of view changes infrequently, as in golf games
(see Figure 13.5). Note that by the time this book is published, Adobe will most
likely have introduced a hardware-accelerated 3D API for the next version of
Flash [22].