#Trying to add a basic plane with a texture

18 messages · Page 1 of 1 (latest)

strange badger
#
const texture = new THREE.TextureLoader().load( 'foo.jpg' )
const geometry = new THREE.PlaneGeometry()
const material = new THREE.MeshBasicMaterial({ map: texture })
const mesh = new THREE.Mesh(geometry, material)
scene.add(mesh)
tepid ibex
#

where do i put that? inside a function?

strange badger
#

what function, you have an index.js no?

#

what are your using to build this project, which tools do you use? a bundler? a server?

tepid ibex
#

sorry, im new to this and its all confusing. I'm on code sandbox.

strange badger
#

codesandbox is a very good choice

tepid ibex
#

thanks:)

#

if i put that code inside my index.js, it comes up red

strange badger
tepid ibex
#

thanks paul, just so i understand, what is const used for?

#

because when im creating things, im not sure what to put inside a function, what const is and why i use them

strange badger
#

a constant variable, you cant change it no more

tepid ibex
#

and it doesn't have to go inside a function

strange badger
#

const a = 1
a = 2 // nope

let a = 1
a = 2 // ok

#

i think you should go through a javascript crash course before touching three. three is complex. definitively know the difference between const/let before you attempt it 😁

tepid ibex
#

that makes sense:)

strange badger
#

also make sure to understand promises and async/await, without this you don't need to start

tepid ibex
#

yeah i probably should, im trying to do this uni project and i dont really understand the basics