Skip to content
Open
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
15 changes: 13 additions & 2 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ async function loadPly(content) {
const match = header.match(regex)
gaussianCount = parseInt(match[1])

// Get degree of SH
const regexSH = /(f_rest_\d+)\nproperty float opacity/
const matchSH = header.match(regexSH)
let shCount;
if (matchSH !== null) {
shCount = parseInt(matchSH[1].split('f_rest_')[1]) + 1;
} else {
shCount = 0;
}

document.querySelector('#loading-text').textContent = `Success. Initializing ${gaussianCount} gaussians...`

// Create arrays for gaussian properties
Expand All @@ -29,7 +39,8 @@ async function loadPly(content) {

// Helpers
const sigmoid = (m1) => 1 / (1 + Math.exp(-m1))
const NUM_PROPS = 62
// xyz + nxnynz + f_dc_012 + f_rest_n + opacity + scale_xyz + rot_0123
const NUM_PROPS = 9 + shCount + 8

// Create a dataview to access the buffer's content on a byte levele
const view = new DataView(content)
Expand All @@ -50,7 +61,7 @@ async function loadPly(content) {
// const n = fromDataView(splatID, 3, 6) // Not used
const harmonic = fromDataView(splatID, 6, 9)

const H_END = 6 + 48 // Offset of the last harmonic coefficient
const H_END = 9 + shCount // Offset of the last harmonic coefficient
const opacity = fromDataView(splatID, H_END)
const scale = fromDataView(splatID, H_END + 1, H_END + 4)
const rotation = fromDataView(splatID, H_END + 4, H_END + 8)
Expand Down