Skip to content

Commit

Permalink
simplify examples
Browse files Browse the repository at this point in the history
  • Loading branch information
yomotsu committed Jul 10, 2020
1 parent 462d68b commit 0683a42
Show file tree
Hide file tree
Showing 15 changed files with 112 additions and 48 deletions.
4 changes: 2 additions & 2 deletions examples/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<button onclick="cameraControls.enabled = true;">enable mouse/touch controls</button>
</div>

<script src="https://unpkg.com/three@0.115.0/build/three.min.js"></script>
<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
CameraControls.install( { THREE: THREE } );
Expand All @@ -56,7 +56,7 @@
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 60, width / height, 0.01, 100 );
camera.position.set( 0, 0, 5 );
const renderer = new THREE.WebGLRenderer( { antialias: true, stencil: false } );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

Expand Down
7 changes: 3 additions & 4 deletions examples/boundary.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<button type="button" onclick="cameraControls.reset( true )">reset</button>
</div>

<script src="https://unpkg.com/three@0.115.0/build/three.min.js"></script>
<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
CameraControls.install( { THREE: THREE } );
Expand All @@ -39,7 +39,7 @@
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 60, width / height, 0.01, 100 );
camera.position.set( 0, 0, 5 );
const renderer = new THREE.WebGLRenderer( { antialias: true, stencil: false } );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

Expand Down Expand Up @@ -92,9 +92,8 @@
function setBoundary0 () {

cameraControls.setBoundary( null );

bbHelper.visible = false;

}

function setBoundary1 () {
Expand Down
4 changes: 2 additions & 2 deletions examples/camera-up.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<button onclick="cameraControls.enabled = true;">enable mouse/touch controls</button>
</div>

<script src="https://unpkg.com/three@0.115.0/build/three.min.js"></script>
<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
CameraControls.install( { THREE: THREE } );
Expand All @@ -41,7 +41,7 @@

camera.up.set( 0, 0, 1 );
camera.position.set( 0, 5, 0 );
const renderer = new THREE.WebGLRenderer( { antialias: true, stencil: false } );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

Expand Down
4 changes: 2 additions & 2 deletions examples/collision.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<button onclick="cameraControls.reset( true )">reset</button>
</div>

<script src="https://unpkg.com/three@0.115.0/build/three.min.js"></script>
<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
CameraControls.install( { THREE: THREE } );
Expand All @@ -32,7 +32,7 @@
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 60, width / height, 0.01, 100 );
camera.position.set( 0, 0, 5 );
const renderer = new THREE.WebGLRenderer( { antialias: true, stencil: false } );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

Expand Down
4 changes: 2 additions & 2 deletions examples/combined-gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ul>
</div>

<script src="https://unpkg.com/three@0.115.0/build/three.min.js"></script>
<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
CameraControls.install( { THREE: THREE } );
Expand All @@ -27,7 +27,7 @@
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 60, width / height, 0.01, 100 );
camera.position.set( 0, 0, 5 );
const renderer = new THREE.WebGLRenderer( { antialias: true, stencil: false } );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

Expand Down
4 changes: 2 additions & 2 deletions examples/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</select>
</div>

<script src="https://unpkg.com/three@0.115.0/build/three.min.js"></script>
<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
CameraControls.install( { THREE: THREE } );
Expand All @@ -89,7 +89,7 @@
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 60, width / height, 0.01, 100 );
camera.position.set( 0, 0, 5 );
const renderer = new THREE.WebGLRenderer( { antialias: true, stencil: false } );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

Expand Down
4 changes: 2 additions & 2 deletions examples/cursor.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<label><input type="checkbox" onchange="cameraControls.dollyToCursor = this.checked">dolly to cursor</label>
</div>

<script src="https://unpkg.com/three@0.115.0/build/three.min.js"></script>
<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
CameraControls.install( { THREE: THREE } );
Expand All @@ -39,7 +39,7 @@
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 60, width / height, 0.01, 100 );
camera.position.set( 0, 0, 5 );
const renderer = new THREE.WebGLRenderer( { antialias: true, stencil: false } );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

Expand Down
6 changes: 3 additions & 3 deletions examples/easing.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<button onclick="rotate0To120()">rotate 0 to 120 deg with easing in 3 sec</button><br>
</div>

<script src="https://unpkg.com/three@0.115.0/build/three.min.js"></script>
<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="https://unpkg.com/@tweenjs/tween.js@18.5.0/dist/tween.umd.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
Expand All @@ -26,7 +26,7 @@
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 60, width / height, 0.01, 100 );
camera.position.set( 0, 0, 5 );
const renderer = new THREE.WebGLRenderer( { antialias: true, stencil: false } );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

Expand Down Expand Up @@ -70,7 +70,7 @@
const rotate0To120 = function () {

cameraControls.azimuthAngle = 0;

new TWEEN.Tween( cameraControls )
.to( { azimuthAngle: 120 * THREE.Math.DEG2RAD }, 3000 )
.easing( TWEEN.Easing.Exponential.Out )
Expand Down
4 changes: 2 additions & 2 deletions examples/first-person.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<button onclick="cameraControls.reset( true )">reset</button>
</div>

<script src="https://unpkg.com/three@0.115.0/build/three.min.js"></script>
<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
CameraControls.install( { THREE: THREE } );
Expand All @@ -44,7 +44,7 @@
const EPS = 1e-5;
// in order to archive FPS look, set EPSILON for the distance to the center
camera.position.set( 0, 0, EPS );
const renderer = new THREE.WebGLRenderer( { antialias: true, stencil: false } );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

Expand Down
4 changes: 2 additions & 2 deletions examples/fit-and-padding.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<button onclick="rotateTo( 'left' ), paddingInCssPixel( 100, 100, 200, 100 )">fit left side with padding in pixel( top: 100<b>px</b>, right: 100<b>px</b>, bottom: 200<b>px</b>, right: 100<b>px</b> )</button>
</div>

<script src="https://unpkg.com/three@0.115.0/build/three.min.js"></script>
<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="https://unpkg.com/@tweenjs/tween.js@18.5.0/dist/tween.umd.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
Expand All @@ -32,7 +32,7 @@
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 60, width / height, 0.01, 100 );
camera.position.set( 0, 0, 5 );
const renderer = new THREE.WebGLRenderer( { antialias: true, stencil: false } );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

Expand Down
4 changes: 2 additions & 2 deletions examples/keyboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<button onclick="cameraControls.reset( true )">reset</button>
</div>

<script src="https://unpkg.com/three@0.115.0/build/three.min.js"></script>
<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="https://unpkg.com/hold-event@0.0.0/dist/hold-event.min.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
Expand All @@ -28,7 +28,7 @@
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 60, width / height, 0.01, 100 );
camera.position.set( 0, 0, 5 );
const renderer = new THREE.WebGLRenderer( { antialias: true, stencil: false } );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

Expand Down
4 changes: 2 additions & 2 deletions examples/orthographic.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<button onclick="cameraControls.enabled = true;">enable mouse/touch controls</button>
</div>

<script src="https://unpkg.com/three@0.115.0/build/three.min.js"></script>
<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
CameraControls.install( { THREE: THREE } );
Expand All @@ -45,7 +45,7 @@
const scene = new THREE.Scene();
const camera = new THREE.OrthographicCamera( width / - 200, width / 200, height / 200, height / - 200, 1, 1000 );
camera.position.set( 0, 0, 100 );
const renderer = new THREE.WebGLRenderer( { antialias: true, stencil: false } );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

Expand Down
12 changes: 6 additions & 6 deletions examples/path-animation.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<button onclick="cameraControls.reset( true )">reset</button>
</div>

<script src="https://unpkg.com/three@0.115.0/build/three.min.js"></script>
<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="https://unpkg.com/@tweenjs/tween.js@18.5.0/dist/tween.umd.js"></script>
<script src="../dist/camera-controls.js"></script>
<script>
Expand All @@ -28,7 +28,7 @@
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 60, width / height, 0.01, 100 );
camera.position.set( 0, 0, 5 );
const renderer = new THREE.WebGLRenderer( { antialias: true, stencil: false } );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

Expand All @@ -45,10 +45,10 @@
scene.add( gridHelper );

const curve = new THREE.CatmullRomCurve3( [
new THREE.Vector3( -3, 2, 1 ),
new THREE.Vector3( 2, 2, 0 ),
new THREE.Vector3( -1, 0, 3 ),
new THREE.Vector3( 2, -1, 0 ),
new THREE.Vector3( - 3, 2, 1 ),
new THREE.Vector3( 2, 2, 0 ),
new THREE.Vector3( - 1, 0, 3 ),
new THREE.Vector3( 2, - 1, 0 ),
] );
const points = curve.getPoints( 50 );
const pathMesh = new THREE.Line(
Expand Down
68 changes: 68 additions & 0 deletions examples/shake.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>=^.^=</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div class="info">
<p><a href="https://github.com/yomotsu/camera-controls">GitHub repo</a></p>
<button onclick="cameraShake.play( 1, 1, 300 )">shake</button>
</div>

<script src="https://unpkg.com/three@0.118.3/build/three.min.js"></script>
<script src="../dist/camera-controls.js"></script>
<script src="./js/shake.js"></script>
<script>
CameraControls.install( { THREE: THREE } );

const width = window.innerWidth;
const height = window.innerHeight;
const clock = new THREE.Clock();
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 60, width / height, 0.01, 100 );
camera.position.set( 0, 0, 5 );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );

const cameraControls = new CameraControls( camera, renderer.domElement );

const mesh = new THREE.Mesh(
new THREE.BoxGeometry( 1, 1, 1 ),
new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } )
);
scene.add( mesh );

const gridHelper = new THREE.GridHelper( 50, 50 );
gridHelper.position.y = - 1;
scene.add( gridHelper );

const cameraShake = new CameraShake( cameraControls );

renderer.render( scene, camera );

( function anim () {

const delta = clock.getDelta();
const elapsed = clock.getElapsedTime();
const updated = cameraControls.update( delta );

// if ( elapsed > 30 ) { return; }

requestAnimationFrame( anim );

if ( updated ) {

renderer.render( scene, camera );
console.log( 'rendered' );

}

} )();
</script>

</body>
</html>
Loading

0 comments on commit 0683a42

Please sign in to comment.