Skip to content

Commit 897a24a

Browse files
committed
Removed unnecessary stuff from webpack config, threejs demo++
1 parent 8d7b487 commit 897a24a

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ module.exports = {
1515
},
1616
"rules": {
1717
"no-console": "off",
18+
"no-unused-vars": 1
1819
}
1920
};

public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<meta charset="UTF-8"/>
55
<meta name="author" content="Brandon Morrissey"/>
6+
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
67

78
<title>Blam</title>
89

src/client/client.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,52 @@
11
import * as THREE from 'three';
2+
import { FirstPersonControls } from 'three/examples/jsm/controls/FirstPersonControls';
23

4+
// The scene object.
35
const scene = new THREE.Scene();
46

7+
// Used to track time deltas.
8+
const clock = new THREE.Clock();
9+
10+
// Create a camera object.
511
const camera = new THREE.PerspectiveCamera(90, window.innerWidth / window.innerHeight, 0.1, 1000);
612
camera.position.z = 10;
713

14+
// Create a renderer, append it to the document body.
815
const renderer = new THREE.WebGLRenderer({ antialias: true });
916
renderer.setSize(window.innerWidth, window.innerHeight);
1017
renderer.setPixelRatio(window.devicePixelRatio);
1118
renderer.setClearColor(0x000000, 1);
1219

13-
document.body.appendChild(renderer.domElement);
20+
document.body.appendChild(renderer.domElement)
21+
22+
// First person camera controller.
23+
const controls = new FirstPersonControls(camera, renderer.domElement);
24+
controls.movementSpeed = 5;
25+
controls.lookSpeed = 0.5;
1426

27+
// Create a cube mesh with a geometry (shape) + material (color), add to scene.
1528
const geometry = new THREE.BoxGeometry();
1629
const material = new THREE.MeshBasicMaterial({ color: 0x87E0FF });
1730
const cube = new THREE.Mesh(geometry, material);
1831

19-
console.log(cube);
20-
2132
scene.add(cube);
2233

34+
// Adjust renderer, aspect ratio on resize.
35+
window.addEventListener('resize', () => {
36+
renderer.setSize(window.innerWidth, window.innerHeight);
37+
camera.aspect = window.innerWidth / window.innerHeight;
38+
camera.updateProjectionMatrix();
39+
});
40+
41+
// Core loop.
2342
function animate() {
2443
requestAnimationFrame(animate);
44+
45+
controls.update(clock.getDelta());
2546
renderer.render(scene, camera);
47+
2648
cube.rotation.x += 0.01;
2749
cube.rotation.y += 0.01;
2850
}
2951

3052
animate();
31-
32-
function onWindowResize() {
33-
renderer.setSize(window.innerWidth, window.innerHeight);
34-
camera.aspect = window.innerWidth / window.innerHeight;
35-
camera.updateProjectionMatrix();
36-
}
37-
38-
window.addEventListener('resize', onWindowResize);

webpack.client.config.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
const path = require('path');
2-
const webpack = require('webpack');
32

43
const www = path.join(__dirname, 'public');
54
const nodeModules = path.join(__dirname, 'node_modules');
65
const server = path.join(__dirname, 'src/server');
76
const client = path.join(__dirname, 'src/client/client');
87

9-
const definePlugin = new webpack.DefinePlugin({
10-
CANVAS_RENDERER: JSON.stringify(true),
11-
WEBGL_RENDERER: JSON.stringify(true)
12-
});
13-
148
module.exports = {
159
mode: 'development',
1610
devtool: 'inline-source-map',
17-
plugins: [ definePlugin ],
1811
entry: {
1912
app: client
2013
},

0 commit comments

Comments
 (0)