@khr3/core 0.2.15 → 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/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 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-DAVP2HJe.js";
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, emitters, scene, rawExtensions, isSocketNode) {
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 if (!emitterSocket) {
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, emitters, gltf.scene, rawExt, options?.isSocketNode));
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,