Skip to content

Commit

Permalink
fix(BatchedMesh): use zero-scale matrix for visibility (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett authored Oct 24, 2023
1 parent 89d7e63 commit 8a1b676
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/objects/BatchedMesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from 'three'

const _identityMatrix = new Matrix4()
const _zeroMatrix = new Matrix4().set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
const _zeroScaleMatrix = new Matrix4().set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1)

// Custom shaders
const batchingParsVertex = /* glsl */ `
Expand Down Expand Up @@ -302,7 +302,7 @@ class BatchedMesh extends Mesh<BufferGeometry, Material> {
}

this._alives[geometryId] = false
_zeroMatrix.toArray(this._matricesArray!, geometryId * 16)
_zeroScaleMatrix.toArray(this._matricesArray!, geometryId * 16)
this._matricesTexture!.needsUpdate = true

// User needs to call optimize() to pack the data.
Expand Down Expand Up @@ -354,7 +354,7 @@ class BatchedMesh extends Mesh<BufferGeometry, Material> {
if (visible === true) {
this._matrices[geometryId].toArray(this._matricesArray!, geometryId * 16)
} else {
_zeroMatrix.toArray(this._matricesArray!, geometryId * 16)
_zeroScaleMatrix.toArray(this._matricesArray!, geometryId * 16)
}

this._matricesTexture!.needsUpdate = true
Expand Down

0 comments on commit 8a1b676

Please sign in to comment.