Print at Dec 19, 2025, 8:31:42 AM View all posts in this thread on one page
Posted by cbcomputer at Aug 31, 2018, 11:37:31 AM
AddLabel WebGL
Bonjour,
j'essaye d'ajouter un label dynamique apres le chargement du plugin WebGl ViewHome mais ca marche pas
pouvez vous m'aider ?
Merci


var retour = viewHome("viewerCanvas", // Id of the canvas
homeUrl, // URL or relative URL of the home to display
onerror, // Callback called in case of error
onprogression, // Callback called while loading
{
roundsPerMinute: 0, // Rotation speed of the animation launched once home is loaded in rounds per minute, no animation if missing or equal to 0
navigationPanel: "none", // Displayed navigation arrows, "none" or "default" for default one or an HTML string containing elements with data-simulated-key
// attribute set "UP", "DOWN", "LEFT", "RIGHT"... to replace the default navigation panel, "none" if missing
aerialViewButtonId: "aerialView", // Id of the aerial view radio button, radio buttons hidden if missing

levelsAndCamerasListId: "levelsAndCameras", // Id of the levels and cameras select component, hidden if missing
/* level: "Roof", */ // Uncomment to select the displayed level, default level if missing */
/* selectableLevels: ["Ground floor", "Roof"], */ // Uncomment to choose the list of displayed levels, no select component if empty array */
/* camera: "Exterior view", */ // Uncomment to select a camera, default camera if missing */
/* selectableCameras: ["Exterior view", "Kitchen"], */ // Uncomment to choose the list of displayed cameras, no camera if missing */
activateCameraSwitchKey: true // Switch between top view / virtual visit with space bar if not false or missing */
});



//r = <label level='level0' x='1222.611' y='218.17773' elevation='250.0' pitch='0.0'>
// <textStyle fontSize='100.0' />
//<text>OTA</text>
//</label>


// var l = this.createLabel(r, "test");
//this.setLabelAttributes(l, "label", r);
// this.home.addLabel(l);



setTimeout(macreationlabel, 5000,retour);


function macreationlabel(retour) {

var mylabel = new Label();
mylabel.x = '1200.00';
mylabel.y = '218.00';
mylabel.pitch = '0.0';
mylabel.elevation = '250.0';
mylabel.text = "toto";
mylabel.level = 'level0';
mylabel.setStyle("fontSize='100.0'");


this.retour.home.addLabel(mylabel);



}


</script>


Posted by Puybaret at Sep 1, 2018, 7:55:28 PM
Re: AddLabel WebGL
Bonjour,

Il semblerait que ce soit surtout des problèmes d'utilisation de l'API :
- La classe Label a un constructeur avec 3 paramètres
- Les modifications des valeurs des attributs x, y, pitch... et surtout level devrait s'effectuer avec les méthodes set... de la classe Label
- Si vous utilisez des niveaux dans votre logement, vous pouvez récupérer les objets de classe Level avec la méthode getLevels de la classe Home. Sinon, pas besoin d'appeler setLevel
- La méthode setStyle prend un objet de classe TextStyle

Vous pourriez aussi regarder dans le code source de Sweet Home 3D JS le test testHome.html qui crée un label (entre autres choses).

Sinon quelles erreurs avez-vous dans la console JavaScript?
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator