This is a breaking change needed to fully implement instancing and stencil highlighting.
Previously, users would work directly with entities (on the Dart side, ThermionEntity), e.g.
final entity = await viewer.loadGlb("some.glb");
However, Filament "entities" are a lower-level abstraction.
Loading a glTF file, for example, inserts multiple entities into the scene.
For example, each mesh, light, and camera within a glTF asset will be assigned an entity. A top-level (non-renderable) entity will also be created for the glTF asset, which can be used to transform the entire hierarchy.
"Asset" is a better representation for loading/inserting objects into the scene; think of this as a bundle of entities.
Unless you need to work directly with transforms, instancing, materials and renderables, you can work directly with ThermionAsset.
49 lines
1.0 KiB
C++
49 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
#include <utils/Entity.h>
|
|
#include <filament/Engine.h>
|
|
#include <filament/Material.h>
|
|
#include <filament/MaterialInstance.h>
|
|
#include <filament/Scene.h>
|
|
#include <filament/Camera.h>
|
|
#include <filament/View.h>
|
|
#include <filament/Viewport.h>
|
|
|
|
#include <gltfio/AssetLoader.h>
|
|
#include <gltfio/FilamentAsset.h>
|
|
#include <gltfio/FilamentInstance.h>
|
|
#include <gltfio/ResourceLoader.h>
|
|
|
|
#include <filament/IndexBuffer.h>
|
|
#include <filament/InstanceBuffer.h>
|
|
|
|
namespace thermion {
|
|
|
|
using namespace filament;
|
|
using namespace utils;
|
|
|
|
class GridOverlay {
|
|
public:
|
|
GridOverlay(Engine& engine);
|
|
void destroy();
|
|
|
|
utils::Entity sphere() {
|
|
return _sphereEntity;
|
|
}
|
|
|
|
utils::Entity grid() {
|
|
return _gridEntity;
|
|
}
|
|
|
|
private:
|
|
Engine &_engine;
|
|
utils::Entity _gridEntity;
|
|
utils::Entity _sphereEntity;
|
|
Material* _material;
|
|
MaterialInstance* _materialInstance;
|
|
MaterialInstance* _sphereMaterialInstance;
|
|
};
|
|
|
|
} |