Socket
Socket
Sign inDemoInstall

@gltf-transform/core

Package Overview
Dependencies
Maintainers
1
Versions
205
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gltf-transform/core - npm Package Compare versions

Comparing version 3.4.6 to 3.4.7

70

dist/properties/node.d.ts

@@ -19,8 +19,8 @@ import { PropertyType, mat4, vec3, vec4, Nullable } from '../constants.js';

*
* Each node may have one or more children, and a transform (position, rotation, and scale) that
* applies to all of its descendants. A node may also reference (or "instantiate") other resources
* at its location, including {@link Mesh}, Camera, Light, and Skin properties. A node cannot be
* Each Node may have one or more children, and a transform (position, rotation, and scale) that
* applies to all of its descendants. A Node may also reference (or "instantiate") other resources
* at its location, including {@link Mesh}, Camera, Light, and Skin properties. A Node cannot be
* part of more than one {@link Scene}.
*
* A node's local transform is represented with array-like objects, intended to be compatible with
* A Node's local transform is represented with array-like objects, intended to be compatible with
* [gl-matrix](https://github.com/toji/gl-matrix), or with the `toArray`/`fromArray` methods of

@@ -51,17 +51,17 @@ * libraries like three.js and babylon.js.

*/
/** Returns the translation (position) of this node in local space. */
/** Returns the translation (position) of this Node in local space. */
getTranslation(): vec3;
/** Returns the rotation (quaternion) of this node in local space. */
/** Returns the rotation (quaternion) of this Node in local space. */
getRotation(): vec4;
/** Returns the scale of this node in local space. */
/** Returns the scale of this Node in local space. */
getScale(): vec3;
/** Sets the translation (position) of this node in local space. */
/** Sets the translation (position) of this Node in local space. */
setTranslation(translation: vec3): this;
/** Sets the rotation (quaternion) of this node in local space. */
/** Sets the rotation (quaternion) of this Node in local space. */
setRotation(rotation: vec4): this;
/** Sets the scale of this node in local space. */
/** Sets the scale of this Node in local space. */
setScale(scale: vec3): this;
/** Returns the local matrix of this node. */
/** Returns the local matrix of this Node. */
getMatrix(): mat4;
/** Sets the local matrix of this node. Matrix will be decomposed to TRS properties. */
/** Sets the local matrix of this Node. Matrix will be decomposed to TRS properties. */
setMatrix(matrix: mat4): this;

@@ -71,9 +71,9 @@ /**********************************************************************************************

*/
/** Returns the translation (position) of this node in world space. */
/** Returns the translation (position) of this Node in world space. */
getWorldTranslation(): vec3;
/** Returns the rotation (quaternion) of this node in world space. */
/** Returns the rotation (quaternion) of this Node in world space. */
getWorldRotation(): vec4;
/** Returns the scale of this node in world space. */
/** Returns the scale of this Node in world space. */
getWorldScale(): vec3;
/** Returns the world matrix of this node. */
/** Returns the world matrix of this Node. */
getWorldMatrix(): mat4;

@@ -83,7 +83,21 @@ /**********************************************************************************************

*/
/** Adds another node as a child of this one. Nodes cannot have multiple parents. */
/**
* Adds the given Node as a child of this Node.
*
* Requirements:
*
* 1. Nodes MAY be root children of multiple {@link Scene Scenes}
* 2. Nodes MUST NOT be children of >1 Node
* 3. Nodes MUST NOT be children of both Nodes and {@link Scene Scenes}
*
* The `addChild` method enforces these restrictions automatically, and will
* remove the new child from previous parents where needed. This behavior
* may change in future major releases of the library.
*
* @privateRemarks Requires non-graph state.
*/
addChild(child: Node): this;
/** Removes a node from this node's child node list. */
/** Removes a Node from this Node's child Node list. */
removeChild(child: Node): this;
/** Lists all child nodes of this node. */
/** Lists all child Nodes of this Node. */
listChildren(): Node[];

@@ -104,19 +118,19 @@ /** @deprecated Use {@link Node.getParentNode} and {@link listNodeScenes} instead. */

*/
/** Returns the {@link Mesh}, if any, instantiated at this node. */
/** Returns the {@link Mesh}, if any, instantiated at this Node. */
getMesh(): Mesh | null;
/**
* Sets a {@link Mesh} to be instantiated at this node. A single mesh may be instatiated by
* multiple nodes; reuse of this sort is strongly encouraged.
* Sets a {@link Mesh} to be instantiated at this Node. A single mesh may be instatiated by
* multiple Nodes; reuse of this sort is strongly encouraged.
*/
setMesh(mesh: Mesh | null): this;
/** Returns the {@link Camera}, if any, instantiated at this node. */
/** Returns the {@link Camera}, if any, instantiated at this Node. */
getCamera(): Camera | null;
/** Sets a {@link Camera} to be instantiated at this node. */
/** Sets a {@link Camera} to be instantiated at this Node. */
setCamera(camera: Camera | null): this;
/** Returns the {@link Skin}, if any, instantiated at this node. */
/** Returns the {@link Skin}, if any, instantiated at this Node. */
getSkin(): Skin | null;
/** Sets a {@link Skin} to be instantiated at this node. */
/** Sets a {@link Skin} to be instantiated at this Node. */
setSkin(skin: Skin | null): this;
/**
* Initial weights of each {@link PrimitiveTarget} for the mesh instance at this node.
* Initial weights of each {@link PrimitiveTarget} for the mesh instance at this Node.
* Most engines only support 4-8 active morph targets at a time.

@@ -126,3 +140,3 @@ */

/**
* Initial weights of each {@link PrimitiveTarget} for the mesh instance at this node.
* Initial weights of each {@link PrimitiveTarget} for the mesh instance at this Node.
* Most engines only support 4-8 active morph targets at a time.

@@ -129,0 +143,0 @@ */

16

dist/properties/scene.d.ts

@@ -26,3 +26,17 @@ import { Nullable, PropertyType } from '../constants.js';

copy(other: this, resolve?: <T extends import("./property.js").Property<import("./property.js").IProperty>>(t: T) => T): this;
/** Adds a {@link Node} to the Scene. */
/**
* Adds a {@link Node} to the Scene.
*
* Requirements:
*
* 1. Nodes MAY be root children of multiple {@link Scene Scenes}
* 2. Nodes MUST NOT be children of >1 Node
* 3. Nodes MUST NOT be children of both Nodes and {@link Scene Scenes}
*
* The `addChild` method enforces these restrictions automatically, and will
* remove the new child from previous parents where needed. This behavior
* may change in future major releases of the library.
*
* @privateRemarks Requires non-graph state.
*/
addChild(node: Node): this;

@@ -29,0 +43,0 @@ /** Removes a {@link Node} from the Scene. */

{
"name": "@gltf-transform/core",
"version": "3.4.6",
"version": "3.4.7",
"repository": "github:donmccurdy/glTF-Transform",

@@ -54,3 +54,3 @@ "homepage": "https://gltf-transform.dev/",

},
"gitHead": "ef36bee93cd111dd45b6ce13f65d4f662c487a9e"
"gitHead": "4ebb250df4702b5d042782c3ba68819864e1fe6b"
}

@@ -10,2 +10,3 @@ import { multiply } from 'gl-matrix/mat4';

import type { Skin } from './skin.js';
import type { Scene } from './scene.js';

@@ -26,8 +27,8 @@ interface INode extends IExtensibleProperty {

*
* Each node may have one or more children, and a transform (position, rotation, and scale) that
* applies to all of its descendants. A node may also reference (or "instantiate") other resources
* at its location, including {@link Mesh}, Camera, Light, and Skin properties. A node cannot be
* Each Node may have one or more children, and a transform (position, rotation, and scale) that
* applies to all of its descendants. A Node may also reference (or "instantiate") other resources
* at its location, including {@link Mesh}, Camera, Light, and Skin properties. A Node cannot be
* part of more than one {@link Scene}.
*
* A node's local transform is represented with array-like objects, intended to be compatible with
* A Node's local transform is represented with array-like objects, intended to be compatible with
* [gl-matrix](https://github.com/toji/gl-matrix), or with the `toArray`/`fromArray` methods of

@@ -53,4 +54,14 @@ * libraries like three.js and babylon.js.

/** @internal Internal reference to node's parent, omitted from {@link Graph}. */
/**
* Internal reference to ≤1 parent Nodes, omitted from {@link Graph}.
* @internal
* @privateRemarks Requires non-graph state.
*/
public _parentNode: Node | null = null;
/**
* Internal reference to N parent scenes, omitted from {@link Graph}.
* @internal
* @privateRemarks Requires non-graph state.
*/
public _parentScenes = new Set<Scene>();

@@ -75,4 +86,4 @@ protected init(): void {

public copy(other: this, resolve = COPY_IDENTITY): this {
// Node cannot be copied, only cloned. Copying is shallow, but nodes cannot have more than
// one parent. Rather than leaving one of the two nodes without children, throw an error here.
// Node cannot be copied, only cloned. Copying is shallow, but Nodes cannot have more than
// one parent. Rather than leaving one of the two Nodes without children, throw an error here.
if (resolve === COPY_IDENTITY) throw new Error('Node cannot be copied.');

@@ -86,3 +97,3 @@ return super.copy(other, resolve);

/** Returns the translation (position) of this node in local space. */
/** Returns the translation (position) of this Node in local space. */
public getTranslation(): vec3 {

@@ -92,3 +103,3 @@ return this.get('translation');

/** Returns the rotation (quaternion) of this node in local space. */
/** Returns the rotation (quaternion) of this Node in local space. */
public getRotation(): vec4 {

@@ -98,3 +109,3 @@ return this.get('rotation');

/** Returns the scale of this node in local space. */
/** Returns the scale of this Node in local space. */
public getScale(): vec3 {

@@ -104,3 +115,3 @@ return this.get('scale');

/** Sets the translation (position) of this node in local space. */
/** Sets the translation (position) of this Node in local space. */
public setTranslation(translation: vec3): this {

@@ -110,3 +121,3 @@ return this.set('translation', translation);

/** Sets the rotation (quaternion) of this node in local space. */
/** Sets the rotation (quaternion) of this Node in local space. */
public setRotation(rotation: vec4): this {

@@ -116,3 +127,3 @@ return this.set('rotation', rotation);

/** Sets the scale of this node in local space. */
/** Sets the scale of this Node in local space. */
public setScale(scale: vec3): this {

@@ -122,3 +133,3 @@ return this.set('scale', scale);

/** Returns the local matrix of this node. */
/** Returns the local matrix of this Node. */
public getMatrix(): mat4 {

@@ -133,3 +144,3 @@ return MathUtils.compose(

/** Sets the local matrix of this node. Matrix will be decomposed to TRS properties. */
/** Sets the local matrix of this Node. Matrix will be decomposed to TRS properties. */
public setMatrix(matrix: mat4): this {

@@ -147,3 +158,3 @@ const translation = this.get('translation').slice() as vec3;

/** Returns the translation (position) of this node in world space. */
/** Returns the translation (position) of this Node in world space. */
public getWorldTranslation(): vec3 {

@@ -155,3 +166,3 @@ const t = [0, 0, 0] as vec3;

/** Returns the rotation (quaternion) of this node in world space. */
/** Returns the rotation (quaternion) of this Node in world space. */
public getWorldRotation(): vec4 {

@@ -163,3 +174,3 @@ const r = [0, 0, 0, 1] as vec4;

/** Returns the scale of this node in world space. */
/** Returns the scale of this Node in world space. */
public getWorldScale(): vec3 {

@@ -171,3 +182,3 @@ const s = [1, 1, 1] as vec3;

/** Returns the world matrix of this node. */
/** Returns the world matrix of this Node. */
public getWorldMatrix(): mat4 {

@@ -195,6 +206,27 @@ // Build ancestor chain.

/** Adds another node as a child of this one. Nodes cannot have multiple parents. */
/**
* Adds the given Node as a child of this Node.
*
* Requirements:
*
* 1. Nodes MAY be root children of multiple {@link Scene Scenes}
* 2. Nodes MUST NOT be children of >1 Node
* 3. Nodes MUST NOT be children of both Nodes and {@link Scene Scenes}
*
* The `addChild` method enforces these restrictions automatically, and will
* remove the new child from previous parents where needed. This behavior
* may change in future major releases of the library.
*
* @privateRemarks Requires non-graph state.
*/
public addChild(child: Node): this {
// Remove existing parent.
// Remove existing parents.
if (child._parentNode) child._parentNode.removeChild(child);
if (child._parentScenes.size) {
const prevSize = child._parentScenes.size;
for (const scene of child._parentScenes) {
scene.removeChild(child);
}
console.log(`parentScenes: ${prevSize} -> ${child._parentScenes.size}`);
}

@@ -205,3 +237,3 @@ // Edge in graph.

// Set new parent.
// TODO(cleanup): Avoid using $attributes here?
// TODO(cleanup): Avoid reaching into $attributes.
child._parentNode = this;

@@ -214,3 +246,3 @@ const childrenRefs = this[$attributes]['children'];

/** Removes a node from this node's child node list. */
/** Removes a Node from this Node's child Node list. */
public removeChild(child: Node): this {

@@ -220,3 +252,3 @@ return this.removeRef('children', child);

/** Lists all child nodes of this node. */
/** Lists all child Nodes of this Node. */
public listChildren(): Node[] {

@@ -249,3 +281,3 @@ return this.listRefs('children');

/** Returns the {@link Mesh}, if any, instantiated at this node. */
/** Returns the {@link Mesh}, if any, instantiated at this Node. */
public getMesh(): Mesh | null {

@@ -256,4 +288,4 @@ return this.getRef('mesh');

/**
* Sets a {@link Mesh} to be instantiated at this node. A single mesh may be instatiated by
* multiple nodes; reuse of this sort is strongly encouraged.
* Sets a {@link Mesh} to be instantiated at this Node. A single mesh may be instatiated by
* multiple Nodes; reuse of this sort is strongly encouraged.
*/

@@ -264,3 +296,3 @@ public setMesh(mesh: Mesh | null): this {

/** Returns the {@link Camera}, if any, instantiated at this node. */
/** Returns the {@link Camera}, if any, instantiated at this Node. */
public getCamera(): Camera | null {

@@ -270,3 +302,3 @@ return this.getRef('camera');

/** Sets a {@link Camera} to be instantiated at this node. */
/** Sets a {@link Camera} to be instantiated at this Node. */
public setCamera(camera: Camera | null): this {

@@ -276,3 +308,3 @@ return this.setRef('camera', camera);

/** Returns the {@link Skin}, if any, instantiated at this node. */
/** Returns the {@link Skin}, if any, instantiated at this Node. */
public getSkin(): Skin | null {

@@ -282,3 +314,3 @@ return this.getRef('skin');

/** Sets a {@link Skin} to be instantiated at this node. */
/** Sets a {@link Skin} to be instantiated at this Node. */
public setSkin(skin: Skin | null): this {

@@ -289,3 +321,3 @@ return this.setRef('skin', skin);

/**
* Initial weights of each {@link PrimitiveTarget} for the mesh instance at this node.
* Initial weights of each {@link PrimitiveTarget} for the mesh instance at this Node.
* Most engines only support 4-8 active morph targets at a time.

@@ -298,3 +330,3 @@ */

/**
* Initial weights of each {@link PrimitiveTarget} for the mesh instance at this node.
* Initial weights of each {@link PrimitiveTarget} for the mesh instance at this Node.
* Most engines only support 4-8 active morph targets at a time.

@@ -301,0 +333,0 @@ */

@@ -0,1 +1,2 @@

import { $attributes } from 'property-graph';
import { Nullable, PropertyType } from '../constants.js';

@@ -42,5 +43,31 @@ import { ExtensibleProperty, IExtensibleProperty } from './extensible-property.js';

/** Adds a {@link Node} to the Scene. */
/**
* Adds a {@link Node} to the Scene.
*
* Requirements:
*
* 1. Nodes MAY be root children of multiple {@link Scene Scenes}
* 2. Nodes MUST NOT be children of >1 Node
* 3. Nodes MUST NOT be children of both Nodes and {@link Scene Scenes}
*
* The `addChild` method enforces these restrictions automatically, and will
* remove the new child from previous parents where needed. This behavior
* may change in future major releases of the library.
*
* @privateRemarks Requires non-graph state.
*/
public addChild(node: Node): this {
return this.addRef('children', node);
// Remove existing parent.
if (node._parentNode) node._parentNode.removeChild(node);
// Edge in graph.
this.addRef('children', node);
// Set new parent.
// TODO(cleanup): Avoid reaching into $attributes.
node._parentScenes.add(this);
const childrenRefs = this[$attributes]['children'];
const ref = childrenRefs[childrenRefs.length - 1];
ref.addEventListener('dispose', () => node._parentScenes.delete(this));
return this;
}

@@ -47,0 +74,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc