Skip to content

Commit

Permalink
Support red skybox
Browse files Browse the repository at this point in the history
Signed-off-by: Nate Koenig <[email protected]>
  • Loading branch information
Nate Koenig committed Sep 29, 2022
1 parent 35782ce commit d96a6da
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
31 changes: 20 additions & 11 deletions src/Scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,18 +682,27 @@ export class Scene {
this.COMvisual.add(mesh);
}

public addSky(): void {
public addSky(cubemap: string | undefined): void {
var cubeLoader = new THREE.CubeTextureLoader();
var cubeTexture = cubeLoader.load([
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-negx.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-posx.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-posy.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-negy.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-negz.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-posz.jpg',
]);

this.scene.background = cubeTexture;
if (cubemap === undefined) {
this.scene.background = cubeLoader.load([
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-negx.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-posx.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-posy.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-negy.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-negz.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-posz.jpg',
]);
} else {
this.scene.background = cubeLoader.load([
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-red-negx.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-red-posx.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-red-posy.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-red-negy.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-red-negz.jpg',
'https://fuel.gazebosim.org/1.0/openrobotics/models/skybox/tip/files/materials/textures/skybox-red-posz.jpg',
]);
}
}

public initScene(): void {
Expand Down
18 changes: 17 additions & 1 deletion src/SceneManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,24 @@ export class SceneManager {
}

if ('sky' in sceneInfo && sceneInfo['sky']) {
this.scene.addSky();

const sky = sceneInfo['sky'];

// Check to see if a cubemap has been specified in the header.
if (sky['header'] !== undefined &&
sky['header']['data'] !== undefined) {
const data = sky['header']['data'];
for (let i = 0; i < data.length; ++i) {
if (data[i]['key'] === 'cubemap_uri' &&
data[i]['value'] !== undefined) {
this.scene.addSky(data[i]['value'][0]);
}
}
} else {
this.scene.addSky();
}
}

this.sceneInfo = sceneInfo;
this.startVisualization();

Expand Down

0 comments on commit d96a6da

Please sign in to comment.