Skip to content
Three.js moving objects
Profile icon
JBloves27

Hiya!

I was experimenting with three.js and I thought about moving objects (such as cubes, spheres, etc.). I tried moving them with codes that came from various sites including the three.js org website, replit, and other websites. However, my conclusion came to failure lol.

If you could help me solve this problem, I would be very glad!
Thanks!

The Repl is attached for more info and you can always ping me on either github, replit, or discord.

You are viewing a single comment. View All
Profile icon
Coder100

as you may know import statement scripts must have type module:

<script src="script.js" type="module"></script>
Profile icon
JBloves27

Yeah, ik, i just used separate script as u can see in code

@Coder100

Profile icon
Coder100

well yeah but script.js still has the error so you should probably remove it to remove conflicts.

@JBloves27

Profile icon
JBloves27

Oh, ok. Uh, and what about my question above?

@Coder100

Profile icon
Hooded-Hacker

@JBloves27
just increase or decrease the position

for instance, say you have a cube named, well, cube

if you wanted to move it, you would do something like

cube.position.x += 1

or

cube.position.y += 1

or

cube.position.z += 1

would be -= for anything else
the link is a demo of movement still going to add jumping
https://replit.com/@UzX/Backup-3D-Platformer-Test-Server#script.js