Papervision Ribbon3D

There’s been some great experimentation with 3d lines and ribbons in Papervision3D, notably Felix Turner’s Ribbon3D and of course the Audi A5 website.

A project I’m currently working on requires the drawing of ribbons in 3D space, and it’s such a simple yet beautiful effect that I thought it was time to have a quick go at it myself.

Looking at some of the available source code though, I felt that there was a slight lack of simplicity, but more importantly a clear API. This no doubt is due to the fact that the aforementioned experiments were just that, experiments, and therefore not built with usability in mind. None-the-less, I wanted a Ribbon3D class which shared a similar looking constructor to that of the native Papervision classes, and which could easily be used in projects and manipulated in the same intuitive manner as the other 3D objects in the Papervision library.

There are some unused methods which I have kept in the source code, as they can create some great effects with pseudo depth of field and colour, but were somewhat processor intensive for the sake of the demo.

As I mentioned, the API is simple and I hope makes sense. The constructor looks like that of any other DisplayObject3D; you pass in a material of your choice, the width of the ribbon and the length (how many segments can be added before the oldest is removed)

var ribbon:Ribbon3D = new Ribbon3D( material, width, length );
scene.addChild( ribbon );

One point of contention was how to make the ribbon grow. I wanted to be able to draw the ribbons using tweens, and so using a method such as addSegment or growTo seemed unnecessarily cumbersome as it would involve using a callback whenever the tween progresses. So too did using alternative members, such as tx, ty, tz etc, as again this would diverge from the standard DisplayObject3D API.

I eventually decided to override the getters and setters for the x, y and z properties, meaning that you can tween an instance of the Ribbon3D class as you would any other DisplayObject3D (including bezier tweens as in the example above) and it will grow to follow the tween. I was hesitant to implement this, as it means that moving or shifting the ribbon as a whole cannot be done in the normal way, however I concluded that the normal use of such a class would be to create trails or patterns, and so moving the whole ribbon around would rarely be required. That said, I have included a moveTo(x,y,z) method if this needs to be done.

So making an instance of Ribbon3D grow is as simple as:

TweenEngine.tween( ribbon, 2, { x:100, y:100, z:100, bezierThrough:yourBezier } );

Because the x, y and z properties can be set separately, you have to call the draw method manually, from within the Timer or EnterFrame event you are using to render your Papervision viewport, for example:

private function render3D ( e:Event ):void
{

	// Tell the Ribbon3D to update it's mesh
	ribbon.draw();
	// Render the Papervision scene
	renderer.renderScene ( scene, camera, viewport );
}

I have also left the material property open, so instead of passing in a colour and therefore having to use a ColorMaterial, you can use any of the wonderful Papervision materials, such as the FlatShadeMaterial, which I’ve used in the demo to give the ribbons a bit of extra depth.

I’m looking forward to playing with physics and collision detection in Papervision, as a swarm of boids with ribbon trails that don’t intersect (you can see the clipping sometimes in the demo) would be good to see. I’m slowly building a library of 2D steering behaviours so when and if I get round to learning the math required to port them to 3D I’ll have a stab at it and post the results.

Download: Ribbon3D Class Download: Ribbon3D Demo

Note: I have included the build of Papervision3D GreatWhite (rev 682-14.2.08) that I used, as the SVN repository is being updated frequently and may temporarily have adverse effects on the demo. Not included in the zip is the tweening engine I used, TweenMax, which you can read about and download here.

Posted on 12 Aug 2008
43 Comments
14 Trackbacks

Meta

3D Ribbons in Papervision was posted on August 12th 2008 in the category Code / Actionscript 3.0, Flash, Open Source and tagged; , , , , , , .

You can Leave a comment.

Twitter <follow>

February 7th 2012 - 5:37pm

RT @_leonardsouza_: 37signals to stop developing for IE8 » http://t.co/wL6dtZSg

Discussion

57 Responses to 3D Ribbons in Papervision

Leave a Reply

Pingbacks / Trackbacks

  1. 3 years ago Recent URLs tagged Boids - Urlrecorder

    [...] Recent public urls tagged “boids” → 3D Ribbons in Papervision [...]

  2. 3 years ago Pv3d News #1 - Nohama napevno v oblacich | Feet firmly on the cloud

    [...] Zajímavý zdroj informací a novinek blog Exeje z Ruska zveřejnil bezier křivku i s detekcí nárazu. Dokážu si představit využití v jednoduchých 3D hrách prolnuté s třídou 3D Ribbons..  [...]

  3. 2 years ago Top Gossips » Blog Archive » Free Flash Menus & Animations From SoulWire

    [...] 3D Ribbons In Papervision [...]

  4. 2 years ago FLARToolKit demo “Rasengan” from NARUTO « flash.tarotaro.org.blog

    [...] is my new FLARToolKit demo, Rasengan from NARUTO . This demo uses Ribbon3D very exciting [...]

  5. 2 years ago AS3 Dynamic Generative Music Visualisations on Bandcamp

    [...] 3D Ribbons in Papervision 7% similar Ribbon3D class for 3d lines and ribbons in PV3D [...]

  6. 2 years ago onebyoneblog » JG Ballard in Augmented Reality

    [...] rotate the image of Ballard using your arrow keys. The little animated ribbon things are courtesy Soulwire. [...]

  7. 2 years ago 3D Ribbons in Papervision | Papervision Tutorials

    [...] reading this tutorial you will be able to create colorful 3D ribbons. You can download the complete class and source code [...]

  8. 2 years ago 3D, ribbons, vertices, uv coordinates | Rozengain.com - Creative Technology Blog

    [...] was using the Ribbon3D class which is based on Papervision3D. Instead of using a color material he wanted to use a bitmap [...]

  9. 2 years ago 3D Ribbon class for Flash Player 10 « Matt Eley | Labs

    [...] demo was my attempt at creating a version of Soulwire’s Papervision3D Ribbon class using native Flash Player 10 code, and while the demo doesn’t support the more advanced [...]

  10. 2 years ago i-create | therefore-i am » Blog Archive » Kuler-Splash with Flex

    [...] have modified this Ribbon Class form Papervision3d to accept kuler colors. Papervision3d Ribbon Class. Notice how I am using local connection to [...]

  11. 1 year ago Away3D Ribbons | silverbase.net

    [...] Here is my Away3D version of flying ribbons. The code is based on PaperVision3D version of 3D ribbons by Justin Windle [...]

  12. 9 months ago Away3D Ribbons | shiftArray()

    [...] Here is my Away3D version of flying ribbons. The code is based on PaperVision3D version of 3D ribbons by Justin Windle [...]

  1. santhakumar 3 years ago

    One more point, I have removed adding Bitmap taking screenshot of viewport. And added viewport to stage. Still It doesn’t dispatches event.

    Thx

    Reply to this comment

  2. Kevin Burke 3 years ago

    Hi,
    I really like this ribbon…I was wondering if there is any way to have the ribbon bend at a sharp 90 degree angle? Thanks!

    Reply to this comment

  3. Michael 3 years ago

    Awesome work. And easy to use and understand – thanks a LOT…

    Reply to this comment

  4. CIP 2 years ago

    Very cool. I need to play with this. I should hang out here more often.

    Reply to this comment

  5. Almog 2 years ago

    Hi this great, I wanted to know how can I have the ribbons create a word at the end is this possible if so can you point me in the right direction any help would great.

    Reply to this comment

  6. Phil 2 years ago

    Superb class! Thank you so much. The rest of the site is great by the way.

    I do have one question though. I would like to dispatch an event when the ribbon has completed drawing itself. I will explain. I create the ribbon and then animate it to another position. Once the animation is complete the ribbon continues to draw itself until it is no longer visible. This is great and exactly what I’d like but I would love to be able to dispatch an event once it has completed this animation.

    Thanks again for the great work.

    Reply to this comment

  7. peter 2 years ago

    1120: Access of undefined property TweenMax.
    1120: Access of undefined property Linear.
    1120: Access of undefined property TweenMax.
    1172: Definition gs.easing:Linear could not be found.
    1172: Definition gs:TweenMax could not be found.
    Warning: 3590: void used where a Boolean value was expected. The expression will be type coerced to Boolean.

    please help me, im using flash cs4 and i can not compile source of this ribbon stuff. where is the problem pls?

    Reply to this comment

  8. Soulwire 2 years ago

    Make sure you’re importing your classes:

    import gs.TweenMax;
    import gs.Easing.*;
    

    …and of course that you actually have download TweenMax and put it in your source code folder.

    Reply to this comment

  9. seb 2 years ago

    Hello Soulwire, this demo is impressive !
    Have you try to put this Ribbons in Flex.
    I tried but I didn’t manage to see Ribbons…

    Have you tried ?

    Reply to this comment

  10. A M 2 years ago

    I’ve not used this program before, but can the ribbon be pointed at the ends?

    I want to re-create this video, would this be possible?:
    http://www.youtube.com/watch?v=MQKj2WCS4iI

    Reply to this comment

  11. craigk 2 years ago

    Really nice.

    Can you tell me if its possible to add a textfield to the texture, like an old style ticker tape news feed?

    Thanks mate

    Reply to this comment

  12. Josh Noble 2 years ago

    This is super cool, really nice work, thanks for taking the time and sharing this.

    Reply to this comment