Skip to content

Commit 09301b4

Browse files
yaleksanderWano-k
authored andcommitted
second attempt
1 parent 8d67056 commit 09301b4

9 files changed

Lines changed: 20 additions & 23 deletions

File tree

src/Core/Camera.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ class Camera {
236236
* Update the distance.
237237
*/
238238
updateDistance() {
239-
this.distance = this.getThreeCamera().position.distanceTo(this
240-
.targetPosition);
239+
this.getThreeCamera().position.normalize().multiplyScalar(this.distance);
241240
}
242241

243242
/**

src/Core/Land.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ class Land extends MapElement {
153153
p: position,
154154
l: localPosition,
155155
b: [
156-
a + rect[0] + Datas.Systems.SQUARE_SIZE / 2,
156+
a + rect[0] + rect[2] / 2,
157157
b + 0.5,
158-
c + rect[1] + Datas.Systems.SQUARE_SIZE / 2,
158+
c + rect[1] + rect[3] / 2,
159159
rect[2],
160160
rect[3],
161161
1,

src/Core/MapObject.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ class MapObject {
545545
this.frame.value = this.currentStateInstance.indexX >= Datas.Systems
546546
.FRAMES ? Datas.Systems.FRAMES - 1 : this.currentStateInstance
547547
.indexX;
548-
this.orientationEye = this.currentStateInstance.indexY;
548+
this.orientationEye = this.currentStateInstance.setWithCamera ? this.currentStateInstance.indexY : Mathf.mod(Scene.Map.current.orientation + this.currentStateInstance.indexY - 2, 4);
549549
this.updateOrientation();
550550
let result: [CustomGeometry, [number, StructMapElementCollision[]]];
551551
let positionTranformation = Position.createFromVector3(this.position);
@@ -629,7 +629,7 @@ class MapObject {
629629
}
630630
this.mesh.position.set(this.position.x, this.position.y, this
631631
.position.z);
632-
this.mesh.renderOrder = 9999;
632+
this.mesh.renderOrder = -1;
633633
this.boundingBoxSettings = objCollision[1][0];
634634
if (this.boundingBoxSettings) {
635635
if (this.currentStateInstance.graphicID === 0) {

src/Core/MapPortion.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class MapPortion {
185185
if (!geometry.isEmpty()) {
186186
geometry.updateAttributes();
187187
this.staticFloorsMesh = new THREE.Mesh(geometry, material);
188-
this.staticFloorsMesh.renderOrder = 0;
188+
this.staticFloorsMesh.renderOrder = -1;
189189
if (Scene.Map.current.mapProperties.isSunLight) {
190190
this.staticFloorsMesh.receiveShadow = true;
191191
this.staticFloorsMesh.castShadow = true;
@@ -321,7 +321,7 @@ class MapPortion {
321321
if (!staticGeometry.isEmpty()) {
322322
staticGeometry.updateAttributes();
323323
this.staticSpritesMesh = new THREE.Mesh(staticGeometry, material);
324-
this.staticSpritesMesh.renderOrder = 999;
324+
this.staticSpritesMesh.renderOrder = -1;
325325
if (Scene.Map.current.mapProperties.isSunLight) {
326326
this.staticSpritesMesh.receiveShadow = true;
327327
this.staticSpritesMesh.castShadow = true;
@@ -332,7 +332,7 @@ class MapPortion {
332332
if (!faceGeometry.isEmpty()) {
333333
faceGeometry.updateAttributes();
334334
this.faceSpritesMesh = new THREE.Mesh(faceGeometry, material);
335-
this.faceSpritesMesh.renderOrder = 999;
335+
this.faceSpritesMesh.renderOrder = -1;
336336
if (Scene.Map.current.mapProperties.isSunLight) {
337337
this.faceSpritesMesh.castShadow = true;
338338
this.faceSpritesMesh.receiveShadow = true;
@@ -584,7 +584,7 @@ class MapPortion {
584584
geometry.updateAttributes();
585585
mesh = new THREE.Mesh(geometry, obj.material);
586586
this.staticObjects3DList.push(mesh);
587-
mesh.renderOrder = 999;
587+
mesh.renderOrder = -1;
588588
if (Scene.Map.current.mapProperties.isSunLight) {
589589
mesh.receiveShadow = true;
590590
mesh.castShadow = true;

src/EventCommand/MoveObject.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ class MoveObject extends Base {
722722
Record<string, any>): Orientation | boolean
723723
{
724724
if (object) {
725-
object.lookAt((Orientation.North + (this.isCameraOrientation ? Scene.Map.current.orientation : 0)) % 4);
725+
object.lookAt((Orientation.North + (this.isCameraOrientation ? Scene.Map.current.orientation + 2 : 0)) % 4);
726726
return true;
727727
}
728728
return Orientation.North;
@@ -739,7 +739,7 @@ class MoveObject extends Base {
739739
Record<string, any>): Orientation | boolean
740740
{
741741
if (object) {
742-
object.lookAt((Orientation.South + (this.isCameraOrientation ? Scene.Map.current.orientation : 0)) % 4);
742+
object.lookAt((Orientation.South + (this.isCameraOrientation ? Scene.Map.current.orientation + 2 : 0)) % 4);
743743
return true;
744744
}
745745
return Orientation.South;
@@ -756,7 +756,7 @@ class MoveObject extends Base {
756756
Record<string, any>): Orientation | boolean
757757
{
758758
if (object) {
759-
object.lookAt((Orientation.West + (this.isCameraOrientation ? Scene.Map.current.orientation : 0)) % 4);
759+
object.lookAt((Orientation.West + (this.isCameraOrientation ? Scene.Map.current.orientation + 2 : 0)) % 4);
760760
return true;
761761
}
762762
return Orientation.West;
@@ -773,7 +773,7 @@ class MoveObject extends Base {
773773
Record<string, any>): Orientation | boolean
774774
{
775775
if (object) {
776-
object.lookAt((Orientation.East + (this.isCameraOrientation ? Scene.Map.current.orientation : 0)) % 4);
776+
object.lookAt((Orientation.East + (this.isCameraOrientation ? Scene.Map.current.orientation + 2 : 0)) % 4);
777777
return true;
778778
}
779779
return Orientation.East;

src/Graphic/Message.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,7 @@ class Message extends Graphic.Base {
479479
if (Datas.Systems.dbOptions.v_fPosAbove) {
480480
this.drawFaceset(x, y, w, h);
481481
}
482-
let newX = x + ScreenResolution.getScreenX(Constants.HUGE_SPACE * 2) +
483-
(this.faceset.empty ? 0 : ScreenResolution.getScreenX(Datas
484-
.Systems.facesetScalingWidth));
482+
let newX = x + (this.faceset.empty ? 0 : ScreenResolution.getScreenX(Datas.Systems.facesetScalingWidth));
485483
let newY = y + ScreenResolution.getScreenMinXY(Constants.HUGE_SPACE);
486484
let offsetY = 0;
487485
let align = Align.None;
@@ -506,10 +504,10 @@ class Message extends Graphic.Base {
506504
offsetX = 0;
507505
break;
508506
case Align.Center:
509-
offsetX = (w - this.totalWidths[j] - newX) / 2;
507+
offsetX = (w - this.totalWidths[j]) / 2;
510508
break;
511509
case Align.Right:
512-
offsetX = w - this.totalWidths[j] - newX;
510+
offsetX = w - this.totalWidths[j];
513511
break;
514512
}
515513
j++;

src/Scene/Map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ class Map extends Base {
901901
points.position.set(Scene.Map.current.camera.target.position.x, Scene
902902
.Map.current.camera.target.position.y, Scene.Map.current.camera.target
903903
.position.z)
904-
points.renderOrder = 1000;
904+
points.renderOrder = -1;
905905
this.scene.add(points);
906906
if (current) {
907907
this.weatherPoints = points;

src/Scene/SaveLoadGame.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class SaveLoadGame extends Base {
4141
this.gamesDatas.push(null);
4242
const newGame = new Game(i);
4343
await newGame.load();
44-
Game.current = newGame;
44+
Game.current = newGame;
4545
this.initializeGame(Game.current);
4646
}
4747
Game.current = currentGame;

src/System/MainMenuCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ class MainMenuCommand extends Translatable {
102102
return true;
103103
};
104104
case Enum.MainMenuCommandKind.Script:
105+
const t = this;
105106
return function() {
106-
return Interpreter.evaluate(this.script, { additionalName:
107-
"menu", additionalValue: this});
107+
return Interpreter.evaluate(t.script, { additionalName: "menu", additionalValue: t, addReturn: false });
108108
};
109109
default:
110110
return null;

0 commit comments

Comments
 (0)