Skip to content
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
6 changes: 5 additions & 1 deletion src/loading2/gltf-splats-decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ export class GltfSplatDecoder implements GeometryDecoder {
const fetchBuffer = async (url: string, offsetMultiplier: bigint): Promise<ArrayBuffer> => {
const firstByte = byteOffset * 4n * offsetMultiplier;
const lastByte = firstByte + byteSize * 4n * offsetMultiplier - 1n;
const headers: Record<string, string> = { Range: `bytes=${firstByte}-${lastByte}` };
const headers: any = {
Range: `bytes=${firstByte}-${lastByte}`,
'Transfer-Encoding': 'compress',
'Accept-Encoding': 'compress',
};
const response = await this.xhrRequest(url, { headers });
return response.arrayBuffer();
};
Expand Down
3 changes: 2 additions & 1 deletion src/loading2/gltf-splats-decoder.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ onmessage = function (event) {
// opacity
let a = view.getFloat32(opacityOffset, true);
a = (1 / (1 + Math.exp(-a))) * 255;
colors[c3] = clamp(Math.floor(a), 0, 255);
a = clamp(Math.floor(a), 0, 255);
colors[c3] = a;
}
} else if (['scale'].includes(pointAttribute.name)) {
let maxScale = 0;
Expand Down
8 changes: 6 additions & 2 deletions src/materials/shaders/splats.vert
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ precision highp int;
uniform vec2 focal;
uniform float inverseFocalAdjustment;
uniform float splatScale;
uniform float initialSplatScale;
uniform vec2 basisViewport;
uniform float harmonicsDegree;
uniform bool renderIds;
Expand Down Expand Up @@ -277,7 +278,8 @@ void main() {

if(adaptiveSize) {
float lodSplatScale = clamp(getLOD( nodePosition, int(vnStart), float(level) ) / maxDepth, 0., 1.);
renderScale = mix(maxSplatScale * splatScale, 1., lodSplatScale);
float currentSplatScale = lodSplatScale < 2. ? initialSplatScale : splatScale;
renderScale = mix(maxSplatScale * currentSplatScale, 1., lodSplatScale);
}

vRenderScale = renderScale;
Expand All @@ -302,7 +304,9 @@ void main() {

vColor = colorData.rgb;

vec3 worldViewDir = normalize(-viewCenter.rgb);
vec4 worldCenter = modelMatrix * vec4(instancePosition, 1.0);

vec3 worldViewDir = normalize(worldCenter.xyz - cameraPosition);

//Harmonics
vec3 harmonics = vec3(0.);
Expand Down
1 change: 1 addition & 0 deletions src/splats-mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export class SplatsMesh extends Object3D {
focal: { value: new Vector2(0, 0) },
inverseFocalAdjustment: { value: 1 },
splatScale: { value: 1 },
initialSplatScale: { value: 1 },
basisViewport: { value: new Vector2(0, 0) },
globalOffset: { value: new Vector3(0, 0, 0) },
sortedTexture: { value: null },
Expand Down