Group of objects on top but added to a camera - three.js

As a precision I already noticed threads about this but didn't find a way to achieve exactly what I need.
Basicaly I have a board of objects that I need remaining always on top of everything but also attached to the camera.
I first tried to add the group to the camera and it stayed as wished always in the viewport. But in this configuration the group of objects still be a part of the scene so while zooming to regular objects in the "editor" the board goes into/among these objects of the scene.
My second trial was based on this thread and work wonderfully in order to get all of the board objects rendered above everything. But on such a configuration when rotating around the axis (with orbit control) both scenes rotates. So I tried to update the foreground scene with coordinates of the camera but the update was not immediate and this scene is flickering (I suppose that while rotating the update function is not called immediately).
My best wish would have been to "attach" the foreground scene to the camera so that it would stay on top and sticked on the screen/viewport but I don't even know if it is possible and how to do that (as only groups of objects seem to be capable to be attached to the camera).
I am really stuck on that point. Thanks you for any help!

If this is what you need,
just set object.material.depthTest = false; and object.renderOrder = 1000; for all objects you need to be always on top and attached to the camera.

Related

Panning in React Three Fiber

When I right click, I can move my camera up and down. By default, when my model loads, half of its body is out of the frame. I want to move the camera down, so the whole body fits in the frame. Is there a setting to do this? I’ve tried using camera position but that didn’t work. Thank you!
when I come across cases like this I do this:
try to scale down the object first, so that I can see the whole picture
add axesHelpers to object or scene, to figure out which direction should I move to
change position of camera accordingly.

Gamemaker Studio2, Draw GUI layer conflict

I would like to preface this by saying I am still quite new to gameMakerstudio and I do not know all there is to know about how the software works and this is probably the root cause of my problem as I do not know why I am having this current layering issue.
I have been having an issue where I have TWO DrawGUI events in separate objects within the same room.
The first object is a Fog Of War that draws a GUI and reveals the map as the player moves, and keeps explored places visible but not in view.
The second object is the joystick where a player will use their thumb to drag the stick to move the player.
Ever since I have implemented the Fog of War. I have been unable to view the joystick. It appears that the fog of war draws overtop of it and I am unable to use it.
I understand there are other draw events where I can do this.
Draw
Draw GUI
Draw Begin
Draw End
Draw GUI BEGIN
Draw GUI END
After changing where I have the code drawing.
Example: At first the joystick and the fog were both in Draw GUI, After moving one from Draw GUI to Draw GUI Begin, the same issue appears.
I have made sure to place the joystick at the top most level in the room and the fog of war at the bottom most layer.
I have tried to apply depth the object
oJoystick_Stick.depth = -100;
this does not achieve anything.
Is there another way to force two objects on the GUI layer to be on top of the other?
To my understanding, DrawGUI always prioritises the objects drawn there above anything in Draw, including Begin Draw and End Draw. This is because DrawGUI is for an interface (like the stats you see about your character like health, ammo ect.), and objects drawn there aren't part of the room itself. You may also have noticed that the objects drawn in DrawGUI also follows the camera/Viewpoint.
So, to clear up the draw priority:
First is the DrawGUI layer that places objects in front of everything, like an interface.
After that, the depth variable and layers inside the room has priority, each layer has also given a depth value, with an interval of 100.
If the depth is also the same (for example when they're in the same layer), then the order of the objects and code loaded decides the order drawn.
The latter is not always reliable when multiple objects are overlapping at the same depth, because if the objects are redrawn in-game again (e.g. a persistent object been loaded into a new room, or pause and unpause using instance_activate_all), then the order of objects drawn may differ. Keep in mind when overlapping objects, that they are placed in different layers to prevent mixed priorities.
I've however not used a Fog of War system myself, so I don't know if it's build-in or not, but I wouldn't recommend placing them in the DrawGUI, as that should be reserved for the interface layout. With the default Draw options, you'll have more flexibility to the layers inside the room.
Some advice about DrawGUI
DrawGUI Begin --> call the event before every drawGUI in that moment
DrawGUI --------> the event is called sync with the screen refresh rate
DrawGUI End ----> call the event after every drawGUI in that moment
so GM-Studio "pipeline" for the DrawGUI is like the step event, we have a BEGIN, a CURRENT, an END.
To prioritize the object render, GM-Studio use the depth in-build variabile. Take the 0 as the reference value. Object with depth value > 0 are rendering as last. Object with depth value < 0 are rendering infront everything.
Check the depth during the calling of the instance_create_depth() function, check where the depth variabile is changing, check in the room editor for each instance layer the depth value. and z-order.

How to fix Blue Screen appearing after GameObject is removed in Unity 2d Project

I have been successfully building and running a Unity 2D game, but started receiving a Blue Screen during one of my operations. Specifically, when I close a popup and remove all of its child Game Objects, the entire Game Screen turns dark blue (the default background color of the main camera). The music for the game still plays and clicks are still registered if you click in the right area (I can still press the back button, just can't see it).
If I remove 1 gameobject, this problem doesn't come up. But once I have to remove 2 game objects, the entire screen turns blue.
This is my function for removing my game object in case it helps, which works perfectly when it comes to actually removing the gameObjects correctly (game objects to be removed are created from prefabs). I think the problem may be with the camera for some reason, but I have no clue as to why it happens on this function.
public void Remove(int index)
{
float toggleWidth = toggle.GetComponent<RectTransform>().sizeDelta.x;
DestroyImmediate(scrollSnap.pagination.transform.GetChild(scrollSnap.NumberOfPanels - 1).gameObject);
scrollSnap.Remove(index);
scrollSnap.pagination.transform.position += new Vector3(toggleWidth / 2f, 0, 0);
}
I don't receive any errors or warnings in the console. Just a blue screen once more than one GameObject is removed
EDIT:
Turns out my main Canvas's planeDistance was being changed from 100 to 3200. I still have no clue as to why this change occurred...but for anyone else having a similar issue with a dark blue screen appearing in the middle or start of their game, then please check the values your canvas and camera in the Inspector. Simply controlling the planeDistance did the trick for me!
Made a new scene next to the sample scene when i started my sprite learning game. Forgot all about that.
When I had to publish it, In the Build Settings, I had the wrong scene selected. So It published an empty scene instead of my game.
I solved it by putting game in 3d mode and realized that the camera is positioned very far from the sprites, just change the z-axis and again go to 2d mode.
Just Move your camera in Z-axis position, it could be too far from object or it is behind the object, you can also check it by 3D mode the check the object position and change it in positive and negative values.

Three.js Position and visibile issue

Currently, I am trying to dive deeper into grouped objects or better hierachic ordered objects. However I got a strange issue with the position and the visibility of a object3D and childs of those.
So i have a set of objects, a light source with is the main object so far, and a few spheres for example, which are childs of the the main object.
The problem is, that child objects, which are positioned behind another object ( siblings ) ( from the camera view ) are visible. And all childs objects appear infront of the main object while those actually positioned behind the main object.
Sadly i can't reproduce this in a codePen so i had to take some pictures of the scene, many apologies for that.
In the pictures, the camera rotates clockwise around the light source (main object to the left).
So basically what I am doing is:
mObj = new THREE.Object3D();
mObj.add(new THREE.Mesh(someGeometry, someMaterial);
cObj = new THREE.Object3D();
cObj.add(new THREE.Mesh(someGeometry, someMaterial);
mObj.add(cObj);
scene.add(mObj);
Is that related to the object hierachic order or something else?
The second more negligible issue is, that on one of my pc's, those parts of objects which are dark (because of no lighting), generate those strange black/grey faces, which i cant explain. Maybe Graphicscard/driver or something?
What's the distance between these objects? It could be a floating point rounding issue. I've run into it myself.
If it's so, and you're getting flickering models, you'll need to keep your camera and the active model at the origin, and move the universe around you to keep precision in the important places (near the player).

Transition between different points of views (SCNCameras) in SceneView

I've built a basic scene for SceneKit, including several SCNNodes with geometries, SCNLights, and an SCNCamera. I would now like to add functionality whereby the point of view shifts between different camera positions when the user taps on the screen.
What is the best way to achieve this? Should I include several SCNCameras in the scene and switch sceneView.pointOfView between them? Or should I rather update the position (and orientation) of a single camera. Also, how can I specify the transition path from moving from the old to the new camera position, i.e. use animation for the transition.
changing the pointOfView of the view is the easiest way. But if you want to control the path you will have to move the camera yourself. You can do that with SCNAction or by using CoreAnimation explicit or implicit animations.

Resources