Why THREE.js doesn't use JavaScript classes?

I mean, the classes introduced in ECMAScript 2015
like so:

class Person {
                   
    //private properties
    private var personName : String;
    private var personAge : Number;
                   
    //constructor
    function Person(name: string, age: int){
        personName = name;
        personAge = age;
    }
                   
    //public function
    function sayAge(){
        alert(personAge);
    }
               
}
                   
var person = new Person(“James”, 30);
person.sayAge();    //30  

Is it because there are many cellphones not supporting ECMAScript 2015 or because THREE started before that and is still using the old way?

I find that defining a class like above is much more elegant.
What I’m really asking is whether there is a possible compatibility problem with some cellphones as I’m about to use it myself.

That one.

Normally, all modern browsers support classes even on older smartphones. If necessary, you can provide a special build without classes for older browsers as a fallback. More information about classes in three.js right here:

2 Likes

Thanks @Mugen87!