Importing Mesh
Main mesh format is GLTF.
First, make sure you have the following systems configured:
ShadedGeometrySystem
SGMeshSystem
TransformAttachmentSystem
import { TransformAttachmentSystem } from "@woosh/meep-engine/src/engine/ecs/transform-attachment/TransformAttachmentSystem";
import { SGMeshSystem } from "@woosh/meep-engine/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem";
import { ShadedGeometrySystem } from "@woosh/meep-engine/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem";
const engine: Engine; // our engine instance
engine.entityManager.addSystem(new ShadedGeometrySystem(engine));
engine.entityManager.addSystem(new SGMeshSystem(engine));
engine.entityManager.addSystem(new TransformAttachmentSystem());
To import a mesh, we create an entity with a Transform
component, the actual mesh will be referenced via SGMesh
component.
import Entity from "@woosh/meep-engine/src/engine/ecs/Entity";
import {SGMesh} from "@woosh/meep-engine/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh";
new Entity()
.add(new Transform())
.add(SGMesh.fromURL('path/to/model.gltf'))
.build(engine.entityManager.dataset); // Build the entity