How to use the cesium.ComponentDatatype 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 PrincessGod / objTo3d-tiles / lib / loadObj.js View on Github external
'use strict';
var Cesium = require('cesium');
var path = require('path');
var Promise = require('bluebird');

var ArrayStorage = require('./ArrayStorage');
var loadMtl = require('./loadMtl');
var outsideDirectory = require('./outsideDirectory');
var readLines = require('./readLines');

var Cartesian2 = Cesium.Cartesian2;
var Cartesian3 = Cesium.Cartesian3;
var ComponentDatatype = Cesium.ComponentDatatype;
var defaultValue = Cesium.defaultValue;
var defined = Cesium.defined;
var IntersectionTests = Cesium.IntersectionTests;
var Matrix3 = Cesium.Matrix3;
var OrientedBoundingBox = Cesium.OrientedBoundingBox;
var Plane = Cesium.Plane;
var PolygonPipeline = Cesium.PolygonPipeline;
var Ray = Cesium.Ray;
var RuntimeError = Cesium.RuntimeError;
var WindingOrder = Cesium.WindingOrder;

module.exports = loadObj;

// Object name (o) -> node
// Group name (g) -> mesh
// Material name (usemtl) -> primitive
github AnalyticalGraphicsInc / gltf-pipeline / lib / compressDracoMeshes.js View on Github external
const addBuffer = require('./addBuffer');
const addExtensionsRequired = require('./addExtensionsRequired');
const addExtensionsUsed = require('./addExtensionsUsed');
const addToArray = require('./addToArray');
const ForEach = require('./ForEach');
const numberOfComponentsForType = require('./numberOfComponentsForType');
const readAccessorPacked = require('./readAccessorPacked');
const removeUnusedElements = require('./removeUnusedElements');
const replaceWithDecompressedPrimitive = require('./replaceWithDecompressedPrimitive');
const splitPrimitives = require('./splitPrimitives');

const arrayFill = Cesium.arrayFill;
const Cartesian3 = Cesium.Cartesian3;
const Check = Cesium.Check;
const clone = Cesium.clone;
const ComponentDatatype = Cesium.ComponentDatatype;
const defaultValue = Cesium.defaultValue;
const defined = Cesium.defined;
const RuntimeError = Cesium.RuntimeError;
const WebGLConstants = Cesium.WebGLConstants;

// Prepare encoder for compressing meshes.
const encoderModule = draco3d.createEncoderModule({});

module.exports = compressDracoMeshes;

/**
 * Compresses meshes using Draco compression in the glTF model.
 *
 * @param {Object} gltf A javascript object containing a glTF asset.
 * @param {Object} options The same options object as {@link processGltf}
 * @param {Object} options.dracoOptions Options defining Draco compression settings.
github a348019017 / 3d_tiles_tools / lib / gltfEx / gltfContainer.js View on Github external
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Cesium = require("cesium");
const fs = require("fs-extra");
const _ = require("lodash");
const dataUriToBuffer = require("data-uri-to-buffer");
const buffer_1 = require("buffer");
const envelop3D_1 = require("../quadtree/envelop3D");
const mime = require("mime");
const path = require("path");
const gltfExporter_1 = require("./gltfExporter");
const glb2b3dm = require("../b3dm/glbToB3dm");
var ComponentDatatype = Cesium.ComponentDatatype;
var defined = Cesium.defined;
//对应于bufferView中的target
var WebGLConstants = Cesium.WebGLConstants;
function getComponentCount(type) {
    switch (type) {
        case 'SCALAR':
            return 1;
        case 'VEC2':
            return 2;
        case 'VEC3':
            return 3;
        case 'VEC4':
        case 'MAT2':
            return 4;
        case 'MAT3':
            return 9;
github AnalyticalGraphicsInc / 3d-tiles-tools / samples-generator / lib / Mesh.js View on Github external
'use strict';
var Cesium = require('cesium');
var Material = require('./Material');
var util = require('./utility');

var Cartesian3 = Cesium.Cartesian3;
var ComponentDatatype = Cesium.ComponentDatatype;
var defined = Cesium.defined;
var Matrix4 = Cesium.Matrix4;

var typeToNumberOfComponents = util.typeToNumberOfComponents;

module.exports = Mesh;

var sizeOfUint16 = 2;
var sizeOfFloat32 = 4;

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

/**
 * Stores the vertex attributes and indices describing a mesh.
github PrincessGod / objTo3d-tiles / lib / createGltf.js View on Github external
'use strict';
var Cesium = require('cesium');
var getBufferPadded = require('./getBufferPadded');
var getDefaultMaterial = require('./loadMtl').getDefaultMaterial;
var Texture = require('./Texture');
var ArrayStorage = require('./ArrayStorage');

var ComponentDatatype = Cesium.ComponentDatatype;
var defined = Cesium.defined;
var WebGLConstants = Cesium.WebGLConstants;

module.exports = createGltf;

var nameRegtex = /^[^_-]+/g;

/**
 * Create a glTF from obj data.
 *
 * @param {Object} objData An object containing an array of nodes containing geometry information and an array of materials.
 * @param {Object} options The options object passed along from lib/obj2gltf.js
 * @returns {Object} A glTF asset.
 *
 * @private
 */
github AnalyticalGraphicsInc / gltf-pipeline / lib / primitiveToGeometry.js View on Github external
'use strict';
var readAccessor = require('./readAccessor');
var numberOfComponentsForType = require('./numberOfComponentsForType');
var modeToPrimitiveType = require('./modeToPrimitiveType');
var Cesium = require('cesium');
var Geometry = Cesium.Geometry;
var GeometryAttribute = Cesium.GeometryAttribute;
var ComponentDatatype = Cesium.ComponentDatatype;
var Cartesian3 = Cesium.Cartesian3;
var defined = Cesium.defined;

module.exports = primitiveToGeometry;

function primitiveToGeometry(gltf, primitive) {
    var positionId = primitive.attributes.POSITION;
    var positionAccessor = gltf.accessors[positionId];
    var componentsPerPosition = numberOfComponentsForType(positionAccessor.type);
    var positionValues = readAccessor(gltf, positionAccessor);
    var positionLength = positionValues.data.length;

    var packedPositions = new Array(positionLength * 3);
    for (var i = 0; i < positionLength; ++i) {
        Cartesian3.pack(positionValues.data[i], packedPositions, i * 3);
    }
github AnalyticalGraphicsInc / gltf-pipeline / lib / getComponentReader.js View on Github external
'use strict';
const Cesium = require('cesium');

const ComponentDatatype = Cesium.ComponentDatatype;

module.exports = getComponentReader;

/**
 * Returns a function to read and convert data from a DataView into an array.
 *
 * @param {Number} componentType Type to convert the data to.
 * @returns {ComponentReader} Function that reads and converts data.
 *
 * @private
 */
function getComponentReader(componentType) {
    switch (componentType) {
        case ComponentDatatype.BYTE:
            return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
                for (let i = 0; i < numberOfComponents; ++i) {
github AnalyticalGraphicsInc / gltf-pipeline / lib / splitPrimitives.js View on Github external
'use strict';
const Cesium = require('cesium');
const hashObject = require('object-hash');
const addBuffer = require('./addBuffer');
const addToArray = require('./addToArray');
const findAccessorMinMax = require('./findAccessorMinMax');
const ForEach = require('./ForEach');
const readAccessorPacked = require('./readAccessorPacked');
const removeUnusedElements = require('./removeUnusedElements');

const clone = Cesium.clone;
const ComponentDatatype = Cesium.ComponentDatatype;
const defaultValue = Cesium.defaultValue;
const defined = Cesium.defined;
const numberOfComponentsForType = Cesium.numberOfComponentsForType;

module.exports = splitPrimitives;

/**
 * Splits primitives that reference different indices within the same mesh.
 * This stage is used internally by compressDracoMeshes.
 *
 * @param {Object} gltf A javascript object containing a glTF asset.
 * @returns {Object} glTF with primitives split.
 *
 * @private
 */
function splitPrimitives(gltf) {
github AnalyticalGraphicsInc / gltf-pipeline / lib / readAccessorPacked.js View on Github external
'use strict';
const Cesium = require('cesium');
const getAccessorByteStride = require('./getAccessorByteStride');
const getComponentReader = require('./getComponentReader');
const numberOfComponentsForType = require('./numberOfComponentsForType');

const arrayFill = Cesium.arrayFill;
const ComponentDatatype = Cesium.ComponentDatatype;
const defined = Cesium.defined;

module.exports = readAccessorPacked;

/**
 * Returns the accessor data in a contiguous array.
 *
 * @param {Object} gltf A javascript object containing a glTF asset.
 * @param {Object} accessor The accessor.
 * @returns {Array} The accessor values in a contiguous array.
 *
 * @private
 */
function readAccessorPacked(gltf, accessor) {
    const byteStride = getAccessorByteStride(gltf, accessor);
    const componentTypeByteLength = ComponentDatatype.getSizeInBytes(accessor.componentType);
github AnalyticalGraphicsInc / gltf-pipeline / lib / findAccessorMinMax.js View on Github external
'use strict';
const Cesium = require('cesium');

const arrayFill = Cesium.arrayFill;
const ComponentDatatype = Cesium.ComponentDatatype;
const defined = Cesium.defined;

const getAccessorByteStride = require('./getAccessorByteStride');
const getComponentReader = require('./getComponentReader');
const numberOfComponentsForType = require('./numberOfComponentsForType');

module.exports = findAccessorMinMax;

/**
 * Finds the min and max values of the accessor.
 *
 * @param {Object} gltf A javascript object containing a glTF asset.
 * @param {Object} accessor The accessor object from the glTF asset to read.
 * @returns {{min: Array, max: Array}} min holding the array of minimum values and max holding the array of maximum values.
 *
 * @private