@octanejs/drei 0.0.21 → 0.0.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/drei",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "Octane port of @react-three/drei",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -38,16 +38,16 @@
38
38
  "three-mesh-bvh": "^0.8.3",
39
39
  "three-stdlib": "^2.35.6",
40
40
  "troika-three-text": "^0.52.4",
41
- "@octanejs/zustand": "0.1.53"
41
+ "@octanejs/zustand": "0.1.54"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=22.22.2"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@types/three": ">=0.159",
48
- "octane": "^0.1.51 || ^0.2.0",
49
48
  "three": ">=0.159",
50
- "@octanejs/three": "0.1.46"
49
+ "@octanejs/three": "0.1.47",
50
+ "octane": "^0.3.0"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "@types/three": {
@@ -81,9 +81,9 @@
81
81
  "typescript": "^5.9.3",
82
82
  "vite": "^8.1.5",
83
83
  "vitest": "^4.1.10",
84
- "@octanejs/three": "0.1.46",
85
- "@octanejs/zustand": "0.1.53",
86
- "octane": "0.2.16"
84
+ "@octanejs/three": "0.1.47",
85
+ "@octanejs/zustand": "0.1.54",
86
+ "octane": "0.3.0"
87
87
  },
88
88
  "scripts": {
89
89
  "upstream:generate": "node scripts/generate-upstream-crosswalk.mjs",
@@ -52,6 +52,7 @@ type SoftShadowMaterial = THREE.ShaderMaterial & {
52
52
  };
53
53
 
54
54
  export const accumulativeContext = createContext<AccumulativeContext>(null!);
55
+ const AccumulativeContextProvider = accumulativeContext;
55
56
 
56
57
  const SoftShadowMaterialImpl = shaderMaterial(
57
58
  { color: new THREE.Color(), blend: 2, alphaTest: 0.75, opacity: 0, map: null },
@@ -234,7 +235,7 @@ export function AccumulativeShadows({
234
235
  });
235
236
  <group {...props}>
236
237
  <group {...({ traverse: () => null } as any)} ref={lights}>
237
- <accumulativeContext.Provider value={api}>{children}</accumulativeContext.Provider>
238
+ <AccumulativeContextProvider value={api}>{children}</AccumulativeContextProvider>
238
239
  </group>
239
240
  <mesh receiveShadow ref={plane as any} scale={scale} rotation={[-Math.PI / 2, 0, 0]}>
240
241
  <planeGeometry />
@@ -314,7 +314,7 @@ export function Bounds({
314
314
  }
315
315
  });
316
316
  <group ref={ref}>
317
- <BoundsContext.Provider value={api}>{children as OctaneNode}</BoundsContext.Provider>
317
+ <BoundsContext value={api}>{children as OctaneNode}</BoundsContext>
318
318
  </group>
319
319
  }
320
320
 
@@ -190,7 +190,7 @@ export function Clouds({
190
190
  const maximum = Math.max(imageBounds[0]!, imageBounds[1]!);
191
191
  imageBounds = [imageBounds[0]! / maximum, imageBounds[1]! / maximum];
192
192
  <group ref={mergedRef} {...props}>
193
- <CloudsContext.Provider value={cloudsRef}>
193
+ <CloudsContext value={cloudsRef}>
194
194
  {children}
195
195
  <instancedMesh
196
196
  matrixAutoUpdate={false}
@@ -204,7 +204,7 @@ export function Clouds({
204
204
  </planeGeometry>
205
205
  <CloudMaterialElement map={cloudTexture} transparent={true} depthWrite={false} />
206
206
  </instancedMesh>
207
- </CloudsContext.Provider>
207
+ </CloudsContext>
208
208
  </group>
209
209
  }
210
210
 
@@ -107,9 +107,9 @@ export function GizmoHelper({
107
107
  const x = alignment.endsWith('-center') ? 0 : alignment.endsWith('-left') ? -size.width / 2 + marginX : size.width / 2 - marginX;
108
108
  const y = alignment.startsWith('center-') ? 0 : alignment.startsWith('top-') ? size.height / 2 - marginY : -size.height / 2 + marginY;
109
109
  <Hud renderPriority={renderPriority}>
110
- <GizmoContext.Provider value={context}>
110
+ <GizmoContext value={context}>
111
111
  <OrthographicCamera makeDefault ref={virtualCamera} position={[0, 0, 200]} />
112
112
  <group ref={gizmo} position={[x, y, 0]}>{children}</group>
113
- </GizmoContext.Provider>
113
+ </GizmoContext>
114
114
  </Hud>
115
115
  }
@@ -51,7 +51,7 @@ export function MarchingCubes({
51
51
  marchingCubes.reset();
52
52
  }, -1);
53
53
  <primitive object={marchingCubes} ref={mergedRef as any} {...props as any}>
54
- <MarchingContext.Provider value={api}>{children}</MarchingContext.Provider>
54
+ <MarchingContext value={api}>{children}</MarchingContext>
55
55
  </primitive>
56
56
  }
57
57
 
@@ -129,11 +129,11 @@ export function MotionPathControls({
129
129
  }
130
130
  });
131
131
  <group ref={group as any} {...props}>
132
- <MotionContext.Provider value={state}>
132
+ <MotionContext value={state}>
133
133
  {children}
134
134
  @if (debug) {
135
135
  <Debug color={debugColor} />
136
136
  }
137
- </MotionContext.Provider>
137
+ </MotionContext>
138
138
  </group>
139
139
  }
@@ -44,7 +44,7 @@ export type PerformanceMonitorProps = {
44
44
  children?: OctaneNode;
45
45
  };
46
46
 
47
- const context = createContext<PerformanceMonitorApi>(null!);
47
+ const PerformanceMonitorContext = createContext<PerformanceMonitorApi>(null!);
48
48
 
49
49
  export function PerformanceMonitor({
50
50
  iterations = 10,
@@ -123,7 +123,7 @@ export function PerformanceMonitor({
123
123
  }
124
124
  }
125
125
  });
126
- <context.Provider value={api}>{children}</context.Provider>
126
+ <PerformanceMonitorContext value={api}>{children}</PerformanceMonitorContext>
127
127
  }
128
128
 
129
129
  export function usePerformanceMonitor({
@@ -132,7 +132,7 @@ export function usePerformanceMonitor({
132
132
  onChange,
133
133
  onFallback,
134
134
  }: Partial<PerformanceMonitorHookApi>): void {
135
- const api = useContext(context);
135
+ const api = useContext(PerformanceMonitorContext);
136
136
  const ref = useRef({ onIncline, onDecline, onChange, onFallback });
137
137
  useLayoutEffect(() => {
138
138
  ref.current.onIncline = onIncline;
@@ -156,7 +156,7 @@ function PointsInstances({
156
156
  <bufferAttribute attach="attributes-color" args={[colors, 3]} usage={THREE.DynamicDrawUsage} />
157
157
  <bufferAttribute attach="attributes-size" args={[sizes, 1]} usage={THREE.DynamicDrawUsage} />
158
158
  </bufferGeometry>
159
- <PointsContext.Provider value={api}>{children}</PointsContext.Provider>
159
+ <PointsContext value={api}>{children}</PointsContext>
160
160
  </points>
161
161
  }
162
162
 
@@ -80,7 +80,7 @@ export function Segments({
80
80
  linewidth={lineWidth}
81
81
  {...rest as any}
82
82
  />
83
- <SegmentsContext.Provider value={api}>{children}</SegmentsContext.Provider>
83
+ <SegmentsContext value={api}>{children}</SegmentsContext>
84
84
  </primitive>
85
85
  }
86
86
 
@@ -343,8 +343,8 @@ export function SpotLight({
343
343
  />
344
344
  }
345
345
  </spotLight>
346
- <SpotLightShadowContext.Provider value={{ spotlightRef: spotlight, debug }}>
346
+ <SpotLightShadowContext value={{ spotlightRef: spotlight, debug }}>
347
347
  {children}
348
- </SpotLightShadowContext.Provider>
348
+ </SpotLightShadowContext>
349
349
  </group>
350
350
  }
@@ -72,10 +72,10 @@ type SpriteAnimatorState = {
72
72
 
73
73
  type Scale = Vector3;
74
74
 
75
- const context = createContext<SpriteAnimatorState | null>(null);
75
+ const SpriteAnimatorContext = createContext<SpriteAnimatorState | null>(null);
76
76
 
77
77
  export function useSpriteAnimator(): SpriteAnimatorState | null {
78
- return useContext(context);
78
+ return useContext(SpriteAnimatorContext);
79
79
  }
80
80
 
81
81
  function isSpriteData(data: SpriteData | null): data is SpriteData {
@@ -317,7 +317,7 @@ export function SpriteAnimator({
317
317
  }
318
318
 
319
319
  <group {...props as any} ref={ref} scale={multiplyScale(aspect, props.scale as Scale | undefined)}>
320
- <context.Provider value={state}>
320
+ <SpriteAnimatorContext value={state}>
321
321
  @if (asSprite) {
322
322
  <Billboard>
323
323
  <mesh ref={spriteRef as any} scale={1} geometry={geometry} {...meshProps as any}>
@@ -333,6 +333,6 @@ export function SpriteAnimator({
333
333
  </Instances>
334
334
  }
335
335
  {children}
336
- </context.Provider>
336
+ </SpriteAnimatorContext>
337
337
  </group>
338
338
  }
@@ -151,7 +151,7 @@ export function FaceControls({
151
151
  const faceBlendshapes = result?.faceBlendshapes?.[0];
152
152
  const videoTextureProps = { onVideoFrame, ...videoTexture };
153
153
  const facemeshChildren = facemesh?.children ?? <meshNormalMaterial side={THREE.DoubleSide} />;
154
- <FaceControlsContext.Provider value={api}>
154
+ <FaceControlsContext value={api}>
155
155
  {!manualDetect &&
156
156
  ('src' in videoTextureProps
157
157
  ? <VideoTexture ref={videoTextureRef} {...videoTextureProps as VideoTextureProps} />
@@ -172,7 +172,7 @@ export function FaceControls({
172
172
  visible={debug}
173
173
  children={facemeshChildren}
174
174
  />
175
- </FaceControlsContext.Provider>
175
+ </FaceControlsContext>
176
176
  }
177
177
 
178
178
  export const useFaceControls = (): FaceControlsApi => useContext(FaceControlsContext);
@@ -40,7 +40,7 @@ export function FaceLandmarker({
40
40
  clearResource(keys);
41
41
  }, [faceLandmarker, basePath, serializedOptions]);
42
42
  useImperativeHandle((ref ?? null) as any, () => faceLandmarker, [faceLandmarker]);
43
- <FaceLandmarkerContext.Provider value={faceLandmarker}>{children}</FaceLandmarkerContext.Provider>
43
+ <FaceLandmarkerContext value={faceLandmarker}>{children}</FaceLandmarkerContext>
44
44
  }
45
45
 
46
46
  export function useFaceLandmarker(): FaceLandmarkerImpl | undefined {
@@ -79,7 +79,7 @@ export function KeyboardControls({ map, children, onChange, domElement }: Keyboa
79
79
  source.removeEventListener('keyup', upHandler as EventListener);
80
80
  };
81
81
  }, [domElement, key]);
82
- <KeyboardContext.Provider value={api}>{children}</KeyboardContext.Provider>
82
+ <KeyboardContext value={api}>{children}</KeyboardContext>
83
83
  }
84
84
 
85
85
  type Selector<T extends string = string> = (state: KeyboardControlsState<T>) => boolean;
@@ -20,9 +20,9 @@ export type ScrollControlsState = {
20
20
  visible(from: number, distance: number, margin?: number): boolean;
21
21
  };
22
22
 
23
- const context = createContext<ScrollControlsState>(null as unknown as ScrollControlsState);
24
- setScrollControlsStateProvider(context.Provider);
25
- export function useScroll(): ScrollControlsState { return useContext(context); }
23
+ const ScrollControlsContext = createContext<ScrollControlsState>(null as unknown as ScrollControlsState);
24
+ setScrollControlsStateProvider(ScrollControlsContext);
25
+ export function useScroll(): ScrollControlsState { return useContext(ScrollControlsContext); }
26
26
 
27
27
  export function ScrollControls({ eps = 0.00001, enabled = true, infinite, horizontal, pages = 1,
28
28
  distance = 1, damping = 0.25, maxSpeed = Infinity, prepend = false, style = {}, children }: ScrollControlsProps) @{
@@ -89,7 +89,7 @@ export function ScrollControls({ eps = 0.00001, enabled = true, infinite, horizo
89
89
 
90
90
  let last = 0;
91
91
  useFrame((_, delta) => { last = state.offset; easing.damp(state, 'offset', scroll.current, damping, delta, maxSpeed, undefined, eps); easing.damp(state, 'delta', Math.abs(last - state.offset), damping, delta, maxSpeed, undefined, eps); if (state.delta > eps) invalidate(); });
92
- <context.Provider value={state}>{children}</context.Provider>
92
+ <ScrollControlsContext value={state}>{children}</ScrollControlsContext>
93
93
  }
94
94
 
95
95
  export type ScrollProps = { children?: OctaneNode; html?: false; style?: never } | { children?: OctaneNode; html: true; style?: Partial<CSSStyleDeclaration>; [key: string]: unknown };
@@ -146,7 +146,7 @@ export function Select({
146
146
  onPointerMissed={onPointerMissed}
147
147
  {...props}
148
148
  >
149
- <SelectionContext.Provider value={active}>{children}</SelectionContext.Provider>
149
+ <SelectionContext value={active}>{children}</SelectionContext>
150
150
  </group>
151
151
  }
152
152
 
@@ -21,7 +21,7 @@ import { Html } from '@octanejs/drei';
21
21
  import { Line } from '../../core/lines.three.tsrx';
22
22
  import { calculateScaleFactor } from '../../core/calculateScaleFactor.js';
23
23
  import { PivotAnnotation } from './annotation.tsrx';
24
- import { context, type Limits, type OnDragStartProps, type PivotContext } from './context.js';
24
+ import { context as PivotControlsContext, type Limits, type OnDragStartProps, type PivotContext } from './context.js';
25
25
 
26
26
  const mL0 = new THREE.Matrix4(), mW0 = new THREE.Matrix4(), mP = new THREE.Matrix4(), mPInv = new THREE.Matrix4();
27
27
  const mW = new THREE.Matrix4(), mL = new THREE.Matrix4(), mL0Inv = new THREE.Matrix4(), mdL = new THREE.Matrix4(), mG = new THREE.Matrix4();
@@ -111,7 +111,7 @@ export function calculateOffset(
111
111
  }
112
112
 
113
113
  function AxisArrow({ direction, axis }: { direction: THREE.Vector3; axis: 0 | 1 | 2 }) @{
114
- const config = useContext(context), controls = useThree((state) => state.controls) as {
114
+ const config = useContext(PivotControlsContext), controls = useThree((state) => state.controls) as {
115
115
  enabled: boolean;
116
116
  } | undefined;
117
117
  const divRef = useRef<HTMLDivElement | null>(null), objectRef = useRef<THREE.Group | null>(null);
@@ -250,7 +250,7 @@ function PlaneSlider({
250
250
  dir2: THREE.Vector3;
251
251
  axis: 0 | 1 | 2;
252
252
  }) @{
253
- const config = useContext(context), controls = useThree((state) => state.controls) as {
253
+ const config = useContext(PivotControlsContext), controls = useThree((state) => state.controls) as {
254
254
  enabled: boolean;
255
255
  } | undefined;
256
256
  const divRef = useRef<HTMLDivElement | null>(null), objectRef = useRef<THREE.Group | null>(
@@ -422,7 +422,7 @@ function AxisRotator({
422
422
  dir2: THREE.Vector3;
423
423
  axis: 0 | 1 | 2;
424
424
  }) @{
425
- const config = useContext(context), controls = useThree((state) => state.controls) as {
425
+ const config = useContext(PivotControlsContext), controls = useThree((state) => state.controls) as {
426
426
  enabled: boolean;
427
427
  } | undefined;
428
428
  const divRef = useRef<HTMLDivElement | null>(null), objectRef = useRef<THREE.Group | null>(
@@ -560,7 +560,7 @@ function AxisRotator({
560
560
  }
561
561
 
562
562
  function ScalingSphere({ direction, axis }: { direction: THREE.Vector3; axis: 0 | 1 | 2 }) @{
563
- const config = useContext(context), size = useThree((state) => state.size), controls = useThree(
563
+ const config = useContext(PivotControlsContext), size = useThree((state) => state.size), controls = useThree(
564
564
  (state) => state.controls,
565
565
  ) as { enabled: boolean } | undefined;
566
566
  const divRef = useRef<HTMLDivElement | null>(null), objectRef = useRef<THREE.Group | null>(
@@ -827,7 +827,7 @@ export function PivotControls({
827
827
  }
828
828
  });
829
829
  useImperativeHandle((forwardedRef ?? null) as any, () => ref.current!, []);
830
- <context.Provider value={config}>
830
+ <PivotControlsContext value={config}>
831
831
  <group ref={parentRef}>
832
832
  <group ref={ref} matrix={matrix} matrixAutoUpdate={false} {...props}>
833
833
  <group visible={visible} ref={gizmoRef} position={offset} rotation={rotation}>
@@ -871,7 +871,7 @@ export function PivotControls({
871
871
  <group ref={childrenRef}>{children}</group>
872
872
  </group>
873
873
  </group>
874
- </context.Provider>
874
+ </PivotControlsContext>
875
875
  }
876
876
 
877
877
  export type { OnDragStartProps, PivotContext } from './context.js';
@@ -4,7 +4,7 @@ import type { ScrollControlsState } from './ScrollControls.three.tsrx';
4
4
 
5
5
  // The Three context is registered with Octane's renderer bridge, so this DOM-owned
6
6
  // root must expose that same provider through the DOM Context call signature.
7
- const DomThreeContextProvider = threeContext.Provider as unknown as Context<RootStore | null>['Provider'];
7
+ const DomThreeContextProvider = threeContext as unknown as Context<RootStore | null>;
8
8
 
9
9
  function ScrollHtmlContent({ state, fiberState, children }: {
10
10
  state: ScrollControlsState;