Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@gltf-transform/core
Advanced tools
Part of the glTF-Transform project.
Install the scripting packages:
npm install --save @gltf-transform/core @gltf-transform/extensions @gltf-transform/functions
Read and write glTF scenes with platform I/O utilities WebIO, NodeIO, or DenoIO:
import { Document, NodeIO } from '@gltf-transform/core';
import { KHRONOS_EXTENSIONS } from '@gltf-transform/extensions';
import draco3d from 'draco3dgltf';
// Configure I/O.
const io = new NodeIO()
.registerExtensions(KHRONOS_EXTENSIONS)
.registerDependencies({
'draco3d.decoder': await draco3d.createDecoderModule(), // Optional.
'draco3d.encoder': await draco3d.createEncoderModule(), // Optional.
});
// Read from URL.
const document = await io.read('path/to/model.glb');
// Write to byte array (Uint8Array).
const glb = await io.writeBinary(document);
To perform changes to an existing glTF Document, import off-the-shelf scripts from the Functions package, or write your own using API classes like Material, Primitive, and Texture.
// Import default functions.
import { prune, dedup } from '@gltf-transform/functions';
import * as sharp from 'sharp'; // Node.js only.
await document.transform(
// Losslessly resample animation frames.
resample(),
// Remove unused nodes, textures, or other data.
prune(),
// Remove duplicate vertex or texture data, if any.
dedup(),
// Compress mesh geometry with Draco.
draco(),
// Convert textures to WebP (Requires glTF Transform v3 and Node.js).
textureCompress({
encoder: sharp,
targetFormat: 'webp',
resize: [1024, 2024],
}),
// Custom transform.
backfaceCulling({cull: true}),
);
// Custom transform: enable/disable backface culling.
function backfaceCulling(options) {
return (document) => {
for (const material of document.getRoot().listMaterials()) {
material.setDoubleSided(!options.cull);
}
};
}
To learn how glTF-Transform works, and the architecture of the scripting API, start with Concepts. To try out the scripting API without installing anything, visit gltf.report/, load a glTF model, and open the Script tab.
See Credits.
Copyright 2023, MIT License.
FAQs
glTF 2.0 SDK for JavaScript and TypeScript, on Web and Node.js.
The npm package @gltf-transform/core receives a total of 4,397 weekly downloads. As such, @gltf-transform/core popularity was classified as popular.
We found that @gltf-transform/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.