Skip to content

Instantly share code, notes, and snippets.

@ngarske
Last active August 12, 2022 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngarske/82820bfc4240c496bdf08c4ddbb09a68 to your computer and use it in GitHub Desktop.
Save ngarske/82820bfc4240c496bdf08c4ddbb09a68 to your computer and use it in GitHub Desktop.
Let's make some 3D in Svelte (Part 1)
<script lang="ts">
import { Canvas } from "@threlte/core";
import Scene from "./Scene.svelte";
</script>
<div>
<Canvas size={{ width: 1280, height: 720 }}>
<Scene />
</Canvas>
</div>
<style>
div {
height: 100%;
width: 100%;
}
</style>
<script lang="ts">
import {
MeshStandardMaterial,
DoubleSide,
BoxBufferGeometry,
} from "three";
import {
DirectionalLight,
Mesh,
OrbitControls,
PerspectiveCamera,
} from "@threlte/core";
</script>
<PerspectiveCamera position={{ x: 30, y: 10, z: 5 }} fov={24}>
<OrbitControls
target={{ y: 3 }}
/>
</PerspectiveCamera>
<Mesh
geometry={new BoxBufferGeometry(4, 4, 4)}
material={new MeshStandardMaterial({ side: DoubleSide, color: "white" })}
/>
<DirectionalLight position={{ x: 10, y: 10, z: 10 }} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment