renaming to Thermion
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import 'package:vector_math/vector_math_64.dart' as v;
|
||||
|
||||
class CameraOrientation {
|
||||
v.Vector3 position = v.Vector3(0, 0, 0);
|
||||
|
||||
var rotationX = 0.0;
|
||||
var rotationY = 0.0;
|
||||
var rotationZ = 0.0;
|
||||
|
||||
v.Quaternion compose() {
|
||||
return v.Quaternion.axisAngle(v.Vector3(0, 0, 1), rotationZ) *
|
||||
v.Quaternion.axisAngle(v.Vector3(0, 1, 0), rotationY) *
|
||||
v.Quaternion.axisAngle(v.Vector3(1, 0, 0), rotationX);
|
||||
}
|
||||
}
|
||||
28
thermion_dart/lib/thermion_dart/utils/dart_resources.dart
Normal file
28
thermion_dart/lib/thermion_dart/utils/dart_resources.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import '../compatibility/compatibility.dart';
|
||||
import 'package:ffi/ffi.dart' hide Utf8Pointer;
|
||||
|
||||
class DartResourceLoader {
|
||||
static final _assets = <int, Pointer>{};
|
||||
static void loadResource(Pointer<Char> uri, Pointer<ResourceBuffer> out) {
|
||||
try {
|
||||
var data = File(uri.cast<Utf8>().toDartString().replaceAll("file://", ""))
|
||||
.readAsBytesSync();
|
||||
var ptr = calloc<Uint8>(data.lengthInBytes);
|
||||
ptr.asTypedList(data.lengthInBytes).setRange(0, data.lengthInBytes, data);
|
||||
|
||||
out.ref.data = ptr.cast<Void>();
|
||||
out.ref.size = data.lengthInBytes;
|
||||
out.ref.id = _assets.length;
|
||||
_assets[out.ref.id] = ptr;
|
||||
} catch (err) {
|
||||
print(err);
|
||||
out.ref.size = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void freeResource(ResourceBuffer rb) {
|
||||
calloc.free(_assets[rb.id]!);
|
||||
}
|
||||
}
|
||||
29
thermion_dart/lib/thermion_dart/utils/light_options.dart
Normal file
29
thermion_dart/lib/thermion_dart/utils/light_options.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:vector_math/vector_math_64.dart' as v;
|
||||
|
||||
class LightOptions {
|
||||
String? iblPath;
|
||||
double iblIntensity;
|
||||
int directionalType;
|
||||
double directionalColor;
|
||||
double directionalIntensity;
|
||||
bool directionalCastShadows;
|
||||
late v.Vector3 directionalPosition;
|
||||
late v.Vector3 directionalDirection;
|
||||
|
||||
LightOptions(
|
||||
{required this.iblPath,
|
||||
required this.iblIntensity,
|
||||
required this.directionalType,
|
||||
required this.directionalColor,
|
||||
required this.directionalIntensity,
|
||||
required this.directionalCastShadows,
|
||||
v.Vector3? directionalDirection,
|
||||
v.Vector3? directionalPosition}) {
|
||||
this.directionalDirection = directionalDirection == null
|
||||
? v.Vector3(0, -1, 0)
|
||||
: directionalDirection;
|
||||
this.directionalPosition = directionalPosition == null
|
||||
? v.Vector3(0, 100, 0)
|
||||
: directionalPosition;
|
||||
}
|
||||
}
|
||||
10
thermion_dart/lib/thermion_dart/utils/using_pointer.dart
Normal file
10
thermion_dart/lib/thermion_dart/utils/using_pointer.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
final allocator = calloc;
|
||||
|
||||
void using(Pointer ptr, Future Function(Pointer ptr) function) async {
|
||||
await function.call(ptr);
|
||||
allocator.free(ptr);
|
||||
}
|
||||
Reference in New Issue
Block a user