How to use the cesium.Quaternion function in cesium

To help you get started, we’ve selected a few cesium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AnalyticalGraphicsInc / gltf-pipeline / lib / nodeHelpers.js View on Github external
'use strict';
var Cesium = require('cesium');
var defined = Cesium.defined;
var defaultValue = Cesium.defaultValue;
var DeveloperError = Cesium.DeveloperError;
var Matrix4 = Cesium.Matrix4;
var Cartesian3 = Cesium.Cartesian3;
var Quaternion = Cesium.Quaternion;

// A set of helper functions for working with gltf nodes
// Should be called after convertDagToTree

module.exports = {
    computeFlatTransformScene: computeFlatTransformScene,
    getLocalMatrix4: getLocalMatrix4,
    getAllNodesInScene: getAllNodesInScene,
    depthFirstTraversal: depthFirstTraversal
};

// computes flattened Matrix4 transforms for ever node in the scene
// store these matrices for each node in extras._pipeline.flatTransform
function computeFlatTransformScene(scene, nodes) {
    var rootNodeIDs = scene.nodes;
    var scratchMat4 = new Matrix4();
github AnalyticalGraphicsInc / gltf-pipeline / specs / lib / GeometryMathSpec.js View on Github external
'use strict';
var Cesium = require('cesium');
var CesiumMath = Cesium.Math;
var Cartesian2 = Cesium.Cartesian2;
var Cartesian3 = Cesium.Cartesian3;
var Matrix4 = Cesium.Matrix4;
var Quaternion = Cesium.Quaternion;
var GeometryMath = require('../../lib/GeometryMath');

describe('GeometryMath', function() {
    it('sums values according to barycentric weights', function() {
        var values = [
            new Cartesian3(1, 0, 0),
            new Cartesian3(0, 1, 0),
            new Cartesian3(0, 0, 1)
        ];

        var barycentric = new Cartesian3(1/3, 1/3, 1/3);
        var result = new Cartesian3();
        result = GeometryMath.sumCartesian3sBarycentric(barycentric, values[0], values[1], values[2], result);
        var expectedResult = new Cartesian3(1/3, 1/3, 1/3);
        expect(Cartesian3.equalsEpsilon(result, expectedResult, CesiumMath.EPSILON7)).toEqual(true);
    });
github AnalyticalGraphicsInc / gltf-pipeline / specs / lib / updateVersionSpec.js View on Github external
'use strict';
const Cesium = require('cesium');
const ForEach = require('../../lib/ForEach');
const numberOfComponentsForType = require('../../lib/numberOfComponentsForType');
const readResources = require('../../lib/readResources');
const updateVersion = require('../../lib/updateVersion');

const arrayFill = Cesium.arrayFill;
const Cartesian3 = Cesium.Cartesian3;
const Quaternion = Cesium.Quaternion;
const WebGLConstants = Cesium.WebGLConstants;

describe('updateVersion', () => {
    it('defaults to 1.0 if gltf has no version', () => {
        const gltf = {};
        updateVersion(gltf, {
            targetVersion: '1.0'
        });
        expect(gltf.asset.version).toEqual('1.0');
    });

    it('updates empty glTF with version from 0.8 to 2.0', () => {
        const gltf = {
            version: '0.8'
        };
        updateVersion(gltf);
github AnalyticalGraphicsInc / 3d-tiles-tools / samples-generator / bin / 3d-tiles-samples-generator.js View on Github external
var createPointCloudTile = require('../lib/createPointCloudTile');
var createTilesetJsonSingle = require('../lib/createTilesetJsonSingle');
var getProperties = require('../lib/getProperties');
var saveTile = require('../lib/saveTile');
var saveTilesetJson = require('../lib/saveTilesetJson');
var util = require('../lib/utility');

var processGlb = gltfPipeline.processGlb;

var Cartesian3 = Cesium.Cartesian3;
var CesiumMath = Cesium.Math;
var clone = Cesium.clone;
var defaultValue = Cesium.defaultValue;
var defined  = Cesium.defined;
var Matrix4 = Cesium.Matrix4;
var Quaternion = Cesium.Quaternion;

var lowercase = util.lowercase;
var metersToLongitude = util.metersToLongitude;
var metersToLatitude = util.metersToLatitude;
var wgs84Transform = util.wgs84Transform;

var prettyJson = true;
var gzip = false;

var outputDirectory = 'output';

var versionNumber = '1.0';

var longitude = -1.31968;
var latitude = 0.698874;
var tileWidth = 200.0;
github AnalyticalGraphicsInc / gltf-pipeline / specs / lib / triangleAxisAlignedBoundingBoxOverlapSpec.js View on Github external
'use strict';
var Cesium = require('cesium');
var AxisAlignedBoundingBox = Cesium.AxisAlignedBoundingBox;
var Cartesian3 = Cesium.Cartesian3;
var Matrix4 = Cesium.Matrix4;
var Quaternion = Cesium.Quaternion;
var triangleAxisAlignedBoundingBoxOverlap = require('../../lib/triangleAxisAlignedBoundingBoxOverlap');

describe('triangleAxisAlignedBoundingBoxOverlap', function() {
    var zPlaneTriangle = [
        new Cartesian3(0.0, 0.0, 0.0),
        new Cartesian3(1.0, 0.0, 0.0),
        new Cartesian3(1.0, 1.0, 0.0)
    ];

    var boxCenter = new Cartesian3();
    var halfSize = new Cartesian3();

    var boundingBoxScratch = new AxisAlignedBoundingBox();
    function makeAxisAlignedBoundingBox(center, halfSize) {
        boundingBoxScratch.center = center;
        boundingBoxScratch.maximum = Cartesian3.add(center, halfSize, boundingBoxScratch.maximum);
github AnalyticalGraphicsInc / 3d-tiles-tools / samples-generator / lib / createBuildings.js View on Github external
'use strict';
var Cesium = require('cesium');
var Material = require('./Material');
var util = require('./utility');

var Cartesian3 = Cesium.Cartesian3;
var CesiumMath = Cesium.Math;
var defaultValue = Cesium.defaultValue;
var Matrix4 = Cesium.Matrix4;
var Quaternion = Cesium.Quaternion;

var metersToLongitude = util.metersToLongitude;
var metersToLatitude = util.metersToLatitude;

module.exports = createBuildings;

var scratchTranslation = new Cartesian3();
var scratchRotation = new Quaternion();
var scratchScale = new Cartesian3();

var whiteOpaqueMaterial = new Material({
    baseColor : [1.0, 1.0, 1.0, 1.0]
});

var whiteTranslucentMaterial = new Material({
    baseColor : [1.0, 1.0, 1.0, 0.5]
github AnalyticalGraphicsInc / gltf-pipeline / lib / bakeAmbientOcclusion.js View on Github external
'use strict';
var Cesium = require('cesium');
var clone = require('clone');

var baryCentricCoordinates = Cesium.barycentricCoordinates;
var Cartesian2 = Cesium.Cartesian2;
var Cartesian3 = Cesium.Cartesian3;
var CesiumMath = Cesium.Math;
var defaultValue = Cesium.defaultValue;
var defined = Cesium.defined;
var DeveloperError = Cesium.DeveloperError;
var Matrix3 = Cesium.Matrix3;
var Matrix4 = Cesium.Matrix4;
var Quaternion = Cesium.Quaternion;
var Ray = Cesium.Ray;
var ShaderSource = Cesium.ShaderSource;
var WebGLConstants = Cesium.WebGLConstants;
var IntersectionTests = Cesium.IntersectionTests;

var GeometryMath = require('./GeometryMath');
var getUniqueId = require('./getUniqueId');
var Jimp = require('jimp');
var NodeHelpers = require('./NodeHelpers');
var readAccessor = require('./readAccessor');
var StaticUniformGrid = require('./StaticUniformGrid');

var scratchRay = new Ray();
var barycentricCoordinateScratch = new Cartesian3();
var worldPositionScratch = new Cartesian3();
var worldNormalScratch = new Cartesian3();
github AnalyticalGraphicsInc / gltf-pipeline / lib / NodeHelpers.js View on Github external
'use strict';
var Cesium = require('cesium');
var defined = Cesium.defined;
var defaultValue = Cesium.defaultValue;
var Matrix4 = Cesium.Matrix4;
var Cartesian3 = Cesium.Cartesian3;
var Quaternion = Cesium.Quaternion;

module.exports = NodeHelpers;

/**
 * A set of helper function for working with glTF nodes.
 * Should be called after convertDagToTree
 * @constructor
 *
 * @private
 */
function NodeHelpers() {}

var cartesian3Scratch1 = new Cartesian3();
var cartesian3Scratch2 = new Cartesian3();
var quaternionScratch = new Quaternion();
var matrix4Scratch = new Matrix4();
github AnalyticalGraphicsInc / 3d-tiles-tools / generator / lib / createBatchTableHierarchy.js View on Github external
var createTilesetJsonSingle = require('./createTilesetJsonSingle');
var getBufferPadded = require('./getBufferPadded');
var getJsonBufferPadded = require('./getJsonBufferPadded');
var Material = require('./Material');
var Mesh = require('./Mesh');
var saveTile = require('./saveTile');
var saveTilesetJson = require('./saveTilesetJson');

var fsExtraReadJson = Promise.promisify(fsExtra.readJson);

var Cartesian3 = Cesium.Cartesian3;
var CesiumMath = Cesium.Math;
var defaultValue = Cesium.defaultValue;
var defined = Cesium.defined;
var Matrix4 = Cesium.Matrix4;
var Quaternion = Cesium.Quaternion;

module.exports = createBatchTableHierarchy;

var sizeOfFloat = 4;
var sizeOfUint16 = 2;

var whiteOpaqueMaterial = new Material({
    diffuse : [1.0, 1.0, 1.0, 1.0],
    ambient : [0.2, 0.2, 0.2, 1.0]
});

/**
 * Create a tileset that uses a batch table hierarchy.
 *
 * @param {Object} options An object with the following properties:
 * @param {String} options.directory Directory in which to save the tileset.
github AnalyticalGraphicsInc / gltf-pipeline / lib / updateVersion.js View on Github external
const getAccessorByteStride = require('./getAccessorByteStride');
const numberOfComponentsForType = require('./numberOfComponentsForType');
const moveTechniqueRenderStates = require('./moveTechniqueRenderStates');
const moveTechniquesToExtension = require('./moveTechniquesToExtension');
const removeUnusedElements = require('./removeUnusedElements');
const updateAccessorComponentTypes = require('./updateAccessorComponentTypes');

const Cartesian3 = Cesium.Cartesian3;
const Cartesian4 = Cesium.Cartesian4;
const clone = Cesium.clone;
const ComponentDatatype = Cesium.ComponentDatatype;
const defaultValue = Cesium.defaultValue;
const defined = Cesium.defined;
const isArray = Cesium.isArray;
const Matrix4 = Cesium.Matrix4;
const Quaternion = Cesium.Quaternion;
const WebGLConstants = Cesium.WebGLConstants;

module.exports = updateVersion;

const updateFunctions = {
    '0.8': glTF08to10,
    '1.0': glTF10to20,
    '2.0': undefined
};

/**
 * Update the glTF version to the latest version (2.0), or targetVersion if specified.
 * Applies changes made to the glTF spec between revisions so that the core library
 * only has to handle the latest version.
 *
 * @param {Object} gltf A javascript object containing a glTF asset.