Package pro.streem.ar.sceneform
Class Scene
- java.lang.Object
-
- pro.streem.ar.sceneform.NodeParent
-
- pro.streem.ar.sceneform.Scene
-
public class Scene extends NodeParent
The Sceneform Scene maintains the scene graph, a hierarchical organization of a scene's content. A scene can have zero or more child nodes and each node can have zero or more child nodes.The Scene also provides hit testing, a way to detect which node is touched by a MotionEvent or Ray.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceScene.OnPeekTouchListenerInterface definition for a callback to be invoked when a touch event is dispatched to a scene.static interfaceScene.OnTouchListenerInterface definition for a callback to be invoked when a touch event is dispatched to a scene.static interfaceScene.OnUpdateListenerInterface definition for a callback to be invoked once per frame immediately before the scene is updated.
-
Field Summary
Fields Modifier and Type Field Description static EnvironmentalHdrParametersDEFAULT_HDR_PARAMETERS
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOnPeekTouchListener(Scene.OnPeekTouchListener onPeekTouchListener)Adds a listener that will be called before theScene.OnTouchListeneris invoked.voidaddOnUpdateListener(Scene.OnUpdateListener onUpdateListener)Adds a listener that will be called once per frame immediately before the Scene is updated.CameragetCamera()Get the camera that is used to render the scene.LightProbegetLightProbe()Get the Light Probe that defines the lighting environment for the scene.NodegetSunlight()Get the default sunlight node.SceneViewgetView()Returns the SceneView used to create the scene.HitTestResulthitTest(android.view.MotionEvent motionEvent)Tests to see if a motion event is touching any nodes within the scene, based on a ray hit test whose origin is the screen position of the motion event, and outputs a HitTestResult containing the node closest to the screen.HitTestResulthitTest(Ray ray)Tests to see if a ray is hitting any nodes within the scene and outputs a HitTestResult containing the node closest to the ray origin that intersects with the ray.java.util.ArrayList<HitTestResult>hitTestAll(android.view.MotionEvent motionEvent)Tests to see if a motion event is touching any nodes within the scene and returns a list of HitTestResults containing all of the nodes that were hit, sorted by distance.java.util.ArrayList<HitTestResult>hitTestAll(Ray ray)Tests to see if a ray is hitting any nodes within the scene and returns a list of HitTestResults containing all of the nodes that were hit, sorted by distance.voidonAddChild(Node child)voidonRemoveChild(Node child)NodeoverlapTest(Node node)Tests to see if the given node's collision shape overlaps the collision shape of any other nodes in the scene usingNode.getCollisionShape().java.util.ArrayList<Node>overlapTestAll(Node node)Tests to see if a node is overlapping any other nodes within the scene usingNode.getCollisionShape().voidremoveOnPeekTouchListener(Scene.OnPeekTouchListener onPeekTouchListener)Removes a listener that will be called before theScene.OnTouchListeneris invoked.voidremoveOnUpdateListener(Scene.OnUpdateListener onUpdateListener)Removes a listener that will be called once per frame immediately before the Scene is updated.voidsetEnvironmentalHdrLightEstimate(float[] sphericalHarmonics, float[] direction, Color colorCorrection, float relativeIntensity, android.media.Image[] cubeMap)Sets the current Hdr Light Estimate state to apply to the Filament scene.voidsetLightEstimate(Color colorCorrection, float pixelIntensity)Sets light estimate to modulate the scene lighting and intensity.voidsetLightProbe(LightProbe lightProbe)Set a new Light Probe for the scene, this affects reflections and indirect lighting.voidsetOnTouchListener(Scene.OnTouchListener onTouchListener)Register a callback to be invoked when the scene is touched.voidsetUseHdrLightEstimate(boolean useHdrLightEstimate)Sets whether the Scene should expect to use an Hdr light estimate, so that Filament light settings can be adjusted appropriately.-
Methods inherited from class pro.streem.ar.sceneform.NodeParent
addChild, callOnHierarchy, canAddChild, findByName, findInHierarchy, getChildren, removeChild
-
-
-
-
Field Detail
-
DEFAULT_HDR_PARAMETERS
public static final EnvironmentalHdrParameters DEFAULT_HDR_PARAMETERS
-
-
Constructor Detail
-
Scene
public Scene(SceneView view)
Create a scene with the given context.
-
-
Method Detail
-
getView
public SceneView getView()
Returns the SceneView used to create the scene.
-
getCamera
public Camera getCamera()
Get the camera that is used to render the scene. The camera is a type of node.- Returns:
- the camera used to render the scene
-
getSunlight
@Nullable public Node getSunlight()
Get the default sunlight node.- Returns:
- the sunlight node used to light the scene
-
getLightProbe
public LightProbe getLightProbe()
Get the Light Probe that defines the lighting environment for the scene.- Returns:
- the light probe used for reflections and indirect lighting.
-
setLightProbe
public void setLightProbe(LightProbe lightProbe)
Set a new Light Probe for the scene, this affects reflections and indirect lighting.- Parameters:
lightProbe- the fully loaded LightProbe to be used as the lighting environment.
-
setOnTouchListener
public void setOnTouchListener(@Nullable Scene.OnTouchListener onTouchListener)Register a callback to be invoked when the scene is touched. The callback will be invoked after the touch event is dispatched to the nodes in the scene if no node consumed the event. This is called even if the touch is not over a node, in which caseHitTestResult.getNode()will be null.- Parameters:
onTouchListener- the touch listener to attach
-
addOnPeekTouchListener
public void addOnPeekTouchListener(Scene.OnPeekTouchListener onPeekTouchListener)
Adds a listener that will be called before theScene.OnTouchListeneris invoked. This is invoked even if the gesture was consumed, making it possible to observe all motion events dispatched to the scene. This is called even if the touch is not over a node, in which caseHitTestResult.getNode()will be null. The listeners will be called in the order in which they were added.- Parameters:
onPeekTouchListener- the peek touch listener to add
-
removeOnPeekTouchListener
public void removeOnPeekTouchListener(Scene.OnPeekTouchListener onPeekTouchListener)
Removes a listener that will be called before theScene.OnTouchListeneris invoked. This is invoked even if the gesture was consumed, making it possible to observe all motion events dispatched to the scene. This is called even if the touch is not over a node, in which caseHitTestResult.getNode()will be null.- Parameters:
onPeekTouchListener- the peek touch listener to remove
-
addOnUpdateListener
public void addOnUpdateListener(Scene.OnUpdateListener onUpdateListener)
Adds a listener that will be called once per frame immediately before the Scene is updated. The listeners will be called in the order in which they were added.- Parameters:
onUpdateListener- the update listener to add
-
removeOnUpdateListener
public void removeOnUpdateListener(Scene.OnUpdateListener onUpdateListener)
Removes a listener that will be called once per frame immediately before the Scene is updated.- Parameters:
onUpdateListener- the update listener to remove
-
onAddChild
public void onAddChild(Node child)
- Overrides:
onAddChildin classNodeParent
-
onRemoveChild
public void onRemoveChild(Node child)
- Overrides:
onRemoveChildin classNodeParent
-
hitTest
public HitTestResult hitTest(android.view.MotionEvent motionEvent)
Tests to see if a motion event is touching any nodes within the scene, based on a ray hit test whose origin is the screen position of the motion event, and outputs a HitTestResult containing the node closest to the screen.- Parameters:
motionEvent- the motion event to use for the test- Returns:
- the result includes the first node that was hit by the motion event (may be null), and information about where the motion event hit the node in world-space
-
hitTest
public HitTestResult hitTest(Ray ray)
Tests to see if a ray is hitting any nodes within the scene and outputs a HitTestResult containing the node closest to the ray origin that intersects with the ray.- Parameters:
ray- the ray to use for the test- Returns:
- the result includes the first node that was hit by the ray (may be null), and information about where the ray hit the node in world-space
- See Also:
Camera.screenPointToRay(float, float)
-
hitTestAll
public java.util.ArrayList<HitTestResult> hitTestAll(android.view.MotionEvent motionEvent)
Tests to see if a motion event is touching any nodes within the scene and returns a list of HitTestResults containing all of the nodes that were hit, sorted by distance.- Parameters:
motionEvent- The motion event to use for the test.- Returns:
- Populated with a HitTestResult for each node that was hit sorted by distance. Empty if no nodes were hit.
-
hitTestAll
public java.util.ArrayList<HitTestResult> hitTestAll(Ray ray)
Tests to see if a ray is hitting any nodes within the scene and returns a list of HitTestResults containing all of the nodes that were hit, sorted by distance.- Parameters:
ray- The ray to use for the test.- Returns:
- Populated with a HitTestResult for each node that was hit sorted by distance. Empty if no nodes were hit.
- See Also:
Camera.screenPointToRay(float, float)
-
overlapTest
@Nullable public Node overlapTest(Node node)
Tests to see if the given node's collision shape overlaps the collision shape of any other nodes in the scene usingNode.getCollisionShape(). The node used for testing does not need to be active.- Parameters:
node- The node to use for the test.- Returns:
- A node that is overlapping the test node. If no node is overlapping the test node, then this is null. If multiple nodes are overlapping the test node, then this could be any of them.
- See Also:
overlapTestAll(Node)
-
overlapTestAll
public java.util.ArrayList<Node> overlapTestAll(Node node)
Tests to see if a node is overlapping any other nodes within the scene usingNode.getCollisionShape(). The node used for testing does not need to be active.- Parameters:
node- The node to use for the test.- Returns:
- A list of all nodes that are overlapping the test node. If no node is overlapping the test node, then the list is empty.
- See Also:
overlapTest(Node)
-
setUseHdrLightEstimate
public void setUseHdrLightEstimate(boolean useHdrLightEstimate)
Sets whether the Scene should expect to use an Hdr light estimate, so that Filament light settings can be adjusted appropriately.
-
setEnvironmentalHdrLightEstimate
public void setEnvironmentalHdrLightEstimate(@Nullable float[] sphericalHarmonics, @Nullable float[] direction, Color colorCorrection, float relativeIntensity, @Nullable android.media.Image[] cubeMap)Sets the current Hdr Light Estimate state to apply to the Filament scene.
-
setLightEstimate
public void setLightEstimate(Color colorCorrection, float pixelIntensity)
Sets light estimate to modulate the scene lighting and intensity. The rendered lights will use a combination of these values and the color and intensity of the lights. A value of a white colorCorrection and pixelIntensity of 1 mean that no changes are made to the light settings.This is used by AR Sceneform scenes internally to adjust lighting based on values from ARCore. An AR scene will call this automatically, possibly overriding other settings. In most cases, you should not need to call this explicitly.
- Parameters:
colorCorrection- modulates the lighting color of the scene.pixelIntensity- modulates the lighting intensity of the scene.
-
-