Compare commits

...

4 Commits

Author SHA1 Message Date
Nick Fisher
1e07486017 chore(release): publish packages
- thermion_flutter@0.2.0-dev.6.0
2024-09-25 21:57:38 +08:00
Nick Fisher
58da196876 chore!: remove superseded HardwareKeyboard* classes 2024-09-25 21:56:16 +08:00
Nick Fisher
78af155a6d chore(release): publish packages
- thermion_dart@0.2.0-dev.5.0
 - thermion_flutter_web@0.1.0-dev.5.0
 - thermion_flutter@0.2.0-dev.5.0
 - thermion_flutter_platform_interface@0.2.0-dev.5.0
 - thermion_flutter_ffi@0.2.0-dev.5.0
2024-09-25 21:52:58 +08:00
Nick Fisher
d7e1b3d7ba chore!: remove EntityTransformController (requires replacement) 2024-09-25 21:52:42 +08:00
14 changed files with 96 additions and 292 deletions

View File

@@ -3,6 +3,60 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## 2024-09-25
### Changes
---
Packages with breaking changes:
- [`thermion_flutter` - `v0.2.0-dev.6.0`](#thermion_flutter---v020-dev60)
Packages with other changes:
- There are no other changes in this release.
---
#### `thermion_flutter` - `v0.2.0-dev.6.0`
- **BREAKING** **CHORE**: remove superseded HardwareKeyboard* classes.
## 2024-09-25
### Changes
---
Packages with breaking changes:
- [`thermion_dart` - `v0.2.0-dev.5.0`](#thermion_dart---v020-dev50)
Packages with other changes:
- [`thermion_flutter_web` - `v0.1.0-dev.5.0`](#thermion_flutter_web---v010-dev50)
- [`thermion_flutter` - `v0.2.0-dev.5.0`](#thermion_flutter---v020-dev50)
- [`thermion_flutter_platform_interface` - `v0.2.0-dev.5.0`](#thermion_flutter_platform_interface---v020-dev50)
- [`thermion_flutter_ffi` - `v0.2.0-dev.5.0`](#thermion_flutter_ffi---v020-dev50)
Packages with dependency updates only:
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `thermion_flutter_web` - `v0.1.0-dev.5.0`
- `thermion_flutter` - `v0.2.0-dev.5.0`
- `thermion_flutter_platform_interface` - `v0.2.0-dev.5.0`
- `thermion_flutter_ffi` - `v0.2.0-dev.5.0`
---
#### `thermion_dart` - `v0.2.0-dev.5.0`
- **BREAKING** **CHORE**: remove EntityTransformController (requires replacement).
## 2024-09-25
### Changes

View File

@@ -1,3 +1,9 @@
## 0.2.0-dev.5.0
> Note: This release has breaking changes.
- **BREAKING** **CHORE**: remove EntityTransformController (requires replacement).
## 0.2.0-dev.4.0
> Note: This release has breaking changes.

View File

@@ -1,179 +0,0 @@
import 'dart:async';
import 'dart:math';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:vector_math/vector_math_64.dart' as v;
class EntityTransformController {
final ThermionViewer controller;
final ThermionEntity _entity;
late Timer _ticker;
double translationSpeed;
double rotationRadsPerSecond;
bool _forward = false;
bool _strafeLeft = false;
bool _strafeRight = false;
bool _back = false;
bool _rotateLeft = false;
bool _rotateRight = false;
double _rotY = 0;
int? forwardAnimationIndex;
int? backwardAnimationIndex;
int? strafeLeftAnimationIndex;
int? strafeRightAnimationIndex;
EntityTransformController(this.controller, this._entity,
{this.translationSpeed = 1,
this.rotationRadsPerSecond = pi / 2,
this.forwardAnimationIndex,
this.backwardAnimationIndex,
this.strafeLeftAnimationIndex,
this.strafeRightAnimationIndex}) {
var translationSpeedPerTick = translationSpeed / (1000 / 16.667);
var rotationRadsPerTick = rotationRadsPerSecond / (1000 / 16.667);
_ticker = Timer.periodic(const Duration(milliseconds: 16), (timer) {
_update(translationSpeedPerTick, rotationRadsPerTick);
});
}
bool _enabled = true;
void enable() {
_enabled = true;
}
void disable() {
_enabled = false;
}
void _update(
double translationSpeedPerTick, double rotationRadsPerTick) async {
if (!_enabled) {
return;
}
var _position = v.Vector3.zero();
bool updateTranslation = false;
if (_forward) {
_position.add(v.Vector3(0, 0, -translationSpeedPerTick));
updateTranslation = true;
}
if (_back) {
_position.add(v.Vector3(0, 0, translationSpeedPerTick));
updateTranslation = true;
}
if (_strafeLeft) {
_position.add(v.Vector3(-translationSpeedPerTick, 0, 0));
updateTranslation = true;
}
if (_strafeRight) {
_position.add(v.Vector3(translationSpeedPerTick, 0, 0));
updateTranslation = true;
}
// TODO - use pitch/yaw/roll
bool updateRotation = false;
var _rotation = v.Quaternion.identity();
double rads = 0.0;
if (_rotY != 0) {
rads = _rotY * pi / 1000;
var rotY = v.Quaternion.axisAngle(v.Vector3(0, 1, 0), rads).normalized();
_rotation = rotY;
updateRotation = true;
_rotY = 0;
}
if (updateTranslation) {
await controller.queuePositionUpdate(
_entity, _position.x, _position.y, _position.z,
relative: true);
}
if (updateRotation) {
await controller.queueRotationUpdateQuat(_entity, _rotation,
relative: true);
}
}
void look(double deltaX) async {
_rotY -= deltaX;
}
void dispose() {
_ticker.cancel();
}
bool _playingForwardAnimation = false;
bool _playingBackwardAnimation = false;
void forwardPressed() async {
_forward = true;
if (forwardAnimationIndex != null && !_playingForwardAnimation) {
await controller.playAnimation(_entity, forwardAnimationIndex!,
loop: true, replaceActive: false);
_playingForwardAnimation = true;
}
}
void forwardReleased() async {
_forward = false;
await Future.delayed(Duration(milliseconds: 50));
if (!_forward) {
_playingForwardAnimation = false;
if (forwardAnimationIndex != null) {
await controller.stopAnimation(_entity, forwardAnimationIndex!);
}
}
}
void backPressed() async {
_back = true;
if (forwardAnimationIndex != null) {
if (!_playingBackwardAnimation) {
await controller.playAnimation(_entity, forwardAnimationIndex!,
loop: true, replaceActive: false, reverse: true);
_playingBackwardAnimation = true;
}
}
}
void backReleased() async {
_back = false;
if (forwardAnimationIndex != null) {
await controller.stopAnimation(_entity, forwardAnimationIndex!);
}
_playingBackwardAnimation = false;
}
void strafeLeftPressed() {
_strafeLeft = true;
}
void strafeLeftReleased() async {
_strafeLeft = false;
}
void strafeRightPressed() {
_strafeRight = true;
}
void strafeRightReleased() async {
_strafeRight = false;
}
void Function()? _mouse1DownCallback;
void onMouse1Down(void Function() callback) {
_mouse1DownCallback = callback;
}
void mouse1Down() async {
_mouse1DownCallback?.call();
}
void mouse1Up() async {}
void mouse2Up() async {}
void mouse2Down() async {}
}

View File

@@ -1,6 +1,6 @@
name: thermion_dart
description: 3D rendering toolkit for Dart.
version: 0.2.0-dev.4.0
version: 0.2.0-dev.5.0
homepage: https://thermion.dev
repository: https://github.com/nmfisher/thermion

View File

@@ -1,3 +1,13 @@
## 0.2.0-dev.6.0
> Note: This release has breaking changes.
- **BREAKING** **CHORE**: remove superseded HardwareKeyboard* classes.
## 0.2.0-dev.5.0
- Update a dependency to the latest release.
## 0.2.0-dev.4.0
- Update a dependency to the latest release.

View File

@@ -1,60 +0,0 @@
import 'package:thermion_dart/thermion_dart/entities/entity_transform_controller.dart';
import 'package:flutter/services.dart';
class HardwareKeyboardListener {
final EntityTransformController _controller;
var _listening = true;
HardwareKeyboardListener(this._controller) {
// Get the global handler.
final KeyMessageHandler? existing =
ServicesBinding.instance.keyEventManager.keyMessageHandler;
// The handler is guaranteed non-null since
// `FallbackKeyEventRegistrar.instance` is only called during
// `Focus.onFocusChange`, at which time `ServicesBinding.instance` must
// have been called somewhere.
assert(existing != null);
// Assign the global handler with a patched handler.
ServicesBinding.instance.keyEventManager.keyMessageHandler = (keyMessage) {
if (keyMessage.rawEvent == null) {
return false;
}
if (!_listening) {
return false;
}
var event = keyMessage.rawEvent!;
switch (event.logicalKey) {
case LogicalKeyboardKey.escape:
_listening = false;
break;
case LogicalKeyboardKey.keyW:
(event is RawKeyDownEvent)
? _controller.forwardPressed()
: _controller.forwardReleased();
break;
case LogicalKeyboardKey.keyA:
event is RawKeyDownEvent
? _controller.strafeLeftPressed()
: _controller.strafeLeftReleased();
break;
case LogicalKeyboardKey.keyS:
event is RawKeyDownEvent
? _controller.backPressed()
: _controller.backReleased();
break;
case LogicalKeyboardKey.keyD:
event is RawKeyDownEvent
? _controller.strafeRightPressed()
: _controller.strafeRightReleased();
break;
default:
break;
}
return true;
};
}
void dispose() {
ServicesBinding.instance.keyEventManager.keyMessageHandler = null;
_controller.dispose();
}
}

View File

@@ -1,39 +0,0 @@
import 'dart:async';
import 'package:thermion_dart/thermion_dart/entities/entity_transform_controller.dart';
import 'package:flutter/services.dart';
class HardwareKeyboardPoll {
final EntityTransformController _controller;
late Timer _timer;
HardwareKeyboardPoll(this._controller) {
_timer = Timer.periodic(const Duration(milliseconds: 16), (_) {
if (RawKeyboard.instance.keysPressed.contains(LogicalKeyboardKey.keyW)) {
_controller.forwardPressed();
} else {
_controller.forwardReleased();
}
if (RawKeyboard.instance.keysPressed.contains(LogicalKeyboardKey.keyS)) {
_controller.backPressed();
} else {
_controller.backReleased();
}
if (RawKeyboard.instance.keysPressed.contains(LogicalKeyboardKey.keyA)) {
_controller.strafeLeftPressed();
} else {
_controller.strafeLeftReleased();
}
if (RawKeyboard.instance.keysPressed.contains(LogicalKeyboardKey.keyD)) {
_controller.strafeRightPressed();
} else {
_controller.strafeRightReleased();
}
});
}
void dispose() {
_timer.cancel();
}
}

View File

@@ -1,6 +1,6 @@
name: thermion_flutter
description: Flutter plugin for 3D rendering with the Thermion toolkit.
version: 0.2.0-dev.4.0
version: 0.2.0-dev.6.0
homepage: https://thermion.dev
repository: https://github.com/nmfisher/thermion
@@ -17,10 +17,10 @@ dependencies:
plugin_platform_interface: ^2.0.0
ffi: ^2.1.2
animation_tools_dart: ^0.0.4
thermion_dart: ^0.2.0-dev.4.0
thermion_flutter_platform_interface: ^0.2.0-dev.4.0
thermion_flutter_ffi: ^0.2.0-dev.4.0
thermion_flutter_web: ^0.1.0-dev.4.0
thermion_dart: ^0.2.0-dev.5.0
thermion_flutter_platform_interface: ^0.2.0-dev.5.0
thermion_flutter_ffi: ^0.2.0-dev.5.0
thermion_flutter_web: ^0.1.0-dev.5.0
logging: ^1.2.0
web: ^1.0.0

View File

@@ -1,3 +1,7 @@
## 0.2.0-dev.5.0
- Update a dependency to the latest release.
## 0.2.0-dev.4.0
- Update a dependency to the latest release.

View File

@@ -1,7 +1,7 @@
name: thermion_flutter_ffi
description: An FFI interface for the thermion_flutter plugin (all platforms except web).
repository: https://github.com/nmfisher/thermion_flutter/thermion_flutter
version: 0.2.0-dev.4.0
version: 0.2.0-dev.5.0
environment:
sdk: ">=3.3.0 <4.0.0"
@@ -22,8 +22,8 @@ dependencies:
flutter:
sdk: flutter
plugin_platform_interface: ^2.1.0
thermion_flutter_platform_interface: ^0.2.0-dev.4.0
thermion_dart: ^0.2.0-dev.4.0
thermion_flutter_platform_interface: ^0.2.0-dev.5.0
thermion_dart: ^0.2.0-dev.5.0
logging: ^1.2.0
dev_dependencies:

View File

@@ -1,3 +1,7 @@
## 0.2.0-dev.5.0
- Update a dependency to the latest release.
## 0.2.0-dev.4.0
- Update a dependency to the latest release.

View File

@@ -1,7 +1,7 @@
name: thermion_flutter_platform_interface
description: A common platform interface for the thermion_flutter plugin.
repository: https://github.com/nmfisher/thermion_flutter/thermion_flutter
version: 0.2.0-dev.4.0
version: 0.2.0-dev.5.0
environment:
sdk: ">=3.3.0 <4.0.0"
@@ -11,7 +11,7 @@ dependencies:
flutter:
sdk: flutter
plugin_platform_interface: ^2.1.0
thermion_dart: ^0.2.0-dev.4.0
thermion_dart: ^0.2.0-dev.5.0
dev_dependencies:
flutter_test:

View File

@@ -1,3 +1,7 @@
## 0.1.0-dev.5.0
- Update a dependency to the latest release.
## 0.1.0-dev.4.0
> Note: This release has breaking changes.

View File

@@ -1,7 +1,7 @@
name: thermion_flutter_web
description: A web platform interface for the thermion_flutter plugin.
repository: https://github.com/nmfisher/thermion_flutter/thermion_flutter
version: 0.1.0-dev.4.0
version: 0.1.0-dev.5.0
environment:
sdk: ">=3.3.0 <4.0.0"
@@ -20,8 +20,8 @@ dependencies:
sdk: flutter
plugin_platform_interface: ^2.1.0
web: ^1.0.0
thermion_dart: ^0.2.0-dev.4.0
thermion_flutter_platform_interface: ^0.2.0-dev.4.0
thermion_dart: ^0.2.0-dev.5.0
thermion_flutter_platform_interface: ^0.2.0-dev.5.0
flutter_web_plugins:
sdk: flutter