Skip to content

Commit

Permalink
refs CesiumGS#5152 option to switch normal shading
Browse files Browse the repository at this point in the history
  • Loading branch information
geoscan-builder committed Dec 7, 2018
1 parent 3632059 commit 4a8c92d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
20 changes: 20 additions & 0 deletions Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ define([
'../Core/Resource',
'../Core/RuntimeError',
'../Core/Transforms',
'../DataSources/ConstantProperty',
'../Renderer/ClearCommand',
'../Renderer/Pass',
'../ThirdParty/when',
Expand Down Expand Up @@ -62,6 +63,7 @@ define([
Resource,
RuntimeError,
Transforms,
ConstantProperty,
ClearCommand,
Pass,
when,
Expand Down Expand Up @@ -285,6 +287,24 @@ 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
20 changes: 18 additions & 2 deletions Source/Scene/PointCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define([
'../Core/PrimitiveType',
'../Core/RuntimeError',
'../Core/Transforms',
'../DataSources/ConstantProperty',
'../Renderer/Buffer',
'../Renderer/BufferUsage',
'../Renderer/DrawCommand',
Expand Down Expand Up @@ -62,6 +63,7 @@ define([
PrimitiveType,
RuntimeError,
Transforms,
ConstantProperty,
Buffer,
BufferUsage,
DrawCommand,
Expand Down Expand Up @@ -114,6 +116,8 @@ define([
Check.typeOf.object('options.arrayBuffer', options.arrayBuffer);
//>>includeEnd('debug');

var that = this;

// Hold onto the payload until the render resources are created
this._parsedContent = undefined;

Expand Down Expand Up @@ -147,11 +151,13 @@ define([

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

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

this._opaqueRenderState = undefined;
this._translucentRenderState = undefined;
Expand Down Expand Up @@ -249,6 +255,16 @@ define([

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
4 changes: 3 additions & 1 deletion Source/Scene/PointCloud3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ define([
fragmentShaderLoaded : getFragmentShaderLoaded(this),
uniformMapLoaded : getUniformMapLoaded(this),
batchTableLoaded : getBatchTableLoaded(this),
pickIdLoaded : getPickIdLoaded(this)
pickIdLoaded : getPickIdLoaded(this),
normalShading : tileset.normalShading,
backfaceCulling : tileset.backfaceCulling
});
}

Expand Down

0 comments on commit 4a8c92d

Please sign in to comment.