Skip to content
Snippets Groups Projects
Commit 7807a065 authored by Sandro Weber's avatar Sandro Weber Committed by Manos Angelidis
Browse files

Merged in NRRPLT-7542_robot-designer-mirror (pull request #34)


[NRRPLT-7542] robot designer changes, prettify toolchain

Approved-by: default avatarManos Angelidis <angelidis@fortiss.org>
Approved-by: default avatarAxel von Arnim <axel.vonarnim@fortiss.org>
parent 105f600a
No related branches found
No related tags found
No related merge requests found
Showing
with 10205 additions and 10754 deletions
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
# Change these settings to your own preference
indent_style = space
indent_size = 2
# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
package.json package.json
gz3d/utils/package.json gz3d/utils/package.json
gz3d/utils/Gruntfile.js
gz3d/client/js
bower_components
node_modules
build
cmake
gzbridge
http
\ No newline at end of file
{
"singleQuote": true
}
{ {
"name": "gz3d-hbp", "name": "gz3d-hbp",
"description": "3D rendering component of gzweb, modified for HBP", "description": "3D rendering component of gzweb, modified for HBP",
"version": "2.3.2", "version": "2.3.2",
"private": true, "private": true,
"repository": { "repository": {
"url": "git+ssh://bbpcode.epfl.ch/neurorobotics/gzweb", "url": "git+ssh://bbpcode.epfl.ch/neurorobotics/gzweb",
"type": "git" "type": "git"
}, },
"main": [ "main": ["gz3d/build/gz3d.js"],
"gz3d/build/gz3d.js"
],
"dependencies": { "dependencies": {
"three.js": "threejs#r89", "three.js": "threejs#r89",
"eventemitter2": "latest", "eventemitter2": "latest",
"xml2json": "latest", "xml2json": "latest",
"roslibjs": "~0.17.0", "roslibjs": "~0.17.0",
"lodash": "^4.15.0" "lodash": "^4.15.0"
}, },
"keywords": [ "keywords": ["gzweb", "rendering", "webgl", "three.js", "hbp"],
"gzweb", "authors": ["Sandro Weber <webers@in.tum.de>"],
"rendering",
"webgl",
"three.js",
"hbp"
],
"authors": [
"Sandro Weber <webers@in.tum.de>"
],
"ignore": [ "ignore": [
"**/.*", "**/.*",
"bower_components/", "bower_components/",
"build/", "build/",
"cmake/", "cmake/",
"gz3d/client/js/external/", "gz3d/client/js/external/",
"gz3d/http/", "gz3d/http/",
"gz3d/src/", "gz3d/src/",
"gz3d/utils/", "gz3d/utils/",
"gzbridge/", "gzbridge/",
"hbp/", "hbp/",
"http/", "http/",
"node_modules/", "node_modules/",
"tools/", "tools/",
"Gruntfile.js", "Gruntfile.js",
"package.json", "package.json",
"*.sh", "*.sh",
"*.py", "*.py",
"*.html", "*.html",
"README", "README",
"CMakeLists.txt" "CMakeLists.txt"
] ]
} }
\ No newline at end of file
This diff is collapsed.
...@@ -150,11 +150,11 @@ ...@@ -150,11 +150,11 @@
} }
} }
function setRoscmdListener(fn){ function setRoscmdListener(fn) {
connections[url].roscmdListener = fn; connections[url].roscmdListener = fn;
} }
function removeRoscmdListener(){ function removeRoscmdListener() {
delete connections[url].roscmdListener; delete connections[url].roscmdListener;
} }
} }
......
var GZ3D = GZ3D || { var GZ3D = GZ3D || {
REVISION : '1', REVISION: '1',
assetsPath: 'http://localhost:8080/assets', assetsPath: 'http://localhost:8080/assets',
webSocketUrl: 'ws://localhost:7681', webSocketUrl: 'ws://localhost:7681',
webSocketToken: undefined, webSocketToken: undefined,
isRobot: function (model) { isRobot: function(model) {
return false; return false;
} }
}; };
\ No newline at end of file
GZ3D.AnimatedModel = function(scene) { GZ3D.AnimatedModel = function(scene) {
this.scene = scene; this.scene = scene;
this.loader = null; this.loader = null;
...@@ -6,11 +5,13 @@ GZ3D.AnimatedModel = function(scene) { ...@@ -6,11 +5,13 @@ GZ3D.AnimatedModel = function(scene) {
GZ3D.AnimatedModel.prototype.loadAnimatedModel = function(modelName) { GZ3D.AnimatedModel.prototype.loadAnimatedModel = function(modelName) {
this.loader = new THREE.ColladaLoader(); this.loader = new THREE.ColladaLoader();
this.loader.textureLoadedCallback = ()=>{this.scene.refresh3DViews();}; this.loader.textureLoadedCallback = () => {
this.scene.refresh3DViews();
};
// Helper function to enable 'skinning' property so three.js treats meshes as deformable // Helper function to enable 'skinning' property so three.js treats meshes as deformable
var enableSkinning = function (skinnedMesh) { var enableSkinning = function(skinnedMesh) {
var materials = skinnedMesh.material.materials; var materials = skinnedMesh.material.materials;
if (materials !== null && materials !== undefined) { if (materials !== null && materials !== undefined) {
for (var i = 0, length = materials.length; i < length; i++) { for (var i = 0, length = materials.length; i < length; i++) {
...@@ -35,121 +36,127 @@ GZ3D.AnimatedModel.prototype.loadAnimatedModel = function(modelName) { ...@@ -35,121 +36,127 @@ GZ3D.AnimatedModel.prototype.loadAnimatedModel = function(modelName) {
element.done = false; element.done = false;
GZ3D.assetProgressData.assets.push(element); GZ3D.assetProgressData.assets.push(element);
var scene = this.scene; var scene = this.scene;
this.loader.load(element.url, function (collada) { this.loader.load(
var modelParent = new THREE.Object3D(); element.url,
modelParent.name = modelName + '_animated'; function(collada) {
var linkParent = new THREE.Object3D(); var modelParent = new THREE.Object3D();
modelParent.name = modelName + '_animated';
// Set gray, phong-shaded material for loaded model var linkParent = new THREE.Object3D();
collada.scene.traverse(function (child)
{ // Set gray, phong-shaded material for loaded model
if (child instanceof THREE.Mesh) collada.scene.traverse(function(child) {
{ if (child instanceof THREE.Mesh) {
var applyDefaultMaterial = true; var applyDefaultMaterial = true;
if (child.material instanceof THREE.MultiMaterial) if (child.material instanceof THREE.MultiMaterial) {
{ if (
if (child.material.materials[0].pbrMaterialDescription !== undefined) child.material.materials[0].pbrMaterialDescription !== undefined
{ ) {
child.material = child.material.materials[0]; child.material = child.material.materials[0];
applyDefaultMaterial = false;
}
} else if (child.material instanceof THREE.MeshPhongMaterial) {
applyDefaultMaterial = false; applyDefaultMaterial = false;
} }
}
else if (child.material instanceof THREE.MeshPhongMaterial)
{
applyDefaultMaterial = false;
}
if (applyDefaultMaterial) if (applyDefaultMaterial) {
{ var transparentMaterial = new THREE.MeshPhongMaterial({
var transparentMaterial = new THREE.MeshPhongMaterial({ color: 0x707070 }); color: 0x707070
transparentMaterial.wireframe = false; });
child.material = transparentMaterial; transparentMaterial.wireframe = false;
child.material = transparentMaterial;
}
} }
} });
});
// Enable skinning for all child meshes // Enable skinning for all child meshes
collada.scene.traverse(function (child) { collada.scene.traverse(function(child) {
if (child instanceof THREE.SkinnedMesh) { if (child instanceof THREE.SkinnedMesh) {
enableSkinning(child); enableSkinning(child);
} }
}); });
linkParent.add(collada.scene); linkParent.add(collada.scene);
// Hide model coordinate frames for the time being; remove as soon as position offset and rotation axis issues are fixed // Hide model coordinate frames for the time being; remove as soon as position offset and rotation axis issues are fixed
/*var collada_scene_axes = new THREE.AxisHelper(2); /*var collada_scene_axes = new THREE.AxisHelper(2);
linkParent.add(collada_scene_axes);*/ linkParent.add(collada_scene_axes);*/
modelParent.add(linkParent); modelParent.add(linkParent);
// Hide model coordinate frames for the time being; remove as soon as position offset and rotation axis issues are fixed // Hide model coordinate frames for the time being; remove as soon as position offset and rotation axis issues are fixed
/*var model_parent_axes = new THREE.AxisHelper(4); /*var model_parent_axes = new THREE.AxisHelper(4);
modelParent.add(model_parent_axes);*/ modelParent.add(model_parent_axes);*/
// Use scale, position, and rotation offsets provided in animated robot model specification // Use scale, position, and rotation offsets provided in animated robot model specification
var p = GZ3D.animatedModel.visualModelParams; var p = GZ3D.animatedModel.visualModelParams;
modelParent.scale.x = modelParent.scale.y = modelParent.scale.z = p[6]; modelParent.scale.x = modelParent.scale.y = modelParent.scale.z = p[6];
modelParent.position.x = modelParent.position.x + p[0] ; modelParent.position.x = modelParent.position.x + p[0];
modelParent.position.y = modelParent.position.y + p[1]; modelParent.position.y = modelParent.position.y + p[1];
modelParent.position.z = modelParent.position.z + p[2]; modelParent.position.z = modelParent.position.z + p[2];
modelParent.rotation.x = modelParent.rotation.x + p[3]; modelParent.rotation.x = modelParent.rotation.x + p[3];
modelParent.rotation.y = modelParent.rotation.y + p[4]; modelParent.rotation.y = modelParent.rotation.y + p[4];
modelParent.rotation.z = modelParent.rotation.z + p[5]; modelParent.rotation.z = modelParent.rotation.z + p[5];
// Build list of bones in rig, and attach it to scene node (userData) for later retrieval in animation handling // Build list of bones in rig, and attach it to scene node (userData) for later retrieval in animation handling
var getBoneList = function (object) { var getBoneList = function(object) {
var boneList = []; var boneList = [];
if (object instanceof THREE.Bone) { if (object instanceof THREE.Bone) {
boneList.push(object); boneList.push(object);
} }
for (var i = 0; i < object.children.length; i++) { for (var i = 0; i < object.children.length; i++) {
boneList.push.apply(boneList, getBoneList(object.children[i])); boneList.push.apply(boneList, getBoneList(object.children[i]));
} }
return boneList; return boneList;
}; };
var boneList = getBoneList(collada.scene); var boneList = getBoneList(collada.scene);
var boneHash = {}; var boneHash = {};
for (var k = 0; k < boneList.length; k++) { for (var k = 0; k < boneList.length; k++) {
boneHash[boneList[k].name] = boneList[k]; boneHash[boneList[k].name] = boneList[k];
} }
// Skeleton visualization helper class // Skeleton visualization helper class
var helper = new THREE.SkeletonHelper(collada.scene); var helper = new THREE.SkeletonHelper(collada.scene);
boneHash['Skeleton_Visual_Helper'] = helper; boneHash['Skeleton_Visual_Helper'] = helper;
modelParent.userData = boneHash; modelParent.userData = boneHash;
helper.material.linewidth = 3; helper.material.linewidth = 3;
// Hide skeleton helper for the time being // Hide skeleton helper for the time being
// TODO: Make this configurable for visualizing the underlying skeleton // TODO: Make this configurable for visualizing the underlying skeleton
helper.visible = false; helper.visible = false;
that.scene.add(helper); that.scene.add(helper);
that.scene.add(modelParent); that.scene.add(modelParent);
that.scene.applyComposerSettingsToModel(modelParent); that.scene.applyComposerSettingsToModel(modelParent);
// Progress update: execute callback // Progress update: execute callback
element.done = true; element.done = true;
if (GZ3D.assetProgressCallback) { if (GZ3D.assetProgressCallback) {
GZ3D.assetProgressCallback(GZ3D.assetProgressData); GZ3D.assetProgressCallback(GZ3D.assetProgressData);
} }
}, function(progress){ },
element.progress = progress.loaded; function(progress) {
element.totalSize = progress.total; element.progress = progress.loaded;
element.error = progress.error; element.totalSize = progress.total;
if (GZ3D.assetProgressCallback) { element.error = progress.error;
GZ3D.assetProgressCallback(GZ3D.assetProgressData); if (GZ3D.assetProgressCallback) {
GZ3D.assetProgressCallback(GZ3D.assetProgressData);
}
} }
}); );
}; };
GZ3D.AnimatedModel.prototype.updateJoint = function(robotName, jointName, jointValue, jointAxis) { GZ3D.AnimatedModel.prototype.updateJoint = function(
robotName,
jointName,
jointValue,
jointAxis
) {
// Check if there is an animated model for it on the client side // Check if there is an animated model for it on the client side
var entity = this.scene.getByName(robotName + '_animated'); var entity = this.scene.getByName(robotName + '_animated');
if (entity) { if (entity) {
...@@ -157,7 +164,10 @@ GZ3D.AnimatedModel.prototype.updateJoint = function(robotName, jointName, jointV ...@@ -157,7 +164,10 @@ GZ3D.AnimatedModel.prototype.updateJoint = function(robotName, jointName, jointV
var boneName = jointName; var boneName = jointName;
// Retrieve bone instance from userData map of bone instances in animated model // Retrieve bone instance from userData map of bone instances in animated model
if (entity.userData[boneName] !== undefined && entity.userData[boneName] !== null) { if (
entity.userData[boneName] !== undefined &&
entity.userData[boneName] !== null
) {
var targetBone = entity.userData[boneName]; var targetBone = entity.userData[boneName];
var rotationAxis = jointAxis; var rotationAxis = jointAxis;
var rotationAngle = jointValue; var rotationAngle = jointValue;
......
GZ3D.VisualMuscleModel = function(scene, robotName) { GZ3D.VisualMuscleModel = function(scene, robotName) {
this.scene = scene; this.scene = scene;
this.cylinderShapes = {}; this.cylinderShapes = {};
...@@ -12,15 +11,12 @@ GZ3D.VisualMuscleModel = function(scene, robotName) { ...@@ -12,15 +11,12 @@ GZ3D.VisualMuscleModel = function(scene, robotName) {
}; };
GZ3D.VisualMuscleModel.prototype.setVisible = function(visible) { GZ3D.VisualMuscleModel.prototype.setVisible = function(visible) {
this.rootGroup.visible = visible; this.rootGroup.visible = visible;
}; };
GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) { GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) {
if (message.robot_name === this.robotName) { if (message.robot_name === this.robotName) {
if (this.last_muscle_count !== message.muscle.length) if (this.last_muscle_count !== message.muscle.length) {
{
// Compute the radius as fraction of the average length of all cylinders. // Compute the radius as fraction of the average length of all cylinders.
var total_length = 0; var total_length = 0;
for (var k1 = 0; k1 < message.muscle.length; ++k1) { for (var k1 = 0; k1 < message.muscle.length; ++k1) {
...@@ -41,9 +37,9 @@ GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) { ...@@ -41,9 +37,9 @@ GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) {
var activation = message.muscle[k].activation; var activation = message.muscle[k].activation;
var color; var color;
if (message.muscle[k].isMuscle) { if (message.muscle[k].isMuscle) {
color = new THREE.Color(activation, 0, 1-activation); color = new THREE.Color(activation, 0, 1 - activation);
} else { } else {
color = new THREE.Color(activation, 1-activation, 0); // Path actuators are green. color = new THREE.Color(activation, 1 - activation, 0); // Path actuators are green.
} }
var num_segments = message.muscle[k].pathPoint.length - 1; var num_segments = message.muscle[k].pathPoint.length - 1;
...@@ -52,8 +48,8 @@ GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) { ...@@ -52,8 +48,8 @@ GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) {
// It would result in superfluous visible geometry. // It would result in superfluous visible geometry.
if (!(k in this.cylinderShapes)) { if (!(k in this.cylinderShapes)) {
this.cylinderShapes[k] = { this.cylinderShapes[k] = {
cylinders : [], cylinders: [],
spheres : [] spheres: []
}; };
} }
let cylinders = this.cylinderShapes[k].cylinders; let cylinders = this.cylinderShapes[k].cylinders;
...@@ -61,11 +57,14 @@ GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) { ...@@ -61,11 +57,14 @@ GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) {
// Create new cylinder on demand. // Create new cylinder on demand.
if (cylinders.length <= cq) { if (cylinders.length <= cq) {
let edgeGeometry = new THREE.CylinderBufferGeometry(1, 1, 1, 8, 1); let edgeGeometry = new THREE.CylinderBufferGeometry(1, 1, 1, 8, 1);
let cylinder = new THREE.Mesh(edgeGeometry, new THREE.MeshLambertMaterial({ let cylinder = new THREE.Mesh(
color: color, edgeGeometry,
wireframe: false, new THREE.MeshLambertMaterial({
flatShading: THREE.FlatShading color: color,
})); wireframe: false,
flatShading: THREE.FlatShading
})
);
this.rootGroup.add(cylinder); this.rootGroup.add(cylinder);
cylinders.push(cylinder); cylinders.push(cylinder);
} }
...@@ -76,25 +75,33 @@ GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) { ...@@ -76,25 +75,33 @@ GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) {
cylinderEndPoint_1 = new THREE.Vector3( cylinderEndPoint_1 = new THREE.Vector3(
message.muscle[k].pathPoint[cq].x, message.muscle[k].pathPoint[cq].x,
message.muscle[k].pathPoint[cq].y, message.muscle[k].pathPoint[cq].y,
message.muscle[k].pathPoint[cq].z); message.muscle[k].pathPoint[cq].z
);
cylinderEndPoint_2 = new THREE.Vector3( cylinderEndPoint_2 = new THREE.Vector3(
message.muscle[k].pathPoint[cq + 1].x, message.muscle[k].pathPoint[cq + 1].x,
message.muscle[k].pathPoint[cq + 1].y, message.muscle[k].pathPoint[cq + 1].y,
message.muscle[k].pathPoint[cq + 1].z); message.muscle[k].pathPoint[cq + 1].z
let cylinder_direction = new THREE.Vector3().subVectors(cylinderEndPoint_2, cylinderEndPoint_1); );
let cylinder_direction = new THREE.Vector3().subVectors(
cylinderEndPoint_2,
cylinderEndPoint_1
);
cylinder.material.color = color; cylinder.material.color = color;
cylinder.scale.y = cylinder_direction.length(); cylinder.scale.y = cylinder_direction.length();
cylinder.scale.x = radius; cylinder.scale.x = radius;
cylinder.scale.z = radius; cylinder.scale.z = radius;
cylinder_direction.normalize(); cylinder_direction.normalize();
cylinder.quaternion.setFromUnitVectors(new THREE.Vector3(0,1,0), cylinder_direction); cylinder.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
cylinder_direction
);
cylinder.position.x = (cylinderEndPoint_2.x + cylinderEndPoint_1.x) / 2; cylinder.position.x = (cylinderEndPoint_2.x + cylinderEndPoint_1.x) / 2;
cylinder.position.y = (cylinderEndPoint_2.y + cylinderEndPoint_1.y) / 2; cylinder.position.y = (cylinderEndPoint_2.y + cylinderEndPoint_1.y) / 2;
cylinder.position.z = (cylinderEndPoint_2.z + cylinderEndPoint_1.z) / 2; cylinder.position.z = (cylinderEndPoint_2.z + cylinderEndPoint_1.z) / 2;
} // end for path points } // end for path points
// I don't bother tracking how many segments were needed last time. // I don't bother tracking how many segments were needed last time.
// Simply loop over all superfluous segments and turn them all off. // Simply loop over all superfluous segments and turn them all off.
for(; cq < cylinders.length; ++cq) { for (; cq < cylinders.length; ++cq) {
cylinders[cq].visible = false; cylinders[cq].visible = false;
} }
// Now the spheres! // Now the spheres!
...@@ -103,11 +110,14 @@ GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) { ...@@ -103,11 +110,14 @@ GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) {
// Create one if needed. // Create one if needed.
if (spheres.length <= cq) { if (spheres.length <= cq) {
let geom = new THREE.SphereBufferGeometry(1, 8, 8); let geom = new THREE.SphereBufferGeometry(1, 8, 8);
let s = new THREE.Mesh(geom, new THREE.MeshLambertMaterial({ let s = new THREE.Mesh(
color: color, geom,
wireframe: false, new THREE.MeshLambertMaterial({
flatShading: THREE.FlatShading color: color,
})); wireframe: false,
flatShading: THREE.FlatShading
})
);
this.rootGroup.add(s); this.rootGroup.add(s);
spheres.push(s); spheres.push(s);
} }
...@@ -118,14 +128,15 @@ GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) { ...@@ -118,14 +128,15 @@ GZ3D.VisualMuscleModel.prototype.updateVisualization = function(message) {
let pos = new THREE.Vector3( let pos = new THREE.Vector3(
message.muscle[k].pathPoint[cq].x, message.muscle[k].pathPoint[cq].x,
message.muscle[k].pathPoint[cq].y, message.muscle[k].pathPoint[cq].y,
message.muscle[k].pathPoint[cq].z); message.muscle[k].pathPoint[cq].z
);
sphere.position.copy(pos); sphere.position.copy(pos);
sphere.scale.x = radius; sphere.scale.x = radius;
sphere.scale.y = radius; sphere.scale.y = radius;
sphere.scale.z = radius; sphere.scale.z = radius;
} }
// Turn off not needed ones. // Turn off not needed ones.
for(; cq < spheres.length; ++cq) { for (; cq < spheres.length; ++cq) {
spheres[cq].visible = false; spheres[cq].visible = false;
} }
} // end for message.muscle } // end for message.muscle
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -16,45 +16,43 @@ GZ3D.MASTER_QUALITY_MINIMAL = 'Minimal'; ...@@ -16,45 +16,43 @@ GZ3D.MASTER_QUALITY_MINIMAL = 'Minimal';
// Composer Settings // Composer Settings
GZ3D.ComposerSettings = function () GZ3D.ComposerSettings = function() {
{ this.shadows = false;
this.shadows = false; this.antiAliasing = true;
this.antiAliasing = true;
this.ssao = false; // Screen space ambient occlusion this.ssao = false; // Screen space ambient occlusion
this.ssaoDisplay = false; this.ssaoDisplay = false;
this.ssaoClamp = 0.8; this.ssaoClamp = 0.8;
this.ssaoLumInfluence = 0.7; this.ssaoLumInfluence = 0.7;
this.rgbCurve = {'red':[],'green':[],'blue':[]}; // Color correction, disabled by default this.rgbCurve = { red: [], green: [], blue: [] }; // Color correction, disabled by default
this.levelsInBlack = 0.0; // Color levels this.levelsInBlack = 0.0; // Color levels
this.levelsInGamma = 1.0; this.levelsInGamma = 1.0;
this.levelsInWhite = 1.0; this.levelsInWhite = 1.0;
this.levelsOutBlack = 0.0; this.levelsOutBlack = 0.0;
this.levelsOutWhite = 1.0; this.levelsOutWhite = 1.0;
this.skyBox = ''; // The file path of the sky box (without file extension) or empty string for plain color background this.skyBox = ''; // The file path of the sky box (without file extension) or empty string for plain color background
this.dynamicEnvMap = true; // Environment map is generated at the beginning of the experiment this.dynamicEnvMap = true; // Environment map is generated at the beginning of the experiment
this.sun = ''; // empty string for no sun or "SIMPLELENSFLARE" for simple lens flare rendering this.sun = ''; // empty string for no sun or "SIMPLELENSFLARE" for simple lens flare rendering
this.bloom = false; // Bloom this.bloom = false; // Bloom
this.bloomStrength = 1.0; this.bloomStrength = 1.0;
this.bloomRadius = 0.37; this.bloomRadius = 0.37;
this.bloomThreshold = 0.98; this.bloomThreshold = 0.98;
this.fog = false; // Fog this.fog = false; // Fog
this.fogDensity = 0.05; this.fogDensity = 0.05;
this.fogColor = '#b2b2b2'; // CSS style this.fogColor = '#b2b2b2'; // CSS style
this.pbrMaterial = true; // Physically based material this.pbrMaterial = true; // Physically based material
// User camera frustum settings // User camera frustum settings
this.verticalFOV = 60.0; this.verticalFOV = 60.0;
this.nearClippingDistance = 0.15; this.nearClippingDistance = 0.15;
this.farClippingDistance = 100.0; this.farClippingDistance = 100.0;
this.showCameraHelper = false; this.showCameraHelper = false;
}; };
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -4,57 +4,48 @@ ...@@ -4,57 +4,48 @@
*/ */
GZ3D.LevelsShader = { GZ3D.LevelsShader = {
uniforms: {
tDiffuse: { value: null },
uniforms: { // Levels parameters
'tDiffuse': { value: null }, inBlack: { value: 0.0 },
inWhite: { value: 1.0 },
inGamma: { value: 1.0 },
// Levels parameters outBlack: { value: 0.0 },
outWhite: { value: 1.0 }
},
'inBlack': { value: 0.0 }, vertexShader: [
'inWhite': { value: 1.0 }, 'varying vec2 vUv;',
'inGamma': { value: 1.0 },
'outBlack': { value: 0.0 }, 'void main() {',
'outWhite': { value: 1.0 },
},
vertexShader: [ 'vUv = uv;',
'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
'varying vec2 vUv;', '}'
].join('\n'),
'void main() {', fragmentShader: [
'uniform float inBlack,inWhite,inGamma,outBlack,outWhite;',
'uniform sampler2D tDiffuse;',
'vUv = uv;', 'varying vec2 vUv;',
'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
'}' 'void main() {',
].join('\n'), 'vec4 texel = texture2D( tDiffuse, vUv );',
fragmentShader: [ 'float outf = (outWhite - outBlack);',
'uniform float inBlack,inWhite,inGamma,outBlack,outWhite;', 'texel[0] = pow((texel[0] - inBlack) / (inWhite - inBlack),inGamma) * outf + outBlack;',
'uniform sampler2D tDiffuse;', 'texel[1] = pow((texel[1] - inBlack) / (inWhite - inBlack),inGamma) * outf + outBlack;',
'texel[2] = pow((texel[2] - inBlack) / (inWhite - inBlack),inGamma) * outf + outBlack;',
'varying vec2 vUv;', 'gl_FragColor = texel;',
'void main() {',
'vec4 texel = texture2D( tDiffuse, vUv );',
'float outf = (outWhite - outBlack);',
'texel[0] = pow((texel[0] - inBlack) / (inWhite - inBlack),inGamma) * outf + outBlack;',
'texel[1] = pow((texel[1] - inBlack) / (inWhite - inBlack),inGamma) * outf + outBlack;',
'texel[2] = pow((texel[2] - inBlack) / (inWhite - inBlack),inGamma) * outf + outBlack;',
'gl_FragColor = texel;',
'}'
].join('\n')
'}'
].join('\n')
}; };
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment