@khr3/core 0.2.11 → 0.2.12
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/KhrAssembly.d.ts +4 -6
- package/dist/KhrCollider.d.ts +5 -1
- package/dist/clone.d.ts +5 -0
- package/dist/decoders.d.ts +30 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +755 -245
- package/dist/index.js.map +1 -1
- package/dist/inertia.d.ts +23 -14
- package/dist/joints-5IgWDD2w.js +865 -0
- package/dist/joints-5IgWDD2w.js.map +1 -0
- package/dist/joints.d.ts +2 -0
- package/dist/types.d.ts +2 -0
- package/dist/vehicle.d.ts +4 -17
- package/dist/vehicle.js +465 -422
- package/dist/vehicle.js.map +1 -1
- package/dist/vehicleJoints.d.ts +50 -0
- package/package.json +1 -1
- package/dist/KhrAssembly-CKW8I_2z.js +0 -1667
- package/dist/KhrAssembly-CKW8I_2z.js.map +0 -1
package/dist/KhrAssembly.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ import React from "react";
|
|
|
2
2
|
import * as THREE from "three";
|
|
3
3
|
import { type ThreeElements } from "@react-three/fiber";
|
|
4
4
|
import { type RapierRigidBody, type RigidBodyProps } from "@react-three/rapier";
|
|
5
|
-
import { type
|
|
6
|
-
import { type ColliderMass } from "./KhrCollider.js";
|
|
5
|
+
import { type RapierBodyMassTarget } from "./inertia.js";
|
|
7
6
|
import { type JointRuntime, type KhrAssetBundle, type KhrBodySpec, type KhrColliderSpec, type KhrJointSpec } from "./types.js";
|
|
8
7
|
type Vec3 = [number, number, number];
|
|
9
8
|
type Quat = [number, number, number, number];
|
|
@@ -11,7 +10,7 @@ export interface PlannedCollider {
|
|
|
11
10
|
spec: KhrColliderSpec;
|
|
12
11
|
position: Vec3;
|
|
13
12
|
quaternion: Quat;
|
|
14
|
-
|
|
13
|
+
density?: number;
|
|
15
14
|
}
|
|
16
15
|
export interface PartPlan {
|
|
17
16
|
spec: KhrBodySpec;
|
|
@@ -23,7 +22,7 @@ export interface PartPlan {
|
|
|
23
22
|
restRelRootQuat: Quat;
|
|
24
23
|
axisParent: Vec3;
|
|
25
24
|
axisChild: Vec3;
|
|
26
|
-
|
|
25
|
+
massTarget: RapierBodyMassTarget | null;
|
|
27
26
|
colliders: PlannedCollider[];
|
|
28
27
|
}
|
|
29
28
|
export interface RootPlan {
|
|
@@ -33,11 +32,10 @@ export interface RootPlan {
|
|
|
33
32
|
mountNode: THREE.Object3D;
|
|
34
33
|
mountPosition: Vec3;
|
|
35
34
|
mountQuaternion: Quat;
|
|
36
|
-
|
|
35
|
+
massTarget: RapierBodyMassTarget | null;
|
|
37
36
|
colliders: PlannedCollider[];
|
|
38
37
|
parts: PartPlan[];
|
|
39
38
|
}
|
|
40
|
-
export declare function toColliderMass(lumped: LumpedMassProps, colMat?: THREE.Matrix4, colQuat?: THREE.Quaternion): ColliderMass;
|
|
41
39
|
export declare function planAssembly(bundle: KhrAssetBundle): RootPlan[];
|
|
42
40
|
export type AssemblyRigidBodyProps = Omit<RigidBodyProps, "type" | "position" | "rotation" | "quaternion" | "colliders" | "children" | "ref">;
|
|
43
41
|
export interface KhrAssemblyHandle {
|
package/dist/KhrCollider.d.ts
CHANGED
|
@@ -20,13 +20,17 @@ export interface ColliderMass {
|
|
|
20
20
|
w: number;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
+
/** `RAPIER.TriMeshFlags.FIX_INTERNAL_EDGES` (144) — merges duplicate vertices and suppresses internal seam ghost normals. */
|
|
24
|
+
export declare const KHR_TRIMESH_FLAGS = 144;
|
|
23
25
|
export interface KhrColliderProps {
|
|
24
26
|
c: KhrColliderSpec;
|
|
25
27
|
position?: [number, number, number];
|
|
26
28
|
quaternion?: [number, number, number, number];
|
|
29
|
+
density?: number;
|
|
30
|
+
mass?: number;
|
|
27
31
|
massProperties?: ColliderMass;
|
|
28
32
|
collisionGroups?: number;
|
|
29
33
|
solverGroups?: number;
|
|
30
34
|
ref?: React.Ref<RapierCollider>;
|
|
31
35
|
}
|
|
32
|
-
export declare function KhrCollider({ c, position, quaternion, massProperties, collisionGroups, solverGroups, ref, }: KhrColliderProps): React.JSX.Element;
|
|
36
|
+
export declare function KhrCollider({ c, position, quaternion, density, mass, massProperties, collisionGroups, solverGroups, ref, }: KhrColliderProps): React.JSX.Element;
|
package/dist/clone.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ import { type KhrAssetBundle } from "./types.js";
|
|
|
4
4
|
export declare function registerMountedSubtree(ownerScene: THREE.Object3D, restoreForClone: () => () => void): () => void;
|
|
5
5
|
export declare function claimBundleMount(bundle: KhrAssetBundle, ownerComponent: string): void;
|
|
6
6
|
export declare function releaseBundleMount(bundle: KhrAssetBundle): void;
|
|
7
|
+
/**
|
|
8
|
+
* Returns a structural `Object3D` clone with any mounted `RotorVisualSlot` / `MountSubtreeSlot`
|
|
9
|
+
* subtrees restored synchronously when `root` is currently mounted, or `root` itself otherwise.
|
|
10
|
+
*/
|
|
11
|
+
export declare function snapshotSceneWithMountedSubtrees(root: THREE.Object3D): THREE.Object3D;
|
|
7
12
|
/**
|
|
8
13
|
* Clones a parsed `KhrAssetBundle` in O(nodes) while sharing GPU `BufferGeometry` / `Material` buffers
|
|
9
14
|
* and Rapier `Float32Array` collider vertices. Only restores subtrees belonging to `bundle.scene`.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { type EcctrlPropellerTag, type EcctrlWheelTag, type KhrBodySpec, type KhrBreakawaySpec, type KhrCombineMode, type KhrImplicitShape, type KhrJointSpec, type KhrPluginOptions } from "./types.js";
|
|
3
|
+
export interface KhrNodeMeta {
|
|
4
|
+
nodeName: string;
|
|
5
|
+
extras: Record<string, unknown>;
|
|
6
|
+
worldPosition: [number, number, number];
|
|
7
|
+
contactDots?: Array<[string, [number, number, number]]>;
|
|
8
|
+
}
|
|
9
|
+
export interface KhrTemplateMeta {
|
|
10
|
+
nodes: KhrNodeMeta[];
|
|
11
|
+
bodies: Array<{
|
|
12
|
+
nodeName: string;
|
|
13
|
+
extras: Record<string, unknown>;
|
|
14
|
+
}>;
|
|
15
|
+
ikSockets: Array<[string, [number, number, number]]>;
|
|
16
|
+
}
|
|
17
|
+
export declare function decodeShape(raw: Record<string, unknown>, idx: number): KhrImplicitShape;
|
|
18
|
+
export declare function decodePhysicsMaterial(rawMaterials: Array<Record<string, unknown>>, idx: unknown, ownerName: string): {
|
|
19
|
+
friction?: number;
|
|
20
|
+
restitution?: number;
|
|
21
|
+
frictionCombine?: KhrCombineMode;
|
|
22
|
+
restitutionCombine?: KhrCombineMode;
|
|
23
|
+
};
|
|
24
|
+
export declare function decodeCollisionGroups(rawFilters: Array<Record<string, unknown>>): number[];
|
|
25
|
+
export declare function decodeMotion(motion: Record<string, unknown>, hasMotion: boolean, name: string): Omit<KhrBodySpec, "nodeName" | "localPosition" | "localQuaternion" | "colliders" | "joint" | "object" | "role">;
|
|
26
|
+
export declare function decodeJoint(rawJoints: Array<Record<string, unknown>>, jointIdx: number, nodeName: string, connectedNode: THREE.Object3D, childNode: THREE.Object3D, enableCollision: boolean, role: string | null, connectedNodeName?: string): KhrJointSpec;
|
|
27
|
+
export declare function decodeWheelTag(obj: THREE.Object3D, name: string, rawWheel: unknown, scene?: THREE.Object3D, rawOmiWheel?: unknown): EcctrlWheelTag;
|
|
28
|
+
export declare function decodePropellerTag(obj: THREE.Object3D, name: string, rawPropeller: unknown, scene?: THREE.Object3D): EcctrlPropellerTag;
|
|
29
|
+
export declare function decodeBreakawaySpec(raw: unknown): KhrBreakawaySpec | undefined;
|
|
30
|
+
export declare function collectNodeSockets(obj: THREE.Object3D, name: string, extras: Record<string, unknown>, sockets: Record<string, [number, number, number]>, isSocketNode?: KhrPluginOptions["isSocketNode"]): KhrNodeMeta;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ export { JointRegistryContext, KhrValidationError, assignRef, type CurveData, ty
|
|
|
3
3
|
export { createKhrGltfPlugin, loadKhrGlb } from "./loader.js";
|
|
4
4
|
export { exportKhrGlb, patchGlbJsonChunk } from "./exporter.js";
|
|
5
5
|
export type { MutableGltfJson, RawGltfJson } from "./glb.js";
|
|
6
|
-
export { claimBundleMount, cloneKhrBundle, disposeKhrBundle, releaseBundleMount } from "./clone.js";
|
|
7
|
-
export { assertIdentityWorldScale, assertSceneIdentityWorldScale, assertUnitScale,
|
|
8
|
-
export { KhrCollider, type ColliderMass, type KhrColliderProps } from "./KhrCollider.js";
|
|
6
|
+
export { claimBundleMount, cloneKhrBundle, disposeKhrBundle, releaseBundleMount, snapshotSceneWithMountedSubtrees } from "./clone.js";
|
|
7
|
+
export { applyRapierBodyMass, assertIdentityWorldScale, assertSceneIdentityWorldScale, assertUnitScale, buildBodyMassTarget, type RapierBodyMassTarget, } from "./inertia.js";
|
|
8
|
+
export { KHR_TRIMESH_FLAGS, KhrCollider, type ColliderMass, type KhrColliderProps } from "./KhrCollider.js";
|
|
9
9
|
export { KhrAssembly, planAssembly, type KhrAssemblyHandle, type KhrAssemblyProps } from "./KhrAssembly.js";
|
|
10
10
|
export { KhrGLTFLoader, createScopedGltfLoaderClass, useKhrGlb } from "./useKhrGlb.js";
|
|
11
|
-
export { ATTACHED_PANEL_INTERACTION_GROUPS, DETACHED_PANEL_INTERACTION_GROUPS, buildJointRuntime, configureJointDrive, createRapierImpulseJoint, isJointOpen, measureJointCoordinate, openTargetForLimits, } from "./joints.js";
|
|
11
|
+
export { ATTACHED_PANEL_INTERACTION_GROUPS, DETACHED_PANEL_INTERACTION_GROUPS, buildJointRuntime, closedTargetForLimits, configureJointDrive, createRapierImpulseJoint, isJointOpen, measureJointCoordinate, openTargetForLimits, toggleDrivenJoint, } from "./joints.js";
|