[Papervision3D] interactivescreen and interactive materials howto
ilteris kaplan
ilteriskaplan at gmail.com
Thu Nov 8 14:04:00 PST 2007
Hey Guys,
I am trying to follow Devon Wolfang's tutorial(http://
www.onebyonedesign.com/tutorials/papervision_gallery/) to create a
composition with planes after each other. I think there is some
changes to p3d after the tutorial has been written because it's not
working like the way it's. So that I just went ahead and tried
mashing up different tutorials to recreate the tutorial with no luck.
Actually everything is working fine but I am getting an error in the
below part of source code:
private function onImageClick(is3d:InteractiveScene3DEvent):void {
var clickedPlane:Plane = is3d.target as Plane;
var targetZ:Number = clickedPlane.extra.zPos * -1;
Tweener.addTween(_imageHolder, {z:targetZ, time:TWEEN_TIME,
transition:"easeOutSine"});
}
The error that I am getting in flex builder is this:
1046: Type was not found or was not a compile-time constant:
InteractiveScene3DEvent. PVGallery0
I do remember one post about there is no InteractiveScene's anymore.
Should I be going with a different direction here? What I am trying
to do is relatively simple. In the first part of my code I am
creating the material out of the bitmap to use with each plane that I
am creating in addImage function. I am also curious to know if I am
on the right track with the material since I want this planes to be
clickable but using bitmapMaterial.
Sorry for the massive questions. I am really looking for advices here.
best,
ilteris
// whole code.
package {
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.Event;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.*;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.objects.Plane;
import org.papervision3d.events.*;
import caurina.transitions.Tweener;
public class PVGallery0 extends Sprite {
[Embed(source="/assets/borobudur-java-indonesia.png")] private var
Image:Class;
private var _container:Sprite;
private var _scene:InteractiveScene3D;
private var _camera:Camera3D;
private var _imageHolder:DisplayObject3D;
private var myMaterials:Object;
private const ZSTEP:Number = 1000;
private const NUM_IMAGES:int = 15;
private const TWEEN_TIME:Number = .5;
public function PVGallery0() {
addEventListener(Event.ADDED, init, false, 0, true); //see my
comment below
}
private function init():void {
var bmd:Bitmap = new Image(0,0) as Bitmap;
myMaterials = {
// the property name needs to correspond with the name you gave it
// in 3ds Max. you can also look it up in the collada (*.dae) file:
// <material id="myPhotoMaterial" name="myPhotoMaterial">
bmd: new BitmapMaterial( bmd.bitmapData )
};
init3D();
addEventListener(Event.ENTER_FRAME, render, false, 0, true);
addImages();
}
private function init3D():void {
_container = new Sprite();
_container.x = 400;
addChild(_container);
_scene = new InteractiveScene3D(_container);
_imageHolder = _scene.addChild(new DisplayObject3D("_imageHolder"));
_imageHolder.y = -300;
_camera = new Camera3D();
_camera.focus = 350;
_camera.zoom = 4;
}
private function addImages():void {
for(var i:int = 0; i < NUM_IMAGES; i++) {
var targetHeight:Number = 400;
var ratio:Number = targetHeight / myMaterials.height;
var targetWidth:Number = myMaterials.width * ratio;
var p:Plane = new Plane(myMaterials, targetWidth, targetHeight, 1);
p.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK,
onImageClick);
p.z = i * ZSTEP;
p.extra = {zPos:p.z};
_imageHolder.addChild(p);
}
//
}
private function onImageClick(is3d:InteractiveScene3DEvent):void {
var clickedPlane:Plane = is3d.target as Plane;
var targetZ:Number = clickedPlane.extra.zPos * -1;
Tweener.addTween(_imageHolder, {z:targetZ, time:TWEEN_TIME,
transition:"easeOutSine"});
}
private function render():void {
_scene.renderCamera(_camera);
}
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20071108/227bfb0f/attachment-0001.html
More information about the Papervision3D
mailing list