-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Sandcastle - Nested gallery structure #12631
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
5d31cd1
new gallery structure
jjspace 05206b7
switch sandcastle code to modules
jjspace 90ed59c
label windows based on env
jjspace e1955f9
Merge branch 'sandcastle-v2' into nested-gallery
jjspace 3b03f8a
remove iife Cesium from bucket and standalone
jjspace 5185be6
isolate sandcastle api compilation
jjspace 382516b
move build gallery script
jjspace 1dcbbd9
integrate gallery build script more
jjspace 8081c69
prevent building using vite dev config
jjspace dcdc2c5
minor gallery format adjustments
jjspace 0dd9463
change gallery url per build env
jjspace 11d39ee
relocate gallery
jjspace 52e0568
fix legacy id
jjspace 61627d6
small change
jjspace 15095e5
fix script as main detection
jjspace 193925a
small style adjustments for scrolling gallery
jjspace 7381646
document gallery structure, support development only sandcastles
jjspace 05f0a6f
add import to default code
jjspace 08fb8cb
prevent missing types from breaking dev server
jjspace 7ec2400
change import detection
jjspace b75874d
remove todo
jjspace 319c640
remove id from sandcastle yaml
jjspace 1baddfc
don't generate tsbuildinfo files into tmp directory
jjspace d837c68
move types back into single copy plugin for dev server
jjspace 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 contains hidden or 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 hidden or 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 hidden or 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
108 changes: 108 additions & 0 deletions
108
packages/sandcastle/gallery/3d-models-coloring/index.html
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| <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; | ||
| } | ||
| #toolbar .header { | ||
| font-weight: bold; | ||
| } | ||
| </style> | ||
| <div id="cesiumContainer" class="fullSize"></div> | ||
| <div id="loadingOverlay"><h1>Loading...</h1></div> | ||
| <div id="toolbar"> | ||
| <table> | ||
| <tbody> | ||
| <tr> | ||
| <td class="header">Model Color</td> | ||
| </tr> | ||
| <tr> | ||
| <td>Mode</td> | ||
| <td> | ||
| <select | ||
| data-bind="options: colorBlendModes, value: colorBlendMode" | ||
| ></select> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td>Color</td> | ||
| <td><select data-bind="options: colors, value: color"></select></td> | ||
| </tr> | ||
| <tr> | ||
| <td>Alpha</td> | ||
| <td> | ||
| <input | ||
| type="range" | ||
| min="0.0" | ||
| max="1.0" | ||
| step="0.01" | ||
| data-bind="value: alpha, valueUpdate: 'input'" | ||
| /> | ||
| <input type="text" size="5" data-bind="value: alpha" /> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td data-bind="style: { color: colorBlendAmountEnabled ? '' : 'gray'}"> | ||
| Mix | ||
| </td> | ||
| <td> | ||
| <input | ||
| type="range" | ||
| min="0.0" | ||
| max="1.0" | ||
| step="0.01" | ||
| data-bind="value: colorBlendAmount, valueUpdate: 'input', enable: colorBlendAmountEnabled" | ||
| /> | ||
| <input | ||
| type="text" | ||
| size="5" | ||
| data-bind="value: colorBlendAmount, enable: colorBlendAmountEnabled" | ||
| /> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td class="header">Model Silhouette</td> | ||
| </tr> | ||
| <tr> | ||
| <td>Color</td> | ||
| <td> | ||
| <select | ||
| data-bind="options: silhouetteColors, value: silhouetteColor" | ||
| ></select> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td>Alpha</td> | ||
| <td> | ||
| <input | ||
| type="range" | ||
| min="0.0" | ||
| max="1.0" | ||
| step="0.01" | ||
| data-bind="value: silhouetteAlpha, valueUpdate: 'input'" | ||
| /> | ||
| <input type="text" size="5" data-bind="value: silhouetteAlpha" /> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td>Size</td> | ||
| <td> | ||
| <input | ||
| type="range" | ||
| min="0.0" | ||
| max="10.0" | ||
| step="0.01" | ||
| data-bind="value: silhouetteSize, valueUpdate: 'input'" | ||
| /> | ||
| <input type="text" size="5" data-bind="value: silhouetteSize" /> | ||
| </td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
| </div> |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| import * as Cesium from "cesium"; | ||
| import Sandcastle from "Sandcastle"; | ||
|
|
||
| const viewer = new Cesium.Viewer("cesiumContainer", { | ||
| infoBox: false, | ||
| selectionIndicator: false, | ||
| shadows: true, | ||
| shouldAnimate: true, | ||
| }); | ||
|
|
||
| let entity; | ||
|
|
||
| function getColorBlendMode(colorBlendMode) { | ||
| return Cesium.ColorBlendMode[colorBlendMode.toUpperCase()]; | ||
| } | ||
|
|
||
| function getColor(colorName, alpha) { | ||
| const color = Cesium.Color[colorName.toUpperCase()]; | ||
| return Cesium.Color.fromAlpha(color, parseFloat(alpha)); | ||
| } | ||
|
|
||
| // The viewModel tracks the state of our mini application. | ||
| const viewModel = { | ||
| color: "Red", | ||
| colors: ["White", "Red", "Green", "Blue", "Yellow", "Gray"], | ||
| alpha: 1.0, | ||
| colorBlendMode: "Highlight", | ||
| colorBlendModes: ["Highlight", "Replace", "Mix"], | ||
| colorBlendAmount: 0.5, | ||
| colorBlendAmountEnabled: false, | ||
| silhouetteColor: "Red", | ||
| silhouetteColors: ["Red", "Green", "Blue", "Yellow", "Gray"], | ||
| silhouetteAlpha: 1.0, | ||
| silhouetteSize: 2.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. | ||
| const toolbar = document.getElementById("toolbar"); | ||
| Cesium.knockout.applyBindings(viewModel, toolbar); | ||
|
|
||
| Cesium.knockout | ||
| .getObservable(viewModel, "color") | ||
| .subscribe(function (newValue) { | ||
| entity.model.color = getColor(newValue, viewModel.alpha); | ||
| }); | ||
|
|
||
| Cesium.knockout | ||
| .getObservable(viewModel, "alpha") | ||
| .subscribe(function (newValue) { | ||
| entity.model.color = getColor(viewModel.color, newValue); | ||
| }); | ||
|
|
||
| Cesium.knockout | ||
| .getObservable(viewModel, "colorBlendMode") | ||
| .subscribe(function (newValue) { | ||
| const colorBlendMode = getColorBlendMode(newValue); | ||
| entity.model.colorBlendMode = colorBlendMode; | ||
| viewModel.colorBlendAmountEnabled = | ||
| colorBlendMode === Cesium.ColorBlendMode.MIX; | ||
| }); | ||
|
|
||
| Cesium.knockout | ||
| .getObservable(viewModel, "colorBlendAmount") | ||
| .subscribe(function (newValue) { | ||
| entity.model.colorBlendAmount = parseFloat(newValue); | ||
| }); | ||
|
|
||
| Cesium.knockout | ||
| .getObservable(viewModel, "silhouetteColor") | ||
| .subscribe(function (newValue) { | ||
| entity.model.silhouetteColor = getColor( | ||
| newValue, | ||
| viewModel.silhouetteAlpha, | ||
| ); | ||
| }); | ||
|
|
||
| Cesium.knockout | ||
| .getObservable(viewModel, "silhouetteAlpha") | ||
| .subscribe(function (newValue) { | ||
| entity.model.silhouetteColor = getColor( | ||
| viewModel.silhouetteColor, | ||
| newValue, | ||
| ); | ||
| }); | ||
|
|
||
| Cesium.knockout | ||
| .getObservable(viewModel, "silhouetteSize") | ||
| .subscribe(function (newValue) { | ||
| entity.model.silhouetteSize = parseFloat(newValue); | ||
| }); | ||
|
|
||
| function createModel(url, height) { | ||
| viewer.entities.removeAll(); | ||
|
|
||
| const position = Cesium.Cartesian3.fromDegrees( | ||
| -123.0744619, | ||
| 44.0503706, | ||
| height, | ||
| ); | ||
| const heading = Cesium.Math.toRadians(135); | ||
| const pitch = 0; | ||
| const roll = 0; | ||
| const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll); | ||
| const orientation = Cesium.Transforms.headingPitchRollQuaternion( | ||
| position, | ||
| hpr, | ||
| ); | ||
|
|
||
| entity = viewer.entities.add({ | ||
| name: url, | ||
| position: position, | ||
| orientation: orientation, | ||
| model: { | ||
| uri: url, | ||
| minimumPixelSize: 128, | ||
| maximumScale: 20000, | ||
| color: getColor(viewModel.color, viewModel.alpha), | ||
| colorBlendMode: getColorBlendMode(viewModel.colorBlendMode), | ||
| colorBlendAmount: parseFloat(viewModel.colorBlendAmount), | ||
| silhouetteColor: getColor( | ||
| viewModel.silhouetteColor, | ||
| viewModel.silhouetteAlpha, | ||
| ), | ||
| silhouetteSize: parseFloat(viewModel.silhouetteSize), | ||
| }, | ||
| }); | ||
| viewer.trackedEntity = entity; | ||
| } | ||
|
|
||
| const options = [ | ||
| { | ||
| text: "Aircraft", | ||
| onselect: function () { | ||
| createModel("../../SampleData/models/CesiumAir/Cesium_Air.glb", 5000.0); | ||
| }, | ||
| }, | ||
| { | ||
| text: "Ground Vehicle", | ||
| onselect: function () { | ||
| createModel("../../SampleData/models/GroundVehicle/GroundVehicle.glb", 0); | ||
| }, | ||
| }, | ||
| { | ||
| text: "Hot Air Balloon", | ||
| onselect: function () { | ||
| createModel( | ||
| "../../SampleData/models/CesiumBalloon/CesiumBalloon.glb", | ||
| 1000.0, | ||
| ); | ||
| }, | ||
| }, | ||
| { | ||
| text: "Milk Truck", | ||
| onselect: function () { | ||
| createModel( | ||
| "../../SampleData/models/CesiumMilkTruck/CesiumMilkTruck.glb", | ||
| 0, | ||
| ); | ||
| }, | ||
| }, | ||
| { | ||
| text: "Skinned Character", | ||
| onselect: function () { | ||
| createModel("../../SampleData/models/CesiumMan/Cesium_Man.glb", 0); | ||
| }, | ||
| }, | ||
| ]; | ||
|
|
||
| Sandcastle.addToolbarMenu(options); | ||
|
|
||
| Sandcastle.addToggleButton("Shadows", viewer.shadows, function (checked) { | ||
| viewer.shadows = checked; | ||
| }); | ||
6 changes: 6 additions & 0 deletions
6
packages/sandcastle/gallery/3d-models-coloring/sandcastle.yaml
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| legacyId: 3D Models Coloring.html | ||
| title: 3D Models Coloring | ||
| description: Change color of 3D models. | ||
| labels: | ||
| - Showcases | ||
| thumbnail: ./thumbnail.jpg |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <style> | ||
| @import url(../templates/bucket.css); | ||
| </style> | ||
| <div id="cesiumContainer" class="fullSize"></div> | ||
| <div id="loadingOverlay"><h1>Loading...</h1></div> | ||
| <div id="toolbar"></div> |
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.
Totally out of scope of this PR, but we should really make a pass at getting rid of knockout from our examples. It leads to users depending on it, and ideally we want to move away from depending on it. Could you please write up an issue to take a content pass to get rid of the knockout bindings from Sandcastle 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.
I think most of the places it's used in sandcastles right now are to set up sliders and more complex toolbar inputs. I was thinking this could be handled by expanding the
Sandcastle"API" with more features. It's been in the back of my mind but I'll make sure it's written up somewhereThere 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.
Sounds good. I think it'll be good to write up an issue just in case we don't cover all the cases. If we end up doing so, then 🎉, we can close that issue.