@volter/blender-engine 0.1.36 → 0.1.37
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/protocol.ts
CHANGED
|
@@ -76,6 +76,9 @@ export type WorkerRequest =
|
|
|
76
76
|
/** ONE RESTRICTION COLUMN, written (`session.py`'s `outliner_set`). A column
|
|
77
77
|
* Blender draws on no row of that type is refused by name. */
|
|
78
78
|
| { id: number; op: 'outliner-set'; path: string; column: string; value: boolean }
|
|
79
|
+
/** A person's shading pick, kept in the file's own 3D View (`session.py`'s `_view_shading`);
|
|
80
|
+
* UI state, so it marks nothing changed and rides the next save. */
|
|
81
|
+
| { id: number; op: 'view-shading'; shading: 'WIREFRAME' | 'SOLID' | 'MATERIAL' | 'RENDERED' }
|
|
79
82
|
| { id: number; op: 'read-file'; path: string }
|
|
80
83
|
| { id: number; op: 'write-file'; path: string; bytes: Uint8Array }
|
|
81
84
|
| { id: number; op: 'list-files'; path: string }
|
package/browser/runtime.ts
CHANGED
|
@@ -318,6 +318,12 @@ export class BlenderRuntime {
|
|
|
318
318
|
})) as BlenderRnaWrite;
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
+
/** Keep a person's shading pick in the file's own 3D View, as UI state (no save of its own). */
|
|
322
|
+
async viewShading(shading: 'WIREFRAME' | 'SOLID' | 'MATERIAL' | 'RENDERED'): Promise<void> {
|
|
323
|
+
await this.#ready();
|
|
324
|
+
await this.#request({ op: 'view-shading', shading });
|
|
325
|
+
}
|
|
326
|
+
|
|
321
327
|
/** BLENDER'S VIEW LAYER TREE for the scene — what its Outliner shows, as
|
|
322
328
|
* rows (`./rna.ts`, `BlenderOutlinerTree`). `selected` is our viewport's
|
|
323
329
|
* selection by object name; reading it never writes the engine's. */
|
package/browser/session.py
CHANGED
|
@@ -789,6 +789,23 @@ def _saved_view():
|
|
|
789
789
|
return None
|
|
790
790
|
|
|
791
791
|
|
|
792
|
+
def _view_shading(shading):
|
|
793
|
+
"""A person's shading pick, written where Blender keeps it: the `View3DShading.type` of the 3D
|
|
794
|
+
View `_saved_view` reads. UI STATE, NOT THE MODEL: nothing is marked changed, so it rides the
|
|
795
|
+
next save the model's own edits make, as a shading change in Blender is kept only by a save."""
|
|
796
|
+
screens = [window.screen for wm in bpy.data.window_managers for window in wm.windows
|
|
797
|
+
if window.screen is not None]
|
|
798
|
+
workspace = bpy.data.workspaces.get("Modeling")
|
|
799
|
+
screens.extend(workspace.screens if workspace is not None else [])
|
|
800
|
+
screens.extend(bpy.data.screens)
|
|
801
|
+
for screen in screens:
|
|
802
|
+
for area in screen.areas:
|
|
803
|
+
if area.type == "VIEW_3D":
|
|
804
|
+
area.spaces[0].shading.type = shading
|
|
805
|
+
return {"shading": area.spaces[0].shading.type}
|
|
806
|
+
return {"shading": None}
|
|
807
|
+
|
|
808
|
+
|
|
792
809
|
def _subject_line(scene, view_layer):
|
|
793
810
|
"""The 3D Viewport's second overlay line, as `draw_selected_name` (`view3d_draw.cc`) writes it,
|
|
794
811
|
less the two parts that follow the playhead: the tab draws `(frame)` and the marker on it
|
|
@@ -5002,6 +5019,8 @@ def _dispatch(request):
|
|
|
5002
5019
|
_say("@@VOLTER-ERROR the present after this call failed, so the Model document is "
|
|
5003
5020
|
"showing the state before it: " + repr(thrown))
|
|
5004
5021
|
return answer
|
|
5022
|
+
if op == "view-shading":
|
|
5023
|
+
return _view_shading(request["shading"])
|
|
5005
5024
|
if op == "rna-set":
|
|
5006
5025
|
SESSION.mark_changed()
|
|
5007
5026
|
answer = rna_set(request["path"], request["property"], request["value"],
|
|
@@ -843,6 +843,10 @@ export class BlenderRuntimeView {
|
|
|
843
843
|
* draw mode Blender reopens it in (null from a file whose view carried none). Null before a
|
|
844
844
|
* frame or when the file saved no 3D View.
|
|
845
845
|
*/
|
|
846
|
+
noteSavedShading(shading: keyof typeof SAVED_SHADING): void {
|
|
847
|
+
if (this.frame?.view) this.frame.view.shading = shading;
|
|
848
|
+
}
|
|
849
|
+
|
|
846
850
|
savedView(): {
|
|
847
851
|
readonly target: readonly [number, number, number];
|
|
848
852
|
readonly direction: readonly [number, number, number];
|
package/browser/worker.ts
CHANGED
|
@@ -508,6 +508,8 @@ async function handle(request: WorkerRequest): Promise<unknown> {
|
|
|
508
508
|
...(request.object === undefined ? {} : { object: request.object }),
|
|
509
509
|
...(request.collection === undefined ? {} : { collection: request.collection }),
|
|
510
510
|
});
|
|
511
|
+
case 'view-shading':
|
|
512
|
+
return ask({ op: 'view-shading', shading: request.shading });
|
|
511
513
|
case 'rna-set':
|
|
512
514
|
return ask({
|
|
513
515
|
op: 'rna-set',
|