Hi,
I have attached a video for reference. As shown in the video, the model flickers when zooming in or moving it to certain positions. However, the model appears fine when no action is applied.
link to video: Game creator Ks's Video - Dec 12, 2024
Hi Ashok,
Model flickering during zoom or movement is often caused by rendering or depth buffer issues. Here are some steps you can take to troubleshoot and potentially resolve the issue:
-
Check Model Normals: Ensure your model’s normals are correctly defined. Incorrect normals can lead to visual artifacts during transformations.
-
Material Settings: Verify if your material’s settings in the shader are configured properly. If you’re using transparent shaders, ensure that blending and depth testing settings are correct.
-
Camera Settings: Make sure the near and far clipping planes of your camera are set appropriately. Extremely close or far values can cause flickering.
-
Render Order: If there are multiple overlapping objects, ensure they are rendered in the correct order. Check their z-index and ensure they are set up correctly in the scene.
-
Update Three.js: If you are using an older version of Three.js, consider upgrading. The flickering issue might have been addressed in newer releases.
-
Shader Precision: If you are using custom shaders, ensure you are not facing precision issues, which may occur on certain hardware due to low floating-point precision if not specified.
Given the information above, you may want to review how your models and materials are set up. If the issue persists, you might want to isolate the model and simplify the scene to identify if a specific component is causing the flicker.
For detailed reference, consult the following resources:
If you need more specific guidance, such as the particular code handling the model, please share snippets of relevant code or any settings being applied to the models during movement or zooming.
1 replies left - Get a PRO license for more AI replies.
thread_Nsf6fuRbk7XMmH4Ofy5oCcAQ
Reply to this message to continue the conversation
You mostly refer to this part here? The white box?
Because this looks to me like z fighting (two opaque elements being TOO close to each other with your current camera near+far plane, similar to what the bot said)
You can try to decrease the far plane or increase the near plane to lessen the range - that’s the most common cause - OR to move these parts a little bit further apart in your scene.
Hello @ashok_99 did you try my suggestion above?
Yes, moving the parts a bit further cleared the issue. Thanks
Hi, another question not related to this.
import { Behaviour, serializable, GameObject, Camera, FileReference, SceneSwitcher, AssetReference } from “@needle-tools/engine”;
@serializable(AssetReference)
sceneContainer:AssetReference = ;
for some reason I cant assign scenes into sceneContainer through inspector. it only accepts Prefabs and gameobjects
You need to drag-drop the scene asset into the field in Unity (you can look at the Multi scene sample as a reference)
Drag and dropping works only in given sceneSwitcher script
This is the generated c# code related to this.
public UnityEngine.Transform @sceneContainer = new UnityEngine.Transform{ };
They use the same code. Can you show your C# script and the full typescript code?
Sure.
ts:
import { Behaviour, serializable, GameObject, Camera, FileReference, SceneSwitcher, AssetReference } from "@needle-tools/engine";
import { ComponentData, ModelSourceData } from "./CustomClassesContainer";
import { StepDataSource } from "./StepDataSource";
export class ComponentDataContainer extends Behaviour {
@serializable()
componentObjects: GameObject[] = [];
@serializable(ComponentData)
sequenceComponentHideList: ComponentData[] = [];
@serializable(Camera)
baseCamera?: Camera;
@serializable(ModelSourceData)
modelSourceData?: ModelSourceData;
@serializable(FileReference)
jsonData?: FileReference;
@serializable(StepDataSource)
currentStepDataSource?:StepDataSource|null;
@serializable(SceneSwitcher)
sceneSwitcher?:SceneSwitcher;
sequenceIndex:number = 0;
@serializable(AssetReference)
sceneContainer:AssetReference[] = [];
public static instance: ComponentDataContainer;
async awake() {
ComponentDataContainer.instance = this;
const data = await this.jsonData?.loadText();
if (data) this.modelSourceData = JSON.parse(data);
console.log(this.modelSourceData);
}
start(): void {
//this.currentStepDataSource = GameObject.findObjectOfType(StepDataSource);
}
setBaseCameraPosition(cam: Camera) {
this.baseCamera?.setWorldPosition(cam.worldPosition.x, cam.worldPosition.y, cam.worldPosition.z);
this.baseCamera?.setWorldRotation(cam.worldRotation.x, cam.worldRotation.y, cam.worldRotation.z);
}
sceneChangeEvent(){
console.log("Scene loaded");
//this.currentStepDataSource = GameObject.findObjectOfType(StepDataSource);
}
}
c#:
// NEEDLE_CODEGEN_START
// auto generated code - do not edit directly
#pragma warning disable
namespace Needle.Typescript.GeneratedComponents
{
public partial class ComponentDataContainer : UnityEngine.MonoBehaviour
{
public UnityEngine.GameObject[] @componentObjects = new UnityEngine.GameObject[]{ };
public ComponentData[] @sequenceComponentHideList = new ComponentData[]{ };
public UnityEngine.Camera @baseCamera;
public ModelSourceData @modelSourceData;
public Needle.Engine.FileReference @jsonData;
public Needle.Typescript.GeneratedComponents.StepDataSource @currentStepDataSource;
public Needle.Engine.Components.SceneSwitcher @sceneSwitcher;
public float @sequenceIndex = 0f;
public UnityEngine.Transform[] @sceneContainer = new UnityEngine.Transform[]{ };
public void awake(){}
public void start(){}
public void setBaseCameraPosition(UnityEngine.Camera @cam){}
public void sceneChangeEvent(){}
}
}
// NEEDLE_CODEGEN_END
Ok that looks wrong. Which Engine version are you using? Can you show a screenshot of the component compiler component in your scene?
As a workaround you can annotate the expected type, see docs here with // @type: Automatic Component Generation | Needle Engine Documentation
The screenshot is from the Export component, can you send one with the component compiler in the scene? It’s usually below that one.
The AssetReference type is in the Needle.Engine.Common.Runtime asmdef and the fullname is Needle.Engine.AssetReference
so you want to add // @type Needle.Engine.AssetReference[]
above the field in typescript that doesnt generate correctly
Thanks, it worked. My scene doesn’t have a component generator component
Ok so your code is inside a npmdef package? Could you share a screenshot of the npmdef package inspector then?
This topic was automatically closed 13 days after the last reply. New replies are no longer allowed.