@@ -1062,7 +1062,7 @@ class NodeBuilder {
10621062 */
10631063 generateArrayDeclaration ( type , count ) {
10641064
1065- return type + '[ ' + count + ' ]' ;
1065+ return this . getType ( type ) + '[ ' + count + ' ]' ;
10661066
10671067 }
10681068
@@ -1084,7 +1084,7 @@ class NodeBuilder {
10841084
10851085 if ( value !== null ) {
10861086
1087- snippet += value . build ( this ) ;
1087+ snippet += value . build ( this , type ) ;
10881088
10891089 } else {
10901090
@@ -1653,6 +1653,23 @@ class NodeBuilder {
16531653
16541654 }
16551655
1656+ /**
1657+ * Returns the array length.
1658+ *
1659+ * @param {Node } node - The node.
1660+ * @return {Number? } The array length.
1661+ */
1662+ getArrayCount ( node ) {
1663+
1664+ let count = null ;
1665+
1666+ if ( node . isArrayNode ) count = node . count ;
1667+ else if ( node . isVarNode && node . node . isArrayNode ) count = node . node . count ;
1668+
1669+ return count ;
1670+
1671+ }
1672+
16561673 /**
16571674 * Returns an instance of {@link NodeVar} for the given variable node.
16581675 *
@@ -1685,7 +1702,11 @@ class NodeBuilder {
16851702
16861703 }
16871704
1688- nodeVar = new NodeVar ( name , type , readOnly ) ;
1705+ //
1706+
1707+ const count = this . getArrayCount ( node ) ;
1708+
1709+ nodeVar = new NodeVar ( name , type , readOnly , count ) ;
16891710
16901711 if ( ! readOnly ) {
16911712
@@ -1720,6 +1741,24 @@ class NodeBuilder {
17201741 return this . isDeterministic ( node . aNode ) &&
17211742 ( node . bNode ? this . isDeterministic ( node . bNode ) : true ) ;
17221743
1744+ } else if ( node . isArrayNode ) {
1745+
1746+ if ( node . values !== null ) {
1747+
1748+ for ( const n of node . values ) {
1749+
1750+ if ( ! this . isDeterministic ( n ) ) {
1751+
1752+ return false ;
1753+
1754+ }
1755+
1756+ }
1757+
1758+ }
1759+
1760+ return true ;
1761+
17231762 } else if ( node . isConstNode ) {
17241763
17251764 return true ;
@@ -2183,11 +2222,12 @@ class NodeBuilder {
21832222 *
21842223 * @param {String } type - The variable's type.
21852224 * @param {String } name - The variable's name.
2225+ * @param {Number? } [count=null] - The array length.
21862226 * @return {String } The shader string.
21872227 */
2188- getVar ( type , name ) {
2228+ getVar ( type , name , count = null ) {
21892229
2190- return `${ this . getType ( type ) } ${ name } ` ;
2230+ return `${ count !== null ? this . generateArrayDeclaration ( type , count ) : this . getType ( type ) } ${ name } ` ;
21912231
21922232 }
21932233
0 commit comments