playcanvas / engine Goto Github PK
View Code? Open in Web Editor NEWFast and lightweight JavaScript game engine built on WebGL and glTF
Home Page: https://playcanvas.com
License: MIT License
Fast and lightweight JavaScript game engine built on WebGL and glTF
Home Page: https://playcanvas.com
License: MIT License
Duiring setting the viewport and scissor on drawFullscreenQuad there is issue to rect properties access:
if(rect) {
x = rect.x * w;
y = rect.y * h;
w *= rect.z;
h *= rect.w
}
But if I log rect i see: {"data":{"0":0,"1":0,"2":1,"3":1}
So property is wrong to access to x, y, z, w.
To fix this the posteffectqueue enable function need to use camera.getRect() instead of camera.rect.
Thanks,
Amer
IE currently doesn't have Web Audio, so the engine falls back to HTML5 Audio API. When running SWOOOP locally, the game hangs during audio resource loading. No exception is thrown. Interestingly, if you force the engine to use HTML5 Audio API in Chrome (by hacking the engine), the same hang occurs. Note that when running SWOOOP from apps.playcanvas.com, the loading process gets further (indicating that there may be a timing problem), but throws an exception of InalidStateError when setting currentTime to 0 in Channel.stop.
I am new to Javascript APIs and I'm having trouble distinguishing the engine's public API from its private code.
There seems to be quite a lot of undocumented functionality in the engine which does not show up under the API Reference (such as pc.scene.RENDERSTYLE_WIREFRAME). I've been browsing the source code, but then I encounter areas like src/core which seem to be internal code.
This makes it difficult to tell what I am or am not supposed to call in client code.
Is there any way we can make this clearer? If the API Reference is indeed the canonical definition of the public API, are there any guidelines I can follow to determine whether to submit a patch for missing documentation?
User: pryme8 wants to implement various projectile effects and stated that he'd be interested in seeing an equivalent of the Unity TrailRenderer in PlayCanvas.
http://forum.playcanvas.com/t/development-log/166/12
This could be implemented completely as a script.
Check out this project:
https://playcanvas.com/will/physicsperformance
The shader on the ground plane's material creates a varying for each of the 4 maps (diffuse, normal, specular, opacity). This takes the number of varyings over 8 and the program fails to link on an iPhone, for example, that can support no more than 8 varyings.
If you mouse down on the PlayCanvas canvas but then move the mouse outside the bounds of the canvas and mouse up, PlayCanvas still reports the button as pressed (via the isPressed function).
Perhaps we should be capturing the mouse (see Element.setCapture docs) internally in the engine.
Tests for Gamepad would be nice. Examples, too!
There is no way to set strength of parallax at the moment.
Would be great to have parallax strength property with 0.0 to 2.0 value range, to multiply parallax offset by, same as bumpiness.
After loading a material from the asset the .resource
property which is set for all other assets types, is not set for materials.
The engine now prints this message when running normally: WARNING: Invalid filter mode set on non power of two texture. Forcing linear addressing.
Doesn't seem to cause any issues, but we should be wary of warnings.
We need a way to say that a given light lights a given set of models. This could be automated based on a lights bounding volume or specifiable in the Designer interface (create layer and add models to it and specify the layer on the light).
pc.fw.entity.findByName()
seems to only work for the entitys children, so I would suggest adding getParentByName()
:
getParentByName: function(name){
var tmp = this.entity;
while(tmp.getParent() && tmp.getName() !== name){
tmp = tmp.getParent();
}
if(tmp.getName() === name) return tmp;
else return null;
}
Kind regards,
Aaron
Looks like the gamepad API has changed since the original gamepad support was written.
navigator.webkitGetGamepads' is deprecated. Please use 'navigator.getGamepads' instead.
Scifi demo reportedly broken: http://forum.playcanvas.com/t/broken-gamepad-support/314
See https://playcanvas.com/dave/goingaround
Run from the pack. The characters arms flail while changing animations.
Consider using textureCubeLodEXT
from EXT_shader_texture_lod extension for using MipMap levels to extract different levels of filtering instead of re-uploading individual CubeMaps each bind. 55% supported.
And use individual CubeMaps as fallback.
Having FXAA shader as post effect on Camera, screws up resizing of canvas, adding weird stretching and delay before resize applies. Try resizing window running the demo, or changing orientation on mobile.
Script causing issue: http://code.playcanvas.com/posteffects/posteffect_fxaa.js
Demo to replicate: http://playcanvas.com/max/post-effect-resize-issue/designer/bootstrap?e=d996a0e2-7fbf-11e4-9f8e-12313b0a5ec6
If you disable scripts on camera, or remove fxaa shader, issue vanishes.
Other shaders seems not suffering of such symptoms.
When AO map is applied, entity is fully transparent, looks like failed to generate some shader.
Currently if something slightly goes a bit off planned, it throws exceptions, for example:
The reaction currently it is throwing internal exceptions and very unclear messages to console, that people perceive as engine bug, then it fails to load or work at all.
Desirable behaviour:
Console dev friendly messages with identifiers of error source and explanation of what to look at. Then apply default material, texture, etc just to keep game working even with black textures / blank materials etc.
Scripting
When scripting fails, it starts spawning crazy messages on every update, should it in development mode follow this behaviour: Console dev friendly message with identifiers of error source and pointer to script file + line number, then disable script, and keep going.
That will allow artists to still work with project even if coder is breaking stuff around.
Specific Cases
console.warn
uniform name and material name that tries to set invalid value to.console.warn
ID of unavailable asset, entity name and index of sub-model, that material was referenced in.Changing Culling Mode on entity, has no effect on depth buffer for shadows, and enforce renders entities with depth thrown only by Back Faces (default Culling Mode).
Project with replicated issue: http://playcanvas.com/max/shadow-culling
Notice box that is on light, that has Front Faces Culling Mode.
If there are geometry rendered with material using Additive
Blend Type, PostEffects will be screwed, as they don't set own Blending and will inherit what was set in rendering scene process. Good example would be Bloom PostEffect.
In order to replicate it, have some entity with Additive Blend Type and clone it by keypress, so that it will be at the end of render queue.
I would say it's useful to have a rotational difference between two vectors(eulerAngles). E.g. when applying an angular velocity to rotate an entity into a specific rotation.
sub2rotational: function(lhs, rhs){
var diff = new pc.Vec3();
for(var i=0; i<3; i++){
var tmp = lhs.data[i] - rhs.data[i];
if(tmp > 180) diff.data[i] = -360 + Math.abs(tmp);
else if(tmp < -180) diff.data[i] = 360 - Math.abs(tmp);
else diff.data[i] = tmp;
}
return diff;
}
EDIT:
Hm I've just met a special case where this doesn't work..
Receive Shadows flag makes no difference.
In the Camera component we ignore the alpha value of the clear color.
It would be a powerful addition to allow people to blend between a material property's map or corresponding color. For example, if the diffuse color is red and there is a diffuse map, we can introduce a diffuseMixAmount property (0 to 1) which blends between the color and the map. Current functionality is that the map (if present) simply takes priority over the color.
Currently we do not handle context lost events.
Comments welcome:
How should we handle these?
Is it possible to recover?
I am unable perform keyboard shortcuts (ie. alt+middle-click to pan) in the IDE, or navigate via the WASD keys in an FPS template project. I am using Chromium version 37.0.2030.0 (Developer Build 274814).
e.g.
var q = new pc.Quat();
var p = new pc.Quat();
q.slerp(p,p);
// q is full of NaNs
I'm experimenting with running webGL apps in web workers, by proxying the GL commands over to the main thread. The motivation is that workers never stall the main thread, can do things the main thread cannot (sync binary xhrs), and also this approach can be faster (10% speedup on emscripten'd cube2/bananabread - queuing up gl commands is faster than actually issuing them, freeing up the cpu-intensive thread).
I started to tinker with playcanvas to see how a non-emscripten app does. I haven't quite gotten this to work, but the gl stream seems to be almost correct. Main issue is I'm not familiar with the playcanvas codebase, so for example as I was tracing back a NaN it went into an onSomething call so I don't have a stack trace, and I got confused.
Any interest in getting playcanvas to run in workers? If so it would be great to work together on this. There's probably not much in the way here - the proxying code passes various emscripten tests, works on cube2/bananabread, and on a playcanvas demo as mentioned above, it emits a gl stream that looks almost right barring some NaNs and wrong # of glDrawElements count.
Work is at
https://github.com/kripken/webgl-worker
Basically playcanvas/normal.html runs on the main thread, /worker.html in a worker. The last commit adds an option to show just 1 frame in both, for debugging purposes. There's also a debug branch that adds full gl logging on both.
The function entity.clone()
creates components and loads data using the normal resource loader (even though all resources are already loaded). This means that this code doesn't work:
var newCloneObject = this.masterObject.clone();
newCloneObject.script.scriptName.someVariable = 3;
As clone is async and the script component is not loaded during the clone function.
This problem also applies to addComponent()
clone()
should return an entity with all components completely initialized.
If you have an audiosource component on an entity that is enabled but activate is set to false, the sound will start playing on game load. See Accelerally for an example. The theme shouldn't play until you enter the game.
I'm not sure exactly which version this broke, but it was working in version 0.156.2. No longer working on 0.158.4.
Example: https://playcanvas.com/will/picking
The Frame Buffer version doesn't do anything while the collision shape version does.
Particles stretching does not respect DeltaTime and if camera rotates it will overstretch weirdly, especially if FPS falls.
Demo to replicate problems:
http://playcanvas.com/max/shadow-culling/designer/pack/d61d3d0c-7c7e-11e4-984b-12313b0a5ec6
box_big
will affect that artefact, assuming it is out of range and not cleared.box_big
, and changing that state how it affects shadows too.floor
- it affects yellow and green lights dramatically.As you can see, autoMipMap variable is simply not used, but initialized to true anyway. This forces all textures with any options to have automipmaps, unless user will change this property after creation. I suggest replacing this.autoMipmap = true
withthis.autoMipmap = autoMipMap
var autoMipmap = true;
if (typeof options !== 'undefined') {
width = (typeof options.width !== 'undefined') ? options.width : width;
height = (typeof options.height !== 'undefined') ? options.height : height;
format = (typeof options.format !== 'undefined') ? options.format : format;
cubemap = (typeof options.cubemap !== 'undefined') ? options.cubemap : cubemap;
autoMipmap = (typeof options.autoMipmap !== 'undefined') ? options.autoMipmap : autoMipmap;
}
// PUBLIC
this.name = null;
this.autoMipmap = true;
if (this.autoMipmap && pc.math.powerOfTwo(this._width) && pc.math.powerOfTwo(this._height) && this._levels.length === 1) {
gl.generateMipmap(this._glTarget);
}
It would be useful to be able to play animations backwards by setting a negative speed.
Requested here: http://answers.playcanvas.com/questions/478/play-animation-backwards
The particle system currently ignores the scene's fog settings.
If material blend is set to normal
and opacity
is 1.0 and there is no opacityMap
set, it should blend it as none
to prevent alpha sorting issues.
For ShadowMaps consider using WEBGL_depth_texture instead of pack/unpack for browsers that do support that extension, 82%.
And use pack/unpack as fallback.
Run this:
http://playcanvas.github.io/post_effects/index.html
The post effect scripts are not loading.
Both _createContactPointFromAmmo and _createReverseContactPointFromAmmo dynamically allocate 5 pc.Vec3 objects and 1 ContactPoint object. This burns a lot of performance and generates a lot of garbage.
If on Windows 8 in IE11 Audio API is not supported fully, it will report it's availability but will fail to work.
Installing Media Feature Pack for N and KN versions of Windows 8.1 solves the problem.
Engine should not fail screen and expect such scenario, fallback to basic audio and still run the game. Without media pack it assumed it supports Web Audio API, then tried to load mp3 but failed to decode it, threw exception and just failed to play the game.
Is Audio considered high priority that will lead to big fail if it wont load, or should be considered as not mandatory asset, and potentially can fail to load but still will run the game as that would be expected case scenario.
The change in this commit makes it pretty hard to integrate an HTML-based UI into PlayCanvas. When clicking on an overlay, the mouse events are still handled by PlayCanvas (as if clicking on the canvas) - so you often handle clicks that should be suppressed.
Part of that commit message mentions that it was to fix full screen in Chrome. I've been testing with Chrome and fullscreen for the past couple of months without any issue. Here's what I've been doing / a suggestion for fullscreen functionality:
In framework_application , enableFullscreen starts with this:
enableFullscreen: function (element, success, error) {
element = element || this.canvas;
I've had a lot of success calling enableFullscreen by doing the following:
pc_app.enableFullscreen(document.documentElement);
I'm not 100% sure if this would work, but you could listen for mouse events on the element, and default the element to document.documentElement instead of the canvas.
Under certain circumstances, kinematic bodies can suddenly rotate without being influenced by a PlayCanvas script. On initial inspection, it seems that this is something related to ammo.js but logging here until it can be proved it's actually an ammo problem.
We currently don't expose much of the Audio API through the AudioManager, Channel, Sound interfaces.
This is a request for features that you would like to see added to the API. Please comment on this thread with your requirements.
To repro:
Notice how the loading screen is offset. In the colorTanks/Tanx game, the touch controls are mostly/totally offscreen.
If you create a model procedurally and set it on a model component for rendering, it is not currently possible to also set it on a collision component to make the mesh into a static body. Not using the API anyway. A workaround is to call:
context.systems.collision.addComponent(this.entity, {
type: 'mesh'
});
this.entity.collision.model = model;
context.systems.collision.implementations.mesh.doRecreatePhysicalShape(this.entity.collision);
I was running python build.py and it breaks with index_error because a hg revision check. So, create a hg init into git repo, and it builds ok. Maybe you guys can fix that or put it in documentation/README. :)
I'm not sure if this is the right place to report this, but I ran into an opacity issue earlier today. I have a plane with an opacity map that was working yesterday and this morning, but stopped working at some point in the day. I tracked it down to the PlayCanvas version getting bumped from 0.152.1 to 0.152.2 (exporting the pack and then using 0.152.1 instead makes to opacity work correctly).
Basically, it's not blending correctly except at certain angles. I've got a scene set up with a "Clouds" plane above a city. See this album
There are no pc.gfx.PRIMITIVE_*
constants for the WebGL LINE_LOOP
and TRIANGLE_FAN
drawing modes. I'd like to request that they be added.
Changes would at least involve modifying pc.gfx
and jsonToPrimitiveType
, and pc.scene.Picker
would need review.
I don't know whether there'd be any other implications. I'll look at putting together a pull request.
The line:
this.defaultClearOptions = {
color: [0, 0, 0, 1],
depth: 1,
flags: pc.gfx.CLEARFLAG_COLOR | pc.gfx.CLEARFLAG_COLOR
};
Should be:
this.defaultClearOptions = {
color: [0, 0, 0, 1],
depth: 1,
flags: pc.gfx.CLEARFLAG_COLOR | pc.gfx.CLEARFLAG_DEPTH
};
Probably this is a typo error.
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.