I am struggling to render a sphere in the correct position relative to a tree, with a scene generated using bpy:
import os
import bpy
# remove default square
bpy.ops.object.delete(use_global=False, confirm=False)
bpy.ops.outliner.orphans_purge(do_local_ids=True, do_linked_ids=True, do_recursive=True)
# tree
tree_params = { "do_update": True, "bevel": True, "prune": False, "showLeaves": True, "useArm": False, "seed": 0, "handleType": '1', "levels": 3, "length": (0.8, 0.6, 0.5, 0.1), "lengthV": (0, 0.1, 0, 0), "taperCrown": 0.5, "branches": (0, 55, 10, 1), "curveRes": (8, 5, 3, 1), "curve": (0, -15, 0, 0), "curveV": (20, 50, 75, 0), "curveBack": (0, 0, 0, 0), "baseSplits": 3, "segSplits": (0.1, 0.5, 0.2, 0), "splitByLen": True, "rMode": 'rotate', "splitAngle": (18, 18, 22, 0), "splitAngleV": (5, 5, 5, 0), "scale": 5, "scaleV": 2, "attractUp": (3.5, -1.89984, 0, 0), "attractOut": (0, 0.8, 0, 0), "shape": '7', "shapeS": '10', "customShape": (0.5, 1, 0.3, 0.5), "branchDist": 1.5, "nrings": 0, "baseSize": 0.3, "baseSize_s": 0.16, "splitHeight": 0.2, "splitBias": 0.55, "ratio": 0.015, "minRadius": 0.0015, "closeTip": False, "rootFlare": 1, "autoTaper": True, "taper": (1, 1, 1, 1), "radiusTweak": (1, 1, 1, 1), "ratioPower": 1.2, "downAngle": (0, 26.21, 52.56, 30), "downAngleV": (0, 10, 10, 10), "useOldDownAngle": True, "useParentAngle": True, "rotate": (99.5, 137.5, 137.5, 137.5), "rotateV": (15, 0, 0, 0),}
bpy.ops.curve.tree_add(**tree_params)
# sphere
bpy.ops.mesh.primitive_uv_sphere_add(radius=0.1, location=(10,10,10))
sphere = bpy.context.active_object
material = bpy.data.materials.new(name="Sphere_Material")
sphere.data.materials.append(material)
#export
output_path = os.path.join(os.getcwd(), 'tree_scene.glb')
bpy.ops.export_scene.gltf(filepath=output_path, export_format='GLB')
visualising this using https://gltf-viewer.donmccurdy.com/ produces the correct result:
Rendering this using pyrender using the following code:
from pyrender import Mesh, Scene, Viewer
import trimesh
glb_file_path = "tree_scene.glb"
tree_scene = trimesh.load(glb_file_path, file_type='glb')
tree_trimesh_geometry_list = list(tree_scene.geometry.values())
tree_mesh = Mesh.from_trimesh(tree_trimesh_geometry_list)
scene = Scene(ambient_light=[1.0, 0.2, 0.3])
scene.add(tree_mesh)
Viewer(scene)
shows the sphere at the origin (base of the tree):
Why is there this difference and how can I correct the render in pyrender?