-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uses another script to move vehicle forward instead of bone translation
- Loading branch information
Showing
4 changed files
with
46 additions
and
34 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,41 @@ | ||
<html> | ||
|
||
<head> | ||
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script> | ||
<script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script> | ||
|
||
<script src="https://unpkg.com/[email protected]/dist/aframe-orbit-controls.min.js"></script> | ||
<!-- <script src="./dist/aframe-street-component.js"></script> --> | ||
|
||
<script src="./src/tested/vehicle-wheel-animation-test.js"></script> | ||
<script> | ||
|
||
// source: https://github.com/networked-aframe/networked-aframe/blob/master/examples/js/forward.component.js | ||
// modified to be meters per second and default direction | ||
AFRAME.registerComponent('forward', { | ||
schema: { | ||
speed: {default: 1}, // meters per second | ||
}, | ||
|
||
init: function() { | ||
var worldDirection = new THREE.Vector3(); | ||
|
||
this.el.object3D.getWorldDirection(worldDirection); | ||
|
||
this.worldDirection = worldDirection; | ||
}, | ||
|
||
tick: function() { | ||
var el = this.el; | ||
|
||
var currentPosition = el.getAttribute('position'); | ||
var newPosition = this.worldDirection | ||
.clone() | ||
.multiplyScalar(this.data.speed / 1000) | ||
.add(currentPosition); | ||
el.setAttribute('position', newPosition); | ||
} | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
|
@@ -20,13 +49,13 @@ | |
<img id="checker" src="//assets.3dstreet.app/materials/Checkerboard_tile.jpg" crossorigin="anonymous" /> | ||
</a-assets> | ||
|
||
<a-entity gltf-model="#bus" wheel="speed:5; wheelDiameter:1.08" position="-8 0 0"></a-entity> | ||
<a-entity gltf-model="#sedan" wheel="speed:10; wheelDiameter:0.76" position="-1 0 -9"></a-entity> | ||
<a-entity gltf-model="#sedan-taxi" wheel="speed:15; wheelDiameter:0.76" position="-1 0 -5"></a-entity> | ||
<a-entity gltf-model="#suv" wheel="speed:5; wheelDiameter:0.84" position="-3 0 0"></a-entity> | ||
<a-entity gltf-model="#box-truck" wheel="speed:2; wheelDiameter:1.05" position="-5 0 -5"></a-entity> | ||
<a-entity gltf-model="#bus" wheel="speed:5; wheelDiameter:1.08" forward="speed:5" position="-8 0 0"></a-entity> | ||
<a-entity gltf-model="#sedan" wheel="speed:10; wheelDiameter:0.76" forward="speed:10" position="-1 0 -9"></a-entity> | ||
<a-entity gltf-model="#sedan-taxi" wheel="speed:15; wheelDiameter:0.76" forward="speed:15" position="-1 0 -5"></a-entity> | ||
<a-entity gltf-model="#suv" wheel="speed:5; wheelDiameter:0.84" forward="speed:5" position="-3 0 0"></a-entity> | ||
<a-entity gltf-model="#box-truck" wheel="speed:1; wheelDiameter:1.05" forward position="-5 0 -5"></a-entity> | ||
<a-entity camera id="camera-parent" position="3 1 0" rotation="0 90 0"> | ||
<a-entity camera look-controls id="camera"></a-entity> | ||
<a-entity camera wasd-controls look-controls id="camera"></a-entity> | ||
</a-entity> | ||
<a-entity geometry="primitive: plane; height: 100; width: 100" rotation="90 0 0" | ||
material="src: #checker;side: double;shader: flat; color: lightgreen; repeat: 100 100 "></a-entity> | ||
|