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

#2182 Undead patch-1 #2188

Merged
merged 1 commit into from
Apr 3, 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
3 changes: 1 addition & 2 deletions packages/viewer/src/modules/batching/DrawRanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export class DrawRanges {

const materialIndex = materials.indexOf(range.material)
edgesForward[r0] = materialIndex
edgesForward[r1] =
edgesForward[next] !== undefined ? edgesForward[next] : edgesBackwards[next]
edgesForward[r1] = r1 >= next ? edgesForward[next] : edgesBackwards[next]
}

const drawRanges = []
Expand Down
50 changes: 50 additions & 0 deletions packages/viewer/test/__snapshots__/draw-ranges.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,56 @@ exports[`Draw Ranges > Mixed Ranges 1`] = `
]
`;

exports[`Draw Ranges > Mixed Ranges 2 1`] = `
[
{
"count": 6,
"materialIndex": 0,
"start": 0,
},
{
"count": 36,
"materialIndex": 2,
"start": 6,
},
{
"count": 486,
"materialIndex": 0,
"start": 42,
},
{
"count": 3261,
"materialIndex": 1,
"start": 528,
},
]
`;

exports[`Draw Ranges > Mixed Ranges 3 1`] = `
[
{
"count": 528,
"materialIndex": 0,
"start": 0,
},
{
"count": 2,
"materialIndex": 1,
"start": 528,
},
{
"count": 36,
"materialIndex": 2,
"start": 530,
},
{
"count": 3223,
"materialIndex": 1,
"start": 566,
},
]
`;

exports[`Draw Ranges > Multiple Materials 1`] = `
[
{
Expand Down
50 changes: 49 additions & 1 deletion packages/viewer/test/draw-ranges.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DrawGroup } from '../src/modules/batching/Batch'

const material0 = new SpeckleBasicMaterial({ color: 0xff0000 })
const material1 = new SpeckleBasicMaterial({ color: 0x00ff00 })
const material2 = new SpeckleBasicMaterial({ color: 0x0000ff })

describe('Draw Ranges', () => {
it('Boundary Ranges', () => {
Expand Down Expand Up @@ -109,8 +110,55 @@ describe('Draw Ranges', () => {
expect(groups).toMatchSnapshot()
})

it('Mixed Ranges 2', () => {
let groups = [
{
start: 0,
count: 528,
materialIndex: 0
} as DrawGroup,
{
start: 528,
count: 3261,
materialIndex: 1
} as DrawGroup
]

const drawRange = new DrawRanges()

groups = drawRange.integrateRanges(
groups,
[material0, material1, material2],
[{ offset: 6, count: 36, material: material2 }]
)
expect(groups).toMatchSnapshot()
})

it('Mixed Ranges 3', () => {
let groups = [
{
start: 0,
count: 528,
materialIndex: 0
} as DrawGroup,
{
start: 528,
count: 3261,
materialIndex: 1
} as DrawGroup
]

const drawRange = new DrawRanges()

groups = drawRange.integrateRanges(
groups,
[material0, material1, material2],
[{ offset: 530, count: 36, material: material2 }]
)
expect(groups).toMatchSnapshot()
})

it('Multiple Materials', () => {
const material2 = new SpeckleBasicMaterial({ color: 0x0000ff })
const material3 = new SpeckleBasicMaterial({ color: 0x0000ff })
const material4 = new SpeckleBasicMaterial({ color: 0x0000ff })

Expand Down