michalbe / cervus Goto Github PK
View Code? Open in Web Editor NEW:video_game: tiny WebGL 3d game engine
License: MIT License
:video_game: tiny WebGL 3d game engine
License: MIT License
#45 added Entity.look_at
which currently always assumes that the look-at rotation should align the object's left
direction with the world`s horizontal plane.
This might be helpful: https://stackoverflow.com/questions/8942950/how-do-i-find-the-orthogonal-projection-of-a-point-onto-a-plane
Let's make it possible to imports parts of the engine so it will treeshake better. It should be possible to use final version this way:
import { Box } from 'cervus/shapes';
import { Phong } from 'cervus/material';
const voxel = new Box({ material: Phong });
It would be nice to have some. Investigate possibilities here.
Some deeper research should be done here, but from what I know today, there are two basic approaches to that topic:
if
statements are slowing shaders down, all the branches should be handled with preprocessor commands. This way shaders handled for instance in Horde3D
.#ifdef CUSTOM_RULES
const).require
kind of tool for glsl
programs.Entity::color.vec
at all then.Scale setter isn't working correctly, it's scaling by
the vector, not to
the vector.
[5, 5, 5]
entity.scale = [1, 1, 1];
entity.local_matrix
was just scaled by [1, 1, 1]
vector.Setting Entity.rotation
to a quarternion should be enough if we expose quat.fromEurler
and quat.setAxisAngle
to the user.
We could possible save space by using Object.assign(this, options)
and a default options
parameter.
When perform_ticks
executes update()
multiple time (when ticks_qty
is > 1), all update()
calls will the the input data stored in game.keys
. Because this code is synchronous, any key events will fire callbacks when the updates are already done.
It would be nice to have an ability to save the current game state as JSON, and then build the game using this JSON.
Related issues:
Where components are inheriting from basic components (like Entity
), and public methods are visible from the editor when not contain _
in name.
For instance, mat4.create
could be implemented as:
return Float32Array.of(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
Perhaps vec3.up
etc. would be sufficient.
Maybe Group
can just be an empty Entity
? Investigate this. If not, they sure can share most of the code.
Right now, if we want to support both, WSAD
& ZQSD
with:
game.camera.get_component(Move).dir_desc['81'] = 'l';
game.camera.get_component(Move).dir_desc['90'] = 'f';
Only the latter will work.
Renderable
Movable
Keep in mind that each component keeps a reference to an Entity it's assigned to, and this Entity has map of components, so standard deepCloning
won't work here.
Related issues:
As a first step here, it would be nice to create cervus bindings to any 3d physics library available.
Most of the current use-cases will want to set position
directly. If needed, move_along
can be used.
And Entity
class should use vectors and math from the Camera
class.
Features like moving, mouse look, rendering, or get_view_matrix
should be abstracted and promoted to separate components which can be enabled/disabled and added/removed to Entities on runtime.
core/math
could simply export const vec3 = ...;
and export const mat4 = ...'
. This will allow the following usage in other files: import { vec3 } from './core/math'; vec3.method_name();
.
Ideas:
Entity
can take a target
entity and follow it all the timeforward
and right
vector then? They probably should - #13).I initially suggested to @michalbe that the Z axis be the "up" axis, to stay in line with Blender. However it's clear to me now that this goes against OpenGL. Let's change it back.
While most of the time this isn't a big issue, it comes up as a problem during the look at and target to rotations. These operations should orient the forward face toward a point. Instead they assume that Z is forward
and they currently orient the up
face.
@stasm ideas?
I mean, fix them, they're broken as hell right now...
When using mouse look it will helpful to provide an option to hide the mouse cursor.
camera
modulecore
or separate moduleCasting rays is something that could be used in collision detection, or mouseclicks on elements.
๐ก Inspirations:
Random utilities added to The Moment Lost In Time.
should be part of Cervus.
Right now it's in milliseconds. Which requires us to do a lot of / 1000
everywhere.
... but bundle only methods that we use in the output file.
Right now they duplicate too much code.
Let's find a way to render multiple cameras to different parts of the screen. This way it will be easy to implement minimaps, VR rendering, etc.
Previous discussion: #23 (comment)
By removing Entity.origin
we can keep the API surface small. The same effect can be achieved by introducing an intermediate parent in the object hierarchy. This solution also has the benefit of being consistent: rotating ancestors results in consistent rotation of all descendants relative to the ancestor's origin. With Entity.origin
it's weird that rotating the entity may not happen around it's (0, 0, 0) point.
it's currently broken and I've removed it in #37. Let's bring it back.
Since basically every 3d software can export FBX format, let's use it in Cervus as well.
The MORPH
component could probably be used in here, but further research is required
to confirm that.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.