Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Useless3d #152

Merged
merged 4 commits into from
Jan 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"redux-persist": "^6.0.0",
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^2.0.4",
"three": "^0.136.0",
"typescript": "^4.5.4",
"uuid": "^8.3.2",
"web-vitals": "^1.1.2"
Expand Down
6 changes: 6 additions & 0 deletions src/components/Home/AnimatedLogo/AnimatedLogo.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { render } from "@testing-library/react";
import AnimatedLogo from "./AnimatedLogo";

it("renders without crashing", () => {
render(<AnimatedLogo />);
});
45 changes: 45 additions & 0 deletions src/components/Home/AnimatedLogo/AnimatedLogo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, { useEffect } from "react";
import * as THREE from "three/build/three.module";
import PaddleSceneJson from "./scene.json";

/**
* AnimatedLogo component in QuickHit.
*/
function AnimatedLogo(): JSX.Element {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let camera: any, scene: any, renderer: any;

function init(): void {
camera = new THREE.PerspectiveCamera(70, 400 / 150, 0.01, 10);
camera.position.x = 0;
camera.position.y = 0.75;
camera.position.z = 0;
scene = new THREE.ObjectLoader().parse(PaddleSceneJson);
scene.getObjectByName("Group").position.x = 0;
scene.getObjectByName("Group").position.z = -3.5;

renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(400, 150);
renderer.setAnimationLoop(animation);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;

const useless3DDiv = document.getElementById("useless3D");
if (useless3DDiv) {
useless3DDiv.appendChild(renderer.domElement);
}
}

function animation(time: number): void {
scene.getObjectByName("Group").rotation.y = time / 3000;
renderer.render(scene, camera);
}

useEffect(() => {
init();
}, []);

return <div id={"useless3D"} />;
}

export default AnimatedLogo;
Loading