Object constructor
Object({})
Implementation
Object({
Vector3? position,
Vector3? rotation,
Vector3? scale,
this.name,
Mesh? mesh,
Scene? scene,
this.parent,
List<Object>? 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 ?? <Object>[];
for (Object 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(Object(name: mesh.name, mesh: mesh, backfaceCulling: backfaceCulling, lighting: lighting));
}
}
this.scene?.objectCreated(this);
});
} else {
this.scene?.objectCreated(this);
}
}