2022-05-03 02:34:11 +00:00
|
|
|
<script>
|
|
|
|
|
import * as THREE from 'three';
|
2022-05-04 02:04:11 +00:00
|
|
|
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
|
2022-05-03 02:34:11 +00:00
|
|
|
import * as SC from 'svelte-cubed';
|
2022-05-04 02:04:11 +00:00
|
|
|
let star;
|
2022-05-04 19:40:27 +00:00
|
|
|
let rotation = 0;
|
2022-05-03 02:34:11 +00:00
|
|
|
|
2022-05-04 19:40:27 +00:00
|
|
|
let loader = new GLTFLoader();
|
2022-05-04 02:04:11 +00:00
|
|
|
loader.load('star.gltf', (gltf) => {
|
|
|
|
|
star = gltf.scene.children[0].geometry;
|
|
|
|
|
});
|
2022-05-04 19:40:27 +00:00
|
|
|
|
|
|
|
|
SC.onFrame(() => {
|
|
|
|
|
rotation += 0.01
|
|
|
|
|
})
|
2022-05-03 02:34:11 +00:00
|
|
|
</script>
|
|
|
|
|
|
2022-05-04 19:46:41 +00:00
|
|
|
<header>
|
|
|
|
|
<div class="star-container">
|
|
|
|
|
<SC.Canvas antialias alpha>
|
|
|
|
|
<SC.Mesh
|
|
|
|
|
geometry={star}
|
|
|
|
|
rotation={[-90, 0, rotation]}
|
|
|
|
|
material={new THREE.MeshStandardMaterial({
|
|
|
|
|
color: 0xffff00,
|
|
|
|
|
roughness: 0,
|
|
|
|
|
metalness: 0.7,
|
|
|
|
|
})}
|
|
|
|
|
/>
|
|
|
|
|
<SC.PerspectiveCamera position={[3, 1, 3]} />
|
|
|
|
|
<SC.AmbientLight intensity={1} />
|
|
|
|
|
<SC.DirectionalLight intensity={0.7} />
|
|
|
|
|
<SC.PointLight intensity={1} position={[2, 5, 2]} />
|
|
|
|
|
</SC.Canvas>
|
|
|
|
|
</div>
|
|
|
|
|
<h1>Star World</h1>
|
|
|
|
|
</header>
|
2022-05-03 02:34:11 +00:00
|
|
|
|
|
|
|
|
<style>
|
2022-05-04 19:46:41 +00:00
|
|
|
header {
|
|
|
|
|
display: flex;
|
|
|
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.star-container {
|
|
|
|
|
position: relative;
|
|
|
|
|
width: 100px;
|
|
|
|
|
height: 100px;
|
2022-05-03 02:34:11 +00:00
|
|
|
}
|
|
|
|
|
</style>
|