--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/uFjOz5F0uK8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
var viewer = new Cesium.Viewer('cesiumContainer', { sceneMode: Cesium.SceneMode.COLUMBUS_VIEW, //Hide the base layer picker baseLayerPicker: false, //Use BingMaps imageryProvider: new Cesium.BingMapsImageryProvider({ url: '//dev.virtualearth.net', mapStyle: Cesium.BingMapsStyle.ROAD }), fullscreenButton: false, homeButton: false, navigationHelpButton: false, navigationInstructionsInitiallyVisible: false, animation: false, geocoder: false, infobox: false, sceneModePicker: false, selectionIndicator: false, timeline: false
});Sandcastle.addToolbarButton('Matrix4.fromScale(2.0)', function() { var CurrentModelMatrix = primitives.get(0).geometryInstances[0].modelMatrix; CurrentModelMatrix = Cesium.Matrix4.fromScale(2.0);});Sandcastle.addToolbarButton('Matrix4.fromScale(3.0)', function() { var CurrentModelMatrix = primitives.get(0).geometryInstances[0].modelMatrix; CurrentModelMatrix = Cesium.Matrix4.fromScale(3.0);});Sandcastle.addToolbarButton('Matrix4.fromScale(4.0)', function() { var CurrentModelMatrix = primitives.get(0).geometryInstances[0].modelMatrix; CurrentModelMatrix = Cesium.Matrix4.fromScale(2.0);});var scene = viewer.scene;var primitives = scene.primitives;
function flyTo(x,y) { try { viewer.scene.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(x - .006,y - .015, 2000.0), up: new Cesium.Cartesian3(0.0, 0.0, 1), direction: new Cesium.Cartesian3(0.3, 0.5, -.5) }); } catch (e) { alert(e.message); } }var positionOnEllipsoid = Cesium.Cartesian3.fromDegrees(-120.0, 40.0);var modelMatrix = Cesium.Matrix4.multiplyByTranslation( Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid), new Cesium.Cartesian3(0.0, 0.0, length * 0.5), new Cesium.Matrix4());// Create the cylinder geometry.var cylinderGeometry = new Cesium.CylinderGeometry({ length : 1000.0, topRadius : 100.0, bottomRadius : 100.0, vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT});// Create a geometry instance using the cylinder geometry// created above. We can also specify a color attribute,// in this case, we're creating a solid green color.var greenCylinder = new Cesium.GeometryInstance({ geometry : cylinderGeometry, modelMatrix : modelMatrix, attributes : { color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.GREEN) }});primitives.add(new Cesium.Primitive({ releaseGeometryInstances: false, geometryInstances : [greenCylinder], appearance : new Cesium.PerInstanceColorAppearance({ closed : true, translucent: false })}));flyTo(-120,40);To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/uFjOz5F0uK8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.
var viewer = new Cesium.Viewer('cesiumContainer', { sceneMode: Cesium.SceneMode.COLUMBUS_VIEW, //Hide the base layer picker baseLayerPicker: false, //Use BingMaps imageryProvider: new Cesium.BingMapsImageryProvider({ url: '//dev.virtualearth.net', mapStyle: Cesium.BingMapsStyle.ROAD }), fullscreenButton: false, homeButton: false, navigationHelpButton: false, navigationInstructionsInitiallyVisible: false, animation: false, geocoder: false, infobox: false, sceneModePicker: false, selectionIndicator: false, timeline: false
});var scene = viewer.scene;var toolbar = document.getElementById('toolbar');var primitives = viewer.scene.primitives;// Draw a red box and position it on the globe surface.
var dimensions = new Cesium.Cartesian3(50.0, 50.0, 1000.0);// Box geometries are initially centered on the origin.// We can use a model matrix to position the box on the// globe surface.var positionOnEllipsoid = Cesium.Cartesian3.fromDegrees(-111, 41);var boxModelMatrix = Cesium.Matrix4.multiplyByTranslation( Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid), new Cesium.Cartesian3(0.0, 0.0, dimensions.z * 0.5), new Cesium.Matrix4());// Create a box geometry.var boxGeometry = Cesium.BoxGeometry.fromDimensions({ vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT, dimensions : dimensions});// Create a geometry instance using the geometry// and model matrix created above.var boxGeometryInstance = new Cesium.GeometryInstance({ geometry : boxGeometry, modelMatrix : boxModelMatrix, attributes : { color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5)) }});// Add the geometry instance to primitives.primitives.add(new Cesium.Primitive({ releaseGeometryInstances : false, asynchronous : false, geometryInstances : boxGeometryInstance, appearance : new Cesium.PerInstanceColorAppearance({ closed: true })}));viewer.scene.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(-111 - .006, 41 - .05, 5000.0), up: new Cesium.Cartesian3(0.0, 0.0, 1), direction: new Cesium.Cartesian3(0.3, 0.5, -.5) });Sandcastle.addToolbarButton('Change Model Matrix', function() { var prim = viewer.scene.primitives.get(0); alert(prim);//check to see if primitive object exists var matrix = prim.geometryInstances.modelMatrix; alert(matrix);//check to see if the matrix object exists var newMatrix = Cesium.Matrix4.multiplyByTranslation( Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid), new Cesium.Cartesian3(0.0, 0.0, dimensions.z), new Cesium.Matrix4()); prim.geometryInstances.modelMatrix = newMatrix; });
function changePolygonHeight(layer, height) {
var datasource = viewer.dataSources.get(layer); datasource.entities.suspendEvents(); var entities = viewer.dataSources.get(layer).entities.entities for (var i = 0; i < entities.length; i++) { var extrudedHeights = source.entities.entities[i]._polygon._extrudedHeight._values; for (var j = 0; j < extrudedHeights.length; j++) { var extrudedHeight = source.entities.entities[i]._polygon._extrudedHeight._values[j].data; extrudedHeight = extrudedHeight * 2; } } datasource.entities.resumeEvents();}function changePolygonWidth(layer, width){ var datasource = viewer.dataSources.get(layer); datasource.entities.suspendEvents(); var entities = viewer.dataSources.get(layer).entities.entities for (var i = 0; i < entities.length; i++) { var lat = entities[i].lat; var long = entities[i].long; var positions = entities[i]._polygon._positions; positions.setValue(Cesium.Cartesian3.fromDegreesArray(degreesToFourPoints(lat,long))); }}function changePolygonColor(layer, red, green, blue) { var datasource = viewer.dataSources.get(layer); datasource.entities.suspendEvents(); var entities = viewer.dataSources.get(layer).entities.entities for (var i = 0; i < entities.length; i++) { entities[i]._polygon._material._color.setValue(Color.fromBytes(red,green,blue,255)); }
}function degreesToFourPoints(lattitude, longitude) { // generate four points at an equal distance from the center point var ax,ay,az,bx,by,bz,cx,cy,cz,dx,dy,dz; ax = longitude+.001; ay = lattitude+.001; az = 0.0; bx = longitude-.001; by = lattitude+.001; bz = 0.0; cx = longitude-.001; cy = lattitude-.001; cz = 0.0; dx = longitude+.001; dy = lattitude-.001; dz = 0.0; var points = [ax,ay,az,bx,by,bz,cx,cy,cz,dx,dy,dz]; return points;}