change transform order for relative setPosition to SRT

This commit is contained in:
Nick Fisher
2024-02-05 08:43:54 +08:00
parent 48a1c6dc0b
commit 6561af6825
3 changed files with 7 additions and 3 deletions

View File

@@ -1211,7 +1211,9 @@ namespace polyvox
decomposeMatrix(transform, &translation, &rotation, &scale);
if(relative) {
translation += math::float3( x, y, z );
math::mat3f rotationMatrix(rotation);
math::float3 relativeTranslation = rotationMatrix * math::float3( x, y, z );
translation += relativeTranslation;
} else {
translation = math::float3(x,y,z);
}
@@ -1250,6 +1252,7 @@ namespace polyvox
transform = composeMatrix(translation, rotation, scale);
tm.setTransform(transformInstance, transform);
}

View File

@@ -73,7 +73,7 @@ class EntityTransformController {
updateTranslation = true;
}
// todo - better to use pitch/yaw/roll
// TODO - use pitch/yaw/roll
bool updateRotation = false;
var _rotation = v.Quaternion.identity();
@@ -92,7 +92,6 @@ class EntityTransformController {
relative: true);
}
if (updateRotation) {
var axis = _rotation.axis;
await controller.setRotationQuat(_entity, _rotation, relative: true);
}
}

View File

@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:ffi';
import 'dart:io';
import 'dart:math';
import 'dart:ui' as ui;
import 'dart:developer' as dev;
import 'package:flutter/services.dart';
@@ -1056,6 +1057,7 @@ class FilamentControllerFFI extends FilamentController {
if (_viewer == null) {
throw Exception("No viewer available, ignoring");
}
set_position(_assetManager!, entity, x, y, z, relative);
}