Skip to content

Commit 4642853

Browse files
author
Alex Anderson
committed
fix(Viewscreen): Adjust the planetary scan viewscreen so the scanner is more interesting and properly frames the planet.
1 parent 7cc7b11 commit 4642853

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

src/components/viewscreens/PlanetaryScan/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const RenderSphere = props => {
1616
return (
1717
<div className="planetary-scan">
1818
<div className="scannerBox" ref={measureRef}>
19-
<div className="scannerBar" />
2019
{dimensions.width && (
2120
<ThreeView
2221
{...props}

src/components/viewscreens/PlanetaryScan/style.scss

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
height: 56vh;
77
position: absolute;
88
overflow: hidden;
9-
border-radius: 50%;
109
}
1110
.scannerBar {
1211
background: linear-gradient(

src/components/viewscreens/PlanetaryScan/threeView.js

+36-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, {Component} from "react";
22
import * as THREE from "three";
3+
import {CircleGeometry, LineLoop, LineBasicMaterial} from "three";
34

45
window.THREE = THREE;
56

@@ -30,7 +31,7 @@ class ThreeView extends Component {
3031
this.scene.add(dirLight);
3132

3233
this.camera.position.y = 1;
33-
this.camera.position.z = 3;
34+
this.camera.position.z = 3.5;
3435
this.camera.lookAt(new THREE.Vector3(0, 0, 0));
3536
this.objectGroup = new THREE.Group();
3637

@@ -68,6 +69,23 @@ class ThreeView extends Component {
6869
this.clouds.visible = true;
6970
}
7071

72+
const geometry = new CircleGeometry(1.1, 32);
73+
geometry.vertices.shift();
74+
const mat1 = new LineBasicMaterial({
75+
color: 0xfac79e,
76+
});
77+
const mat2 = new LineBasicMaterial({
78+
color: 0xfafa9a,
79+
});
80+
81+
this.scannerLine1 = new LineLoop(geometry, mat1);
82+
this.scannerLine1.scale.set(1.1, 1.1, 1.1);
83+
this.objectGroup.add(this.scannerLine1);
84+
85+
this.scannerLine2 = new LineLoop(geometry, mat2);
86+
this.scannerLine2.scale.set(1.15, 1.15, 1.15);
87+
this.objectGroup.add(this.scannerLine2);
88+
7189
this.threeMount.current.appendChild(this.renderer.domElement);
7290
this.animating = true;
7391
this.animate();
@@ -108,6 +126,16 @@ class ThreeView extends Component {
108126
this.clouds.visible = true;
109127
}
110128
}
129+
shouldComponentUpdate(nextProps) {
130+
if (
131+
nextProps.wireframe !== this.props.wireframe ||
132+
nextProps.color !== this.props.color ||
133+
nextProps.planet !== this.props.planet ||
134+
nextProps.clouds !== this.props.clouds
135+
)
136+
return true;
137+
return false;
138+
}
111139
componentWillUnmount() {
112140
this.animating = false;
113141
cancelAnimationFrame(this.frame);
@@ -130,6 +158,13 @@ class ThreeView extends Component {
130158
this.cloudRotation += 0.03;
131159
this.objectGroup.rotation.setFromVector3(rot);
132160
this.clouds.rotation.setFromVector3(cloudRot);
161+
162+
this.scannerLine1.rotation.x += 0.01;
163+
this.scannerLine1.rotateY(0.02);
164+
165+
this.scannerLine2.rotation.x += 0.005;
166+
this.scannerLine2.rotateY(0.03);
167+
133168
this.renderer.render(this.scene, this.camera);
134169
this.frame = requestAnimationFrame(this.animate);
135170
};

0 commit comments

Comments
 (0)