@gltf-transform/core
Advanced tools
Comparing version 0.1.0 to 0.2.1
@@ -1,78 +0,56 @@ | ||
declare const AccessorType: { | ||
SCALAR: string; | ||
VEC2: string; | ||
VEC3: string; | ||
VEC4: string; | ||
MAT2: string; | ||
MAT3: string; | ||
MAT4: string; | ||
}; | ||
declare const AccessorTypeData: { | ||
SCALAR: { | ||
value: string; | ||
size: number; | ||
}; | ||
VEC2: { | ||
value: string; | ||
size: number; | ||
}; | ||
VEC3: { | ||
value: string; | ||
size: number; | ||
}; | ||
VEC4: { | ||
value: string; | ||
size: number; | ||
}; | ||
MAT2: { | ||
value: string; | ||
size: number; | ||
}; | ||
MAT3: { | ||
value: string; | ||
size: number; | ||
}; | ||
MAT4: { | ||
value: string; | ||
size: number; | ||
}; | ||
}; | ||
declare const AccessorComponentType: { | ||
BYTE: number; | ||
UNSIGNED_BYTE: number; | ||
SHORT: number; | ||
UNSIGNED_SHORT: number; | ||
UNSIGNED_INT: number; | ||
FLOAT: number; | ||
}; | ||
declare const AccessorComponentTypeData: { | ||
'5120': { | ||
value: string; | ||
size: number; | ||
}; | ||
'5121': { | ||
value: string; | ||
size: number; | ||
}; | ||
'5122': { | ||
value: string; | ||
size: number; | ||
}; | ||
'5123': { | ||
value: string; | ||
size: number; | ||
}; | ||
'5125': { | ||
value: string; | ||
size: number; | ||
}; | ||
'5126': { | ||
value: string; | ||
size: number; | ||
}; | ||
}; | ||
declare const BufferViewTarget: { | ||
ARRAY_BUFFER: number; | ||
ELEMENT_ARRAY_BUFFER: number; | ||
}; | ||
export { AccessorType, AccessorTypeData, AccessorComponentType, AccessorComponentTypeData, BufferViewTarget }; | ||
/** | ||
* Current version of the package. | ||
* @hidden | ||
*/ | ||
export declare const VERSION = "v0.2"; | ||
/** @hidden */ | ||
export declare const NAME = "@gltf-transform/core"; | ||
/** | ||
* Interface allowing Accessor setter/getter methods to be used interchangeably with gl-matrix | ||
* arrays or with three.js math objects' fromArray/toArray methods. For example, THREE.Vector2, | ||
* THREE.Vector3, THREE.Vector4, THREE.Quaternion, THREE.Matrix3, THREE.Matrix4, and THREE.Color. | ||
* | ||
* @hidden | ||
*/ | ||
export interface ArrayProxy { | ||
/** Sets the value of the object from an array of values. */ | ||
fromArray(array: number[]): ArrayProxy; | ||
/** Writes the value of the object into the given array. */ | ||
toArray(array: number[]): number[]; | ||
} | ||
/** | ||
* 2-dimensional vector. | ||
* @hidden | ||
*/ | ||
export declare type vec2 = [number, number]; | ||
/** | ||
* 3-dimensional vector. | ||
* @hidden | ||
*/ | ||
export declare type vec3 = [number, number, number]; | ||
/** | ||
* 4-dimensional vector, e.g. RGBA or a quaternion. | ||
* @hidden | ||
*/ | ||
export declare type vec4 = [number, number, number, number]; | ||
/** | ||
* 3x3 matrix, e.g. an affine transform of a 2D vector. | ||
* @hidden | ||
*/ | ||
export declare type mat3 = [number, number, number, number, number, number, number, number, number]; | ||
/** | ||
* 4x4 matrix, e.g. an affine transform of a 3D vector. | ||
* @hidden | ||
*/ | ||
export declare type mat4 = [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]; | ||
/** @hidden */ | ||
export declare const GLB_BUFFER = "__glb.bin"; | ||
/** | ||
* Abstraction representing any one of the typed array classes supported by glTF and JavaScript. | ||
* @hidden | ||
*/ | ||
export declare type TypedArray = Float32Array | Uint32Array | Uint16Array | Uint8Array | Int16Array | Int8Array; | ||
/** @hidden */ | ||
export declare class NotImplementedError extends Error { | ||
constructor(); | ||
} |
@@ -1,36 +0,109 @@ | ||
interface IBufferMap { | ||
[s: string]: ArrayBuffer; | ||
} | ||
interface IContainer { | ||
json: GLTF.IGLTF; | ||
getBuffer(bufferIndex: number): ArrayBuffer; | ||
setBuffer(bufferIndex: number, buffer: ArrayBuffer): void; | ||
validate(): void; | ||
} | ||
import { Accessor, Buffer, Material, Mesh, Node, Primitive, PropertyGraph, Root, Scene, Texture } from './properties/index'; | ||
import { Logger } from './utils'; | ||
export declare type Transform = (container: Container) => void; | ||
/** | ||
* Wrapper for a glTF asset. | ||
* # Container | ||
* | ||
* *Wraps a glTF asset and its resources for easier modification.* | ||
* | ||
* A new resource {@link Property} (e.g. a {@link Mesh} or {@link Material}) is created by calling | ||
* factory methods on the container, `container.create*(name)`. Resources are destroyed by calling | ||
* {@link Property.dispose}(). | ||
* | ||
* ```ts | ||
* const texture1 = container.createTexture('myTexture') | ||
* .setImage(arrayBuffer) | ||
* .setMimeType('image/png'); | ||
* const texture2 = container.createTexture('myTexture2') | ||
* .setImage(arrayBuffer) | ||
* .setMimeType('image/png'); | ||
* | ||
* container.getRoot().listTextures(); // → [texture x 2] | ||
* | ||
* container | ||
* .transform( | ||
* prune({textures: true}), | ||
* ao({samples: 500}), | ||
* split({meshes: ['Cog', 'Wheel']}) | ||
* ); | ||
* | ||
* container.getRoot().listTextures(); // → [texture x 1] | ||
* ``` | ||
* | ||
* Reference: | ||
* - [glTF → Basics](https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#gltf-basics) | ||
* - [glTF → Concepts](https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#concepts) | ||
* | ||
* @category Containers | ||
*/ | ||
declare class GLTFContainer implements IContainer { | ||
json: GLTF.IGLTF; | ||
resources: IBufferMap; | ||
constructor(json: GLTF.IGLTF, resources: IBufferMap); | ||
export declare class Container { | ||
private graph; | ||
private root; | ||
private logger; | ||
/** Returns the glTF {@link Root} property. */ | ||
getRoot(): Root; | ||
/** | ||
* Resolves a resource URI. | ||
* @param uri | ||
* Returns the {@link Graph} representing connectivity of resources within this container. | ||
* | ||
* @hidden | ||
*/ | ||
resolveURI(uri: string): ArrayBuffer; | ||
getBuffer(bufferIndex: number): ArrayBuffer; | ||
setBuffer(bufferIndex: number, buffer: ArrayBuffer): void; | ||
getGraph(): PropertyGraph; | ||
/** Returns the {@link Logger} instance used for any operations performed on this container. */ | ||
getLogger(): Logger; | ||
/** | ||
* Creates a deep copy of the asset. | ||
* Overrides the {@link Logger} instance used for any operations performed on this container. | ||
* | ||
* Usage: | ||
* | ||
* ```ts | ||
* container | ||
* .setLogger(new Logger(Logger.Verbosity.SILENT)) | ||
* .transform(split(), ao({samples: 50})); | ||
* ``` | ||
*/ | ||
clone(): GLTFContainer; | ||
validate(): void; | ||
setLogger(logger: Logger): Container; | ||
/** | ||
* Returns the accessor for the given index, as a typed array. | ||
* @param index | ||
* Clones this container and its graph, copying all resources within it. | ||
* @hidden | ||
*/ | ||
getAccessorArray(index: number): Float32Array | Uint32Array | Uint16Array | Uint8Array; | ||
equals(other: GLTFContainer): boolean; | ||
clone(): Container; | ||
/** | ||
* Applies a series of modifications to this container. Each transformation is synchronous, | ||
* takes the {@link Container} as input, and returns nothing. Transforms are applied in the | ||
* order given, which may affect the final result. | ||
* | ||
* Usage: | ||
* | ||
* ```ts | ||
* container.transform( | ||
* ao({samples: 500}), | ||
* prune() | ||
* ); | ||
* ``` | ||
* | ||
* @param transforms List of synchronous transformation functions to apply. | ||
*/ | ||
transform(...transforms: Transform[]): Container; | ||
/********************************************************************************************** | ||
* Property factory methods. | ||
*/ | ||
/** Creates a new {@link Scene} attached to this container's {@link Root}. */ | ||
createScene(name: string): Scene; | ||
/** Creates a new {@link Node} attached to this container's {@link Root}. */ | ||
createNode(name: string): Node; | ||
/** Creates a new {@link Mesh} attached to this container's {@link Root}. */ | ||
createMesh(name: string): Mesh; | ||
/** | ||
* Creates a new {@link Primitive}. Primitives must be attached to a {@link Mesh} | ||
* for use and export; they are not otherwise associated with a {@link Root}. | ||
*/ | ||
createPrimitive(): Primitive; | ||
/** Creates a new {@link Material} attached to this container's {@link Root}. */ | ||
createMaterial(name: string): Material; | ||
/** Creates a new {@link Texture} attached to this container's {@link Root}. */ | ||
createTexture(name: string): Texture; | ||
/** Creates a new {@link Accessor} attached to this container's {@link Root}. */ | ||
createAccessor(name: string, buffer: Buffer): Accessor; | ||
/** Creates a new {@link Buffer} attached to this container's {@link Root}. */ | ||
createBuffer(name: string): Buffer; | ||
} | ||
export { GLTFContainer, IBufferMap, IContainer }; |
@@ -1,6 +0,5 @@ | ||
import { GLTFContainer } from './container'; | ||
import { GLTFUtil } from './util'; | ||
import { NodeIO, WebIO } from './io'; | ||
import { Logger, LoggerVerbosity } from './logger'; | ||
import { AccessorType, AccessorTypeData, AccessorComponentType, AccessorComponentTypeData, BufferViewTarget } from './constants'; | ||
export { GLTFUtil, GLTFContainer, NodeIO, WebIO, Logger, LoggerVerbosity, AccessorType, AccessorTypeData, AccessorComponentType, AccessorComponentTypeData, BufferViewTarget }; | ||
export { Document, Transform } from './document'; | ||
export { Accessor, Buffer, Property, Material, Mesh, Node, Primitive, Root, Scene, Texture, TextureInfo, TextureSampler } from './properties'; | ||
export { Graph } from './graph/'; | ||
export { NodeIO, WebIO } from './io/'; | ||
export { BufferUtils, FileUtils, ImageUtils, Logger, uuid } from './utils/'; |
{ | ||
"name": "@gltf-transform/core", | ||
"version": "0.1.0", | ||
"version": "0.2.1", | ||
"repository": "github:donmccurdy/glTF-Transform", | ||
"description": "JavaScript and TypeScript utilities for processing glTF 3D models", | ||
"main": "dist/gltf-transform-core.js", | ||
"module": "dist/gltf-transform-core.module.js", | ||
"types": "dist/index.d.ts", | ||
"description": "glTF 2.0 SDK for JavaScript, TypeScript, and Node.js", | ||
"main": "dist/core.js", | ||
"module": "dist/core.module.js", | ||
"source": "src/core.ts", | ||
"types": "dist/core.d.ts", | ||
"scripts": { | ||
"test": "node test/test.js" | ||
"dist": "microbundle", | ||
"watch": "microbundle watch", | ||
"watch:debug": "microbundle watch --no-compress" | ||
}, | ||
@@ -28,3 +31,9 @@ "keywords": [ | ||
], | ||
"gitHead": "c6fa67080f7863f4ed79560ab1b812ccd8a73fbe" | ||
"dependencies": { | ||
"gl-matrix": "^3.3.0" | ||
}, | ||
"mangle": { | ||
"regex": "^_" | ||
}, | ||
"gitHead": "16389dd42919d314d61571ed22f58af8af86e08d" | ||
} |
@@ -1,19 +0,27 @@ | ||
# glTF-Transform-Util | ||
# @gltf-transform/core | ||
<!-- This file is automatically generated. Please don't edit it directly: | ||
if you find an error, edit the source file (likely index.js), and re-run | ||
./scripts/generate-readmes in the turf project. --> | ||
![Status](https://img.shields.io/badge/status-experimental-orange.svg) | ||
[![Latest NPM release](https://img.shields.io/npm/v/@gltf-transform/core.svg)](https://www.npmjs.com/package/@gltf-transform/core) | ||
[![License](https://img.shields.io/npm/l/@gltf-transform/core.svg)](https://github.com/donmccurdy/glTF-Transform/blob/master/LICENSE) | ||
[![Build Status](https://travis-ci.com/donmccurdy/glTF-Transform.svg?branch=master)](https://travis-ci.com/donmccurdy/glTF-Transform) | ||
> This module is part of the [glTF-Transform project](https://github.com/donmccurdy/glTF-Transform), where you can create PRs and | ||
issues. | ||
Part of the glTF-Transform project. | ||
- GitHub: https://github.com/donmccurdy/glTF-Transform | ||
- Documentation: https://gltf-transform.donmccurdy.com/ | ||
## Installation | ||
Install: | ||
``` | ||
npm install @gltf-transform/core | ||
npm install --save @gltf-transform/core | ||
``` | ||
Import: | ||
```js | ||
// ES6 | ||
import { Document, Scene, WebIO } from '@gltf-transform/core'; | ||
// CommonJS | ||
const { Document, Scene, WebIO } = require('@gltf-transform/core'); | ||
``` |
@@ -1,44 +0,77 @@ | ||
const AccessorType = { | ||
SCALAR: 'SCALAR', | ||
VEC2: 'VEC2', | ||
VEC3: 'VEC3', | ||
VEC4: 'VEC4', | ||
MAT2: 'MAT2', | ||
MAT3: 'MAT3', | ||
MAT4: 'MAT4', | ||
/** | ||
* Current version of the package. | ||
* @hidden | ||
*/ | ||
export const VERSION = 'v0.2'; | ||
/** @hidden */ | ||
export const NAME = '@gltf-transform/core'; | ||
/** | ||
* Interface allowing Accessor setter/getter methods to be used interchangeably with gl-matrix | ||
* arrays or with three.js math objects' fromArray/toArray methods. For example, THREE.Vector2, | ||
* THREE.Vector3, THREE.Vector4, THREE.Quaternion, THREE.Matrix3, THREE.Matrix4, and THREE.Color. | ||
* | ||
* @hidden | ||
*/ | ||
export interface ArrayProxy { | ||
/** Sets the value of the object from an array of values. */ | ||
fromArray(array: number[]): ArrayProxy; | ||
/** Writes the value of the object into the given array. */ | ||
toArray(array: number[]): number[]; | ||
} | ||
const AccessorTypeData = { | ||
SCALAR: {value: 'SCALAR', size: 1}, | ||
VEC2: {value: 'VEC2', size: 2}, | ||
VEC3: {value: 'VEC3', size: 3}, | ||
VEC4: {value: 'VEC4', size: 4}, | ||
MAT2: {value: 'MAT2', size: 4}, | ||
MAT3: {value: 'MAT3', size: 9}, | ||
MAT4: {value: 'MAT4', size: 16}, | ||
}; | ||
const AccessorComponentType = { | ||
BYTE: 5120, | ||
UNSIGNED_BYTE: 5121, | ||
SHORT: 5122, | ||
UNSIGNED_SHORT: 5123, | ||
UNSIGNED_INT: 5125, | ||
FLOAT: 5126, | ||
}; | ||
/** | ||
* 2-dimensional vector. | ||
* @hidden | ||
*/ | ||
export type vec2 = [number, number]; | ||
const AccessorComponentTypeData = { | ||
'5120': {value: 'BYTE', size: 1 }, | ||
'5121': {value: 'UNSIGNED_BYTE', size: 1 }, | ||
'5122': {value: 'SHORT', size: 2 }, | ||
'5123': {value: 'UNSIGNED_SHORT', size: 2 }, | ||
'5125': {value: 'UNSIGNED_INT', size: 4 }, | ||
'5126': {value: 'FLOAT', size: 4 }, | ||
}; | ||
/** | ||
* 3-dimensional vector. | ||
* @hidden | ||
*/ | ||
export type vec3 = [number, number, number]; | ||
const BufferViewTarget = { | ||
ARRAY_BUFFER: 34962, | ||
ELEMENT_ARRAY_BUFFER: 34963 | ||
/** | ||
* 4-dimensional vector, e.g. RGBA or a quaternion. | ||
* @hidden | ||
*/ | ||
export type vec4 = [number, number, number, number]; | ||
/** | ||
* 3x3 matrix, e.g. an affine transform of a 2D vector. | ||
* @hidden | ||
*/ | ||
export type mat3 = [ | ||
number, number, number, | ||
number, number, number, | ||
number, number, number, | ||
]; | ||
/** | ||
* 4x4 matrix, e.g. an affine transform of a 3D vector. | ||
* @hidden | ||
*/ | ||
export type mat4 = [ | ||
number, number, number, number, | ||
number, number, number, number, | ||
number, number, number, number, | ||
number, number, number, number, | ||
]; | ||
/** @hidden */ | ||
export const GLB_BUFFER = '__glb.bin'; | ||
/** | ||
* Abstraction representing any one of the typed array classes supported by glTF and JavaScript. | ||
* @hidden | ||
*/ | ||
export type TypedArray = Float32Array | Uint32Array | Uint16Array | Uint8Array | Int16Array | Int8Array; | ||
/** @hidden */ | ||
export class NotImplementedError extends Error { | ||
constructor () { | ||
super('@gltf-transform/core: Not implemented.'); | ||
} | ||
} | ||
export { AccessorType, AccessorTypeData, AccessorComponentType, AccessorComponentTypeData, BufferViewTarget }; |
@@ -1,12 +0,18 @@ | ||
import { GLTFContainer } from './container'; | ||
import { GLTFUtil } from './util'; | ||
import { NodeIO, WebIO } from './io'; | ||
import { Logger, LoggerVerbosity } from './logger'; | ||
import { AccessorType, AccessorTypeData, AccessorComponentType, AccessorComponentTypeData, BufferViewTarget } from './constants'; | ||
export { Document, Transform } from './document'; | ||
export { Accessor, Buffer, Property, Material, Mesh, Node, Primitive, Root, Scene, Texture, TextureInfo, TextureSampler } from './properties'; | ||
export { Graph } from './graph/'; | ||
export { NodeIO, WebIO } from './io/'; | ||
export { BufferUtils, FileUtils, ImageUtils, Logger, uuid } from './utils/'; | ||
export { | ||
GLTFUtil, GLTFContainer, | ||
NodeIO, WebIO, | ||
Logger, LoggerVerbosity, | ||
AccessorType, AccessorTypeData, AccessorComponentType, AccessorComponentTypeData, BufferViewTarget | ||
}; | ||
// Improved gl-matrix performance in modern web browsers. | ||
import {glMatrix} from 'gl-matrix'; | ||
glMatrix.setMatrixArrayType(Array); | ||
/** [[include:CONCEPTS.md]] */ | ||
namespace Concepts {}; | ||
/** [[include:SCRIPTING.md]] */ | ||
namespace Scripting {}; | ||
/** [[include:CONTRIBUTING.md]] */ | ||
namespace Contributing {}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1464848
83
6551
28
1
4
19
+ Addedgl-matrix@^3.3.0
+ Addedgl-matrix@3.4.3(transitive)