JavaScript access to accelerometer

Hello guys,

I recently discovered the latest fuse samples and Im very impressed especially of the native interop accelerometer sample.
Its really great to move a circle just with handmovements, but Im not sure how I can access the x and y values from javascript in order to make it available for if conditions and make it a bit smooth.

<App Background="#3C4959">
	<Panel>
		<Circle Width="40" Height="40" Fill="#F2AF5C">
			<InteractiveTransform ux:Name="transform" />
		</Circle>
		
		<AccelerometerExampleMovement Target="transform" />
	</Panel>
</App>

On the uno stage it seems clear, that the event immediately pasts the coordinates into the InteractiveTransform, which directly communicates with the ux object properties.

...
public InteractiveTransform Target { get; private set; }
	
void AccUpdated(object sender, AccelerometerUpdatedArgs args)
{
	float3 acceleration = args.Value;
		
	Target.Translation = acceleration.XY * 10;
	Target.ZoomFactor = acceleration.Z * 0.2f + 0.2f;
}
...

How can I extract it with a JS native module, or maybe even on ux stage?

Hi! I’ve added a JS module to the project, which you can find the source code of here.
An example of how to use the module can be found here.

I’d recommend having a look at Attractor (which you can see an example of here) for smoothing.

hey thanks for the quick reply…
that looks great, exactly that what I wanted, but there are errors occuring during compile.

... E3114: There is nothing named 'NativeEventEmitterModule' accessible in this scope.

Does it need some additional using directives?

Whoops! I forgot to mention it will only work with the next release of Fuse (0.30), which you can get your hands on here :slight_smile:

thanks a lot!! :slight_smile: