@octanejs/drei 0.0.20 → 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 +8 -8
- package/src/core/AccumulativeShadows.three.tsrx +2 -1
- package/src/core/Bounds.three.tsrx +1 -1
- package/src/core/Cloud.three.tsrx +2 -2
- package/src/core/GizmoHelper.three.tsrx +2 -2
- package/src/core/MarchingCubes.three.tsrx +1 -1
- package/src/core/MotionPathControls.three.tsrx +2 -2
- package/src/core/PerformanceMonitor.three.tsrx +3 -3
- package/src/core/Points.three.tsrx +1 -1
- package/src/core/Segments.three.tsrx +1 -1
- package/src/core/SpotLight.three.tsrx +2 -2
- package/src/core/SpriteAnimator.three.tsrx +4 -4
- package/src/web/FaceControls.three.tsrx +2 -2
- package/src/web/FaceLandmarker.three.tsrx +1 -1
- package/src/web/KeyboardControls.three.tsrx +1 -1
- package/src/web/ScrollControls.three.tsrx +4 -4
- package/src/web/Select.three.tsrx +1 -1
- package/src/web/pivotControls/index.three.tsrx +7 -7
- package/src/web/scroll-html-root.tsrx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/drei",
|
|
3
|
-
"version": "0.0.
|
|
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.
|
|
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.
|
|
49
|
+
"@octanejs/three": "0.1.47",
|
|
50
|
+
"octane": "^0.3.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
53
53
|
"@types/three": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@react-three/drei": "10.7.7",
|
|
72
72
|
"@react-three/fiber": "9.6.1",
|
|
73
|
-
"@tsrx/react": "^0.
|
|
73
|
+
"@tsrx/react": "^0.3.0",
|
|
74
74
|
"@types/react": "^19.2.17",
|
|
75
75
|
"@types/stats.js": "^0.17.4",
|
|
76
76
|
"@types/three": "0.172.0",
|
|
@@ -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.
|
|
85
|
-
"@octanejs/zustand": "0.1.
|
|
86
|
-
"octane": "0.
|
|
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
|
-
<
|
|
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 />
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
132
|
+
<MotionContext value={state}>
|
|
133
133
|
{children}
|
|
134
134
|
@if (debug) {
|
|
135
135
|
<Debug color={debugColor} />
|
|
136
136
|
}
|
|
137
|
-
</MotionContext
|
|
137
|
+
</MotionContext>
|
|
138
138
|
</group>
|
|
139
139
|
}
|
|
@@ -44,7 +44,7 @@ export type PerformanceMonitorProps = {
|
|
|
44
44
|
children?: OctaneNode;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
const
|
|
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
|
-
<
|
|
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(
|
|
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
|
|
159
|
+
<PointsContext value={api}>{children}</PointsContext>
|
|
160
160
|
</points>
|
|
161
161
|
}
|
|
162
162
|
|
|
@@ -343,8 +343,8 @@ export function SpotLight({
|
|
|
343
343
|
/>
|
|
344
344
|
}
|
|
345
345
|
</spotLight>
|
|
346
|
-
<SpotLightShadowContext
|
|
346
|
+
<SpotLightShadowContext value={{ spotlightRef: spotlight, debug }}>
|
|
347
347
|
{children}
|
|
348
|
-
</SpotLightShadowContext
|
|
348
|
+
</SpotLightShadowContext>
|
|
349
349
|
</group>
|
|
350
350
|
}
|
|
@@ -72,10 +72,10 @@ type SpriteAnimatorState = {
|
|
|
72
72
|
|
|
73
73
|
type Scale = Vector3;
|
|
74
74
|
|
|
75
|
-
const
|
|
75
|
+
const SpriteAnimatorContext = createContext<SpriteAnimatorState | null>(null);
|
|
76
76
|
|
|
77
77
|
export function useSpriteAnimator(): SpriteAnimatorState | null {
|
|
78
|
-
return useContext(
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
24
|
-
setScrollControlsStateProvider(
|
|
25
|
-
export function useScroll(): ScrollControlsState { return useContext(
|
|
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
|
-
<
|
|
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
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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
|
|
7
|
+
const DomThreeContextProvider = threeContext as unknown as Context<RootStore | null>;
|
|
8
8
|
|
|
9
9
|
function ScrollHtmlContent({ state, fiberState, children }: {
|
|
10
10
|
state: ScrollControlsState;
|