Sie sind nicht angemeldet.

1

Donnerstag, 11. März 2010, 00:29

3D objects in krpano

Hi all,

I'm trying to place an swf inside a pano that contains a 3D object (created using the Papervision3D library.)

This simple swf, http://threelamps.com/test.swf , works just fine to add as a plugin or hotspot.
However, this swf, http://threelamps.com/test_3d.swf , whose only difference is that it contains a 3D object will not display inside a krpano.

All assets are compiled into the swf, so I do not believe it is a path issue.

My XML looks like this:

Quellcode

1
2
3
4
5
6
7
8
<hotspot name="test3d"
         	url="/test_3d.swf"
         	distorted="true"
         	ath="-56.020470524020936" atv="1.2863143116010487"
         	scale=".3"
         	rx="0" ry="0" rz="0"
         	zorder="1"
 			 />


Would someone be able to drop the 3d one into one of their panos to see if they experience the same issue?

Or has anyone already run across this before?

Thanks for any help,
fodder

2

Donnerstag, 11. März 2010, 23:20

Sorry, I forgot to add the AS3 code that imports the 3D object (a KMZ model) into test_3d.swf:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package {

	import flash.display.MovieClip;
	import flash.display.Stage;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.utils.ByteArray;
	
	import org.papervision3d.core.proto.CameraObject3D;
	import org.papervision3d.cameras.*;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.view.BasicView;
	import org.papervision3d.view.layer.util.ViewportLayerSortMode;
	import org.papervision3d.render.BasicRenderEngine;
	import org.papervision3d.objects.parsers.Sketchup;
	import org.papervision3d.objects.parsers.KMZ;
	import org.papervision3d.events.FileLoadEvent;
	
	import info1;
	
	public class infoModel extends MovieClip {
	
		[Embed(source="test2.kmz", mimeType="application/octet-stream")]
		private static var myKMZ :Class;

		private var view:BasicView;
		private var model:KMZ;
		
		public function infoModel():void {
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			init3d();
			initKMZ();
		}
		
		private function init3d():void {
			view = new BasicView(550, 400, true, false);
			view.camera.zoom = 12;
			view.camera.focus = 100;
			addChild(view);
			view.viewport.containerSprite.sortMode = ViewportLayerSortMode.INDEX_SORT;
			stage.addEventListener(Event.ENTER_FRAME, renderScene);
		}
		
		private function initKMZ():void {
			var modelByteArray:ByteArray = new myKMZ() as ByteArray;
			model = new KMZ();
			model.load(modelByteArray);
			model.z = 1000;
			model.scale = 0.5;
			view.scene.addChild(model);
		}
		
		private function renderScene(e:Event):void {
			model.rotationY += 2;
			view.singleRender();
		}
	}
}


Could this be a scale or viewpoint problem?

3

Freitag, 12. März 2010, 16:43

Any luck

*confused* I seem to be having the same problem, any luck in figuring it out yet? *confused*

4

Freitag, 19. März 2010, 13:02

Hi,

the main problem is the "stage" access here at the start of the swf:

public function infoModel():void {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;

init3d();
initKMZ();
}


install/use the debug flashplayer and it will shown error because of
an access to a 'null' object,

the 'stage' member will be set from Flash after the ADDED_TO_STAGE event,
but the code itself already starts executing direct after loading,

as solution use a startup code like this:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public function infoModel():void 
{
  if(stage == null)
    this.addEventListener(Event.ADDED_TO_STAGE, infoModel_realstart);
  else
  {
    stage.align = StageAlign.TOP_LEFT;
    stage.scaleMode = StageScaleMode.NO_SCALE;

    infoModel_realstart(null);  
  }
}

public function infoModel_realstart(event:Event):void 
{
  if (event != null)
    this.removeEventListener(Event.ADDED_TO_STAGE, infoModel_realstart);

  init3d();
  initKMZ();
}
..


best regards,
Klaus

5

Freitag, 19. März 2010, 22:43

Thank You, Klaus!

It worked like a charm.

For anyone else also looking that this, I also had to use distorted="false" (in the XML) or the 3D object wouldn't show up and using zoom="true" allowed the object to hover over a single location in the pano.

Fodder

6

Mittwoch, 24. März 2010, 15:20

synchronize rotation of a 3D object with krpano

This seems to be an interesting topic, what about adding a 3D house into a panorama? Let's take the barn for example from http://sketchup.google.com/3dwarehouse/d…2e1b4a55475605f.

Following your instructions, the barn model has been loaded into the panorama. Can we somehow synchronize it with the pano so that it follows panning and tilting? We should somehow align either the camera view or the rotationX and rotationY of the model in papervision3d with hlookat of krpano's view. I was playing a bit with these properties but didn't find a working solution.