Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BatchedMesh: Add getGeometryRangeAt #29409

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -868,6 +868,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