@3driseai/3drise-viewer 0.1.24 → 0.1.26
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/animationsV2/ClipPlayer.d.ts +13 -0
- package/dist/animationsV2/ClipPlayer.d.ts.map +1 -0
- package/dist/animationsV2/ClipPlayer.js +140 -0
- package/dist/animationsV2/ClipsRuntime.d.ts +111 -0
- package/dist/animationsV2/ClipsRuntime.d.ts.map +1 -0
- package/dist/animationsV2/ClipsRuntime.js +476 -0
- package/dist/animationsV2/appliers.d.ts +16 -0
- package/dist/animationsV2/appliers.d.ts.map +1 -0
- package/dist/animationsV2/appliers.js +204 -0
- package/dist/animationsV2/clipUtils.d.ts +33 -0
- package/dist/animationsV2/clipUtils.d.ts.map +1 -0
- package/dist/animationsV2/clipUtils.js +164 -0
- package/dist/animationsV2/elementSettings.d.ts +15 -0
- package/dist/animationsV2/elementSettings.d.ts.map +1 -0
- package/dist/animationsV2/elementSettings.js +16 -0
- package/dist/animationsV2/index.d.ts +16 -0
- package/dist/animationsV2/index.d.ts.map +1 -0
- package/dist/animationsV2/index.js +12 -0
- package/dist/animationsV2/nodeTracks.d.ts +13 -0
- package/dist/animationsV2/nodeTracks.d.ts.map +1 -0
- package/dist/animationsV2/nodeTracks.js +165 -0
- package/dist/animationsV2/normalize.d.ts +4 -0
- package/dist/animationsV2/normalize.d.ts.map +1 -0
- package/dist/animationsV2/normalize.js +49 -0
- package/dist/animationsV2/sequenceUtils.d.ts +57 -0
- package/dist/animationsV2/sequenceUtils.d.ts.map +1 -0
- package/dist/animationsV2/sequenceUtils.js +120 -0
- package/dist/animationsV2/types.d.ts +95 -0
- package/dist/animationsV2/types.d.ts.map +1 -0
- package/dist/animationsV2/types.js +8 -0
- package/dist/api/sceneHandle.d.ts +102 -0
- package/dist/api/sceneHandle.d.ts.map +1 -0
- package/dist/api/sceneHandle.js +237 -0
- package/dist/components/CameraController.d.ts.map +1 -1
- package/dist/components/CameraController.js +3 -44
- package/dist/components/Clouds.d.ts.map +1 -1
- package/dist/components/Clouds.js +0 -34
- package/dist/components/CreatedObject.d.ts.map +1 -1
- package/dist/components/CreatedObject.js +19 -1
- package/dist/components/EnvironmentManager.d.ts.map +1 -1
- package/dist/components/EnvironmentManager.js +6 -4
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +5 -1
- package/dist/components/ObjectsRenderer.d.ts +5 -1
- package/dist/components/ObjectsRenderer.d.ts.map +1 -1
- package/dist/components/ObjectsRenderer.js +24 -3
- package/dist/components/Ocean.d.ts.map +1 -1
- package/dist/components/Ocean.js +0 -63
- package/dist/components/ProjectLoader.d.ts +9 -3
- package/dist/components/ProjectLoader.d.ts.map +1 -1
- package/dist/components/ProjectLoader.js +5 -4
- package/dist/components/SceneBuilder.d.ts +9 -1
- package/dist/components/SceneBuilder.d.ts.map +1 -1
- package/dist/components/SceneBuilder.js +30 -5
- package/dist/components/SkyController.d.ts.map +1 -1
- package/dist/components/SkyController.js +0 -39
- package/dist/components/Stars.d.ts.map +1 -1
- package/dist/components/Stars.js +3 -46
- package/dist/components/terrain/TerrainSurface.d.ts.map +1 -1
- package/dist/components/terrain/TerrainSurface.js +0 -5
- package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts.map +1 -1
- package/dist/components/volumetricClouds/VolumetricCloudsPass.js +0 -6
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -2
- package/dist/hooks/useInteraction.d.ts +7 -7
- package/dist/hooks/useInteraction.d.ts.map +1 -1
- package/dist/hooks/useInteraction.js +87 -233
- package/dist/hooks/useLightConfig.d.ts.map +1 -1
- package/dist/hooks/useLightConfig.js +7 -0
- package/dist/hooks/useLightLive.d.ts.map +1 -1
- package/dist/hooks/useLightLive.js +2 -0
- package/dist/hooks/useLightTargets.d.ts +7 -0
- package/dist/hooks/useLightTargets.d.ts.map +1 -0
- package/dist/hooks/useLightTargets.js +132 -0
- package/dist/hooks/useObjectAnimation.d.ts.map +1 -1
- package/dist/hooks/useObjectAnimation.js +0 -2
- package/dist/hooks/useOceanMaterial.d.ts.map +1 -1
- package/dist/hooks/useOceanMaterial.js +0 -5
- package/dist/hooks/useRuntimeSettings.d.ts +15 -0
- package/dist/hooks/useRuntimeSettings.d.ts.map +1 -0
- package/dist/hooks/useRuntimeSettings.js +22 -0
- package/dist/hooks/useSequenceAnimation.d.ts.map +1 -1
- package/dist/hooks/useSequenceAnimation.js +27 -9
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/interactions/index.d.ts +3 -0
- package/dist/interactions/index.d.ts.map +1 -0
- package/dist/interactions/index.js +1 -0
- package/dist/interactions/runner.d.ts +9 -0
- package/dist/interactions/runner.d.ts.map +1 -0
- package/dist/interactions/runner.js +23 -0
- package/dist/operations/catalogue/displayImage.d.ts +3 -0
- package/dist/operations/catalogue/displayImage.d.ts.map +1 -0
- package/dist/operations/catalogue/displayImage.js +39 -0
- package/dist/operations/catalogue/fade.d.ts +3 -0
- package/dist/operations/catalogue/fade.d.ts.map +1 -0
- package/dist/operations/catalogue/fade.js +44 -0
- package/dist/operations/catalogue/focus.d.ts +3 -0
- package/dist/operations/catalogue/focus.d.ts.map +1 -0
- package/dist/operations/catalogue/focus.js +22 -0
- package/dist/operations/catalogue/glow.d.ts +3 -0
- package/dist/operations/catalogue/glow.d.ts.map +1 -0
- package/dist/operations/catalogue/glow.js +49 -0
- package/dist/operations/catalogue/materialFx.d.ts +6 -0
- package/dist/operations/catalogue/materialFx.d.ts.map +1 -0
- package/dist/operations/catalogue/materialFx.js +13 -0
- package/dist/operations/catalogue/moveToFront.d.ts +3 -0
- package/dist/operations/catalogue/moveToFront.d.ts.map +1 -0
- package/dist/operations/catalogue/moveToFront.js +25 -0
- package/dist/operations/catalogue/visibility.d.ts +3 -0
- package/dist/operations/catalogue/visibility.d.ts.map +1 -0
- package/dist/operations/catalogue/visibility.js +24 -0
- package/dist/operations/catalogue/zoom.d.ts +3 -0
- package/dist/operations/catalogue/zoom.d.ts.map +1 -0
- package/dist/operations/catalogue/zoom.js +32 -0
- package/dist/operations/index.d.ts +5 -0
- package/dist/operations/index.d.ts.map +1 -0
- package/dist/operations/index.js +4 -0
- package/dist/operations/registry.d.ts +11 -0
- package/dist/operations/registry.d.ts.map +1 -0
- package/dist/operations/registry.js +21 -0
- package/dist/operations/runtime.d.ts +22 -0
- package/dist/operations/runtime.d.ts.map +1 -0
- package/dist/operations/runtime.js +161 -0
- package/dist/operations/types.d.ts +96 -0
- package/dist/operations/types.d.ts.map +1 -0
- package/dist/operations/types.js +3 -0
- package/dist/operations/useOperationsRuntime.d.ts +3 -0
- package/dist/operations/useOperationsRuntime.d.ts.map +1 -0
- package/dist/operations/useOperationsRuntime.js +31 -0
- package/package.json +2 -2
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { SceneActions, findNodesByName } from '@3driseai/3drise-core';
|
|
2
|
+
import { findById } from '../utils/sceneQuery.js';
|
|
3
|
+
import { getOperation, resolveParams } from './registry.js';
|
|
4
|
+
const active = new Map(); // `${op}:${uuid}`
|
|
5
|
+
const slots = new Map(); // exclusive group → active key
|
|
6
|
+
const toolsStack = [];
|
|
7
|
+
let cameraHome = null;
|
|
8
|
+
const keyOf = (op, target) => `${op}:${target.uuid}`;
|
|
9
|
+
const tools = () => toolsStack[toolsStack.length - 1];
|
|
10
|
+
function context(self) {
|
|
11
|
+
const t = tools();
|
|
12
|
+
if (!t)
|
|
13
|
+
return null;
|
|
14
|
+
return {
|
|
15
|
+
tools: t,
|
|
16
|
+
self,
|
|
17
|
+
saveCameraHome: () => { if (!cameraHome)
|
|
18
|
+
cameraHome = t.cameraPose(); },
|
|
19
|
+
restoreCameraHome: (duration, ease) => {
|
|
20
|
+
const home = cameraHome;
|
|
21
|
+
cameraHome = null;
|
|
22
|
+
if (home)
|
|
23
|
+
void t.animateCamera({ position: home.position }, duration, ease, home.target);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** Register the mounted scene's tools. Returns the unregister. */
|
|
28
|
+
export function registerOperationTools(t) {
|
|
29
|
+
toolsStack.push(t);
|
|
30
|
+
ensureActionsSubscription();
|
|
31
|
+
return () => {
|
|
32
|
+
const i = toolsStack.lastIndexOf(t);
|
|
33
|
+
if (i >= 0)
|
|
34
|
+
toolsStack.splice(i, 1);
|
|
35
|
+
if (toolsStack.length === 0) {
|
|
36
|
+
active.clear();
|
|
37
|
+
slots.clear();
|
|
38
|
+
cameraHome = null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function isOperationOn(op, target) {
|
|
43
|
+
return active.has(keyOf(op, target));
|
|
44
|
+
}
|
|
45
|
+
export function applyOperation(def, target, params, self) {
|
|
46
|
+
const ctx = context(self);
|
|
47
|
+
if (!ctx)
|
|
48
|
+
return false;
|
|
49
|
+
const key = keyOf(def.value, target);
|
|
50
|
+
if (def.exclusive) {
|
|
51
|
+
const prevKey = slots.get(def.exclusive.group);
|
|
52
|
+
if (prevKey && prevKey !== key) {
|
|
53
|
+
const prev = active.get(prevKey);
|
|
54
|
+
active.delete(prevKey);
|
|
55
|
+
const prevDef = prev && getOperation(prev.op);
|
|
56
|
+
// `revert` puts the previous one back; `handover` leaves it to the new one.
|
|
57
|
+
if (prev && prevDef?.revert && def.exclusive.release === 'revert')
|
|
58
|
+
prevDef.revert(prev.target, prev.params, ctx);
|
|
59
|
+
}
|
|
60
|
+
slots.set(def.exclusive.group, key);
|
|
61
|
+
}
|
|
62
|
+
void def.apply(target, params, ctx);
|
|
63
|
+
if (def.revert)
|
|
64
|
+
active.set(key, { op: def.value, target, params });
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
export function revertOperation(def, target) {
|
|
68
|
+
const key = keyOf(def.value, target);
|
|
69
|
+
const entry = active.get(key);
|
|
70
|
+
const ctx = context();
|
|
71
|
+
if (!entry || !ctx || !def.revert)
|
|
72
|
+
return false;
|
|
73
|
+
active.delete(key);
|
|
74
|
+
if (def.exclusive && slots.get(def.exclusive.group) === key)
|
|
75
|
+
slots.delete(def.exclusive.group);
|
|
76
|
+
def.revert(target, entry.params, ctx);
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
/** The objects an effect acts on: 'self', object ids, narrowed to model nodes. */
|
|
80
|
+
export function resolveEffectTargets(effect, self) {
|
|
81
|
+
const out = [];
|
|
82
|
+
for (const t of effect.targets ?? []) {
|
|
83
|
+
const root = t === 'self' ? self : findById(t);
|
|
84
|
+
if (!root)
|
|
85
|
+
continue;
|
|
86
|
+
const names = t === 'self' ? undefined : effect.meshNames?.[t];
|
|
87
|
+
if (names?.length) {
|
|
88
|
+
for (const name of names)
|
|
89
|
+
out.push(...findNodesByName(root, name).filter(n => n !== root));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
out.push(root);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Run one effect.
|
|
99
|
+
* trigger interactions: toggle when the operation toggles, else apply
|
|
100
|
+
* apply / revert / toggle explicit
|
|
101
|
+
*/
|
|
102
|
+
export function runEffect(effect, mode, self) {
|
|
103
|
+
const def = getOperation(effect.operation);
|
|
104
|
+
if (!def)
|
|
105
|
+
return;
|
|
106
|
+
const targets = resolveEffectTargets(effect, self);
|
|
107
|
+
const params = resolveParams(def, effect.params);
|
|
108
|
+
for (const target of def.multi ? targets : targets.slice(0, 1)) {
|
|
109
|
+
const on = isOperationOn(def.value, target);
|
|
110
|
+
const m = mode === 'trigger' ? (def.toggles ? 'toggle' : 'apply') : mode;
|
|
111
|
+
if (m === 'revert' || (m === 'toggle' && on))
|
|
112
|
+
revertOperation(def, target);
|
|
113
|
+
else if (m === 'apply' || m === 'toggle')
|
|
114
|
+
applyOperation(def, target, params, self);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// ---------------------------------------------------------------- actions
|
|
118
|
+
const actionEffectsOn = new Set();
|
|
119
|
+
const listeners = new Set();
|
|
120
|
+
const notify = () => listeners.forEach(l => { try {
|
|
121
|
+
l();
|
|
122
|
+
}
|
|
123
|
+
catch { /* listener error */ } });
|
|
124
|
+
/** Apply or undo an action's effects directly (the editor's "Try it"). */
|
|
125
|
+
export function runActionEffects(action, mode) {
|
|
126
|
+
const on = actionEffectsOn.has(action.id);
|
|
127
|
+
if (mode === 'apply' && on)
|
|
128
|
+
return;
|
|
129
|
+
if (mode === 'revert' && !on)
|
|
130
|
+
return;
|
|
131
|
+
for (const effect of action.effects ?? [])
|
|
132
|
+
runEffect(effect, mode);
|
|
133
|
+
if (mode === 'apply')
|
|
134
|
+
actionEffectsOn.add(action.id);
|
|
135
|
+
else
|
|
136
|
+
actionEffectsOn.delete(action.id);
|
|
137
|
+
notify();
|
|
138
|
+
}
|
|
139
|
+
export const areActionEffectsOn = (actionId) => actionEffectsOn.has(actionId);
|
|
140
|
+
/** Subscribe to action-effects on/off changes (studio badges). */
|
|
141
|
+
export function subscribeActionEffects(fn) {
|
|
142
|
+
listeners.add(fn);
|
|
143
|
+
return () => { listeners.delete(fn); };
|
|
144
|
+
}
|
|
145
|
+
let unsubscribeActions = null;
|
|
146
|
+
function ensureActionsSubscription() {
|
|
147
|
+
if (unsubscribeActions)
|
|
148
|
+
return;
|
|
149
|
+
unsubscribeActions = SceneActions.onEvent((e) => {
|
|
150
|
+
if (e.type === 'applied') {
|
|
151
|
+
if (e.runEffects)
|
|
152
|
+
runActionEffects(e.action, 'apply');
|
|
153
|
+
}
|
|
154
|
+
else if (e.type === 'reverted') {
|
|
155
|
+
runActionEffects(e.action, 'revert');
|
|
156
|
+
}
|
|
157
|
+
else if (e.type === 'reset') {
|
|
158
|
+
e.actions.forEach(a => runActionEffects(a, 'revert'));
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Object3D } from 'three';
|
|
2
|
+
import type { OperationName, OperationParamValue, Vector3Array } from '@3driseai/3drise-core';
|
|
3
|
+
/** A parameter the studio shows under the effect, with its default. */
|
|
4
|
+
export type OperationParamSpec = {
|
|
5
|
+
type: 'number';
|
|
6
|
+
label: string;
|
|
7
|
+
default: number;
|
|
8
|
+
min?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
step?: number;
|
|
11
|
+
unit?: string;
|
|
12
|
+
hint?: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: 'color';
|
|
15
|
+
label: string;
|
|
16
|
+
default: string;
|
|
17
|
+
hint?: string;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'select';
|
|
20
|
+
label: string;
|
|
21
|
+
default: string;
|
|
22
|
+
options: Array<{
|
|
23
|
+
value: string;
|
|
24
|
+
label: string;
|
|
25
|
+
}>;
|
|
26
|
+
hint?: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'boolean';
|
|
29
|
+
label: string;
|
|
30
|
+
default: boolean;
|
|
31
|
+
hint?: string;
|
|
32
|
+
};
|
|
33
|
+
export type OperationParams = Record<string, OperationParamValue>;
|
|
34
|
+
export type OperationSource = 'interaction' | 'action';
|
|
35
|
+
/** Scene tools the runtime hands an operation (built from the viewer's hooks). */
|
|
36
|
+
export interface OperationTools {
|
|
37
|
+
/** Animate the camera; `lookAt` moves the orbit target. */
|
|
38
|
+
animateCamera: (to: {
|
|
39
|
+
position?: Vector3Array;
|
|
40
|
+
}, duration: number, ease: string, lookAt?: Vector3Array) => Promise<void>;
|
|
41
|
+
/** Where the camera is and looks right now. */
|
|
42
|
+
cameraPose: () => {
|
|
43
|
+
position: Vector3Array;
|
|
44
|
+
target: Vector3Array;
|
|
45
|
+
} | null;
|
|
46
|
+
moveToFront: (object: Object3D, options: {
|
|
47
|
+
distance: number;
|
|
48
|
+
scale: [number, number];
|
|
49
|
+
duration: number;
|
|
50
|
+
ease: string;
|
|
51
|
+
}) => void;
|
|
52
|
+
restoreTransform: (object: Object3D, options: {
|
|
53
|
+
duration: number;
|
|
54
|
+
ease: string;
|
|
55
|
+
}) => void;
|
|
56
|
+
}
|
|
57
|
+
export interface OperationContext {
|
|
58
|
+
tools: OperationTools;
|
|
59
|
+
/** The object an interaction is on (interactions only). */
|
|
60
|
+
self?: Object3D | null;
|
|
61
|
+
/** Remember the camera pose once, before the first camera operation. */
|
|
62
|
+
saveCameraHome: () => void;
|
|
63
|
+
/** Fly back to the remembered pose and forget it. */
|
|
64
|
+
restoreCameraHome: (duration: number, ease: string) => void;
|
|
65
|
+
}
|
|
66
|
+
export interface OperationDefinition {
|
|
67
|
+
value: OperationName;
|
|
68
|
+
label: string;
|
|
69
|
+
/** One line for the studio (tooltip). */
|
|
70
|
+
description: string;
|
|
71
|
+
/** More than one target allowed. */
|
|
72
|
+
multi: boolean;
|
|
73
|
+
/** An interaction triggered again undoes it. */
|
|
74
|
+
toggles: boolean;
|
|
75
|
+
/** Where the operation can be used. */
|
|
76
|
+
usableIn: OperationSource[];
|
|
77
|
+
/** Only on gallery objects. */
|
|
78
|
+
galleryOnly?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* One target of this group is "on" at a time, scene-wide. Applying another:
|
|
81
|
+
* `revert` undoes the previous one first (bring to front), `handover` just
|
|
82
|
+
* takes over (camera moves — the remembered home pose stays).
|
|
83
|
+
*/
|
|
84
|
+
exclusive?: {
|
|
85
|
+
group: string;
|
|
86
|
+
release: 'revert' | 'handover';
|
|
87
|
+
};
|
|
88
|
+
params?: Record<string, OperationParamSpec>;
|
|
89
|
+
apply: (target: Object3D, params: OperationParams, ctx: OperationContext) => void | Promise<void>;
|
|
90
|
+
/** No revert = one-way (applies only). */
|
|
91
|
+
revert?: (target: Object3D, params: OperationParams, ctx: OperationContext) => void;
|
|
92
|
+
}
|
|
93
|
+
/** Type helper for catalogue files. */
|
|
94
|
+
export declare const defineOperation: (def: OperationDefinition) => OperationDefinition;
|
|
95
|
+
export declare const DEFAULT_EASE = "power2.out";
|
|
96
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/operations/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOperationsRuntime.d.ts","sourceRoot":"","sources":["../../src/operations/useOperationsRuntime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,uBAAuB,CAAC;AAQvE,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,WAAW,QAuB/D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Mounts the operations runtime on the scene: builds the scene tools from the
|
|
2
|
+
// viewer's hooks and registers them. Called once, in ObjectsRenderer.
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import cameraManager from '../utils/CameraSingleton.js';
|
|
5
|
+
import useCameraAnimation from '../hooks/useCameraAnimation.js';
|
|
6
|
+
import { useFrameAnimations } from '../hooks/useFrameAnimations.js';
|
|
7
|
+
import { useOrbitControls } from '../hooks/useOrbitControls.js';
|
|
8
|
+
import { registerOperationTools } from './runtime.js';
|
|
9
|
+
export function useOperationsRuntime(cameraSettings) {
|
|
10
|
+
const { animateCamera } = useCameraAnimation({ autoAnimate: false, defaultDuration: 1, defaultEase: 'power2.out' });
|
|
11
|
+
const { moveToFront, restoreOriginalTransform } = useFrameAnimations(cameraSettings);
|
|
12
|
+
const controls = useOrbitControls();
|
|
13
|
+
// Latest hook functions, read at call time (the registration itself is stable).
|
|
14
|
+
const latest = useRef({ animateCamera, moveToFront, restoreOriginalTransform, controls, cameraSettings });
|
|
15
|
+
latest.current = { animateCamera, moveToFront, restoreOriginalTransform, controls, cameraSettings };
|
|
16
|
+
useEffect(() => registerOperationTools({
|
|
17
|
+
animateCamera: (to, duration, ease, lookAt) => latest.current.animateCamera(to, duration, ease, lookAt),
|
|
18
|
+
cameraPose: () => {
|
|
19
|
+
const pos = cameraManager.getPosition();
|
|
20
|
+
if (!pos)
|
|
21
|
+
return null;
|
|
22
|
+
const t = latest.current.controls?.target;
|
|
23
|
+
const target = t
|
|
24
|
+
? [t.x, t.y, t.z]
|
|
25
|
+
: latest.current.cameraSettings?.controls?.target ?? [0, 0, 0];
|
|
26
|
+
return { position: [pos.x, pos.y, pos.z], target };
|
|
27
|
+
},
|
|
28
|
+
moveToFront: (object, o) => latest.current.moveToFront(object, o),
|
|
29
|
+
restoreTransform: (object, o) => latest.current.restoreOriginalTransform(object, o),
|
|
30
|
+
}), []);
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3driseai/3drise-viewer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@3driseai/3drise-common": "^1.0.1",
|
|
42
|
-
"@3driseai/3drise-core": "^1.0.
|
|
42
|
+
"@3driseai/3drise-core": "^1.0.19"
|
|
43
43
|
}
|
|
44
44
|
}
|