Class ViewRenderable
- java.lang.Object
-
- com.google.ar.sceneform.rendering.Renderable
-
- com.google.ar.sceneform.rendering.ViewRenderable
-
@RequiresApi(api=24) public class ViewRenderable extends Renderable
Renders a 2D Android view in 3D space by attaching it to aNode
withNode.setRenderable(Renderable)
. By default, the size of the view is 1 meter in theScene
per 250dp in the layout. Use aViewSizer
to control how the size of the view in theScene
is calculated.future = ViewRenderable.builder().setView(context, R.layout.view).build(); viewRenderable = future.thenAccept(...);
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ViewRenderable.Builder
Factory class forViewRenderable
static class
ViewRenderable.HorizontalAlignment
Controls the horizontal alignment of theViewRenderable
relative to theNode
it is attached to.static class
ViewRenderable.VerticalAlignment
Controls the vertical alignment of theViewRenderable
relative to theNode
it is attached to.
-
Field Summary
-
Fields inherited from class com.google.ar.sceneform.rendering.Renderable
DEFAULT_ANIMATION_FRAME_RATE, RENDER_PRIORITY_DEFAULT, RENDER_PRIORITY_FIRST, RENDER_PRIORITY_LAST
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ViewRenderable.Builder
builder()
Constructs aViewRenderable
Matrix
getFinalModelMatrix(Matrix originalMatrix)
Takes the model matrix from theTransformProvider
for rendering thisNode
and scales it to size it appropriately based on the meters to pixel ratio for the view.ViewRenderable.HorizontalAlignment
getHorizontalAlignment()
Gets theViewRenderable.HorizontalAlignment
that controls where theViewRenderable
is positioned relative to theNode
it is attached to along the x-axis.ViewSizer
getSizer()
ViewRenderable.VerticalAlignment
getVerticalAlignment()
Gets theViewRenderable.VerticalAlignment
that controls where theViewRenderable
is positioned relative to theNode
it is attached to along the y-axis.android.view.View
getView()
The 2D AndroidView
that is rendered by thisViewRenderable
.ViewRenderable
makeCopy()
Creates a new instance of this ViewRenderable.void
setHorizontalAlignment(ViewRenderable.HorizontalAlignment horizontalAlignment)
Sets theViewRenderable.HorizontalAlignment
that controls where theViewRenderable
is positioned relative to theNode
it is attached to along the x-axis.void
setSizer(ViewSizer viewSizer)
void
setVerticalAlignment(ViewRenderable.VerticalAlignment verticalAlignment)
Sets theViewRenderable.VerticalAlignment
that controls where theViewRenderable
is positioned relative to theNode
it is attached to along the y-axis.-
Methods inherited from class com.google.ar.sceneform.rendering.Renderable
createInstance, getAnimationFrameRate, getCollisionShape, getId, getMaterial, getMaterial, getRenderPriority, getSubmeshCount, getSubmeshName, isShadowCaster, isShadowReceiver, setCollisionShape, setMaterial, setMaterial, setRenderPriority, setShadowCaster, setShadowReceiver, updateFromDefinition
-
-
-
-
Method Detail
-
getView
public android.view.View getView()
The 2D AndroidView
that is rendered by thisViewRenderable
.
-
makeCopy
public ViewRenderable makeCopy()
Creates a new instance of this ViewRenderable.The new renderable will have unique copy of all mutable state. All materials referenced by the ViewRenderable will also be instanced. Immutable data will be shared between the instances. The new ViewRenderable will reference the same getFilamentEngine View as the original ViewRenderable.
- Specified by:
makeCopy
in classRenderable
-
getSizer
public ViewSizer getSizer()
-
setSizer
public void setSizer(ViewSizer viewSizer)
-
getHorizontalAlignment
public ViewRenderable.HorizontalAlignment getHorizontalAlignment()
Gets theViewRenderable.HorizontalAlignment
that controls where theViewRenderable
is positioned relative to theNode
it is attached to along the x-axis. The default isViewRenderable.HorizontalAlignment.CENTER
.
-
setHorizontalAlignment
public void setHorizontalAlignment(ViewRenderable.HorizontalAlignment horizontalAlignment)
Sets theViewRenderable.HorizontalAlignment
that controls where theViewRenderable
is positioned relative to theNode
it is attached to along the x-axis. The default isViewRenderable.HorizontalAlignment.CENTER
.
-
getVerticalAlignment
public ViewRenderable.VerticalAlignment getVerticalAlignment()
Gets theViewRenderable.VerticalAlignment
that controls where theViewRenderable
is positioned relative to theNode
it is attached to along the y-axis. The default isViewRenderable.VerticalAlignment.BOTTOM
.
-
setVerticalAlignment
public void setVerticalAlignment(ViewRenderable.VerticalAlignment verticalAlignment)
Sets theViewRenderable.VerticalAlignment
that controls where theViewRenderable
is positioned relative to theNode
it is attached to along the y-axis. The default isViewRenderable.VerticalAlignment.BOTTOM
.
-
getFinalModelMatrix
public Matrix getFinalModelMatrix(Matrix originalMatrix)
Takes the model matrix from theTransformProvider
for rendering thisNode
and scales it to size it appropriately based on the meters to pixel ratio for the view.- Overrides:
getFinalModelMatrix
in classRenderable
- Parameters:
originalMatrix
-
-
builder
public static ViewRenderable.Builder builder()
Constructs aViewRenderable
-
-