Skip to content

Commit

Permalink
Fixed a viewer issue related to having meshes with no vertex data and…
Browse files Browse the repository at this point in the history
… IBO shufling. We're now ignoring any render view which lacks vertex data and we're also displaying a warning when such objects are converted (specklesystems#1369)
  • Loading branch information
AlexandruPopovici authored Feb 14, 2023
1 parent a6fba9e commit 234c403
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/viewer-sandbox/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,7 @@ await sandbox.loadUrl(
// 'https://latest.speckle.dev/streams/92b620fb17/commits/b4366a7086?filter=%7B%7D&c=%5B-31.02357,37.60008,96.58899,11.01564,7.40652,66.0411,0,1%5D)'
// double
// 'https://latest.speckle.dev/streams/92b620fb17/commits/b4366a7086?overlay=c009dbe144&filter=%7B%7D&c=%5B-104.70053,-98.80617,67.44669,6.53096,1.8739,38.584,0,1%5D'
'https://latest.speckle.dev/streams/efd2c6a31d/commits/4b495e1901'
// 'https://latest.speckle.dev/streams/efd2c6a31d/commits/4b495e1901'
// tekla 2
'https://speckle.xyz/streams/be4813ccd2/commits/da85000921?c=%5B-1.12295,-2.60901,6.12402,4.77979,0.555,3.63346,0,1%5D'
)
6 changes: 4 additions & 2 deletions packages/viewer/src/modules/batching/Batcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from './Batch'
import PointBatch from './PointBatch'
// import { FilterMaterialType } from '../FilteringManager'
import { Material, Mesh, WebGLRenderer } from 'three'
import { Material, Mesh, Vector3, WebGLRenderer } from 'three'
import { FilterMaterial, FilterMaterialType } from '../filtering/FilteringManager'
import Logger from 'js-logger'

Expand Down Expand Up @@ -47,9 +47,11 @@ export default class Batcher {
// console.warn(rendeViews)

for (let i = 0; i < materialHashes.length; i++) {
const batch = rendeViews.filter(
let batch = rendeViews.filter(
(value) => value.renderMaterialHash === materialHashes[i]
)
/** Prune any meshes with no geometry data */
batch = batch.filter((value) => value.aabb.getSize(new Vector3()).lengthSq() > 0)

let matRef = null

Expand Down
15 changes: 12 additions & 3 deletions packages/viewer/src/modules/converter/Converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,18 @@ export default class Coverter {

private async MeshToNode(obj, node) {
if (!obj) return

if (!obj.vertices) return
if (!obj.faces) return
if (!obj.vertices || obj.vertices.length === 0) {
Logger.warn(
`Object id ${obj.id} of type ${obj.speckle_tpe} has no vertex position data and will be ignored`
)
return
}
if (!obj.faces || obj.faces.length === 0) {
Logger.warn(
`Object id ${obj.id} of type ${obj.speckle_tpe} has no face data and will be ignored`
)
return
}

node.model.raw.vertices = await this.dechunk(obj.vertices)
node.model.raw.faces = await this.dechunk(obj.faces)
Expand Down

0 comments on commit 234c403

Please sign in to comment.