Skip to content

Commit

Permalink
refs CesiumGS#5152 moved properties to pointCloudShading
Browse files Browse the repository at this point in the history
  • Loading branch information
geoscan-builder committed Dec 28, 2018
1 parent a563bda commit 39ade84
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 38 deletions.
18 changes: 0 additions & 18 deletions Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,24 +295,6 @@ define([
*/
this.shadows = defaultValue(options.shadows, ShadowMode.ENABLED);

/**
* Determines whether backfaces of points / mesh are hidden
*
* @type {boolean}
* @default false
*/
var backFaceCulling = defaultValue(options.backFaceCulling, false);
this.backFaceCulling = new ConstantProperty(backFaceCulling);

/**
* Determines whether the tileset is lighted by the sun
*
* @type {boolean}
* @default true
*/
var normalShading = defaultValue(options.normalShading, true);
this.normalShading = new ConstantProperty(normalShading);

/**
* Determines if the tileset will be shown.
*
Expand Down
37 changes: 20 additions & 17 deletions Source/Scene/PointCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,15 @@ define([
this._quantizedRange = 0.0;
this._octEncodedRange = 0.0;

this._pointCloudShading = defaultValue(options.shading, {
backFaceCulling : false,
normalShading : true
});

// Use per-point normals to hide back-facing points.
this.backFaceCulling = false;
bindProperty(this, 'backFaceCulling', options.backFaceCulling);
this._backFaceCulling = this.backFaceCulling;

// Whether to enable normal shading
this.normalShading = true;
bindProperty(this, 'normalShading', options.normalShading);
this._normalShading = this.normalShading;

this._opaqueRenderState = undefined;
Expand Down Expand Up @@ -248,21 +249,23 @@ define([
set : function(value) {
this._boundingSphere = BoundingSphere.clone(value);
}
},

backFaceCulling : {
get : function() {
return this._pointCloudShading.backFaceCulling;
}
},

normalShading : {
get : function() {
return this._pointCloudShading.normalShading;
}
}
});

var sizeOfUint32 = Uint32Array.BYTES_PER_ELEMENT;

function bindProperty(object, field, property) {
if (property) {
var val = property.getValue();
object[field] = val;
property.definitionChanged.addEventListener(function(newValue) {
object[field] = newValue.getValue();
});
}
}

function initialize(pointCloud, options) {
var arrayBuffer = options.arrayBuffer;
var byteOffset = defaultValue(options.byteOffset, 0);
Expand Down Expand Up @@ -1142,6 +1145,7 @@ define([
} else {
vs += ' vec3 normal = a_normal; \n';
}
vs += ' vec3 view_normal = czm_normal * normal; \n';
} else {
vs += ' vec3 normal = vec3(1.0); \n';
}
Expand All @@ -1168,8 +1172,7 @@ define([
vs += ' color = color * u_highlightColor; \n';

if (usesNormals && normalShading) {
vs += ' normal = czm_normal * normal; \n' +
' float diffuseStrength = czm_getLambertDiffuse(czm_sunDirectionEC, normal); \n' +
vs += ' float diffuseStrength = czm_getLambertDiffuse(czm_sunDirectionEC, view_normal); \n' +
' diffuseStrength = max(diffuseStrength, 0.4); \n' + // Apply some ambient lighting
' color.xyz *= diffuseStrength; \n';
}
Expand All @@ -1178,7 +1181,7 @@ define([
' gl_Position = czm_modelViewProjection * vec4(position, 1.0); \n';

if (usesNormals && backFaceCulling) {
vs += ' float visible = step(-normal.z, 0.0); \n' +
vs += ' float visible = step(-view_normal.z, 0.0); \n' +
' gl_Position *= visible; \n' +
' gl_PointSize *= visible; \n';
}
Expand Down
3 changes: 1 addition & 2 deletions Source/Scene/PointCloud3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ define([
uniformMapLoaded : getUniformMapLoaded(this),
batchTableLoaded : getBatchTableLoaded(this),
pickIdLoaded : getPickIdLoaded(this),
normalShading : tileset.normalShading,
backfaceCulling : tileset.backfaceCulling
shading : tileset.pointCloudShading
});
}

Expand Down
16 changes: 16 additions & 0 deletions Source/Scene/PointCloudShading.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ define([
* @default 1.0
*/
this.eyeDomeLightingRadius = defaultValue(pointCloudShading.eyeDomeLightingRadius, 1.0);

/**
* Determines whether backfaces of points / mesh are hidden
*
* @type {boolean}
* @default false
*/
this.backFaceCulling = defaultValue(pointCloudShading.backFaceCulling, false);

/**
* Determines whether the tileset is lighted by the sun
*
* @type {boolean}
* @default true
*/
this.normalShading = defaultValue(pointCloudShading.normalShading, true);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion Source/Scene/TimeDynamicPointCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ define([
*/
this.style = options.style;

this.normalShading = options.normalShading;
this.backFaceCulling = options.backFaceCulling;

/**
* The event fired to indicate that a frame failed to load. A frame may fail to load if the
* request for its uri fails or processing fails due to invalid content.
Expand Down Expand Up @@ -420,7 +423,8 @@ define([
cull : true,
fragmentShaderLoaded : getFragmentShaderLoaded,
uniformMapLoaded : getUniformMapLoaded(that),
pickIdLoaded : getPickIdLoaded
pickIdLoaded : getPickIdLoaded,
shading : that.shading
});
return frame.pointCloud.readyPromise;
}).otherwise(handleFrameFailure(that, uri));
Expand Down

0 comments on commit 39ade84

Please sign in to comment.