I'm going around in circles on this a little and need some help. Full disclosure - I posted this on Stackoverflow but got no hits.

Background ... I have a javascript (babylon.js) 3d application that uses html5 webgl canvas element. I would like to add this to my Drupal 8 site. I am new to Drupal but not to MVC and have spent several hours on the various drupal tutorials so I think get the (very) basics of module/theme development.

Intuitively I thought I would need to: - add the canvas element to a block using a module - position the block in a region (or possibly use Panels for more flexible positioning) - update a theme to amend presentation of the canvas element in the block - add the javascript application as a library that manipulates the canvas and the objects within it.

The few references to this kind of thing I can find seem to suggest that the HTML5 canvas element should be introduced via twig as part of a theme. I get the twig process but is this approach correct? In my understanding this would be effectively adding content/structure straight into Drupal's presentation layer which does not feel right?

Ultimately where I want to get to is to display the canvas in one region with blocks in another region (or possibly using 2 tabbed Views) showing a) a list of all available 3d object types; and b) the 3d object types (and counts) currently included in the scene. With buttons to add/remove objects from the scene. This will require passing values between the Drupal/PHP part of the site and the javascript babylon.js code. I effectively want the scene and the objects within it to be managed as Drupal content.

However first things first .. how do I correctly display the webgl canvas element!!

Thanks in advance.

Comments

OOPdude’s picture

I have been working on WebGL applications on Drupal 7 and 8.
I know what you got slightly frustrated because most of Drupal persons do not work on WebGL.
My present projects are terrian maps of local regions on web. For this, I decomposed cad data and connected them to Drupal entity structures. Then, successfully plugged in to Drupal view/pages.

I haven't tried to connect them to block (in fact, we don't use blocks for some reasons).
For the cavas, that's not a big thing.
I will be back to this talk because I am out of town.

paulnaude’s picture

I am still a newbie with Drupal but I am watching this with interest.
can you do a simple tutorial on what is needed to make it all go together?