Skip to content

Commit

Permalink
Merge pull request #1100 from moddio/feat-add-3d-map-editor-to-threejs
Browse files Browse the repository at this point in the history
fix: scale transform for the 3d model gizmo
  • Loading branch information
moe-moe-pupil committed Jun 20, 2024
2 parents 3e10900 + 5ca52b8 commit 6c3de65
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ts/src/renderer/three/EntityEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ namespace Renderer {
if (event.key === 'c' && event.ctrlKey && this.selectedEntity && this.selectedEntity instanceof InitEntity) {
const action = this.selectedEntity.action;
const is3DObject = this.selectedEntity.isObject3D;
taro.developerMode.activeButton = 'add-entities'

this.selectEntity(null);
this.activatePlacement(true);

setTimeout(() => {
(window as any).selectTool('add-entities');
this.activeEntity = {
id: action.entity,
player: action.player.variableName,
Expand Down
4 changes: 2 additions & 2 deletions ts/src/renderer/three/EntityGizmo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ namespace Renderer {
} else if (control.object.body instanceof Model) {
editedAction['scale'] = {
x: Utils.worldToPixel(control.object.body.getSize().x / control.object.defaultWidth),
y: Utils.worldToPixel(control.object.body.getSize().z / control.object.defaultDepth),
z: Utils.worldToPixel(control.object.body.getSize().y / control.object.defaultHeight),
y: Utils.worldToPixel(control.object.body.getSize().y / control.object.defaultHeight),
z: Utils.worldToPixel(control.object.body.getSize().z / control.object.defaultDepth),
function: 'vector3',
};
}
Expand Down
12 changes: 8 additions & 4 deletions ts/src/renderer/three/InitEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ namespace Renderer {
);
} else if (body instanceof Model) {
this.setSize(
Utils.pixelToWorld(defaultWidth * action.scale.x),
Utils.pixelToWorld(defaultDepth * action.scale.z),
Utils.pixelToWorld(defaultHeight * action.scale.y)
Utils.pixelToWorld(this.defaultWidth * action.scale.x),
Utils.pixelToWorld(this.defaultHeight * action.scale.y),
Utils.pixelToWorld(this.defaultDepth * action.scale.z)
);
}
} else if (!isNaN(action.width) && !isNaN(action.height)) {
Expand Down Expand Up @@ -204,7 +204,11 @@ namespace Renderer {
if (isNaN(this.action.scale.z)) {
this.action.scale.z = 0;
}
this.setSize(this.action.scale.x, this.action.scale.z, this.action.scale.y);
this.setSize(
Utils.pixelToWorld(this.defaultWidth * action.scale.x),
Utils.pixelToWorld(this.defaultHeight * action.scale.y),
Utils.pixelToWorld(this.defaultDepth * action.scale.z)
);
}
if (!isNaN(this.action.width) && !isNaN(action.width)) {
this.action.width = action.width;
Expand Down

0 comments on commit 6c3de65

Please sign in to comment.