From 7759197b030bdadce618e413bc7212819721d3d2 Mon Sep 17 00:00:00 2001 From: Bradley Shellnut Date: Thu, 5 May 2022 11:30:38 -0700 Subject: [PATCH] Add collision to the cubes and rotation to cubes. --- src/lib/Box.svelte | 16 ++++++++++++---- src/routes/index.svelte | 11 ++++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/lib/Box.svelte b/src/lib/Box.svelte index 7fd05bd..5b8b549 100644 --- a/src/lib/Box.svelte +++ b/src/lib/Box.svelte @@ -2,12 +2,20 @@ import * as SC from 'svelte-cubed'; import * as THREE from 'three'; import * as PE from 'svelte-cannon'; + import * as CANNON from 'cannon-es'; - const position = PE.writableVec3(0,5,0); + const position = PE.writableVec3(0, 5, 0); + let rotation = PE.writableVec3(0, 0, 0); + let velocity = new CANNON.Vec3(1, 1, 1); - - + console.log(e)} mass={1} bind:position={$position} bind:rotation={$rotation} {velocity}> + - \ No newline at end of file + \ No newline at end of file diff --git a/src/routes/index.svelte b/src/routes/index.svelte index caea7a4..08e59bb 100644 --- a/src/routes/index.svelte +++ b/src/routes/index.svelte @@ -3,20 +3,29 @@ import * as THREE from 'three'; import * as PE from 'svelte-cannon'; import Box from '$lib/Box.svelte'; + + let count = 1; + count += 1} /> + - + {#each {length: count } as _} + + {/each} + + \ No newline at end of file