From 3a94a94e5ddaced2bce6afa256ec704c2d6e5024 Mon Sep 17 00:00:00 2001 From: Daan Vanden Bosch Date: Wed, 14 Aug 2019 18:29:40 +0200 Subject: [PATCH] Improved entity section guessing when translating entities. --- src/quest_editor/loading/entities.ts | 4 ++-- src/quest_editor/rendering/QuestModelManager.ts | 8 ++++---- src/quest_editor/rendering/conversion/areas.ts | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/quest_editor/loading/entities.ts b/src/quest_editor/loading/entities.ts index 526cd066..780246ee 100644 --- a/src/quest_editor/loading/entities.ts +++ b/src/quest_editor/loading/entities.ts @@ -80,7 +80,7 @@ export async function load_npc_geometry(npc_type: NpcType): Promise { +export async function load_npc_textures(npc_type: NpcType): Promise { return npc_tex_cache.get_or_set(npc_type, async () => { try { const { data } = await load_npc_data(npc_type, AssetType.Texture); @@ -114,7 +114,7 @@ export async function load_object_geometry(object_type: ObjectType): Promise { +export async function load_object_textures(object_type: ObjectType): Promise { return object_tex_cache.get_or_set(object_type, async () => { try { const { data } = await load_object_data(object_type, AssetType.Texture); diff --git a/src/quest_editor/rendering/QuestModelManager.ts b/src/quest_editor/rendering/QuestModelManager.ts index 3f4c21ad..e1e553eb 100644 --- a/src/quest_editor/rendering/QuestModelManager.ts +++ b/src/quest_editor/rendering/QuestModelManager.ts @@ -4,9 +4,9 @@ import { Intersection, Mesh, Object3D, Raycaster, Vector3 } from "three"; import { load_area_collision_geometry, load_area_render_geometry } from "../loading/areas"; import { load_npc_geometry, - load_npc_tex as load_npc_textures, + load_npc_textures, load_object_geometry, - load_object_tex as load_object_textures, + load_object_textures, } from "../loading/entities"; import { create_npc_mesh, create_object_mesh } from "./conversion/entities"; import { QuestRenderer } from "./QuestRenderer"; @@ -129,12 +129,12 @@ export class QuestModelManager { raycaster.set(origin, down); const intersection1 = raycaster .intersectObject(render_geom, true) - .find(i => (i.object.userData as AreaUserData).section != null); + .find(i => (i.object.userData as AreaUserData).section != undefined); raycaster.set(origin, up); const intersection2 = raycaster .intersectObject(render_geom, true) - .find(i => (i.object.userData as AreaUserData).section != null); + .find(i => (i.object.userData as AreaUserData).section != undefined); let intersection: Intersection | undefined; diff --git a/src/quest_editor/rendering/conversion/areas.ts b/src/quest_editor/rendering/conversion/areas.ts index 816fb05a..4588d192 100644 --- a/src/quest_editor/rendering/conversion/areas.ts +++ b/src/quest_editor/rendering/conversion/areas.ts @@ -141,6 +141,7 @@ export function area_geometry_to_sections_and_object_3d( mesh.position.set(section.position.x, section.position.y, section.position.z); mesh.rotation.set(section.rotation.x, section.rotation.y, section.rotation.z); + mesh.updateMatrixWorld(); if (section.id >= 0) { const sec = new Section(section.id, section.position, section.rotation.y);