Three.js: Incomplete type definitions in Nodes

Created on 8 Nov 2019  路  6Comments  路  Source: mrdoob/three.js

The type definitions for Node materials seem incomplete. All the shortcuts like color, alpha etc are missing.

Most helpful comment

Oh dear, the type declaration file for ShadowMaterial is totally messed up. Let's fix this...

All 6 comments

+1

ShadowMaterial params are declared as ShaderMaterialParams, so passing the color there triggers the typescript, also.

Oh dear, the type declaration file for ShadowMaterial is totally messed up. Let's fix this...

@martinRenou What do you mean with shortcuts? Can you show the respective JS code, please?

Sorry, I was not super clear, and thanks for taking the time for opening a PR for this!

So there seem to be a "shortcut" logic in the code here: https://github.com/mrdoob/three.js/blob/master/examples/jsm/nodes/materials/StandardNodeMaterial.js#L22-L41

And my understanding is that it dynamically adds getter and setters to the Material prototype: https://github.com/mrdoob/three.js/blob/22ed6755399fa180ede84bf18ff6cea0ad66f6c0/examples/jsm/nodes/core/NodeUtils.js#L11-L27

None of those properties is part of the TypeScript definition.

This might be the case for other classes in the nodes examples. I could come up with a PR myself fixing those.

I could come up with a PR myself fixing those.

That would be great! /cc @sunag

That would be great!

+1

Was this page helpful?
0 / 5 - 0 ratings