Skip to content

jeromeetienne/threex.spaceships

Repository files navigation

threex.spaceships

Threex.spaceships is a three.js game extension to easily display a bunch of spaceships models. It has five different models, it contains 3 space fighters and 2 shuttles, plus the asset to make them shoot at each other. They comes from "free models pack". You can use them to have a whole fleet in your space battle games. You can even have intergalactic battles if you want! Try them out, they are out of this world!

Show Don't Tell

A Screenshot

screenshot

How To Install It

You can install it via script tag

<script src='threex.spaceships.js'></script>

Or you can install with bower, as you wish.

bower install threex.spaceships

How To Use It

When you want to load the SpaceFighter01, just do

THREEx.SpaceShips.loadSpaceFighter01(function(object3d){
	// object3d is the loaded spacefighter
	// now we add it to the scene
	scene.add(object3d)
})

It is the same for SpaceFighter02, just do

THREEx.SpaceShips.loadSpaceFighter02(function(object3d){
	scene.add(object3d)
})

You get the idea. here is how to add SpaceFighter03, Shuttle01 and Shuttle02.

THREEx.SpaceShips.loadSpaceFighter03(function(object3d){
	scene.add(object3d)
})
THREEx.SpaceShips.loadShuttle01(function(object3d){
	scene.add(object3d)
})
THREEx.SpaceShips.loadShuttle02(function(object3d){
	scene.add(object3d)
})

Now suppose you want a SpaceFighter01 which shoots, do the following.

THREEx.SpaceShips.loadSpaceFighter03(function(object3d){
	var spaceship	= object3d
	scene.add(spaceship)

	// the right shoot
	var shoot	= new THREEx.SpaceShips.Shoot()
	shoot.position.x= 0.5
	shoot.position.z= 0.3
	scene.add(shoot)

	// the left shoot
	var shoot	= new THREEx.SpaceShips.Shoot()
	shoot.position.x=-0.5
	shoot.position.z= 0.3
	scene.add(shoot)

	// the right detonation effect
	var detonation	= new THREEx.SpaceShips.Detonation()
	detonation.position.x= 0.5
	detonation.position.z= 0.1
	scene.add(detonation)

	// the left detonation effect
	var detonation	= new THREEx.SpaceShips.Detonation()
	detonation.position.x=-0.5
	detonation.position.z= 0.1
	scene.add(detonation)
})

Possible Improvements

  • add a trail behind the ships and/or their shoots
    • how to do a trail
    • you get a geometry depending on the trail
      • single plane
        • single plane with a lot of segments for details
      • multiple intersecting planes
      • a cylinder
    • how to make it move to appear as it follows the emitter object
    • this is a trail so there is a moving object which emit this trail
    • the moving object will need to push new coordinates to the trail
    • update the trails based on emitter object
      • the coordinates are likely in world axis
      • a quaternion for trail's orientation based on the velocity of emitter object

About

three.js extension to get spaceships

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published