generated from the-pudding/svelte-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
348 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.