cjcliffe / cubicvr.js Goto Github PK
View Code? Open in Web Editor NEWCubicVR 3D Engine, WebGL Edition
Home Page: http://www.cubicvr.org/
CubicVR 3D Engine, WebGL Edition
Home Page: http://www.cubicvr.org/
This line below (in CubicVR.js) makes initializing CubicVR much slower. What should be done about it?
var lc = 1;
while (1) {
if (!lightTest.use(enums.light.type.POINT,lc) || lc === 8) {
base.MAX_LIGHTS=lc;
break;
}
lc++;
}
Add some hooks or an adapter to make it easier to connect third-party post-processing solutions such as seriously.js
Example: http://seriouslyjs.org/drive-in/
Now that the math library is in a much better state it's probably a good time to fix up the logically reversed order on the mat4.multiply function that was carried over from my old C++ software rendering stack -- it's origin isn't CubicVR C++ since it used the OpenGL matrix stack exclusively at the time which is why I needed to quickly grab an old implementation I had available for porting :)
CubicVR.js/source/CubicVR.ScenePhysics.js
Line 280 in fc9d60b
obj_init is first used (line 280) without being declared and can result in leaking a global variable.
It is declared on line 286.
Any minor patches for 0.2.0 should be wrapped up during API documentation and review and ready to align with the 0.2.1 tag release.
I've just tried this on two machines:
In CanvasTexture, change the init to this to let
function CanvasTexture(options) {
var gl = CubicVR.GLCore.gl;
if (options.nodeName === 'VIDEO' || options.nodeName === 'CANVAS' || options.nodeName === 'IMG') {
this.canvasSource = options;
} else {
this.canvasSource = document.createElement('CANVAS');
if (options.width === undefined || options.height === undefined) {
throw new Error('Width and height must be specified for generating a new CanvasTexture.');
} //if
this.canvasSource.width = options.width;
this.canvasSource.height = options.height;
this.canvasContext = this.canvasSource.getContext('2d');
} //if
this.updateFunction = options.update;
this.texture = new CubicVR.Texture();
Trying to load a webm from localhost explodes my computers. Two different machines. Two different gfx cards. Two different gfx drivers. Same linux distro. :/
Buh?
When initializing a new CubicVR object with a given canavs tag, the object should pick up the width and height of the given canvas tag. It should not create the object with the browser size.
This bit of code breaks CubicVR all over and smashes Firefox in the face. Like violent joint-aches on a rainy day.
function Scene( canvas ) {
var gl = CubicVR.init( canvas ),
boxMesh = new CubicVR.Mesh({
primitive: {
type: "box",
size: 1.0,
material: {
textures: {
color: "../images/6583-diffuse.jpg"
}
},
uv: {
projectionMode: "cubic",
scale: [1, 1, 1]
}
},
compile: true
}),
boxObj = new CubicVR.SceneObject( boxMesh ),
scene = new CubicVR.Scene( canvas.width, canvas.height, 60 ),
ml = new CubicVR.MainLoop( function( timer, gl ) {
scene.render();
});
scene.bind(boxObj);
scene.camera.position = [1, 1, 1];
scene.camera.target = [0, 0, 0];
CubicVR.addResizeable(scene);
var mvc = new CubicVR.MouseViewController( canvas, scene.camera );
} //Scene
var scene1 = new Scene( document.getElementById( "canvas1" ) ),
scene2 = new Scene( document.getElementById( "canvas2" ) );
The problem occurs almost right away, initializing boxMesh
. I'm going to take a stab at guessing what the problem might be: buffer compiling?
Currently lights must be positioned in absolute coordinates. Would be more convenient to use if I they were transformable by scene object.
Particle system framework should be as such:
Recreate:
uniform vec4 myUniform;
uniform vec4 myUniform;
void main() {
gl_FragData[0] = myUniform;
}
myShader.myUniform = [1, 1, 1, 1]
We need automated ref tests (e.g., tests against a reference image) so we can write regression tests for CubicVR.js' drawing code. There is a bunch of prior-art here in the processing.js project:
Test Runner: https://github.com/jbuck/processing-js/blob/develop/test/ref/index.html
Test Builder: https://github.com/jbuck/processing-js/blob/develop/test/ref/ref-test-builder.html
A bunch of work has been done to generalize this by another student: https://github.com/cwdesautels/sundae.js Using this might be a good start.
Basically what we want is the following:
The processing.js team (humph, jbuck, pomax) can help you understand how the ref test stuff should work, and ccliffe can answer questions related to CubicVR.js itself.
Replace redundant tests such as:
if (SceneObject.morphWeight !== null) ..
if (SceneObject.morphTarget !== -1) ..
if (SceneObject.morphSource !== -1) ..
with simple flags such as:
if (SceneObject.morphInstance) {
.. assume stuff has been set elsewhere appropriately ..
}
which can be toggled by relevant getters/setters for morph weights.
this should improve performance in key areas as suggested by @secretrobotron and @humphd
Hi,
I have two files with a bunny model. One has 22999 faces and the second one has 20999 faces. Here are the screenshots of the rendered models: 23k faces, 21k faces
The code can be tested on this address:http://www.fi.muni.cz/~xhracho1/cubicvr_issue/
Both of the files were simplified from ply_models/bun_zipper.ply
using MeshLab. Position and material were modified in Blender.
I am using Chromium 17, Ubuntu 11.10., NVIDIA GeForce GT 520M with proprietary drivers.
Having wireframes for select meshes would be great, especially for showing physics meshes (e.g. debug mode).
cclffe and I discussed doing this in a separate pass:
scene.render();
scene.renderWireframes();
The Ambient texture has broken again, samples/cubicvrxml/cubicvr_mesh.html is rendering black.
Not to be completed for this issue but we should probably add a test that can iterate all the common material types and ensure the combinations are producing a correct result.
We need to add support for just updating specific tagged face segments (already supported for visibility and buffer packed in linear order). This will allow updates to specific portions of the mesh data quickly such as localized deformations.
This should wait until the VBO buffering code stabilizes so we're not re-inventing it multiple times.
In, SceneRenderTexture.update, this.renderText.begin binds the frame buffer, but updateShadows sets it back to null. so the scene gets rendered to the screen and not the framebuffer/texture.
The UV offset parameter doesn't respect shader masks, pooled shaders with instances are having issues with values from other UV offsets bleeding into their context.
Creating meshes, sceneobject, textures, materials, etc. usually requires keeping a variable around, and passing into functional bodies that require it.
It would be beneficial to have simple pools to store objects explicitly by name.
var meshPool = new MeshPool();
meshPool.add( "cow", cowMesh );
var scene = new Scene();
scene.addPool( "mesh", meshPool );
assert( meshPool.get( "cow" ) === scene.getMesh( "cow" ) );
There's a lot of Worker work that's happened, including some effort in require.js to get nice event-handling.
Shadows in 0.2.x are broken on ATI HD on iMac, this applies to Mozilla and Chrome so it should be driver/GLSL related.
I've had to make a few patches before due to shoddy ATI drivers so it's not surprising, most likely something that's changed in the GLSL is too much for it to comprehend...
Would be interested to know if any other platforms than Mac are having shadow issues with ATI, please check out the examples and demos in the wiki and see if any of the shadowed ones work.
Firefox complains in the error console when shaders are XHR'ed.
As title states.
Ive hacked my version of the core fragment shader to include fog, liner and exponential, and working on introducing noise. is this something of interest to the overall project? if so, how best to share (I'm a new kid on the block here)?
Noticed that the MouseViewController documentation has not been updated to show the new mouse and keyboard handler options.
Need a way to calculate the lights that apply to each sceneObject so that when rendering we're not doing excessive drawing of objects that are outside the range of a particular light.
Perhaps having an .active_lights array for each sceneObject with two lists in it, one for dynamic and one for static lights (so we can splice them together on render). If the octree can somehow fill these lists on each pass we'd have a forward-run of just visible objects with their active lighting set.
We'll need a static/dynamic flag for objects and lights and hopefully the static stuff can be computed when a light/object is added and the dynamic can be a slightly more efficient system that uses object tracking like we have now.
Right now it's not possible to set the face/point normals through the Mesh constructor, this needs to be patched up.
Now that the COLLADA loader is matured a bit it's time to start dividing it up further into a class that can initialize itself from a COLLADA file and then be used as more of a resource than just a one-shot scene.
Right now we parse and load all the scenes from a COLLADA file but just return the default one and can't extract individual resources without loading the whole thing; this won't be sufficient moving forward.
Someone without any prior experience should evaluate the learning curve required to become proficient in basic CubicVR.js use, based on this information prepare suggestions for API fixes, documentation and sample projects.
I've rewritten most of the octree business in a another lib, which is self-contained and testable in isolation.
CubicVR should use it instead. The code is far less awful than my Java-based Octree implementation. :D
It was suggested here:
http://www.cubicvr.org/index.php?option=com_fireboard&Itemid=62&func=view&catid=5&id=205
That we should implement an ArcBall / Trackball and it might make a nice addition to MouseViewController
Add an AABB-AABB intersection test. Does anyone have a preference of how to return values, since there are 4 cases?
A is inside B
B is inside A
A and B intersect
A and B are disjoint
new CubicVR.Light({type:cubicvr.light.type.DIRECTIONAL,direction:[0.5,-1,0.5]})
can be shortened to look like this:
new CubicVR.Light({type:"directional",direction:[0.5,-1,0.5]})
Lights aren't the only part of CubicVR which would benefit from this syntactical optimization.
A camera positioned at [1,1,1] and targeting [0,0,0] seems to produce a different viewpoint from a camera with position [0,0,0], rotation [0,0,0] bound to a parent object with position [1,1,1] and rotation [-45,45,0]. Why is this?
While discussing another issue with @secretrobotron it came to my attention the possibility of user parameters to the Scene.render() function. Currently it accepts none so this github issue is for possible ideas.
Currently to change the opacity of a material it must initially start at something less than 1.0, such as opacity 0.999, if the opacity is changed the shader does not adapt to support it. This will require a flag check or bitmask to re-initialize the shader when alpha conditions have changed.
This however might attest to a more systematic problem of the lack of a material 'dirty' flag. The ideal here might be to add a general flag to the material to force it to flush it's pool cache and regenerate or reassign on the next draw.
Investigate adding support for the IFC file format:
Examples:
Lighting appears very dark (almost completely invisible) on most of the demos.
Specs:
Win7
Firefox 4
Nvidia GeForce GTX 470
However, looks great on a MacBook Pro.
Need to fix up the constructors so they can all support the #id and myfile.js / myfile.json / myfile.xml passed in place of relevant objects.
setSegment() examples were lost when we removed some tests from the repository. Need to make up or resurrect a sample project.
Rather than running through the manual tests in the tests directory, devs should be able to open a page in their browser and have it run a bunch of reference tests to make sure that a patch doesn't cause a regression.
Hi!
I'm testing your framework and I think I have discovered a bug. In the following function:
set dir(value){
this.direction = vec3.normalize(value.slice(0));
},
You need to define vec3 before or just change it to: base.vec3
At the moment GL_POINTS drawing is unsupported.
In reference to the problem that occurs frequently in #29, add a test that can iterate all the common material types and ensure the combinations are producing a correct result.
If we wish to do a complete test it will likely need to be automated given that the possible shader permutations already exceed half a million (and billions if you include the lighting count per shader) so we may just want to stick to a set of realistic pre-defined parameters.
Here's a thought that came to mind:
Must note that various raytracers will produce different results as well as light choices etc. so we'd need to pick a set of base settings and just use one for comparison or handle it via separate 'profiles' for each renderer.
If this was able to help us produce more accurate images and perhaps core GLSL rendering profiles for various setups it would make fine-tuning materials very simple and advanced production such as integrating rendered video content would be more seamless.
I set up a local server to run http://localhost:9898/samples/polygon/tessellate.html
, which runs fine in Firefox, but not in Chrome.
Uncaught TypeError: Cannot read property 'length' of null CubicVR.Polygon.js:157
var triangles = CubicVR.util.repackArray(triangulated,3,triangulated.length/3);
Before running the sample, I did a fresh pull from this repo.
Browser data:
Google Chrome 22.0.1229.79 (Official Build 158531)
OS Mac OS X
WebKit 537.4 (@129177)
JavaScript V8 3.12.19.11
Flash 11.4.402.265
User Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4
Recently I decided to dive into trying to get Cubic to render to two separate canvases. It didn't work so well.
There are a few things that I think stood in my way:
CubicVR.init( canvas )
before anything. If Cubic is being used as more of a library, there's a bit of a problem. You may want to collect a bunch of objects before initializing a canvas. This seems like the biggest hurdle, and simply hiding the canvas while it's not in use isn't such a huge deal. We don't have to constantly render to it.gl
. Rendering to multiple canvases requires ignoring the gl context that's passed in, and doing the gl.clear
yourself.After some thought, I attempted to use a state-minded approach and settled on GLCore.switchContext
which will alleviate some of the problem by letting the user switch between gl contexts explicitly. Regardless, this solution was suboptimal. I think it makes a lot more sense to try to enclose GLCore within a scope that can be passed to objects when they need it, or have objects spawned out of some closure that has a less-than-globally available GLCore.
Some initial work was done here, but it's far from complete: 716cfd8#commitcomment-638203
Need to change how these work so that they hold a SceneObject like the RigidBody adapter but are not the SceneObject themselves. Also the landscape constructor is currently a list of parameters which doesn't fit with the rest of the API as well as it's currently immovable, wrapping a SceneObject would make performing orient/height calls much easier as we could use it as an inverse transform to make operations relative to the SceneObject.
Right now, it is not possible to specify a file for your shader source for 'CustomShader'. For example:
< script id="vs" src="lib/Shader.vs" type="x-shader/x-vertex">
</ script>
< script id="fs" src="lib/Shader.fs" type="x-shader/x-fragment">
</ script>"
So, it is necessary to put the code on the html page, inside the script tags, like the demos available.
PS: One work around I have made:
On CubicVr.Utility.js, on the 'get' method, after it checks if '(idOrUrl[0] == '#')', I put:
if (url !== null) {
return util.getScriptContents(id);
}
So, if the tag has a 'src' defined, it will load the script from the file :P
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.