Hello,
Iām working on a scene with text and icons embeded into textures, and I need to load the in full resolution at the loading of the page.
Iāve tried to load without mipmap after a delay and it was starting to work, but the progressive loading seems to be a priority.
My goal is to target some gameobjects containing textures to display their best resolution available.
Here is the script Iām using:
import { Behaviour, GameObject, MeshRenderer } from "@needle-tools/engine";
import { serializable } from "@needle-tools/engine";
import { MeshStandardMaterial, LinearFilter } from "three";
export class TextureQualityEnforcer extends Behaviour {
@serializable(GameObject)
public targetObjects: GameObject[] = [];
// Un champ pour rƩgler le dƩlai en secondes depuis l'inspecteur
@serializable()
public applyDelay: number = 1;
// On transforme "start" en fonction asynchrone pour utiliser "await"
async start() {
// On attend le dƩlai spƩcifiƩ avant d'exƩcuter le reste du code
await this.delay(this.applyDelay * 1000);
for (const target of this.targetObjects) {
if (!target) continue;
const renderer = target.getComponent(MeshRenderer);
if (!renderer) continue;
const material = renderer.sharedMaterial as MeshStandardMaterial;
if (!material || !material.map) continue;
const texture = material.map;
console.log(`Application des réglages HQ sur ${target.name} après ${this.applyDelay}s.`);
// On dit au moteur de ne pas gƩnƩrer/utiliser de mipmaps
texture.generateMipmaps = false;
// On applique les autres rƩglages de qualitƩ
texture.minFilter = LinearFilter;
texture.magFilter = LinearFilter;
const maxAniso = this.context.renderer.capabilities.getMaxAnisotropy();
texture.anisotropy = maxAniso;
// On signale au moteur que la texture doit ĆŖtre mise Ć jour
texture.needsUpdate = true;
}
}
private delay(ms: number): Promise<void> {
if (ms <= 0) return Promise.resolve();
return new Promise(resolve => setTimeout(resolve, ms));
}
}
Do you have another component that do the same action in Needle (4.7.4)?
Is there a fix into the code that can help to make it with your rendering process?
Cheers,
Corentin