|
@@ -22,19 +22,19 @@
|
|
|
|
|
|
import Stats from './jsm/libs/stats.module.js';
|
|
import Stats from './jsm/libs/stats.module.js';
|
|
|
|
|
|
- var container, stats;
|
|
|
|
|
|
+ let container, stats;
|
|
|
|
|
|
- var camera, scene, renderer;
|
|
|
|
|
|
+ let camera, scene, renderer;
|
|
|
|
|
|
- var group;
|
|
|
|
|
|
+ let group;
|
|
|
|
|
|
- var targetRotation = 0;
|
|
|
|
- var targetRotationOnPointerDown = 0;
|
|
|
|
|
|
+ let targetRotation = 0;
|
|
|
|
+ let targetRotationOnPointerDown = 0;
|
|
|
|
|
|
- var pointerX = 0;
|
|
|
|
- var pointerXOnPointerDown = 0;
|
|
|
|
|
|
+ let pointerX = 0;
|
|
|
|
+ let pointerXOnPointerDown = 0;
|
|
|
|
|
|
- var windowHalfX = window.innerWidth / 2;
|
|
|
|
|
|
+ let windowHalfX = window.innerWidth / 2;
|
|
|
|
|
|
init();
|
|
init();
|
|
animate();
|
|
animate();
|
|
@@ -51,15 +51,15 @@
|
|
camera.position.set( 0, 150, 500 );
|
|
camera.position.set( 0, 150, 500 );
|
|
scene.add( camera );
|
|
scene.add( camera );
|
|
|
|
|
|
- var light = new THREE.PointLight( 0xffffff, 0.8 );
|
|
|
|
|
|
+ const light = new THREE.PointLight( 0xffffff, 0.8 );
|
|
camera.add( light );
|
|
camera.add( light );
|
|
|
|
|
|
group = new THREE.Group();
|
|
group = new THREE.Group();
|
|
group.position.y = 50;
|
|
group.position.y = 50;
|
|
scene.add( group );
|
|
scene.add( group );
|
|
|
|
|
|
- var loader = new THREE.TextureLoader();
|
|
|
|
- var texture = loader.load( "textures/uv_grid_opengl.jpg" );
|
|
|
|
|
|
+ const loader = new THREE.TextureLoader();
|
|
|
|
+ const texture = loader.load( "textures/uv_grid_opengl.jpg" );
|
|
|
|
|
|
// it's necessary to apply these settings in order to correctly display the texture on a shape geometry
|
|
// it's necessary to apply these settings in order to correctly display the texture on a shape geometry
|
|
|
|
|
|
@@ -71,9 +71,9 @@
|
|
// flat shape with texture
|
|
// flat shape with texture
|
|
// note: default UVs generated by THREE.ShapeBufferGeometry are simply the x- and y-coordinates of the vertices
|
|
// note: default UVs generated by THREE.ShapeBufferGeometry are simply the x- and y-coordinates of the vertices
|
|
|
|
|
|
- var geometry = new THREE.ShapeBufferGeometry( shape );
|
|
|
|
|
|
+ let geometry = new THREE.ShapeBufferGeometry( shape );
|
|
|
|
|
|
- var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( { side: THREE.DoubleSide, map: texture } ) );
|
|
|
|
|
|
+ let mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( { side: THREE.DoubleSide, map: texture } ) );
|
|
mesh.position.set( x, y, z - 175 );
|
|
mesh.position.set( x, y, z - 175 );
|
|
mesh.rotation.set( rx, ry, rz );
|
|
mesh.rotation.set( rx, ry, rz );
|
|
mesh.scale.set( s, s, s );
|
|
mesh.scale.set( s, s, s );
|
|
@@ -81,9 +81,9 @@
|
|
|
|
|
|
// flat shape
|
|
// flat shape
|
|
|
|
|
|
- var geometry = new THREE.ShapeBufferGeometry( shape );
|
|
|
|
|
|
+ geometry = new THREE.ShapeBufferGeometry( shape );
|
|
|
|
|
|
- var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( { color: color, side: THREE.DoubleSide } ) );
|
|
|
|
|
|
+ mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( { color: color, side: THREE.DoubleSide } ) );
|
|
mesh.position.set( x, y, z - 125 );
|
|
mesh.position.set( x, y, z - 125 );
|
|
mesh.rotation.set( rx, ry, rz );
|
|
mesh.rotation.set( rx, ry, rz );
|
|
mesh.scale.set( s, s, s );
|
|
mesh.scale.set( s, s, s );
|
|
@@ -91,9 +91,9 @@
|
|
|
|
|
|
// extruded shape
|
|
// extruded shape
|
|
|
|
|
|
- var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );
|
|
|
|
|
|
+ geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );
|
|
|
|
|
|
- var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( { color: color } ) );
|
|
|
|
|
|
+ mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( { color: color } ) );
|
|
mesh.position.set( x, y, z - 75 );
|
|
mesh.position.set( x, y, z - 75 );
|
|
mesh.rotation.set( rx, ry, rz );
|
|
mesh.rotation.set( rx, ry, rz );
|
|
mesh.scale.set( s, s, s );
|
|
mesh.scale.set( s, s, s );
|
|
@@ -109,15 +109,15 @@
|
|
|
|
|
|
shape.autoClose = true;
|
|
shape.autoClose = true;
|
|
|
|
|
|
- var points = shape.getPoints();
|
|
|
|
- var spacedPoints = shape.getSpacedPoints( 50 );
|
|
|
|
|
|
+ const points = shape.getPoints();
|
|
|
|
+ const spacedPoints = shape.getSpacedPoints( 50 );
|
|
|
|
|
|
- var geometryPoints = new THREE.BufferGeometry().setFromPoints( points );
|
|
|
|
- var geometrySpacedPoints = new THREE.BufferGeometry().setFromPoints( spacedPoints );
|
|
|
|
|
|
+ const geometryPoints = new THREE.BufferGeometry().setFromPoints( points );
|
|
|
|
+ const geometrySpacedPoints = new THREE.BufferGeometry().setFromPoints( spacedPoints );
|
|
|
|
|
|
// solid line
|
|
// solid line
|
|
|
|
|
|
- var line = new THREE.Line( geometryPoints, new THREE.LineBasicMaterial( { color: color } ) );
|
|
|
|
|
|
+ let line = new THREE.Line( geometryPoints, new THREE.LineBasicMaterial( { color: color } ) );
|
|
line.position.set( x, y, z - 25 );
|
|
line.position.set( x, y, z - 25 );
|
|
line.rotation.set( rx, ry, rz );
|
|
line.rotation.set( rx, ry, rz );
|
|
line.scale.set( s, s, s );
|
|
line.scale.set( s, s, s );
|
|
@@ -125,7 +125,7 @@
|
|
|
|
|
|
// line from equidistance sampled points
|
|
// line from equidistance sampled points
|
|
|
|
|
|
- var line = new THREE.Line( geometrySpacedPoints, new THREE.LineBasicMaterial( { color: color } ) );
|
|
|
|
|
|
+ line = new THREE.Line( geometrySpacedPoints, new THREE.LineBasicMaterial( { color: color } ) );
|
|
line.position.set( x, y, z + 25 );
|
|
line.position.set( x, y, z + 25 );
|
|
line.rotation.set( rx, ry, rz );
|
|
line.rotation.set( rx, ry, rz );
|
|
line.scale.set( s, s, s );
|
|
line.scale.set( s, s, s );
|
|
@@ -133,7 +133,7 @@
|
|
|
|
|
|
// vertices from real points
|
|
// vertices from real points
|
|
|
|
|
|
- var particles = new THREE.Points( geometryPoints, new THREE.PointsMaterial( { color: color, size: 4 } ) );
|
|
|
|
|
|
+ let particles = new THREE.Points( geometryPoints, new THREE.PointsMaterial( { color: color, size: 4 } ) );
|
|
particles.position.set( x, y, z + 75 );
|
|
particles.position.set( x, y, z + 75 );
|
|
particles.rotation.set( rx, ry, rz );
|
|
particles.rotation.set( rx, ry, rz );
|
|
particles.scale.set( s, s, s );
|
|
particles.scale.set( s, s, s );
|
|
@@ -141,7 +141,7 @@
|
|
|
|
|
|
// equidistance sampled points
|
|
// equidistance sampled points
|
|
|
|
|
|
- var particles = new THREE.Points( geometrySpacedPoints, new THREE.PointsMaterial( { color: color, size: 4 } ) );
|
|
|
|
|
|
+ particles = new THREE.Points( geometrySpacedPoints, new THREE.PointsMaterial( { color: color, size: 4 } ) );
|
|
particles.position.set( x, y, z + 125 );
|
|
particles.position.set( x, y, z + 125 );
|
|
particles.rotation.set( rx, ry, rz );
|
|
particles.rotation.set( rx, ry, rz );
|
|
particles.scale.set( s, s, s );
|
|
particles.scale.set( s, s, s );
|
|
@@ -152,7 +152,7 @@
|
|
|
|
|
|
// California
|
|
// California
|
|
|
|
|
|
- var californiaPts = [];
|
|
|
|
|
|
+ const californiaPts = [];
|
|
|
|
|
|
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( 450, 300 ) );
|
|
@@ -177,14 +177,14 @@
|
|
californiaPts.push( new THREE.Vector2( 600, 370 ) );
|
|
californiaPts.push( new THREE.Vector2( 600, 370 ) );
|
|
californiaPts.push( new THREE.Vector2( 610, 320 ) );
|
|
californiaPts.push( new THREE.Vector2( 610, 320 ) );
|
|
|
|
|
|
- for ( var i = 0; i < californiaPts.length; i ++ ) californiaPts[ i ].multiplyScalar( 0.25 );
|
|
|
|
|
|
+ for ( let i = 0; i < californiaPts.length; i ++ ) californiaPts[ i ].multiplyScalar( 0.25 );
|
|
|
|
|
|
- var californiaShape = new THREE.Shape( californiaPts );
|
|
|
|
|
|
+ const californiaShape = new THREE.Shape( californiaPts );
|
|
|
|
|
|
|
|
|
|
// Triangle
|
|
// Triangle
|
|
|
|
|
|
- var triangleShape = new THREE.Shape()
|
|
|
|
|
|
+ const triangleShape = new THREE.Shape()
|
|
.moveTo( 80, 20 )
|
|
.moveTo( 80, 20 )
|
|
.lineTo( 40, 80 )
|
|
.lineTo( 40, 80 )
|
|
.lineTo( 120, 80 )
|
|
.lineTo( 120, 80 )
|
|
@@ -193,9 +193,9 @@
|
|
|
|
|
|
// Heart
|
|
// Heart
|
|
|
|
|
|
- var x = 0, y = 0;
|
|
|
|
|
|
+ const x = 0, y = 0;
|
|
|
|
|
|
- var heartShape = new THREE.Shape() // From http://blog.burlock.org/html5/130-paths
|
|
|
|
|
|
+ const heartShape = new THREE.Shape() // From http://blog.burlock.org/html5/130-paths
|
|
.moveTo( x + 25, y + 25 )
|
|
.moveTo( x + 25, y + 25 )
|
|
.bezierCurveTo( x + 25, y + 25, x + 20, y, x, y )
|
|
.bezierCurveTo( x + 25, y + 25, x + 20, y, x, y )
|
|
.bezierCurveTo( x - 30, y, x - 30, y + 35, x - 30, y + 35 )
|
|
.bezierCurveTo( x - 30, y, x - 30, y + 35, x - 30, y + 35 )
|
|
@@ -207,9 +207,9 @@
|
|
|
|
|
|
// Square
|
|
// Square
|
|
|
|
|
|
- var sqLength = 80;
|
|
|
|
|
|
+ const sqLength = 80;
|
|
|
|
|
|
- var squareShape = new THREE.Shape()
|
|
|
|
|
|
+ const squareShape = new THREE.Shape()
|
|
.moveTo( 0, 0 )
|
|
.moveTo( 0, 0 )
|
|
.lineTo( 0, sqLength )
|
|
.lineTo( 0, sqLength )
|
|
.lineTo( sqLength, sqLength )
|
|
.lineTo( sqLength, sqLength )
|
|
@@ -218,7 +218,7 @@
|
|
|
|
|
|
// Rounded rectangle
|
|
// Rounded rectangle
|
|
|
|
|
|
- var roundedRectShape = new THREE.Shape();
|
|
|
|
|
|
+ const roundedRectShape = new THREE.Shape();
|
|
|
|
|
|
( function roundedRect( ctx, x, y, width, height, radius ) {
|
|
( function roundedRect( ctx, x, y, width, height, radius ) {
|
|
|
|
|
|
@@ -237,7 +237,7 @@
|
|
|
|
|
|
// Track
|
|
// Track
|
|
|
|
|
|
- var trackShape = new THREE.Shape()
|
|
|
|
|
|
+ const trackShape = new THREE.Shape()
|
|
.moveTo( 40, 40 )
|
|
.moveTo( 40, 40 )
|
|
.lineTo( 40, 160 )
|
|
.lineTo( 40, 160 )
|
|
.absarc( 60, 160, 20, Math.PI, 0, true )
|
|
.absarc( 60, 160, 20, Math.PI, 0, true )
|
|
@@ -247,8 +247,8 @@
|
|
|
|
|
|
// Circle
|
|
// Circle
|
|
|
|
|
|
- var circleRadius = 40;
|
|
|
|
- var circleShape = new THREE.Shape()
|
|
|
|
|
|
+ const circleRadius = 40;
|
|
|
|
+ const circleShape = new THREE.Shape()
|
|
.moveTo( 0, circleRadius )
|
|
.moveTo( 0, circleRadius )
|
|
.quadraticCurveTo( circleRadius, circleRadius, circleRadius, 0 )
|
|
.quadraticCurveTo( circleRadius, circleRadius, circleRadius, 0 )
|
|
.quadraticCurveTo( circleRadius, - circleRadius, 0, - circleRadius )
|
|
.quadraticCurveTo( circleRadius, - circleRadius, 0, - circleRadius )
|
|
@@ -258,9 +258,7 @@
|
|
|
|
|
|
// Fish
|
|
// Fish
|
|
|
|
|
|
- var x = y = 0;
|
|
|
|
-
|
|
|
|
- var fishShape = new THREE.Shape()
|
|
|
|
|
|
+ const fishShape = new THREE.Shape()
|
|
.moveTo( x, y )
|
|
.moveTo( x, y )
|
|
.quadraticCurveTo( x + 50, y - 80, x + 90, y - 10 )
|
|
.quadraticCurveTo( x + 50, y - 80, x + 90, y - 10 )
|
|
.quadraticCurveTo( x + 100, y - 10, x + 115, y - 40 )
|
|
.quadraticCurveTo( x + 100, y - 10, x + 115, y - 40 )
|
|
@@ -271,11 +269,11 @@
|
|
|
|
|
|
// Arc circle
|
|
// Arc circle
|
|
|
|
|
|
- var arcShape = new THREE.Shape()
|
|
|
|
|
|
+ const arcShape = new THREE.Shape()
|
|
.moveTo( 50, 10 )
|
|
.moveTo( 50, 10 )
|
|
.absarc( 10, 10, 40, 0, Math.PI * 2, false );
|
|
.absarc( 10, 10, 40, 0, Math.PI * 2, false );
|
|
|
|
|
|
- var holePath = new THREE.Path()
|
|
|
|
|
|
+ const holePath = new THREE.Path()
|
|
.moveTo( 20, 10 )
|
|
.moveTo( 20, 10 )
|
|
.absarc( 10, 10, 10, 0, Math.PI * 2, true );
|
|
.absarc( 10, 10, 10, 0, Math.PI * 2, true );
|
|
|
|
|
|
@@ -284,19 +282,19 @@
|
|
|
|
|
|
// Smiley
|
|
// Smiley
|
|
|
|
|
|
- var smileyShape = new THREE.Shape()
|
|
|
|
|
|
+ const smileyShape = new THREE.Shape()
|
|
.moveTo( 80, 40 )
|
|
.moveTo( 80, 40 )
|
|
.absarc( 40, 40, 40, 0, Math.PI * 2, false );
|
|
.absarc( 40, 40, 40, 0, Math.PI * 2, false );
|
|
|
|
|
|
- var smileyEye1Path = new THREE.Path()
|
|
|
|
|
|
+ const smileyEye1Path = new THREE.Path()
|
|
.moveTo( 35, 20 )
|
|
.moveTo( 35, 20 )
|
|
.absellipse( 25, 20, 10, 10, 0, Math.PI * 2, true );
|
|
.absellipse( 25, 20, 10, 10, 0, Math.PI * 2, true );
|
|
|
|
|
|
- var smileyEye2Path = new THREE.Path()
|
|
|
|
|
|
+ const smileyEye2Path = new THREE.Path()
|
|
.moveTo( 65, 20 )
|
|
.moveTo( 65, 20 )
|
|
.absarc( 55, 20, 10, 0, Math.PI * 2, true );
|
|
.absarc( 55, 20, 10, 0, Math.PI * 2, true );
|
|
|
|
|
|
- var smileyMouthPath = new THREE.Path()
|
|
|
|
|
|
+ const smileyMouthPath = new THREE.Path()
|
|
.moveTo( 20, 40 )
|
|
.moveTo( 20, 40 )
|
|
.quadraticCurveTo( 40, 60, 60, 40 )
|
|
.quadraticCurveTo( 40, 60, 60, 40 )
|
|
.bezierCurveTo( 70, 45, 70, 50, 60, 60 )
|
|
.bezierCurveTo( 70, 45, 70, 50, 60, 60 )
|
|
@@ -310,17 +308,17 @@
|
|
|
|
|
|
// Spline shape
|
|
// Spline shape
|
|
|
|
|
|
- var splinepts = [];
|
|
|
|
|
|
+ const splinepts = [];
|
|
splinepts.push( new THREE.Vector2( 70, 20 ) );
|
|
splinepts.push( new THREE.Vector2( 70, 20 ) );
|
|
splinepts.push( new THREE.Vector2( 80, 90 ) );
|
|
splinepts.push( new THREE.Vector2( 80, 90 ) );
|
|
splinepts.push( new THREE.Vector2( - 30, 70 ) );
|
|
splinepts.push( new THREE.Vector2( - 30, 70 ) );
|
|
splinepts.push( new THREE.Vector2( 0, 0 ) );
|
|
splinepts.push( new THREE.Vector2( 0, 0 ) );
|
|
|
|
|
|
- var splineShape = new THREE.Shape()
|
|
|
|
|
|
+ const splineShape = new THREE.Shape()
|
|
.moveTo( 0, 0 )
|
|
.moveTo( 0, 0 )
|
|
.splineThru( splinepts );
|
|
.splineThru( splinepts );
|
|
|
|
|
|
- var extrudeSettings = { depth: 8, bevelEnabled: true, bevelSegments: 2, steps: 2, bevelSize: 1, bevelThickness: 1 };
|
|
|
|
|
|
+ const extrudeSettings = { depth: 8, bevelEnabled: true, bevelSegments: 2, steps: 2, bevelSize: 1, bevelThickness: 1 };
|
|
|
|
|
|
// addShape( shape, color, x, y, z, rx, ry,rz, s );
|
|
// addShape( shape, color, x, y, z, rx, ry,rz, s );
|
|
|
|
|
|
@@ -338,7 +336,7 @@
|
|
|
|
|
|
addLineShape( arcShape.holes[ 0 ], 0x804000, 150, 0, 0, 0, 0, 0, 1 );
|
|
addLineShape( arcShape.holes[ 0 ], 0x804000, 150, 0, 0, 0, 0, 0, 1 );
|
|
|
|
|
|
- for ( var i = 0; i < smileyShape.holes.length; i += 1 ) {
|
|
|
|
|
|
+ for ( let i = 0; i < smileyShape.holes.length; i += 1 ) {
|
|
|
|
|
|
addLineShape( smileyShape.holes[ i ], 0xf000f0, - 200, 250, 0, 0, 0, Math.PI, 1 );
|
|
addLineShape( smileyShape.holes[ i ], 0xf000f0, - 200, 250, 0, 0, 0, Math.PI, 1 );
|
|
|
|
|