-
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
Model coloring #4547
Changes from 10 commits
d1d09f9
f8d2ac1
5c7911d
bdc8425
4bd0ad6
250874e
dec5b0a
5c20c55
5fcde36
dcf2f2b
77ace36
84fbd37
5e9e66d
cade6fa
6a60f25
f23d436
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
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(); | ||
} | ||
|
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.