Skip to content

Commit

Permalink
TSL: Node - Introduce getElementType() (#28437)
Browse files Browse the repository at this point in the history
* Fix Array Element Type

* revision
  • Loading branch information
sunag authored May 20, 2024
1 parent 6651acf commit 114f0ad
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions examples/jsm/nodes/accessors/BufferNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class BufferNode extends UniformNode {

}

getElementType( builder ) {

return this.getNodeType( builder );

}

getInputType( /*builder*/ ) {

return 'buffer';
Expand Down
9 changes: 9 additions & 0 deletions examples/jsm/nodes/core/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ class Node extends EventDispatcher {

}

getElementType( builder ) {

const type = this.getNodeType( builder );
const elementType = builder.getElementType( type );

return elementType;

}

getNodeType( builder ) {

const nodeProperties = builder.getNodeProperties( this );
Expand Down
10 changes: 10 additions & 0 deletions examples/jsm/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,16 @@ class NodeBuilder {

}

getElementType( type ) {

if ( type === 'mat2' ) return 'vec2';
if ( type === 'mat3' ) return 'vec3';
if ( type === 'mat4' ) return 'vec4';

return this.getComponentType( type );

}

getComponentType( type ) {

type = this.getVectorType( type );
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/utils/ArrayElementNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ArrayElementNode extends Node { // @TODO: If extending from TempNode it br

getNodeType( builder ) {

return this.node.getNodeType( builder );
return this.node.getElementType( builder );

}

Expand Down

0 comments on commit 114f0ad

Please sign in to comment.