wco_models 3.5.0.7 → 3.5.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/wco/main.scss +7 -3
  3. data/app/assets/stylesheets/wco/photos.scss +2 -1
  4. data/app/controllers/wco/office_action_templates_controller.rb +3 -0
  5. data/app/controllers/wco/publishers_controller.rb +6 -16
  6. data/app/controllers/wco/reports_controller.rb +6 -5
  7. data/app/controllers/wco/sitemap_paths_controller.rb +14 -2
  8. data/app/controllers/wco/sites_controller.rb +1 -1
  9. data/app/controllers/wco/tags_controller.rb +1 -1
  10. data/app/models/iro/option.rb +37 -4
  11. data/app/models/iro/priceitem.rb +62 -4
  12. data/app/models/tda/option.rb +39 -41
  13. data/app/models/wco/newspartial.rb +3 -2
  14. data/app/models/wco/publisher.rb +29 -8
  15. data/app/models/wco/publisher_d10.rb +50 -0
  16. data/app/models/wco/report.rb +12 -2
  17. data/app/models/wco/site.rb +1 -67
  18. data/app/models/wco/sitemap_path.rb +19 -13
  19. data/app/models/wco/tag.rb +15 -8
  20. data/app/models/wco/utils.rb +1 -1
  21. data/app/views/wco/api/newsproducer/README.txt +4 -0
  22. data/app/views/wco/api/newsproducer/_studio_blue2.js-bk +606 -0
  23. data/app/views/wco/api/newsproducer/_studio_blue2.js-bk2 +898 -0
  24. data/app/views/wco/api/newsproducer/studio_blue2.html.erb-bk +151 -0
  25. data/app/views/wco/office_action_templates/index.haml +1 -1
  26. data/app/views/wco/office_actions/_actions.haml +1 -1
  27. data/app/views/wco/publishers/_form.haml +11 -2
  28. data/app/views/wco/publishers/_post_with.haml +1 -1
  29. data/app/views/wco/reports/_form.haml +13 -2
  30. data/app/views/wco/reports/_index.haml +18 -11
  31. data/app/views/wco/reports/show.haml +6 -1
  32. data/app/views/wco/sitemap_paths/_index.haml +1 -0
  33. data/app/views/wco/sitemap_paths/show.haml +14 -0
  34. data/app/views/wco/sites/index.haml +6 -0
  35. data/app/views/wco/sites/show.haml +1 -1
  36. data/app/views/wco/tags/_form.haml +3 -0
  37. data/config/routes.rb +5 -5
  38. data/lib/shortcuts.rb +1 -1
  39. data/lib/wco_models.rb +1 -1
  40. metadata +8 -3
  41. data/app/views/wco/sitemap_paths/check.haml +0 -13
@@ -0,0 +1,606 @@
1
+
2
+ const scene_cfg = {
3
+ 'active_spot': 'spot_1',
4
+ 'spot_1': 'eve',
5
+ 'spot_2': 'gregor',
6
+ 'studio': 'collision-world',
7
+ 'active_camera': 'cam_wide',
8
+ 'light_ambient': 'on',
9
+ 'light_hemi': 'on',
10
+ 'light_key': 'on',
11
+ 'light_fill': 'on',
12
+ 'light_rim': 'on',
13
+ 'light_shadows': 'on',
14
+ }
15
+
16
+ const ISH_VERSION = 'v0.4.14'
17
+ const MODELS_ROOT = `https://cdn.jsdelivr.net/gh/wasya-co/ishlib3js@${ISH_VERSION}/public/vendor/models`
18
+
19
+
20
+ // const avatars = await fetch(`${MODELS_ROOT}/avatars/index.json`).then(r => r.json())
21
+ const avatars = {
22
+ brunette: { type: 'F', url: `${MODELS_ROOT}/avatars/brunette/model.glb` },
23
+ cara: { type: 'F', url: `${MODELS_ROOT}/avatars/cara/model.glb` }, // short hair
24
+ eve: { type: 'F', url: `${MODELS_ROOT}/avatars/eve/model.glb` }, // poison green
25
+ denis: { type: 'M', url: `${MODELS_ROOT}/avatars/denis/model.glb` }, // beard
26
+ gregor: { type: 'M', url: `${MODELS_ROOT}/avatars/gregor/model.glb` }, // gray shirt
27
+ }
28
+ $(`select.spots`).each((_idx, el) => {
29
+ const $spot = $(el)
30
+ $.each(avatars, function(name) {
31
+ $('<option>', { value: name, text: name }).appendTo($spot)
32
+ })
33
+ if ( scene_cfg[$spot.data('spot_id')] ) {
34
+ $spot.val( scene_cfg[$spot.data('spot_id')] )
35
+ }
36
+ })
37
+ let spot_positions = {
38
+ 'spot_1': [0, 0, 0],
39
+ 'spot_2': [1, 0, 0],
40
+ 'spot_3': [-1, 0, 0],
41
+ }
42
+
43
+
44
+ const studios = await fetch(`${MODELS_ROOT}/scenes/index.json`).then(r => r.json())
45
+ $.each(studios, (name) => {
46
+ $('<option>', { value: name, text: name }).appendTo($('select.studio'))
47
+ })
48
+ if ( scene_cfg['studio'] ) {
49
+ $(`select.studio`).val(saved)
50
+ }
51
+ let active_studio = studios[scene_cfg['studio']] || studios['collision-world']
52
+
53
+
54
+ let gestures = {
55
+ talking_1: (avatar) => `${MODELS_ROOT}/animation-library/feminine/fbx/expression/${avatar.body}_Talking_Variations_001.fbx`,
56
+ talking_4: (avatar) => `${MODELS_ROOT}/animation-library/feminine/fbx/expression/${avatar.body}_Talking_Variations_004.fbx`,
57
+ walk_1: { speed: 2.0, url: (a) => `${MODELS_ROOT}/animation-library/feminine/fbx/locomotion/${a.body}_Walk_001.fbx` },
58
+ walk_2: { speed: 2.0, url: (a) => `${MODELS_ROOT}/animation-library/feminine/fbx/locomotion/${a.body}_Walk_002.fbx` },
59
+
60
+ sitting: (a) => `${MODELS_ROOT}/animations/Sitting.fbx`,
61
+ sit_to_stand: (a) => `${MODELS_ROOT}/animations/Sit To Stand.fbx`,
62
+ stand_to_sit: (a) => `${MODELS_ROOT}/animations/Stand To Sit.fbx`,
63
+
64
+ entering_car: (a) => `${MODELS_ROOT}/animations/Entering Car.fbx`,
65
+ slow_run: { speed: 1.1, url: (a) => `${MODELS_ROOT}/animations/Slow Run.fbx`, }
66
+ };
67
+ $.each(gestures, (name) => {
68
+ $('<option>', { value: name, text: name }).appendTo($(`select.gesture`))
69
+ })
70
+ function gesture_url(g, avatar) {
71
+ if (typeof g === 'function') return g(avatar)
72
+ const u = g && g.url
73
+ return typeof u === 'function' ? u(avatar) : u
74
+ }
75
+
76
+
77
+
78
+ import * as THREE from 'three'
79
+
80
+ import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js'
81
+ import { FBXLoader } from 'three/addons/loaders/FBXLoader.js'
82
+ import { OrbitControls } from 'three/addons/controls/OrbitControls.js'
83
+
84
+ import { TalkingHead } from "talkinghead"
85
+
86
+ const params = new URLSearchParams(window.location.search)
87
+ const api_key = params.get('api_key')
88
+ const api_secret = params.get('api_secret')
89
+ const wco_origin = params.get('wco_origin')
90
+ const newspartial_id = params.get('newspartial_id')
91
+
92
+ let streamOpts = {
93
+ sampleRate: 8000,
94
+ mood: 'neutral',
95
+ gain: 0.5,
96
+ lipsyncType: "visemes",
97
+ lipsyncLang: "en",
98
+ waitForAudioChunks: false,
99
+ metrics: { enabled: false },
100
+ };
101
+
102
+ const onMetrics = (which) => {
103
+ logg(which, 'onMetrics')
104
+ }
105
+
106
+ const onSubtitles = (which) => {
107
+ logg(which, 'onSubtitles')
108
+ }
109
+
110
+
111
+ let width = 854
112
+ let height = 480
113
+ let slug = '<ccapture>'
114
+ const fps = 30
115
+
116
+ let frame = 0
117
+ let lastAnimTime = 0
118
+ let capturing = false
119
+ let captureFrame = 0
120
+ let captureTotal = 0
121
+ let totalFrames
122
+
123
+
124
+ let active_camera
125
+ let cameraTransition = null
126
+ const CAMERA_BLEND_MS = 900
127
+ let cameras = {
128
+ 'cam_wide': { 'cam': null, 'tgt': new THREE.Vector3(0.5, 1.2, 0) },
129
+ 'cam_1': { 'cam': null, 'tgt': new THREE.Vector3(0, 1.5, 0) },
130
+ 'cam_2': { 'cam': null, 'tgt': new THREE.Vector3(1, 1.5, 0) },
131
+ 'cam_3': { 'cam': null, 'tgt': new THREE.Vector3(-1, 1.5, 0) },
132
+
133
+ }
134
+ function cameras_fn(which) {
135
+ switch (which) {
136
+ case 'wide':
137
+ return camera_wide
138
+ case 'av_1':
139
+ return camera_1
140
+ case 'av_2':
141
+ return camera_2
142
+ case 'av_3':
143
+ return camera_3
144
+ default:
145
+ logg('fpq - cameras_fn default - this should never happen')
146
+ return camera_wide
147
+ }
148
+ }
149
+
150
+
151
+ let controls, renderer, scene
152
+ let head, head_1, head_2, head_3
153
+ let avatar_1, avatar_2, avatar_3
154
+ let faceTarget = new THREE.Vector3()
155
+
156
+
157
+
158
+ let chunkedInput = null
159
+ const lights = {}
160
+ var capturer = new CCapture( { format: 'webm', framerate: fps } )
161
+ const gltfLoader = new GLTFLoader()
162
+ const loading = document.getElementById('loading')
163
+ const status = document.getElementById('status')
164
+
165
+
166
+ /*
167
+ **/
168
+ function setup_light(scene) {
169
+ lights.ambientLight = new THREE.AmbientLight( 0xffffff, 0.6 )
170
+ scene.add( lights.ambientLight )
171
+
172
+ lights.hemiLight = new THREE.HemisphereLight( 0xffffff, 0x444444, 1.2 )
173
+ lights.hemiLight.position.set( 0, 20, 0 )
174
+ scene.add( lights.hemiLight )
175
+
176
+ lights.keyLight = new THREE.DirectionalLight( 0xffffff, 2.5 )
177
+ lights.keyLight.position.set( 5, 10, 7 )
178
+ lights.keyLight.castShadow = true
179
+ lights.keyLight.shadow.mapSize.set( 2048, 2048 )
180
+ lights.keyLight.shadow.camera.near = 0.5
181
+ lights.keyLight.shadow.camera.far = 40
182
+ lights.keyLight.shadow.camera.left = -10
183
+ lights.keyLight.shadow.camera.right = 10
184
+ lights.keyLight.shadow.camera.top = 10
185
+ lights.keyLight.shadow.camera.bottom = -10
186
+ lights.keyLight.shadow.bias = -0.0001
187
+ scene.add( lights.keyLight )
188
+
189
+ lights.fillLight = new THREE.DirectionalLight( 0xffffff, 1.2 )
190
+ lights.fillLight.position.set( -5, 4, -2 )
191
+ scene.add( lights.fillLight )
192
+
193
+ lights.rimLight = new THREE.DirectionalLight( 0xffffff, 0.8 )
194
+ lights.rimLight.position.set( 0, 6, -8 )
195
+ scene.add( lights.rimLight )
196
+
197
+ restoreLightControls()
198
+ syncLightsFromControls()
199
+ }
200
+
201
+
202
+
203
+
204
+ let eventsIndex = 0
205
+ function tickEvents(elapsedMs) {
206
+ if (!chunkedInput || !chunkedInput.ftimes || !chunkedInput.fns) return
207
+ while (eventsIndex < chunkedInput.ftimes.length && elapsedMs >= chunkedInput.ftimes[eventsIndex]) {
208
+ const fn = chunkedInput.fns[eventsIndex]
209
+ logg(fn, 'fn')
210
+ eventsIndex++
211
+ eval(fn)
212
+ }
213
+ }
214
+
215
+
216
+
217
+ /*
218
+ **/
219
+ async function init() {
220
+ if (newspartial_id) {
221
+ try {
222
+ const url = wco_origin + '/wco/api/newspartials/' + newspartial_id + '/config.json?api_key=' + api_key + '&api_secret=' + api_secret
223
+ chunkedInput = await fetch(url).then(r => r.json())
224
+ logg(chunkedInput, 'chunkedInput')
225
+
226
+ const last = chunkedInput.wtimes.length-1
227
+ const duration_ms = chunkedInput.wtimes[last] + chunkedInput.wdurations[last]
228
+ totalFrames = duration_ms/1000*fps
229
+ width = chunkedInput.w_px
230
+ height = chunkedInput.h_px
231
+ slug = chunkedInput.slug
232
+ } catch (error) {
233
+ console.log(error)
234
+ chunkedInput = null
235
+ totalFrames = undefined
236
+ }
237
+ }
238
+
239
+ scene = new THREE.Scene()
240
+ scene.background = new THREE.Color(0x333333) // new THREE.Color(0xd3d3d3)
241
+
242
+ /* fov — Camera frustum vertical field of view.
243
+ * aspect — Camera frustum aspect ratio.
244
+ * near — Camera frustum near plane.
245
+ * far — Camera frustum far plane.
246
+ **/
247
+ camera_1 = new THREE.PerspectiveCamera( 10, width/height, 0.1, 1000 )
248
+ camera_1.position.set( 0, 1.6, 4 )
249
+ camera_1.lookAt( 0, 1.5, 0 )
250
+
251
+ camera_2 = new THREE.PerspectiveCamera( 10, width/height, 0.1, 1000 )
252
+ camera_2.position.set( 2, 1.6, 4 )
253
+ camera_2.lookAt( 1, 1.5, 0 )
254
+
255
+ camera_3 = new THREE.PerspectiveCamera( 10, width/height, 0.1, 1000 )
256
+ camera_3.position.set( -2, 1.6, 4 )
257
+ camera_3.lookAt( -1, 1.5, 0 )
258
+
259
+ camera_wide = new THREE.PerspectiveCamera( 25, width/height, 0.1, 1000 )
260
+ camera_wide.position.set( -2, 2.2, 8 )
261
+ camera_wide.lookAt( 0.5, 1.2, 0 )
262
+
263
+ camera = new THREE.PerspectiveCamera( 10, width/height, 0.1, 1000 )
264
+ camera.position.copy( camera_wide.position )
265
+ camera.quaternion.copy( camera_wide.quaternion )
266
+ camera.fov = camera_wide.fov
267
+ camera.updateProjectionMatrix()
268
+
269
+ setup_light(scene)
270
+
271
+ const grid = new THREE.GridHelper(10, 10, 0x888888, 0xbbbbbb)
272
+ grid.position.y = 0
273
+ scene.add(grid)
274
+
275
+
276
+ async function load_studio(_studio) {
277
+ logg(_studio, 'load_studio()')
278
+
279
+ if (_studio && _studio.parent) _studio.parent.remove(_studio)
280
+ _studio = (await gltfLoader.loadAsync(cfg.url)).scene
281
+ rescale(studio, { height: cfg.height })
282
+ set_shadows(studio, false, true)
283
+ scene.add(studio)
284
+ }
285
+ await load_studio(studio)
286
+ $('select.studio').on('change', async function() {
287
+ const name = $(this).val()
288
+ if (!studios[name]) return
289
+ localStorage.setItem(STUDIO_STOR, name)
290
+ scene_cfg = studios[name]
291
+ loading.textContent = 'Loading...'
292
+ try {
293
+ await load_studio(studio)
294
+ loading.textContent = 'loaded'
295
+ } catch (error) {
296
+ console.log(error)
297
+ loading.textContent = error.toString()
298
+ }
299
+ })
300
+
301
+
302
+ // head = new TalkingHead( document.getElementById('avatar'), {
303
+ // avatarOnly: true,
304
+ // avatarOnlyScene: scene,
305
+ // avatarOnlyCamera: camera,
306
+ // lipsyncModules: ["en"],
307
+ // dracoEnabled: true,
308
+ // })
309
+ head_1 = new TalkingHead( document.getElementById('avatar_1'), {
310
+ avatarOnly: true,
311
+ avatarOnlyScene: scene,
312
+ avatarOnlyCamera: camera_1,
313
+ lipsyncModules: ["en"],
314
+ dracoEnabled: true,
315
+ })
316
+ head_2 = new TalkingHead( document.getElementById('avatar_2'), {
317
+ avatarOnly: true,
318
+ avatarOnlyScene: scene,
319
+ avatarOnlyCamera: camera_1,
320
+ lipsyncModules: ["en"],
321
+ dracoEnabled: true,
322
+ })
323
+ head_3 = new TalkingHead( document.getElementById('avatar_3'), {
324
+ avatarOnly: true,
325
+ avatarOnlyScene: scene,
326
+ avatarOnlyCamera: camera_1,
327
+ lipsyncModules: ["en"],
328
+ dracoEnabled: true,
329
+ })
330
+
331
+
332
+
333
+
334
+ $('select.avatar').on('change', async function() {
335
+ const uid = String($(this).data('uid'))
336
+ const thisHead = heads_fn(uid)
337
+ const val = $(this).val()
338
+ localStorage.setItem(`${SPOT_STOR}-${uid}`, val || '')
339
+ if (!thisHead) return
340
+ if (thisHead.armature && thisHead.armature.parent) thisHead.armature.parent.remove(thisHead.armature)
341
+ const avatar = avatars[val]
342
+ if (!avatar || !avatar.url) return
343
+ loading.textContent = 'Loading...'
344
+ try {
345
+ if (thisHead.armature && thisHead.armature.parent) thisHead.armature.parent.remove(thisHead.armature)
346
+ await thisHead.showAvatar({
347
+ url: avatar.url,
348
+ body: avatar.type,
349
+ avatarMood: 'neutral',
350
+ lipsyncLang: 'en'
351
+ }, (ev) => {
352
+ if ( ev.lengthComputable ) {
353
+ let val = Math.min(100,Math.round(ev.loaded/ev.total * 100 ))
354
+ loading.textContent = "Loading " + val + "%"
355
+ }
356
+ })
357
+ thisHead.armature.rotation.set(0, 0, 0)
358
+ set_shadows(thisHead.armature, true, false)
359
+ scene.add(thisHead.armature)
360
+ put_feet_at_origin(thisHead)
361
+ thisHead.armature.position.add(new THREE.Vector3(...spot_positions[uid]))
362
+ point_camera_at_face(`av_${uid}`, thisHead)
363
+ await thisHead.streamStart(streamOpts, () => {}, () => {}, onSubtitles, onMetrics)
364
+ loading.textContent = 'loaded'
365
+ } catch (error) {
366
+ console.log(error)
367
+ loading.textContent = error.toString()
368
+ }
369
+ })
370
+ $('select.avatar').trigger('change')
371
+
372
+
373
+
374
+ //
375
+
376
+ renderer = new THREE.WebGLRenderer( {
377
+ alpha: false,
378
+ antialias: true,
379
+ } )
380
+ renderer.setClearColor(0xd3d3d3, 1)
381
+ renderer.setPixelRatio( 1 ); // window.devicePixelRatio )
382
+ renderer.setSize( width, height )
383
+ renderer.toneMapping = THREE.ACESFilmicToneMapping
384
+ renderer.toneMappingExposure = 1
385
+ renderer.outputColorSpace = THREE.SRGBColorSpace
386
+ renderer.shadowMap.enabled = true
387
+ renderer.shadowMap.type = THREE.PCFSoftShadowMap
388
+ document.getElementById('rotatingC').appendChild( renderer.domElement )
389
+
390
+ //
391
+
392
+ controls = new OrbitControls( camera, renderer.domElement )
393
+ controls.enableDamping = true
394
+ controls.enableRotate = true
395
+ controls.enablePan = true
396
+ controls.enableZoom = true
397
+ controls.minDistance = 0.5
398
+ controls.maxDistance = 100
399
+ controls.target.copy(faceTarget)
400
+ controls.autoRotate = false
401
+ controls.update()
402
+
403
+ restoreHeadControl()
404
+ document.querySelectorAll('input[name=head]').forEach((input) => {
405
+ input.addEventListener('change', () => {
406
+ if (!input.checked) return
407
+ setActiveHead(input.value)
408
+ })
409
+ })
410
+ const selectedHead = document.querySelector('input[name=head]:checked')
411
+ setActiveHead(selectedHead ? selectedHead.value : '1')
412
+
413
+ restoreCameraControl()
414
+ document.querySelectorAll('input[name=camera]').forEach((input) => {
415
+ input.addEventListener('change', () => {
416
+ if (!input.checked) return
417
+ setActiveCamera(input.value)
418
+ })
419
+ })
420
+ const selected = document.querySelector('input[name=camera]:checked')
421
+ setActiveCamera(selected ? selected.value : 'wide', true)
422
+
423
+ document.querySelectorAll('input.light-ctrl').forEach((input) => {
424
+ input.addEventListener('change', syncLightsFromControls)
425
+ })
426
+ syncLightsFromControls()
427
+ $('#is_shadows').on('change', sync_shadows)
428
+ sync_shadows()
429
+
430
+ //
431
+
432
+ window.addEventListener( 'resize', onWindowResize )
433
+
434
+
435
+ // Keep rendering so OrbitControls drag/damping stay live
436
+ lastAnimTime = performance.now()
437
+ renderer.setAnimationLoop(animate)
438
+ }
439
+
440
+ /*
441
+ let semafore = false
442
+ document.addEventListener('DOMContentLoaded', async function(e) {
443
+ if (!semafore) {
444
+ semafore = true
445
+ await init()
446
+ }
447
+ })
448
+ */
449
+ if (document.readyState === 'loading') {
450
+ document.addEventListener('DOMContentLoaded', init)
451
+ } else {
452
+ init()
453
+ }
454
+
455
+
456
+
457
+ function heads_fn(which) {
458
+ switch (which) {
459
+ case '1':
460
+ return head_1
461
+ break;
462
+ case '2':
463
+ return head_2
464
+ break;
465
+ case '3':
466
+ return head_3
467
+ break;
468
+ default:
469
+ logg('fpp - heads_fn default - this should never happen')
470
+ return head_1
471
+ }
472
+ }
473
+
474
+ function setActiveHead(id) {
475
+ head = heads_fn(id)
476
+ persistHeadControl(id)
477
+ }
478
+
479
+
480
+
481
+ function onWindowResize() {
482
+ ;[camera_wide, camera_1, camera_2, camera_3].forEach((cam) => {
483
+ if (cam) {
484
+ cam.aspect = width / height
485
+ cam.updateProjectionMatrix()
486
+ }
487
+ })
488
+ renderer.setSize( width, height )
489
+ render()
490
+ }
491
+
492
+ function render() {
493
+ renderer.render( scene, camera )
494
+ }
495
+
496
+ function animate() {
497
+ let dt
498
+ if (capturing) {
499
+ dt = 1000 / fps
500
+ } else {
501
+ const now = performance.now()
502
+ dt = lastAnimTime ? (now - lastAnimTime) : (1000 / fps)
503
+ lastAnimTime = now
504
+ if (dt > 100) dt = 100
505
+ }
506
+
507
+ if (capturing) tickEvents(captureFrame * dt)
508
+
509
+ if (head_1) head_1.animate(dt)
510
+ if (head_2) head_2.animate(dt)
511
+ if (head_3) head_3.animate(dt)
512
+ update_walk(head_1, dt)
513
+ update_walk(head_2, dt)
514
+ update_walk(head_3, dt)
515
+ updateCameraTransition(dt)
516
+ if (!cameraTransition && !capturing) controls.update()
517
+ renderer.render( scene, camera )
518
+
519
+ if (capturing) {
520
+ capturer.capture( renderer.domElement )
521
+ captureFrame++
522
+ if (captureFrame >= captureTotal) {
523
+ finishCapture()
524
+ }
525
+ }
526
+ }
527
+
528
+ async function startSpeakCapture() {
529
+ if (capturing) return
530
+ if (!head) return
531
+ if (!chunkedInput) return
532
+
533
+ const last = chunkedInput.wtimes.length - 1
534
+ const duration_ms = chunkedInput.wtimes[last] + chunkedInput.wdurations[last]
535
+ captureTotal = Math.max(1, Math.ceil(duration_ms / 1000 * fps))
536
+ captureFrame = 0
537
+ eventsIndex = 0
538
+ capturing = true
539
+ cameraTransition = null
540
+ if (controls) controls.enabled = false
541
+
542
+ capturer = new CCapture( { format: 'webm', framerate: fps } )
543
+ capturer.start()
544
+ logg('capturer.start')
545
+ status.textContent = 'capturing'
546
+ head.streamAudio(chunkedInput)
547
+ }
548
+
549
+ function finishCapture() {
550
+ capturing = false
551
+ capturer.stop()
552
+ logg('capturer.stop')
553
+ lastAnimTime = performance.now()
554
+ if (controls) controls.enabled = true
555
+
556
+ capturer.save((blob) => {
557
+ logg(blob, 'blob')
558
+ renderer.domElement.toBlob((thumb) => {
559
+ logg(thumb, 'thumb')
560
+ const form = new FormData()
561
+ form.append('video', blob, 'lips.webm')
562
+ form.append('name', slug)
563
+ form.append('thumb', thumb)
564
+ if (newspartial_id) form.append('newspartial_id', newspartial_id)
565
+
566
+ const url = wco_origin
567
+ ? (wco_origin + '/wco/api/videos/?api_key=' + api_key + '&api_secret=' + api_secret)
568
+ : '/wco/api/videos/'
569
+ fetch(url, {
570
+ method: 'POST',
571
+ body: form,
572
+ }).then(() => {
573
+ status.textContent = 'finished'
574
+ }).catch((error) => {
575
+ console.log(error)
576
+ status.textContent = 'save failed'
577
+ })
578
+ })
579
+ })
580
+ }
581
+
582
+
583
+ $('#speak').on('click', async () => {
584
+ try {
585
+ await startSpeakCapture()
586
+ } catch (error) {
587
+ console.log(error)
588
+ capturing = false
589
+ lastAnimTime = performance.now()
590
+ if (controls) controls.enabled = true
591
+ }
592
+ })
593
+
594
+ $('#jesture').on('click', async () => {
595
+ try {
596
+ if (!head) return
597
+ const name = $('select.gestures').val()
598
+ const gesture = gestures[name]
599
+ head.speed = gesture.speed || 0
600
+ head.playAnimation( gesture_url(gesture, head.avatar) )
601
+ } catch (error) {
602
+ console.log(error)
603
+ }
604
+ })
605
+
606
+ console.log('+++ loaded wco_models :: newsproducer :: studio_blue.js')