-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
3D Tiles - Point Cloud Styling #4336
Changes from 1 commit
41fc014
46d00e3
8e98836
b7c2dfd
cc1c4e6
5cb1088
758ebb2
9d2838e
096b15b
976f32f
953f9be
1fd4b27
dbd681d
75beb23
72ee217
88903d5
62ecd50
7754b66
cab3705
464cee8
18be9d6
079d6f6
6d8a879
84d8ff7
a217024
55cf834
8823472
c04ff78
f0f86ad
83efc1b
45d96d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,11 @@ define([ | |
this._show = undefined; | ||
this._meta = undefined; | ||
|
||
this._colorShaderFunction = undefined; | ||
this._showShaderFunction = undefined; | ||
this._colorShaderFunctionReady = false; | ||
this._showShaderFunctionReady = false; | ||
|
||
var style = this; | ||
if (typeof data === 'string') { | ||
RequestScheduler.request(data, loadJson).then(function(styleJson) { | ||
|
@@ -80,6 +85,17 @@ define([ | |
that._style = clone(styleJson, true); | ||
|
||
styleJson = defaultValue(styleJson, defaultValue.EMPTY_OBJECT); | ||
|
||
if (!defined(styleJson.color)) { | ||
// If there is no color style do not create a shader function. Otherwise a function would be created by the default style (white). | ||
that._colorShaderFunctionReady = true; | ||
} | ||
|
||
if (!defined(styleJson.show)) { | ||
// If there is no show style do not create a shader function. | ||
that._showShaderFunctionReady = true; | ||
} | ||
|
||
var colorExpression = defaultValue(styleJson.color, DEFAULT_JSON_COLOR_EXPRESSION); | ||
var showExpression = defaultValue(styleJson.show, DEFAULT_JSON_BOOLEAN_EXPRESSION); | ||
|
||
|
@@ -294,9 +310,62 @@ define([ | |
set : function(value) { | ||
this._meta = value; | ||
} | ||
}, | ||
|
||
} | ||
}); | ||
|
||
/** | ||
* Gets the color shader function for this style. | ||
* | ||
* @param {String} name Name to give to the generated function. | ||
* @param {String} variablePrefix Prefix that is added to any variable names to access vertex attributes. | ||
* @param {Object} info Stores information about the generated shader function. | ||
* | ||
* @returns {String} The shader function. | ||
* | ||
* @private | ||
*/ | ||
Cesium3DTileStyle.prototype.getColorShaderFunction = function(name, variablePrefix, info) { | ||
if (this._colorShaderFunctionReady) { | ||
// Return the cached result, may be undefined | ||
return this._colorShaderFunction; | ||
} | ||
|
||
this._colorShaderFunctionReady = true; | ||
this._colorShaderFunction = this.color.getShaderFunction(name, variablePrefix, 'vec4', info); | ||
//>>includeStart('debug', pragmas.debug); | ||
if (!defined(this._colorShaderFunction)) { | ||
throw new DeveloperError('Could not generate valid shader code for the color style.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even though this is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, if this happens in non-pathological cases, we should have a more detailed error message. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't be hard to give more detailed error messages for this inside |
||
} | ||
//>>includeEnd('debug'); | ||
return this._colorShaderFunction; | ||
}; | ||
|
||
/** | ||
* Gets the show shader function for this style. | ||
* | ||
* @param {String} name Name to give to the generated function. | ||
* @param {String} variablePrefix Prefix that is added to any variable names to access vertex attributes. | ||
* @param {Object} info Stores information about the generated shader function. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment. |
||
* | ||
* @returns {String} The shader function. | ||
* | ||
* @private | ||
*/ | ||
Cesium3DTileStyle.prototype.getShowShaderFunction = function(name, variablePrefix, info) { | ||
if (this._showShaderFunctionReady) { | ||
// Return the cached result, may be undefined | ||
return this._showShaderFunction; | ||
} | ||
|
||
this._showShaderFunctionReady = true; | ||
this._showShaderFunction = this.show.getShaderFunction(name, variablePrefix, 'bool', info); | ||
//>>includeStart('debug', pragmas.debug); | ||
if (!defined(this._showShaderFunction)) { | ||
throw new DeveloperError('Could not generate valid shader code for the show style.'); | ||
} | ||
//>>includeEnd('debug'); | ||
return this._showShaderFunction; | ||
}; | ||
|
||
return Cesium3DTileStyle; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,13 @@ | |
define([ | ||
'../Core/Color', | ||
'../Core/defined', | ||
'../Core/defineProperties' | ||
'../Core/defineProperties', | ||
'./PointCloud3DTileContent' | ||
], function( | ||
Color, | ||
defined, | ||
defineProperties) { | ||
defineProperties, | ||
PointCloud3DTileContent) { | ||
'use strict'; | ||
|
||
/** | ||
|
@@ -74,36 +76,41 @@ define([ | |
// 2) this tile is now visible, but it wasn't visible when the style was first assigned | ||
if (tile.lastStyleTime !== lastStyleTime) { | ||
tile.lastStyleTime = lastStyleTime; | ||
styleCompositeContent(this, tile.content, stats); | ||
styleCompositeContent(this, frameState, tile.content, stats); | ||
|
||
++stats.numberOfTilesStyled; | ||
} | ||
} | ||
} | ||
}; | ||
|
||
function styleCompositeContent(styleEngine, content, stats) { | ||
function styleCompositeContent(styleEngine, frameState, content, stats) { | ||
var innerContents = content.innerContents; | ||
if (defined(innerContents)) { | ||
var length = innerContents.length; | ||
for (var i = 0; i < length; ++i) { | ||
// Recurse for composites of composites | ||
styleCompositeContent(styleEngine, innerContents[i], stats); | ||
styleCompositeContent(styleEngine, frameState, innerContents[i], stats); | ||
} | ||
} else { | ||
// Not a composite tile | ||
styleContent(styleEngine, content, stats); | ||
styleContent(styleEngine, frameState, content, stats); | ||
} | ||
} | ||
|
||
var scratchColor = new Color(); | ||
|
||
function styleContent(styleEngine, content, stats) { | ||
function styleContent(styleEngine, frameState, content, stats) { | ||
var length = content.featuresLength; | ||
var style = styleEngine._style; | ||
|
||
stats.numberOfFeaturesStyled += length; | ||
|
||
// Apply style to point cloud. Only apply style if the point cloud is not backed by a batch table. | ||
if ((content instanceof PointCloud3DTileContent) && (length === 0)) { | ||
content.applyStyle(frameState, style); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps rework this function so that each content type has a function like |
||
} | ||
|
||
if (!defined(style)) { | ||
clearStyle(content); | ||
return; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename
info
. From this context, I have no idea what it is.