Monthly Archives: June 2018

Augmented Reality in an Ionic/Angular PWA | joshmorony – Learn Ionic & Build Mobile Apps with Web Tech

https://www.joshmorony.com/augmented-reality-in-an-ionic-angular-pwa/

Augmented Reality in an Ionic/Angular PWA

| |



·

Recently, I published a tutorial on using ThreeJS with Ionic to embed virtual reality content into a mobile application using WebVR. This tutorial is going to be somewhat similar, we will still be making use of ThreeJS and WebGL, but we will be creating an augmented reality experience in an Ionic/Angular application.

If you are unfamiliar with technologies like WebGL (which uses the GPU of a device to render 3D graphics on the web) and ThreeJS (a framework that makes using WebGL easier) it might be beneficial to read the previous article about WebVR first.

Introduction to Augmented Reality

Put simply, augmented reality uses technology to “virtually” change a real physical space. Unlike virtual reality which throws you into a fully artificial/simulated world, augmented reality adds to an existing space. Although an augmented reality experience isn’t limited to just the use of a camera, most AR projects available today involve using your device’s camera to view a physical space, and additional objects will be added to that space on the screen – your device acts as a “window” into the augmented space.

This technology is still in its infancy, and I don’t think this is something people are really using in their day-to-day lives, but there are a few interesting examples out there already. Many people would have seen the use of augmented reality to add Pokémon to a real physical space in Pokémon GO which is a bit of fun, but then there are also projects like Google Lens which allows you find out more information about particular objects by using your device’s camera.

Web vs Native Augmented Reality

Apple are working on developing ARKit for native iOS applications, and Google are working on ARCore for native Android applications which will allow developers to provide augmented reality experiences in iOS and Android applications.

If you are building your Ionic applications with Cordova or Capacitor, then you can still access these Native APIs. Although comparisons are often framed as “native or hybrid”, it is important to note that when you build an Ionic application for iOS or Android it is a native application like any other – the difference is that “hybrid” applications use an embedded browser to display the web-powered user interface for the application. An application built with Ionic still has all the native tools that any other application has access to available to it, and that includes the ability to launch native views that use ARKit or ARCore.

We are talking about embedding dynamic 3D objects into a physical space in real-time here, so for experiences on the higher end of the spectrum, you are probably going to want to use these Native APIs. However, it is still entirely possible to create an augmented reality experience purely using web tech (just good old HTML, CSS, and JavaScript) – that includes integration with the camera and the rendering of 3D objects.

A downside of using Native APIs to provide an augmented reality experience is that it is platform specific. One of the big draws of Ionic and the web is that you can code an application once that will work everywhere. When you deviate away from the web and into platform-specific native integrations, you lose some of that portability.

The other benefit to using a web-based AR approach is that if you want to integrate the experience into the interface of an Ionic application, as opposed to just launching a full-screen native view, you will more easily be able to integrate a web-based AR approach with Ionic’s web-based UI. It is possible to mix native views with web UI, but unless it is just an overlay it can get messy (which is why I generally favour the web-based Google Maps JavaScript SDK over the Native SDK).

Whilst you’re probably not going to be building something like this using Web AR:

(although to be fair, this could be possible with WebAR for all I know)

There are still uses cases for a fully web-based AR experience, and since this tech is still in its infancy this is sure to grow in the future.

Building an Augmented Reality Experience in Ionic

In this tutorial, we are going to walk through an example of projecting a 3D ThreeJS scene built with A-Frame right into real life through your device’s camera. This will run completely through the web. We will be able to deploy this application as a PWA (Progressive Web Application) and access it directly through a devices web browser to activate the augmented reality functionality (assuming the device has a camera, of course).

We will be using a package called AR.js which was created by Jerome Etienne, which makes it absurdly easy to get an augmented reality experience up and running. You can literally just dump this 10 line example from the documentation into a web page:

and you have a working demo. This demo (and the example we will be building) relies on using a marker image like this. You simply point your camera at the marker image and the 3D object or objects will be projected there. You can just display the image on your computer, phone, or you could print it out on paper if you like.

What we will be focusing on in this tutorial is how to get a similar example working well in an Ionic/Angular environment. When we are done, we will have something that looks like this:

Augmented Reality in an Ionic & Angular PWAwww.joshmorony.com/wp-content/uploads/2018/06/arcat-166×300.png 166w” sizes=”(max-width: 499px) 100vw, 499px” class=”clear” style=”max-width: 100%; margin: 0.5em auto; display: block; height: auto; clear: both;”>

Javascript Camp

You can view this demo directly yourself by clicking here. You don’t even need to be on your phone, if your computer has a webcam then it should run through that as well.

Create the 3D Scene

We can create the 3D scene that we want to display in augmented reality using A-Frame – which is basically a framework that makes using ThreeJS easier (which is a framework that makes using WebGL easier). A-Frame allows us to use simple HTML syntax to embed 3D objects into a scene. I will likely post a more in-depth tutorial about A-Frame in the future, but for now, we are just going to use it for a simple example.

We can trigger the behaviour of AR.js by adding the arjs attribute to the A-Frame scene, but it is important to note that it will attach its functionality to the <body> tag of the page. This makes it a little difficult to just add an A-Frame scene to one of the page’s templates in our Ionic/Angular application because it isn’t going to play nicely with the rest of the application.

This makes using an <iframe> an attractive option because we can just load our scene directly into the <iframe> and we can embed the frame wherever we need it in the application. We can just create a standard HTML file and save it as a local asset for the application, then we can just load that directly into the IFrame. We are going to create an example that is almost identical to the demo code – we are just going to tweak a couple of things so we have some more interesting objects.

Save the following file as aframe-ar.html in your assets folder

This will create a simple 3D scene with a plane positioned at the bottom, and a box that is sitting on top of it. The AR functionality is completely self-contained in this frame, so there is no need to install or make any modifications to the Ionic/Angular application. All we will need to do is embed the IFrame somewhere.

Add the IFrame

You can embed the IFrame anywhere you like in your Ionic/Angular application (just make sure that you supply your static .html file from the assets folder as the src for the IFrame), but you will probably want to add a few styles to make it display more nicely (just add this to whatever component you are displaying the frame in):

iframe {

    position: absolute;

    width: 100%;

    height: 100%;

    border: none;

}

For the example application, I created an ARLauncherPage that I launched as a modal to trigger the AR functionality:

ar-launcher.page.html

<ion-header>

  <ion-toolbar>

    <ion-title>ARLauncher</ion-title>

    <ion-buttons slot="end">

      <ion-button (click)="close()"><ion-icon name="close" slot="icon-only"></ion-icon></ion-button>

    </ion-buttons>

  </ion-toolbar>

</ion-header>

<ion-content>

    <iframe src="/assets/aframe-ar.html"></iframe>

</ion-content>

ar-launcher.page.ts

import { Component, OnInit, ViewEncapsulation } from '@angular/core';

import { ModalController } from '@ionic/angular';

@Component({

  selector: 'app-ar-launcher',

  templateUrl: './ar-launcher.page.html',

  styleUrls: ['./ar-launcher.page.scss'],

  encapsulation: ViewEncapsulation.None

})

export class ARLauncherPage implements OnInit {

  constructor(private modalCtrl: ModalController) { }

  ngOnInit() {

  }

  close(){

    this.modalCtrl.dismiss();

  }

}

Deploy to the Web

The cool thing about AR.js is that it runs entirely with web tech, there is absolutely no native integration required which means we can just run it directly on the web (you could also deploy it as a native application if you wanted to).

If you would like to set the application up as a PWA (you don’t have to) you can follow the steps in this tutorial. Once you are ready to host it on the web, you can follow this tutorial to get it set up with Firebase Hosting (or you could host it wherever you prefer).

Summary

With your application hosted, all you need to do is go to the URL, launch the page that contains the AR functionality, and point your camera at the marker image.

Augmented Reality in an Ionic & Angular PWAwww.joshmorony.com/wp-content/uploads/2018/06/arcat-166×300.png 166w” sizes=”(max-width: 499px) 100vw, 499px” class=”clear” style=”max-width: 100%; margin: 0.5em auto; display: block; height: auto; clear: both;”>

Whilst AR.js – and augmented reality on the web in general – is still under development, it is exciting to see the kinds of things we are already able to do with the web today.

What to watch next…

Mr. Potato Head





This is a really good email. It took a long time to write but it’s a short read. That’s what makes it so good. View this email in your browser. June 26, 2018.


 

SUBSCRIBE
2018 $$$

Briefed while companies spend ~$4b running legitimate sweepstakes in the US




THOUGHT OF THE DAY

“CYA is an insurance contortionist. With removable limbs. Or maybe we are more like Mr. Potato Head? You can add or remove or swap the assets you want us to cover – at any time! Simply log in to your CYA account to make the change.” That’s CYA, as in Cover Your Assets. A new brand in the warranty space.
 

 

TIDBITS

We Need to Talk About Kevin
Meet Kevin:

 
Kevin is a virtual roommate that gives the impression that someone is home with the aim of preventing burglaries. It was co-developed by Mitipi and the Helvetia Corporate Incubator. Functionalities include simulating presence with lights, shadows and acoustics (TV, music, cooking, shower and more). Established in 2016, the Zurich-based startup is led by Julian Stylianou (CEO), Laura Schilliger (CMO), Khanh Ngyuen (CTO), and Jakob Cevc (Head of Product). At some point later this year, the product will retail for ~$280. Bottom Line: raised more than CHF 50K above its Kickstarter goal.

You’ll Always Be CSA For Me
Last month Generali Global Assistance announced the launch of a new online claims portal for its US-based travel insurance partner Justfly (think: an online travel agent).
 

The portal allows customers to download their description of coverage or policy, start a new claim, add information to an existing claim, and track the status of their claim online. Generali Global Assistance was recently named a top travel insurance company for 2018 by The Elliot Readers’ Choice Awards. However, on Yelp it isn’t doing so well – 1.5 stars from 89 reviews for CSA Travel Protection, which rebranded to Generali Global Assistance in 2017. Speaking of reviews, Justfly made a general manager at Square very upset and the BBB has in the past issued a warning concerning the company. 

AMEXA
Born in collaboration with AMEX and AXA Partners, Blue Protection is an insurance package that includes five policies in the areas of home, health, mobility, cyber and tech. The offers are geared toward Italy-based AMEX clients who can configure the protection based on their needs – from choosing one policy to the full package.
 

Coverage highlights: Blue Protection Mobility – roadside assistance that isn’t limited to vehicles owned by the insured – it also covers other vehicles of which the insured is an authorized driver. Blue Protection Home – coverage in case of emergency situations. The policy also offers warranty extension on a wide range of equipment and appliances. Blue Protection Tech – coverage for electronic devices in case of theft or accidental damage, along with personal items, such as bags and wallets. Blue Protection Cyber – reimbursement of expenses incurred for judicial proceedings relating to events suffered by the insured or by a member of the family due to matters relating to private life. Blue Protection Health – a medical call center available 24 hours, and the ability to request a doctor or ambulance if necessary. To purchase coverage, AMEX clients are redirected to AXA’s Inter Partners Assistance Blue Protection branded website.

Everything is Blue.
Blue Owl has a new look. Before:

 
After:

 
Bottom Line: wait for it. Recall: Blue Owl is the San Francisco-based digital-slash-innovation arm of State Farm. Also, the makers of HiRoad. And thank god for HiRoad (see below).

When You Just Wanted To Get Shoes
Sun Life Financial announced its partnership with E-Commerce platform Lazada to make it easier for Filipinos to purchase insurance online. Recall: founded in 2012, Lazada is Southeast Asia’s leading online shopping and selling platform with $4.7b in funding from investors that include Alibaba and Tesco. The company enjoys over 32m monthly visitors to its website.
 

In what’s considered “a first of its kind” partnership (but really isn’t), Sun Life’s personal accident insurance product will be available to Lazada members through its website by July 2018. The insurance can be purchased and activated completely online. 

Carro Care
Carro, the Singapore-based online marketplace for buying and selling cars with $78m in funding, is now offering Carro Care, Singapore’s first insurer backed warranty that covers direct owner purchases.

Underwritten by Tokio Marine Insurance Singapore and administered by The Warranty Group, Carro Care offers car owners protection from unexpected repair costs even if they haven’t bought their car on Carro. In the event of a claim, car owners take their cars to one of several authorized repair shops. The shop then provides a diagnosis of the problem, its cause, and estimated costs of parts and labor to The Warranty Group to get the claim approved. Founded in 2015, Carro also has presence in Indonesia and Thailand. 

 

VIA COVERAGER POST


American Capital Assurance Corporation Live in 8 Months on Majesco P&C Suite
Majesco, a global provider of core insurance software and consulting services for insurance business transformation, today announced that American Capital Assurance Corporation went live with the Majesco P&C Core Suite, inclusive of policy, billing, and claims. Read the full Post here.

Recently Funded
DroneDeply – the California-based drone data software platform announced it has raised $25m Series C, bringing its total funding to date to $56m. 

 



JOBS

Head of insurance operations / CIO 
VP Finance 
Broker Evangelist 
CTO 


TWEET TALK


*

BRIEFED ABOUT

AIG Malaysia. AMEX. Blue Owl. Carro. Consumer Priority Service. CYA. DroneDeploy. Generali Global Assistance. Helvetia. Majesco. Mitipi. State Farm. Sun Life Financial. The Warranty Group. Tokio Marine.

 

* WELCOME *

American Family. Genworth Financial. Globant. Liberty Mutual. Metromile. National Partners. Primerica. Verisk.

To post a job, click here. To publish news and announcements, click here. To advertise, click here.
 

ARCHIVE

Twitter


YouTube


LinkedIn



You’re receiving this email because you opted in.
unsubscribe

Digital Insurance Revolution

Digital Insurance Revolution
George Kesselman | 19 Jun 2018
https://www.linkedin.com/pulse/digital-insurance-revolution-george-kesselman

Read more…

信諾中小企團體醫療保

Chatbot enabled quotation and application www.cigna.com.hk/zh-hant/our-insurance-solutions/medical-health/cigna-smart-entrepreneur-group-medical-plan

Payment Platform Marqeta Raises $45 Million From Goldman, Iconiq – Bloomberg

www.bloomberg.com/news/articles/2018-06-05/payment-platform-marqeta-raises-45-million-from-goldman-iconiq