forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNodeBuilder.js
2644 lines (1858 loc) · 58.8 KB
/
NodeBuilder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import NodeUniform from './NodeUniform.js';
import NodeAttribute from './NodeAttribute.js';
import NodeVarying from './NodeVarying.js';
import NodeVar from './NodeVar.js';
import NodeCode from './NodeCode.js';
import NodeCache from './NodeCache.js';
import ParameterNode from './ParameterNode.js';
import StructType from './StructType.js';
import FunctionNode from '../code/FunctionNode.js';
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
import { getTypeFromLength } from './NodeUtils.js';
import { NodeUpdateType, defaultBuildStages, shaderStages } from './constants.js';
import {
NumberNodeUniform, Vector2NodeUniform, Vector3NodeUniform, Vector4NodeUniform,
ColorNodeUniform, Matrix2NodeUniform, Matrix3NodeUniform, Matrix4NodeUniform
} from '../../renderers/common/nodes/NodeUniform.js';
import { stack } from './StackNode.js';
import { getCurrentStack, setCurrentStack } from '../tsl/TSLBase.js';
import CubeRenderTarget from '../../renderers/common/CubeRenderTarget.js';
import ChainMap from '../../renderers/common/ChainMap.js';
import BindGroup from '../../renderers/common/BindGroup.js';
import { REVISION, IntType, UnsignedIntType, LinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapLinearFilter } from '../../constants.js';
import { RenderTarget } from '../../core/RenderTarget.js';
import { Color } from '../../math/Color.js';
import { Vector2 } from '../../math/Vector2.js';
import { Vector3 } from '../../math/Vector3.js';
import { Vector4 } from '../../math/Vector4.js';
import { Float16BufferAttribute } from '../../core/BufferAttribute.js';
const rendererCache = new WeakMap();
const typeFromArray = new Map( [
[ Int8Array, 'int' ],
[ Int16Array, 'int' ],
[ Int32Array, 'int' ],
[ Uint8Array, 'uint' ],
[ Uint16Array, 'uint' ],
[ Uint32Array, 'uint' ],
[ Float32Array, 'float' ]
] );
const toFloat = ( value ) => {
if ( /e/g.test( value ) ) {
return String( value ).replace( /\+/g, '' );
} else {
value = Number( value );
return value + ( value % 1 ? '' : '.0' );
}
};
/**
* Base class for builders which generate a shader program based
* on a 3D object and its node material definition.
*/
class NodeBuilder {
/**
* Constructs a new node builder.
*
* @param {Object3D} object - The 3D object.
* @param {Renderer} renderer - The current renderer.
* @param {NodeParser} parser - A reference to a node parser.
*/
constructor( object, renderer, parser ) {
/**
* The 3D object.
*
* @type {Object3D}
*/
this.object = object;
/**
* The material of the 3D object.
*
* @type {?Material}
*/
this.material = ( object && object.material ) || null;
/**
* The geometry of the 3D object.
*
* @type {?BufferGeometry}
*/
this.geometry = ( object && object.geometry ) || null;
/**
* The current renderer.
*
* @type {Renderer}
*/
this.renderer = renderer;
/**
* A reference to a node parser.
*
* @type {NodeParser}
*/
this.parser = parser;
/**
* The scene the 3D object belongs to.
*
* @type {?Scene}
* @default null
*/
this.scene = null;
/**
* The camera the 3D object is rendered with.
*
* @type {?Camera}
* @default null
*/
this.camera = null;
/**
* A list of all nodes the builder is processing
* for this 3D object.
*
* @type {Array<Node>}
*/
this.nodes = [];
/**
* A list of all sequential nodes.
*
* @type {Array<Node>}
*/
this.sequentialNodes = [];
/**
* A list of all nodes which {@link Node#update} method should be executed.
*
* @type {Array<Node>}
*/
this.updateNodes = [];
/**
* A list of all nodes which {@link Node#updateBefore} method should be executed.
*
* @type {Array<Node>}
*/
this.updateBeforeNodes = [];
/**
* A list of all nodes which {@link Node#updateAfter} method should be executed.
*
* @type {Array<Node>}
*/
this.updateAfterNodes = [];
/**
* A dictionary that assigns each node to a unique hash.
*
* @type {Object<number,Node>}
*/
this.hashNodes = {};
/**
* A reference to a node material observer.
*
* @type {?NodeMaterialObserver}
* @default null
*/
this.observer = null;
/**
* A reference to the current lights node.
*
* @type {?LightsNode}
* @default null
*/
this.lightsNode = null;
/**
* A reference to the current environment node.
*
* @type {?Node}
* @default null
*/
this.environmentNode = null;
/**
* A reference to the current fog node.
*
* @type {?FogNode}
* @default null
*/
this.fogNode = null;
/**
* The current clipping context.
*
* @type {?ClippingContext}
*/
this.clippingContext = null;
/**
* The generated vertex shader.
*
* @type {?string}
*/
this.vertexShader = null;
/**
* The generated fragment shader.
*
* @type {?string}
*/
this.fragmentShader = null;
/**
* The generated compute shader.
*
* @type {?string}
*/
this.computeShader = null;
/**
* Nodes used in the primary flow of code generation.
*
* @type {Object<string,Array<Node>>}
*/
this.flowNodes = { vertex: [], fragment: [], compute: [] };
/**
* Nodes code from `.flowNodes`.
*
* @type {Object<string,string>}
*/
this.flowCode = { vertex: '', fragment: '', compute: '' };
/**
* This dictionary holds the node uniforms of the builder.
* The uniforms are maintained in an array for each shader stage.
*
* @type {Object}
*/
this.uniforms = { vertex: [], fragment: [], compute: [], index: 0 };
/**
* This dictionary holds the output structs of the builder.
* The structs are maintained in an array for each shader stage.
*
* @type {Object}
*/
this.structs = { vertex: [], fragment: [], compute: [], index: 0 };
/**
* This dictionary holds the bindings for each shader stage.
*
* @type {Object}
*/
this.bindings = { vertex: {}, fragment: {}, compute: {} };
/**
* This dictionary maintains the binding indices per bind group.
*
* @type {Object}
*/
this.bindingsIndexes = {};
/**
* Reference to the array of bind groups.
*
* @type {?Array<BindGroup>}
*/
this.bindGroups = null;
/**
* This array holds the node attributes of this builder
* created via {@link AttributeNode}.
*
* @type {Array<NodeAttribute>}
*/
this.attributes = [];
/**
* This array holds the node attributes of this builder
* created via {@link BufferAttributeNode}.
*
* @type {Array<NodeAttribute>}
*/
this.bufferAttributes = [];
/**
* This array holds the node varyings of this builder.
*
* @type {Array<NodeVarying>}
*/
this.varyings = [];
/**
* This dictionary holds the (native) node codes of this builder.
* The codes are maintained in an array for each shader stage.
*
* @type {Object<string,Array<NodeCode>>}
*/
this.codes = {};
/**
* This dictionary holds the node variables of this builder.
* The variables are maintained in an array for each shader stage.
* This dictionary is also used to count the number of variables
* according to their type (const, vars).
*
* @type {Object<string,Array<NodeVar>|number>}
*/
this.vars = {};
/**
* Current code flow.
* All code generated in this stack will be stored in `.flow`.
*
* @type {{code: string}}
*/
this.flow = { code: '' };
/**
* A chain of nodes.
* Used to check recursive calls in node-graph.
*
* @type {Array<Node>}
*/
this.chaining = [];
/**
* The current stack.
* This reflects the current process in the code block hierarchy,
* it is useful to know if the current process is inside a conditional for example.
*
* @type {StackNode}
*/
this.stack = stack();
/**
* List of stack nodes.
* The current stack hierarchy is stored in an array.
*
* @type {Array<StackNode>}
*/
this.stacks = [];
/**
* A tab value. Used for shader string generation.
*
* @type {string}
* @default '\t'
*/
this.tab = '\t';
/**
* Reference to the current function node.
*
* @type {?FunctionNode}
* @default null
*/
this.currentFunctionNode = null;
/**
* The builder's context.
*
* @type {Object}
*/
this.context = {
material: this.material
};
/**
* The builder's cache.
*
* @type {NodeCache}
*/
this.cache = new NodeCache();
/**
* Since the {@link NodeBuilder#cache} might be temporarily
* overwritten by other caches, this member retains the reference
* to the builder's own cache.
*
* @type {NodeCache}
* @default this.cache
*/
this.globalCache = this.cache;
this.flowsData = new WeakMap();
/**
* The current shader stage.
*
* @type {?('vertex'|'fragment'|'compute'|'any')}
*/
this.shaderStage = null;
/**
* The current build stage.
*
* @type {?('setup'|'analyze'|'generate')}
*/
this.buildStage = null;
}
/**
* Returns the bind groups of the current renderer.
*
* @return {ChainMap} The cache.
*/
getBindGroupsCache() {
let bindGroupsCache = rendererCache.get( this.renderer );
if ( bindGroupsCache === undefined ) {
bindGroupsCache = new ChainMap();
rendererCache.set( this.renderer, bindGroupsCache );
}
return bindGroupsCache;
}
/**
* Factory method for creating an instance of {@link RenderTarget} with the given
* dimensions and options.
*
* @param {number} width - The width of the render target.
* @param {number} height - The height of the render target.
* @param {Object} options - The options of the render target.
* @return {RenderTarget} The render target.
*/
createRenderTarget( width, height, options ) {
return new RenderTarget( width, height, options );
}
/**
* Factory method for creating an instance of {@link CubeRenderTarget} with the given
* dimensions and options.
*
* @param {number} size - The size of the cube render target.
* @param {Object} options - The options of the cube render target.
* @return {CubeRenderTarget} The cube render target.
*/
createCubeRenderTarget( size, options ) {
return new CubeRenderTarget( size, options );
}
/**
* Whether the given node is included in the internal array of nodes or not.
*
* @param {Node} node - The node to test.
* @return {boolean} Whether the given node is included in the internal array of nodes or not.
*/
includes( node ) {
return this.nodes.includes( node );
}
/**
* Returns the output struct name which is required by
* {@link OutputStructNode}.
*
* @abstract
* @return {string} The name of the output struct.
*/
getOutputStructName() {}
/**
* Returns a bind group for the given group name and binding.
*
* @private
* @param {string} groupName - The group name.
* @param {Array<NodeUniformsGroup>} bindings - List of bindings.
* @return {BindGroup} The bind group
*/
_getBindGroup( groupName, bindings ) {
const bindGroupsCache = this.getBindGroupsCache();
//
const bindingsArray = [];
let sharedGroup = true;
for ( const binding of bindings ) {
bindingsArray.push( binding );
sharedGroup = sharedGroup && binding.groupNode.shared !== true;
}
//
let bindGroup;
if ( sharedGroup ) {
bindGroup = bindGroupsCache.get( bindingsArray );
if ( bindGroup === undefined ) {
bindGroup = new BindGroup( groupName, bindingsArray, this.bindingsIndexes[ groupName ].group, bindingsArray );
bindGroupsCache.set( bindingsArray, bindGroup );
}
} else {
bindGroup = new BindGroup( groupName, bindingsArray, this.bindingsIndexes[ groupName ].group, bindingsArray );
}
return bindGroup;
}
/**
* Returns an array of node uniform groups for the given group name and shader stage.
*
* @param {string} groupName - The group name.
* @param {('vertex'|'fragment'|'compute'|'any')} shaderStage - The shader stage.
* @return {Array<NodeUniformsGroup>} The array of node uniform groups.
*/
getBindGroupArray( groupName, shaderStage ) {
const bindings = this.bindings[ shaderStage ];
let bindGroup = bindings[ groupName ];
if ( bindGroup === undefined ) {
if ( this.bindingsIndexes[ groupName ] === undefined ) {
this.bindingsIndexes[ groupName ] = { binding: 0, group: Object.keys( this.bindingsIndexes ).length };
}
bindings[ groupName ] = bindGroup = [];
}
return bindGroup;
}
/**
* Returns a list bindings of all shader stages separated by groups.
*
* @return {Array<BindGroup>} The list of bindings.
*/
getBindings() {
let bindingsGroups = this.bindGroups;
if ( bindingsGroups === null ) {
const groups = {};
const bindings = this.bindings;
for ( const shaderStage of shaderStages ) {
for ( const groupName in bindings[ shaderStage ] ) {
const uniforms = bindings[ shaderStage ][ groupName ];
const groupUniforms = groups[ groupName ] || ( groups[ groupName ] = [] );
groupUniforms.push( ...uniforms );
}
}
bindingsGroups = [];
for ( const groupName in groups ) {
const group = groups[ groupName ];
const bindingsGroup = this._getBindGroup( groupName, group );
bindingsGroups.push( bindingsGroup );
}
this.bindGroups = bindingsGroups;
}
return bindingsGroups;
}
/**
* Sorts the bind groups and updates {@link NodeBuilder#bindingsIndexes}.
*/
sortBindingGroups() {
const bindingsGroups = this.getBindings();
bindingsGroups.sort( ( a, b ) => ( a.bindings[ 0 ].groupNode.order - b.bindings[ 0 ].groupNode.order ) );
for ( let i = 0; i < bindingsGroups.length; i ++ ) {
const bindingGroup = bindingsGroups[ i ];
this.bindingsIndexes[ bindingGroup.name ].group = i;
bindingGroup.index = i;
}
}
/**
* The builder maintains each node in a hash-based dictionary.
* This method sets the given node (value) with the given hash (key) into this dictionary.
*
* @param {Node} node - The node to add.
* @param {number} hash - The hash of the node.
*/
setHashNode( node, hash ) {
this.hashNodes[ hash ] = node;
}
/**
* Adds a node to this builder.
*
* @param {Node} node - The node to add.
*/
addNode( node ) {
if ( this.nodes.includes( node ) === false ) {
this.nodes.push( node );
this.setHashNode( node, node.getHash( this ) );
}
}
/**
* It is used to add Nodes that will be used as FRAME and RENDER events,
* and need to follow a certain sequence in the calls to work correctly.
* This function should be called after 'setup()' in the 'build()' process to ensure that the child nodes are processed first.
*
* @param {Node} node - The node to add.
*/
addSequentialNode( node ) {
if ( this.sequentialNodes.includes( node ) === false ) {
this.sequentialNodes.push( node );
}
}
/**
* Checks the update types of nodes
*/
buildUpdateNodes() {
for ( const node of this.nodes ) {
const updateType = node.getUpdateType();
if ( updateType !== NodeUpdateType.NONE ) {
this.updateNodes.push( node.getSelf() );
}
}
for ( const node of this.sequentialNodes ) {
const updateBeforeType = node.getUpdateBeforeType();
const updateAfterType = node.getUpdateAfterType();
if ( updateBeforeType !== NodeUpdateType.NONE ) {
this.updateBeforeNodes.push( node.getSelf() );
}
if ( updateAfterType !== NodeUpdateType.NONE ) {
this.updateAfterNodes.push( node.getSelf() );
}
}
}
/**
* A reference the current node which is the
* last node in the chain of nodes.
*
* @type {Node}
*/
get currentNode() {
return this.chaining[ this.chaining.length - 1 ];
}
/**
* Whether the given texture is filtered or not.
*
* @param {Texture} texture - The texture to check.
* @return {boolean} Whether the given texture is filtered or not.
*/
isFilteredTexture( texture ) {
return ( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
texture.minFilter === LinearFilter || texture.minFilter === LinearMipmapNearestFilter || texture.minFilter === NearestMipmapLinearFilter || texture.minFilter === LinearMipmapLinearFilter );
}
/**
* Adds the given node to the internal node chain.
* This is used to check recursive calls in node-graph.
*
* @param {Node} node - The node to add.
*/
addChain( node ) {
/*
if ( this.chaining.indexOf( node ) !== - 1 ) {
console.warn( 'Recursive node: ', node );
}
*/
this.chaining.push( node );
}
/**
* Removes the given node from the internal node chain.
*
* @param {Node} node - The node to remove.
*/
removeChain( node ) {
const lastChain = this.chaining.pop();
if ( lastChain !== node ) {
throw new Error( 'NodeBuilder: Invalid node chaining!' );
}
}
/**
* Returns the native shader method name for a given generic name. E.g.
* the method name `textureDimensions` matches the WGSL name but must be
* resolved to `textureSize` in GLSL.
*
* @abstract
* @param {string} method - The method name to resolve.
* @return {string} The resolved method name.
*/
getMethod( method ) {
return method;
}
/**
* Returns a node for the given hash, see {@link NodeBuilder#setHashNode}.
*
* @param {number} hash - The hash of the node.
* @return {Node} The found node.
*/
getNodeFromHash( hash ) {
return this.hashNodes[ hash ];
}
/**
* Adds the Node to a target flow so that it can generate code in the 'generate' process.
*
* @param {('vertex'|'fragment'|'compute')} shaderStage - The shader stage.
* @param {Node} node - The node to add.
* @return {Node} The node.
*/
addFlow( shaderStage, node ) {
this.flowNodes[ shaderStage ].push( node );
return node;
}
/**
* Sets builder's context.
*
* @param {Object} context - The context to set.
*/
setContext( context ) {
this.context = context;
}
/**
* Returns the builder's current context.
*
* @return {Object} The builder's current context.
*/
getContext() {
return this.context;
}
/**
* Gets a context used in shader construction that can be shared across different materials.
* This is necessary since the renderer cache can reuse shaders generated in one material and use them in another.
*
* @return {Object} The builder's current context without material.
*/
getSharedContext() {
const context = { ...this.context };
delete context.material;
return this.context;
}
/**
* Sets builder's cache.
*
* @param {NodeCache} cache - The cache to set.
*/
setCache( cache ) {
this.cache = cache;
}
/**
* Returns the builder's current cache.
*
* @return {NodeCache} The builder's current cache.
*/
getCache() {
return this.cache;
}
/**
* Returns a cache for the given node.
*
* @param {Node} node - The node.
* @param {boolean} [parent=true] - Whether this node refers to a shared parent cache or not.
* @return {NodeCache} The cache.
*/
getCacheFromNode( node, parent = true ) {
const data = this.getDataFromNode( node );
if ( data.cache === undefined ) data.cache = new NodeCache( parent ? this.getCache() : null );
return data.cache;
}
/**
* Whether the requested feature is available or not.
*
* @abstract
* @param {string} name - The requested feature.
* @return {boolean} Whether the requested feature is supported or not.
*/
isAvailable( /*name*/ ) {
return false;
}
/**
* Returns the vertexIndex input variable as a native shader string.
*
* @abstract
* @return {string} The instanceIndex shader string.
*/
getVertexIndex() {
console.warn( 'Abstract function.' );
}
/**
* Returns the instanceIndex input variable as a native shader string.
*
* @abstract
* @return {string} The instanceIndex shader string.
*/
getInstanceIndex() {
console.warn( 'Abstract function.' );
}
/**
* Returns the drawIndex input variable as a native shader string.
* Only relevant for WebGL and its `WEBGL_multi_draw` extension.
*
* @abstract
* @return {?string} The drawIndex shader string.
*/
getDrawIndex() {
console.warn( 'Abstract function.' );
}
/**
* Returns the frontFacing input variable as a native shader string.
*
* @abstract
* @return {string} The frontFacing shader string.
*/
getFrontFacing() {
console.warn( 'Abstract function.' );
}
/**
* Returns the fragCoord input variable as a native shader string.
*
* @abstract
* @return {string} The fragCoord shader string.
*/
getFragCoord() {
console.warn( 'Abstract function.' );
}
/**
* Whether to flip texture data along its vertical axis or not. WebGL needs
* this method evaluate to `true`, WebGPU to `false`.
*
* @abstract
* @return {boolean} Whether to flip texture data along its vertical axis or not.
*/
isFlipY() {
return false;
}
/**
* Calling this method increases the usage count for the given node by one.
*
* @param {Node} node - The node to increase the usage count for.
* @return {number} The updated usage count.
*/
increaseUsage( node ) {
const nodeData = this.getDataFromNode( node );
nodeData.usageCount = nodeData.usageCount === undefined ? 1 : nodeData.usageCount + 1;
return nodeData.usageCount;