@khr3/core 0.2.14 → 0.2.16
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/README.md +1 -1
- package/dist/{KhrAssembly-BOY_g5we.js → KhrAssembly-Dtn5VNKn.js} +41 -34
- package/dist/KhrAssembly-Dtn5VNKn.js.map +1 -0
- package/dist/KhrAssembly.d.ts +2 -1
- package/dist/KhrCollider.d.ts +1 -1
- package/dist/decoders.d.ts +2 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -38
- package/dist/index.js.map +1 -1
- package/dist/inertia.d.ts +20 -1
- package/dist/types.d.ts +0 -11
- package/dist/vehicle.js +35 -16
- package/dist/vehicle.js.map +1 -1
- package/dist/vehicleJoints.d.ts +1 -3
- package/docs/api-reference.md +2 -3
- package/package.json +1 -1
- package/dist/KhrAssembly-BOY_g5we.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useRef } from "react";
|
|
|
2
2
|
import { useFrame, useLoader } from "@react-three/fiber";
|
|
3
3
|
import { Physics, RigidBody, useRapier } from "@react-three/rapier";
|
|
4
4
|
import { TimeControl } from "@pinkaphant/ecctrl/time";
|
|
5
|
-
import { A as computeAssemblyMassAndCom, B as
|
|
5
|
+
import { A as computeAssemblyMassAndCom, B as resolveBodyMassFromColliders, D as assertSceneIdentityWorldScale, E as assertIdentityWorldScale, F as isLiveRapierBody, G as isFiniteNum, H as JointRegistryContext, I as isLiveRapierCollider, J as isPosNum, K as isNonNegNum, L as jacobiPrincipalInertia, M as computeRelativePose, N as computeShapeInertia, O as assertUnitScale, P as extractMeshColliderShape, R as readFiniteVec3, S as releaseBundleMount, T as applyRapierBodyMass, U as KhrValidationError, V as COMBINE_MODES, W as assignRef, Y as optFiniteNum, a as DETACHED_PANEL_INTERACTION_GROUPS, b as disposeKhrBundle, c as configureJointDrive, d as measureJointCoordinate, f as openTargetForLimits, h as KhrCollider, i as ATTACHED_PANEL_INTERACTION_GROUPS, j as computeLumpedMassProps, l as createRapierImpulseJoint, m as KHR_TRIMESH_FLAGS, n as KhrAssembly, o as buildJointRuntime, p as toggleDrivenJoint, q as isObj, r as planAssembly, s as closedTargetForLimits, u as isJointOpen, v as claimBundleMount, w as snapshotSceneWithMountedSubtrees, y as cloneKhrBundle, z as readUnitQuat } from "./KhrAssembly-Dtn5VNKn.js";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import * as THREE from "three";
|
|
8
8
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
@@ -591,7 +591,7 @@ function extractDefaultBodyRole(extras) {
|
|
|
591
591
|
}
|
|
592
592
|
return null;
|
|
593
593
|
}
|
|
594
|
-
function collectNodeSockets(obj, name, extras, sockets,
|
|
594
|
+
function collectNodeSockets(obj, name, extras, sockets, isSocketNode) {
|
|
595
595
|
if (extras.socketId !== void 0 && (typeof extras.socketId !== "string" || extras.socketId.length === 0)) throw new KhrValidationError(`Node "${name}" has invalid extras.socketId`);
|
|
596
596
|
obj.getWorldPosition(_wpA);
|
|
597
597
|
const worldPosition = [
|
|
@@ -599,40 +599,12 @@ function collectNodeSockets(obj, name, extras, sockets, emitters, scene, rawExte
|
|
|
599
599
|
_wpA.y,
|
|
600
600
|
_wpA.z
|
|
601
601
|
];
|
|
602
|
-
let emitterSocket;
|
|
603
|
-
const rawEmitter = rawExtensions?.KOLMO_emitter;
|
|
604
|
-
if (rawEmitter !== void 0) {
|
|
605
|
-
if (!isObj(rawEmitter)) throw new KhrValidationError(`Node "${name}" has invalid extensions.KOLMO_emitter`);
|
|
606
|
-
if (rawEmitter.socket !== void 0) {
|
|
607
|
-
if (typeof rawEmitter.socket !== "string" || rawEmitter.socket.length === 0) throw new KhrValidationError(`Node "${name}" has invalid KOLMO_emitter.socket`);
|
|
608
|
-
emitterSocket = rawEmitter.socket;
|
|
609
|
-
sockets[emitterSocket] = [...worldPosition];
|
|
610
|
-
sockets[name] = [...worldPosition];
|
|
611
|
-
}
|
|
612
|
-
if (rawEmitter.kind !== void 0) {
|
|
613
|
-
if (typeof rawEmitter.kind !== "string" || rawEmitter.kind.length === 0) throw new KhrValidationError(`Node "${name}" has invalid KOLMO_emitter.kind`);
|
|
614
|
-
if (rawEmitter.drive !== void 0 && (typeof rawEmitter.drive !== "string" || rawEmitter.drive.length === 0)) throw new KhrValidationError(`Node "${name}" has invalid KOLMO_emitter.drive`);
|
|
615
|
-
let color;
|
|
616
|
-
if (rawEmitter.color !== void 0) color = readFiniteVec3(rawEmitter.color, `${name}.KOLMO_emitter.color`);
|
|
617
|
-
const size = optFiniteNum(rawEmitter.size, `${name}.KOLMO_emitter.size`, true);
|
|
618
|
-
emitters.push({
|
|
619
|
-
nodeName: name,
|
|
620
|
-
kind: rawEmitter.kind,
|
|
621
|
-
...typeof rawEmitter.drive === "string" ? { drive: rawEmitter.drive } : {},
|
|
622
|
-
...color ? { color } : {},
|
|
623
|
-
...size === void 0 ? {} : { size },
|
|
624
|
-
position: [...worldPosition],
|
|
625
|
-
quaternion: getRelativeQuatArray(obj, scene),
|
|
626
|
-
object: obj
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
602
|
let inferredSocket;
|
|
631
603
|
const custom = isSocketNode?.(name, extras);
|
|
632
604
|
if (custom || extras.isIkAnchor === true || typeof extras.socketId === "string") {
|
|
633
605
|
const key = typeof custom === "string" && custom.length > 0 ? custom : typeof extras.socketId === "string" ? extras.socketId : name;
|
|
634
606
|
sockets[key] = [...worldPosition];
|
|
635
|
-
} else
|
|
607
|
+
} else {
|
|
636
608
|
const prefixMatch = SOCKET_PREFIX_RE.exec(name);
|
|
637
609
|
if (prefixMatch) {
|
|
638
610
|
inferredSocket = prefixMatch[1].toLowerCase();
|
|
@@ -666,7 +638,6 @@ function collectNodeSockets(obj, name, extras, sockets, emitters, scene, rawExte
|
|
|
666
638
|
nodeName: name,
|
|
667
639
|
extras,
|
|
668
640
|
worldPosition,
|
|
669
|
-
...emitterSocket ? { emitterSocket } : {},
|
|
670
641
|
...inferredSocket ? { inferredSocket } : {},
|
|
671
642
|
...contactDots ? { contactDots } : {}
|
|
672
643
|
};
|
|
@@ -1014,14 +985,13 @@ function extractKhrBundleFromGltf(gltf, options) {
|
|
|
1014
985
|
const { parentIdx, nodeNames, resolveObj } = buildNodeGraphLookup(gltf, rawNodes, json);
|
|
1015
986
|
const nodeMetas = [];
|
|
1016
987
|
const sockets = Object.create(null);
|
|
1017
|
-
const emitters = [];
|
|
1018
988
|
for (let i = 0; i < rawNodes.length; i++) {
|
|
1019
989
|
const obj = resolveObj(i);
|
|
1020
990
|
if (!obj) continue;
|
|
1021
991
|
const rawExt = rawNodes[i].extensions;
|
|
1022
992
|
if (rawExt !== void 0 && !isObj(rawExt)) throw new KhrValidationError(`Node "${nodeNames[i]}" has invalid extensions`);
|
|
1023
993
|
const extras = isObj(rawNodes[i].extras) ? rawNodes[i].extras : {};
|
|
1024
|
-
nodeMetas.push(collectNodeSockets(obj, nodeNames[i], extras, sockets,
|
|
994
|
+
nodeMetas.push(collectNodeSockets(obj, nodeNames[i], extras, sockets, options?.isSocketNode));
|
|
1025
995
|
}
|
|
1026
996
|
const bodies = [];
|
|
1027
997
|
const bodyMetas = [];
|
|
@@ -1173,7 +1143,6 @@ function extractKhrBundleFromGltf(gltf, options) {
|
|
|
1173
1143
|
bodies,
|
|
1174
1144
|
wheels,
|
|
1175
1145
|
propellers,
|
|
1176
|
-
emitters,
|
|
1177
1146
|
sockets,
|
|
1178
1147
|
totalDynamicMass,
|
|
1179
1148
|
centerOfMass,
|
|
@@ -1785,7 +1754,7 @@ function KhrHeightfield({ ref, colliderRef, heights, segments, size, layout = "r
|
|
|
1785
1754
|
};
|
|
1786
1755
|
useEffect(() => {
|
|
1787
1756
|
const rb = rbRef.current;
|
|
1788
|
-
if (!rb ||
|
|
1757
|
+
if (!rb || world.getRigidBody(rb.handle) !== rb) return;
|
|
1789
1758
|
const colHeights = layout === "row-major" ? transposeHeightfieldForRapier(heights, nrows, ncols) : heights;
|
|
1790
1759
|
const expected = (nrows + 1) * (ncols + 1);
|
|
1791
1760
|
if (colHeights.length !== expected) throw new KhrValidationError(`KhrHeightfield: expected ${expected} samples for ${nrows}x${ncols} cells, got ${colHeights.length}`);
|
|
@@ -1802,7 +1771,7 @@ function KhrHeightfield({ ref, colliderRef, heights, segments, size, layout = "r
|
|
|
1802
1771
|
assignRef(colliderRef, col);
|
|
1803
1772
|
return () => {
|
|
1804
1773
|
assignRef(colliderRef, null);
|
|
1805
|
-
if (world.getCollider(col.handle)) world.removeCollider(col, false);
|
|
1774
|
+
if (world.getCollider(col.handle) === col) world.removeCollider(col, false);
|
|
1806
1775
|
};
|
|
1807
1776
|
}, [
|
|
1808
1777
|
rapier,
|
|
@@ -1940,6 +1909,6 @@ function useKhrGlb(url, options) {
|
|
|
1940
1909
|
}
|
|
1941
1910
|
};
|
|
1942
1911
|
})(useKhrGlb || (useKhrGlb = {}));
|
|
1943
|
-
export { ATTACHED_PANEL_INTERACTION_GROUPS, DETACHED_PANEL_INTERACTION_GROUPS, JointRegistryContext, KHR_HEIGHTFIELD_FLAGS, KHR_TRIMESH_FLAGS, KhrAssembly, KhrCollider, KhrGLTFLoader, KhrHeightfield, KhrValidationError, PhysicsWorld, applyRapierBodyMass, assertIdentityWorldScale, assertSceneIdentityWorldScale, assertUnitScale, assignRef, buildJointRuntime, claimBundleMount, cloneKhrBundle, closedTargetForLimits, computeLumpedMassProps, computeShapeInertia, configureJointDrive, createHeightfieldGeometry, createKhrGltfPlugin, createRapierImpulseJoint, createScopedGltfLoaderClass, disposeKhrBundle, ensureHeadlessFileReader, exportKhrGlb, isJointOpen, jacobiPrincipalInertia, loadKhrGlb, measureJointCoordinate, openTargetForLimits, patchGlbJsonChunk, planAssembly, releaseBundleMount, resolveBodyMassFromColliders, sampleRapierHeightfield, snapshotSceneWithMountedSubtrees, toggleDrivenJoint, transposeHeightfieldForRapier, useKhrGlb };
|
|
1912
|
+
export { ATTACHED_PANEL_INTERACTION_GROUPS, DETACHED_PANEL_INTERACTION_GROUPS, JointRegistryContext, KHR_HEIGHTFIELD_FLAGS, KHR_TRIMESH_FLAGS, KhrAssembly, KhrCollider, KhrGLTFLoader, KhrHeightfield, KhrValidationError, PhysicsWorld, applyRapierBodyMass, assertIdentityWorldScale, assertSceneIdentityWorldScale, assertUnitScale, assignRef, buildJointRuntime, claimBundleMount, cloneKhrBundle, closedTargetForLimits, computeLumpedMassProps, computeShapeInertia, configureJointDrive, createHeightfieldGeometry, createKhrGltfPlugin, createRapierImpulseJoint, createScopedGltfLoaderClass, disposeKhrBundle, ensureHeadlessFileReader, exportKhrGlb, isJointOpen, isLiveRapierBody, isLiveRapierCollider, jacobiPrincipalInertia, loadKhrGlb, measureJointCoordinate, openTargetForLimits, patchGlbJsonChunk, planAssembly, releaseBundleMount, resolveBodyMassFromColliders, sampleRapierHeightfield, snapshotSceneWithMountedSubtrees, toggleDrivenJoint, transposeHeightfieldForRapier, useKhrGlb };
|
|
1944
1913
|
|
|
1945
1914
|
//# sourceMappingURL=index.js.map
|