Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added shadows property to Cesium3DTileset #4386

Merged
merged 5 commits into from
Oct 3, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/Scene/Batched3DModel3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ define([
releaseGltfJson : true, // Models are unique and will not benefit from caching so save memory
basePath : this._url,
modelMatrix : this._tile.computedTransform,
shadows: this._tileset.shadows,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace, please update in 3d-tiles branch.

vertexShaderLoaded : batchTable.getVertexShaderCallback(),
fragmentShaderLoaded : batchTable.getFragmentShaderCallback(),
uniformMapLoaded : batchTable.getUniformMapCallback(),
Expand Down Expand Up @@ -303,6 +304,7 @@ define([
// actually generate commands.
this.batchTable.update(tileset, frameState);
this._model.modelMatrix = this._tile.computedTransform;
this._model.shadows = this._tileset.shadows;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, except while testing I noticed that changing the shadows at run time wasn't working because the Batched3DModel3DTileContent clones the model's commands, so we need to also set the shadows for the cloned commands.

At https://github.com/AnalyticalGraphicsInc/cesium/blob/3d-tiles/Source/Scene/Cesium3DTileBatchTable.js#L785 add the following lines:

derivedCommands.originalCommand.castShadows = command.castShadows;
derivedCommands.originalCommand.receiveShadows = command.receiveShadows;
derivedCommands.back.castShadows = command.castShadows;
derivedCommands.back.receiveShadows = command.receiveShadows;
derivedCommands.front.castShadows = command.castShadows;
derivedCommands.front.receiveShadows = command.receiveShadows;

this._model.update(frameState);

frameState.addCommand = oldAddCommand;
Expand Down
15 changes: 13 additions & 2 deletions Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ define([
'./Cesium3DTileStyleEngine',
'./CullingVolume',
'./DebugCameraPrimitive',
'./SceneMode'
'./SceneMode',
'./ShadowMode'
], function(
Color,
defaultValue,
Expand Down Expand Up @@ -54,7 +55,8 @@ define([
Cesium3DTileStyleEngine,
CullingVolume,
DebugCameraPrimitive,
SceneMode) {
SceneMode,
ShadowMode) {
'use strict';

/**
Expand All @@ -76,6 +78,7 @@ define([
* @param {Boolean} [options.debugColorizeTiles=false] For debugging only. When true, assigns a random color to each tile.
* @param {Boolean} [options.debugShowBoundingVolume=false] For debugging only. When true, renders the bounding volume for each tile.
* @param {Boolean} [options.debugShowContentBoundingVolume=false] For debugging only. When true, renders the bounding volume for each tile's content.
* @param {ShadowMode} [options.shadows=ShadowMode.ENABLED] Determines whether the tileset casts or receives shadows from each light source.
*
* @example
* var tileset = scene.primitives.add(new Cesium.Cesium3DTileset({
Expand Down Expand Up @@ -130,6 +133,14 @@ define([

this._refineToVisible = defaultValue(options.refineToVisible, false);

/**
* Determines whether the tileset casts or receives shadows from each light source.
*
* @type {ShadowMode}
* @default ShadowMode.ENABLED
*/
this.shadows = defaultValue(options.shadows, ShadowMode.ENABLED);

/**
* Determines if the tileset will be shown.
*
Expand Down
1 change: 1 addition & 0 deletions Source/Scene/Instanced3DModel3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ define([
// actually generate commands.
this.batchTable.update(tileset, frameState);
this._modelInstanceCollection.transform = this._tile.computedTransform;
this._modelInstanceCollection.shadows = this._tileset.shadows;
this._modelInstanceCollection.update(frameState);

frameState.addCommand = oldAddCommand;
Expand Down