wco_models 3.4.0.10 → 3.5.0.1
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.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/wco/main.scss +3 -7
- data/app/assets/stylesheets/wco/photos.scss +1 -2
- data/app/controllers/wco/api/newspartials_controller.rb +9 -0
- data/app/controllers/wco/newsvideos_controller.rb +12 -6
- data/app/controllers/wco/office_action_templates_controller.rb +0 -3
- data/app/controllers/wco/publishers_controller.rb +16 -6
- data/app/controllers/wco/reports_controller.rb +5 -6
- data/app/controllers/wco/sitemap_paths_controller.rb +2 -14
- data/app/controllers/wco/sites_controller.rb +1 -1
- data/app/controllers/wco/tags_controller.rb +1 -1
- data/app/models/iro/option.rb +4 -37
- data/app/models/iro/priceitem.rb +4 -62
- data/app/models/tda/option.rb +41 -39
- data/app/models/wco/newspartial.rb +12 -2
- data/app/models/wco/publisher.rb +8 -29
- data/app/models/wco/report.rb +2 -12
- data/app/models/wco/setting.rb +1 -1
- data/app/models/wco/site.rb +67 -1
- data/app/models/wco/sitemap_path.rb +13 -19
- data/app/models/wco/tag.rb +8 -15
- data/app/views/wco/api/newsproducer/_studio_blue2.js +16 -37
- data/app/views/wco/api/newsproducer/_studio_fps.js +12 -12
- data/app/views/wco/api/newsproducer/studio_fps.html.erb +8 -10
- data/app/views/wco/api/newsproducer/trash/_scenes.js-bk +20 -0
- data/app/views/wco/api/newsproducer/trash/_scenes.js.erb +15 -0
- data/app/views/wco/api/newsproducer/trash/_studio_blue0.js +326 -0
- data/app/views/wco/api/newsproducer/trash/_studio_blue1.js +733 -0
- data/app/views/wco/api/newsproducer/trash/studio_blue0.html.erb +27 -0
- data/app/views/wco/api/newsproducer/trash/studio_blue1.html.erb +108 -0
- data/app/views/wco/api/newsvideos/show.jbuilder +1 -1
- data/app/views/wco/newsvideos/show.haml +2 -2
- data/app/views/wco/office_action_templates/index.haml +1 -1
- data/app/views/wco/office_actions/_actions.haml +1 -1
- data/app/views/wco/publishers/_form.haml +2 -11
- data/app/views/wco/publishers/_post_with.haml +1 -1
- data/app/views/wco/reports/_form.haml +2 -13
- data/app/views/wco/reports/_index.haml +11 -18
- data/app/views/wco/reports/show.haml +1 -6
- data/app/views/wco/sitemap_paths/_index.haml +0 -1
- data/app/views/wco/sitemap_paths/check.haml +13 -0
- data/app/views/wco/sites/index.haml +0 -6
- data/app/views/wco/sites/show.haml +1 -1
- data/app/views/wco/tags/_form.haml +0 -3
- data/config/routes.rb +12 -11
- data/lib/shortcuts.rb +1 -1
- data/lib/wco_models.rb +1 -1
- metadata +28 -24
- data/app/models/wco/publisher_d10.rb +0 -50
- data/app/views/wco/api/newsproducer/README_newsproducer.txt +0 -12
- data/app/views/wco/sitemap_paths/show.haml +0 -14
- /data/app/views/wco/api/newsproducer/{_scenes.js-bk → done/_scenes.js-bk} +0 -0
- /data/app/views/wco/api/newsproducer/{_scenes.js.erb → done/_scenes.js.erb} +0 -0
- /data/app/views/wco/api/newsproducer/{_studio_1.js → done/_studio_1.js} +0 -0
- /data/app/views/wco/api/newsproducer/{_studio_blue0.js → done/_studio_blue0.js} +0 -0
- /data/app/views/wco/api/newsproducer/{_studio_blue1.js → done/_studio_blue1.js} +0 -0
- /data/app/views/wco/api/newsproducer/{_studio_coc.js → done/_studio_coc.js} +0 -0
- /data/app/views/wco/api/newsproducer/{_studio_coc.js-bk → done/_studio_coc.js-bk} +0 -0
- /data/app/views/wco/api/newsproducer/{_studio_coc.js-cannon → done/_studio_coc.js-cannon} +0 -0
- /data/app/views/wco/api/newsproducer/{_studio_ra2.js → done/_studio_ra2.js} +0 -0
- /data/app/views/wco/api/newsproducer/{_touch_controls.js → done/_touch_controls.js} +0 -0
- /data/app/views/wco/api/newsproducer/{_touch_pad.css → done/_touch_pad.css} +0 -0
- /data/app/views/wco/api/newsproducer/{canvas.html.erb → done/canvas.html.erb} +0 -0
- /data/app/views/wco/api/newsproducer/{canvas_minimal.html.erb → done/canvas_minimal.html.erb} +0 -0
- /data/app/views/wco/api/newsproducer/{games_fps.html → done/games_fps.html} +0 -0
- /data/app/views/wco/api/newsproducer/{studio_1.html.erb → done/studio_1.html.erb} +0 -0
- /data/app/views/wco/api/newsproducer/{studio_blue0.html.erb → done/studio_blue0.html.erb} +0 -0
- /data/app/views/wco/api/newsproducer/{studio_blue1.html.erb → done/studio_blue1.html.erb} +0 -0
- /data/app/views/wco/api/newsproducer/{studio_coc.html.erb → done/studio_coc.html.erb} +0 -0
- /data/app/views/wco/api/newsproducer/{studio_ra2.html.erb → done/studio_ra2.html.erb} +0 -0
|
@@ -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')
|