diff --git a/Source/Scene/Cesium3DTileset.js b/Source/Scene/Cesium3DTileset.js index 8b394390f0b6..10780186ec38 100644 --- a/Source/Scene/Cesium3DTileset.js +++ b/Source/Scene/Cesium3DTileset.js @@ -20,6 +20,7 @@ define([ '../Core/Resource', '../Core/RuntimeError', '../Core/Transforms', + '../DataSources/ConstantProperty', '../Renderer/ClearCommand', '../Renderer/Pass', '../ThirdParty/when', @@ -65,6 +66,7 @@ define([ Resource, RuntimeError, Transforms, + ConstantProperty, ClearCommand, Pass, when, @@ -293,6 +295,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. * diff --git a/Source/Scene/PointCloud.js b/Source/Scene/PointCloud.js index 252764a23f4e..2bfc0b7ef869 100644 --- a/Source/Scene/PointCloud.js +++ b/Source/Scene/PointCloud.js @@ -21,6 +21,7 @@ define([ '../Core/PrimitiveType', '../Core/RuntimeError', '../Core/Transforms', + '../DataSources/ConstantProperty', '../Renderer/Buffer', '../Renderer/BufferUsage', '../Renderer/DrawCommand', @@ -62,6 +63,7 @@ define([ PrimitiveType, RuntimeError, Transforms, + ConstantProperty, Buffer, BufferUsage, DrawCommand, @@ -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; @@ -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; @@ -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); diff --git a/Source/Scene/PointCloud3DTileContent.js b/Source/Scene/PointCloud3DTileContent.js index f9cb8caa9855..740627fcdaf4 100644 --- a/Source/Scene/PointCloud3DTileContent.js +++ b/Source/Scene/PointCloud3DTileContent.js @@ -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 }); }