Sfoglia il codice sorgente

Update the hello-three demo

customisations
alemart 11 mesi fa
parent
commit
442d5a954f
1 ha cambiato i file con 13 aggiunte e 12 eliminazioni
  1. 13
    12
      demos/hello-three/demo.js

+ 13
- 12
demos/hello-three/demo.js Vedi File

@@ -1,7 +1,6 @@
1 1
 /**
2 2
  * Augmented Reality demo using the three.js plugin for encantar.js
3
- * @author Alexandre Martins (https://github.com/alemart)
4
- * https://alemart.github.io/encantar-js/
3
+ * @author Alexandre Martins <alemartf(at)gmail.com> (https://github.com/alemart/encantar-js)
5 4
  */
6 5
 
7 6
 (function() {
@@ -37,7 +36,12 @@ class DemoUtils
37 36
         if(clips.length == 0)
38 37
             throw new Error('No animation clips');
39 38
 
40
-        const clip = (name !== null) ? THREE.AnimationClip.findByName(clips, name) : clips[0];
39
+        if(name === null) {
40
+            const sortedNames = clips.map(clip => clip.name).sort();
41
+            name = sortedNames[0];
42
+        }
43
+
44
+        const clip = THREE.AnimationClip.findByName(clips, name);
41 45
         const action = mixer.clipAction(clip);
42 46
 
43 47
         return action;
@@ -156,7 +160,7 @@ class DemoScene extends ARScene
156 160
 
157 161
     /**
158 162
      * Initialize the augmented scene
159
-     * @param {ARPluginSystem} ar
163
+     * @param {ARSystem} ar
160 164
      * @returns {Promise<void>}
161 165
      */
162 166
     async init(ar)
@@ -168,19 +172,16 @@ class DemoScene extends ARScene
168 172
         ar.root.position.set(0, -0.5, 0);
169 173
         ar.root.scale.set(0.7, 0.7, 0.7);
170 174
 
171
-        // add lights
175
+        // add light
172 176
         const ambientLight = new THREE.AmbientLight(0xffffff);
177
+        ambientLight.intensity = 1.4;
173 178
         ar.scene.add(ambientLight);
174 179
 
175
-        const directionalLight = new THREE.DirectionalLight(0xffffff);
176
-        directionalLight.position.set(0, 0, 3);
177
-        ar.root.add(directionalLight);
178
-
179 180
         // create the magic circle
180 181
         const magicCircle = this._utils.createImagePlane('../assets/magic-circle.png');
181 182
         magicCircle.material.color = new THREE.Color(0xbeefff);
182 183
         magicCircle.material.transparent = true;
183
-        magicCircle.material.opacity = 0.85;
184
+        magicCircle.material.opacity = 1;
184 185
         magicCircle.scale.set(6, 6, 1);
185 186
         ar.root.add(magicCircle);
186 187
 
@@ -190,7 +191,7 @@ class DemoScene extends ARScene
190 191
         ar.root.add(mage);
191 192
 
192 193
         // prepare the animation of the mage
193
-        const animationAction = this._utils.createAnimationAction(gltf);
194
+        const animationAction = this._utils.createAnimationAction(gltf, 'Idle');
194 195
         animationAction.loop = THREE.LoopRepeat;
195 196
         animationAction.play();
196 197
 
@@ -202,7 +203,7 @@ class DemoScene extends ARScene
202 203
 
203 204
     /**
204 205
      * Update / animate the augmented scene
205
-     * @param {ARPluginSystem} ar
206
+     * @param {ARSystem} ar
206 207
      * @returns {void}
207 208
      */
208 209
     update(ar)

Loading…
Annulla
Salva