Skip to content

Commit

Permalink
Show Toch geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
shezard committed May 29, 2023
1 parent cdcd09b commit 34371ef
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/components/Torch.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,48 @@
<script lang="ts">
import * as THREE from 'three';
import * as SC from 'svelte-cubed';
import type { Position2d } from '$lib/map';
export let position: Position2d;
export let direction = Math.PI / 2;
export let color = 0xfff0f0;
</script>

<SC.PointLight intensity={0.8} position={[position[0], 0.5, position[1]]} distance={10} shadow={true} />
<SC.Group position={[0, -0.1, 0]}>
<SC.PointLight
intensity={0.8}
position={[position[0], 0.4, position[1]]}
distance={10}
shadow={true}
{color}
/>

<SC.Mesh
geometry={new THREE.BoxGeometry(0.05, 0.05, 0.05)}
material={new THREE.MeshLambertMaterial({
color
})}
position={[
position[0] + 0.45 * Math.cos(direction),
0.3,
position[1] + 0.45 * Math.sin(direction)
]}
/>

<SC.Mesh
geometry={new THREE.BoxGeometry(0.055, 0.2, 0.055)}
material={new THREE.MeshLambertMaterial({
color: 0x62351c
})}
position={[
position[0] + 0.5 * Math.cos(direction),
0.2,
position[1] + 0.5 * Math.sin(direction)
]}
rotation={[0.5 * Math.cos(direction + Math.PI / 2), 0, 0.5 * Math.sin(direction + Math.PI / 2)]}
castShadow
/>
</SC.Group>

0 comments on commit 34371ef

Please sign in to comment.