Hi there,
somehow i am a bit confused my code looks like it changed x en z axis and up/down?
With matList, I expected the green side of the cube to be not displayed but i would see the grey??
import adobe.utils.CustomActions;
import com.greensock.*;
import com.greensock.easing.*;
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.events.Event;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.view.BasicView;
[SWF(width="400", height="300", frameRate="30")]
public class Papervision03 extends BasicView{
private var cube:Cube;
private var cube2:Cube;
private var matList:MaterialsList;
private var matRed:MaterialsList;
private var startStopBtn:MovieClip;
public function Papervision03(){
//initialise Papervision3D
init3D();
//create the 3D objects
createScene();
//create interactive
createButtons();
//start rendering the scene
startRendering();
}
private function init3D():void {
camera.x = 250;
camera.y = 150;
camera.z = 250;
}
private function createScene():void {
matList = new MaterialsList({
front:new ColorMaterial(0xff0000),//red
back:new ColorMaterial(0xffffff),//white
left:new ColorMaterial(0x999999),//grey
right:new ColorMaterial(0x00ff00),//green
top:new ColorMaterial(0xffff00),//yellow
bottom:new ColorMaterial(0x0000FF)});//blue
matRed = new MaterialsList({
front:new ColorMaterial(0x7C191E),
back:new ColorMaterial(0x601418),
left:new ColorMaterial(0x601418),
right:new ColorMaterial(0xB8252D),
top:new ColorMaterial(0x7C191E),
bottom:new ColorMaterial(0x7C191E)});
cube = new Cube(matList, 60, 60, 60);
cube2 = new Cube(matRed, 60, 60, 60);
cube2.z = -60;
cube2.x = 60;
//cube.yaw(45);
//cube.pitch(45);
scene.addChild(cube);
scene.addChild(cube2);
}
private function createButtons():void {
startStopBtn = new MovieClip();
startStopBtn.graphics.beginFill(0xFF0000);
startStopBtn.graphics.drawRect(0, 0, 100, 80);
startStopBtn.graphics.endFill();
startStopBtn.x = 80;
startStopBtn.y = 60;
addChild(startStopBtn);
// if you want a hand cursor
startStopBtn.buttonMode = true;
startStopBtn.useHandCursor = true;
//toggle start/stop
startStopBtn.addEventListener(MouseEvent.CLICK, togglePlay);
}
private function animateCube():void {
TweenLite.to(cube, 1, {x:300, onComplete:function():void{
TweenLite.to(cube, 1, {scaleX:1, onComplete:function():void{
TweenLite.to(cube, 1, {scaleY:3, onComplete:function():void{
TweenLite.to(cube, 1, {scaleY:1, onComplete:animateCube});
}})
}});
}});
}
private function togglePlay(event:MouseEvent):void {
trace('heli');
animateCube();
}
}