Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support red skybox #40

Closed
wants to merge 4 commits into from
Closed
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
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();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this asset comes from the websocket, we should pass the websocket loading manager here as well. Check for other cases where it was used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that I'll add all skyboxes to fuel. I'd that okay?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that I'll add all skyboxes to fuel. I'd that okay?

It looks like this was already done, correct? That is, if I use this branch and add in a cubemap_uri to my SDF, I get a red sky as desired. So I think that means everything was properly downloaded from fuel. Do I have that right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that sounds right

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/Cole/models/skyboxgrey/tip/files/materials/textures/skybox-negx.jpg',
'https://fuel.gazebosim.org/1.0/Cole/models/skyboxgrey/tip/files/materials/textures/skybox-posx.jpg',
'https://fuel.gazebosim.org/1.0/Cole/models/skyboxgrey/tip/files/materials/textures/skybox-posy.jpg',
'https://fuel.gazebosim.org/1.0/Cole/models/skyboxgrey/tip/files/materials/textures/skybox-negy.jpg',
'https://fuel.gazebosim.org/1.0/Cole/models/skyboxgrey/tip/files/materials/textures/skybox-negz.jpg',
'https://fuel.gazebosim.org/1.0/Cole/models/skyboxgrey/tip/files/materials/textures/skybox-posz.jpg',
]);
} else {
this.scene.background = cubeLoader.load([
'https://fuel.gazebosim.org/1.0/Cole/models/skyboxred/tip/files/materials/textures/skybox-red-negx.jpg',
'https://fuel.gazebosim.org/1.0/Cole/models/skyboxred/tip/files/materials/textures/skybox-red-posx.jpg',
'https://fuel.gazebosim.org/1.0/Cole/models/skyboxred/tip/files/materials/textures/skybox-red-posy.jpg',
'https://fuel.gazebosim.org/1.0/Cole/models/skyboxred/tip/files/materials/textures/skybox-red-negy.jpg',
'https://fuel.gazebosim.org/1.0/Cole/models/skyboxred/tip/files/materials/textures/skybox-red-negz.jpg',
'https://fuel.gazebosim.org/1.0/Cole/models/skyboxred/tip/files/materials/textures/skybox-red-posz.jpg',
]);
}
}

public initScene(): void {
Expand Down
19 changes: 18 additions & 1 deletion src/SceneManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,25 @@ 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 ('header' in sky && sky['header'] !== null && sky['header'] !== undefined &&
'data' in sky['header'] && sky['header']['data'] !== null && 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'] !== null && data[i]['value'] !== undefined) {
this.scene.addSky(data[i]['value'][0]);
break;
}
}
} else {
this.scene.addSky();
}
}

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

Expand Down