-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add back ModelInstance class #12588
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
Draft
lukemckinstry
wants to merge
21
commits into
main
Choose a base branch
from
model-instance-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add back ModelInstance class #12588
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4337a46
Instancing draw command fixes, refactoring model node transforms
ggetz e9f495a
Cleanup
ggetz 12b4e21
Cleanup
ggetz c74a160
merge model instancing v2 updates
lukemckinstry e6d5c2f
cleanup
lukemckinstry a5cd979
docs updates
lukemckinstry 61aa900
ModelInstance specs
lukemckinstry fcba86f
add PipelineStage tests
lukemckinstry 502f42c
add update stage tests to pipeline stage test for model instancing
lukemckinstry a28c29c
wip doc notes
lukemckinstry daa0838
shader fixes for normals and instance transforms
lukemckinstry 1e40c93
fixes to model scale
lukemckinstry 10145d0
add scaling for runtime instanced models - centered at earth origin
lukemckinstry 3e8e272
fix scaling
lukemckinstry b98245e
docs cleanup runtime model instancing pipeline stage
lukemckinstry 5896065
fix runtime model instancing pipeline stage spec
lukemckinstry 025aef3
api design for model instance collection
lukemckinstry ce3f303
model collection updates
lukemckinstry ac03da3
update changelog
lukemckinstry 43f4df1
sandcastle cleanup
lukemckinstry 1454e9a
document instance collection in model class
lukemckinstry 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" | ||
/> | ||
<meta name="description" content="Create 3D models using glTF." /> | ||
<meta name="cesium-sandcastle-labels" content="Tutorials,Showcases" /> | ||
<title>Cesium Demo</title> | ||
<script type="text/javascript" src="../Sandcastle-header.js"></script> | ||
<script | ||
type="text/javascript" | ||
src="../../../Build/CesiumUnminified/Cesium.js" | ||
nomodule | ||
></script> | ||
<script type="module" src="../load-cesium-es6.js"></script> | ||
</head> | ||
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html"> | ||
<style> | ||
@import url(../templates/bucket.css); | ||
</style> | ||
<div id="cesiumContainer" class="fullSize"></div> | ||
<div id="loadingOverlay"><h1>Loading...</h1></div> | ||
<div id="toolbar"></div> | ||
<script id="cesium_sandcastle_script"> | ||
window.startup = async function (Cesium) { | ||
"use strict"; | ||
//Sandcastle_Begin | ||
const viewer = new Cesium.Viewer("cesiumContainer"); | ||
|
||
let model; | ||
try { | ||
model = await Cesium.Model.fromGltfAsync({ | ||
url: "../../SampleData/models/GroundVehicle/GroundVehicle.glb", | ||
minimumPixelSize: 64, | ||
}); | ||
viewer.scene.primitives.add(model); | ||
} catch (error) { | ||
console.log(`Failed to load model. ${error}`); | ||
} | ||
|
||
const lng = -75.1652; | ||
const lat = 39.9526; | ||
|
||
let position; | ||
const headingPositionRoll = new Cesium.HeadingPitchRoll(); | ||
const fixedFrameTransform = Cesium.Transforms.localFrameToFixedFrameGenerator( | ||
"north", | ||
"west", | ||
); | ||
|
||
let instanceTransform; | ||
for (let i = 0; i < 10; i++) { | ||
position = Cesium.Cartesian3.fromDegrees( | ||
lng + i * Math.random() * 0.0001, | ||
lat + i * 0.0001, | ||
); | ||
instanceTransform = new Cesium.Transforms.headingPitchRollToFixedFrame( | ||
position, | ||
headingPositionRoll, | ||
Cesium.Ellipsoid.WGS84, | ||
fixedFrameTransform, | ||
); | ||
model.instances.add(instanceTransform); | ||
} | ||
|
||
viewer.scene.camera.setView({ | ||
destination: new Cesium.Cartesian3( | ||
1253512.5232461668, | ||
-4732922.214567729, | ||
4074115.474546098, | ||
), | ||
orientation: new Cesium.HeadingPitchRoll( | ||
2.205737333179613, | ||
-0.7255022564055849, | ||
6.283181225638178, | ||
), | ||
}); | ||
|
||
let instance; | ||
let rotation = new Cesium.Matrix3(); | ||
let newTransform; | ||
// modify the instance transform by supplying a new rotations after a delay | ||
setTimeout(() => { | ||
for (let i = 0; i < model.instances.length; i++) { | ||
instance = model.instances.get(i); | ||
rotation = Cesium.Matrix4.getRotation(instance.transform, rotation); | ||
newTransform = Cesium.clone(instance.transform); | ||
|
||
const angleDegrees = Math.random() * 180; | ||
const angleRadians = Cesium.Math.toRadians(angleDegrees); | ||
const rotationZ = Cesium.Matrix3.fromRotationZ(angleRadians); | ||
const newRotation = Cesium.Matrix3.multiply( | ||
rotationZ, | ||
rotation, | ||
new Cesium.Matrix3(), | ||
); | ||
newTransform = Cesium.clone(instance.transform); | ||
Cesium.Matrix4.setRotation(newTransform, newRotation, newTransform); | ||
instance.transform = newTransform; | ||
} | ||
}, "6000"); | ||
//Sandcastle_End | ||
}; | ||
if (typeof Cesium !== "undefined") { | ||
window.startupCalled = true; | ||
window.startup(Cesium).catch((error) => { | ||
"use strict"; | ||
console.error(error); | ||
}); | ||
Sandcastle.finishedLoading(); | ||
} | ||
</script> | ||
</body> | ||
</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
Oops, something went wrong.
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.
@lukemckinstry Once the public API is where you'd like it, a reminder to clean up the Sandcastle example.