.prototype to ES6 conversion question

I am puttering through Julian Chenard’s excellent ebook “Learning Babylon.js” as I realized how much I have forgotten over the years. However, it was wrote for Babylon 2.4 using pre ES6 standards so I have added the challenge of converting all the code in the book to modern standards including ES6. I figured that would force me to brush up on modern standards and the latest 4.x engine.

I am sure it is nothing but a typo, but I am at a loss as to where. This is a basic “player class” from one of his early examples semi converted to ES6. But Babylon seems to be loosing reference when trying to call setVertexData. Why?

https://playground.babylonjs.com/#9XLTG5

The console syntax error is “TypeError: e.setVerticesData is not a function”.

Also is “this.that= this” or “this._this = this” still the best way of doing things. It would amaze me if that was not made more elegant in ES6 but I still see it in examples.

In typescript, the scope should be all good so you do most of the time not need any this related trick.

About setVertexData, please import “@babylonjs/core/Meshes/sphereBuilder” which contain all the related information to create spheres.

How does one go about importing the sphereBuilder into the engine?

just add this line at the end of your imports:

import “@babylonjs/core/Meshes/sphereBuilder”;

You should have a look here it should explain a bit more about why and how: ES6 - Babylon.js Documentation