@@ -43,54 +43,52 @@ run_action.SetLoop(impeller::scene::AnimationAction::kLoopForever);
4343run_action.SetWeight(0.3f);
4444run_action.Play();
4545
46- scene.Add (
46+ scene.GetRoot().AddChild (
4747 impeller::scene::DirectionalLight(
4848 /* color * / impeller::Color::AntiqueWhite(),
4949 /* intensity * / 5,
5050 /* direction * / {2, 3, 4}));
5151
52- impeller::scene::StaticMeshEntity sphere_entity;
53- sphere_entity.SetGlobalTransform(
52+ Node sphere_node;
53+ Mesh sphere_mesh;
54+ sphere_node.SetGlobalTransform(
5455 Matrix::MakeRotationEuler({kPiOver4, kPiOver4, 0}));
55- sphere_entity.SetCullingMode(impeller::scene::CullingMode::kFrustum);
5656
57- std::unique_ptr < impeller::scene::SphereGeometry > sphere =
57+ auto sphere_geometry =
5858 impeller::scene::Geometry::MakeSphere(allocator, /* radius * / 2);
5959
60- sphere_entity.SetGeometry(sphere);
61-
6260auto material = impeller::scene::Material::MakeStandard();
63- material. SetAlbedo(impeller::Color::Red());
64- material. SetRoughness(0.4);
65- material. SetMetallic(0.2);
61+ material-> SetAlbedo(impeller::Color::Red());
62+ material-> SetRoughness(0.4);
63+ material-> SetMetallic(0.2);
6664// Common properties shared by all materials.
67- material. SetEnvironmentMap(environment_hdri);
68- material. SetFlatShaded(true);
69- material. SetBlendConfig({
65+ material-> SetEnvironmentMap(environment_hdri);
66+ material-> SetFlatShaded(true);
67+ material-> SetBlendConfig({
7068 impeller::BlendOperation::kAdd, // color_op
7169 impeller::BlendFactor::kOne, // source_color_factor
7270 impeller::BlendFactor::kOneMinusSourceAlpha, // destination_color_factor
7371 impeller::BlendOperation::kAdd, // alpha_op
7472 impeller::BlendFactor::kOne, // source_alpha_factor
7573 impeller::BlendFactor::kOneMinusSourceAlpha, // destination_alpha_factor
7674});
77- material. SetStencilConfig({
75+ material-> SetStencilConfig({
7876 impeller::StencilOperation::kIncrementClamp, // operation
7977 impeller::CompareFunction::kAlways, // compare
8078});
81-
82- sphere_entity->SetMaterials({material} );
83-
84-
85- impeller::scene::StaticMeshEntity cube_entity ;
86- cube_entity.GetGeometry(
87- impeller::scene::Geometry::MakeCube(allocator, {4, 4, 4}));
88- cube_entity.SetMaterials({material });
89-
90- cube_entity.SetLocalTransform(Matrix::MakeTranslation({4, 0, 0}) );
91-
92- sphere_entity->Add(sube_entity );
93- scene.Add(sphere_entity );
79+ sphere_mesh.AddPrimitive({sphere_geometry, material});
80+ sphere_node.SetMesh(sphere_mesh );
81+
82+ Node cube_node;
83+ cube_node.SetLocalTransform(Matrix::MakeTranslation({4, 0, 0})) ;
84+ Mesh cube_mesh;
85+ auto cube_geometry = impeller::scene::Geometry::MakeCuboid(
86+ allocator, {4, 4, 4 });
87+ cube_mesh.AddPrimitive({cube_geometry, material});
88+ cube_node.SetMesh(cube_mesh );
89+
90+ sphere_node.AddChild(cube_node );
91+ scene.GetRoot().AddChild(sphere_node );
9492
9593/// Post processing.
9694
0 commit comments