Skip to content

Commit

Permalink
Merge pull request #926 from vorth/tween-default
Browse files Browse the repository at this point in the history
Set the tween default to 500ms
  • Loading branch information
vorth authored Oct 21, 2024
2 parents b198055 + f346b07 commit 19178a3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
7 changes: 7 additions & 0 deletions online/serve/app/test/cases/github-share-online/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
</head>
<body>
<article>
<p>
<ul>
<li>data from GitHub share</li>
<li>preview JSON in online format</li>
<li>shows all scenes</li>
</ul>
</p>
<section>
<vzome-viewer src="https://vorth.github.io/vzome-sharing/2024/06/03/09-54-50-863Z-heptagon-test/heptagon-test.vZome" show-scenes="all" >
</vzome-viewer>
Expand Down
11 changes: 9 additions & 2 deletions online/serve/app/test/cases/github-share/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test GitHub share URL</title>
<title>GitHub share, legacy preview</title>

<link rel="stylesheet" href="../../vzome-viewer.css">

Expand All @@ -12,8 +12,15 @@
</head>
<body>
<article>
<p>
<ul>
<li>data from GitHub share</li>
<li>preview JSON in legacy format</li>
<li>no scenes available</li>
</ul>
</p>
<section>
<vzome-viewer src="https://raw.githubusercontent.com/vorth/vzome-sharing/main/2023/12/15/08-57-13-mirroring-red-strut/mirroring-red-strut.vZome" show-scenes="none" >
<vzome-viewer src="https://raw.githubusercontent.com/vorth/vzome-sharing/main/2023/12/15/08-57-13-mirroring-red-strut/mirroring-red-strut.vZome" show-scenes="all" >
</vzome-viewer>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion online/serve/app/test/gltf.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf8">
<title>&lt;vzome-viewer&gt;</title>
<title>GLTF and VRML</title>
<link rel="stylesheet" href="./vzome-viewer.css">

<script type="module">
Expand Down
15 changes: 8 additions & 7 deletions online/src/viewer/context/camera.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const defaultScene = () => ({
lighting: defaultLighting(),
outlines: false,
tweening: {
duration: 0,
duration: 500,
}
});

Expand Down Expand Up @@ -232,17 +232,15 @@ const CameraProvider = ( props ) =>
tweenZoom
.easing( Easing.Quadratic.InOut )
.to( { distance }, duration )
.onUpdate( ({ distance }) => setDistance( distance ) )
.start();
.onUpdate( ({ distance }) => setDistance( distance ) );

const [ cx, cy, cz ] = state.camera.lookAt;
const tweenPan = new Tween( { x: cx, y: cy, z: cz } ); // start with current value
tweens .add( tweenPan );
tweenPan
.easing( Easing.Quadratic.InOut )
.to( { x, y, z }, duration )
.onUpdate( ({ x, y, z }) => setCamera( { lookAt: toVector( { x, y, z } ) } ) )
.start();
.onUpdate( ({ x, y, z }) => setCamera( { lookAt: toVector( { x, y, z } ) } ) );

// HEAVILY adapted from https://stackoverflow.com/questions/28091876/tween-camera-position-while-rotation-with-slerp-three-js

Expand All @@ -264,8 +262,11 @@ const CameraProvider = ( props ) =>
const up = toVector( new Vector3(0,1,0) .applyQuaternion( sourceQuaternion ) );
const lookDir = toVector( new Vector3(0,0,-1) .applyQuaternion( sourceQuaternion ) );
setCamera( { up, lookDir } );
})
.start();
});

// We don't want to do this sync, since the tween duration may expire before subsequent
// code in the caller finishes.
requestAnimationFrame( () => tweens .getAll() .map( tween => tween.start() ) );
}

const providerValue = {
Expand Down

0 comments on commit 19178a3

Please sign in to comment.