Twist doesn't appear to be working correctly, do you have any working
example code I could reference to for Twist? Code I attempted below:

// FlashBuilder (flex4) at SDK 3.5
// Away3D 3.6 latest trunk downloaded
// Greensock tweenlite
// Latest versions of flash player debug for chrome/netscape compatible
browsers installed


*// AS3DMod Start*
modStack = new ModifierStack(new LibraryAway3d(), plane);
// Errors with "Incorrect number of arguments. Expected no more than 0"
//var t:Twist=new Twist(Math.PI/2);

// No error with
twist = new Twist();

// Errors with "Implicit coercion of a value Twist to an unrelated type
com.as3mod:IModifier
modStack.addModifier(twist);

this.modStack.apply();





*Bend works fine with the following code:*
bend = new Bend(0.5,0);
bend.offset = 0.5;
modStack.addModifier(bend);
this.modStack.apply();






Full source code:
<?xml version='1.0' encoding='utf-8'?>
<mx:Application xmlns:mx='http://www.adobe.com/2006/mxml' layout='absolute'
frameRate='31' applicationComplete='init()' backgroundColor="0x000000">
<mx:Script>
<![CDATA[
import away3d.cameras.HoverCamera3D;
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.core.render.BasicRenderer;
import away3d.core.utils.Cast;
import away3d.debug.AwayStats;
import away3d.materials.BitmapMaterial;
import away3d.primitives.Plane;
import away3d.primitives.Trident;
 import com.as3dmod.ModifierStack;
import com.as3dmod.modifiers.Bend;
import com.as3dmod.modifiers.Twist;
import com.as3dmod.plugins.away3d.LibraryAway3d;
import com.as3dmod.util.Phase;
  //
------------------------------------------------------------------------------------------------
// Embedded asssets
[Embed(source='assets/front.jpg')]
private var page1aAsset:Class;
 [Embed(source='assets/back.jpg')]
private var page1bAsset:Class;
//
------------------------------------------------------------------------------------------------
// Var ini
private var scene:Scene3D;
private var camera:HoverCamera3D;
private var view:View3D;
private var renderer:BasicRenderer;
 private var bMove:Boolean = false;
private var lastPanAngle:Number;
private var lastTiltAngle:Number;
private var lastMouseX:Number;
private var lastMouseY:Number;
 // Primitives
private var plane:Plane;
private var nSegments:Number = 10;
 // Materials
private var bmat1:BitmapMaterial;
private var bmat2:BitmapMaterial;
 // Vars AS3DMod
private var bend:Bend;
private var twist:Twist;
private var modStack:ModifierStack;
//
------------------------------------------------------------------------------------------------
  //
------------------------------------------------------------------------------------------------
public function init():void
{
// Setup Away3D
camera = new HoverCamera3D();
renderer = new BasicRenderer();
 scene = new Scene3D();
view = new View3D();
view.scene = scene;
view.camera = camera;
view.renderer = renderer;
view.x = stage.stageWidth / 2;
view.y = stage.stageHeight / 2;
 //var clipping:FrustumClipping = new FrustumClipping();
//view.clipping = clipping;
//view.renderer = Renderer.CORRECT_Z_ORDER;
 // Setup away3d stats (appears to slow the cpu)
var awaystats:AwayStats = new AwayStats(view);
away3dstatsContainer.addChild(awaystats);
 var tr:Trident = new Trident(500,true);
scene.addChild(tr);
 // Setup camera
camera.minTiltAngle = -80;
camera.maxTiltAngle = 80;
camera.panAngle = 150;
camera.tiltAngle = 20;
camera.zoom = 5;
 // Add Away3D to its container UIComponent
away3dContainer.addChild(view);
 // Resize handler
this.addEventListener(Event.RESIZE,handleBrowserResize);
handleBrowserResize();
 // Enter frame handler (make things move)
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
stage.addEventListener(MouseEvent.MOUSE_UP,mouseUpHandler);
 // Setup materials
bmat1 = new BitmapMaterial(  Cast.bitmap( new page1aAsset() )  );
bmat2 = new BitmapMaterial(  Cast.bitmap( new page1bAsset() )  );
 // generate
generateScene();
}
//
------------------------------------------------------------------------------------------------
  //
------------------------------------------------------------------------------------------------
private function generateScene():void
{
// Generate our plane
createPlane();
 // Ini slider values (which are also defaults for bend modifier)
hslider1.value = nSegments;
 // Prevent scene drag on slider focus
hslider1.addEventListener(Event.ACTIVATE,stopSceneDrag);
 // Apply values
sliderChange();
}
//
------------------------------------------------------------------------------------------------
 //
------------------------------------------------------------------------------------------------
private function stopSceneDrag(e:Event):void{
bMove = false;
}
//
------------------------------------------------------------------------------------------------
  //
------------------------------------------------------------------------------------------------
private function createPlane():void
{
//plane = new
Plane({segmentsW:10,segmentsH:10,width:800,height:800,material:new
WireframeMaterial()});
plane = new Plane();
plane.segmentsW = plane.segmentsH = nSegments;
plane.width = 800;
plane.height = 800;
plane.bothsides = true;
plane.material = bmat1;
plane.back = bmat2;
scene.addChild(plane);
 // AS3DMod Start
modStack = new ModifierStack(new LibraryAway3d(), plane);
 //var t:Twist=new Twist(Math.PI/2); // Errors with "Incorrect number of
arguments. Expected no more than 0"
twist = new Twist(); // No error
//modStack.addModifier(twist); // Errors with "Implicit coercion of a value
Twist to an unrelated type com.as3mod:IModifier
 // This works fine
bend = new Bend(0.5,0); // No error
bend.offset = 0.5;
modStack.addModifier(bend);
}
//
------------------------------------------------------------------------------------------------
 private var twistPhase:Phase;
  //
------------------------------------------------------------------------------------------------
private function sliderChange():void
{
// Prevent scene rotation while dragging sliders
bMove = false;
 // Plane segments
hslider1Label.text = "Plane segmentsW&H: " + hslider1.value;
if (nSegments != hslider1.value){
scene.removeChild(plane);
nSegments = hslider1.value;
createPlane();
}

 // AS3DMod apply
this.modStack.apply();
}
//
------------------------------------------------------------------------------------------------
    //
------------------------------------------------------------------------------------------------
private function onEnterFrame(event:Event):void
{
// AS3DMod
//twistPhase.value += 0.05;
//twist.angle = Math.PI / 8 * twistPhase.phasedValue;
twist
this.modStack.apply();
 // Camera movement
if (bMove) {
camera.panAngle = 0.3 * (stage.mouseX - lastMouseX) + lastPanAngle;
camera.tiltAngle = 0.3 * (stage.mouseY - lastMouseY) + lastTiltAngle;
}
 // Hover camera
camera.hover();
 // Render
view.render();
}
//
------------------------------------------------------------------------------------------------
   //
------------------------------------------------------------------------------------------------
private function mouseDownHandler(event:MouseEvent):void
{
lastPanAngle = camera.panAngle;
lastTiltAngle = camera.tiltAngle;
lastMouseX = stage.mouseX;
lastMouseY = stage.mouseY;
bMove = true;
 stage.addEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);
}
//
------------------------------------------------------------------------------------------------
//
------------------------------------------------------------------------------------------------
private function mouseUpHandler(event:MouseEvent):void
{
bMove = false;
stage.removeEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);
}
//
------------------------------------------------------------------------------------------------
//
------------------------------------------------------------------------------------------------
private function onStageMouseLeave(event:Event):void
{
bMove = false;
stage.removeEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);
}
//
------------------------------------------------------------------------------------------------
  //
------------------------------------------------------------------------------------------------
// Browser resize handler (simply adjust view3d center x:0 y:0 at browser
1/2 width and height to keep things in the middle
private function handleBrowserResize(e:Event=null):void
{
this.view.x = stage.stageWidth/2;
this.view.y = stage.stageHeight/2;
}
//
------------------------------------------------------------------------------------------------
  ]]>
</mx:Script>
 <mx:UIComponent id='away3dContainer' visible='true'/>
<mx:UIComponent right='130' top='10' id='away3dstatsContainer'
visible='true'/>
 <mx:Panel width="250" height="200" layout="absolute" title="Configurator"
color="#FFFFFF" fontSize="12" left="10" top="10">

<mx:Label x="10" y="60" text="Plane segments" color="#000000"
fontFamily="Arial" fontSize="10" id="hslider1Label"/>
<mx:HSlider x="10" y="70" id="hslider1" liveDragging="true"
change="sliderChange()" minimum="2" maximum="20" snapInterval="1"
width="210"/>
 </mx:Panel>
  <mx:UIComponent id='overlayContainer' visible='true'/>
 </mx:Application>











On 24 November 2010 15:22, Darcey Lloyd <[email protected]> wrote:

> Legend!
>
> Applying it now :)
>
> Thanks
>
> Darcey
>
>
>
>
> On 24 November 2010 15:12, jens lofberg <[email protected]> wrote:
>
>> Hi Darcey
>> Attached you have the whole library as3dmod modified so it works for 3.6
>>
>> =)
>> jens
>>
>> Le 24/11/2010 15:49, Darcey Lloyd a écrit :
>>
>>  Anyone got a twist modifier that works on Away3D 3.6?
>>>
>>> Thanks
>>>
>>> Darcey
>>>
>>
>>
>

Reply via email to