mdx-m3-viewer: Some portrait model problems
Now that I have managed to deploy my resources Express server somehow for free, I can open this issue finally. Here’s a demo of the website using the model viewer (best having Friz Quadrata TT font installed): https://peaceful-mcnulty-a8a424.netlify.app/ (just search for the respective hero name/title on the search bar on the lower right)
How do I deal with the issue where some models are not visible at all when setting the camera of the portrait model? Most of the models are fine but some models can’t be seen at certain aspect ratios of the viewport when it’s a bit too wide. Example:
Units/Creeps/SylvanusWindrunner/SylvanusWindrunner_portrait.mdx(search “alleria”)Units/Orc/HeroFarSeer/HeroFarSeer_portrait.mdx(search “chen”)Units/NightElf/MountainGiant/MountainGiant_Portrait.mdx(search “tiny”)- and several others
Also, there’s the problem with the camera of some models where the perspective(?) is wrong. Some models I noticed with this problem:
Units/Demon/HeroChaosBladeMaster/HeroChaosBladeMaster_portrait.mdx(search “yurnero”)Units/NightElf/DruidoftheClaw/DruidoftheClaw_portrait.mdx(search “lone druid”, only on non-alternate sequences)
I use the following code for setting the perspective and face direction, how the camera values was used was referenced from d07RiV’s WC3 Data code:
if (model.cameras.length) {
const { farClippingPlane, fieldOfView, nearClippingPlane, position, targetPosition } = model.cameras[0]
const aspectRatio = canvasRef.current.width / canvasRef.current.height
// Custom fieldOfView value from d07RiV's WC3 Data model viewer component
// I don't really understand much but this seems to scale pretty well when used instead of the one in the portrait camera
const scalableFoV = Math.atan(Math.tan(fieldOfView / 2) / aspectRatio) * 2
instance.resetTransformation()
instance.setSequence(portraitSequence === -1 ? 0 : portraitSequence)
scene.camera.perspective(scalableFoV, aspectRatio, nearClippingPlane, farClippingPlane)
scene.camera.moveToAndFace(position, targetPosition, [0, 0, 1])
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 33 (18 by maintainers)
Commits related to this issue
- Update - The questionable double radius for culling was indeed questionable (and wrong). The real problem was models that have no main extent but do have sequence extents, which were not used by the ... — committed to flowtsohg/mdx-m3-viewer by flowtsohg 3 years ago
- Added handling for invalid layer filter modes ( #66 ) — committed to flowtsohg/mdx-m3-viewer by flowtsohg 3 years ago
- Biggest update so far ( #66 ) — committed to flowtsohg/mdx-m3-viewer by flowtsohg 3 years ago
- temporary fix for zet portrait bug Fixes temporarily the bug where the portrait is not visible when changing the view to Portrait Discussion: https://github.com/flowtsohg/mdx-m3-viewer/issues/66#iss... — committed to jp06/wc3-dota-info by jp06 3 years ago
- Fixes - Instances now update if they are dirty also if they are not visible. This allows clients to move instances as they will without getting into a situation where the instance cannot get updated ... — committed to flowtsohg/mdx-m3-viewer by flowtsohg 3 years ago
- Fix a bit the MDX camera class ( #66 ) — committed to flowtsohg/mdx-m3-viewer by flowtsohg 3 years ago
- Add twist and following MDX cameras to SimpleOrbitCamera for #66 and the Hive client - Added SimpleOrbitCamera.twist to control the twist angle (remember to update the camera afterwards!) - Added Sim... — committed to flowtsohg/mdx-m3-viewer by flowtsohg 3 years ago
- Small update - When using an instance camera, SimpleOrbitCamera will now properly use its world transformation (related to the Hive viewer, and probably to #66 ) - The sanity test client no longer cl... — committed to flowtsohg/mdx-m3-viewer by flowtsohg 3 years ago
You shouldn’t need to call
recalculateTransformation(), your code should intuitively work, so as far as I am concerned this is bug, but if you want a fix for now that will work.localXis in object space, andworldXis in world space. If a node is parented, the local values are relative to the parent and the world ones are absolute. If a node isn’t parented, they are the same. E.g. if an instance is moved 50 units on the X axis, and it is parented to another instance that is moved 50 units on the X axis,localLocation[0] == 50andworldLocation[0] == 100.