How to create UI for Spark AR? - user-interface

I'm new to Spark AR and I'm having issues creating a UI that sticks to the screen rather than moving with the 3D object (I'm using plane tracking). Does anyone have a tutorial you followed or could tell me how to do it?
My end game is to have the user be able to switch between 3D models by touching two buttons.

Have you tried using a canvas object?
See here:
https://sparkar.facebook.com/ar-studio/learn/tutorials/2D-objects-and-layers

Related

The best approach to use only ThreeJS for building interactive UI without HTML DOM overlays

May I have a 2D layer for UI, Text, Buttons, etc over the 3D scene in ThreeJS?
Ideally something like engine from PixiJS inside ThreeJS? I've seen PixiJS offers some 3D features so why not combine both libraries in something super-powerful? I just do not want to place any HTML Dom elements over WebGL canvas as this will probably slow down performance on Mobile devices.
One way to solve this issue is to implement the UI as screen space sprites like demonstrated in the following official example (check out how the red sprites are rendered):
https://threejs.org/examples/webgl_sprites
The idea is to render them with a separate orthographic camera and an additional call of WebGLRenderer.render(). Besides, instances of THREE.Sprite do support raycasting which is of course useful when implementing interaction.
Building up on Mugen87's answer, you can also use THREE.Shape to make visual containers adapted to the user screen size :
https://threejs.org/docs/#api/en/extras/core/Shape
You can use THREE.Shape to make mesh-based text, is illustrated in this example :
https://threejs.org/examples/?q=text#webgl_geometry_text_shapes
You should also have a look at three-mesh-ui, an add-on for building mesh-based user interface with three.js :
https://github.com/felixmariotto/three-mesh-ui

How to create a custom sprite [FiveM Lua]

I have been searching for a way to draw a custom image (.png) on screen.
When I started to look it up, I noticed everyone went for the UI way.
I've already asked how I could do this using one of FiveM's natives and I got the answer of drawSprite()
But now I have a new question; How can I create a custom sprite for the drawSprite() native to call upon?
And when I have this custom sprite, how do I use it in the drawSprite() native?
Thanks in advance!

Improving THREE js loading time

I'm new to webgl and three js but I managed to finished a small project in a few weeks. But what I want to ask is, what can I do do improve loading times of the app? I'm not complaining about the fps's because the interaction with it is smooth, but it takes quite a while to load everything. Do you guys have any tips or resources that I can check to improve the bundle js loading times?
Im using d3, topojson and three js. The project is a 3d globe with a background image. The globe has a texture and it shows the overlay of the country you're hovering with (so it has mousemove and click events). It also has 3d markers (spheres and cylinders) and interact when you click them.
I tried removing all the code i could, avoid heavy computations, and use BufferGeometry everywhere I could. It also has particles. Since it uses click events I needed Projector.js and I needed OrbitControls.js for the controls logic. Im using debounce on the events also. I'm just asking about general three js tips, some guidelines to avoid waiting 6-9seconds for whole scene to load. Thanks!
shrink your 3D model data;
use compressed texture format such as dds or crunch;
cut big scene into small ones and load them by lods;
Hope this helpful.

How to prevent automatic re-centering when scene is loaded on Gear VR?

I'm using Unity 5 and OVR utilities, I'd like to avoid the scene being recentered every time I load a new scene. Basically, I'd like the player to be able to sit down and even if he's looking at his right at the moment of a new scene loading, I'd like him to be able to continue playing without having to use some manual recentering or having to change his sitting position.
I've found 2 other posts with the same question but only for other VR platforms and they didn't solve my problem:
Persist Google Cardboard forward direction across scene loads in Unity3D 4.6.7?
Google Cardboard - how to face the same way when changing scenes?
Turns out, if you're using OVR Utilities from Oculus, there's a very simple boolean-based solution that you can set in the Editor:
Find the OVRManager script attached to the OVRCameraRig
Uncheck 'Reset Tracker On Load'

Cocoa control to render a tile map

Is there any Cocoa control that is capable of drawing tile maps with multiple layers and multiple texture sources which can also intercept touches into single tiles? Having multiple layer support is not a real requirement but an optional feature (the views could still be stacked). Hardware acceleration is not needed at all.
So far I have toyed around with NSMatrix, IKImageBrowser and NSCollectionView but non of them felt like a good solution for the problem. Ideally I need an control similar to the one in Tiled.app. Is there anything, third party or built-in, or do I have to handcraft this control?
I fear that you will be hardly able to find a ready-to-use control for managing tile maps.
If I had to implement something like that on my own, I would consider using CATiledLayer, since this is the closest thing to a tile map control that I know of.
From CATiledLayer Reference:
CATiledLayer is a subclass of CALayer providing a way to asynchronously provide tiles of the layer's content, potentially cached at multiple levels of detail.
There is a nice sample by Bill Dudney (the author of "Core Animation for MacOS and the iPhone"). This sample could provide you a solid foundation for your own project, though it only displays one single PDF, allowing you to zoom in the area you clicked on (this requires rereading the tile at a different detail level).
Another interesting introduction can be found here. This is more step-by-step, so you might start with this.
Finally, on Cocoa is my Girlfriend there is a nice article, although it focuses on iOS, but you may find it anyway relevant.
Cocos2D supports building mac applications now
Article on cocos2d stating this: http://www.cocos2d-iphone.org/archives/1444
Aee here for how to do it: http://chris-fletcher.com/tag/cocos2d-os-x/
Aee here on how to use TMX tile maps with Cocos2D to build tile based maps: http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:tiled_maps
This means you can use the power of Cocos2d and you will have to write much less code to get to where you want with a tile based map.
If you don't want to use Cocos2D:
It seems you would have to code it yourself, but it shouldn't be too hard to do.
First you can create your .TMX file using the tile editor "Tiled.app" then you would need to parse the XML using a standard xml library for Cocoa.
To lay out the tiles use a UIView for the overall container and then create a tile class that holds your tile display information and responds to clicks the tile class should extend UIView. For the tile class allow the assigning of a click delegate and assign your ViewController as the click delegate for all tiles so you can handle clicks easily with the clicked tile being passed to you.
Loop through your xml data and create and position the tiles in the overall UIView by using the tiles width/height and your tilemaps rows/columns.
I think in about a day or 2 you could have the tile map being rendered and clickable using the standard TMX format which will allow you to edit your map in "Tiled.app"
The TMX standard is covered here: https://github.com/bjorn/tiled/wiki/TMX-Map-Format
route-me might fit the bill.

Resources