Skip to content

Commit

Permalink
New page for Playground
Browse files Browse the repository at this point in the history
  • Loading branch information
Qz07 committed Mar 16, 2024
1 parent 3c0d15b commit ad720b0
Show file tree
Hide file tree
Showing 11 changed files with 348 additions and 9 deletions.
148 changes: 146 additions & 2 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"gsap": "^3.12.5",
"katex": "^0.16.9",
"mathbox": "^2.3.2-rc1",
"svelte-routing": "^2.12.0",
"svelte-tweakpane-ui": "^1.2.2",
"three": "^0.161.0"
}
}
3 changes: 3 additions & 0 deletions src/components/Explorable/Text/Article.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import Spacer from "./Spacer.svelte";
import Bold from "./Bold.svelte";
import Tex from "./Tex.svelte";
import {Link} from 'svelte-routing';
</script>

<div id="title-spacer" class="h-[2500px]" />
Expand Down Expand Up @@ -76,5 +77,7 @@
<Part id="st-13">What is going on?</Part>
</Section>

<!-- <Spacer /> -->

<Spacer />
<Spacer />
19 changes: 19 additions & 0 deletions src/components/Explorable/ToPlayground.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div id="playground">
<div class="flex flex-col gap-5 items-left relative">
<h2 style='font-size: 30px'>To explore the chaotic cycles, hop into the Playground below</h2>
<a href="/playground">
<button class='button'>Playground</button>
</a>
</div>

</div>

<style>
/* Centering styles */
#playground {
display: flex;
justify-content: center; /* Horizontally center */
align-items: center; /* Vertically center */
height: 100vh; /* Full height of the viewport */
}
</style>
104 changes: 103 additions & 1 deletion src/components/Explorable/Visual/Playground.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,106 @@
<script>
import { T } from "@threlte/core";
import { OrbitControls } from "@threlte/extras";
import { Attractor, Collider, RigidBody } from "@threlte/rapier";
import { Checkbox, Folder, Pane, RadioGrid, Slider } from 'svelte-tweakpane-ui';
// import { cameraControls, mesh} from './stores';
import Sun from "./Sun.svelte";
import Earth from "./Earth.svelte";
export let type = "static";
const config = {
static: {
type: "static",
strength: 3,
range: 100,
gravitationalConstant: undefined
}
};
let numberOfBodies = 1;
let showEarth = true;
let isPlaying = true;
let massAmt = 5;
const positionSun= {
1: [-50, 0, 60],
2: [0, 10, -20],
3: [50, 0, 60]
};
</script>

<div class="text-4xl text-center pb-16 my-16">THIS IS THE PLAYGROUND</div>

<T.PerspectiveCamera
position.y={20}
position.z={100}
makeDefault
fov={70}
far={100000}
on:create={({ ref }) => {
ref.lookAt(0, -10, 0);
}}
>
<OrbitControls enableDamping enablePan={true} enableZoom={true} />
</T.PerspectiveCamera>

<T.GridHelper args={[100]} />

<!-- <Earth /> -->
{#if showEarth}
<RigidBody linearVelocity={[0, 5, 0]}>
<Collider shape="ball" args={[1]} mass={10} />
<Earth />
</RigidBody>
{/if}


<!-- Create suns based on the number of bodies -->
{#each Array.from({ length: numberOfBodies }) as _, i}
<T.Group position={positionSun[i+1]}>
<RigidBody
linearVelocity={[Math.random() * 10, Math.random() * 10, 0]}
position={[Math.random() * 100 - 50, Math.random() * 100 - 50, 0]}>
<Collider shape="ball" args={[1]} mass={config[type].strength} />
<Sun />
<!-- <Attractor
range={config[type].range}
gravitationalConstant={config[type].gravitationalConstant}
strength={config[type].strength}
gravityType={type}
/> -->
</RigidBody>
</T.Group>
{/each}

<Attractor
range={config[type].range}
gravitationalConstant={config[type].gravitationalConstant}
strength={config[type].strength}
gravityType={type}
/>

<Pane
position = 'fixed'
title = "Playground"
userExpandable = {true}>
<Folder
userExpandable = {false}
exanded
title = 'Number of Bodies'>
<RadioGrid
bind:value={numberOfBodies}
values={[1,2,3]}/>
<Checkbox
bind:value={showEarth}
label = 'Show Earth'>
</Checkbox>
</Folder>
<!-- <Slider
bind:value = {massAmt}
min = {1}
max = {10}
format = {(v) => v.toFixed(2)}
label = 'Mass1'/> -->
</Pane>
17 changes: 13 additions & 4 deletions src/components/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import Threlte from "./Explorable/Visual/Threlte.svelte";
// import Footer from "./Explorable/Footer.svelte";
// import Playground from "./Explorable/Visual/Playground.svelte";
// import { Canvas } from "@threlte/core";
// import { World } from "@threlte/rapier";
import ToPlayground from "./Explorable/ToPlayground.svelte";
$: if ($loaded) {
// // gsap.set("body", { overflowY: "scroll", overflowX: "visible" });
ScrollTrigger.refresh();
Expand All @@ -26,7 +29,13 @@
</div>
</article>

<!-- <div class="relative flex-col hidden lg:flex">
<Playground />
<Footer />
</div> -->
<ToPlayground />

<!-- <div class="relative flex-col hidden lg:flex"> -->
<!-- <Canvas>
<World gravity={[0, 0, 0]}>
<Playground />
</World>
</Canvas> -->
<!-- <Footer /> -->
<!-- </div> -->
Loading

0 comments on commit ad720b0

Please sign in to comment.