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

Add new animated chars #461

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
26 changes: 24 additions & 2 deletions src/aframe-streetmix-parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,30 @@ function createSidewalkClonedVariants (segmentWidthInMeters, density, elevationP
normal: 0.125,
dense: 0.25
};

// the speed for some pedestrian models is different
const charSpeed = {
// baby-stroller-walk
a_char10: 1,
// wheel-chair
a_char11: 1,
// walker-walk
a_char12: 0.2,
// kid-scooter
a_char13: 2,
// kid-walk
a_char14: 0.8,
// blind-cane-walk
a_char15: 1,
// cart-walk
a_char16: 1.2
}
const totalPedestrianNumber = parseInt(densityFactors[density] * streetLength, 10);
const dividerParentEl = createParentElement('pedestrians-parent');
dividerParentEl.setAttribute('position', { y: elevationPosY });
// Randomly generate avatars
for (let i = 0; i < totalPedestrianNumber; i++) {
const variantName = (animated === true) ? 'a_char' + String(getRandomIntInclusive(1, 8)) : 'char' + String(getRandomIntInclusive(1, 16));
const variantName = 'a_char' + String(getRandomIntInclusive(1, 16));
const xVal = getRandomArbitrary(xValueRange[0], xValueRange[1]);
const zVal = zValueRange.pop();
const yVal = 0;
Expand All @@ -223,7 +241,11 @@ function createSidewalkClonedVariants (segmentWidthInMeters, density, elevationP
}

if (animated) {
addLinearStreetAnimation(placedObjectEl, 1.4, streetLength, xVal, yVal, zVal, animationDirection);
const speed = charSpeed[variantName] || 1.4;
addLinearStreetAnimation(placedObjectEl, speed, streetLength, xVal, yVal, zVal, animationDirection);
} else {
// solution for pause animation-mixer animation from donmccurdy
placedObjectEl.setAttribute('animation-mixer', {timeScale: 0});
}
dividerParentEl.append(placedObjectEl);
}
Expand Down
40 changes: 17 additions & 23 deletions src/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,9 @@ function buildAssetHTML (assetUrl, categories) {
<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>
`,
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>
<a-mixin shadow id="char1" gltf-part="src: #humans; part: Character_1"></a-mixin>
<a-mixin shadow id="char2" gltf-part="src: #humans; part: Character_2"></a-mixin>
<a-mixin shadow id="char3" gltf-part="src: #humans; part: Character_3"></a-mixin>
<a-mixin shadow id="char4" gltf-part="src: #humans; part: Character_4"></a-mixin>
<a-mixin shadow id="char5" gltf-part="src: #humans; part: Character_5"></a-mixin>
<a-mixin shadow id="char6" gltf-part="src: #humans; part: Character_6"></a-mixin>
<a-mixin shadow id="char7" gltf-part="src: #humans; part: Character_7"></a-mixin>
<a-mixin shadow id="char8" gltf-part="src: #humans; part: Character_8"></a-mixin>
<a-asset-item id="humans2" src="${assetUrl}sets/human-characters-poses-2/gltf-exports/draco/human-characters-poses-2.glb"></a-asset-item>
<a-mixin shadow id="char9" gltf-part="src: #humans2; part: Character_9"></a-mixin>
<a-mixin shadow id="char10" gltf-part="src: #humans2; part: Character_10"></a-mixin>
<a-mixin shadow id="char11" gltf-part="src: #humans2; part: Character_11"></a-mixin>
<a-mixin shadow id="char12" gltf-part="src: #humans2; part: Character_12"></a-mixin>
<a-mixin shadow id="char13" gltf-part="src: #humans2; part: Character_13"></a-mixin>
<a-mixin shadow id="char14" gltf-part="src: #humans2; part: Character_14"></a-mixin>
<a-mixin shadow id="char15" gltf-part="src: #humans2; part: Character_15"></a-mixin>
<a-mixin shadow id="char16" gltf-part="src: #humans2; part: Character_16"></a-mixin>
`,
'people-rigged': `
people: `
<a-asset-item id="character1walk" src="${assetUrl}sets/human-characters-animation-seperated/gltf-exports/draco/character-1-walk.glb"></a-asset-item>
<a-mixin shadow id="a_char1" gltf-model="#character1walk" animation-mixer></a-mixin>

<a-asset-item id="character2walk" src="${assetUrl}sets/human-characters-animation-seperated/gltf-exports/draco/character-2-walk.glb"></a-asset-item>
<a-mixin shadow id="a_char2" gltf-model="#character2walk" animation-mixer></a-mixin>
<a-asset-item id="character3walk" src="${assetUrl}sets/human-characters-animation-seperated/gltf-exports/draco/character-3-walk.glb"></a-asset-item>
Expand All @@ -68,6 +46,22 @@ function buildAssetHTML (assetUrl, categories) {
<a-mixin shadow id="a_char7" gltf-model="#character7walk" animation-mixer></a-mixin>
<a-asset-item id="character8walk" src="${assetUrl}sets/human-characters-animation-seperated/gltf-exports/draco/character-8-walk.glb"></a-asset-item>
<a-mixin shadow id="a_char8" gltf-model="#character8walk" animation-mixer></a-mixin>
<a-asset-item id="character9walk" src="${assetUrl}sets/human-characters-animation-seperated/gltf-exports/draco/character-9-walk.glb"></a-asset-item>
<a-mixin shadow id="a_char9" gltf-model="#character9walk" animation-mixer></a-mixin>
<a-asset-item id="character10walk" src="${assetUrl}sets/human-characters-animation-seperated/gltf-exports/draco/character-10-baby-stroller-walk.glb"></a-asset-item>
<a-mixin shadow id="a_char10" gltf-model="#character10walk" animation-mixer></a-mixin>
<a-asset-item id="character11walk" src="${assetUrl}sets/human-characters-animation-seperated/gltf-exports/draco/character-11-wheel-chair.glb"></a-asset-item>
<a-mixin shadow id="a_char11" gltf-model="#character11walk" animation-mixer></a-mixin>
<a-asset-item id="character12walk" src="${assetUrl}sets/human-characters-animation-seperated/gltf-exports/draco/character-12-walker-walk.glb"></a-asset-item>
<a-mixin shadow id="a_char12" gltf-model="#character12walk" animation-mixer></a-mixin>
<a-asset-item id="character13walk" src="${assetUrl}sets/human-characters-animation-seperated/gltf-exports/draco/character-13-kid-scooter.glb"></a-asset-item>
<a-mixin shadow id="a_char13" gltf-model="#character13walk" animation-mixer></a-mixin>
<a-asset-item id="character14walk" src="${assetUrl}sets/human-characters-animation-seperated/gltf-exports/draco/character-14-kid-walk.glb"></a-asset-item>
<a-mixin shadow id="a_char14" gltf-model="#character14walk" animation-mixer></a-mixin>
<a-asset-item id="character15walk" src="${assetUrl}sets/human-characters-animation-seperated/gltf-exports/draco/character-15-blind-cane-walk.glb"></a-asset-item>
<a-mixin shadow id="a_char15" gltf-model="#character15walk" animation-mixer></a-mixin>
<a-asset-item id="character16walk" src="${assetUrl}sets/human-characters-animation-seperated/gltf-exports/draco/character-16-cart-walk.glb"></a-asset-item>
<a-mixin shadow id="a_char16" gltf-model="#character16walk" animation-mixer></a-mixin>
`,
vehicles: `
<!-- vehicles -->
Expand Down
Loading