Selaa lähdekoodia

Change parameters of the scenes due to changes in the calculations of the Image Tracker. Add initialization flags.

customisations
alemart 9 kuukautta sitten
vanhempi
commit
d36a2ebb15

+ 2
- 2
demos/hello-aframe/index.html Näytä tiedosto

83
             <ar-root reference-image="mage">
83
             <ar-root reference-image="mage">
84
 
84
 
85
                 <!-- Switch from top view to front view -->
85
                 <!-- Switch from top view to front view -->
86
-                <a-entity rotation="-90 0 0" position="0 -0.5 0">
86
+                <a-entity rotation="-90 0 0" position="0 -0.8 0">
87
 
87
 
88
                     <!-- Light -->
88
                     <!-- Light -->
89
                     <a-light type="ambient" intensity="1.5"></a-light>
89
                     <a-light type="ambient" intensity="1.5"></a-light>
106
 
106
 
107
             <!-- The cat -->
107
             <!-- The cat -->
108
             <ar-root reference-image="cat">
108
             <ar-root reference-image="cat">
109
-                <a-entity rotation="-90 0 0" position="0 -0.5 0">
109
+                <a-entity rotation="-90 0 0" position="0 -0.8 0">
110
                     <a-light type="ambient" intensity="1.5"></a-light>
110
                     <a-light type="ambient" intensity="1.5"></a-light>
111
 
111
 
112
                     <a-entity
112
                     <a-entity

+ 2
- 2
demos/hello-aframe/video.html Näytä tiedosto

83
             <ar-root reference-image="mage">
83
             <ar-root reference-image="mage">
84
 
84
 
85
                 <!-- Switch from top view to front view -->
85
                 <!-- Switch from top view to front view -->
86
-                <a-entity rotation="-90 0 0" position="0 -0.5 0">
86
+                <a-entity rotation="-90 0 0" position="0 -0.8 0">
87
 
87
 
88
                     <!-- Light -->
88
                     <!-- Light -->
89
                     <a-light type="ambient" intensity="1.5"></a-light>
89
                     <a-light type="ambient" intensity="1.5"></a-light>
106
 
106
 
107
             <!-- The cat -->
107
             <!-- The cat -->
108
             <ar-root reference-image="cat">
108
             <ar-root reference-image="cat">
109
-                <a-entity rotation="-90 0 0" position="0 -0.5 0">
109
+                <a-entity rotation="-90 0 0" position="0 -0.8 0">
110
                     <a-light type="ambient" intensity="1.5"></a-light>
110
                     <a-light type="ambient" intensity="1.5"></a-light>
111
 
111
 
112
                     <a-entity
112
                     <a-entity

+ 12
- 2
demos/hello-babylon/demo.js Näytä tiedosto

18
         super();
18
         super();
19
 
19
 
20
         this._objects = { };
20
         this._objects = { };
21
+        this._initialized = false;
21
     }
22
     }
22
 
23
 
23
     /**
24
     /**
99
         });
100
         });
100
 
101
 
101
         // Change the point of view - slightly
102
         // Change the point of view - slightly
102
-        ar.root.position.y = -0.5;
103
+        ar.root.position.y = -0.8;
103
 
104
 
104
         // Initialize objects
105
         // Initialize objects
105
         this._initLight(ar);
106
         this._initLight(ar);
110
             this._initMage(ar),
111
             this._initMage(ar),
111
             this._initCat(ar),
112
             this._initCat(ar),
112
         ]);
113
         ]);
114
+
115
+        // done!
116
+        this._initialized = true;
113
     }
117
     }
114
 
118
 
115
     /**
119
     /**
130
 
134
 
131
     _initLight(ar)
135
     _initLight(ar)
132
     {
136
     {
133
-        const light = new BABYLON.HemisphericLight('light', BABYLON.Vector3.Down());
137
+        const light = new BABYLON.HemisphericLight('light', BABYLON.Vector3.Up());
134
         light.intensity = 1.0;
138
         light.intensity = 1.0;
135
         light.diffuse.set(1, 1, 0.9);
139
         light.diffuse.set(1, 1, 0.9);
136
         light.specular.set(0, 0, 0);
140
         light.specular.set(0, 0, 0);
229
 
233
 
230
     _onTargetFound(referenceImage)
234
     _onTargetFound(referenceImage)
231
     {
235
     {
236
+        // make sure that the scene is initialized
237
+        if(!this._initialized) {
238
+            alert(`Target \"${referenceImage.name}\" was found, but the 3D scene is not yet initialized!`);
239
+            return;
240
+        }
241
+
232
         // change the scene based on the tracked image
242
         // change the scene based on the tracked image
233
         switch(referenceImage.name) {
243
         switch(referenceImage.name) {
234
             case 'mage':
244
             case 'mage':

+ 12
- 2
demos/hello-three/demo.js Näytä tiedosto

92
         super();
92
         super();
93
 
93
 
94
         this._objects = { };
94
         this._objects = { };
95
+        this._initialized = false;
95
     }
96
     }
96
 
97
 
97
     /**
98
     /**
169
         // ar.root, a node that is automatically aligned to the physical scene.
170
         // ar.root, a node that is automatically aligned to the physical scene.
170
         // Adjusting ar.root will adjust all virtual objects.
171
         // Adjusting ar.root will adjust all virtual objects.
171
         Utils.switchToFrontView(ar);
172
         Utils.switchToFrontView(ar);
172
-        ar.root.position.set(0, -0.5, 0);
173
+        ar.root.position.set(0, -0.8, 0);
173
 
174
 
174
-        // initialize objects
175
+        // Initialize objects
175
         this._initLight(ar);
176
         this._initLight(ar);
176
         this._initText(ar);
177
         this._initText(ar);
177
         this._initMagicCircle(ar);
178
         this._initMagicCircle(ar);
180
             this._initMage(ar),
181
             this._initMage(ar),
181
             this._initCat(ar),
182
             this._initCat(ar),
182
         ]);
183
         ]);
184
+
185
+        // done!
186
+        this._initialized = true;
183
     }
187
     }
184
 
188
 
185
     /**
189
     /**
298
 
302
 
299
     _onTargetFound(referenceImage)
303
     _onTargetFound(referenceImage)
300
     {
304
     {
305
+        // make sure that the scene is initialized
306
+        if(!this._initialized) {
307
+            alert(`Target \"${referenceImage.name}\" was found, but the 3D scene is not yet initialized!`);
308
+            return;
309
+        }
310
+
301
         // change the scene based on the tracked image
311
         // change the scene based on the tracked image
302
         switch(referenceImage.name) {
312
         switch(referenceImage.name) {
303
             case 'mage':
313
             case 'mage':

Loading…
Peruuta
Tallenna