How to use Kotlin anonymous classes as arguments for native JavaScript Functions?


#1

I asked this on SO but figured it was worth asking here too.

I am setting up the interop layer for this ThreeJS class and the constructor of the class takes in a object which is used to set the properties.

  //PointCloudMaterial.js  
  THREE.PointCloudMaterial = function ( parameters ) {
           THREE.Material.call( this );
           this.color = new THREE.Color( 0xffffff );
           this.map = null;
           this.size = 1;
           this.sizeAttenuation = true;
           this.vertexColors = THREE.NoColors;
           this.fog = true;
           this.setValues( parameters );
  };

Below is what I would like to be able to do in Kotlin, is it possible to use anomalous objects in should a fashion? I was originally thinking of creating an object equivalent to the possible perimeters to pass in, problem with that is it would override the current values which is not something I want.

  //Interop Layer
  native(“THREE.PointCloudMaterial”)
  public class PointCloudMaterial(parameters: object) { } //Error “Type Expected”

  //Example usage
  var sizeObject = object {
  var size: Double = size
  }
  PointCloudMaterial(sizeObject);


#2

Answered on SO.