Skip to content

Commit

Permalink
TSL: Improve range() size (#28745)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag authored Jun 25, 2024
1 parent 4d479c2 commit 6f40b10
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions examples/jsm/nodes/geometry/RangeNode.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Node, { addNodeClass } from '../core/Node.js';
import { getValueType } from '../core/NodeUtils.js';
import { buffer } from '../accessors/BufferNode.js';
//import { bufferAttribute } from '../accessors/BufferAttributeNode.js';
import { instancedBufferAttribute } from '../accessors/BufferAttributeNode.js';
import { instanceIndex } from '../core/IndexNode.js';
import { nodeProxy, float } from '../shadernode/ShaderNode.js';

import { Vector4, MathUtils } from 'three';
import { Vector4, MathUtils, InstancedBufferAttribute } from 'three';

let min = null;
let max = null;
Expand Down Expand Up @@ -82,8 +82,19 @@ class RangeNode extends Node {

const nodeType = this.getNodeType( builder );

output = buffer( array, 'vec4', object.count ).element( instanceIndex ).convert( nodeType );
//output = bufferAttribute( array, 'vec4', 4, 0 ).convert( nodeType );
if ( object.count <= 4096 ) {

output = buffer( array, 'vec4', object.count ).element( instanceIndex ).convert( nodeType );

} else {

// TODO: Improve anonymous buffer attribute creation removing this part
const bufferAttribute = new InstancedBufferAttribute( array, 4 );
builder.geometry.setAttribute( '__range' + this.id, bufferAttribute );

output = instancedBufferAttribute( bufferAttribute ).convert( nodeType );

}

} else {

Expand Down

0 comments on commit 6f40b10

Please sign in to comment.