Skip to content

Commit

Permalink
BatchedMesh: Add getGeometryRangeAt (#29409)
Browse files Browse the repository at this point in the history
* BatchedMesh: Add getGeometryRangeAt

Co-authored-by: Luigi Denora <luigidenora@users.noreply.github.com>

* Fix eslint error

Co-authored-by: Luigi Denora <luigidenora@users.noreply.github.com>

* Doc changed

* Add optional target

---------

Co-authored-by: Luigi Denora <luigidenora@users.noreply.github.com>
  • Loading branch information
agargaro and luigidenora authored Sep 24, 2024
1 parent 9df48f2 commit ab23d7b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
19 changes: 16 additions & 3 deletions docs/api/en/objects/BatchedMesh.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,29 @@ <h3>
<p>
[page:Integer instanceId]: The id of an instance to get the visibility state of.
</p>
<p>Get whether the given instance is marked as "visible" or not.</p>

<p>Get whether the given instance is marked as "visible" or not.</p>

<h3>
[method:Object getGeometryRangeAt]( [param:Integer geometryId], [param:Object target] )
</h3>
<p>
[page:Integer geometryId]: The id of the geometry to get the range of.
</p>
<p>
[page:Object target]: Optional target object to copy the range in to.
</p>
<p>Get the range representing the subset of triangles related to the attached geometry, indicating the starting offset and count, or `null` if invalid.</p>
<p>Return an object of the form:</p>
<code>{ start: Integer, count: Integer }</code>

<h3>
[method:Integer getGeometryIdAt]( [param:Integer instanceId] )
</h3>
<p>
[page:Integer instanceId]: The id of an instance to get the geometryIndex of.
</p>
<p>Get the geometryIndex of the defined instance.</p>

<h3>
[method:undefined setColorAt]( [param:Integer instanceId], [param:Color color] )
</h3>
Expand Down
17 changes: 17 additions & 0 deletions src/objects/BatchedMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,23 @@ class BatchedMesh extends Mesh {

}

getGeometryRangeAt( geometryId, target = {} ) {

if ( geometryId < 0 || geometryId >= this._geometryCount ) {

return null;

}

const drawRange = this._drawRanges[ geometryId ];

target.start = drawRange.start;
target.count = drawRange.count;

return target;

}

raycast( raycaster, intersects ) {

const drawInfo = this._drawInfo;
Expand Down

0 comments on commit ab23d7b

Please sign in to comment.