Papervision 3D Examples Added With Source Code
Wednesday, August 06th, 2008 | Author: dehash
Added some more Papervision 3D examples with source code.
All examples use current Papervision3D GreatWhite from SVN and so far all use BasicView also. **Update:** added four more examples to the top of the list to make 18 in total:
![]()
- InteractiveScene3DEvent example
- Layers Demo
- Simple Wow Engine Demo
- Rotation Demo
- BitmapFileMaterial example
- Two Sided Plane
- Video Cube Demo
- VideoStreamMaterial demo
- Sphere BitmapMaterial
- Blender Collada DAE
- Blur effect
- Curved lines
- Lines3D
- Particle field demo
- Bitmap material demo
- Rotating cylinder
- Shaded cube
- Plane wireframe
A clickable Plane with a swapped material that rotates using Tweener
Setting the layer order of objects to try to control which is on top
Spheres contained in a Cube
Shows three rotation axes
Using BitmapFileMaterial to load a jpg and provide texture for a Plane
Extended DisplayObject3D to create a Plane with Wireframe one side and MovieMaterial on the other
Displaying a flv on the inside walls of a Cube
Using VideoStreamMaterial to provide a texture for a Plane
Using BitmapMaterial to display a jpg on a Sphere
Loading a Collada DAE file exported from Blender
Simple example using the newly integrated Effects branch
Using an external class to create curved lines
Using the built in Line3D class to create straight lines
Simple ParticleField example
Basic BitmapMaterial example using an embedded jpg
Cylinder with FlatShadeMaterial
Cube with FlatShadeMaterial
Simplest Wireframe Plane



Hi, I’m impressed about your examples
but I’ve got problem with first one
InteractiveScene3DEvent.
I’ve to change
plane.material = e.target; (line 46?)
to
plane.material = BitmapFileMaterial(e.target)
and
onComplete:function() { tweening = false;}
to
onComplete:function():Boolean { tweening = false; return true; }
to compile this.
Thanks for the feedback kml.
Have updated the code and decided to remove the tweening variable and the onComplete entirely using Tweener.isComplete instead which is a better approach than what was there.
Also changed plane.material = e.target to plane.material = bitmapFileMaterial and added some tweaks to make it more transparent what is happening in this short example.
Should now compile fine.
Thanks for your examples and the code.
I am very enthusiastic about papervision and I have a question – is possible to map video to a collada file ?
Yes I did it …
thanks again for your sharing.
Here is the code the one I used for mapping video on a collada file.
import org.papervision3d.view.Viewport3D;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.materials.VideoStreamMaterial;
import flash.events.Event;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
var videoStreamMaterial:VideoStreamMaterial;
var quality:uint = 16;
var netConnection:NetConnection;
var video:Video;
var netStream:NetStream;
var viewport:Viewport3D;
var scene:Scene3D;
var camera:Camera3D;
var dae:DAE;
var renderer:BasicRenderEngine;
viewport = new Viewport3D(800, 600, true, true);
addChild(viewport);
scene = new Scene3D();
camera = new Camera3D();
camera.z = -2000;
renderer = new BasicRenderEngine();
var customClient:Object = new Object();
customClient.onMetaData = metaDataHandler;
netConnection = new NetConnection();
netConnection.connect(null);
netStream = new NetStream(netConnection);
netStream.client = customClient;
netStream.play(“video.flv”);
video = new Video();
video.width = 320;
video.height = 240;
video.smoothing = true;
video.attachNetStream(netStream);
videoStreamMaterial = new VideoStreamMaterial(video, netStream);
videoStreamMaterial.doubleSided=true;
var materialsList:MaterialsList = new MaterialsList();
materialsList.addMaterial(videoStreamMaterial, “all”);
dae = new DAE();
dae.load(“screen.dae”, materialsList);
dae.scale = 200;
scene.addChild(dae);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(e:Event):void {
var rotY: Number = (mouseY-(stage.stageHeight/2))/(stage.height/2)*(600);
var rotX: Number = (mouseX-(stage.stageWidth/2))/(stage.width/2)*(-600);
camera.x= camera.x+(rotX-camera.x)/5;
camera.y= camera.y+(rotY-camera.y)/5;
renderer.renderScene(scene, camera, viewport);
dae.roll(0.01);
}
function metaDataHandler(infoObject:Object):void {
trace(‘metaDataHandler’,infoObject);
}
Glad you got it working Bram and likely to add more examples soon including collada materials.
Thank You! These are AWESOME!
great work, thanks!
Thanks for all these examples, they are of great help to me (noob with papervision). I’m busy with the layering example but I get this error and I don’t really know exactly why.
Error:1120: Access of undefined property topDepth.
viewport.getChildLayer(b1, true).layerIndex = ++topDepth;
I downloaded great white two days ago so I don’t know if this new revision is the problem.
Do you have any suggestions on how to fix this?
Thanx for the help and keep up the good work
Hi sorry.
Never mind the previous post, after going over the code for the hundredth time I found that I forgot to declare the var. o_0 but for some reason my png file refuses to load on the one plane, it just shows a black background with the pink frame…?
I’ll try and figure that out too.
Thanks anyway
thanks for the effort, these are really helpful
wow..these are just amazing examples. thank you for your time and effort
Also is there anyway you can upload the Papervision classes folder you are using. There are so many versions on google code I am not even sure which one to download. Every version I download has a problem and I cant run your examples because some class is missing. Thanks
Each example is made with current (at the time) svn version of Papervision but things can change fast in svn so I have included the revision number in the title for each example. For the PV3D classes I just use Tortoise SVN to grab the latest version and update it regularly. As a rule developers try to maintain backward compatibility so hopefully if you do that it would solve any issues you are facing.
Hi,
Your examples are amazing and I have to do application about render the same object with difference view. (In front view and back view).
Each view render in the panel component. Right panel show front view and Left panel show back view. I want to move object in front view and then Back view also render that object was moved too. I have no idea to do this. Do you have any suggestion?
Thanks :)
Question…. I’m a newbie to Papervision and an not a pro at actionscript. Why all of your samples start with “com.dehash.pv3d.examples.noise”, and so-forth after the package?
Are these samples pulling in more code from the dehash local directory?
I copy and paste the code from various samples, but inevitably I get an error every time. Can you point me to something that would educate me of how to use your code samples?
@Marty –
It is just the directory structure/path. So where you see this:
package com.dehash.pv3d.examples.basic
it means the class here is in a folder like this:
com\dehash\pv3d\examples\basic
so you can copy that folder structure or delete what is after the word package…
@Jane – not sure of what you are asking there but if it is multiple scenes I will make some example of this at some point I expect
Hi, thanks for your cool examples to share. I got problem as what Marty mentioned and now solved, but another problem is below:
5008: The name of definition ‘InteractiveScene3DEventExample’ does not reflect the location of this file. Please change the definition’s name inside this file, or rename the file. C:\Documents and Settings\Jeff Lung\desktop\415\main.as
Hi, many thanks for your help with all these examples. Can you please do one with reflection. I’ve been trying for ages but can’t seem to figure it out. Your help would be much appreciated.
Wonderful coding, great site for starters and developers, I would like to get some help here, I want to run InteractivePlanesBoard, I need to know how to make it run in flash cs4, so far I have the class for it, I have the SVN tortoise handling great white on my system, I have the icons, what about the FLA project, can you point me how to build that from the scratch to get a identical swf project as you have on you demo? (Title: InteractivePlanesBoard).
The docs on Packages should answer most of the questions here:
http://livedocs.adobe.com/flash/9.0/main/00000041.html
There is a Flash CS3 example with source code of the InteractivePlanesBoard example here:
http://www.dehash.com/?p=231
I have a question about http://www.dehash.com/?page_id=192
How do i make the same but with a movieclip in flash CS4? Thanks for your attention.
I have downloaded your .dae file and png file and using the above class with flash CS4. Im getting an error of WARNING: Collada material daecube_cube_png not found. What will be the reason?
One more doubt I have downloaded few more .dae files and tested for eg http://papervision2.com/loading-complex-models/ this one I’m not able to see the objects but i get a wire frame alone even though the png and the dae files are int the same folder this is not working what will be the problem?
Thanks
Hari.
@Harish – Looks like your problem is with paths so first thing I would try is to move everything (html/swf/png/dae) into the same folder and make sure the files are not edited and have their original names.
Hi All,
Hope someone can help me, I am trying to wrap an flv around a cube (Excluding the top and bottom) but I am unsuccessful so far. I have searched everywhere on the net and all I can manage is to display the entire video on each side of the cube.
Code:
video = new VideoStreamMaterial(videoFile, ncStream, true);
var materialsList:MaterialsList = new MaterialsList(); materialsList.addMaterial(video, “all”);
//Apply the VideoStreamMaterial to object
cube = new Cube(materialsList,1024, 1024,1024,30,30,30, 0, Cube.TOP + Cube.BOTTOM);
Is there a way I can tell it to wrap the videoStreamMaterial around all 4 faces or if there isn’t can I map the videoStreamMaterial onto a plane and then warp this plane to form a cube?
I hope someone can help as I’m stuck on this find no information how to do this. Every example I’ve seen so far lets you map the material to every individual face.
Thanks in advance,
Gunning
hi, is the collada file (.dae) that is exported from blender, an animation? and when it’s imported by papervision3d, can it move on (animated) automatically while executed by papervision3d?
@galih
No it is a regular collada dae file that is being rotated using PV3D.
@Gunning
Sounds possible some way but I have not done that myself.