SceneObject constructor
SceneObject({})
Implementation
SceneObject({
Vector3? position,
Vector3? rotation,
Vector3? scale,
this.name,
Mesh? mesh,
Scene? scene,
this.parent,
List<SceneObject>? children,
this.backfaceCulling = true,
this.lighting = false,
this.visiable = true,
bool normalized = true,
String? fileName,
bool isAsset = true,
}) {
if (position != null) position.copyInto(this.position);
if (rotation != null) rotation.copyInto(this.rotation);
if (scale != null) scale.copyInto(this.scale);
updateTransform();
this.mesh = mesh ?? Mesh();
this.children = children ?? <SceneObject>[];
for (SceneObject child in this.children) {
child.parent = this;
}
this.scene = scene;
// load mesh from obj file
if (fileName != null) {
loadObj(fileName, normalized, isAsset: isAsset).then((List<Mesh> meshes) {
if (meshes.length == 1) {
this.mesh = meshes[0];
} else if (meshes.length > 1) {
// multiple objects
for (Mesh mesh in meshes) {
add(SceneObject(
name: mesh.name,
mesh: mesh,
backfaceCulling: backfaceCulling,
lighting: lighting));
}
}
this.scene?.objectCreated(this);
});
} else {
this.scene?.objectCreated(this);
}
}