Hello, encountered problem with object keys. @JsNa...
# javascript
n
Hello, encountered problem with object keys. @JsName("keyName") on fields and @JsExports doesn't work for me or I'm not using them in the right way. More in thread.
1
I'm trying to create a wrapper for three.js class MeshLambertMaterial github source line . Here is my code.
Copy code
@file:JsModule("three")
@file:JsNonModule
package wrappers
...
@JsName("MeshLambertMaterial")
external class MeshLambertMaterial(parameters: LambertParameters)

external interface LambertParameters {
    @JsName("color")
    var color: Long
    @JsName("opacity")
    var opacity: Float
    @JsName("emissive")
    var emissive: Long
}

// another file

data class LambertParametersImpl(
    override var color: Long,
    override var opacity: Float,
    override var emissive: Long
    ) : LambertParameters
Also tried using only data class with JsName.
The problem is, when I'm getting 3d object on screen there are following warnings.
Copy code
> THREE.MeshLambertMaterial: '_color_2' is not a property of this material.
> THREE.MeshLambertMaterial: '_opacity' is not a property of this material
... etc
Those warnings coming from github source line, when it iterates over keys.
a
It has been my experience that overriding external interfaces still mangle the field and method names. I would approach it like so
Copy code
fun LambertParameters(
    color: Long,
    opacity: Float,
    emissive: Long
) = jsObject<LambertParameters> {
    this.color = color
    this.opacity = opacity
    this.emmisive = emmisive
}
1
n
Thx! It worked