plane size depends on image size (factor 100)

This commit is contained in:
Ruben van de Ven 2020-06-19 17:50:50 +02:00
parent 1819b35404
commit c4ce456af0

View file

@ -413,10 +413,18 @@ class ParadeImage {
makeMesh(scene, config) {
this.mesh = new BABYLON.TransformNode();
var img = new Image();
let self = this; // use in callback
img.onload = function() {
// we preload the image, so we can create the plane based on image dimensions
// see https://www.html5gamedevs.com/topic/8917-textures-source-image-aspect-ratio/?do=findComment&comment=52949
var planeOptions = {
// TODO: should size be dynamic?
height: 5.4762,
width: 7.3967,
height: this.height/100,
width: this.width/100,
sideOrientation: BABYLON.Mesh.DOUBLESIDE // texture should be visible from front and back
};
@ -424,11 +432,14 @@ class ParadeImage {
var imageMat = new BABYLON.StandardMaterial("m", scene);
imageMat.diffuseTexture = new BABYLON.Texture(this.getImageUrl(), scene);
imageMat.diffuseTexture = new BABYLON.Texture(self.getImageUrl(), scene);
imageMat.roughness = 1;
imageMat.emissiveColor = new BABYLON.Color3.White();
imagePlane.material = imageMat;
imagePlane.parent = this.mesh;
imagePlane.parent = self.mesh;
}
img.src = this.getImageUrl();
// text https://www.babylonjs-playground.com/#TMHF80
// TODO: cleanup this mess of the dynamic texture: