소스 검색

Update the hello-three demo

customisations
alemart 11 달 전
부모
커밋
442d5a954f
1개의 변경된 파일13개의 추가작업 그리고 12개의 파일을 삭제
  1. 13
    12
      demos/hello-three/demo.js

+ 13
- 12
demos/hello-three/demo.js 파일 보기

1
 /**
1
 /**
2
  * Augmented Reality demo using the three.js plugin for encantar.js
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
 (function() {
6
 (function() {
37
         if(clips.length == 0)
36
         if(clips.length == 0)
38
             throw new Error('No animation clips');
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
         const action = mixer.clipAction(clip);
45
         const action = mixer.clipAction(clip);
42
 
46
 
43
         return action;
47
         return action;
156
 
160
 
157
     /**
161
     /**
158
      * Initialize the augmented scene
162
      * Initialize the augmented scene
159
-     * @param {ARPluginSystem} ar
163
+     * @param {ARSystem} ar
160
      * @returns {Promise<void>}
164
      * @returns {Promise<void>}
161
      */
165
      */
162
     async init(ar)
166
     async init(ar)
168
         ar.root.position.set(0, -0.5, 0);
172
         ar.root.position.set(0, -0.5, 0);
169
         ar.root.scale.set(0.7, 0.7, 0.7);
173
         ar.root.scale.set(0.7, 0.7, 0.7);
170
 
174
 
171
-        // add lights
175
+        // add light
172
         const ambientLight = new THREE.AmbientLight(0xffffff);
176
         const ambientLight = new THREE.AmbientLight(0xffffff);
177
+        ambientLight.intensity = 1.4;
173
         ar.scene.add(ambientLight);
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
         // create the magic circle
180
         // create the magic circle
180
         const magicCircle = this._utils.createImagePlane('../assets/magic-circle.png');
181
         const magicCircle = this._utils.createImagePlane('../assets/magic-circle.png');
181
         magicCircle.material.color = new THREE.Color(0xbeefff);
182
         magicCircle.material.color = new THREE.Color(0xbeefff);
182
         magicCircle.material.transparent = true;
183
         magicCircle.material.transparent = true;
183
-        magicCircle.material.opacity = 0.85;
184
+        magicCircle.material.opacity = 1;
184
         magicCircle.scale.set(6, 6, 1);
185
         magicCircle.scale.set(6, 6, 1);
185
         ar.root.add(magicCircle);
186
         ar.root.add(magicCircle);
186
 
187
 
190
         ar.root.add(mage);
191
         ar.root.add(mage);
191
 
192
 
192
         // prepare the animation of the mage
193
         // prepare the animation of the mage
193
-        const animationAction = this._utils.createAnimationAction(gltf);
194
+        const animationAction = this._utils.createAnimationAction(gltf, 'Idle');
194
         animationAction.loop = THREE.LoopRepeat;
195
         animationAction.loop = THREE.LoopRepeat;
195
         animationAction.play();
196
         animationAction.play();
196
 
197
 
202
 
203
 
203
     /**
204
     /**
204
      * Update / animate the augmented scene
205
      * Update / animate the augmented scene
205
-     * @param {ARPluginSystem} ar
206
+     * @param {ARSystem} ar
206
      * @returns {void}
207
      * @returns {void}
207
      */
208
      */
208
     update(ar)
209
     update(ar)

Loading…
취소
저장