Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 18 additions & 5 deletions src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import * as THREE from 'three'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'
import * as dat from 'dat.gui'

// Loading
const textureLoader=new THREE.textureLoader()

const normalTexture = textureLoader.load("/textures.planet.jpg")


// Debug
const gui = new dat.GUI()

Expand All @@ -13,12 +19,17 @@ const canvas = document.querySelector('canvas.webgl')
const scene = new THREE.Scene()

// Objects
const geometry = new THREE.TorusGeometry( .7, .2, 16, 100 );
const geometry =new THREE.SphereBufferGeometry(.5,64,64)


// Materials

const material = new THREE.MeshBasicMaterial()
material.color = new THREE.Color(0xff0000)
const material = new THREE.MeshStandardMaterial()
material.roughness= 0.2
material.metalness =0.7
material.normalMap =normalTexture;
material.color = new THREE.Color(0x00ddbb)


// Mesh
const sphere = new THREE.Mesh(geometry,material)
Expand Down Expand Up @@ -73,11 +84,13 @@ scene.add(camera)
* Renderer
*/
const renderer = new THREE.WebGLRenderer({
canvas: canvas
canvas: canvas,
alpha: true
})
renderer.setSize(sizes.width, sizes.height)
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))


/**
* Animate
*/
Expand All @@ -96,7 +109,7 @@ const tick = () =>
// controls.update()

// Render
renderer.render(scene, camera)
renderer.render(scene, camera)

// Call tick again on the next frame
window.requestAnimationFrame(tick)
Expand Down
2 changes: 1 addition & 1 deletion src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

html,
body
{
{background-color: darkolivegreen;
height: 100vh;
font-family: 'Poppins';
}
Expand Down
Binary file added static/Textures/planet.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/Textures/sci_fi_normal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.