Skip to content

Commit

Permalink
chore: fix data texture generation (??) and material onbeforerender
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonflatval-cognite committed Jul 17, 2024
1 parent 02d1d45 commit 9b92bbb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ export function makeOnBeforeRender(
node: IPointCloudTreeNode,
pcIndex: number
): (renderer: WebGLRenderer, scene: Scene, camera: Camera, bufferGeometry: BufferGeometry, material: Material) => void {
return (_renderer: WebGLRenderer, _scene: Scene, _camera: Camera, _geometry: BufferGeometry, material: Material) => {
return (renderer: WebGLRenderer, _scene: Scene, _camera: Camera, _geometry: BufferGeometry, material: Material) => {
const pointCloudMaterial = material as PointCloudMaterial;
pointCloudMaterial.onBeforeRender(renderer);
const materialUniforms = pointCloudMaterial.uniforms;

materialUniforms.level.value = node.level;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class PointCloudMaterial extends RawShaderMaterial {
glslVersion: GLSL3
});

const tex = (this.visibleNodesTexture = generateDataTexture(2048, 1, COLOR_WHITE));
const tex = (this.visibleNodesTexture = generateDataTexture(2048, 1, COLOR_WHITE, 0x0));
tex.minFilter = NearestFilter;
tex.magFilter = NearestFilter;
this.setUniform('visibleNodes', tex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class PointCloudObjectAppearanceTexture {
private _annotationIdsToObjectId: Map<number, number> | undefined;

constructor(width: number, height: number) {
this._objectStyleTexture = generateDataTexture(width, height, new THREE.Color(0x01000000)); // Initialize with visibility bit set
this._objectStyleTexture = generateDataTexture(width, height, new THREE.Color(0x0), 0x01); // Initialize with visibility bit set

this._width = width;
this._height = height;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from 'three';
import { PointClassification, IGradient } from './types';

export function generateDataTexture(width: number, height: number, color: Color): DataTexture {
export function generateDataTexture(width: number, height: number, color: Color, alpha: number): DataTexture {
const size = width * height;
const data = new Uint8Array(4 * size);

Expand All @@ -26,6 +26,7 @@ export function generateDataTexture(width: number, height: number, color: Color)
data[i * 4] = r;
data[i * 4 + 1] = g;
data[i * 4 + 2] = b;
data[i * 4 + 3] = alpha;
}

const texture = new DataTexture(data, width, height, RGBAFormat);
Expand Down

0 comments on commit 9b92bbb

Please sign in to comment.