diff --git a/src/Core/Camera.ts b/src/Core/Camera.ts index ecc61e44..04c8aa21 100644 --- a/src/Core/Camera.ts +++ b/src/Core/Camera.ts @@ -236,8 +236,7 @@ class Camera { * Update the distance. */ updateDistance() { - this.distance = this.getThreeCamera().position.distanceTo(this - .targetPosition); + this.getThreeCamera().position.normalize().multiplyScalar(this.distance); } /** diff --git a/src/Core/Land.ts b/src/Core/Land.ts index d5954f15..138b0b3c 100644 --- a/src/Core/Land.ts +++ b/src/Core/Land.ts @@ -153,9 +153,9 @@ class Land extends MapElement { p: position, l: localPosition, b: [ - a + rect[0] + Datas.Systems.SQUARE_SIZE / 2, + a + rect[0] + rect[2] / 2, b + 0.5, - c + rect[1] + Datas.Systems.SQUARE_SIZE / 2, + c + rect[1] + rect[3] / 2, rect[2], rect[3], 1, diff --git a/src/Core/MapObject.ts b/src/Core/MapObject.ts index ef4d6bc9..b33e9eb1 100644 --- a/src/Core/MapObject.ts +++ b/src/Core/MapObject.ts @@ -545,7 +545,7 @@ class MapObject { this.frame.value = this.currentStateInstance.indexX >= Datas.Systems .FRAMES ? Datas.Systems.FRAMES - 1 : this.currentStateInstance .indexX; - this.orientationEye = this.currentStateInstance.indexY; + this.orientationEye = this.currentStateInstance.setWithCamera ? this.currentStateInstance.indexY : Mathf.mod(Scene.Map.current.orientation + this.currentStateInstance.indexY - 2, 4); this.updateOrientation(); let result: [CustomGeometry, [number, StructMapElementCollision[]]]; let positionTranformation = Position.createFromVector3(this.position); @@ -629,7 +629,7 @@ class MapObject { } this.mesh.position.set(this.position.x, this.position.y, this .position.z); - this.mesh.renderOrder = 9999; + this.mesh.renderOrder = -1; this.boundingBoxSettings = objCollision[1][0]; if (this.boundingBoxSettings) { if (this.currentStateInstance.graphicID === 0) { diff --git a/src/Core/MapPortion.ts b/src/Core/MapPortion.ts index 3eae9031..c78a5c70 100644 --- a/src/Core/MapPortion.ts +++ b/src/Core/MapPortion.ts @@ -185,7 +185,7 @@ class MapPortion { if (!geometry.isEmpty()) { geometry.updateAttributes(); this.staticFloorsMesh = new THREE.Mesh(geometry, material); - this.staticFloorsMesh.renderOrder = 0; + this.staticFloorsMesh.renderOrder = -1; if (Scene.Map.current.mapProperties.isSunLight) { this.staticFloorsMesh.receiveShadow = true; this.staticFloorsMesh.castShadow = true; @@ -321,7 +321,7 @@ class MapPortion { if (!staticGeometry.isEmpty()) { staticGeometry.updateAttributes(); this.staticSpritesMesh = new THREE.Mesh(staticGeometry, material); - this.staticSpritesMesh.renderOrder = 999; + this.staticSpritesMesh.renderOrder = -1; if (Scene.Map.current.mapProperties.isSunLight) { this.staticSpritesMesh.receiveShadow = true; this.staticSpritesMesh.castShadow = true; @@ -332,7 +332,7 @@ class MapPortion { if (!faceGeometry.isEmpty()) { faceGeometry.updateAttributes(); this.faceSpritesMesh = new THREE.Mesh(faceGeometry, material); - this.faceSpritesMesh.renderOrder = 999; + this.faceSpritesMesh.renderOrder = -1; if (Scene.Map.current.mapProperties.isSunLight) { this.faceSpritesMesh.castShadow = true; this.faceSpritesMesh.receiveShadow = true; @@ -584,7 +584,7 @@ class MapPortion { geometry.updateAttributes(); mesh = new THREE.Mesh(geometry, obj.material); this.staticObjects3DList.push(mesh); - mesh.renderOrder = 999; + mesh.renderOrder = -1; if (Scene.Map.current.mapProperties.isSunLight) { mesh.receiveShadow = true; mesh.castShadow = true; diff --git a/src/EventCommand/MoveObject.ts b/src/EventCommand/MoveObject.ts index f3ddb988..bb3fda44 100644 --- a/src/EventCommand/MoveObject.ts +++ b/src/EventCommand/MoveObject.ts @@ -722,7 +722,7 @@ class MoveObject extends Base { Record): Orientation | boolean { if (object) { - object.lookAt((Orientation.North + (this.isCameraOrientation ? Scene.Map.current.orientation : 0)) % 4); + object.lookAt((Orientation.North + (this.isCameraOrientation ? Scene.Map.current.orientation + 2 : 0)) % 4); return true; } return Orientation.North; @@ -739,7 +739,7 @@ class MoveObject extends Base { Record): Orientation | boolean { if (object) { - object.lookAt((Orientation.South + (this.isCameraOrientation ? Scene.Map.current.orientation : 0)) % 4); + object.lookAt((Orientation.South + (this.isCameraOrientation ? Scene.Map.current.orientation + 2 : 0)) % 4); return true; } return Orientation.South; @@ -756,7 +756,7 @@ class MoveObject extends Base { Record): Orientation | boolean { if (object) { - object.lookAt((Orientation.West + (this.isCameraOrientation ? Scene.Map.current.orientation : 0)) % 4); + object.lookAt((Orientation.West + (this.isCameraOrientation ? Scene.Map.current.orientation + 2 : 0)) % 4); return true; } return Orientation.West; @@ -773,7 +773,7 @@ class MoveObject extends Base { Record): Orientation | boolean { if (object) { - object.lookAt((Orientation.East + (this.isCameraOrientation ? Scene.Map.current.orientation : 0)) % 4); + object.lookAt((Orientation.East + (this.isCameraOrientation ? Scene.Map.current.orientation + 2 : 0)) % 4); return true; } return Orientation.East; diff --git a/src/Graphic/Message.ts b/src/Graphic/Message.ts index b35de713..be8a84da 100644 --- a/src/Graphic/Message.ts +++ b/src/Graphic/Message.ts @@ -479,9 +479,7 @@ class Message extends Graphic.Base { if (Datas.Systems.dbOptions.v_fPosAbove) { this.drawFaceset(x, y, w, h); } - let newX = x + ScreenResolution.getScreenX(Constants.HUGE_SPACE * 2) + - (this.faceset.empty ? 0 : ScreenResolution.getScreenX(Datas - .Systems.facesetScalingWidth)); + let newX = x + (this.faceset.empty ? 0 : ScreenResolution.getScreenX(Datas.Systems.facesetScalingWidth)); let newY = y + ScreenResolution.getScreenMinXY(Constants.HUGE_SPACE); let offsetY = 0; let align = Align.None; @@ -506,10 +504,10 @@ class Message extends Graphic.Base { offsetX = 0; break; case Align.Center: - offsetX = (w - this.totalWidths[j] - newX) / 2; + offsetX = (w - this.totalWidths[j]) / 2; break; case Align.Right: - offsetX = w - this.totalWidths[j] - newX; + offsetX = w - this.totalWidths[j]; break; } j++; diff --git a/src/Scene/Map.ts b/src/Scene/Map.ts index 2de3c7bb..0c4ff4d4 100644 --- a/src/Scene/Map.ts +++ b/src/Scene/Map.ts @@ -901,7 +901,7 @@ class Map extends Base { points.position.set(Scene.Map.current.camera.target.position.x, Scene .Map.current.camera.target.position.y, Scene.Map.current.camera.target .position.z) - points.renderOrder = 1000; + points.renderOrder = -1; this.scene.add(points); if (current) { this.weatherPoints = points; diff --git a/src/Scene/SaveLoadGame.ts b/src/Scene/SaveLoadGame.ts index 2588fbff..cd331fcc 100644 --- a/src/Scene/SaveLoadGame.ts +++ b/src/Scene/SaveLoadGame.ts @@ -41,7 +41,7 @@ class SaveLoadGame extends Base { this.gamesDatas.push(null); const newGame = new Game(i); await newGame.load(); - Game.current = newGame; + Game.current = newGame; this.initializeGame(Game.current); } Game.current = currentGame; diff --git a/src/System/MainMenuCommand.ts b/src/System/MainMenuCommand.ts index 2304f21e..bafa0a2b 100644 --- a/src/System/MainMenuCommand.ts +++ b/src/System/MainMenuCommand.ts @@ -102,9 +102,9 @@ class MainMenuCommand extends Translatable { return true; }; case Enum.MainMenuCommandKind.Script: + const t = this; return function() { - return Interpreter.evaluate(this.script, { additionalName: - "menu", additionalValue: this}); + return Interpreter.evaluate(t.script, { additionalName: "menu", additionalValue: t, addReturn: false }); }; default: return null;