-
Notifications
You must be signed in to change notification settings - Fork 33
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
Change street component parameters #512
Conversation
✅ Deploy Preview for 3dstreet-core-builds ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
# Conflicts: # src/lib/aframe-loader-3dtiles-component.js # src/lib/aframe-loader-3dtiles-component.min.js
src/index.js
Outdated
this.toggleEntitiesVisibillity(vehicleEntities, showVehicles); | ||
}, | ||
toggleGround: function (showGround) { | ||
const groundEntities = Array.from(document.querySelectorAll('.ground-left, .ground-right')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array.from is not needed.
Updated this PR to the latest version of the 3dstreet repository. This issue has now been fixed: #673 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a new property to street component such as synchronized
true/false
if synchronized is true (it should be true by default at the start) then it will create children entities; after creating children entities for the first time synchronized should be set to false; then use that instead of the global STREET.sourceType
src/components/streetplan-loader.js
Outdated
@@ -78,6 +78,8 @@ AFRAME.registerComponent('streetplan-loader', { | |||
return; | |||
} | |||
|
|||
STREET.sourceType = 'streetplanURL'; // it also could be jsonFile/streetmixURL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Algorush there will be more than 1 street per scene so I don't understand why this needs to be set ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I thought about more than 1 street per scene and was tested with this case also. STREET.sourceType
refers to the currently loaded street. And global STREET is not good place for it, yeah...
And yes, maybe its not good idea, but I didn’t find a better option when was thinking about it.
src/index.js
Outdated
// fired once at start and at each subsequent change of a schema value | ||
var data = this.data; | ||
// do not call the update function when the component is initially loaded and sourceType is jsonFile | ||
if (STREET.sourceType === 'jsonFile' && this._initLoad) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Algorush we should not be using a global for sourceType that describes this specific entity; multiple streets may be loading from different types of sources on the same scene;
src/index.js
Outdated
const el = this.el; | ||
|
||
// do not call update function while loading scene from JSON file | ||
if (STREET.sourceType === 'jsonFile') return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same feedback, not a global
Ok, it works good, when I added |
question: should visibility options showGround, showStripping, showVehicles be saved in JSON or should they only be valid during the session? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
synchronized
means the entities are recreated each time from streetmix json.
If we don't want the behavior, we set synchronized
to false after loading the json the first time.
src/index.js
Outdated
@@ -185,6 +228,8 @@ AFRAME.registerComponent('streetmix-loader', { | |||
JSON.stringify({ streetmixSegmentsMetric: streetmixSegments }) | |||
); | |||
el.emit('streetmix-loader-street-loaded'); | |||
// the streetmix data has been loaded, set the synchronized flag | |||
data.synchronized = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't set it like that, otherwise the change won't be properly exported. Use
this.el.setAttribute('street', 'synchronized', true}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current code may work on aframe 1.5.0 but I think it won't work on aframe 1.6.0 or master because of internals restructuring, calling getAttribute('street') won't return the modified data object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying. Yes, I have read the documentation why it is better to use setAttribute. But in general it would be better to use an internal variable of the component in these cases, which is saved in JSON, but will not be displayed in the editor. There is no such mechanism in the component implementation, but it could be done using __innerAttrName
and internal get/set functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Algorush it's ok for this variable to be exposed to the end-user
src/index.js
Outdated
@@ -171,7 +214,7 @@ AFRAME.registerComponent('streetmix-loader', { | |||
); | |||
} | |||
|
|||
el.setAttribute('data-layer-name', 'Streetmix • ' + streetmixName); | |||
el.setAttribute('data-layer-name', 'Streetmix � ' + streetmixName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unicode issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, something strange with my code editor. Will fix in next commit too
src/index.js
Outdated
@@ -86,6 +123,8 @@ AFRAME.registerComponent('street', { | |||
); | |||
this.el.append(buildingsEl); | |||
} | |||
// the scene has been loaded, set the synchronized flag | |||
this.data.synchronized = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use setAttribute
@Algorush sorry for the miscommunication, this is close but the logic is inverted. Instead of "this.data.synchronized = true;" we would like to have For the avoidance of doubt, after the objects are created initially, then set synchronize to false. |
test
|
Added the ability to change the parameters of the street component (showGround, showVehicles, showStriping) without reloading the scene. It remains to add globalAnimated. So this PR not ready yet.
Also, now there is no need to rename street to not-street, like streetmix-loader and intersection. I added a check that the scene is loaded from jsonFile and do not run the update function in these components