AddLabel WebGL

This topic has been viewed 1906 times and has 1 replies
Thread status: Active
Vos suggestions et questions en français [img]http://www.sweethome3d.com/images/flags/fr_small.gif[/img]
Post Reply New Topic
cbcomputer
Posts: 1
Joined: Fri Aug 31, 2018 9:33 am
Country: France

AddLabel WebGL

Post by cbcomputer »

Bonjour,
j'essaye d'ajouter un label dynamique apres le chargement du plugin WebGl ViewHome mais ca marche pas
pouvez vous m'aider ?
Merci

Code: Select all


 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>
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: AddLabel WebGL

Post by Puybaret »

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 [font=courier new]set...[/font] de la classe [font=courier new]Label[/font]
- Si vous utilisez des niveaux dans votre logement, vous pouvez récupérer les objets de classe Level avec la méthode [font=courier new]getLevels[/font] de la classe Home. Sinon, pas besoin d'appeler [font=courier new]setLevel[/font]
- La méthode [font=courier new]setStyle[/font] 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
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 2 guests