Skip to content

Commit

Permalink
Include RTC origin in WebGLRendererModel layer
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Mar 13, 2024
1 parent b13a701 commit c638f08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/webglrenderer/src/LayerParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export interface LayerParams { // Params for RendererLayer constructor
primitive: number;
layerIndex: number;
textureSet?: RendererTextureSet;
origin?:FloatArrayParam;
origin:FloatArrayParam;
}
19 changes: 11 additions & 8 deletions packages/webglrenderer/src/WebGLRendererModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export class WebGLRendererModel extends Component implements RendererModel {
if (!rendererTextureSet) {
throw new SDKError("SceneTextureSet not found");
}
const layer = this.#getLayer(textureSetId, mesh.geometry);
const layer = this.#getLayer(textureSetId, mesh);
if (!layer) {
return; // TODO
}
Expand Down Expand Up @@ -381,11 +381,13 @@ export class WebGLRendererModel extends Component implements RendererModel {
this.#numMeshes++;
}

#getLayer(textureSetId: string, geometryCompressedParams: SceneGeometryCompressedParams): Layer | undefined {
const layerId = `${textureSetId}_${geometryCompressedParams.primitive}`;
#getLayer(textureSetId: string, mesh: SceneMesh): Layer | undefined {
const geometry = mesh.geometry;
const origin = mesh.origin;
const layerId = `${textureSetId}.${geometry.primitive}.${Math.round(origin[0])}.${Math.round(origin[1])}.${Math.round(origin[2])}`;
let layer = this.#currentLayers[layerId];
if (layer) {
if (layer.canCreateLayerMesh(geometryCompressedParams)) {
if (layer.canCreateLayerMesh(geometry)) {
return layer;
} else {
layer.build();
Expand All @@ -400,22 +402,23 @@ export class WebGLRendererModel extends Component implements RendererModel {
return;
}
}
switch (geometryCompressedParams.primitive) {
switch (geometry.primitive) {
case TrianglesPrimitive:
case SolidPrimitive:
case SurfacePrimitive:
layer = new TrianglesLayer(<LayerParams>{
gl: this.#renderContext.gl,
view: this.#view,
rendererModel: this,
primitive: geometryCompressedParams.primitive,
primitive: geometry.primitive,
textureSet,
layerIndex: 0
layerIndex: 0,
origin
});
this.log(`Creating new TrianglesLayer`);
break;
default:
this.error(`Primitive type not supported: ${geometryCompressedParams.primitive}`);
this.error(`Primitive type not supported: ${geometry.primitive}`);
return;
}
this.#layers[layerId] = layer;
Expand Down

0 comments on commit c638f08

Please sign in to comment.