react-three-game 0.0.51 → 0.0.53

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.
Files changed (30) hide show
  1. package/dist/helpers/index.js +1 -1
  2. package/dist/tools/prefabeditor/EditorTree.js +48 -7
  3. package/dist/tools/prefabeditor/EditorUI.js +2 -2
  4. package/dist/tools/prefabeditor/PrefabEditor.d.ts +1 -0
  5. package/dist/tools/prefabeditor/PrefabEditor.js +4 -3
  6. package/dist/tools/prefabeditor/PrefabRoot.d.ts +2 -3
  7. package/dist/tools/prefabeditor/PrefabRoot.js +9 -3
  8. package/dist/tools/prefabeditor/components/GeometryComponent.js +8 -8
  9. package/dist/tools/prefabeditor/components/Input.d.ts +2 -1
  10. package/dist/tools/prefabeditor/components/Input.js +63 -11
  11. package/dist/tools/prefabeditor/components/MaterialComponent.js +4 -2
  12. package/dist/tools/prefabeditor/components/ModelComponent.js +3 -1
  13. package/dist/tools/prefabeditor/components/PhysicsComponent.d.ts +3 -1
  14. package/dist/tools/prefabeditor/components/PhysicsComponent.js +33 -2
  15. package/dist/tools/prefabeditor/styles.d.ts +1 -4
  16. package/dist/tools/prefabeditor/styles.js +2 -0
  17. package/package.json +7 -7
  18. package/react-three-game-skill/react-three-game/SKILL.md +4 -2
  19. package/react-three-game-skill/react-three-game/rules/ADVANCED_PHYSICS.md +17 -1
  20. package/src/helpers/index.ts +1 -1
  21. package/src/tools/prefabeditor/EditorTree.tsx +92 -17
  22. package/src/tools/prefabeditor/EditorUI.tsx +2 -2
  23. package/src/tools/prefabeditor/PrefabEditor.tsx +24 -15
  24. package/src/tools/prefabeditor/PrefabRoot.tsx +14 -6
  25. package/src/tools/prefabeditor/components/GeometryComponent.tsx +13 -13
  26. package/src/tools/prefabeditor/components/Input.tsx +110 -20
  27. package/src/tools/prefabeditor/components/MaterialComponent.tsx +22 -6
  28. package/src/tools/prefabeditor/components/ModelComponent.tsx +9 -1
  29. package/src/tools/prefabeditor/components/PhysicsComponent.tsx +39 -3
  30. package/src/tools/prefabeditor/styles.ts +3 -1
@@ -1,4 +1,4 @@
1
- import { RigidBody, RapierRigidBody } from "@react-three/rapier";
1
+ import { RigidBody, RapierRigidBody, useRapier } from "@react-three/rapier";
2
2
  import type { RigidBodyOptions, CollisionPayload, IntersectionEnterPayload, IntersectionExitPayload } from "@react-three/rapier";
3
3
  import type { ReactNode } from 'react';
4
4
  import { useRef, useEffect, useCallback } from 'react';
@@ -7,7 +7,9 @@ import { FieldRenderer, FieldDefinition } from "./Input";
7
7
  import { ComponentData } from "../types";
8
8
  import { gameEvents, getEntityIdFromRigidBody } from "../GameEvents";
9
9
 
10
- export type PhysicsProps = RigidBodyOptions;
10
+ export type PhysicsProps = RigidBodyOptions & {
11
+ activeCollisionTypes?: 'all' | undefined;
12
+ };
11
13
 
12
14
  const physicsFields: FieldDefinition[] = [
13
15
  {
@@ -77,6 +79,15 @@ const physicsFields: FieldDefinition[] = [
77
79
  type: 'boolean',
78
80
  label: 'Sensor (Trigger Only)',
79
81
  },
82
+ {
83
+ name: 'activeCollisionTypes',
84
+ type: 'select',
85
+ label: 'Collision Detection',
86
+ options: [
87
+ { value: '', label: 'Default (Dynamic only)' },
88
+ { value: 'all', label: 'All (includes kinematic & fixed)' },
89
+ ],
90
+ },
80
91
  ];
81
92
 
82
93
  function PhysicsComponentEditor({ component, onUpdate }: { component: ComponentData; onUpdate: (newComp: any) => void }) {
@@ -101,10 +112,19 @@ interface PhysicsViewProps {
101
112
  }
102
113
 
103
114
  function PhysicsComponentView({ properties, children, position, rotation, scale, editMode, nodeId, registerRigidBodyRef }: PhysicsViewProps) {
104
- const { type, colliders, sensor, ...otherProps } = properties;
115
+ const { type, colliders, sensor, activeCollisionTypes, ...otherProps } = properties;
105
116
  const colliderType = colliders || (type === 'fixed' ? 'trimesh' : 'hull');
106
117
  const rigidBodyRef = useRef<RapierRigidBody>(null);
107
118
 
119
+ // Try to get rapier context - will be null if not inside <Physics>
120
+ let rapier: any = null;
121
+ try {
122
+ const rapierContext = useRapier();
123
+ rapier = rapierContext.rapier;
124
+ } catch (e) {
125
+ // Not inside Physics context - that's ok, just won't have rapier features
126
+ }
127
+
108
128
  // Register RigidBody ref when it's available
109
129
  useEffect(() => {
110
130
  if (nodeId && registerRigidBodyRef && rigidBodyRef.current) {
@@ -117,6 +137,22 @@ function PhysicsComponentView({ properties, children, position, rotation, scale,
117
137
  };
118
138
  }, [nodeId, registerRigidBodyRef]);
119
139
 
140
+ // Configure active collision types for kinematic/sensor bodies
141
+ useEffect(() => {
142
+ if (activeCollisionTypes === 'all' && rigidBodyRef.current && rapier) {
143
+ const rb = rigidBodyRef.current;
144
+ // Apply to all colliders on this rigid body
145
+ for (let i = 0; i < rb.numColliders(); i++) {
146
+ const collider = rb.collider(i);
147
+ collider.setActiveCollisionTypes(
148
+ rapier.ActiveCollisionTypes.DEFAULT |
149
+ rapier.ActiveCollisionTypes.KINEMATIC_FIXED |
150
+ rapier.ActiveCollisionTypes.KINEMATIC_KINEMATIC
151
+ );
152
+ }
153
+ }
154
+ }, [activeCollisionTypes, rapier, type, colliders]);
155
+
120
156
  // Event handlers for physics interactions
121
157
  const handleIntersectionEnter = useCallback((payload: IntersectionEnterPayload) => {
122
158
  if (!nodeId) return;
@@ -124,7 +124,9 @@ export const tree = {
124
124
  scroll: {
125
125
  overflowY: 'auto' as const,
126
126
  padding: 4,
127
- },
127
+ scrollbarWidth: 'thin' as const,
128
+ scrollbarColor: 'rgba(255,255,255,0.06) transparent',
129
+ } as React.CSSProperties,
128
130
  row: {
129
131
  display: 'flex',
130
132
  alignItems: 'center',