Giter VIP home page Giter VIP logo

indiesoftby / defold-scene3d Goto Github PK

View Code? Open in Web Editor NEW
128.0 6.0 8.0 18.96 MB

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

Home Page: https://indiesoftby.github.io/defold-scene3d/

License: MIT License

Lua 67.06% C++ 23.11% HTML 2.21% GLSL 5.35% JavaScript 2.27%
defold defold-library defold-shaders game-development 3d 3d-graphics

defold-scene3d's Introduction

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.
  • blocksbuster: a re-creation of popular hyper-casual game mechanics.

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.

defold-scene3d's People

Contributors

aglitchman avatar notbadgun avatar subsoap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

defold-scene3d's Issues

Default display size is too large

1920x1080 is large. It would be better to halve what's in the game.project file so it's 960x540.

Reasoning for this is that not all users have large screens and the default display size can cause issues for them if they are running on a PC.

If a larger initial view size is desired it could be set with DefOS based on user configs.

Prepare and release Houdini HDAs

I used SideFX Houdini to prepare all the content included in Scene3D. It's time to release HDAs that I developed for that task.

  • Learn how to release open-source HDAs - they can be in binary/directory formats and should work with Houdini for indies.
  • Clean up Python code.
  • Write documentation.
  • Release.

Basic first person shooter example

FPS games are a common desire to make. We could make a Quake style level with TrenchBroom and find a good workflow for that.

Example would need first person view (maybe with unique models), crosshair stuff, shooting, reloading, maybe multiple guns, maybe grenades. Maybe an enemy too with a body+head hitbox for instant kills.

Could also do a 3rd person shooter example in the style of Fortnite.

Destiny style Sparrow vehicle

Destiny 2 can be played for free on Stadia to reference how sparrows behave.

One feature that's nice about their version is that mouse can be used for turning in a precise way. This would be the main reasoning in adding this vehicle type as an example.

Make follow camera avoid obstacles?

Follow camera does not currently avoid obstacles.

Follow camera could raycast to the player and try to avoid obstacles between it and the player in a smart way.

Convert all content from Kenney's 3D assets to use with Scene3D

Describe the content you'd like
I'd like to use 3D assets from Kenney: https://kenney.nl/assets?q=3d
They are available for free and can be used commercially.

The idea is to:

  1. Mass-convert all the assets from Kenney and put them into a separate repository (defold-scene3d-kenney). The repo will be huge.
  2. Wrap all models into game objects that will have the same components as Scene3D's icon, i.e. mesh, collisionobject, script.
  3. Render previews for all models and put them in repo's README to know what we have.

I think it'll be fun to be able to put any Kenney's 3D put into your scene, modify collision, material, animation and make a game right from the Defold IDE in a "zero-coding" manner.

Describe alternatives you've considered (optional)
It's time-consuming to dig in Kenney's asset library and put them in your scene because you do that one by one.

Jittering of vehicle when display rate is faster than physics

Describe the bug
When turning the vehicle, jittering can be observed if the display frequency rate is beyond the physics

To Reproduce
Steps to reproduce the behavior:

  1. Open demo on display faster than 60hz
  2. Accelerate and turn
  3. See Jittering

Expected behavior
Vehicle should not be jittering while turning.

Hardware (optional)

  • Device: Lenovo Laptop with i5 processor
  • OS: windows 11

Additional context (optional)
Setting the engine display rate to 60 inside the game project file fixes this issue

Block game example

Block game (like Infiniminer / Minecraft) example project.

  • Multiple block types
  • Add block / remove block
  • Block collision
  • AI pathing example (dumb raycasts)
  • Basic combat?
  • Chunking?
  • Dynamic geometry optimization?

Getting started section

Describe the content you'd like
A simple example of the steps to install scene3d into one's project (similar to other extensions)

Describe alternatives you've considered (optional)
Bruteforcing implementation and reading the code in order to guess at how to use it

Additional context (optional)
I am not a C++ developer, so I cannot derive too much meaning from the internal core files such as extension.cpp

Camera3d throwing error when rotation X is exactly -90

Describe the bug
Hello when I tried camera3d, it is throwing error when rotation X is exactly -90. I tried to debug it and it looks like Error is in render3d.lua . viewport.view_right has vector3 with nan values.

image

To Reproduce
Steps to reproduce the behavior:
image
4. Run the game

Expected behavior
Show sphere

Hardware (optional)

Additional context (optional)
Error:

ERROR:SCRIPT: scene3d/render/render3d.lua:98: argument #1 contains one or more values which are not numbers: vmath.vector3(nan, nan, nan)
stack traceback:
  [C]:-1: in function cross
  scene3d/render/render3d.lua:98: in function view_direction
  scene3d/camera/camera3d.script:32: in function update_render
  scene3d/camera/camera3d.script:70: in function <scene3d/camera/camera3d.script:68>

Add useful editor scripts

Editor scripts is a great idea - we should add another issue to discuss it. Something like:

Align selected objects
Rename selected objects
etc...

#7 (comment)

Should compile a list of more useful ideas here / ask the community what 3D related features we could add as editor scripts that would be useful.

Converting screen coordinates to world coordinates

To create 3d hyper-casual games in which control is carried out using "hold and drag", it is necessary that on each device, regardless of the screen resolution, the mouse must travel the same distance in world coordinates, this requires a function or method for translating screen coordinates into world coordinates, which is currently missing or not implemented.

image

Terrain collision example

Need some kind of workflow for making/using patches of terrain which can be shaped in some tool and have its geometry used for collisions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.