Rebuild local Blender WASM environment and recovery evidence
This commit is contained in:
46
tools/web/generated/WBV2-P4-004.py
Normal file
46
tools/web/generated/WBV2-P4-004.py
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def cube(name, location):
|
||||
bpy.ops.mesh.primitive_cube_add(size=2, location=location)
|
||||
obj = bpy.context.object
|
||||
obj.name = name
|
||||
obj.data.name = f"{name}Mesh"
|
||||
return obj
|
||||
|
||||
|
||||
def main(output):
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
scene = bpy.context.scene
|
||||
scene.name = "WBV2P4004SimulationScene"
|
||||
scene.frame_start = 1
|
||||
scene.frame_end = 4
|
||||
scene.frame_set(1)
|
||||
floor = cube("WBV2P4004Collision", (0, 0, -1.5))
|
||||
bpy.context.view_layer.objects.active = floor
|
||||
bpy.ops.rigidbody.object_add()
|
||||
floor.rigid_body.type = "PASSIVE"
|
||||
floor.rigid_body.collision_shape = "BOX"
|
||||
body = cube("WBV2P4004RigidBody", (0, 0, 1.0))
|
||||
bpy.context.view_layer.objects.active = body
|
||||
bpy.ops.rigidbody.object_add()
|
||||
body.rigid_body.type = "ACTIVE"
|
||||
body.rigid_body.mass = 2.5
|
||||
body.rigid_body.friction = 0.35
|
||||
body.rigid_body.restitution = 0.2
|
||||
body.rigid_body.linear_damping = 0.04
|
||||
body.rigid_body.angular_damping = 0.1
|
||||
body.rigid_body.collision_shape = "BOX"
|
||||
bpy.context.scene.frame_set(1)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=str(pathlib.Path(output).resolve()), check_existing=False, compress=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
arguments = sys.argv[sys.argv.index("--") + 1:]
|
||||
if len(arguments) != 1:
|
||||
raise SystemExit("usage: blender -b --factory-startup --python WBV2-P4-004.py -- OUTPUT")
|
||||
main(arguments[0])
|
||||
Reference in New Issue
Block a user