-
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
Model coloring #4547
Merged
Merged
Model coloring #4547
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d1d09f9
Added model color
lilleyse f8d2ac1
Merge branch 'master' into model-color
lilleyse 5c7911d
Updated 3D Models dev Sandcastle
lilleyse bdc8425
Add to Entity API, CZML, and 3D Models showcase
lilleyse 4bd0ad6
Support alpha in blend color
lilleyse 250874e
Switch render states depending on alpha
lilleyse dec5b0a
Alpha test
lilleyse 5c20c55
Remove separation of front/back commands
lilleyse 5fcde36
Merge remote-tracking branch 'origin/master' into model-color
pjcozzi dcf2f2b
Move CHANGES.md update to 1.29
pjcozzi 77ace36
Small fix
lilleyse 84fbd37
Use ColorBlendMode instead of always Mix
lilleyse 5e9e66d
Update CHANGES.md
pjcozzi cade6fa
Separate model coloring into its own demo
lilleyse 6a60f25
Use ColorBlendMode.getColorBlend function
lilleyse f23d436
Don't issue command when alpha is 0
lilleyse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,44 @@ | |
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html"> | ||
<style> | ||
@import url(../templates/bucket.css); | ||
#toolbar { | ||
background: rgba(42, 42, 42, 0.8); | ||
padding: 4px; | ||
border-radius: 4px; | ||
} | ||
#toolbar input { | ||
vertical-align: middle; | ||
padding-top: 2px; | ||
padding-bottom: 2px; | ||
} | ||
</style> | ||
<div id="cesiumContainer" class="fullSize"></div> | ||
<div id="loadingOverlay"><h1>Loading...</h1></div> | ||
<div id="toolbar"></div> | ||
<div id="toolbar"> | ||
<table><tbody> | ||
<tr> | ||
<td>Blend Amount</td> | ||
<td> | ||
<input type="range" min="0.0" max="1.0" step="0.01" data-bind="value: blendAmount, valueUpdate: 'input'"> | ||
<input type="text" size="5" data-bind="value: blendAmount"> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>Blend Color</td> | ||
<td> | ||
<input type="range" min="0.0" max="1.0" step="0.01" data-bind="value: blendColor, valueUpdate: 'input'"> | ||
<input type="text" size="5" data-bind="value: blendColor"> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>Blend Alpha</td> | ||
<td> | ||
<input type="range" min="0.0" max="1.0" step="0.01" data-bind="value: blendAlpha, valueUpdate: 'input'"> | ||
<input type="text" size="5" data-bind="value: blendAlpha"> | ||
</td> | ||
</tr> | ||
</tbody></table> | ||
</div> | ||
<script id="cesium_sandcastle_script"> | ||
function startup(Cesium) { | ||
'use strict'; | ||
|
@@ -33,6 +67,40 @@ | |
shadows : true | ||
}); | ||
|
||
var entity; | ||
|
||
// The viewModel tracks the state of our mini application. | ||
var viewModel = { | ||
blendAmount : 0.0, | ||
blendColor : 0.0, | ||
blendAlpha : 1.0 | ||
}; | ||
|
||
// Convert the viewModel members into knockout observables. | ||
Cesium.knockout.track(viewModel); | ||
|
||
// Bind the viewModel to the DOM elements of the UI that call for it. | ||
var toolbar = document.getElementById('toolbar'); | ||
Cesium.knockout.applyBindings(viewModel, toolbar); | ||
|
||
Cesium.knockout.getObservable(viewModel, 'blendAmount').subscribe( | ||
function(newValue) { | ||
entity.model.blendAmount = newValue; | ||
} | ||
); | ||
|
||
Cesium.knockout.getObservable(viewModel, 'blendColor').subscribe( | ||
function(newValue) { | ||
entity.model.blendColor = Cesium.Color.fromHsl(newValue, 1.0, 0.5, viewModel.blendAlpha); | ||
} | ||
); | ||
|
||
Cesium.knockout.getObservable(viewModel, 'blendAlpha').subscribe( | ||
function(newValue) { | ||
entity.model.blendColor = Cesium.Color.fromHsl(viewModel.blendColor, 1.0, 0.5, newValue); | ||
} | ||
); | ||
|
||
function createModel(url, height) { | ||
viewer.entities.removeAll(); | ||
|
||
|
@@ -43,14 +111,16 @@ | |
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll); | ||
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr); | ||
|
||
var entity = viewer.entities.add({ | ||
entity = viewer.entities.add({ | ||
name : url, | ||
position : position, | ||
orientation : orientation, | ||
model : { | ||
uri : url, | ||
minimumPixelSize : 128, | ||
maximumScale : 20000 | ||
maximumScale : 20000, | ||
blendAmount : viewModel.blendAmount, | ||
blendColor : Cesium.Color.fromHsl(viewModel.blendColor, 1.0, 0.5, viewModel.blendAlpha) | ||
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. Do our users think of this as blending? Or just as applying a color to a model like Billboard.color? What do you think of renaming this to |
||
} | ||
}); | ||
viewer.trackedEntity = entity; | ||
|
@@ -84,6 +154,11 @@ | |
}]; | ||
|
||
Sandcastle.addToolbarMenu(options); | ||
|
||
Sandcastle.addToggleButton('Shadows', viewer.shadows, function(checked) { | ||
viewer.shadows = checked; | ||
}); | ||
|
||
//Sandcastle_End | ||
Sandcastle.finishedLoading(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@lilleyse up to you, but do you think that we've made this Sandcastle example too complicated? Would it be better (and more discoverable) to have separate 3D Models and 3D Model Coloring examples?
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.
Plus silhouettes can be combined in that new demo.