quiz game scoring system
This commit is contained in:
@@ -3,31 +3,32 @@ import { assignParams } from "@/lib/MeshUtils";
|
||||
|
||||
class ImageObject {
|
||||
constructor(engine, obj) {
|
||||
var t = new TextureLoader().setPath(obj.path).load(obj.value);
|
||||
//t.encoding = sRGBEncoding;
|
||||
var mp = {
|
||||
map: t,
|
||||
alphaTest: 0.5
|
||||
};
|
||||
if (obj.nm) {
|
||||
mp.normalMap = new TextureLoader().setPath(obj.path).load(obj.nm);
|
||||
}
|
||||
if (obj.em) {
|
||||
mp.emissiveMap = new TextureLoader().setPath(obj.path).load(obj.em);
|
||||
}
|
||||
if (obj.am) {
|
||||
mp.alphaMap = new TextureLoader().setPath(obj.path).load(obj.am);
|
||||
}
|
||||
obj.material && Object.assign(mp, obj.material);
|
||||
let geo = new PlaneGeometry(obj.width || 1, obj.height || 1);
|
||||
if (obj.uv) {
|
||||
var uvAttribute = geo.attributes.uv;
|
||||
for (var i = 0; i < uvAttribute.count; i++) {
|
||||
uvAttribute.setXY(i, obj.uv[2 * i], obj.uv[2 * i + 1]);
|
||||
return new Promise(async(resolve, reject)=>{
|
||||
var t = await engine.loadTexture(obj.value, obj.path)
|
||||
var mp = {
|
||||
map: t,
|
||||
alphaTest: 0.5
|
||||
};
|
||||
if (obj.nm) {
|
||||
mp.normalMap = new TextureLoader().setPath(obj.path).load(obj.nm);
|
||||
}
|
||||
}
|
||||
this.object = new Mesh(geo, mp.metalness ? new MeshStandardMaterial(mp) : new MeshBasicMaterial(mp));
|
||||
assignParams(this.object, obj);
|
||||
if (obj.em) {
|
||||
mp.emissiveMap = new TextureLoader().setPath(obj.path).load(obj.em);
|
||||
}
|
||||
if (obj.am) {
|
||||
mp.alphaMap = new TextureLoader().setPath(obj.path).load(obj.am);
|
||||
}
|
||||
obj.material && Object.assign(mp, obj.material);
|
||||
let geo = new PlaneGeometry(obj.width || 1, obj.height || 1);
|
||||
if (obj.uv) {
|
||||
var uvAttribute = geo.attributes.uv;
|
||||
for (var i = 0; i < uvAttribute.count; i++) {
|
||||
uvAttribute.setXY(i, obj.uv[2 * i], obj.uv[2 * i + 1]);
|
||||
}
|
||||
}
|
||||
this.object = new Mesh(geo, mp.metalness ? new MeshStandardMaterial(mp) : new MeshBasicMaterial(mp));
|
||||
resolve(this)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user