|
drbii, Member
Posted: 06 December 2014 06:02 AM Total Posts: 72
What I am trying to do is determine when a mesh is visible to the camera and have a flash.text label locate itself on the visible portion of the mesh. Not sure if this possible.
The label needs to be able to adjust with the view. The user can move around the objects as well as zoom in and out. So I need something that will evaluate the mesh, find a point on the mesh that is visible to the camera and place the label. I’d like the label to be located on and move in sync with the mesh. If possible it would be nice if the labels also avoided overlapping each other. Any ideas, tips, warnings or thoughts? Looking for some wisdom from the masters!
Thanks!
Dan
|
rdoi, Member
Posted: 10 December 2014 01:23 PM Total Posts: 86
[ # 1 ]
You can check if the mesh is in view frustum:
mesh.worldBounds.isInFrustum(camera.frustumPlanes, camera.frustumPlanes.length);
But specifically about labels, maybe you could project the label point of the mesh to the View, so you can catch it in a 2D layer and then test it by its width and height.
|
drbii, Member
Posted: 22 December 2014 10:40 PM Total Posts: 72
[ # 2 ]
rdoi - 10 December 2014 01:23 PM You can check if the mesh is in view frustum:
mesh.worldBounds.isInFrustum(camera.frustumPlanes, camera.frustumPlanes.length);
But specifically about labels, maybe you could project the label point of the mesh to the View, so you can catch it in a 2D layer and then test it by its width and height.
Not getting this to work. My cameras use hover controller does this matter?
|
rdoi, Member
Posted: 23 December 2014 12:28 PM Total Posts: 86
[ # 3 ]
drbii - 22 December 2014 10:40 PM
Not getting this to work. My cameras use hover controller does this matter?
How its failing? Show some code.
Btw, the controller doesn’t matter at all.
|
drbii, Member
Posted: 22 January 2015 07:29 PM Total Posts: 72
[ # 4 ]
Ok, getting back into this.
public static function check_inView():void { var stage2dPos:Vector3D = away3dView_pre.project(_Facet_pre_hotspots.meshes[0].scenePosition); facet1lText.x = stage2dPos.x; facet1lText.y = stage2dPos.y; //facet1lText.z = stage2dPos.z; if (_Facet_pre_hotspots.meshes[0].worldBounds.isInFrustum(away3dView_pre.camera.frustumPlanes, away3dView_pre.camera.frustumPlanes.length) == true ){ trace ("Yes, it is in view"); facet1lText.alpha = 1; } if (_Facet_pre_hotspots.meshes[0].worldBounds.isInFrustum(away3dView_pre.camera.frustumPlanes, away3dView_pre.camera.frustumPlanes.length) == false ){ trace ("No, it is not in view");
facet1lText.alpha = 0; }
This is working but always true if within the frustum. I need something that determines if it is visible or occluded by some other mesh. I’m trying to turn off 2D labels if the object is not seen and turn them on if it is.
Thanks for your help!
|