Skip to content

Commit

Permalink
BatchedMesh: Cleanup (mrdoob#27201)
Browse files Browse the repository at this point in the history
* visible -> visibility

* Remove comment
  • Loading branch information
gkjohnson authored and AdaRoseCannon committed Jan 15, 2024
1 parent e8931df commit feeb057
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/core/Object3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ class Object3D extends EventDispatcher {
object.drawRanges = this._drawRanges;
object.reservedRanges = this._reservedRanges;

object.visible = this._visible;
object.visibility = this._visibility;
object.active = this._active;
object.bounds = this._bounds.map( bound => ( {
boxInitialized: bound.boxInitialized,
Expand Down
2 changes: 1 addition & 1 deletion src/loaders/ObjectLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ class ObjectLoader extends Loader {
object._drawRanges = data.drawRanges;
object._reservedRanges = data.reservedRanges;

object._visible = data.visible;
object._visibility = data.visibility;
object._active = data.active;
object._bounds = data.bounds.map( bound => {

Expand Down
33 changes: 16 additions & 17 deletions src/objects/BatchedMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ const _mesh = new Mesh();
const _batchIntersects = [];

// @TODO: SkinnedMesh support?
// @TODO: Future work if needed. Move into the core. Can be optimized more with WEBGL_multi_draw.
// @TODO: geometry.groups support?
// @TODO: geometry.drawRange support?
// @TODO: geometry.morphAttributes support?
Expand Down Expand Up @@ -135,7 +134,7 @@ class BatchedMesh extends Mesh {
this._drawRanges = [];
this._reservedRanges = [];

this._visible = [];
this._visibility = [];
this._active = [];
this._bounds = [];

Expand Down Expand Up @@ -438,13 +437,13 @@ class BatchedMesh extends Mesh {

}

const visible = this._visible;
const visibility = this._visibility;
const active = this._active;
const matricesTexture = this._matricesTexture;
const matricesArray = this._matricesTexture.image.data;

// push new visibility states
visible.push( true );
visibility.push( true );
active.push( true );

// update id
Expand Down Expand Up @@ -749,7 +748,7 @@ class BatchedMesh extends Mesh {

setVisibleAt( geometryId, value ) {

const visible = this._visible;
const visibility = this._visibility;
const active = this._active;
const geometryCount = this._geometryCount;

Expand All @@ -758,21 +757,21 @@ class BatchedMesh extends Mesh {
if (
geometryId >= geometryCount ||
active[ geometryId ] === false ||
visible[ geometryId ] === value
visibility[ geometryId ] === value
) {

return this;

}

visible[ geometryId ] = value;
visibility[ geometryId ] = value;
return this;

}

getVisibleAt( geometryId ) {

const visible = this._visible;
const visibility = this._visibility;
const active = this._active;
const geometryCount = this._geometryCount;

Expand All @@ -783,13 +782,13 @@ class BatchedMesh extends Mesh {

}

return visible[ geometryId ];
return visibility[ geometryId ];

}

raycast( raycaster, intersects ) {

const visible = this._visible;
const visibility = this._visibility;
const active = this._active;
const drawRanges = this._drawRanges;
const geometryCount = this._geometryCount;
Expand All @@ -814,7 +813,7 @@ class BatchedMesh extends Mesh {

for ( let i = 0; i < geometryCount; i ++ ) {

if ( ! visible[ i ] || ! active[ i ] ) {
if ( ! visibility[ i ] || ! active[ i ] ) {

continue;

Expand Down Expand Up @@ -863,7 +862,7 @@ class BatchedMesh extends Mesh {
this._drawRanges = source._drawRanges.map( range => ( { ...range } ) );
this._reservedRanges = source._reservedRanges.map( range => ( { ...range } ) );

this._visible = source._visible.slice();
this._visibility = source._visibility.slice();
this._active = source._active.slice();
this._bounds = source._bounds.map( bound => ( {
boxInitialized: bound.boxInitialized,
Expand Down Expand Up @@ -907,7 +906,7 @@ class BatchedMesh extends Mesh {
const index = geometry.getIndex();
const bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;

const visible = this._visible;
const visibility = this._visibility;
const multiDrawStarts = this._multiDrawStarts;
const multiDrawCounts = this._multiDrawCounts;
const drawRanges = this._drawRanges;
Expand All @@ -933,9 +932,9 @@ class BatchedMesh extends Mesh {
// get the camera position
_vector.setFromMatrixPosition( camera.matrixWorld );

for ( let i = 0, l = visible.length; i < l; i ++ ) {
for ( let i = 0, l = visibility.length; i < l; i ++ ) {

if ( visible[ i ] ) {
if ( visibility[ i ] ) {

this.getMatrixAt( i, _matrix );
this.getBoundingSphereAt( i, _sphere ).applyMatrix4( _matrix );
Expand Down Expand Up @@ -982,9 +981,9 @@ class BatchedMesh extends Mesh {

} else {

for ( let i = 0, l = visible.length; i < l; i ++ ) {
for ( let i = 0, l = visibility.length; i < l; i ++ ) {

if ( visible[ i ] ) {
if ( visibility[ i ] ) {

// determine whether the batched geometry is within the frustum
let culled = false;
Expand Down

0 comments on commit feeb057

Please sign in to comment.