@fps-games/editor 0.1.1-beta.9 → 0.1.2-beta.2
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/local-editor-harness.d.ts +52 -4
- package/dist/local-editor-harness.d.ts.map +1 -1
- package/dist/local-editor-harness.js +437 -91
- package/dist/local-editor-harness.js.map +1 -1
- package/dist/local-editor-scene-render-scheduler.d.ts +33 -0
- package/dist/local-editor-scene-render-scheduler.d.ts.map +1 -0
- package/dist/local-editor-scene-render-scheduler.js +160 -0
- package/dist/local-editor-scene-render-scheduler.js.map +1 -0
- package/dist/local-editor-scene-view-interaction-runtime.d.ts +22 -0
- package/dist/local-editor-scene-view-interaction-runtime.d.ts.map +1 -0
- package/dist/local-editor-scene-view-interaction-runtime.js +80 -0
- package/dist/local-editor-scene-view-interaction-runtime.js.map +1 -0
- package/dist/local-editor-viewport-render-coordinator.d.ts +17 -0
- package/dist/local-editor-viewport-render-coordinator.d.ts.map +1 -0
- package/dist/local-editor-viewport-render-coordinator.js +102 -0
- package/dist/local-editor-viewport-render-coordinator.js.map +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/editor-sky.d.ts +2 -0
- package/node_modules/@fps-games/editor-babylon/dist/editor-sky.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/editor-sky.js +9 -3
- package/node_modules/@fps-games/editor-babylon/dist/editor-sky.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/editor-world.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/editor-world.js +2 -0
- package/node_modules/@fps-games/editor-babylon/dist/editor-world.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/index.d.ts +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/index.js +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/index.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/infinite-grid.d.ts +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/infinite-grid.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/infinite-grid.js +335 -32
- package/node_modules/@fps-games/editor-babylon/dist/infinite-grid.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/main-camera-preview.d.ts +25 -0
- package/node_modules/@fps-games/editor-babylon/dist/main-camera-preview.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/main-camera-preview.js +162 -0
- package/node_modules/@fps-games/editor-babylon/dist/main-camera-preview.js.map +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/projection.d.ts +28 -1
- package/node_modules/@fps-games/editor-babylon/dist/projection.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/projection.js +169 -25
- package/node_modules/@fps-games/editor-babylon/dist/projection.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/scene-camera-preview.d.ts +2 -22
- package/node_modules/@fps-games/editor-babylon/dist/scene-camera-preview.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/scene-camera-preview.js +1 -121
- package/node_modules/@fps-games/editor-babylon/dist/scene-camera-preview.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/scene-view-camera-controller.d.ts +4 -0
- package/node_modules/@fps-games/editor-babylon/dist/scene-view-camera-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/scene-view-camera-controller.js +37 -23
- package/node_modules/@fps-games/editor-babylon/dist/scene-view-camera-controller.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/scene-view-input-controller.d.ts +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/scene-view-input-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/scene-view-input-controller.js +100 -8
- package/node_modules/@fps-games/editor-babylon/dist/scene-view-input-controller.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.d.ts +6 -1
- package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.js +172 -106
- package/node_modules/@fps-games/editor-babylon/dist/transform-gizmo-controller.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/transform-solver.d.ts +30 -0
- package/node_modules/@fps-games/editor-babylon/dist/transform-solver.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/transform-solver.js +120 -0
- package/node_modules/@fps-games/editor-babylon/dist/transform-solver.js.map +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/types.d.ts +2 -0
- package/node_modules/@fps-games/editor-babylon/dist/types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/package.json +4 -4
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-actions.d.ts +2 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-actions.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-actions.js +167 -34
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-actions.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.d.ts +2 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.js +105 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.d.ts +3 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.js +49 -4
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-input-router.d.ts +4 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-input-router.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-input-router.js +12 -3
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-input-router.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.d.ts +1 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.js +96 -14
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shared.js +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shared.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shortcuts.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shortcuts.js +7 -6
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shortcuts.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-tooltip.js +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.d.ts +59 -2
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-workbench.d.ts +1 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-workbench.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-workbench.js +3 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-workbench.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.d.ts +5 -2
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.js +260 -40
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/package.json +2 -2
- package/node_modules/@fps-games/editor-core/dist/scene-view-input.d.ts +7 -0
- package/node_modules/@fps-games/editor-core/dist/scene-view-input.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/transform-gizmo.d.ts +22 -0
- package/node_modules/@fps-games/editor-core/dist/transform-gizmo.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/transform-gizmo.js.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/viewport-tools.d.ts +6 -6
- package/node_modules/@fps-games/editor-core/dist/viewport-tools.js +3 -3
- package/node_modules/@fps-games/editor-core/dist/viewport-tools.js.map +1 -1
- package/node_modules/@fps-games/editor-core/package.json +2 -2
- package/node_modules/@fps-games/editor-forge-play/package.json +2 -2
- package/node_modules/@fps-games/editor-protocol/package.json +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { applyBabylonEditorProjectionCameraRig } from './projection';
|
|
2
|
+
const DEFAULT_MAIN_CAMERA_PREVIEW_SETTINGS = {
|
|
3
|
+
projection: 'orthographic',
|
|
4
|
+
alpha: 3.9269908169872414,
|
|
5
|
+
beta: 0.8,
|
|
6
|
+
radius: 14,
|
|
7
|
+
orthoSize: 6,
|
|
8
|
+
fov: 0.85,
|
|
9
|
+
targetOffset: { x: 0, y: 0, z: 0 },
|
|
10
|
+
minZ: 1,
|
|
11
|
+
maxZ: 10000,
|
|
12
|
+
inertia: 0.9,
|
|
13
|
+
targetScreenOffset: { x: 0, y: 0 },
|
|
14
|
+
};
|
|
15
|
+
export function createBabylonMainCameraPreviewController(options) {
|
|
16
|
+
let previewCamera = null;
|
|
17
|
+
let previewCameraKind = null;
|
|
18
|
+
let savedActiveCamera = null;
|
|
19
|
+
let savedActiveCameras = null;
|
|
20
|
+
let savedPointerCamera = null;
|
|
21
|
+
let active = false;
|
|
22
|
+
function getPreviewCameraKind(rig) {
|
|
23
|
+
return rig?.transform && options.babylon.UniversalCamera ? 'transform' : 'orbit';
|
|
24
|
+
}
|
|
25
|
+
function ensurePreviewCamera(kind) {
|
|
26
|
+
if (previewCamera && previewCameraKind === kind)
|
|
27
|
+
return previewCamera;
|
|
28
|
+
previewCamera?.dispose?.();
|
|
29
|
+
previewCamera = null;
|
|
30
|
+
previewCameraKind = null;
|
|
31
|
+
const Vector3 = options.babylon.Vector3;
|
|
32
|
+
if (!Vector3)
|
|
33
|
+
return null;
|
|
34
|
+
if (kind === 'transform' && options.babylon.UniversalCamera) {
|
|
35
|
+
previewCamera = new options.babylon.UniversalCamera('editor-main-camera-preview', new Vector3(0, 0, 0), options.scene);
|
|
36
|
+
}
|
|
37
|
+
else if (options.babylon.ArcRotateCamera) {
|
|
38
|
+
previewCamera = new options.babylon.ArcRotateCamera('editor-main-camera-preview', DEFAULT_MAIN_CAMERA_PREVIEW_SETTINGS.alpha, DEFAULT_MAIN_CAMERA_PREVIEW_SETTINGS.beta, DEFAULT_MAIN_CAMERA_PREVIEW_SETTINGS.radius, new Vector3(0, 0, 0), options.scene);
|
|
39
|
+
}
|
|
40
|
+
else if (options.babylon.UniversalCamera) {
|
|
41
|
+
previewCamera = new options.babylon.UniversalCamera('editor-main-camera-preview', new Vector3(0, 0, 0), options.scene);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
previewCameraKind = kind;
|
|
47
|
+
previewCamera.inertia = 0;
|
|
48
|
+
return previewCamera;
|
|
49
|
+
}
|
|
50
|
+
function restoreEditorCamera() {
|
|
51
|
+
if (!active)
|
|
52
|
+
return;
|
|
53
|
+
options.scene.activeCamera = savedActiveCamera ?? options.editorCamera;
|
|
54
|
+
if (Array.isArray(savedActiveCameras)) {
|
|
55
|
+
options.scene.activeCameras = savedActiveCameras;
|
|
56
|
+
}
|
|
57
|
+
else if (options.scene.activeCameras) {
|
|
58
|
+
options.scene.activeCameras = [savedActiveCamera ?? options.editorCamera];
|
|
59
|
+
}
|
|
60
|
+
options.scene.cameraToUseForPointers = savedPointerCamera ?? options.editorCamera;
|
|
61
|
+
savedActiveCamera = null;
|
|
62
|
+
savedActiveCameras = null;
|
|
63
|
+
savedPointerCamera = null;
|
|
64
|
+
active = false;
|
|
65
|
+
}
|
|
66
|
+
function applyRig(rig) {
|
|
67
|
+
const camera = ensurePreviewCamera(getPreviewCameraKind(rig));
|
|
68
|
+
const Vector3 = options.babylon.Vector3;
|
|
69
|
+
if (!camera || !Vector3)
|
|
70
|
+
return;
|
|
71
|
+
const settings = {
|
|
72
|
+
...DEFAULT_MAIN_CAMERA_PREVIEW_SETTINGS,
|
|
73
|
+
...(rig?.settings ?? {}),
|
|
74
|
+
};
|
|
75
|
+
const target = rig?.target ?? settings.targetOffset ?? { x: 0, y: 0, z: 0 };
|
|
76
|
+
if (rig?.transform) {
|
|
77
|
+
const transform = rig.transform;
|
|
78
|
+
camera.position = new Vector3(transform.position.x, transform.position.y, transform.position.z);
|
|
79
|
+
if (camera.rotationQuaternion)
|
|
80
|
+
camera.rotationQuaternion = null;
|
|
81
|
+
camera.rotation = new Vector3(transform.rotation.x, transform.rotation.y, transform.rotation.z);
|
|
82
|
+
applyBabylonEditorProjectionCameraRig(options.babylon, options.scene, camera, settings, { lockOrbit: false });
|
|
83
|
+
camera.position = new Vector3(transform.position.x, transform.position.y, transform.position.z);
|
|
84
|
+
if (camera.rotationQuaternion)
|
|
85
|
+
camera.rotationQuaternion = null;
|
|
86
|
+
camera.rotation = new Vector3(transform.rotation.x, transform.rotation.y, transform.rotation.z);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
if (typeof camera.alpha === 'number') {
|
|
90
|
+
applyBabylonEditorProjectionCameraRig(options.babylon, options.scene, camera, settings, { target });
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
camera.position = createOrbitPosition(Vector3, target, settings);
|
|
94
|
+
applyBabylonEditorProjectionCameraRig(options.babylon, options.scene, camera, settings, { target });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
isActive() {
|
|
100
|
+
return active;
|
|
101
|
+
},
|
|
102
|
+
setActive(nextActive, rig) {
|
|
103
|
+
if (nextActive) {
|
|
104
|
+
if (!active) {
|
|
105
|
+
savedActiveCamera = options.scene.activeCamera ?? options.editorCamera;
|
|
106
|
+
savedActiveCameras = Array.isArray(options.scene.activeCameras)
|
|
107
|
+
? [...options.scene.activeCameras]
|
|
108
|
+
: null;
|
|
109
|
+
savedPointerCamera = options.scene.cameraToUseForPointers ?? null;
|
|
110
|
+
}
|
|
111
|
+
const camera = ensurePreviewCamera(getPreviewCameraKind(rig));
|
|
112
|
+
if (!camera) {
|
|
113
|
+
savedActiveCamera = null;
|
|
114
|
+
savedActiveCameras = null;
|
|
115
|
+
savedPointerCamera = null;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (!active) {
|
|
119
|
+
active = true;
|
|
120
|
+
}
|
|
121
|
+
applyRig(rig);
|
|
122
|
+
options.scene.activeCamera = camera;
|
|
123
|
+
if (options.scene.activeCameras)
|
|
124
|
+
options.scene.activeCameras = [camera];
|
|
125
|
+
options.scene.cameraToUseForPointers = camera;
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
restoreEditorCamera();
|
|
129
|
+
},
|
|
130
|
+
sync(rig) {
|
|
131
|
+
if (!active)
|
|
132
|
+
return;
|
|
133
|
+
applyRig(rig);
|
|
134
|
+
},
|
|
135
|
+
dispose() {
|
|
136
|
+
restoreEditorCamera();
|
|
137
|
+
previewCamera?.dispose?.();
|
|
138
|
+
previewCamera = null;
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export function createBabylonMainCameraPreviewRigFromProjectionNode(node) {
|
|
143
|
+
if (!node || node.runtimeKind !== 'camera' || node.active === false)
|
|
144
|
+
return null;
|
|
145
|
+
return {
|
|
146
|
+
...(node.transform
|
|
147
|
+
? {
|
|
148
|
+
transform: {
|
|
149
|
+
position: { ...node.transform.position },
|
|
150
|
+
rotation: { ...node.transform.rotation },
|
|
151
|
+
...(node.transform.scale ? { scale: { ...node.transform.scale } } : {}),
|
|
152
|
+
},
|
|
153
|
+
}
|
|
154
|
+
: {}),
|
|
155
|
+
...(node.camera ? { settings: { ...node.camera } } : {}),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function createOrbitPosition(Vector3, target, settings) {
|
|
159
|
+
const sinBeta = Math.sin(settings.beta);
|
|
160
|
+
return new Vector3(target.x + settings.radius * Math.cos(settings.alpha) * sinBeta, target.y + settings.radius * Math.cos(settings.beta), target.z + settings.radius * Math.sin(settings.alpha) * sinBeta);
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=main-camera-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-camera-preview.js","sourceRoot":"","sources":["../src/main-camera-preview.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qCAAqC,EAAE,MAAM,cAAc,CAAC;AA0BrE,MAAM,oCAAoC,GAA0C;IAClF,UAAU,EAAE,cAAc;IAC1B,KAAK,EAAE,kBAAkB;IACzB,IAAI,EAAE,GAAG;IACT,MAAM,EAAE,EAAE;IACV,SAAS,EAAE,CAAC;IACZ,GAAG,EAAE,IAAI;IACT,YAAY,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;IAClC,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,GAAG;IACZ,kBAAkB,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;CACnC,CAAC;AAEF,MAAM,UAAU,wCAAwC,CACtD,OAAkD;IAElD,IAAI,aAAa,GAAyB,IAAI,CAAC;IAC/C,IAAI,iBAAiB,GAAiC,IAAI,CAAC;IAC3D,IAAI,iBAAiB,GAAyB,IAAI,CAAC;IACnD,IAAI,kBAAkB,GAA2B,IAAI,CAAC;IACtD,IAAI,kB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,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzD,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAC1B,OAAqD,EACrD,MAA2C,EAC3C,QAA+C;IAE/C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxC,OAAO,IAAI,OAAO,CAChB,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,OAAO,EAC/D,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EACpD,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,OAAO,CAChE,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { EditorSelectionState, EditorTransformPivot, EditorTransformSnapshot, EditorTransformVec3 } from '@fps-games/editor-core';
|
|
2
|
-
import type { BabylonRuntimeGlobal, RuntimeScene } from './types';
|
|
2
|
+
import type { BabylonRuntimeGlobal, RuntimeCamera, RuntimeScene } from './types';
|
|
3
3
|
export type BabylonEditorProjectionVec3 = EditorTransformVec3;
|
|
4
|
+
export interface BabylonEditorProjectionVec2 {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}
|
|
4
8
|
export interface BabylonEditorProjectionTransform {
|
|
5
9
|
position: BabylonEditorProjectionVec3;
|
|
6
10
|
rotation: BabylonEditorProjectionVec3;
|
|
@@ -22,11 +26,27 @@ export type BabylonEditorProjectionPrimitiveShape = 'cube' | 'sphere' | 'plane'
|
|
|
22
26
|
export interface BabylonEditorProjectionPrimitive {
|
|
23
27
|
shape: BabylonEditorProjectionPrimitiveShape;
|
|
24
28
|
}
|
|
29
|
+
export type BabylonEditorProjectionCameraMode = 'orthographic' | 'perspective';
|
|
25
30
|
export interface BabylonEditorProjectionCameraSettings {
|
|
31
|
+
projection?: BabylonEditorProjectionCameraMode;
|
|
26
32
|
alpha: number;
|
|
27
33
|
beta: number;
|
|
28
34
|
radius: number;
|
|
29
35
|
orthoSize: number;
|
|
36
|
+
fov?: number;
|
|
37
|
+
targetOffset?: BabylonEditorProjectionVec3;
|
|
38
|
+
minZ?: number;
|
|
39
|
+
maxZ?: number;
|
|
40
|
+
lowerBetaLimit?: number;
|
|
41
|
+
upperBetaLimit?: number;
|
|
42
|
+
lowerRadiusLimit?: number;
|
|
43
|
+
upperRadiusLimit?: number;
|
|
44
|
+
inertia?: number;
|
|
45
|
+
targetScreenOffset?: BabylonEditorProjectionVec2;
|
|
46
|
+
}
|
|
47
|
+
export interface BabylonEditorProjectionCameraRigApplyOptions {
|
|
48
|
+
target?: BabylonEditorProjectionVec3 | null;
|
|
49
|
+
lockOrbit?: boolean;
|
|
30
50
|
}
|
|
31
51
|
export interface BabylonEditorProjectionColorRGB {
|
|
32
52
|
r: number;
|
|
@@ -70,6 +90,11 @@ export interface BabylonEditorProjectionOptions {
|
|
|
70
90
|
scene: RuntimeScene;
|
|
71
91
|
importModel?: BabylonEditorProjectionImporter;
|
|
72
92
|
logger?: Pick<Console, 'warn'>;
|
|
93
|
+
onProjectionReady?: (event: BabylonEditorProjectionReadyEvent) => void;
|
|
94
|
+
}
|
|
95
|
+
export interface BabylonEditorProjectionReadyEvent {
|
|
96
|
+
nodeId: string;
|
|
97
|
+
async: boolean;
|
|
73
98
|
}
|
|
74
99
|
export interface ProjectedBabylonEditorNode {
|
|
75
100
|
nodeId: string;
|
|
@@ -113,5 +138,7 @@ export interface BabylonEditorProjectionBounds {
|
|
|
113
138
|
}
|
|
114
139
|
export declare function createBabylonEditorProjection(options: BabylonEditorProjectionOptions): BabylonEditorProjection;
|
|
115
140
|
export declare function readProjectionTransform(node: any): EditorTransformSnapshot;
|
|
141
|
+
export declare function normalizeBabylonEditorProjectionCameraSettings(settings: BabylonEditorProjectionCameraSettings | undefined): BabylonEditorProjectionCameraSettings;
|
|
142
|
+
export declare function applyBabylonEditorProjectionCameraRig(babylon: BabylonRuntimeGlobal, scene: RuntimeScene, camera: RuntimeCamera, settings: BabylonEditorProjectionCameraSettings | undefined, options?: BabylonEditorProjectionCameraRigApplyOptions): BabylonEditorProjectionCameraSettings;
|
|
116
143
|
export declare function applyProjectionTransform(babylon: BabylonRuntimeGlobal, node: any, transform: BabylonEditorProjectionTransform): void;
|
|
117
144
|
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,2BAA2B,GAAG,mBAAmB,CAAC;AAE9D,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,2BAA2B,CAAC;IACtC,QAAQ,EAAE,2BAA2B,CAAC;IACtC,KAAK,CAAC,EAAE,2BAA2B,CAAC;CACrC;AAED,MAAM,WAAW,qCAAqC;IACpD,QAAQ,CAAC,EAAE,2BAA2B,CAAC;IACvC,QAAQ,CAAC,EAAE,2BAA2B,CAAC;IACvC,WAAW,CAAC,EAAE,2BAA2B,CAAC;IAC1C,KAAK,CAAC,EAAE,MAAM,GAAG,2BAA2B,CAAC;CAC9C;AAED,MAAM,WAAW,4BAA4B;IAC3C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,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gB,wBAAwB,CACtC,OAAO,EAAE,oBAAoB,EAC7B,IAAI,EAAE,GAAG,EACT,SAAS,EAAE,gCAAgC,GAC1C,IAAI,CAMN"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const ROOT_HELPER_LABEL = 'World Origin';
|
|
1
2
|
function requireBabylonCtor(value, name) {
|
|
2
3
|
if (!value)
|
|
3
4
|
throw new Error(`Babylon runtime missing ${name}`);
|
|
@@ -283,6 +284,11 @@ async function loadModelProjection(options, node, projection) {
|
|
|
283
284
|
attachFallbackProjection(options.babylon, options.scene, node, projection, true);
|
|
284
285
|
}
|
|
285
286
|
}
|
|
287
|
+
finally {
|
|
288
|
+
if (!projection.root.isDisposed?.()) {
|
|
289
|
+
options.onProjectionReady?.({ nodeId: node.id, async: true });
|
|
290
|
+
}
|
|
291
|
+
}
|
|
286
292
|
}
|
|
287
293
|
function attachImportedProjectionResult(babylon, scene, node, asset, projection, result) {
|
|
288
294
|
const TransformNode = babylon.TransformNode;
|
|
@@ -357,7 +363,7 @@ function attachCameraProjection(babylon, scene, node, projection) {
|
|
|
357
363
|
const Color3 = requireBabylonCtor(babylon.Color3, 'Color3');
|
|
358
364
|
if (!MeshBuilder || !StandardMaterial)
|
|
359
365
|
return;
|
|
360
|
-
const settings =
|
|
366
|
+
const settings = normalizeBabylonEditorProjectionCameraSettings(node.camera);
|
|
361
367
|
const body = MeshBuilder.CreateBox(`${node.id}.cameraHelper`, {
|
|
362
368
|
width: 0.38,
|
|
363
369
|
height: 0.28,
|
|
@@ -455,7 +461,7 @@ function createRootLabelProjection(babylon, scene, node) {
|
|
|
455
461
|
let texture;
|
|
456
462
|
try {
|
|
457
463
|
texture = new DynamicTexture(`${node.id}.rootLabel.texture`, {
|
|
458
|
-
width:
|
|
464
|
+
width: 384,
|
|
459
465
|
height: 96,
|
|
460
466
|
}, scene, false);
|
|
461
467
|
}
|
|
@@ -473,7 +479,7 @@ function createRootLabelProjection(babylon, scene, node) {
|
|
|
473
479
|
material.specularColor = new Color3(0, 0, 0);
|
|
474
480
|
material.backFaceCulling = false;
|
|
475
481
|
const label = MeshBuilder.CreatePlane(`${node.id}.rootLabel`, {
|
|
476
|
-
width:
|
|
482
|
+
width: 1.35,
|
|
477
483
|
height: 0.34,
|
|
478
484
|
}, scene);
|
|
479
485
|
label.material = material;
|
|
@@ -482,7 +488,7 @@ function createRootLabelProjection(babylon, scene, node) {
|
|
|
482
488
|
...createProjectionMetadata(node.id, {
|
|
483
489
|
helperKind: 'root',
|
|
484
490
|
helper: 'label',
|
|
485
|
-
text:
|
|
491
|
+
text: ROOT_HELPER_LABEL,
|
|
486
492
|
}),
|
|
487
493
|
editorProjectionRuntimeObjects: [texture, material],
|
|
488
494
|
};
|
|
@@ -492,22 +498,22 @@ function createRootLabelProjection(babylon, scene, node) {
|
|
|
492
498
|
function drawRootLabelTexture(texture) {
|
|
493
499
|
const context = texture.getContext?.();
|
|
494
500
|
if (!context) {
|
|
495
|
-
texture.drawText?.(
|
|
501
|
+
texture.drawText?.(ROOT_HELPER_LABEL, null, 58, 'bold 34px sans-serif', '#f8fbff', 'transparent', true, true);
|
|
496
502
|
return;
|
|
497
503
|
}
|
|
498
|
-
context.clearRect?.(0, 0,
|
|
504
|
+
context.clearRect?.(0, 0, 384, 96);
|
|
499
505
|
context.fillStyle = 'rgba(10, 18, 28, 0.76)';
|
|
500
|
-
roundRectPath(context,
|
|
506
|
+
roundRectPath(context, 16, 18, 352, 56, 18);
|
|
501
507
|
context.fill?.();
|
|
502
508
|
context.strokeStyle = 'rgba(100, 190, 255, 0.9)';
|
|
503
509
|
context.lineWidth = 3;
|
|
504
|
-
roundRectPath(context,
|
|
510
|
+
roundRectPath(context, 16, 18, 352, 56, 18);
|
|
505
511
|
context.stroke?.();
|
|
506
512
|
context.fillStyle = '#f8fbff';
|
|
507
|
-
context.font = 'bold
|
|
513
|
+
context.font = 'bold 34px sans-serif';
|
|
508
514
|
context.textAlign = 'center';
|
|
509
515
|
context.textBaseline = 'middle';
|
|
510
|
-
context.fillText?.(
|
|
516
|
+
context.fillText?.(ROOT_HELPER_LABEL, 192, 47);
|
|
511
517
|
texture.update?.();
|
|
512
518
|
}
|
|
513
519
|
function roundRectPath(context, x, y, width, height, radius) {
|
|
@@ -612,27 +618,55 @@ function createCameraFrustumLines(babylon, scene, node, settings) {
|
|
|
612
618
|
if (!MeshBuilder?.CreateLineSystem)
|
|
613
619
|
return null;
|
|
614
620
|
const distance = Math.max(0.4, settings.radius * 0.12);
|
|
615
|
-
const
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
621
|
+
const aspect = 16 / 9;
|
|
622
|
+
const nearDistance = 0.18;
|
|
623
|
+
let lines;
|
|
624
|
+
if (settings.projection === 'perspective') {
|
|
625
|
+
const halfHeight = Math.max(0.12, Math.tan((settings.fov ?? 0.85) / 2) * distance);
|
|
626
|
+
const halfWidth = halfHeight * aspect;
|
|
627
|
+
const origin = new Vector3(0, 0, nearDistance);
|
|
628
|
+
const topLeft = new Vector3(-halfWidth, halfHeight, -distance);
|
|
629
|
+
const topRight = new Vector3(halfWidth, halfHeight, -distance);
|
|
630
|
+
const bottomRight = new Vector3(halfWidth, -halfHeight, -distance);
|
|
631
|
+
const bottomLeft = new Vector3(-halfWidth, -halfHeight, -distance);
|
|
632
|
+
lines = [
|
|
624
633
|
[topLeft, topRight, bottomRight, bottomLeft, topLeft],
|
|
625
|
-
[
|
|
626
|
-
[
|
|
627
|
-
[
|
|
628
|
-
[
|
|
629
|
-
]
|
|
634
|
+
[origin, topLeft],
|
|
635
|
+
[origin, topRight],
|
|
636
|
+
[origin, bottomRight],
|
|
637
|
+
[origin, bottomLeft],
|
|
638
|
+
];
|
|
639
|
+
}
|
|
640
|
+
else {
|
|
641
|
+
const halfHeight = Math.max(0.12, settings.orthoSize * 0.08);
|
|
642
|
+
const halfWidth = halfHeight * aspect;
|
|
643
|
+
const nearTopLeft = new Vector3(-halfWidth, halfHeight, nearDistance);
|
|
644
|
+
const nearTopRight = new Vector3(halfWidth, halfHeight, nearDistance);
|
|
645
|
+
const nearBottomRight = new Vector3(halfWidth, -halfHeight, nearDistance);
|
|
646
|
+
const nearBottomLeft = new Vector3(-halfWidth, -halfHeight, nearDistance);
|
|
647
|
+
const farTopLeft = new Vector3(-halfWidth, halfHeight, -distance);
|
|
648
|
+
const farTopRight = new Vector3(halfWidth, halfHeight, -distance);
|
|
649
|
+
const farBottomRight = new Vector3(halfWidth, -halfHeight, -distance);
|
|
650
|
+
const farBottomLeft = new Vector3(-halfWidth, -halfHeight, -distance);
|
|
651
|
+
lines = [
|
|
652
|
+
[nearTopLeft, nearTopRight, nearBottomRight, nearBottomLeft, nearTopLeft],
|
|
653
|
+
[farTopLeft, farTopRight, farBottomRight, farBottomLeft, farTopLeft],
|
|
654
|
+
[nearTopLeft, farTopLeft],
|
|
655
|
+
[nearTopRight, farTopRight],
|
|
656
|
+
[nearBottomRight, farBottomRight],
|
|
657
|
+
[nearBottomLeft, farBottomLeft],
|
|
658
|
+
];
|
|
659
|
+
}
|
|
660
|
+
const frustum = MeshBuilder.CreateLineSystem(`${node.id}.cameraFrustum`, {
|
|
661
|
+
lines,
|
|
630
662
|
}, scene);
|
|
631
663
|
frustum.color = new Color3(0.45, 0.68, 1);
|
|
632
664
|
frustum.metadata = createProjectionMetadata(node.id, {
|
|
633
665
|
runtimeKind: 'camera',
|
|
634
666
|
helper: 'frustum',
|
|
667
|
+
projection: settings.projection,
|
|
635
668
|
orthoSize: settings.orthoSize,
|
|
669
|
+
fov: settings.fov,
|
|
636
670
|
});
|
|
637
671
|
return frustum;
|
|
638
672
|
}
|
|
@@ -660,14 +694,124 @@ function createLightDirectionLines(babylon, scene, node, direction) {
|
|
|
660
694
|
});
|
|
661
695
|
return arrow;
|
|
662
696
|
}
|
|
663
|
-
function
|
|
697
|
+
export function normalizeBabylonEditorProjectionCameraSettings(settings) {
|
|
698
|
+
const targetOffset = readOptionalProjectionVec3(settings?.targetOffset);
|
|
699
|
+
const targetScreenOffset = readOptionalProjectionVec2(settings?.targetScreenOffset);
|
|
664
700
|
return {
|
|
701
|
+
projection: readProjectionCameraMode(settings?.projection),
|
|
665
702
|
alpha: readFiniteNumber(settings?.alpha, 3.9269908169872414),
|
|
666
703
|
beta: readFiniteNumber(settings?.beta, 0.8),
|
|
667
704
|
radius: Math.max(0.001, readFiniteNumber(settings?.radius, 14)),
|
|
668
705
|
orthoSize: Math.max(0.001, readFiniteNumber(settings?.orthoSize, 6)),
|
|
706
|
+
fov: Math.max(0.001, readFiniteNumber(settings?.fov, 0.85)),
|
|
707
|
+
...(targetOffset ? { targetOffset } : {}),
|
|
708
|
+
minZ: Math.max(0.001, readFiniteNumber(settings?.minZ, 1)),
|
|
709
|
+
maxZ: Math.max(0.001, readFiniteNumber(settings?.maxZ, 10000)),
|
|
710
|
+
lowerBetaLimit: readFiniteNumber(settings?.lowerBetaLimit, settings?.beta ?? 0.8),
|
|
711
|
+
upperBetaLimit: readFiniteNumber(settings?.upperBetaLimit, settings?.beta ?? 0.8),
|
|
712
|
+
lowerRadiusLimit: Math.max(0.001, readFiniteNumber(settings?.lowerRadiusLimit, settings?.radius ?? 14)),
|
|
713
|
+
upperRadiusLimit: Math.max(0.001, readFiniteNumber(settings?.upperRadiusLimit, settings?.radius ?? 14)),
|
|
714
|
+
inertia: clampUnit(readFiniteNumber(settings?.inertia, 0.9)),
|
|
715
|
+
...(targetScreenOffset ? { targetScreenOffset } : {}),
|
|
669
716
|
};
|
|
670
717
|
}
|
|
718
|
+
export function applyBabylonEditorProjectionCameraRig(babylon, scene, camera, settings, options = {}) {
|
|
719
|
+
const normalized = normalizeBabylonEditorProjectionCameraSettings(settings);
|
|
720
|
+
const Vector3 = babylon.Vector3;
|
|
721
|
+
const Vector2 = babylon.Vector2;
|
|
722
|
+
const targetInput = options.target ?? normalized.targetOffset ?? null;
|
|
723
|
+
const target = targetInput && Vector3
|
|
724
|
+
? new Vector3(targetInput.x, targetInput.y, targetInput.z)
|
|
725
|
+
: null;
|
|
726
|
+
camera.minZ = normalized.minZ ?? 1;
|
|
727
|
+
camera.maxZ = Math.max(camera.minZ + 0.001, normalized.maxZ ?? 10000);
|
|
728
|
+
camera.inertia = normalized.inertia ?? camera.inertia;
|
|
729
|
+
if (normalized.targetScreenOffset) {
|
|
730
|
+
camera.targetScreenOffset = Vector2
|
|
731
|
+
? new Vector2(normalized.targetScreenOffset.x, normalized.targetScreenOffset.y)
|
|
732
|
+
: { ...normalized.targetScreenOffset };
|
|
733
|
+
}
|
|
734
|
+
if (typeof camera.alpha === 'number') {
|
|
735
|
+
clearBabylonArcRotateCameraOrbitLimits(camera);
|
|
736
|
+
if (target)
|
|
737
|
+
camera.target = target;
|
|
738
|
+
camera.alpha = normalized.alpha;
|
|
739
|
+
camera.beta = normalized.beta;
|
|
740
|
+
camera.radius = normalized.radius;
|
|
741
|
+
if (options.lockOrbit !== false) {
|
|
742
|
+
camera.lowerAlphaLimit = normalized.alpha;
|
|
743
|
+
camera.upperAlphaLimit = normalized.alpha;
|
|
744
|
+
camera.lowerBetaLimit = normalized.lowerBetaLimit ?? normalized.beta;
|
|
745
|
+
camera.upperBetaLimit = normalized.upperBetaLimit ?? normalized.beta;
|
|
746
|
+
camera.lowerRadiusLimit = normalized.lowerRadiusLimit ?? normalized.radius;
|
|
747
|
+
camera.upperRadiusLimit = normalized.upperRadiusLimit ?? normalized.radius;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
else if (target) {
|
|
751
|
+
camera.setTarget?.(target);
|
|
752
|
+
}
|
|
753
|
+
if (normalized.projection === 'perspective') {
|
|
754
|
+
camera.mode = babylon.Camera?.PERSPECTIVE_CAMERA ?? 0;
|
|
755
|
+
camera.fov = normalized.fov ?? 0.85;
|
|
756
|
+
return normalized;
|
|
757
|
+
}
|
|
758
|
+
camera.mode = babylon.Camera?.ORTHOGRAPHIC_CAMERA ?? 1;
|
|
759
|
+
const aspect = readProjectionSceneAspect(scene);
|
|
760
|
+
const halfHeight = normalized.orthoSize;
|
|
761
|
+
const halfWidth = halfHeight * aspect;
|
|
762
|
+
camera.orthoLeft = -halfWidth;
|
|
763
|
+
camera.orthoRight = halfWidth;
|
|
764
|
+
camera.orthoTop = halfHeight;
|
|
765
|
+
camera.orthoBottom = -halfHeight;
|
|
766
|
+
return normalized;
|
|
767
|
+
}
|
|
768
|
+
function clearBabylonArcRotateCameraOrbitLimits(camera) {
|
|
769
|
+
camera.lowerAlphaLimit = null;
|
|
770
|
+
camera.upperAlphaLimit = null;
|
|
771
|
+
camera.lowerBetaLimit = null;
|
|
772
|
+
camera.upperBetaLimit = null;
|
|
773
|
+
camera.lowerRadiusLimit = null;
|
|
774
|
+
camera.upperRadiusLimit = null;
|
|
775
|
+
}
|
|
776
|
+
function readProjectionCameraMode(value) {
|
|
777
|
+
return value === 'perspective' ? 'perspective' : 'orthographic';
|
|
778
|
+
}
|
|
779
|
+
function readProjectionSceneAspect(scene) {
|
|
780
|
+
const engine = scene.getEngine?.();
|
|
781
|
+
const width = Number(engine?.getRenderWidth?.() ?? engine?.getRenderingCanvas?.()?.width ?? 1);
|
|
782
|
+
const height = Number(engine?.getRenderHeight?.() ?? engine?.getRenderingCanvas?.()?.height ?? 1);
|
|
783
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || height <= 0)
|
|
784
|
+
return 16 / 9;
|
|
785
|
+
return Math.max(0.01, width / height);
|
|
786
|
+
}
|
|
787
|
+
function readOptionalProjectionVec2(value) {
|
|
788
|
+
if (!value || typeof value !== 'object')
|
|
789
|
+
return null;
|
|
790
|
+
const candidate = value;
|
|
791
|
+
if (!Number.isFinite(candidate.x) || !Number.isFinite(candidate.y))
|
|
792
|
+
return null;
|
|
793
|
+
return {
|
|
794
|
+
x: Number(candidate.x),
|
|
795
|
+
y: Number(candidate.y),
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
function readOptionalProjectionVec3(value) {
|
|
799
|
+
if (!value || typeof value !== 'object')
|
|
800
|
+
return null;
|
|
801
|
+
const candidate = value;
|
|
802
|
+
if (!Number.isFinite(candidate.x) || !Number.isFinite(candidate.y) || !Number.isFinite(candidate.z))
|
|
803
|
+
return null;
|
|
804
|
+
return {
|
|
805
|
+
x: Number(candidate.x),
|
|
806
|
+
y: Number(candidate.y),
|
|
807
|
+
z: Number(candidate.z),
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
function clampUnit(value) {
|
|
811
|
+
if (!Number.isFinite(value))
|
|
812
|
+
return 0;
|
|
813
|
+
return Math.min(1, Math.max(0, value));
|
|
814
|
+
}
|
|
671
815
|
function readProjectionDirectionalLightSettings(settings) {
|
|
672
816
|
return {
|
|
673
817
|
type: 'directional',
|