move MaterialInstance methods to own class
This commit is contained in:
@@ -1211,15 +1211,6 @@ external void remove_stencil_highlight(
|
||||
int entity,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Pointer<TMaterialInstance> Function(
|
||||
ffi.Pointer<ffi.Void>, EntityId, ffi.Int)>(isLeaf: true)
|
||||
external ffi.Pointer<TMaterialInstance> get_material_instance_at(
|
||||
ffi.Pointer<ffi.Void> sceneManager,
|
||||
int entity,
|
||||
int materialIndex,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<ffi.Void>, EntityId, ffi.Int,
|
||||
ffi.Pointer<ffi.Char>, ffi.Float)>(isLeaf: true)
|
||||
@@ -1311,6 +1302,29 @@ external void apply_texture_to_material(
|
||||
int materialIndex,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Pointer<TMaterialInstance> Function(
|
||||
ffi.Pointer<ffi.Void>, EntityId, ffi.Int)>(isLeaf: true)
|
||||
external ffi.Pointer<TMaterialInstance> get_material_instance_at(
|
||||
ffi.Pointer<ffi.Void> sceneManager,
|
||||
int entity,
|
||||
int materialIndex,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Bool)>(
|
||||
isLeaf: true)
|
||||
external void MaterialInstance_setDepthWrite(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
bool enabled,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TMaterialInstance>, ffi.Bool)>(
|
||||
isLeaf: true)
|
||||
external void MaterialInstance_setDepthCulling(
|
||||
ffi.Pointer<TMaterialInstance> materialInstance,
|
||||
bool enabled,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<ffi.Void>,
|
||||
|
||||
@@ -1982,15 +1982,6 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
allocator.free(ptr);
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future setMaterialDepthWrite(
|
||||
ThermionEntity entity, int materialIndex, bool enabled) {
|
||||
set_material_depth_write(_sceneManager!, entity, materialIndex, enabled);
|
||||
return Future.value();
|
||||
}
|
||||
|
||||
Future<Uint8List> unproject(ThermionEntity entity, Uint8List input,
|
||||
int inputWidth, int inputHeight, int outWidth, int outHeight) async {
|
||||
final outPtr = Uint8List(outWidth * outHeight * 4);
|
||||
@@ -2132,6 +2123,18 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
allocator.free(ptr);
|
||||
return Future.value();
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future<MaterialInstance?> getMaterialInstanceAt(
|
||||
ThermionEntity entity, int index) async {
|
||||
final instance = get_material_instance_at(_sceneManager!, entity, index);
|
||||
if (instance == nullptr) {
|
||||
return null;
|
||||
}
|
||||
return ThermionFFIMaterialInstance(instance);
|
||||
}
|
||||
}
|
||||
|
||||
class ThermionFFITexture extends ThermionTexture {
|
||||
@@ -2144,4 +2147,14 @@ class ThermionFFIMaterialInstance extends MaterialInstance {
|
||||
final Pointer<TMaterialInstance> _pointer;
|
||||
|
||||
ThermionFFIMaterialInstance(this._pointer);
|
||||
|
||||
@override
|
||||
Future setDepthCullingEnabled(bool enabled) async {
|
||||
MaterialInstance_setDepthCulling(this._pointer, enabled);
|
||||
}
|
||||
|
||||
@override
|
||||
Future setDepthWriteEnabled(bool enabled) async {
|
||||
MaterialInstance_setDepthWrite(this._pointer, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
abstract class MaterialInstance {
|
||||
|
||||
Future setDepthWriteEnabled(bool enabled);
|
||||
Future setDepthCullingEnabled(bool enabled);
|
||||
}
|
||||
|
||||
enum AlphaMode {
|
||||
OPAQUE,
|
||||
MASK,
|
||||
BLEND
|
||||
}
|
||||
enum AlphaMode { OPAQUE, MASK, BLEND }
|
||||
|
||||
@@ -599,13 +599,6 @@ abstract class ThermionViewer {
|
||||
Future setMaterialPropertyInt(
|
||||
ThermionEntity entity, String propertyName, int materialIndex, int value);
|
||||
|
||||
///
|
||||
/// Sets the depthWrite material instance at [materialIndex] for [entity] to [enabled].
|
||||
/// [entity] must have a Renderable attached.
|
||||
///
|
||||
Future setMaterialDepthWrite(
|
||||
ThermionEntity entity, int materialIndex, bool enabled);
|
||||
|
||||
///
|
||||
/// Scale [entity] to fit within the unit cube.
|
||||
///
|
||||
@@ -858,7 +851,7 @@ abstract class ThermionViewer {
|
||||
|
||||
///
|
||||
/// Assigns [entity] to visibility layer [layer].
|
||||
///
|
||||
///
|
||||
Future setVisibilityLayer(ThermionEntity entity, int layer);
|
||||
|
||||
///
|
||||
@@ -944,4 +937,10 @@ abstract class ThermionViewer {
|
||||
///
|
||||
///
|
||||
Future<MaterialInstance> createUnlitMaterialInstance();
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future<MaterialInstance?> getMaterialInstanceAt(
|
||||
ThermionEntity entity, int index);
|
||||
}
|
||||
|
||||
@@ -928,6 +928,30 @@ class ThermionViewerStub extends ThermionViewer {
|
||||
// TODO: implement setMaterialPropertyInt
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MaterialInstance?> getMaterialInstanceAt(ThermionEntity entity, int index) {
|
||||
// TODO: implement getMaterialInstanceAt
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future setLayerVisibility(int layer, bool visible) {
|
||||
// TODO: implement setLayerVisibility
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future setMaterialDepthWrite(ThermionEntity entity, int materialIndex, bool enabled) {
|
||||
// TODO: implement setMaterialDepthWrite
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future setVisibilityLayer(ThermionEntity entity, int layer) {
|
||||
// TODO: implement setVisibilityLayer
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2186,7 +2186,7 @@ class ThermionViewerWasm implements ThermionViewer {
|
||||
@override
|
||||
Future setLayerEnabled(int layer, bool enabled) async {
|
||||
_module!.ccall(
|
||||
"set_layer_enabled",
|
||||
"set_layer_visibility",
|
||||
"void",
|
||||
[
|
||||
"void*".toJS,
|
||||
|
||||
Reference in New Issue
Block a user