-
Notifications
You must be signed in to change notification settings - Fork 3
/
TWEEN.html
18 lines (16 loc) · 873 Bytes
/
TWEEN.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE html>
<title>TWEEN Behavior Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tween.js/17.2.0/Tween.min.js"></script>
<script src="https://cdn.jsdelivr.net/combine/npm/three@0.95.0/build/three.min.js,npm/altspace@2.9.0/dist/altspace.min.js,npm/altspacevr-behaviors@1.1.5/js/altspaceutil.min.js"></script>
<script>
altspaceutil.getFullspaceApp().then(app => {
app.anchor.addBehavior(new altspaceutil.behaviors.TWEEN());
let cube = new THREE.Mesh(new THREE.BoxBufferGeometry(2, 2, 2), new THREE.MeshBasicMaterial({ color: 'red' }));
app.anchor.add(cube);
let forward = new TWEEN.Tween(cube.position).to({ x: 2 }, 1000).easing(TWEEN.Easing.Back.Out);
let reverse = new TWEEN.Tween(cube.position).to({ x: -2 }, 1000).easing(TWEEN.Easing.Back.Out);
forward.chain(reverse);
reverse.chain(forward);
forward.start();
});
</script>