Преглед на файлове

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

customisations
alemart преди 10 месеца
родител
ревизия
d36a2ebb15
променени са 4 файла, в които са добавени 28 реда и са изтрити 8 реда
  1. 2
    2
      demos/hello-aframe/index.html
  2. 2
    2
      demos/hello-aframe/video.html
  3. 12
    2
      demos/hello-babylon/demo.js
  4. 12
    2
      demos/hello-three/demo.js

+ 2
- 2
demos/hello-aframe/index.html Целия файл

@@ -83,7 +83,7 @@
83 83
             <ar-root reference-image="mage">
84 84
 
85 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 88
                     <!-- Light -->
89 89
                     <a-light type="ambient" intensity="1.5"></a-light>
@@ -106,7 +106,7 @@
106 106
 
107 107
             <!-- The cat -->
108 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 110
                     <a-light type="ambient" intensity="1.5"></a-light>
111 111
 
112 112
                     <a-entity

+ 2
- 2
demos/hello-aframe/video.html Целия файл

@@ -83,7 +83,7 @@
83 83
             <ar-root reference-image="mage">
84 84
 
85 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 88
                     <!-- Light -->
89 89
                     <a-light type="ambient" intensity="1.5"></a-light>
@@ -106,7 +106,7 @@
106 106
 
107 107
             <!-- The cat -->
108 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 110
                     <a-light type="ambient" intensity="1.5"></a-light>
111 111
 
112 112
                     <a-entity

+ 12
- 2
demos/hello-babylon/demo.js Целия файл

@@ -18,6 +18,7 @@ class EnchantedDemo extends ARDemo
18 18
         super();
19 19
 
20 20
         this._objects = { };
21
+        this._initialized = false;
21 22
     }
22 23
 
23 24
     /**
@@ -99,7 +100,7 @@ class EnchantedDemo extends ARDemo
99 100
         });
100 101
 
101 102
         // Change the point of view - slightly
102
-        ar.root.position.y = -0.5;
103
+        ar.root.position.y = -0.8;
103 104
 
104 105
         // Initialize objects
105 106
         this._initLight(ar);
@@ -110,6 +111,9 @@ class EnchantedDemo extends ARDemo
110 111
             this._initMage(ar),
111 112
             this._initCat(ar),
112 113
         ]);
114
+
115
+        // done!
116
+        this._initialized = true;
113 117
     }
114 118
 
115 119
     /**
@@ -130,7 +134,7 @@ class EnchantedDemo extends ARDemo
130 134
 
131 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 138
         light.intensity = 1.0;
135 139
         light.diffuse.set(1, 1, 0.9);
136 140
         light.specular.set(0, 0, 0);
@@ -229,6 +233,12 @@ class EnchantedDemo extends ARDemo
229 233
 
230 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 242
         // change the scene based on the tracked image
233 243
         switch(referenceImage.name) {
234 244
             case 'mage':

+ 12
- 2
demos/hello-three/demo.js Целия файл

@@ -92,6 +92,7 @@ class EnchantedDemo extends ARDemo
92 92
         super();
93 93
 
94 94
         this._objects = { };
95
+        this._initialized = false;
95 96
     }
96 97
 
97 98
     /**
@@ -169,9 +170,9 @@ class EnchantedDemo extends ARDemo
169 170
         // ar.root, a node that is automatically aligned to the physical scene.
170 171
         // Adjusting ar.root will adjust all virtual objects.
171 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 176
         this._initLight(ar);
176 177
         this._initText(ar);
177 178
         this._initMagicCircle(ar);
@@ -180,6 +181,9 @@ class EnchantedDemo extends ARDemo
180 181
             this._initMage(ar),
181 182
             this._initCat(ar),
182 183
         ]);
184
+
185
+        // done!
186
+        this._initialized = true;
183 187
     }
184 188
 
185 189
     /**
@@ -298,6 +302,12 @@ class EnchantedDemo extends ARDemo
298 302
 
299 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 311
         // change the scene based on the tracked image
302 312
         switch(referenceImage.name) {
303 313
             case 'mage':

Loading…
Отказ
Запис