Skip to content

Commit

Permalink
fix(PolyDataOutput and MeshOutput): check SharedArrayBuffer
Browse files Browse the repository at this point in the history
check SharedArrayBuffer in PolyDataOutput and MeshOutput transferables
  • Loading branch information
pritamrungta committed May 17, 2023
1 parent d34c4b9 commit 40f5736
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 11 deletions.
21 changes: 17 additions & 4 deletions src/core/internal/meshTransferables.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
import Mesh from '../Mesh.js'
import getTransferable from '../getTransferable.js'

function meshTransferables (mesh: Mesh): ArrayBuffer[] {
const transferables: ArrayBuffer[] = []
if (mesh.points != null) {
transferables.push(mesh.points.buffer)
let transferable = getTransferable(mesh.points)
if (transferable != null) {
transferables.push(transferable)
}
}
if (mesh.pointData != null) {
transferables.push(mesh.pointData.buffer)
let transferable = getTransferable(mesh.pointData)
if (transferable != null) {
transferables.push(transferable)
}
}
if (mesh.cells != null) {
transferables.push(mesh.cells.buffer)
let transferable = getTransferable(mesh.cells)
if (transferable != null) {
transferables.push(transferable)
}
}
if (mesh.cellData != null) {
transferables.push(mesh.cellData.buffer)
let transferable = getTransferable(mesh.cellData)
if (transferable != null) {
transferables.push(transferable)
}
}

return transferables
Expand Down
36 changes: 29 additions & 7 deletions src/core/internal/polyDataTransferables.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,49 @@
import PolyData from '../PolyData.js'
import getTransferable from '../getTransferable.js'

function polyDataTransferables (polyData: PolyData): ArrayBuffer[] {
const transferables: ArrayBuffer[] = []
if (polyData.points != null) {
transferables.push(polyData.points.buffer)
let transferable = getTransferable(polyData.points)
if (transferable != null) {
transferables.push(transferable)
}
}
if (polyData.vertices != null) {
transferables.push(polyData.vertices.buffer)
let transferable = getTransferable(polyData.vertices)
if (transferable != null) {
transferables.push(transferable)
}
}
if (polyData.lines != null) {
transferables.push(polyData.lines.buffer)
let transferable = getTransferable(polyData.lines)
if (transferable != null) {
transferables.push(transferable)
}
}
if (polyData.polygons != null) {
transferables.push(polyData.polygons.buffer)
let transferable = getTransferable(polyData.polygons)
if (transferable != null) {
transferables.push(transferable)
}
}
if (polyData.triangleStrips != null) {
transferables.push(polyData.triangleStrips.buffer)
let transferable = getTransferable(polyData.triangleStrips)
if (transferable != null) {
transferables.push(transferable)
}
}
if (polyData.pointData != null) {
transferables.push(polyData.pointData.buffer)
let transferable = getTransferable(polyData.pointData)
if (transferable != null) {
transferables.push(transferable)
}
}
if (polyData.cellData != null) {
transferables.push(polyData.cellData.buffer)
let transferable = getTransferable(polyData.cellData)
if (transferable != null) {
transferables.push(transferable)
}
}

return transferables
Expand Down

0 comments on commit 40f5736

Please sign in to comment.