package
{
import com.as3dmod.ModifierStack;
import com.as3dmod.modifiers.Cloth;
import com.as3dmod.plugins.pv3d.LibraryPv3d;
import flash.events.Event;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.BitmapMaterial;
import org.papervision3d.materials.shadematerials.GouraudMaterial;
import org.papervision3d.objects.primitives.Cylinder;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.view.BasicView;
public class AS3DmodFlag extends BasicView
{
[Embed(source="Flag.png")]
private var Asset :Class;
private var object :Plane;
private var stack :ModifierStack;
private var modifier :Cloth;
public function AS3DmodFlag()
{
super();
var light :PointLight3D = new PointLight3D();
var material :BitmapMaterial = new BitmapMaterial(new Asset().bitmapData, true);
material.doubleSided = true;
object = new Plane(material, 500, 500, 10, 10);
object.y = 50;
object.useOwnContainer = true;
scene.addChild(object);
var object2 :Cylinder = new Cylinder(new GouraudMaterial(light, 0xffffff, 0x666666, 200), 10, 1400);
object2.x = -250;
object2.y = -370;
scene.addChild(object2);
var object3 :Sphere = new Sphere(new GouraudMaterial(light, 0xffffff, 0x666600, 200), 15);
object3.x = -250;
object3.y = 330;
object3.useOwnContainer = true;
scene.addChild(object3);
stack = new ModifierStack(new LibraryPv3d(), object);
modifier = new Cloth();
stack.addModifier(modifier);
modifier.setForce(0.2, -0.2, -0.2);
modifier.lockXMin();
startRendering();
}
protected override function onRenderTick(e:Event=null):void
{
stack.apply();
super.onRenderTick(e);
}
}
}
Download