@volter/blender-engine 0.1.35 → 0.1.36
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/browser/session.py
CHANGED
|
@@ -760,13 +760,17 @@ def _empty_display(obj):
|
|
|
760
760
|
|
|
761
761
|
|
|
762
762
|
def _saved_view():
|
|
763
|
-
"""The 3D View the file saved, which is where Blender opens it: the
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
`
|
|
763
|
+
"""The 3D View the file saved, which is where Blender opens it: the one on the screen the
|
|
764
|
+
file's window was showing when it was saved (Blender reopens that workspace; a stock file's is
|
|
765
|
+
`Layout`), else the `Modeling` workspace's (this editor's Model workspace is Blender's
|
|
766
|
+
Modeling), else the first 3D View any screen holds. `RegionView3D`'s pivot, rotation (view to
|
|
767
|
+
world, `(w, x, y, z)`), distance and projection (`PERSP`, `ORTHO`, or `CAMERA` for a view
|
|
768
|
+
through the scene camera), the `View3D`'s lens, and its SHADING TYPE, which Blender reopens
|
|
769
|
+
with the view: a file saved in Material Preview opens in Material Preview."""
|
|
770
|
+
screens = [window.screen for wm in bpy.data.window_managers for window in wm.windows
|
|
771
|
+
if window.screen is not None]
|
|
768
772
|
workspace = bpy.data.workspaces.get("Modeling")
|
|
769
|
-
screens
|
|
773
|
+
screens.extend(workspace.screens if workspace is not None else [])
|
|
770
774
|
screens.extend(bpy.data.screens)
|
|
771
775
|
for screen in screens:
|
|
772
776
|
for area in screen.areas:
|
|
@@ -780,6 +784,7 @@ def _saved_view():
|
|
|
780
784
|
"rotation": [float(v) for v in region.view_rotation],
|
|
781
785
|
"distance": float(region.view_distance),
|
|
782
786
|
"perspective": region.view_perspective,
|
|
787
|
+
"shading": space.shading.type,
|
|
783
788
|
}
|
|
784
789
|
return None
|
|
785
790
|
|
|
@@ -43,6 +43,13 @@ import {
|
|
|
43
43
|
} from './blender-runtime-camera-view';
|
|
44
44
|
import { DEFAULT_VIEWPORT_DISPLAY, workbenchMaterial } from './blender-workbench-material';
|
|
45
45
|
|
|
46
|
+
/** A saved `View3DShading.type` as the stage's draw mode: Material Preview is `preview`. */
|
|
47
|
+
const SAVED_SHADING = {
|
|
48
|
+
WIREFRAME: 'wireframe',
|
|
49
|
+
SOLID: 'solid',
|
|
50
|
+
MATERIAL: 'preview',
|
|
51
|
+
RENDERED: 'rendered',
|
|
52
|
+
} as const;
|
|
46
53
|
const scalar = z.number().finite();
|
|
47
54
|
const point = z.tuple([scalar, scalar, scalar]);
|
|
48
55
|
const edge = z.tuple([z.number().int().nonnegative(), z.number().int().nonnegative()]);
|
|
@@ -547,6 +554,7 @@ export const frameSchema = z
|
|
|
547
554
|
distance: z.number().finite(),
|
|
548
555
|
perspective: z.enum(['PERSP', 'ORTHO', 'CAMERA']),
|
|
549
556
|
lens: z.number().finite().positive().default(50),
|
|
557
|
+
shading: z.enum(['WIREFRAME', 'SOLID', 'MATERIAL', 'RENDERED']).optional(),
|
|
550
558
|
})
|
|
551
559
|
.nullable()
|
|
552
560
|
.optional(),
|
|
@@ -831,8 +839,9 @@ export class BlenderRuntimeView {
|
|
|
831
839
|
* direction from the pivot to the eye (the view's +Z, `view_rotation` turning view space into
|
|
832
840
|
* the world: RNA's inverse of `viewquat`), the screen's up (the view's +Y), the distance and
|
|
833
841
|
* the projection. A view saved through the scene camera opens in perspective along the same
|
|
834
|
-
* axis: looking through a camera is not a view this stage has.
|
|
835
|
-
*
|
|
842
|
+
* axis: looking through a camera is not a view this stage has. With it the view's SHADING, the
|
|
843
|
+
* draw mode Blender reopens it in (null from a file whose view carried none). Null before a
|
|
844
|
+
* frame or when the file saved no 3D View.
|
|
836
845
|
*/
|
|
837
846
|
savedView(): {
|
|
838
847
|
readonly target: readonly [number, number, number];
|
|
@@ -841,6 +850,7 @@ export class BlenderRuntimeView {
|
|
|
841
850
|
readonly distance: number;
|
|
842
851
|
readonly projection: 'perspective' | 'orthographic';
|
|
843
852
|
readonly lens: number;
|
|
853
|
+
readonly drawMode: 'wireframe' | 'solid' | 'preview' | 'rendered' | null;
|
|
844
854
|
} | null {
|
|
845
855
|
const saved = this.frame?.view;
|
|
846
856
|
if (!saved) return null;
|
|
@@ -855,6 +865,7 @@ export class BlenderRuntimeView {
|
|
|
855
865
|
distance: saved.distance,
|
|
856
866
|
projection: saved.perspective === 'ORTHO' ? 'orthographic' : 'perspective',
|
|
857
867
|
lens: saved.lens,
|
|
868
|
+
drawMode: saved.shading ? SAVED_SHADING[saved.shading] : null,
|
|
858
869
|
};
|
|
859
870
|
}
|
|
860
871
|
|