From 30c4cd002563c7ff100b67128eb8879b29c6c191 Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Wed, 4 Oct 2023 21:55:46 -0300 Subject: [PATCH 1/2] add environment option color --- src/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 87aae1a02..d9fdf39e5 100644 --- a/src/index.js +++ b/src/index.js @@ -374,7 +374,8 @@ AFRAME.registerComponent('intersection', { AFRAME.registerComponent('street-environment', { schema: { - preset: { type: 'string', default: 'day', oneOf: ['day', 'night'] } + preset: { type: 'string', default: 'day', oneOf: ['day', 'night', 'color'] }, + backgroundColor: { type: 'color', default: '#FFF' } }, setEnvOption: function () { const sky = this.sky; @@ -384,21 +385,26 @@ AFRAME.registerComponent('street-environment', { if (this.data.preset === 'night') { light1.setAttribute('light', 'intensity', 0.5); light2.setAttribute('light', 'intensity', 0.15); + sky.setAttribute('visible', true); sky.setAttribute('color', '#444'); sky.setAttribute('src', '#sky-night'); sky.setAttribute('rotation', '0 0 0'); - } else { // day + } else if (this.data.preset === 'day') { // TODO: create a parent with children light1.setAttribute('light', 'intensity', 2); light2.setAttribute('light', 'intensity', 0.6); + sky.setAttribute('visible', true); sky.setAttribute('color', '#FFF'); sky.setAttribute('src', '#sky'); sky.setAttribute('rotation', '0 255 0'); + } else { // color + sky.setAttribute('visible', false); + this.scene.setAttribute('background', 'color', this.data.backgroundColor); } }, init: function () { const el = this.el; - + this.scene = document.querySelector('a-scene'); this.light1 = document.createElement('a-entity'); const light1 = this.light1; light1.setAttribute('id', 'env-light1'); From 5f808671797170e800dfab5c0f022c9475742e32 Mon Sep 17 00:00:00 2001 From: Kieran Farr Date: Wed, 8 Nov 2023 20:38:31 -0800 Subject: [PATCH 2/2] fix merge, ensure sky visible for relevant presets --- src/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index e1c22fd6b..db331b4e7 100644 --- a/src/index.js +++ b/src/index.js @@ -379,7 +379,7 @@ AFRAME.registerComponent('intersection', { AFRAME.registerComponent('street-environment', { schema: { - preset: { type: 'string', default: 'day', oneOf: ['day', 'night', 'color', 'sunny-morning', 'cloudy-afternoon', 'sunny-afternoon', 'sunny-noon', 'foggy', 'cloudy'] } + preset: { type: 'string', default: 'day', oneOf: ['day', 'night', 'color', 'sunny-morning', 'cloudy-afternoon', 'sunny-afternoon', 'sunny-noon', 'foggy', 'cloudy'] }, backgroundColor: { type: 'color', default: '#FFF' } }, setEnvOption: function () { @@ -398,6 +398,7 @@ AFRAME.registerComponent('street-environment', { } else if (this.data.preset === 'day') { // TODO: create a parent with children light1.setAttribute('light', 'intensity', 0.8); + sky.setAttribute('visible', true); sky.setAttribute('color', '#FFF'); sky.setAttribute('src', '#sky'); sky.setAttribute('rotation', '0 20 0'); @@ -407,6 +408,7 @@ AFRAME.registerComponent('street-environment', { light1.setAttribute('light', 'intensity', 0.8); light2.setAttribute('light', 'intensity: 2.2; castShadow: true; shadowCameraBottom: -20; shadowCameraLeft: -30; shadowCameraRight: 40; shadowCameraTop: 30; shadowMapHeight: 2048; shadowMapWidth: 2048'); light2.setAttribute('position', '-60 56 -16'); + sky.setAttribute('visible', true); sky.setAttribute('color', '#FFF'); sky.setAttribute('src', `url(${assetsPathRoot}images/skies/2048-polyhaven-qwantani_puresky-sdr.jpeg)`); sky.setAttribute('rotation', '0 0 0'); @@ -415,14 +417,13 @@ AFRAME.registerComponent('street-environment', { light2.setAttribute('light', 'intensity', 0.6); sky.setAttribute('visible', true); sky.setAttribute('color', '#FFF'); - sky.setAttribute('src', '#sky'); - sky.setAttribute('rotation', '0 255 0'); sky.setAttribute('src', `url(${assetsPathRoot}images/skies/2048-mud_road_puresky-sdr.jpeg)`); sky.setAttribute('rotation', '0 0 0'); } else if (this.data.preset === 'sunny-afternoon') { light1.setAttribute('light', 'intensity', 2); light2.setAttribute('light', 'intensity: 2.2; castShadow: true; shadowCameraBottom: -20; shadowCameraLeft: -30; shadowCameraRight: 40; shadowCameraTop: 30; shadowMapHeight: 2048; shadowMapWidth: 2048'); light2.setAttribute('position', '60 56 -16'); + sky.setAttribute('visible', true); sky.setAttribute('color', '#FFF'); sky.setAttribute('src', `url(${assetsPathRoot}images/skies/2048-kloofendal_43d_clear_puresky-sdr.jpeg)`); sky.setAttribute('rotation', '0 0 0'); @@ -430,18 +431,21 @@ AFRAME.registerComponent('street-environment', { light1.setAttribute('light', 'intensity', 2); light2.setAttribute('light', 'intensity: 2.2; castShadow: true; shadowCameraBottom: -20; shadowCameraLeft: -30; shadowCameraRight: 40; shadowCameraTop: 30; shadowMapHeight: 2048; shadowMapWidth: 2048'); light2.setAttribute('position', '5 56 -16'); + sky.setAttribute('visible', true); sky.setAttribute('color', '#FFF'); sky.setAttribute('src', `url(${assetsPathRoot}images/skies/2048-kloppenheim_05_puresky-sdr.jpeg)`); sky.setAttribute('rotation', '0 0 0'); } else if (this.data.preset === 'foggy') { light1.setAttribute('light', 'intensity', 2); light2.setAttribute('light', 'intensity: 0.6; castShadow: false;'); + sky.setAttribute('visible', true); sky.setAttribute('color', '#FFF'); sky.setAttribute('src', `url(${assetsPathRoot}images/skies/2048-kloofendal_misty_morning_puresky-sdr.jpeg)`); sky.setAttribute('rotation', '0 0 0'); } else if (this.data.preset === 'cloudy') { light1.setAttribute('light', 'intensity', 2); light2.setAttribute('light', 'intensity', 0.6); + sky.setAttribute('visible', true); sky.setAttribute('color', '#FFF'); sky.setAttribute('src', `url(${assetsPathRoot}images/skies/2048-kloofendal_48d_partly_cloudy_puresky-sdr.jpeg)`); sky.setAttribute('rotation', '0 0 0');