Skip to content

Scene3D is a collection of scripts, materials and tools to help you develop 3D games with the Defold game engine.

License

Notifications You must be signed in to change notification settings

notbadgun/defold-scene3d

 
 

Repository files navigation

Scene3D Cover

Scene3D - make 3D games with Defold

Scene3D is a collection of assets to help you developing 3D games with the Defold game engine. Use included prefabs to quickly prototype structures, levels, and to test game mechanics. Try out ideas quickly!

The built-in example scene is available to play online. Controls:

  • WASD to run or drive, SPACE to jump. Mouse to look. 4 to switch between character/car.
  • Special keys: 5 to reload current scene, 6 to load next scene, 0 to toggle photo mode (move the mouse to look, WASD to fly, SPACE to go up, C to go down, M to copy camera settings).
  • In the debug build: 1 to toggle physics debug, 2 to toggle profiler.

Follow further developments:

Showcase

Merge Getaway

Key features

  • Car physics.
  • Character controller.
  • Controls: keyboard, mouse look with a pointer lock.
  • Frustum culling for 3D meshes. Note: now it's better to use Defold's built-in frustum culling.
  • Helper 3D math functions (docs).

Included Assets (i.e. Prefabs)

  • Camera. Options: clear color, FOV, near clip, far clip.
    • First-person mouse-look with a pointer lock support.
    • Orbit camera script to follow an object in a third-person view.
  • Directional Light. Options: ambient color, intensity, light direction, fog color, fog range.
  • Chunked Floor. Spawns objects from a factory to make an "infinite" world around an object.
  • Late Update. It calls your scripts after all update functions have been called and physics objects have been moved.
  • Request more or contribute.

Debugging

  • Photo mode: press 0 to capture controls and observe the scene. The mode controls: move the mouse to look, WASD to fly, SPACE to go up, C to go down, M to copy camera settings, Enter to take a screenshot.

Buildings

  • Floor: 1x1, 2x2, 5x5, 10x10.
  • Walls: 0.1x1x3, 0.1x5x3, 0.1x10x3.
  • Blocks: 1x1x1, 3x3x3, 5x5x5.
  • Walls with door frames.
  • Walls with window frames.
  • Stairs 1x1.
  • Ramps 1x1, 3x3, 1x2, 3x6.

Environment

  • Sky: texture mapped on sphere.

Icons

  • Arrow (right), cog, flag, flash, heart, home, key, location, lock closed/open, music, puzzle, spanner, star, tick, video.
  • Letters A-Z, numbers 0-9.

Primitives

  • Cone.
  • Cube.
  • Cylinder.
  • Pyramid.
  • Sphere.
  • Tube.

Props

  • Road cone.
  • Soccerball.

Visual Effects

  • Blob shadows (implemented as projected 2D sprites).

Materials

  • basic_color.material - colors your model + the simplest shading. The mesh should have the "color" stream.
  • basic_grid_*.material - it puts a texture on your objects without having to make UV’s.
  • basic_unlit.material - the simplest possible textured material. sky.material is the same but with a different tag.
  • primitive_*.material - no textures, only applies tint on your model.

Some materials have a tint from the palette: #687378 Nickel, #d9d9d3 Timberwolf, #38b2cb Pacific Blue, #0baaad Verdigris, #94d2bd Middle Blue Green, #e9d8a6 Medium Champagne, #ffcd70 Maximum Yellow Red, #fd905e Atomic Tangerine, #ef766b Salmon, #e2797d Candy Pink.

Included shaders don't apply gamma correction.

Current Status

⚠️ Work in progress ⚠️

  • ✔️ It's suitable for production, but be aware that API, scripts, project structure aren't in a finished state and may be changed.
  • ✔️ If you are making the game with Scene3D, follow the optimization section below before releasing your game.

How To Use

Before You Start

Scene3D uses the metric system, i.e. metres as its default unit for measuring distance/length, i.e. 1 unit is 1 meter.

  • Coordinate system: OpenGL, i.e. a right-handed system - the positive x-axis is to your right, the positive y-axis is up and the positive z-axis is backwards. The forward direction is vmath.vector3(0, 0, -1).

Installation

Use it in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add the link to the ZIP file.

Required Dependencies

  • Pointer Lock (only if a project uses mouse_look.script or the debug_ui.collection prefab).

Optional Dependencies

Scene3D can use the following dependencies if you include them in your project:

Included Scenes

  • playground: a playable level with a first-person character controller and a car. Loaded first.
  • basic_3d: use it as a template to start developing a new 3D project/scene.
  • shadows: a scene to test shadows.

math3d.lua

The table briefly describes the included helper math functions. The source code of math3d.lua has more detailed explanation.

Lua Function Description Corresponding Unity API
Quaternions
math3d.euler_x(q) Returns the Euler angle representation of a rotation, in degrees - X. Quaternion.eulerAngles.x
math3d.euler_y(q) Returns the Euler angle representation of a rotation, in degrees - Y. Quaternion.eulerAngles.y
math3d.euler_z(q) Returns the Euler angle representation of a rotation, in degrees - Z. Quaternion.eulerAngles.z
math3d.quat_inv(q) Returns the inverse of rotation. Quaternion.Inverse
math3d.quat_look_rotation(forward, upwards) Creates a rotation with the specified forward and upwards directions. Quaternion.LookRotation
Math
math3d.clamp(x, min, max) Clamps the given x between the given minimum float and maximum float values. Mathf.Clamp
math3d.clamp01(x) Clamps x between 0 and 1 and returns value. Mathf.Clamp
math3d.delta_angle(a, b) Calculates the shortest difference between two given angles (in degrees). Mathf.DeltaAngle
math3d.inverse_lerp(t, a, b) Calculates the lerp parameter between of two values. Mathf.InverseLerp
math3d.lerp(t, a, b, [dt]) Linearly interpolates between a and b by t. The parameter t is clamped to the range [0, 1]. Mathf.Lerp
math3d.lerp_angle(t, a, b, [dt]) Same as vmath.lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. Mathf.LerpAngle
math3d.limited_lerp(t, a, b, max_step) Same as vmath.lerp but max_step limits the increment of value. -
math3d.move_towards(a, b, max_delta) Moves the a value towards b. Mathf.MoveTowards
math3d.ping_pong(t, length) Pingpongs the value t, so that it is never larger than length and never smaller than 0. Mathf.PingPong
math3d.repeat_(t, length) Loops the value t, so that it is never larger than length and never smaller than 0. Mathf.Repeat
math3d.sign(x) Returns the sign of x. Mathf.Sign
math3d.smooth_step(x, min, max) Interpolates between min and max with smoothing at the limits. Mathf.SmoothStep
math3d.smooth_damp(a, b, cur_velocity, smooth_time, max_speed, dt) Gradually changes a value towards a desired goal over time. Mathf.SmoothDamp
math3d.smooth_damp_angle(a, b, cur_velocity, smooth_time, max_speed, dt) Gradually changes an angle given in degrees towards a desired goal angle over time. Mathf.SmoothDampAngle
Camera
render3d.screen_to_world(x, y, z, [world_coord]) Transforms a point from screen space into world space. Camera.ScreenToWorldPoint
Noise
scene3d.simplex_noise2(x, y) Generates 2D Perlin noise. Output range is [0, 1]. Mathf.PerlinNoise

Known Issues

  • Frustum culling uses camera matrices from the previous frame.

Optimization

TODO

... Add information about the over-use of scripts and how to optimize them. ... Add info about shaders optimization, downsizing meshes buffers.

Vote For The Issues

The following issues are critical for the further development of Scene3D. Please put 👍👍👍 on them!

Editor Issues

Contributing to Scene3D

👍🎉 First off, thanks for taking the time to contribute! 🎉👍

Scene3D tries to follow the principles:

  • Developer-friendly: it should be user-friendly and have a comfortable learning curve to make it a good choice for developers of any experience.
  • Mobile-friendly: it should be able to run on mobile and web platforms.
  • Ready-to-use: the included components should be ready for production.

When creating a bug report, please include as many details as possible. If you find a Closed issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one.

Please, follow code formatting style of the project:

Credits

Artsiom Trubchyk (@aglitchman) is the current Scene3D owner within Indiesoft and is responsible for the open source repository.

Contributors

  1. Brian Kramer (@subsoap)
  2. Be the next!

License

The content and sources are licensed under the MIT license.

Third-Party Licenses & Acknowledgements

  • The excellent POLYGON Prototype Pack by Synty inspired a collection of prefabs for mechanics & level prototyping.
  • 3D icons shapes are based on Typicons by Stephen Hutchings, CC BY-SA 4.0 License.
  • Nunito Sans are licensed under the Open Font license.

About

Scene3D is a collection of scripts, materials and tools to help you develop 3D games with the Defold game engine.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Lua 67.5%
  • C++ 22.8%
  • GLSL 5.3%
  • JavaScript 2.2%
  • HTML 2.2%