Skip to content

Commit

Permalink
Merge branch 'main' into update-aframe
Browse files Browse the repository at this point in the history
  • Loading branch information
kfarr committed Sep 9, 2024
2 parents 30c7712 + 1aa33f6 commit 0e7c89b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 8 deletions.
14 changes: 13 additions & 1 deletion src/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ function buildAssetHTML(assetUrl, categories) {
<a-mixin shadow id="bus-stop" gltf-part="src: #streetProps; part: transit-shelter-1"></a-mixin>
<a-mixin shadow id="pride-flag" position="0.409 3.345 0" rotation="0 0 0" scale="0.5 0.75 0" geometry="width:2;height:2;primitive:plane" material="side:double; src:${assetUrl}materials/rainbow-flag-poles_512.png;transparent: true;"></a-mixin>
<a-mixin shadow id="wayfinding-box" geometry="primitive: box; height: 2; width: 0.84; depth: 0.1" material="color: gray"></a-mixin>
`,
<a-mixin shadow id="trash-bin" gltf-model="url(${assetUrl}sets/uoregon/gltf-exports/draco/bin.glb)"></a-mixin>
<a-mixin shadow id="lending-library" gltf-model="url(${assetUrl}sets/uoregon/gltf-exports/draco/lending-library.glb)"></a-mixin>
<a-mixin shadow id="residential-mailbox" gltf-model="url(${assetUrl}sets/uoregon/gltf-exports/draco/residential-mailbox.glb)"></a-mixin>
<a-mixin shadow id="USPS-mailbox" gltf-model="url(${assetUrl}sets/uoregon/gltf-exports/draco/USPS-mailbox.glb)"></a-mixin>
<a-mixin shadow id="picnic-bench" gltf-model="url(${assetUrl}sets/uoregon/gltf-exports/draco/picnic-bench.glb)"></a-mixin>
<a-mixin shadow id="large-parklet" gltf-model="url(${assetUrl}sets/uoregon/gltf-exports/draco/large-parklet-seating.glb)"></a-mixin>
`,
people: `
<!-- human characters -->
<a-asset-item id="humans" src="${assetUrl}sets/human-characters-poses-1/gltf-exports/draco/human-characters-poses-1.glb"></a-asset-item>
Expand Down Expand Up @@ -127,11 +133,13 @@ function buildAssetHTML(assetUrl, categories) {
'segment-textures': `
<!-- segment mixins with textures -->
<img id="seamless-road" src="${assetUrl}materials/TexturesCom_Roads0086_1_seamless_S_rotate.jpg" crossorigin="anonymous">
<img id="seamless-sandy-road" src="${assetUrl}materials/TexturesCom_Roads0086_1_seamless_S_rotate-sandy.webp" crossorigin="anonymous">
<img id="seamless-bright-road" src="${assetUrl}materials/asphalthd_Base_Color.jpg" crossorigin="anonymous">
<img id="seamless-sidewalk" src="${assetUrl}materials/TexturesCom_FloorsRegular0301_1_seamless_S.jpg" crossorigin="anonymous">
<img id="hatched-base" src="${assetUrl}materials/seamless-lane-with-hatch-half.jpg" crossorigin="anonymous">
<img id="hatched-normal" src="${assetUrl}materials/seamless-lane-with-hatch-half.jpg" crossorigin="anonymous">
<a-mixin shadow="cast: false" id="drive-lane" geometry="width:3;height:150;primitive:plane" material="roughness:${surfacesRoughness};repeat:0.3 25;offset:0.55 0;src:#seamless-road;"></a-mixin>
<a-mixin shadow="cast: false" id="sandy-lane" geometry="width:3;height:150;primitive:plane" material="roughness:${surfacesRoughness};repeat:0.3 5;offset:0.55 0;src:#seamless-sandy-road;"></a-mixin>
<a-mixin shadow="cast: false" id="bright-lane" geometry="width:3;height:150;primitive:plane" material="roughness:${surfacesRoughness};repeat:0.6 50;offset:0.55 0;src:#seamless-bright-road;color:#dddddd"></a-mixin>
<a-mixin shadow="cast: false" id="bike-lane" geometry="width:1.8;height:150;primitive:plane" material="roughness:${surfacesRoughness};repeat:0.3 25;offset:0.55 0;metalness:0;src:#seamless-road;"></a-mixin>
<a-mixin shadow id="sidewalk" anisotropy geometry="width:3;height:150;primitive:plane" material="roughness:${surfacesRoughness};repeat:1.5 75;src:#seamless-sidewalk;"></a-mixin>
Expand Down Expand Up @@ -214,6 +222,8 @@ function buildAssetHTML(assetUrl, categories) {
<a-mixin shadow id="street-element-traffic-island" scale="1.5 1.5 1.5" rotation="0 0 0" gltf-model="url(${assetUrl}sets/uoregon/gltf-exports/draco/curb-traffic-island.glb)"></a-mixin>
<a-mixin shadow id="street-element-speed-hump" scale="1.5 1.5 1.5" rotation="0 0 0" gltf-model="url(${assetUrl}sets/uoregon/gltf-exports/draco/speed-hump.glb)"></a-mixin>
<a-mixin shadow id="crosswalk-zebra-box" geometry="primitive: box; height: 0.1; width: 2; depth: 10" material="src: url(${assetUrl}materials/markings-crosswalk.png)"></a-mixin>
<a-mixin shadow id="traffic-calming-bumps" gltf-model="url(${assetUrl}sets/uoregon/gltf-exports/draco/traffic-calming-bumps.glb)"></a-mixin>
<a-mixin shadow id="corner-island" gltf-model="url(${assetUrl}sets/uoregon/gltf-exports/draco/corner-island.glb)"></a-mixin>
`,
sky: `
<!-- sky -->
Expand All @@ -223,8 +233,10 @@ function buildAssetHTML(assetUrl, categories) {
grounds: `
<!-- grounds -->
<img id="grass-texture" src="${assetUrl}materials/TexturesCom_Grass0052_1_seamless_S.jpg" crossorigin="anonymous">
<img id="compacted-gravel-texture" src="${assetUrl}materials/compacted-gravel_color.webp" crossorigin="anonymous">
<img id="parking-lot-texture" src="${assetUrl}materials/TexturesCom_Roads0111_1_seamless_S.jpg" crossorigin="anonymous">
<img id="asphalt-texture" src="${assetUrl}materials/TexturesCom_AsphaltDamaged0057_1_seamless_S.jpg" crossorigin="anonymous">
<img id="sandy-asphalt-texture" src="${assetUrl}materials/sandy-asphalt-texture_color.webp" crossorigin="anonymous">
<!-- legacy plane-based grounds for compatibility with 0.4.2 and earlier scenes, not used for new streets -->
<a-mixin shadow id="ground-grass" rotation="-90 0 0" geometry="primitive:plane;height:150;width:40" material="src:#grass-texture;repeat:5 5;roughness:1"></a-mixin>
Expand Down
10 changes: 10 additions & 0 deletions src/editor/api/user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const PRO_DOMAINS = ['unam.mx'];

const isUserPro = async (user) => {
if (user) {
try {
// Check if the user's email contains "unam.mx"
if (
user.email &&
PRO_DOMAINS.some((domain) => user.email.includes(domain))
) {
return true;
}

await user.getIdToken(true);
const idTokenResult = await user.getIdTokenResult();
if (idTokenResult.claims.plan === 'PRO') {
Expand Down
28 changes: 22 additions & 6 deletions src/editor/components/scenegraph/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ export default class Toolbar extends Component {
// isPlaying: false,
isSaveActionActive: false,
isCapturingScreen: false,
showSaveBtn: true,
showLoadBtn: true,
savedNewDocument: false,
isSavingScene: false,
pendingSceneSave: false,
signInSuccess: false
signInSuccess: false,
isAuthor: props.isAuthor
};
this.saveButtonRef = React.createRef();
}
Expand All @@ -76,7 +76,12 @@ export default class Toolbar extends Component {
}

componentDidUpdate(prevProps) {
if (prevProps.isAuthor !== this.props.isAuthor) {
this.setState({ isAuthor: this.props.isAuthor });
}
if (this.props.currentUser !== prevProps.currentUser) {
console.log('component updated');
console.log(this.props);
this.setState({ currentUser: this.props.currentUser });

if (this.state.pendingSceneSave && this.props.currentUser) {
Expand All @@ -86,7 +91,6 @@ export default class Toolbar extends Component {
this.cloudSaveHandler({ doSaveAs: true })
.then(() => {
// The promise from cloudSaveHandler has resolved, now update the state.
this.setState({ showSaveBtn: true });
})
.catch((error) => {
// Handle any errors here
Expand Down Expand Up @@ -210,6 +214,18 @@ export default class Toolbar extends Component {

// we want to save, so if we *still* have no sceneID at this point, then create a new one
if (!currentSceneId || !!doSaveAs) {
// ask user for scene title here currentSceneTitle
let newSceneTitle = prompt('Scene Title:', currentSceneTitle);

if (newSceneTitle) {
currentSceneTitle = newSceneTitle;
}
AFRAME.scenes[0].setAttribute(
'metadata',
'sceneTitle',
currentSceneTitle
);

console.log(
'no urlSceneId or doSaveAs is true, therefore generate new one'
);
Expand Down Expand Up @@ -257,7 +273,7 @@ export default class Toolbar extends Component {
'Scene saved to 3DStreet Cloud in existing file.'
);
}

this.setState({ isAuthor: true });
sendMetric('SaveSceneAction', doSaveAs ? 'saveAs' : 'save');
} catch (error) {
STREET.notify.errorMessage(
Expand Down Expand Up @@ -376,7 +392,7 @@ export default class Toolbar extends Component {
<div className="hideInLowResolution">New</div>
</Button>
</div>
{this.state.showSaveBtn && this.props.currentUser ? (
{this.props.currentUser ? (
<div className="saveButtonWrapper" ref={this.saveButtonRef}>
<Button
leadingIcon={<Save24Icon />}
Expand All @@ -391,7 +407,7 @@ export default class Toolbar extends Component {
leadingIcon={<Cloud24Icon />}
variant="white"
onClick={this.cloudSaveHandler}
disabled={this.state.isSavingScene || !this.props.isAuthor}
disabled={this.state.isSavingScene || !this.state.isAuthor}
>
<div>Save</div>
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/editor/lib/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function inputStreetmix() {
export function createElementsForScenesFromJSON(streetData) {
// clear scene data, create new blank scene.
// clearMetadata = true, clearUrlHash = false, addDefaultStreet = false
STREET.utils.newScene(true, true, false);
STREET.utils.newScene(true, false, false);

const streetContainerEl = document.getElementById('street-container');

Expand Down

0 comments on commit 0e7c89b

Please sign in to comment.