Yo herbst, What do you suggest I do to make the models load only when the image is detected?
by user 392979063620501504
Yo herbst, What do you suggest I do to make the models load only when the image is detected?
by user 392979063620501504
@herbst:cactus: the rotation and clipping has been fixed but please do let me know what I could do to make the models appear only when the image is detected
by user 392979063620501504
Also there seems to be this green square that just shows up randomly in the image track, I have made the new file three times and the cube still appears curiously (can be seen in above video)
by user 392979063620501504
Hey, I used chatgpt to write some code to see if it could make the model load in when the image is detected
`import { Behaviour, GameObject, AssetReference } from “@needle-tools/engine”;
class DetecttoLoad extends Behaviour {
private onImageTrackingUpdate = (event: any) => {
const trackedImages = event.detail;
for (const trackedImage of trackedImages) {
// Check if the tracked image corresponds to the model you want to load
if (this.shouldLoadModel(trackedImage)) {
this.loadModel(trackedImage);
}
}
};
private shouldLoadModel(trackedImage: any): boolean {
// Replace this with your own criteria for deciding when to load the model
return trackedImage.model && trackedImage.model.object !== null;
}
private loadModel(trackedImage: any) {
// Use the trackedImage data to decide which model to load
const modelReference = trackedImage.model.object;
// Check if the model is not already loaded
if (!modelReference.isLoaded) {
modelReference.loadAssetAsync().then((asset: GameObject | null) => {
if (asset) {
// Add the model to the scene or manipulate it as needed
this.context.scene.add(asset);
// Apply the tracked image's position and rotation to the model
trackedImage.applyToObject(asset);
}
});
}
}
onEnable(): void {
// Register the event listener for image tracking updates
this.addEventListener("image-tracking", this.onImageTrackingUpdate);
}
onDisable(): void {
// Unregister the event listener when the component is disabled
this.removeEventListener("image-tracking", this.onImageTrackingUpdate);
}
}
export default DetecttoLoad;`
by user 392979063620501504
Of course it didn’t work in Unity, but is this a start or something close? I don’t know
by user 392979063620501504
This is a bug with our handling of avatars in WebXR - you can empty the „avatar“ slot on the WebXR component to get rid of it
You shouldn’t need this at all, image tracking will enable/disable the objects already
but in the recording the objects load and are present at the bottom till they detect the images, then load into place
by user 392979063620501504
Wait I’ll show it a lil more clearly
by user 392979063620501504
by user 392979063620501504
Also green box is gone so thanks for that
by user 392979063620501504
Also the gitchyness has been increasing for some reason
by user 392979063620501504
Is there an issue on my end?
by user 392979063620501504
I’ll submit a bug report from unity
by user 392979063620501504
Whenever I click continue, Open Desc File or close the popup it opens a blank VSCode editor
by user 392979063620501504
Hmm
by user 392979063620501504
You can also disable them in your scene if you want them disabled at start, they’ll get enabled by image tracking
Is that through XR flag?
by user 392979063620501504
Could you elaborate a lil bit please? sorry
by user 392979063620501504