question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some portrait model problems

See original GitHub issue

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])
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:33 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
flowtsohgcommented, Mar 17, 2021

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.

localX is in object space, and worldX is 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] == 50 and worldLocation[0] == 100.

0reactions
flowtsohgcommented, Apr 18, 2021

There was actually still an issue, because applyInstanceCamera() didn’t also use the instance’s own transformation. This should now be fixed, so I think this issue can be closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fatal Attraction | The Problem With Portrait Photography
This article examines the connection between portrait photography and its subject. Should beauty be superficial, or should it be elicited by ...
Read more >
7 Creative Portrait Challenges to Get You Out of a Creative Rut
The best part is that you don't have to have elaborate sets or exotic locations to do any of these 7 portrait challenges....
Read more >
6 Typical Portrait Mistakes and How to Fix Them (VIDEO)
#1 Eyes Not Sharp. "One of the most common problems I see are portrait photos where the eyes of the subject aren't sharp,"...
Read more >
Portrait Problems | Photography - Vocal Media
So let's start with some awkward realities in photography: Your camera data means nothing, your knowledge of photography means a lot. There is...
Read more >
15 Portrait Photography Mistakes (And How to Fix Them)
10. Taking too many photos. Taking too few photos is a serious portrait photography mistake, but taking too many photos can be a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found