-
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
Changes from 10 commits
4f6b0fe
bfb5a41
4fc7a90
9e99dfb
42f3807
1148f91
9e3f5f1
a06b3f4
0098e5e
c24c29a
ebe4a5b
b859507
44fa8f2
d6a28d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
src/editor/lib/TransformControls.js | ||
src/lib/ | ||
public | ||
dist | ||
.storybook/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ if (typeof VERSION !== 'undefined') { | |
var streetmixParsers = require('./aframe-streetmix-parsers'); | ||
var streetmixUtils = require('./tested/streetmix-utils'); | ||
require('./json-utils_1.1.js'); | ||
require('./street-utils.js'); | ||
var streetUtils = require('./street-utils.js'); | ||
require('./components/gltf-part'); | ||
require('./components/ocean'); | ||
require('./components/svg-extruder.js'); | ||
|
@@ -34,9 +34,50 @@ AFRAME.registerComponent('street', { | |
globalAnimated: { default: false }, | ||
length: { default: 60 } // new default of 60 from 0.4.4 | ||
}, | ||
init: function () { | ||
// flag to determine init component load | ||
this._initLoad = true; | ||
}, | ||
toggleEntitiesVisibillity: function (entitiesArray, visible) { | ||
entitiesArray.forEach((entity) => entity.setAttribute('visible', visible)); | ||
}, | ||
toggleVehicles: function (showVehicles) { | ||
const vehicleEntities = streetUtils.getVehicleEntities(); | ||
this.toggleEntitiesVisibillity(vehicleEntities, showVehicles); | ||
}, | ||
toggleGround: function (showGround) { | ||
const groundEntities = Array.from( | ||
document.querySelectorAll('.ground-left, .ground-right') | ||
); | ||
this.toggleEntitiesVisibillity(groundEntities, showGround); | ||
}, | ||
toggleStriping: function (showStriping) { | ||
const stripingEntities = streetUtils.getStripingEntities(); | ||
this.toggleEntitiesVisibillity(stripingEntities, showStriping); | ||
}, | ||
update: function (oldData) { | ||
// 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 commentThe 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; |
||
this._initLoad = false; | ||
return; | ||
} | ||
|
||
const data = this.data; | ||
|
||
if (data.showGround !== oldData.showGround) { | ||
this.toggleGround(data.showGround); | ||
return; | ||
} | ||
|
||
if (data.showVehicles !== oldData.showVehicles) { | ||
this.toggleVehicles(data.showVehicles); | ||
return; | ||
} | ||
|
||
if (data.showStriping !== oldData.showStriping) { | ||
this.toggleStriping(data.showStriping); | ||
return; | ||
} | ||
|
||
if (data.JSON.length === 0) { | ||
if (oldData.JSON !== undefined && oldData.JSON.length === 0) { | ||
|
@@ -101,8 +142,11 @@ AFRAME.registerComponent('streetmix-loader', { | |
// fired at start and at each subsequent change of any schema value | ||
// This method may fire a few times when viewing a streetmix street in 3dstreet: | ||
// First to find the proper path, once to actually load the street, and then subsequent updates such as street name | ||
var data = this.data; | ||
var el = this.el; | ||
const data = this.data; | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. same feedback, not a global |
||
|
||
// if the loader has run once already, and upon update neither URL has changed, do not take action | ||
if ( | ||
|
@@ -134,7 +178,7 @@ AFRAME.registerComponent('streetmix-loader', { | |
return; | ||
} | ||
|
||
var request = new XMLHttpRequest(); | ||
const request = new XMLHttpRequest(); | ||
console.log('[streetmix-loader]', 'GET ' + data.streetmixAPIURL); | ||
|
||
request.open('GET', data.streetmixAPIURL, true); | ||
|
@@ -171,7 +215,7 @@ AFRAME.registerComponent('streetmix-loader', { | |
); | ||
} | ||
|
||
el.setAttribute('data-layer-name', 'Streetmix • ' + streetmixName); | ||
el.setAttribute('data-layer-name', 'Streetmix ? ' + streetmixName); | ||
|
||
if (data.showBuildings) { | ||
el.setAttribute('street', 'right', streetData.rightBuildingVariant); | ||
|
@@ -220,6 +264,9 @@ AFRAME.registerComponent('intersection', { | |
var data = this.data; | ||
var el = this.el; | ||
|
||
// do not call init method while loading scene from JSON file | ||
if (STREET.sourceType === 'jsonFile') return; | ||
|
||
// remove all child nodes if exists | ||
while (el.firstChild) { | ||
el.removeChild(el.lastChild); | ||
|
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.