@gltf-transform/core
Advanced tools
Comparing version 4.0.0-alpha.5 to 4.0.0-alpha.6
@@ -92,4 +92,2 @@ import { PropertyType, mat4, vec3, vec4, Nullable } from '../constants.js'; | ||
* may change in future major releases of the library. | ||
* | ||
* @privateRemarks Requires non-graph state. | ||
*/ | ||
@@ -96,0 +94,0 @@ addChild(child: Node): this; |
@@ -38,4 +38,2 @@ import { Nullable, PropertyType } from '../constants.js'; | ||
* may change in future major releases of the library. | ||
* | ||
* @privateRemarks Requires non-graph state. | ||
*/ | ||
@@ -42,0 +40,0 @@ addChild(node: Node): this; |
{ | ||
"name": "@gltf-transform/core", | ||
"version": "4.0.0-alpha.5", | ||
"version": "4.0.0-alpha.6", | ||
"repository": "github:donmccurdy/glTF-Transform", | ||
@@ -54,3 +54,3 @@ "homepage": "https://gltf-transform.dev/", | ||
}, | ||
"gitHead": "20a2e5c119208c7df9f041e1e8e075d921b8f95b" | ||
"gitHead": "b61933b39454b514f3f06a3d99cbaf10de675792" | ||
} |
@@ -80,3 +80,3 @@ import { BufferViewUsage, Format, PropertyType } from '../constants.js'; | ||
public readonly jsonDoc: JSONDocument, | ||
public readonly options: Required<WriterOptions> | ||
public readonly options: Required<WriterOptions>, | ||
) { | ||
@@ -89,3 +89,3 @@ const root = _doc.getRoot(); | ||
numImages > 1, | ||
(texture) => getSlot(_doc, texture) || options.basename || 'texture' | ||
(texture) => getSlot(_doc, texture) || options.basename || 'texture', | ||
); | ||
@@ -163,3 +163,3 @@ this.logger = _doc.getLogger(); | ||
(edge.getName() === 'attributes' && edge.getAttributes().key === 'POSITION') || | ||
edge.getName() === 'input' | ||
edge.getName() === 'input', | ||
); | ||
@@ -249,3 +249,6 @@ if (needsBounds) { | ||
constructor(private readonly multiple: boolean, private readonly basename: (t: T) => string) {} | ||
constructor( | ||
private readonly multiple: boolean, | ||
private readonly basename: (t: T) => string, | ||
) {} | ||
@@ -252,0 +255,0 @@ public createURI(object: T, extension: string): string { |
@@ -92,3 +92,3 @@ import { | ||
bufferByteOffset: number, | ||
bufferViewTarget?: number | ||
bufferViewTarget?: number, | ||
): BufferViewResult { | ||
@@ -141,3 +141,3 @@ const buffers: Uint8Array[] = []; | ||
bufferIndex: number, | ||
bufferByteOffset: number | ||
bufferByteOffset: number, | ||
): BufferViewResult { | ||
@@ -228,3 +228,3 @@ const vertexCount = accessors[0].getCount(); | ||
bufferIndex: number, | ||
bufferByteOffset: number | ||
bufferByteOffset: number, | ||
): BufferViewResult { | ||
@@ -623,3 +623,3 @@ const buffers: Uint8Array[] = []; | ||
texture, | ||
textureInfo | ||
textureInfo, | ||
) as GLTF.IMaterialNormalTextureInfo; | ||
@@ -637,3 +637,3 @@ if (material.getNormalScale() !== 1) { | ||
texture, | ||
textureInfo | ||
textureInfo, | ||
) as GLTF.IMaterialOcclusionTextureInfo; | ||
@@ -651,3 +651,3 @@ if (material.getOcclusionStrength() !== 1) { | ||
texture, | ||
textureInfo | ||
textureInfo, | ||
); | ||
@@ -688,3 +688,3 @@ } | ||
primitiveDef.attributes[semantic] = context.accessorIndexMap.get( | ||
primitive.getAttribute(semantic)! | ||
primitive.getAttribute(semantic)!, | ||
)!; | ||
@@ -691,0 +691,0 @@ } |
import { multiply } from 'gl-matrix/mat4'; | ||
import { PropertyType, mat4, vec3, vec4, Nullable } from '../constants.js'; | ||
import { $attributes } from 'property-graph'; | ||
import { MathUtils } from '../utils/index.js'; | ||
@@ -52,15 +51,2 @@ import type { Camera } from './camera.js'; | ||
/** | ||
* 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>(); | ||
protected init(): void { | ||
@@ -172,4 +158,3 @@ this.propertyType = PropertyType.NODE; | ||
const ancestors: Node[] = []; | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
for (let node: Node | null = this; node != null; node = node._parentNode) { | ||
for (let node: Node | null = this; node != null; node = node.getParentNode()) { | ||
ancestors.push(node); | ||
@@ -204,24 +189,14 @@ } | ||
* may change in future major releases of the library. | ||
* | ||
* @privateRemarks Requires non-graph state. | ||
*/ | ||
public addChild(child: Node): this { | ||
// Remove existing parents. | ||
if (child._parentNode) child._parentNode.removeChild(child); | ||
if (child._parentScenes.size) { | ||
for (const scene of child._parentScenes) { | ||
scene.removeChild(child); | ||
const parentNode = child.getParentNode(); | ||
if (parentNode) parentNode.removeChild(child); | ||
for (const parent of child.listParents()) { | ||
if (parent.propertyType === PropertyType.SCENE) { | ||
(parent as Scene).removeChild(child); | ||
} | ||
} | ||
// Edge in graph. | ||
this.addRef('children', child); | ||
// Set new parent. | ||
// TODO(cleanup): Avoid reaching into $attributes. | ||
child._parentNode = this; | ||
const childrenRefs = this[$attributes]['children']; | ||
const ref = childrenRefs[childrenRefs.length - 1]; | ||
ref.addEventListener('dispose', () => (child._parentNode = null)); | ||
return this; | ||
return this.addRef('children', child); | ||
} | ||
@@ -248,3 +223,8 @@ | ||
public getParentNode(): Node | null { | ||
return this._parentNode; | ||
for (const parent of this.listParents()) { | ||
if (parent.propertyType === PropertyType.NODE) { | ||
return parent as Node; | ||
} | ||
} | ||
return null; | ||
} | ||
@@ -251,0 +231,0 @@ |
@@ -1,2 +0,1 @@ | ||
import { $attributes } from 'property-graph'; | ||
import { Nullable, PropertyType } from '../constants.js'; | ||
@@ -55,19 +54,9 @@ import { ExtensibleProperty, IExtensibleProperty } from './extensible-property.js'; | ||
* may change in future major releases of the library. | ||
* | ||
* @privateRemarks Requires non-graph state. | ||
*/ | ||
public addChild(node: Node): this { | ||
// Remove existing parent. | ||
if (node._parentNode) node._parentNode.removeChild(node); | ||
const parentNode = node.getParentNode(); | ||
if (parentNode) 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; | ||
return this.addRef('children', node); | ||
} | ||
@@ -74,0 +63,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
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
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
2216709
30776