@luma.gl/gltf 9.3.5 → 9.4.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +48 -56
- package/dist/dist.min.js +3 -3
- package/dist/gltf/gltf-animator.d.ts +8 -28
- package/dist/gltf/gltf-animator.d.ts.map +1 -1
- package/dist/gltf/gltf-animator.js +10 -34
- package/dist/gltf/gltf-animator.js.map +1 -1
- package/dist/index.cjs +40 -50
- package/dist/index.cjs.map +3 -3
- package/dist/parsers/parse-pbr-material.d.ts.map +1 -1
- package/dist/parsers/parse-pbr-material.js +28 -14
- package/dist/parsers/parse-pbr-material.js.map +1 -1
- package/package.json +5 -5
- package/src/gltf/gltf-animator.ts +19 -54
- package/src/parsers/parse-pbr-material.ts +44 -14
|
@@ -1,44 +1,35 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import {
|
|
4
|
+
import { AnimationClipController, Animator } from '@luma.gl/engine';
|
|
5
5
|
import { evaluateSampler, interpolate } from "./animations/interpolate.js";
|
|
6
6
|
import { getTextureTransformDeltaMatrix, getTextureTransformSlotDefinition } from "../pbr/texture-transform.js";
|
|
7
7
|
/** Evaluates one glTF animation against the generated scenegraph. */
|
|
8
|
-
class
|
|
8
|
+
export class GLTFAnimationClip extends AnimationClipController {
|
|
9
9
|
/** Animation definition being played. */
|
|
10
10
|
animation;
|
|
11
11
|
/** Target scenegraph lookup table. */
|
|
12
12
|
gltfNodeIdToNodeMap;
|
|
13
13
|
/** Materials aligned with the source glTF materials array. */
|
|
14
14
|
materials;
|
|
15
|
-
/** Playback start time in seconds. */
|
|
16
|
-
startTime = 0;
|
|
17
|
-
/** Whether playback is currently enabled. */
|
|
18
|
-
playing = true;
|
|
19
|
-
/** Playback speed multiplier. */
|
|
20
|
-
speed = 1;
|
|
21
15
|
/** Mutable runtime texture-transform state for animated material slots. */
|
|
22
16
|
materialTextureTransformState = new Map();
|
|
23
17
|
/** Creates a single-animation controller. */
|
|
24
18
|
constructor(props) {
|
|
19
|
+
super({ name: props.animation.name || 'unnamed' });
|
|
25
20
|
this.animation = props.animation;
|
|
26
21
|
this.gltfNodeIdToNodeMap = props.gltfNodeIdToNodeMap;
|
|
27
22
|
this.materials = props.materials || [];
|
|
28
23
|
this.animation.name ||= 'unnamed';
|
|
24
|
+
this.name = this.animation.name;
|
|
29
25
|
Object.assign(this, props);
|
|
30
26
|
if (this.animation.channels.some(channel => channel.type !== 'node') &&
|
|
31
27
|
!this.materials.length) {
|
|
32
28
|
throw new Error(`Animation ${this.animation.name} targets materials, but GLTFAnimator was created without a materials array`);
|
|
33
29
|
}
|
|
34
30
|
}
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
if (!this.playing) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const absTime = timeMs / 1000;
|
|
41
|
-
const time = (absTime - this.startTime) * this.speed;
|
|
31
|
+
/** Applies the resolved local clip time in seconds. */
|
|
32
|
+
applyTime(time) {
|
|
42
33
|
this.animation.channels.forEach(channel => {
|
|
43
34
|
if (channel.type === 'node') {
|
|
44
35
|
const { sampler, targetNodeId, path } = channel;
|
|
@@ -66,32 +57,17 @@ class GLTFSingleAnimator {
|
|
|
66
57
|
}
|
|
67
58
|
}
|
|
68
59
|
/** Coordinates playback of every animation found in a glTF scene. */
|
|
69
|
-
export class GLTFAnimator {
|
|
70
|
-
/** Individual animation controllers. */
|
|
71
|
-
animations;
|
|
60
|
+
export class GLTFAnimator extends Animator {
|
|
72
61
|
/** Creates an animator for the supplied glTF scenegraph. */
|
|
73
62
|
constructor(props) {
|
|
74
|
-
|
|
63
|
+
super(props.animations.map((animation, index) => {
|
|
75
64
|
const name = animation.name || `Animation-${index}`;
|
|
76
|
-
return new
|
|
65
|
+
return new GLTFAnimationClip({
|
|
77
66
|
gltfNodeIdToNodeMap: props.gltfNodeIdToNodeMap,
|
|
78
67
|
materials: props.materials,
|
|
79
68
|
animation: { name, channels: animation.channels }
|
|
80
69
|
});
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
/** @deprecated Use .setTime(). Will be removed (deck.gl is using this) */
|
|
84
|
-
animate(time) {
|
|
85
|
-
log.warn('GLTFAnimator#animate is deprecated. Use GLTFAnimator#setTime instead')();
|
|
86
|
-
this.setTime(time);
|
|
87
|
-
}
|
|
88
|
-
/** Advances every animation to the supplied wall-clock time in milliseconds. */
|
|
89
|
-
setTime(time) {
|
|
90
|
-
this.animations.forEach(animation => animation.setTime(time));
|
|
91
|
-
}
|
|
92
|
-
/** Returns the per-animation controllers managed by this animator. */
|
|
93
|
-
getAnimations() {
|
|
94
|
-
return this.animations;
|
|
70
|
+
}));
|
|
95
71
|
}
|
|
96
72
|
}
|
|
97
73
|
function applyMaterialAnimationValue(material, channel, value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf-animator.js","sourceRoot":"","sources":["../../src/gltf/gltf-animator.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"gltf-animator.js","sourceRoot":"","sources":["../../src/gltf/gltf-animator.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,uBAAuB,EAAE,QAAQ,EAAsB,MAAM,iBAAiB,CAAC;AAOvF,OAAO,EAAC,eAAe,EAAE,WAAW,EAAC,oCAAiC;AACtE,OAAO,EACL,8BAA8B,EAC9B,iCAAiC,EAGlC,oCAAiC;AAYlC,qEAAqE;AACrE,MAAM,OAAO,iBAAkB,SAAQ,uBAAuB;IAC5D,yCAAyC;IACzC,SAAS,CAAgB;IACzB,sCAAsC;IACtC,mBAAmB,CAAyB;IAC5C,8DAA8D;IAC9D,SAAS,CAAa;IACtB,2EAA2E;IAC3E,6BAA6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AAO,CAAC,WAAW,CAAC,CAAC;IAC/D,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC3B,qBAAqB,GAAG;YACtB,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAqB;YAC7D,QAAQ,EAAE,OAAO,CAAC,aAAa,CAAC,QAAQ;YACxC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAAqB;SAC5D,CAAC;QACF,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,qBAAqB,CAAC;QAC3D,6BAA6B,CAAC,GAAG,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,qBAAqB,CAAC;AAC/B,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -266,6 +266,15 @@ function getTextureTransformDeltaMatrix(baseTransform, currentTransform) {
|
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
// dist/parsers/parse-pbr-material.js
|
|
269
|
+
var GLTF_ATTRIBUTE_ALIASES = {
|
|
270
|
+
NORMAL: ["NORMAL", "normals"],
|
|
271
|
+
TANGENT: ["TANGENT"],
|
|
272
|
+
TEXCOORD_0: ["TEXCOORD_0", "texCoords"],
|
|
273
|
+
TEXCOORD_1: ["TEXCOORD_1", "texCoords1"],
|
|
274
|
+
JOINTS_0: ["JOINTS_0"],
|
|
275
|
+
WEIGHTS_0: ["WEIGHTS_0"],
|
|
276
|
+
COLOR_0: ["COLOR_0", "colors"]
|
|
277
|
+
};
|
|
269
278
|
function parsePBRMaterial(device, material, attributes, options) {
|
|
270
279
|
const parsedMaterial = {
|
|
271
280
|
defines: {
|
|
@@ -299,17 +308,19 @@ function parsePBRMaterial(device, material, attributes, options) {
|
|
|
299
308
|
parsedMaterial.uniforms.scaleDiffBaseMR = [0, 0, 0, 0];
|
|
300
309
|
parsedMaterial.uniforms.scaleFGDSpec = [0, 0, 0, 0];
|
|
301
310
|
}
|
|
302
|
-
if (attributes
|
|
311
|
+
if (hasGLTFAttribute(attributes, "NORMAL"))
|
|
303
312
|
parsedMaterial.defines["HAS_NORMALS"] = true;
|
|
304
|
-
if (attributes
|
|
313
|
+
if (hasGLTFAttribute(attributes, "TANGENT") && (options == null ? void 0 : options.useTangents)) {
|
|
305
314
|
parsedMaterial.defines["HAS_TANGENTS"] = true;
|
|
306
|
-
|
|
315
|
+
}
|
|
316
|
+
if (hasGLTFAttribute(attributes, "TEXCOORD_0"))
|
|
307
317
|
parsedMaterial.defines["HAS_UV"] = true;
|
|
308
|
-
if (attributes
|
|
318
|
+
if (hasGLTFAttribute(attributes, "TEXCOORD_1"))
|
|
309
319
|
parsedMaterial.defines["HAS_UV_1"] = true;
|
|
310
|
-
if (attributes
|
|
320
|
+
if (hasGLTFAttribute(attributes, "JOINTS_0") && hasGLTFAttribute(attributes, "WEIGHTS_0")) {
|
|
311
321
|
parsedMaterial.defines["HAS_SKIN"] = true;
|
|
312
|
-
|
|
322
|
+
}
|
|
323
|
+
if (hasGLTFAttribute(attributes, "COLOR_0"))
|
|
313
324
|
parsedMaterial.defines["HAS_COLORS"] = true;
|
|
314
325
|
if (options == null ? void 0 : options.imageBasedLightingEnvironment)
|
|
315
326
|
parsedMaterial.defines["USE_IBL"] = true;
|
|
@@ -326,15 +337,15 @@ function parsePBRMaterial(device, material, attributes, options) {
|
|
|
326
337
|
function warnOnMissingExpectedAttributes(material, attributes) {
|
|
327
338
|
var _a;
|
|
328
339
|
const uvDependentTextureSlots = getUvDependentTextureSlots(material, 0);
|
|
329
|
-
if (uvDependentTextureSlots.length > 0 && !attributes
|
|
340
|
+
if (uvDependentTextureSlots.length > 0 && !hasGLTFAttribute(attributes, "TEXCOORD_0")) {
|
|
330
341
|
import_core2.log.warn(`glTF material uses ${uvDependentTextureSlots.join(", ")} but primitive is missing TEXCOORD_0; textured shading will sample the default UV coordinates`)();
|
|
331
342
|
}
|
|
332
343
|
const uv1DependentTextureSlots = getUvDependentTextureSlots(material, 1);
|
|
333
|
-
if (uv1DependentTextureSlots.length > 0 && !attributes
|
|
344
|
+
if (uv1DependentTextureSlots.length > 0 && !hasGLTFAttribute(attributes, "TEXCOORD_1")) {
|
|
334
345
|
import_core2.log.warn(`glTF material uses ${uv1DependentTextureSlots.join(", ")} with TEXCOORD_1 but primitive is missing TEXCOORD_1; those textures will be skipped`)();
|
|
335
346
|
}
|
|
336
347
|
const isUnlitMaterial = Boolean(material.unlit || ((_a = material.extensions) == null ? void 0 : _a.KHR_materials_unlit));
|
|
337
|
-
if (isUnlitMaterial || attributes
|
|
348
|
+
if (isUnlitMaterial || hasGLTFAttribute(attributes, "NORMAL")) {
|
|
338
349
|
return;
|
|
339
350
|
}
|
|
340
351
|
const missingNormalReason = material.normalTexture ? "lit PBR shading with normalTexture" : "lit PBR shading";
|
|
@@ -353,6 +364,9 @@ function getUvDependentTextureSlots(material, textureCoordinateSet) {
|
|
|
353
364
|
}
|
|
354
365
|
return uvDependentTextureSlots;
|
|
355
366
|
}
|
|
367
|
+
function hasGLTFAttribute(attributes, attributeName) {
|
|
368
|
+
return GLTF_ATTRIBUTE_ALIASES[attributeName].some((alias) => Boolean(attributes[alias]));
|
|
369
|
+
}
|
|
356
370
|
function getNestedTextureInfo(material, pathSegments) {
|
|
357
371
|
let value = material;
|
|
358
372
|
for (const pathSegment of pathSegments) {
|
|
@@ -742,7 +756,7 @@ function addTexture(device, gltfTexture, uniformName, parsedMaterial, texturePar
|
|
|
742
756
|
import_core2.log.warn(`Skipping ${String(uniformName)} because ${textureCoordinateSet} is not supported; only TEXCOORD_0 and TEXCOORD_1 are currently available`)();
|
|
743
757
|
return;
|
|
744
758
|
}
|
|
745
|
-
if (textureCoordinateSet === 1 && !attributes
|
|
759
|
+
if (textureCoordinateSet === 1 && !hasGLTFAttribute(attributes, "TEXCOORD_1")) {
|
|
746
760
|
import_core2.log.warn(`Skipping ${String(uniformName)} because it requires TEXCOORD_1 but the primitive does not provide TEXCOORD_1`)();
|
|
747
761
|
return;
|
|
748
762
|
}
|
|
@@ -1471,7 +1485,7 @@ function getGLTFMaterialId(gltfMaterial, materialIndex) {
|
|
|
1471
1485
|
}
|
|
1472
1486
|
|
|
1473
1487
|
// dist/gltf/gltf-animator.js
|
|
1474
|
-
var
|
|
1488
|
+
var import_engine5 = require("@luma.gl/engine");
|
|
1475
1489
|
|
|
1476
1490
|
// dist/gltf/animations/interpolate.js
|
|
1477
1491
|
var import_core5 = require("@luma.gl/core");
|
|
@@ -1554,39 +1568,30 @@ function cubicsplineInterpolate({ p0, outTangent0, inTangent1, p1, tDiff, ratio:
|
|
|
1554
1568
|
}
|
|
1555
1569
|
|
|
1556
1570
|
// dist/gltf/gltf-animator.js
|
|
1557
|
-
var
|
|
1571
|
+
var GLTFAnimationClip = class extends import_engine5.AnimationClipController {
|
|
1558
1572
|
/** Animation definition being played. */
|
|
1559
1573
|
animation;
|
|
1560
1574
|
/** Target scenegraph lookup table. */
|
|
1561
1575
|
gltfNodeIdToNodeMap;
|
|
1562
1576
|
/** Materials aligned with the source glTF materials array. */
|
|
1563
1577
|
materials;
|
|
1564
|
-
/** Playback start time in seconds. */
|
|
1565
|
-
startTime = 0;
|
|
1566
|
-
/** Whether playback is currently enabled. */
|
|
1567
|
-
playing = true;
|
|
1568
|
-
/** Playback speed multiplier. */
|
|
1569
|
-
speed = 1;
|
|
1570
1578
|
/** Mutable runtime texture-transform state for animated material slots. */
|
|
1571
1579
|
materialTextureTransformState = /* @__PURE__ */ new Map();
|
|
1572
1580
|
/** Creates a single-animation controller. */
|
|
1573
1581
|
constructor(props) {
|
|
1582
|
+
super({ name: props.animation.name || "unnamed" });
|
|
1574
1583
|
this.animation = props.animation;
|
|
1575
1584
|
this.gltfNodeIdToNodeMap = props.gltfNodeIdToNodeMap;
|
|
1576
1585
|
this.materials = props.materials || [];
|
|
1577
1586
|
this.animation.name ||= "unnamed";
|
|
1587
|
+
this.name = this.animation.name;
|
|
1578
1588
|
Object.assign(this, props);
|
|
1579
1589
|
if (this.animation.channels.some((channel) => channel.type !== "node") && !this.materials.length) {
|
|
1580
1590
|
throw new Error(`Animation ${this.animation.name} targets materials, but GLTFAnimator was created without a materials array`);
|
|
1581
1591
|
}
|
|
1582
1592
|
}
|
|
1583
|
-
/**
|
|
1584
|
-
|
|
1585
|
-
if (!this.playing) {
|
|
1586
|
-
return;
|
|
1587
|
-
}
|
|
1588
|
-
const absTime = timeMs / 1e3;
|
|
1589
|
-
const time = (absTime - this.startTime) * this.speed;
|
|
1593
|
+
/** Applies the resolved local clip time in seconds. */
|
|
1594
|
+
applyTime(time) {
|
|
1590
1595
|
this.animation.channels.forEach((channel) => {
|
|
1591
1596
|
if (channel.type === "node") {
|
|
1592
1597
|
const { sampler, targetNodeId, path } = channel;
|
|
@@ -1612,32 +1617,17 @@ var GLTFSingleAnimator = class {
|
|
|
1612
1617
|
});
|
|
1613
1618
|
}
|
|
1614
1619
|
};
|
|
1615
|
-
var GLTFAnimator = class {
|
|
1616
|
-
/** Individual animation controllers. */
|
|
1617
|
-
animations;
|
|
1620
|
+
var GLTFAnimator = class extends import_engine5.Animator {
|
|
1618
1621
|
/** Creates an animator for the supplied glTF scenegraph. */
|
|
1619
1622
|
constructor(props) {
|
|
1620
|
-
|
|
1623
|
+
super(props.animations.map((animation, index) => {
|
|
1621
1624
|
const name = animation.name || `Animation-${index}`;
|
|
1622
|
-
return new
|
|
1625
|
+
return new GLTFAnimationClip({
|
|
1623
1626
|
gltfNodeIdToNodeMap: props.gltfNodeIdToNodeMap,
|
|
1624
1627
|
materials: props.materials,
|
|
1625
1628
|
animation: { name, channels: animation.channels }
|
|
1626
1629
|
});
|
|
1627
|
-
});
|
|
1628
|
-
}
|
|
1629
|
-
/** @deprecated Use .setTime(). Will be removed (deck.gl is using this) */
|
|
1630
|
-
animate(time) {
|
|
1631
|
-
import_core7.log.warn("GLTFAnimator#animate is deprecated. Use GLTFAnimator#setTime instead")();
|
|
1632
|
-
this.setTime(time);
|
|
1633
|
-
}
|
|
1634
|
-
/** Advances every animation to the supplied wall-clock time in milliseconds. */
|
|
1635
|
-
setTime(time) {
|
|
1636
|
-
this.animations.forEach((animation) => animation.setTime(time));
|
|
1637
|
-
}
|
|
1638
|
-
/** Returns the per-animation controllers managed by this animator. */
|
|
1639
|
-
getAnimations() {
|
|
1640
|
-
return this.animations;
|
|
1630
|
+
}));
|
|
1641
1631
|
}
|
|
1642
1632
|
};
|
|
1643
1633
|
function applyMaterialAnimationValue(material, channel, value) {
|
|
@@ -1703,7 +1693,7 @@ function getCurrentTextureTransform(materialTextureTransformState, material, cha
|
|
|
1703
1693
|
}
|
|
1704
1694
|
|
|
1705
1695
|
// dist/parsers/parse-gltf-animations.js
|
|
1706
|
-
var
|
|
1696
|
+
var import_core7 = require("@luma.gl/core");
|
|
1707
1697
|
|
|
1708
1698
|
// dist/gltf/gltf-extension-support.js
|
|
1709
1699
|
var UNKNOWN_EXTENSION_SUPPORT = {
|
|
@@ -1961,7 +1951,7 @@ function parseAnimationPointerChannel(gltf, target, sampler) {
|
|
|
1961
1951
|
var _a, _b;
|
|
1962
1952
|
const pointer = (_b = (_a = target.extensions) == null ? void 0 : _a["KHR_animation_pointer"]) == null ? void 0 : _b.pointer;
|
|
1963
1953
|
if (typeof pointer !== "string" || !pointer.startsWith("/")) {
|
|
1964
|
-
|
|
1954
|
+
import_core7.log.warn("KHR_animation_pointer channel is missing a valid JSON pointer and will be skipped")();
|
|
1965
1955
|
return null;
|
|
1966
1956
|
}
|
|
1967
1957
|
const pointerSegments = splitJsonPointer(pointer);
|
|
@@ -1983,7 +1973,7 @@ function parseNodePointerAnimationChannel(gltf, pointerSegments, sampler, pointe
|
|
|
1983
1973
|
const nodeIndex = Number(pointerSegments[1]);
|
|
1984
1974
|
const targetNode = gltf.nodes[nodeIndex];
|
|
1985
1975
|
if (!Number.isInteger(nodeIndex) || !targetNode) {
|
|
1986
|
-
|
|
1976
|
+
import_core7.log.warn(`KHR_animation_pointer target ${pointer} references a missing node and will be skipped`)();
|
|
1987
1977
|
return null;
|
|
1988
1978
|
}
|
|
1989
1979
|
const path = getNodeAnimationPath(pointerSegments[2]);
|
|
@@ -1992,7 +1982,7 @@ function parseNodePointerAnimationChannel(gltf, pointerSegments, sampler, pointe
|
|
|
1992
1982
|
return null;
|
|
1993
1983
|
}
|
|
1994
1984
|
if (path === "weights") {
|
|
1995
|
-
|
|
1985
|
+
import_core7.log.warn(`KHR_animation_pointer target ${pointer} will be skipped because morph weights are not implemented in GLTFAnimator`)();
|
|
1996
1986
|
return null;
|
|
1997
1987
|
}
|
|
1998
1988
|
return {
|
|
@@ -2010,7 +2000,7 @@ function parseMaterialPointerAnimationChannel(gltf, pointerSegments, sampler, po
|
|
|
2010
2000
|
const materialIndex = Number(pointerSegments[1]);
|
|
2011
2001
|
const material = gltf.materials[materialIndex];
|
|
2012
2002
|
if (!Number.isInteger(materialIndex) || !material) {
|
|
2013
|
-
|
|
2003
|
+
import_core7.log.warn(`KHR_animation_pointer target ${pointer} references a missing material and will be skipped`)();
|
|
2014
2004
|
return null;
|
|
2015
2005
|
}
|
|
2016
2006
|
const materialTarget = resolveMaterialAnimationTarget(material, pointerSegments.slice(2));
|
|
@@ -2196,7 +2186,7 @@ function getPointerExtensionName(pointerSegments) {
|
|
|
2196
2186
|
return extensionIndex >= 0 && extensionName ? extensionName : null;
|
|
2197
2187
|
}
|
|
2198
2188
|
function warnUnsupportedAnimationPointer(pointer, reason) {
|
|
2199
|
-
|
|
2189
|
+
import_core7.log.warn(`KHR_animation_pointer target ${pointer} will be skipped because ${reason}`)();
|
|
2200
2190
|
}
|
|
2201
2191
|
function accessorToJsArray1D(accessor, accessorCache) {
|
|
2202
2192
|
if (accessorCache.has(accessor)) {
|