|
@@ -36,9 +36,7 @@
|
|
|
|
|
|
var container, stats;
|
|
|
|
|
|
- var camera, scene, renderer;
|
|
|
-
|
|
|
- var group, text, plane;
|
|
|
+ var camera, scene, renderer, group;
|
|
|
|
|
|
var targetRotation = 0;
|
|
|
var targetRotationOnMouseDown = 0;
|
|
@@ -47,7 +45,6 @@
|
|
|
var mouseXOnMouseDown = 0;
|
|
|
|
|
|
var windowHalfX = window.innerWidth / 2;
|
|
|
- var windowHalfY = window.innerHeight / 2;
|
|
|
|
|
|
init();
|
|
|
animate();
|
|
@@ -100,28 +97,28 @@
|
|
|
|
|
|
var californiaPts = [];
|
|
|
|
|
|
- californiaPts.push( new THREE.Vector2 ( 610, 320 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 450, 300 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 392, 392 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 266, 438 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 190, 570 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 190, 600 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 160, 620 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 160, 650 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 180, 640 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 165, 680 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 150, 670 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 90, 737 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 80, 795 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 50, 835 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 64, 870 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 60, 945 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 300, 945 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 300, 743 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 600, 473 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 626, 425 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 600, 370 ) );
|
|
|
- californiaPts.push( new THREE.Vector2 ( 610, 320 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 610, 320 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 450, 300 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 392, 392 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 266, 438 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 190, 570 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 190, 600 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 160, 620 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 160, 650 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 180, 640 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 165, 680 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 150, 670 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 90, 737 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 80, 795 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 50, 835 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 64, 870 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 60, 945 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 300, 945 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 300, 743 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 600, 473 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 626, 425 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 600, 370 ) );
|
|
|
+ californiaPts.push( new THREE.Vector2( 610, 320 ) );
|
|
|
|
|
|
var californiaShape = new THREE.Shape( californiaPts );
|
|
|
|
|
@@ -129,10 +126,10 @@
|
|
|
// Triangle
|
|
|
|
|
|
var triangleShape = new THREE.Shape();
|
|
|
- triangleShape.moveTo( 80, 20 );
|
|
|
- triangleShape.lineTo( 40, 80 );
|
|
|
+ triangleShape.moveTo( 80, 20 );
|
|
|
+ triangleShape.lineTo( 40, 80 );
|
|
|
triangleShape.lineTo( 120, 80 );
|
|
|
- triangleShape.lineTo( 80, 20 ); // close path
|
|
|
+ triangleShape.lineTo( 80, 20 ); // close path
|
|
|
|
|
|
|
|
|
// Heart
|
|
@@ -143,7 +140,7 @@
|
|
|
|
|
|
heartShape.moveTo( x + 25, y + 25 );
|
|
|
heartShape.bezierCurveTo( x + 25, y + 25, x + 20, y, x, y );
|
|
|
- heartShape.bezierCurveTo( x - 30, y, x - 30, y + 35,x - 30,y + 35 );
|
|
|
+ heartShape.bezierCurveTo( x - 30, y, x - 30, y + 35, x - 30, y + 35 );
|
|
|
heartShape.bezierCurveTo( x - 30, y + 55, x - 10, y + 77, x + 25, y + 95 );
|
|
|
heartShape.bezierCurveTo( x + 60, y + 77, x + 80, y + 55, x + 80, y + 35 );
|
|
|
heartShape.bezierCurveTo( x + 80, y + 35, x + 80, y, x + 50, y );
|
|
@@ -155,7 +152,7 @@
|
|
|
var sqLength = 80;
|
|
|
|
|
|
var squareShape = new THREE.Shape();
|
|
|
- squareShape.moveTo( 0,0 );
|
|
|
+ squareShape.moveTo( 0, 0 );
|
|
|
squareShape.lineTo( 0, sqLength );
|
|
|
squareShape.lineTo( sqLength, sqLength );
|
|
|
squareShape.lineTo( sqLength, 0 );
|
|
@@ -167,7 +164,7 @@
|
|
|
var rectLength = 120, rectWidth = 40;
|
|
|
|
|
|
var rectShape = new THREE.Shape();
|
|
|
- rectShape.moveTo( 0,0 );
|
|
|
+ rectShape.moveTo( 0, 0 );
|
|
|
rectShape.lineTo( 0, rectWidth );
|
|
|
rectShape.lineTo( rectLength, rectWidth );
|
|
|
rectShape.lineTo( rectLength, 0 );
|
|
@@ -178,12 +175,12 @@
|
|
|
|
|
|
var roundedRectShape = new THREE.Shape();
|
|
|
|
|
|
- ( function roundedRect( ctx, x, y, width, height, radius ){
|
|
|
+ ( function roundedRect( ctx, x, y, width, height, radius ) {
|
|
|
|
|
|
ctx.moveTo( x, y + radius );
|
|
|
ctx.lineTo( x, y + height - radius );
|
|
|
ctx.quadraticCurveTo( x, y + height, x + radius, y + height );
|
|
|
- ctx.lineTo( x + width - radius, y + height) ;
|
|
|
+ ctx.lineTo( x + width - radius, y + height );
|
|
|
ctx.quadraticCurveTo( x + width, y + height, x + width, y + height - radius );
|
|
|
ctx.lineTo( x + width, y + radius );
|
|
|
ctx.quadraticCurveTo( x + width, y, x + width - radius, y );
|
|
@@ -199,9 +196,9 @@
|
|
|
var circleShape = new THREE.Shape();
|
|
|
circleShape.moveTo( 0, circleRadius );
|
|
|
circleShape.quadraticCurveTo( circleRadius, circleRadius, circleRadius, 0 );
|
|
|
- circleShape.quadraticCurveTo( circleRadius, -circleRadius, 0, -circleRadius );
|
|
|
- circleShape.quadraticCurveTo( -circleRadius, -circleRadius, -circleRadius, 0 );
|
|
|
- circleShape.quadraticCurveTo( -circleRadius, circleRadius, 0, circleRadius );
|
|
|
+ circleShape.quadraticCurveTo( circleRadius, - circleRadius, 0, - circleRadius );
|
|
|
+ circleShape.quadraticCurveTo( - circleRadius, - circleRadius, - circleRadius, 0 );
|
|
|
+ circleShape.quadraticCurveTo( - circleRadius, circleRadius, 0, circleRadius );
|
|
|
|
|
|
|
|
|
// Fish
|
|
@@ -210,23 +207,23 @@
|
|
|
|
|
|
var fishShape = new THREE.Shape();
|
|
|
|
|
|
- fishShape.moveTo(x,y);
|
|
|
- fishShape.quadraticCurveTo(x + 50, y - 80, x + 90, y - 10);
|
|
|
- fishShape.quadraticCurveTo(x + 100, y - 10, x + 115, y - 40);
|
|
|
- fishShape.quadraticCurveTo(x + 115, y, x + 115, y + 40);
|
|
|
- fishShape.quadraticCurveTo(x + 100, y + 10, x + 90, y + 10);
|
|
|
- fishShape.quadraticCurveTo(x + 50, y + 80, x, y);
|
|
|
+ fishShape.moveTo( x, y );
|
|
|
+ fishShape.quadraticCurveTo( x + 50, y - 80, x + 90, y - 10 );
|
|
|
+ fishShape.quadraticCurveTo( x + 100, y - 10, x + 115, y - 40 );
|
|
|
+ fishShape.quadraticCurveTo( x + 115, y, x + 115, y + 40 );
|
|
|
+ fishShape.quadraticCurveTo( x + 100, y + 10, x + 90, y + 10 );
|
|
|
+ fishShape.quadraticCurveTo( x + 50, y + 80, x, y );
|
|
|
|
|
|
|
|
|
// Arc circle
|
|
|
|
|
|
var arcShape = new THREE.Shape();
|
|
|
arcShape.moveTo( 50, 10 );
|
|
|
- arcShape.absarc( 10, 10, 40, 0, Math.PI*2, false );
|
|
|
+ arcShape.absarc( 10, 10, 40, 0, Math.PI * 2, false );
|
|
|
|
|
|
var holePath = new THREE.Path();
|
|
|
holePath.moveTo( 20, 10 );
|
|
|
- holePath.absarc( 10, 10, 10, 0, Math.PI*2, true );
|
|
|
+ holePath.absarc( 10, 10, 10, 0, Math.PI * 2, true );
|
|
|
arcShape.holes.push( holePath );
|
|
|
|
|
|
|
|
@@ -234,18 +231,18 @@
|
|
|
|
|
|
var smileyShape = new THREE.Shape();
|
|
|
smileyShape.moveTo( 80, 40 );
|
|
|
- smileyShape.absarc( 40, 40, 40, 0, Math.PI*2, false );
|
|
|
+ smileyShape.absarc( 40, 40, 40, 0, Math.PI * 2, false );
|
|
|
|
|
|
var smileyEye1Path = new THREE.Path();
|
|
|
smileyEye1Path.moveTo( 35, 20 );
|
|
|
// smileyEye1Path.absarc( 25, 20, 10, 0, Math.PI*2, true );
|
|
|
- smileyEye1Path.absellipse( 25, 20, 10, 10, 0, Math.PI*2, true );
|
|
|
+ smileyEye1Path.absellipse( 25, 20, 10, 10, 0, Math.PI * 2, true );
|
|
|
|
|
|
smileyShape.holes.push( smileyEye1Path );
|
|
|
|
|
|
var smileyEye2Path = new THREE.Path();
|
|
|
smileyEye2Path.moveTo( 65, 20 );
|
|
|
- smileyEye2Path.absarc( 55, 20, 10, 0, Math.PI*2, true );
|
|
|
+ smileyEye2Path.absarc( 55, 20, 10, 0, Math.PI * 2, true );
|
|
|
smileyShape.holes.push( smileyEye2Path );
|
|
|
|
|
|
var smileyMouthPath = new THREE.Path();
|
|
@@ -268,28 +265,28 @@
|
|
|
// Spline shape + path extrusion
|
|
|
|
|
|
var splinepts = [];
|
|
|
- splinepts.push( new THREE.Vector2 ( 350, 100 ) );
|
|
|
- splinepts.push( new THREE.Vector2 ( 400, 450 ) );
|
|
|
- splinepts.push( new THREE.Vector2 ( -140, 350 ) );
|
|
|
- splinepts.push( new THREE.Vector2 ( 0, 0 ) );
|
|
|
+ splinepts.push( new THREE.Vector2( 350, 100 ) );
|
|
|
+ splinepts.push( new THREE.Vector2( 400, 450 ) );
|
|
|
+ splinepts.push( new THREE.Vector2( - 140, 350 ) );
|
|
|
+ splinepts.push( new THREE.Vector2( 0, 0 ) );
|
|
|
|
|
|
- var splineShape = new THREE.Shape( );
|
|
|
+ var splineShape = new THREE.Shape( );
|
|
|
splineShape.moveTo( 0, 0 );
|
|
|
splineShape.splineThru( splinepts );
|
|
|
|
|
|
|
|
|
// addShape( shape, color, x, y, z, rx, ry,rz, s );
|
|
|
|
|
|
- addShape( californiaShape, 0xffaa00, -300, -100, 0, 0, 0, 0, 0.25 );
|
|
|
- addShape( triangleShape, 0xffee00, -180, 0, 0, 0, 0, 0, 1 );
|
|
|
- addShape( roundedRectShape, 0x005500, -150, 150, 0, 0, 0, 0, 1 );
|
|
|
+ addShape( californiaShape, 0xffaa00, - 300, - 100, 0, 0, 0, 0, 0.25 );
|
|
|
+ addShape( triangleShape, 0xffee00, - 180, 0, 0, 0, 0, 0, 1 );
|
|
|
+ addShape( roundedRectShape, 0x005500, - 150, 150, 0, 0, 0, 0, 1 );
|
|
|
addShape( squareShape, 0x0055ff, 150, 100, 0, 0, 0, 0, 1 );
|
|
|
addShape( heartShape, 0xff1100, 60, 100, 0, 0, 0, Math.PI, 1 );
|
|
|
addShape( circleShape, 0x00ff11, 120, 250, 0, 0, 0, 0, 1 );
|
|
|
- addShape( fishShape, 0x222222, -60, 200, 0, 0, 0, 0, 1 );
|
|
|
- addShape( smileyShape, 0xee00ff, -200, 250, 0, 0, 0, Math.PI, 1 );
|
|
|
+ addShape( fishShape, 0x222222, - 60, 200, 0, 0, 0, 0, 1 );
|
|
|
+ addShape( smileyShape, 0xee00ff, - 200, 250, 0, 0, 0, Math.PI, 1 );
|
|
|
addShape( arcShape, 0xbb4422, 150, 0, 0, 0, 0, 0, 1 );
|
|
|
- addShape( splineShape, 0x888888, -50, -100, 0, 0, 0, 0, 0.2 );
|
|
|
+ addShape( splineShape, 0x888888, - 50, - 100, 0, 0, 0, 0, 0.2 );
|
|
|
|
|
|
//
|
|
|
|
|
@@ -315,7 +312,6 @@
|
|
|
function onWindowResize() {
|
|
|
|
|
|
windowHalfX = window.innerWidth / 2;
|
|
|
- windowHalfY = window.innerHeight / 2;
|
|
|
|
|
|
camera.aspect = window.innerWidth / window.innerHeight;
|
|
|
camera.updateProjectionMatrix();
|
|
@@ -347,7 +343,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- function onDocumentMouseUp( event ) {
|
|
|
+ function onDocumentMouseUp() {
|
|
|
|
|
|
document.removeEventListener( 'mousemove', onDocumentMouseMove, false );
|
|
|
document.removeEventListener( 'mouseup', onDocumentMouseUp, false );
|
|
@@ -355,7 +351,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- function onDocumentMouseOut( event ) {
|
|
|
+ function onDocumentMouseOut() {
|
|
|
|
|
|
document.removeEventListener( 'mousemove', onDocumentMouseMove, false );
|
|
|
document.removeEventListener( 'mouseup', onDocumentMouseUp, false );
|