Hi
I’ve been looking at the techniques @will showed in this project…
https://playcanvas.com/project/324696/overview/introducing-iphone-6
… and there are two feature I’m trying to implement. The first one is having a menu and a logo and the second one are the hotspots. With the first goal, to include a menu and a logo I figured the most straightforward solution was to add HTML elements to the document which seems to work very well.
Hotspots on the other hand, seems to present a few different possible paths. When reading through this forum I’ve identified at least these three different techniques:
- Using 3D planes with a texture together with a billboarding script to have them facing the camera at all times. The can either penetrate other geometry or disregard the depth buffer, but in my tests none of those solutions seems perfect. (much like in this project https://playcanvas.com/project/362228/overview/tutorial-selectable-sprites)
- Using a 2D canvas and drawing objects directly onto it, similar to the iphone project.
- and third, creating HTML dom elements, like an image or div or similar, and style and position that with css much like in the bmw i8 project.
In my case, a requirement is that the solution should be able to have an interactiveness so that when you click on a hotspot, a certain lightbox style information should popup for example.
I’ve tried version 1 but I’m not happy with the intersecting thing. So yesterday I tried version 2 from the iphone project but I ran into some problems. Perhaps version 3 is the way to go but I still haven’t tried it.
About version 2, drawing on the 2 canvas, I added this code to create the canvas:
// Create the HTML canvas on which to draw hotspot images/points.
var app = this.app;
this.canvas = document.createElement('canvas');
this.canvas.width = app.graphicsDevice.width;
this.canvas.height = app.graphicsDevice.height;
this.canvas.style.position = 'absolute';
this.canvas.style.left = '0px';
this.canvas.style.top = '0px';
document.body.appendChild(this.canvas);
this.ctx = this.canvas.getContext('2d');
… But when I do, and add it to the body element, I see the performance of my camera orbiting gets slowed down by a lot. It’s not as responsive but more sluggish when turning the model. Also, it seems to create something “selectable” spanning the entire screen, so sometimes when dragging or accidently doubleclicking - the entire screen gets “selected” and gets a purple overlay (in chrome).
Also, I’m not sure how to hide these 2D elements, whether using solution 2 or 3 from the 3D models when the hotspots appear on the back side.
Anyone experienced that can shine a light on the pros and cons and common pitfalls about these 3 techniques, or perhaps there is forth one I’ve missed.
Best regards
- Björn