-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Naively scale up gLTFs for now, add orbit controls (#16)
- Loading branch information
1 parent
a666f6c
commit 00594de
Showing
1 changed file
with
29 additions
and
14 deletions.
There are no files selected for viewing
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,20 +1,35 @@ | ||
<script lang="ts"> | ||
import { T } from '@threlte/core' | ||
import { GLTF } from '@threlte/extras' | ||
import { GLTF, OrbitControls, interactivity } from '@threlte/extras' | ||
interactivity() | ||
export let dataUrl: string | ||
let shouldAutoRotate = true | ||
const AUTO_ROTATE_PAUSE = 5000 | ||
let autorotateTimeout: ReturnType<typeof setTimeout> | undefined | ||
const disableAutoRotate = () => { | ||
shouldAutoRotate = false | ||
clearTimeout(autorotateTimeout) | ||
} | ||
const reenableAutoRotate = () => { | ||
autorotateTimeout = setTimeout(function () { | ||
shouldAutoRotate = true | ||
}, AUTO_ROTATE_PAUSE) | ||
} | ||
</script> | ||
|
||
<T.PerspectiveCamera | ||
makeDefault | ||
on:create={({ ref }) => { | ||
ref.lookAt(0, 1, 0) | ||
}} | ||
/> | ||
<T.PerspectiveCamera makeDefault fov={50} position={[20, 20, 20]}> | ||
<OrbitControls | ||
enableDamping | ||
autoRotate={shouldAutoRotate} | ||
on:start={disableAutoRotate} | ||
on:end={reenableAutoRotate} | ||
/> | ||
</T.PerspectiveCamera> | ||
|
||
<T.AmbientLight color="white" /> | ||
<T.DirectionalLight color="white" /> | ||
<T.DirectionalLight color="white" position={[5, 0, -5]} /> | ||
|
||
<GLTF | ||
url={dataUrl} | ||
position={[0, 1, 0]} | ||
on:load={(payload) => { | ||
console.log('loaded', payload) | ||
}} | ||
/> | ||
<GLTF url={dataUrl} position={[0, 0, 0]} scale={300} /> |