wco_models 3.4.0.10 → 3.5.0.2

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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/wco/main.scss +3 -7
  3. data/app/assets/stylesheets/wco/photos.scss +1 -2
  4. data/app/controllers/wco/api/newspartials_controller.rb +15 -5
  5. data/app/controllers/wco/newspartials_controller.rb +2 -2
  6. data/app/controllers/wco/newsvideos_controller.rb +14 -10
  7. data/app/controllers/wco/office_action_templates_controller.rb +0 -3
  8. data/app/controllers/wco/publishers_controller.rb +16 -6
  9. data/app/controllers/wco/reports_controller.rb +5 -6
  10. data/app/controllers/wco/sitemap_paths_controller.rb +2 -14
  11. data/app/controllers/wco/sites_controller.rb +1 -1
  12. data/app/controllers/wco/tags_controller.rb +1 -1
  13. data/app/models/iro/option.rb +4 -37
  14. data/app/models/iro/priceitem.rb +4 -62
  15. data/app/models/tda/option.rb +41 -39
  16. data/app/models/wco/newspartial.rb +33 -8
  17. data/app/models/wco/newsvideo.rb +4 -3
  18. data/app/models/wco/publisher.rb +8 -29
  19. data/app/models/wco/report.rb +2 -12
  20. data/app/models/wco/setting.rb +1 -1
  21. data/app/models/wco/site.rb +67 -1
  22. data/app/models/wco/sitemap_path.rb +13 -19
  23. data/app/models/wco/tag.rb +8 -15
  24. data/app/models/wco/utils.rb +19 -0
  25. data/app/views/wco/api/newsproducer/_studio_blue2.js +205 -317
  26. data/app/views/wco/api/newsproducer/_studio_fps.js +12 -12
  27. data/app/views/wco/api/newsproducer/studio_blue2.html.erb +25 -24
  28. data/app/views/wco/api/newsproducer/studio_fps.html.erb +8 -10
  29. data/app/views/wco/api/newsproducer/trash/_scenes.js-bk +20 -0
  30. data/app/views/wco/api/newsproducer/trash/_scenes.js.erb +15 -0
  31. data/app/views/wco/api/newsproducer/trash/_studio_blue0.js +326 -0
  32. data/app/views/wco/api/newsproducer/trash/_studio_blue1.js +733 -0
  33. data/app/views/wco/api/newsproducer/trash/studio_blue0.html.erb +27 -0
  34. data/app/views/wco/api/newsproducer/trash/studio_blue1.html.erb +108 -0
  35. data/app/views/wco/api/newsvideos/show.jbuilder +1 -1
  36. data/app/views/wco/newspartials/_form.haml +6 -0
  37. data/app/views/wco/newspartials/_show_in_newsvideo.haml +2 -2
  38. data/app/views/wco/newsvideos/_form.haml +4 -0
  39. data/app/views/wco/newsvideos/show.haml +2 -2
  40. data/app/views/wco/office_action_templates/index.haml +1 -1
  41. data/app/views/wco/office_actions/_actions.haml +1 -1
  42. data/app/views/wco/publishers/_form.haml +2 -11
  43. data/app/views/wco/publishers/_post_with.haml +1 -1
  44. data/app/views/wco/reports/_form.haml +2 -13
  45. data/app/views/wco/reports/_index.haml +11 -18
  46. data/app/views/wco/reports/show.haml +1 -6
  47. data/app/views/wco/sitemap_paths/_index.haml +0 -1
  48. data/app/views/wco/sitemap_paths/check.haml +13 -0
  49. data/app/views/wco/sites/index.haml +0 -6
  50. data/app/views/wco/sites/show.haml +1 -1
  51. data/app/views/wco/tags/_form.haml +0 -3
  52. data/config/routes.rb +12 -11
  53. data/lib/shortcuts.rb +1 -1
  54. data/lib/wco_models.rb +1 -1
  55. metadata +28 -24
  56. data/app/models/wco/publisher_d10.rb +0 -50
  57. data/app/views/wco/api/newsproducer/README_newsproducer.txt +0 -12
  58. data/app/views/wco/sitemap_paths/show.haml +0 -14
  59. /data/app/views/wco/api/newsproducer/{_scenes.js-bk → done/_scenes.js-bk} +0 -0
  60. /data/app/views/wco/api/newsproducer/{_scenes.js.erb → done/_scenes.js.erb} +0 -0
  61. /data/app/views/wco/api/newsproducer/{_studio_1.js → done/_studio_1.js} +0 -0
  62. /data/app/views/wco/api/newsproducer/{_studio_blue0.js → done/_studio_blue0.js} +0 -0
  63. /data/app/views/wco/api/newsproducer/{_studio_blue1.js → done/_studio_blue1.js} +0 -0
  64. /data/app/views/wco/api/newsproducer/{_studio_coc.js → done/_studio_coc.js} +0 -0
  65. /data/app/views/wco/api/newsproducer/{_studio_coc.js-bk → done/_studio_coc.js-bk} +0 -0
  66. /data/app/views/wco/api/newsproducer/{_studio_coc.js-cannon → done/_studio_coc.js-cannon} +0 -0
  67. /data/app/views/wco/api/newsproducer/{_studio_ra2.js → done/_studio_ra2.js} +0 -0
  68. /data/app/views/wco/api/newsproducer/{_touch_controls.js → done/_touch_controls.js} +0 -0
  69. /data/app/views/wco/api/newsproducer/{_touch_pad.css → done/_touch_pad.css} +0 -0
  70. /data/app/views/wco/api/newsproducer/{canvas.html.erb → done/canvas.html.erb} +0 -0
  71. /data/app/views/wco/api/newsproducer/{canvas_minimal.html.erb → done/canvas_minimal.html.erb} +0 -0
  72. /data/app/views/wco/api/newsproducer/{games_fps.html → done/games_fps.html} +0 -0
  73. /data/app/views/wco/api/newsproducer/{studio_1.html.erb → done/studio_1.html.erb} +0 -0
  74. /data/app/views/wco/api/newsproducer/{studio_blue0.html.erb → done/studio_blue0.html.erb} +0 -0
  75. /data/app/views/wco/api/newsproducer/{studio_blue1.html.erb → done/studio_blue1.html.erb} +0 -0
  76. /data/app/views/wco/api/newsproducer/{studio_coc.html.erb → done/studio_coc.html.erb} +0 -0
  77. /data/app/views/wco/api/newsproducer/{studio_ra2.html.erb → done/studio_ra2.html.erb} +0 -0
@@ -14,10 +14,12 @@ document.addEventListener("keydown", e => {
14
14
  }
15
15
  })
16
16
 
17
- // const MODELS_ROOT = '/vendor/models'
18
- // const MODELS_ROOT = "https://cdn.jsdelivr.net/gh/wasya-co/ishlib3js@0.4.0/public/vendor/models"
17
+ const ISH_VERSION = 'v0.4.14'
18
+ const MODELS_ROOT = `https://cdn.jsdelivr.net/gh/wasya-co/ishlib3js@${ISH_VERSION}/public/vendor/models`
19
+
19
20
  const SCENE_STOR = 'studio'
20
- const scenes = await fetch('https://cdn.jsdelivr.net/gh/wasya-co/ishlib3js@0.4.3/public/vendor/models/scenes/index.json').then(r => r.json())
21
+ const scenes = await fetch(`${MODELS_ROOT}/scenes/index.json`).then(r => r.json())
22
+ logg(scenes, 'scenes13')
21
23
  $.each(scenes, (name) => {
22
24
  $('<option>', { value: name, text: name }).appendTo($('select.studio'))
23
25
  })
@@ -760,7 +762,7 @@ function scene_cfg(s) {
760
762
  if (typeof s.url === 'string') {
761
763
  return { ...s, url: s.url }
762
764
  }
763
- logg(s, 'out')
765
+ logg(s, 'scene_cfg() out')
764
766
  return s
765
767
  }
766
768
 
@@ -792,14 +794,10 @@ function reset_player() {
792
794
 
793
795
  const loader = new GLTFLoader()
794
796
 
795
- function specsheet_url(glb_url) {
796
- return glb_url.replace(/[^/]+$/, 'specsheet.json')
797
- }
798
-
799
- async function load_specsheet(glb_url) {
797
+ async function load_specsheet(cfg) {
800
798
  specsheet = null
801
799
  try {
802
- const res = await fetch(specsheet_url(glb_url))
800
+ const res = await fetch(`${cfg.path}/specsheet.json`)
803
801
  if (!res.ok) return
804
802
  specsheet = await res.json()
805
803
  logg(specsheet, 'specsheet')
@@ -809,11 +807,13 @@ async function load_specsheet(glb_url) {
809
807
  }
810
808
 
811
809
  async function load_studio(s) {
810
+ logg(s, 'load_studio')
811
+
812
812
  const cfg = scene_cfg(s)
813
813
  if (studio && studio.parent) studio.parent.remove(studio)
814
814
  if (octree_helper && octree_helper.parent) octree_helper.parent.remove(octree_helper)
815
- const gltf = await loader.loadAsync(cfg.url)
816
- await load_specsheet(cfg.url)
815
+ const gltf = await loader.loadAsync(`${cfg.path}/scene.glb`)
816
+ await load_specsheet(cfg)
817
817
  studio = gltf.scene
818
818
  if (cfg.height) rescale(studio, { height: cfg.height })
819
819
  apply_studio_mesh(studio)
@@ -33,29 +33,30 @@
33
33
  <div class='StudioW1'>
34
34
  <div class='StudioW0'>
35
35
 
36
- <div class='d-flex ctrl-row header-row'>
36
+ <div class='studio d-flex ctrl-row'>
37
37
  <div class='item'>
38
38
  <select class='studio'></select>
39
39
  <em>Status:</em><span id='status'>pending</span>
40
40
  </div>
41
41
  </div>
42
- <div class='d-flex ctrl-row header-row'>
42
+
43
+ <div class='active_spot d-flex ctrl-row'>
43
44
  <div class='item'>
44
45
  <label>
45
- <input type="radio" name="head" value="1" checked>
46
- head 1
46
+ <input type="radio" name="active_spot" value="spot_1">
47
+ spot 1
47
48
  </label>
48
49
  </div>
49
50
  <div class='item'>
50
51
  <label>
51
- <input type="radio" name="head" value="2">
52
- head 2
52
+ <input type="radio" name="active_spot" value="spot_2" >
53
+ spot 2
53
54
  </label>
54
55
  </div>
55
56
  <div class='item'>
56
57
  <label>
57
- <input type="radio" name="head" value="3">
58
- head 3
58
+ <input type="radio" name="active_spot" value="spot_3" >
59
+ spot 3
59
60
  </label>
60
61
  </div>
61
62
  <div class='item'>
@@ -75,42 +76,42 @@
75
76
  text-align: center; " >
76
77
  </div>
77
78
 
78
- <div class='d-flex heads ctrl-row'>
79
+ <div class='avatars d-flex ctrl-row'>
79
80
  <div class='item'>
80
- head 1
81
- <select class='avatar' data-uid="1" ><option></option></select>
81
+ spot 1
82
+ <select class='avatars' data-spot_id="spot_1" ><option></option></select>
82
83
  </div>
83
84
  <div class='item'>
84
- head 2
85
- <select class='avatar' data-uid='2' ><option></option></select>
85
+ spot 2
86
+ <select class='avatars' data-spot_id='spot_2' ><option></option></select>
86
87
  </div>
87
88
  <div class='item'>
88
- head 3
89
- <select class='avatar' data-uid='3' ><option></option></select>
89
+ spot 3
90
+ <select class='avatars' data-spot_id='spot_3' ><option></option></select>
90
91
  </div>
91
92
  </div>
92
93
 
93
- <div class='d-flex cameras ctrl-row'>
94
+ <div class='active_camera d-flex ctrl-row'>
94
95
  <label>
95
- <input type="radio" name="camera" value="wide" checked>
96
+ <input type="radio" name="active_camera" value="wide" checked>
96
97
  cam wide
97
98
  </label>
98
99
  <label>
99
- <input type="radio" name="camera" value="av_1">
100
- cam 1
100
+ <input type="radio" name="active_camera" value="spot_1">
101
+ spot 1
101
102
  </label>
102
103
  <label>
103
- <input type="radio" name="camera" value="av_2">
104
- cam 2
104
+ <input type="radio" name="active_camera" value="spot_2">
105
+ spot 2
105
106
  </label>
106
107
  <label>
107
- <input type="radio" name="camera" value="av_3">
108
- cam 3
108
+ <input type="radio" name="active_camera" value="spot_3">
109
+ spot 3
109
110
  </label>
110
111
 
111
112
  </div>
112
113
 
113
- <div class='d-flex lights ctrl-row'>
114
+ <div class='lights d-flex ctrl-row'>
114
115
  <label>
115
116
  <input type="checkbox" class='light-ctrl' name="ambientLight" value="on" checked>
116
117
  ambientLight
@@ -14,17 +14,14 @@
14
14
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
15
15
 
16
16
  <%= stylesheet_link_tag "wco/application", media: "all" %>
17
- <%= stylesheet_link_tag "wco/studio", media: "all" %>
17
+ <%= stylesheet_link_tag "wco/studio", media: "all" %>
18
18
 
19
19
  </head>
20
20
  <body>
21
21
 
22
- <style><%= render 'touch_pad.css' %></style>
22
+ <style><%= render 'wco/api/newsproducer/done/touch_pad.css' %></style>
23
23
 
24
- <script><%= render 'scenes.js' %></script>
25
-
26
-
27
- <script async src="https://unpkg.com/es-module-shims@1.3.6/dist/es-module-shims.js"></script>
24
+ <script src="https://unpkg.com/es-module-shims@1.3.6/dist/es-module-shims.js" async></script>
28
25
  <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
29
26
  <script src="/vendor/javascript/CCapture.all.min.js"></script>
30
27
 
@@ -33,7 +30,8 @@
33
30
  {
34
31
  "three": "https://cdn.jsdelivr.net/npm/three@0.180.0/build/three.module.js/+esm",
35
32
  "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.180.0/examples/jsm/",
36
- "talkinghead": "https://cdn.jsdelivr.net/gh/wasya-co/TalkingHead@1.7.1/modules/talkinghead.mjs"
33
+ "talkinghead": "https://cdn.jsdelivr.net/gh/wasya-co/TalkingHead@1.7.1/modules/talkinghead.mjs",
34
+ "TouchControls": "https://cdn.jsdelivr.net/gh/wasya-co/ishlib3js@v0.4.13/public/2026/js/touch_controls.js"
37
35
  }
38
36
  }
39
37
  </script>
@@ -47,7 +45,7 @@
47
45
  <select class='studio'></select>
48
46
  <em>Status:</em><span id='status'>pending</span>
49
47
  </div>
50
- <button id='fullScreen' />fullScrn</button>
48
+ <button id='fullScreen'>fullScrn</button>
51
49
 
52
50
  <div class='item'>
53
51
  <label>
@@ -193,7 +191,7 @@
193
191
  </div>
194
192
  </div>
195
193
 
196
- <script type="module"><%= render 'touch_controls.js' %></script>
194
+ <script type="module"><%= render 'wco/api/newsproducer/done/touch_controls.js' %></script>
197
195
  <script type="module"><%= render 'studio_fps.js' %></script>
198
196
 
199
- </body></html>
197
+ </body></html>
@@ -0,0 +1,20 @@
1
+
2
+ const MODELS_ROOT = '/vendor/models'
3
+ let scenes = {
4
+ collision_world: `${MODELS_ROOT}/scenes/000mb collision-world/collision-world.glb`,
5
+ skybox_1: { height: 30, url: `${MODELS_ROOT}/scenes/000mb skybox_1/scene.glb` },
6
+ room_1: { height: 6, url: `${MODELS_ROOT}/scenes/000mb room-1/scene.glb` },
7
+ mountain_1: { height: 30, url: `${MODELS_ROOT}/scenes/000mb lowpoly-mountain/scene.glb` },
8
+ meshy_3: { height: 30, url: `${MODELS_ROOT}/scenes/004mb meshy-scene-3/scene.glb` },
9
+ newsroom_green: { height: 3.3, url: `${MODELS_ROOT}/scenes/001mb newsroom_green/scene.glb` },
10
+ rick_and_morty_garage: `${MODELS_ROOT}/scenes/003mb rick-and-morty-garage/scene.glb`,
11
+ white_park: { height: 10, name: '003mb h100cm white_park' },
12
+ }
13
+
14
+ <% Dir.glob(Rails.root.join('public/vendor/models/scenes/00*')).each do |file| %>
15
+ <%- basename = File.basename(file) -%>
16
+ <%= basename.split.last -%>: {
17
+ <%= "height: #{$1.to_i / 10.0}," if basename =~ /h(\d{3})cm/ -%>
18
+ name: "<%= File.basename(file) -%>",
19
+ },
20
+ <% end %>
@@ -0,0 +1,15 @@
1
+
2
+ let MODELS_ROOT = '/vendor/models'
3
+ let scenes = {
4
+
5
+ <% Dir.glob(Rails.root.join('public/vendor/models/scenes/00*')).each do |file| %>
6
+ <%- basename = File.basename(file) -%>
7
+ "<%= basename.split.last -%>": {
8
+ <%= "height: #{$1.to_i / 10.0}," if basename =~ / h(\d+)cm / -%>
9
+ <%= "height: #{$1}," if basename =~ / h(\d+) / -%>
10
+ name: "<%= basename -%>",
11
+ },
12
+ <% end %>
13
+
14
+ }
15
+ window.scenes = scenes
@@ -0,0 +1,326 @@
1
+
2
+ /*
3
+ **/
4
+ const logg = (a, b="", c=null) => {
5
+ if ('undefined' === typeof window) { return }
6
+ c = "string" === typeof c ? c : b.replace(/\W/g, '')
7
+ if (c.length > 0) {
8
+ window[c] = a
9
+ }
10
+ console.log(`+++ ${b}:`, a) // eslint-disable-line no-console
11
+ }
12
+
13
+ let avatar_brunette_url = 'https://cdn.jsdelivr.net/gh/wasya-co/ishlib3js@0.0.3/public/vendor/models/avatars/brunette.glb'
14
+ let avatar_man_url = 'https://cdn.jsdelivr.net/gh/wasya-co/ishlib3js@0.0.3/public/vendor/models/avatars/male-avatar/model.glb'
15
+ let scene_url = 'https://cdn.jsdelivr.net/gh/wasya-co/ishlib3js@0.2.0/public/vendor/models/scenes/001mb newsroom_green/scene.glb'
16
+
17
+ let avatar_url = avatar_man_url
18
+
19
+
20
+ import * as THREE from 'three'
21
+
22
+ import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js'
23
+ import { OrbitControls } from 'three/addons/controls/OrbitControls.js'
24
+
25
+ import { TalkingHead } from "talkinghead"
26
+
27
+ const params = new URLSearchParams(window.location.search)
28
+
29
+ let config = {
30
+ sampleRate: 8000,
31
+ mood: 'neutral',
32
+ gain: 0.5,
33
+ lipsyncType: "visemes",
34
+ lipsyncLang: "en",
35
+ waitForAudioChunks: false,
36
+ enableMetrics: false,
37
+ }
38
+ let width = 854
39
+ let height = 480
40
+ let slug = '<ccapture>'
41
+ const FPS = 24
42
+
43
+ let frame = 0
44
+ const api_key = params.get('api_key')
45
+ const api_secret = params.get('api_secret')
46
+ const wco_origin = params.get('wco_origin')
47
+ const newspartial_id = params.get('newspartial_id')
48
+ let totalFrames
49
+
50
+ let camera, controls, head, renderer, scene
51
+ let faceTarget = new THREE.Vector3()
52
+ let chunkedInput = null
53
+ var capturer = new CCapture( { format: 'webm', framerate: FPS } )
54
+
55
+ async function init() {
56
+ if (newspartial_id) {
57
+ try {
58
+ const url = wco_origin + '/wco/api/newspartials/' + newspartial_id + '/config.json?api_key=' + api_key + '&api_secret=' + api_secret
59
+ chunkedInput = await fetch(url).then(r => r.json())
60
+ // API may return a JSON string payload
61
+ if (typeof chunkedInput === 'string') {
62
+ chunkedInput = JSON.parse(chunkedInput)
63
+ }
64
+ // logg(chunkedInput, 'chunkedInput')
65
+ const last = chunkedInput.wtimes.length-1
66
+ const duration_ms = chunkedInput.wtimes[last] + chunkedInput.wdurations[last]
67
+ logg(duration_ms, 'duration_ms')
68
+ totalFrames = duration_ms/1000*FPS
69
+ width = chunkedInput.w_px
70
+ height = chunkedInput.h_px
71
+ slug = chunkedInput.slug
72
+ } catch (error) {
73
+ console.log(error)
74
+ chunkedInput = null
75
+ totalFrames = undefined
76
+ }
77
+ }
78
+
79
+ scene = new THREE.Scene()
80
+ scene.background = new THREE.Color(0xd3d3d3)
81
+
82
+ /* fov — Camera frustum vertical field of view.
83
+ * aspect — Camera frustum aspect ratio.
84
+ * near — Camera frustum near plane.
85
+ * far — Camera frustum far plane.
86
+ **/
87
+ camera = new THREE.PerspectiveCamera( 10, width/height, 0.1, 1000 )
88
+ camera.position.set( 0, 2, 8 )
89
+ camera.lookAt( 0, 0, 0 )
90
+
91
+ // const ambientLight = new THREE.AmbientLight( 0xffffff )
92
+ // scene.add( ambientLight )
93
+
94
+ const ambientLight = new THREE.AmbientLight( 0xffffff, 0.6 )
95
+ scene.add( ambientLight )
96
+
97
+ const hemiLight = new THREE.HemisphereLight( 0xffffff, 0x444444, 1.2 )
98
+ hemiLight.position.set( 0, 20, 0 )
99
+ scene.add( hemiLight )
100
+
101
+ // const keyLight = new THREE.DirectionalLight( 0xffffff, 2.5 )
102
+ // keyLight.position.set( 5, 10, 7 )
103
+ // scene.add( keyLight )
104
+
105
+ const fillLight = new THREE.DirectionalLight( 0xffffff, 1.2 )
106
+ fillLight.position.set( -5, 4, -2 )
107
+ scene.add( fillLight )
108
+
109
+ // const rimLight = new THREE.DirectionalLight( 0xffffff, 0.8 )
110
+ // rimLight.position.set( 0, 6, -8 )
111
+ // scene.add( rimLight )
112
+
113
+ // end lights
114
+
115
+ const grid = new THREE.GridHelper(10, 10, 0x888888, 0xbbbbbb)
116
+ grid.position.y = 0
117
+ scene.add(grid)
118
+
119
+ const gltfLoader = new GLTFLoader()
120
+ const sceneGltf = await gltfLoader.loadAsync(scene_url)
121
+
122
+ const box = new THREE.Box3().setFromObject(sceneGltf.scene)
123
+ const size = box.getSize(new THREE.Vector3())
124
+ const currentHeight = size.y
125
+ logg(currentHeight, 'currentHeight')
126
+ const desiredHeight = 3 // meters
127
+ const scale = desiredHeight / currentHeight
128
+ sceneGltf.scene.scale.setScalar(scale)
129
+ scene.add(sceneGltf.scene)
130
+ logg(sceneGltf.scene, 'sceneGltf')
131
+
132
+ const nodeAvatar = document.getElementById('avatar')
133
+ head = new TalkingHead( nodeAvatar, {
134
+ avatarOnly: true,
135
+ avatarOnlyScene: scene,
136
+ avatarOnlyCamera: camera,
137
+
138
+ lipsyncModules: ["en"],
139
+ })
140
+ // logg(head, 'head')
141
+
142
+
143
+
144
+ const nodeLoading = document.getElementById('loading')
145
+ try {
146
+ nodeLoading.textContent = "Loading..."
147
+ await head.showAvatar( {
148
+ url: avatar_url,
149
+ body: 'F',
150
+ avatarMood: 'neutral',
151
+ lipsyncLang: 'en'
152
+ }, (ev) => {
153
+ if ( ev.lengthComputable ) {
154
+ let val = Math.min(100,Math.round(ev.loaded/ev.total * 100 ))
155
+ nodeLoading.textContent = "Loading " + val + "%"
156
+ }
157
+ })
158
+ nodeLoading.style.display = 'none'
159
+
160
+ head.armature.position.set(0, 0, 0)
161
+ head.armature.rotation.set(0, 0, 0)
162
+ scene.add(head.armature)
163
+
164
+ // Put feet at the origin
165
+ head.armature.updateMatrixWorld(true)
166
+ const leftToe = new THREE.Vector3()
167
+ const rightToe = new THREE.Vector3()
168
+ head.objectLeftToeBase.getWorldPosition(leftToe)
169
+ head.objectRightToeBase.getWorldPosition(rightToe)
170
+ head.armature.position.set(
171
+ -(leftToe.x + rightToe.x) / 2,
172
+ -Math.min(leftToe.y, rightToe.y),
173
+ -(leftToe.z + rightToe.z) / 2
174
+ )
175
+ head.armature.updateMatrixWorld(true)
176
+
177
+ // Camera at head level, pointed at the face
178
+ const leftEye = new THREE.Vector3()
179
+ const rightEye = new THREE.Vector3()
180
+ head.objectLeftEye.getWorldPosition(leftEye)
181
+ head.objectRightEye.getWorldPosition(rightEye)
182
+ faceTarget.copy(leftEye).add(rightEye).multiplyScalar(0.5)
183
+
184
+ const camPos = new THREE.Vector3(0, 0, 2)
185
+ camPos.applyQuaternion(head.armature.quaternion)
186
+ camPos.add(faceTarget)
187
+ camera.position.copy(camPos)
188
+ camera.lookAt(faceTarget)
189
+
190
+ await head.streamStart({
191
+ sampleRate: config.sampleRate,
192
+ mood: config.mood,
193
+ gain: config.gain,
194
+ lipsyncType: config.lipsyncType,
195
+ lipsyncLang: config.lipsyncLang,
196
+ waitForAudioChunks: config.waitForAudioChunks,
197
+ metrics: config.enableMetrics ? { enabled: true, intervalHz: config.metricsInterval } : { enabled: false }
198
+ })
199
+
200
+ } catch (error) {
201
+ console.log(error)
202
+ nodeLoading.textContent = error.toString()
203
+ }
204
+
205
+
206
+ //
207
+
208
+ renderer = new THREE.WebGLRenderer( {
209
+ alpha: false,
210
+ antialias: true,
211
+ } )
212
+ renderer.setClearColor(0xd3d3d3, 1)
213
+ renderer.setPixelRatio( 1 ); // window.devicePixelRatio )
214
+ renderer.setSize( width, height )
215
+ renderer.toneMapping = THREE.ACESFilmicToneMapping
216
+ renderer.toneMappingExposure = 1
217
+ renderer.outputColorSpace = THREE.SRGBColorSpace
218
+ document.getElementById('rotatingC').appendChild( renderer.domElement )
219
+
220
+ //
221
+
222
+ controls = new OrbitControls( camera, renderer.domElement )
223
+ controls.enableDamping = true
224
+ controls.enableRotate = true
225
+ controls.enablePan = true
226
+ controls.enableZoom = true
227
+ controls.minDistance = 0.5
228
+ controls.maxDistance = 100
229
+ controls.target.copy(faceTarget)
230
+ controls.autoRotate = false
231
+ controls.update()
232
+
233
+ //
234
+
235
+ window.addEventListener( 'resize', onWindowResize )
236
+
237
+
238
+ // Keep rendering so OrbitControls drag/damping stay live
239
+ renderer.setAnimationLoop(animate)
240
+
241
+ // Start capture/audio only after the renderer exists
242
+ if (newspartial_id && chunkedInput) {
243
+ capturer.start()
244
+ logg('capturer.start')
245
+ head.streamAudio(chunkedInput)
246
+ }
247
+ }
248
+
249
+ let semafore = false
250
+ document.addEventListener('DOMContentLoaded', async function(e) {
251
+ if (!semafore) {
252
+ semafore = true
253
+ await init()
254
+ }
255
+ })
256
+
257
+ function onWindowResize() {
258
+ camera.aspect = width / height
259
+ camera.updateProjectionMatrix()
260
+ renderer.setSize( width, height )
261
+ render()
262
+ }
263
+
264
+ function render() {
265
+ renderer.render( scene, camera )
266
+ }
267
+
268
+ function animate() {
269
+ const t = frame / FPS
270
+ if (head) head.animate(1000/FPS)
271
+ controls.update()
272
+ renderer.render( scene, camera )
273
+
274
+ if (totalFrames) {
275
+ capturer.capture( renderer.domElement )
276
+ frame++
277
+ if (frame >= totalFrames) {
278
+ totalFrames = false
279
+ renderer.setAnimationLoop(null)
280
+ capturer.stop()
281
+ logg('capturer.stop')
282
+
283
+ if (newspartial_id) {
284
+ capturer.save((blob) => {
285
+ logg(blob, 'blob')
286
+ renderer.domElement.toBlob((thumb) => {
287
+ logg(thumb, 'thumb')
288
+ const form = new FormData()
289
+ form.append('video', blob, 'lips.webm')
290
+ form.append('name', slug)
291
+ form.append('thumb', thumb)
292
+ form.append('newspartial_id', newspartial_id)
293
+
294
+ fetch(wco_origin + '/wco/api/videos/?api_key=' + api_key + '&api_secret=' + api_secret, {
295
+ method: 'POST',
296
+ headers: {
297
+ // 'Content-Type': 'video/webm',
298
+ },
299
+ body: form,
300
+ }).then(() => {
301
+ document.getElementById('status').textContent = 'finished'
302
+ document.body.style.backgroundColor = 'gray'
303
+ })
304
+ })
305
+ })
306
+ }
307
+
308
+ // Resume interactive orbit after capture
309
+ renderer.setAnimationLoop(animate)
310
+ }
311
+ }
312
+ }
313
+
314
+
315
+ // Speak when clicked
316
+ const nodeSpeak = document.getElementById('speak')
317
+ nodeSpeak.addEventListener('click', function () {
318
+ try {
319
+
320
+ } catch (error) {
321
+ console.log(error)
322
+ }
323
+ })
324
+
325
+
326
+ console.log('+++ loaded wco_models :: newsproducer :: studio_green.js')