Created
November 22, 2008 20:29
-
-
Save sanity/27933 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mx:Script> | |
<![CDATA[ | |
import org.papervision3d.core.geom.renderables.Triangle3D; | |
import org.papervision3d.core.geom.renderables.Vertex3D; | |
import org.papervision3d.core.geom.TriangleMesh3D; | |
import org.papervision3d.materials.utils.MaterialsList; | |
import org.papervision3d.objects.primitives.Cube; | |
import org.papervision3d.cameras.Camera3D; | |
import org.papervision3d.objects.primitives.Sphere; | |
import org.papervision3d.materials.ColorMaterial; | |
import org.papervision3d.view.BasicView; | |
var bview : BasicView; | |
var mesh : TriangleMesh3D; | |
var sphere : Sphere; | |
private function init() : void { | |
trace("starting"); | |
stage.scaleMode = StageScaleMode.NO_SCALE; | |
stage.align = StageAlign.TOP_LEFT; | |
bview = new BasicView( this.stage.width, this.stage.height, true, false, 'CAMERA3D' ); | |
bview.camera.zoom = 12; | |
bview.camera.focus = 100; | |
mesh = new TriangleMesh3D(new ColorMaterial(0xFFFFFF), [], []); | |
var v1 = new Vertex3D(100, 100, 0); | |
var v2 = new Vertex3D(0,100,0); | |
var v3 = new Vertex3D(0, 100, 0); | |
var v4 = new Vertex3D(0, 000, 0); | |
mesh.geometry.vertices.push(v1, v2, v3, v4); | |
var t3d = new Triangle3D(mesh, [v1, v2, v3], new ColorMaterial(0x00FFFF)); | |
sphere = new Sphere(new ColorMaterial(0xFFFF00)); | |
mesh.geometry.faces.push(t3d); | |
mesh.geometry.ready = true; | |
bview.scene.addChild(mesh); | |
// bview.scene.addChild(sphere); | |
this.rawChildren.addChild(bview); | |
addEventListener( Event.ENTER_FRAME, enterFrameHandler ); | |
} | |
private function enterFrameHandler( event : Event ):void { | |
//You need to cast the camera as your type if you want to use type specific functions | |
Camera3D(bview.camera).orbit(bview.viewport.containerSprite.mouseX/10, bview.viewport.containerSprite.mouseY/10, true, mesh); | |
bview.singleRender(); | |
} | |
]]> | |
</mx:Script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment