wco_models 3.5.0.1 → 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.
- checksums.yaml +4 -4
- data/app/controllers/wco/api/newspartials_controller.rb +15 -14
- data/app/controllers/wco/newspartials_controller.rb +2 -2
- data/app/controllers/wco/newsvideos_controller.rb +3 -5
- data/app/models/wco/newspartial.rb +23 -8
- data/app/models/wco/newsvideo.rb +4 -3
- data/app/models/wco/utils.rb +19 -0
- data/app/views/wco/api/newsproducer/_studio_blue2.js +195 -286
- data/app/views/wco/api/newsproducer/studio_blue2.html.erb +25 -24
- data/app/views/wco/newspartials/_form.haml +6 -0
- data/app/views/wco/newspartials/_show_in_newsvideo.haml +2 -2
- data/app/views/wco/newsvideos/_form.haml +4 -0
- data/config/routes.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 944e681b8a31afee5ce6e98f68fd1fc54bed6770a7c1568d39057d0f90a3c722
|
|
4
|
+
data.tar.gz: 62a8c729538678a89947c90d5ebee4e9856fe5c363a5fcc06e427e90ce6dab87
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 22ff6dd88163091cd5078c2c807776f84c07f0649a981852fd4385b5c9c4773eb76d9717b67afaf8f4a07862f00c5414b2aecf5ce1868a4381f75f8741b8a70b
|
|
7
|
+
data.tar.gz: 581a5a302dbb5864d4f8bf100268a2af1eddc45737915a72f303e2b52a466f289b97b7f61dc787c8fdb6bc96486fc1abcf38d154314fb9238eb31969df6687e9
|
|
@@ -51,30 +51,31 @@ class Wco::Api::NewspartialsController < Wco::ApiController
|
|
|
51
51
|
render json: { status: :ok }
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
## via puppeteer
|
|
55
|
-
def generate_video
|
|
56
|
-
@newspartial = Wco::Newspartial.unscoped.find params[:id]
|
|
57
|
-
authorize! :create, @newspartial
|
|
58
|
-
@newspartial.generate_video
|
|
59
|
-
|
|
60
|
-
render json: { status: :ok }
|
|
61
|
-
end
|
|
62
|
-
|
|
63
54
|
def show_config
|
|
64
55
|
@newspartial = Wco::Newspartial.find params[:id]
|
|
65
|
-
config =
|
|
56
|
+
config = @newspartial.config
|
|
66
57
|
|
|
67
58
|
# @newsvideo_events = Wco::NewsvideoEvent.where( newsvideo: @newspartial.newsvideo )
|
|
68
|
-
@newsvideo_events
|
|
69
|
-
config[:fns]
|
|
70
|
-
config[:ftimes]
|
|
59
|
+
@newsvideo_events = @newspartial.newsvideo_events
|
|
60
|
+
config[:fns] = @newsvideo_events.map { |ev| ev.exec_js }
|
|
61
|
+
config[:ftimes] = @newsvideo_events.map { |ev| ev.start_at_ms }
|
|
71
62
|
config[:fdurations] = @newsvideo_events.map { |ev| ev.duration_ms }
|
|
72
63
|
|
|
73
64
|
|
|
74
65
|
config[:w_px] = @newspartial.newsvideo.w_px
|
|
75
66
|
config[:h_px] = @newspartial.newsvideo.h_px
|
|
67
|
+
config[:fps] = @newspartial.newsvideo.fps
|
|
76
68
|
config[:slug] = "#{@newspartial.newsvideo.slug}::#{@newspartial.slug}"
|
|
77
|
-
|
|
69
|
+
|
|
70
|
+
config[:generate_video_url] = wco.api_newsproducer_studio_blue_url({
|
|
71
|
+
api_key: Wco::Setting.get('WASYACO_SIMPLE_API_KEY'),
|
|
72
|
+
api_secret: Wco::Setting.get('WASYACO_SIMPLE_API_SECRET'),
|
|
73
|
+
host: Rails.application.routes.default_url_options[:host],
|
|
74
|
+
newspartial_id: @newspartial.id.to_s,
|
|
75
|
+
wco_origin: Rails.application.routes.default_url_options[:host], # request.base_url,
|
|
76
|
+
})
|
|
77
|
+
puts! config, 'ze config'
|
|
78
|
+
render json: JSON.generate(config, ascii_only: false, escape_html_entities: false)
|
|
78
79
|
end
|
|
79
80
|
|
|
80
81
|
end
|
|
@@ -46,8 +46,8 @@ class Wco::NewspartialsController < Wco::ApplicationController
|
|
|
46
46
|
authorize! :edit, @newspartial
|
|
47
47
|
|
|
48
48
|
Rails.env.production? ?
|
|
49
|
-
Wco::NewspartialVideoJob.perform_async(params[:id]) :
|
|
50
|
-
Wco::NewspartialVideoJob.perform_sync(
|
|
49
|
+
Wco::NewspartialVideoJob.perform_async( params[:id]) :
|
|
50
|
+
Wco::NewspartialVideoJob.perform_sync( params[:id])
|
|
51
51
|
|
|
52
52
|
flash_notice 'Scheduled.'
|
|
53
53
|
redirect_to controller: 'newsvideos', id: @newspartial.newsvideo_id, action: 'show'
|
|
@@ -137,11 +137,9 @@ class Wco::NewsvideosController < Wco::ApplicationController
|
|
|
137
137
|
@newsvideo = Wco::Newsvideo.unscoped.find params[:id]
|
|
138
138
|
authorize! :edit, @newsvideo
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
out = `#{cmd}`
|
|
144
|
-
puts! out, 'out'
|
|
140
|
+
@newsvideo.newspartials.each do |np|
|
|
141
|
+
np.generate_video
|
|
142
|
+
end
|
|
145
143
|
|
|
146
144
|
render json: { status: :ok }
|
|
147
145
|
end
|
|
@@ -14,9 +14,10 @@ class Wco::Newspartial
|
|
|
14
14
|
|
|
15
15
|
field :body
|
|
16
16
|
field :config_json, type: :string, default: '{}'
|
|
17
|
-
|
|
17
|
+
## no longer used. config_json has everything, including default scene config, excluding audio data.
|
|
18
|
+
# field :speech_json, type: :string, default: '{}' # the smaller config, excludes audio wav
|
|
18
19
|
|
|
19
|
-
field :voice, type: :string, default: 'af_jessica' ## 'af_jessica', 'am_fenrir'
|
|
20
|
+
field :voice, type: :string, default: 'af_jessica' ## defaults: 'af_jessica', 'am_fenrir'
|
|
20
21
|
|
|
21
22
|
belongs_to :newsvideo
|
|
22
23
|
|
|
@@ -78,9 +79,7 @@ class Wco::Newspartial
|
|
|
78
79
|
'Accept' => 'application/json',
|
|
79
80
|
}, body: {
|
|
80
81
|
input: body,
|
|
81
|
-
|
|
82
82
|
voice: voice,
|
|
83
|
-
|
|
84
83
|
language: "en-us",
|
|
85
84
|
audioEncoding: "wav",
|
|
86
85
|
}.to_json
|
|
@@ -99,12 +98,19 @@ class Wco::Newspartial
|
|
|
99
98
|
self.audio = temp_file
|
|
100
99
|
temp_file.close
|
|
101
100
|
temp_file.unlink
|
|
101
|
+
|
|
102
102
|
tmp.delete('audio')
|
|
103
|
+
tmp.delete('audioEncoding')
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
# puts! Wco::Utils.default_studio_config, 'Wco::Utils.default_studio_config'
|
|
106
|
+
tmp.merge!( Wco::Utils.default_studio_config )
|
|
107
|
+
tmp[:active_camera] = Wco::Utils.default_studio_config.key( Wco::Utils.voice_to_avatar(voice) )
|
|
108
|
+
tmp[:active_spot] = Wco::Utils.default_studio_config.key( Wco::Utils.voice_to_avatar(voice) )
|
|
109
|
+
self[:config_json] = tmp.to_json
|
|
110
|
+
# puts! tmp, 'tmp'
|
|
105
111
|
|
|
106
|
-
self.save
|
|
107
|
-
return
|
|
112
|
+
self.save!
|
|
113
|
+
return tmp
|
|
108
114
|
end
|
|
109
115
|
|
|
110
116
|
##
|
|
@@ -137,11 +143,20 @@ class Wco::Newspartial
|
|
|
137
143
|
puts! out, 'out'
|
|
138
144
|
end
|
|
139
145
|
def generate_video_cmd
|
|
140
|
-
cmd = "cd #{Wco::Setting.get('PUPPETEER_ROOT')} ; NEWSPARTIAL_URL
|
|
146
|
+
cmd = "cd #{Wco::Setting.get('PUPPETEER_ROOT')} ; NEWSPARTIAL_URL='#{generate_video_url}' yarn run run_newspartial_1 "
|
|
141
147
|
puts "+++ puppeteer cmd:"
|
|
142
148
|
puts cmd
|
|
143
149
|
cmd
|
|
144
150
|
end
|
|
151
|
+
def generate_video_url
|
|
152
|
+
newspartial = self
|
|
153
|
+
url = Wco::Engine.routes.url_helpers.api_newspartial_config_url({ id: newspartial.id,
|
|
154
|
+
host: Rails.application.routes.default_url_options[:host],
|
|
155
|
+
wco_origin: Rails.application.routes.default_url_options[:host],
|
|
156
|
+
api_key: Wco::Setting.get('WASYACO_SIMPLE_API_KEY'),
|
|
157
|
+
api_secret: Wco::Setting.get('WASYACO_SIMPLE_API_SECRET'),
|
|
158
|
+
})
|
|
159
|
+
end
|
|
145
160
|
|
|
146
161
|
def video
|
|
147
162
|
Wco::Video.where( newspartial_id: self[:id] ).first
|
data/app/models/wco/newsvideo.rb
CHANGED
|
@@ -25,14 +25,15 @@ class Wco::Newsvideo
|
|
|
25
25
|
field :config_json, type: :string
|
|
26
26
|
field :duration_ms, type: :integer
|
|
27
27
|
|
|
28
|
-
field :w_px, type: Integer
|
|
29
|
-
field :h_px, type: Integer
|
|
28
|
+
field :w_px, type: Integer, default: 854
|
|
29
|
+
field :h_px, type: Integer, default: 480
|
|
30
|
+
field :fps, type: :integer, default: 30
|
|
30
31
|
field :x, :type => Float
|
|
31
32
|
field :y, :type => Float
|
|
32
33
|
field :z, :type => Float
|
|
33
34
|
|
|
34
35
|
field :next_overlay_ms, type: :integer, default: 1000
|
|
35
|
-
|
|
36
|
+
|
|
36
37
|
|
|
37
38
|
belongs_to :generated_video, class_name: 'Wco::Video', optional: true
|
|
38
39
|
|
data/app/models/wco/utils.rb
CHANGED
|
@@ -26,6 +26,25 @@ module Wco::Utils
|
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
def self.voice_to_avatar(which)
|
|
30
|
+
case which
|
|
31
|
+
when 'af_jessica'
|
|
32
|
+
return 'brunette'
|
|
33
|
+
when 'am_fernir'
|
|
34
|
+
return 'denis'
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.default_studio_config
|
|
39
|
+
{ active_camera: 'spot_1',
|
|
40
|
+
active_spot: 'spot_1',
|
|
41
|
+
studio: 'newsroom_green',
|
|
42
|
+
spot_1: 'brunette',
|
|
43
|
+
spot_2: 'denis',
|
|
44
|
+
spot_3: 'eve',
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
|
|
29
48
|
private
|
|
30
49
|
|
|
31
50
|
def set_slug
|
|
@@ -10,46 +10,44 @@ const logg = (a, b="", c=null) => {
|
|
|
10
10
|
console.log(`+++ ${b}:`, a) // eslint-disable-line no-console
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
const MODELS_ROOT = 'https://cdn.jsdelivr.net/gh/wasya-co/ishlib3js@v0.4.14/public/vendor/models'
|
|
14
15
|
const AVATARS_ROOT = `${MODELS_ROOT}/avatars`
|
|
15
|
-
const
|
|
16
|
+
const avatars_config = {
|
|
16
17
|
brunette: { type: 'F', url: `${AVATARS_ROOT}/brunette/model.glb` },
|
|
17
18
|
cara: { type: 'F', url: `${AVATARS_ROOT}/cara/model.glb` }, // short hair
|
|
18
|
-
eve: { type: 'F', url: `${AVATARS_ROOT}/eve/model.glb`
|
|
19
|
+
eve: { type: 'F', url: `${AVATARS_ROOT}/eve/model.glb` }, // poison green
|
|
19
20
|
|
|
20
21
|
denis: { type: 'M', url: `${AVATARS_ROOT}/denis/model.glb` }, // beard
|
|
21
22
|
gregor: { type: 'M', url: `${AVATARS_ROOT}/gregor/model.glb` }, // gray shirt
|
|
22
23
|
}
|
|
23
24
|
const AVATAR_STOR = 'avatar'
|
|
24
|
-
$('select.
|
|
25
|
-
const $
|
|
26
|
-
$.each(
|
|
27
|
-
$('<option>', {
|
|
28
|
-
value: name,
|
|
29
|
-
text: name,
|
|
30
|
-
}).appendTo($select)
|
|
25
|
+
$('select.avatars').each((_idx, el) => {
|
|
26
|
+
const $avatar = $(el)
|
|
27
|
+
$.each(avatars_config, function(name) {
|
|
28
|
+
$('<option>', { value: name, text: name }).appendTo($avatar)
|
|
31
29
|
})
|
|
32
30
|
try {
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
31
|
+
const saved_name = localStorage.getItem(`${AVATAR_STOR}-${$avatar.data('spot_id')}`)
|
|
32
|
+
if (saved_name && avatars_config[saved_name]) $avatar.val(saved_name)
|
|
35
33
|
} catch (error) {
|
|
36
34
|
console.log(error)
|
|
37
35
|
}
|
|
38
36
|
})
|
|
39
37
|
|
|
40
|
-
let
|
|
41
|
-
const
|
|
42
|
-
$.each(
|
|
43
|
-
$('<option>', { value: name, text: name }).appendTo($(
|
|
38
|
+
let studios_config = await fetch(`${MODELS_ROOT}/scenes/index.json`).then(r => r.json())
|
|
39
|
+
const STUDIO_STOR = 'studio'
|
|
40
|
+
$.each(studios_config, (name) => {
|
|
41
|
+
$('<option>', { value: name, text: name }).appendTo($(`select.${STUDIO_STOR}`))
|
|
44
42
|
})
|
|
45
43
|
try {
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
44
|
+
const saved_name = localStorage.getItem( STUDIO_STOR )
|
|
45
|
+
if (saved_name && studios_config[saved_name]) $(`select.${STUDIO_STOR}`).val(saved_name)
|
|
48
46
|
} catch (error) {
|
|
49
47
|
console.log(error)
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
let scene_url =
|
|
50
|
+
let scene_url = studios_config[$(`select.${STUDIO_STOR}`).val()] || studios_config['collision-world']
|
|
53
51
|
|
|
54
52
|
let gestures = {
|
|
55
53
|
talking_1: (avatar) => `${MODELS_ROOT}/animation-library/feminine/fbx/expression/${avatar.body}_Talking_Variations_001.fbx`,
|
|
@@ -68,10 +66,10 @@ $.each(gestures, (name) => {
|
|
|
68
66
|
$('<option>', { value: name, text: name }).appendTo($('select.gestures'))
|
|
69
67
|
})
|
|
70
68
|
|
|
71
|
-
let
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
69
|
+
let spot_positions = {
|
|
70
|
+
'spot_1': [0, 0, 0],
|
|
71
|
+
'spot_2': [1, 0, 0],
|
|
72
|
+
'spot_3': [-1, 0, 0],
|
|
75
73
|
}
|
|
76
74
|
|
|
77
75
|
|
|
@@ -85,78 +83,77 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js'
|
|
|
85
83
|
import { TalkingHead } from "talkinghead"
|
|
86
84
|
|
|
87
85
|
const params = new URLSearchParams(window.location.search)
|
|
86
|
+
const api_key = params.get('api_key')
|
|
87
|
+
const api_secret = params.get('api_secret')
|
|
88
|
+
const wco_origin = params.get('wco_origin')
|
|
89
|
+
const newspartial_id = params.get('newspartial_id')
|
|
88
90
|
|
|
89
|
-
let
|
|
91
|
+
let streamOpts = {
|
|
90
92
|
sampleRate: 8000,
|
|
91
93
|
mood: 'neutral',
|
|
92
94
|
gain: 0.5,
|
|
93
95
|
lipsyncType: "visemes",
|
|
94
96
|
lipsyncLang: "en",
|
|
95
97
|
waitForAudioChunks: false,
|
|
96
|
-
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const onMetrics = (which) => {
|
|
100
|
-
logg(which, 'onMetrics')
|
|
98
|
+
metrics: { enabled: false },
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
const onSubtitles = (which) => {
|
|
104
102
|
logg(which, 'onSubtitles')
|
|
105
103
|
}
|
|
106
|
-
const streamOpts = {
|
|
107
|
-
gain: config.gain,
|
|
108
|
-
lipsyncLang: config.lipsyncLang,
|
|
109
|
-
lipsyncType: config.lipsyncType,
|
|
110
|
-
metrics: config.enableMetrics ? { enabled: true, intervalHz: config.metricsInterval } : { enabled: false },
|
|
111
|
-
mood: config.mood,
|
|
112
|
-
sampleRate: config.sampleRate,
|
|
113
|
-
waitForAudioChunks: config.waitForAudioChunks,
|
|
114
|
-
}
|
|
115
|
-
|
|
116
104
|
|
|
117
105
|
let width = 854
|
|
118
106
|
let height = 480
|
|
119
107
|
let slug = '<ccapture>'
|
|
120
|
-
|
|
108
|
+
let fps = 30
|
|
121
109
|
|
|
122
110
|
let frame = 0
|
|
123
111
|
let lastAnimTime = 0
|
|
124
112
|
let capturing = false
|
|
125
113
|
let captureFrame = 0
|
|
126
114
|
let captureTotal = 0
|
|
127
|
-
const api_key = params.get('api_key')
|
|
128
|
-
const api_secret = params.get('api_secret')
|
|
129
|
-
const wco_origin = params.get('wco_origin')
|
|
130
|
-
const newspartial_id = params.get('newspartial_id')
|
|
131
115
|
let totalFrames
|
|
132
116
|
|
|
133
|
-
let
|
|
117
|
+
let active_camera
|
|
118
|
+
let cameras = {
|
|
119
|
+
wide: {
|
|
120
|
+
cam: null,
|
|
121
|
+
tgt: new THREE.Vector3(0.5, 1.2, 0),
|
|
122
|
+
},
|
|
123
|
+
spot_1: {
|
|
124
|
+
cam: null,
|
|
125
|
+
tgt: new THREE.Vector3(0, 1.5, 0),
|
|
126
|
+
},
|
|
127
|
+
spot_2: {
|
|
128
|
+
cam: null,
|
|
129
|
+
tgt: new THREE.Vector3(1, 1.5, 0),
|
|
130
|
+
},
|
|
131
|
+
spot_3: {
|
|
132
|
+
cam: null,
|
|
133
|
+
tgt: new THREE.Vector3(-1, 1.5, 0),
|
|
134
|
+
},
|
|
135
|
+
}
|
|
134
136
|
let controls, renderer, scene
|
|
135
|
-
let
|
|
136
|
-
let
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
av_2: new THREE.Vector3(1, 1.5, 0),
|
|
141
|
-
av_3: new THREE.Vector3(-1, 1.5, 0),
|
|
137
|
+
let active_avatar
|
|
138
|
+
let avatars = {
|
|
139
|
+
spot_1: null,
|
|
140
|
+
spot_2: null,
|
|
141
|
+
spot_3: null,
|
|
142
142
|
}
|
|
143
|
+
let faceTarget = new THREE.Vector3()
|
|
143
144
|
let cameraTransition = null
|
|
144
145
|
const CAMERA_BLEND_MS = 900
|
|
145
146
|
let chunkedInput = null
|
|
146
147
|
const lights = {}
|
|
147
|
-
const LIGHT_CTRL_KEY = 'wco.studio_blue.light-ctrl'
|
|
148
|
-
const HEAD_CTRL_KEY = 'wco.studio_blue.head-ctrl'
|
|
149
|
-
const CAMERA_CTRL_KEY = 'wco.studio_blue.camera-ctrl'
|
|
150
148
|
var capturer = new CCapture( { format: 'webm', framerate: fps } )
|
|
151
149
|
const gltfLoader = new GLTFLoader()
|
|
152
|
-
const fbxLoader = new FBXLoader()
|
|
153
150
|
const loading = document.getElementById('loading')
|
|
154
|
-
const status
|
|
151
|
+
const status = document.getElementById('status')
|
|
155
152
|
|
|
156
153
|
/*
|
|
157
154
|
**/
|
|
158
155
|
function point_camera_at_face(cam_id, _head) {
|
|
159
|
-
const leftEye
|
|
156
|
+
const leftEye = new THREE.Vector3()
|
|
160
157
|
const rightEye = new THREE.Vector3()
|
|
161
158
|
_head.objectLeftEye.getWorldPosition(leftEye)
|
|
162
159
|
_head.objectRightEye.getWorldPosition(rightEye)
|
|
@@ -165,10 +162,10 @@ function point_camera_at_face(cam_id, _head) {
|
|
|
165
162
|
const camPos = new THREE.Vector3(0, 0, 2)
|
|
166
163
|
camPos.applyQuaternion(_head.armature.quaternion)
|
|
167
164
|
camPos.add(faceTarget)
|
|
168
|
-
const _camera =
|
|
165
|
+
const _camera = cameras[cam_id].cam
|
|
169
166
|
_camera.position.copy(camPos)
|
|
170
167
|
_camera.lookAt(faceTarget)
|
|
171
|
-
|
|
168
|
+
cameras[cam_id].tgt.copy(faceTarget)
|
|
172
169
|
}
|
|
173
170
|
|
|
174
171
|
/*
|
|
@@ -190,19 +187,14 @@ function put_feet_at_origin(_head) {
|
|
|
190
187
|
|
|
191
188
|
/*
|
|
192
189
|
**/
|
|
193
|
-
function rescale(model,
|
|
190
|
+
function rescale(model, _config) {
|
|
194
191
|
const box = new THREE.Box3().setFromObject(model)
|
|
195
192
|
const size = box.getSize(new THREE.Vector3())
|
|
196
193
|
const currentHeight = size.y
|
|
197
|
-
const scale =
|
|
194
|
+
const scale = _config.height / currentHeight
|
|
198
195
|
model.scale.setScalar(scale)
|
|
199
196
|
}
|
|
200
197
|
|
|
201
|
-
function scene_cfg(s) {
|
|
202
|
-
if (typeof s === 'string') return { url: s, height: 3.3 }
|
|
203
|
-
return { url: s.url, height: s.height || 3.3 }
|
|
204
|
-
}
|
|
205
|
-
|
|
206
198
|
function set_shadows(root, cast, receive) {
|
|
207
199
|
root.traverse((obj) => {
|
|
208
200
|
if (obj.isMesh) {
|
|
@@ -243,68 +235,15 @@ function setup_light(scene) {
|
|
|
243
235
|
lights.rimLight.position.set( 0, 6, -8 )
|
|
244
236
|
scene.add( lights.rimLight )
|
|
245
237
|
|
|
246
|
-
restoreLightControls()
|
|
247
238
|
syncLightsFromControls()
|
|
248
239
|
}
|
|
249
240
|
|
|
250
|
-
function restoreLightControls() {
|
|
251
|
-
try {
|
|
252
|
-
const saved = JSON.parse(localStorage.getItem(LIGHT_CTRL_KEY) || 'null')
|
|
253
|
-
if (!saved || typeof saved !== 'object') return
|
|
254
|
-
document.querySelectorAll('input.light-ctrl').forEach((input) => {
|
|
255
|
-
if (Object.prototype.hasOwnProperty.call(saved, input.name)) {
|
|
256
|
-
input.checked = !!saved[input.name]
|
|
257
|
-
}
|
|
258
|
-
})
|
|
259
|
-
} catch (error) {
|
|
260
|
-
console.log(error)
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function persistLightControls() {
|
|
265
|
-
const saved = {}
|
|
266
|
-
document.querySelectorAll('input.light-ctrl').forEach((input) => {
|
|
267
|
-
saved[input.name] = input.checked
|
|
268
|
-
})
|
|
269
|
-
localStorage.setItem(LIGHT_CTRL_KEY, JSON.stringify(saved))
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function restoreHeadControl() {
|
|
273
|
-
try {
|
|
274
|
-
const saved = localStorage.getItem(HEAD_CTRL_KEY)
|
|
275
|
-
if (!saved) return
|
|
276
|
-
const input = document.querySelector(`input[name=head][value="${saved}"]`)
|
|
277
|
-
if (input) input.checked = true
|
|
278
|
-
} catch (error) {
|
|
279
|
-
console.log(error)
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function persistHeadControl(id) {
|
|
284
|
-
localStorage.setItem(HEAD_CTRL_KEY, String(id))
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function restoreCameraControl() {
|
|
288
|
-
try {
|
|
289
|
-
const saved = localStorage.getItem(CAMERA_CTRL_KEY)
|
|
290
|
-
if (!saved) return
|
|
291
|
-
const input = document.querySelector(`input[name=camera][value="${saved}"]`)
|
|
292
|
-
if (input) input.checked = true
|
|
293
|
-
} catch (error) {
|
|
294
|
-
console.log(error)
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function persistCameraControl(id) {
|
|
299
|
-
localStorage.setItem(CAMERA_CTRL_KEY, String(id))
|
|
300
|
-
}
|
|
301
241
|
|
|
302
242
|
function syncLightsFromControls() {
|
|
303
243
|
document.querySelectorAll('input.light-ctrl').forEach((input) => {
|
|
304
244
|
const light = lights[input.name]
|
|
305
245
|
if (light) light.visible = input.checked
|
|
306
246
|
})
|
|
307
|
-
persistLightControls()
|
|
308
247
|
}
|
|
309
248
|
|
|
310
249
|
function sync_shadows() {
|
|
@@ -328,36 +267,33 @@ function update_walk(this_head, dt) {
|
|
|
328
267
|
this_head.armature.position.addScaledVector(dir, this_head.speed * dt / 1000)
|
|
329
268
|
}
|
|
330
269
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
270
|
+
function play_animation(props) {
|
|
271
|
+
logg(props, 'play_animation()')
|
|
272
|
+
let this_head = avatars[props.spot_id]
|
|
273
|
+
if (this_head) this_head.playAnimation(geastures[props.animation_name](props))
|
|
274
|
+
}
|
|
336
275
|
|
|
337
276
|
function cut_to(key) {
|
|
338
|
-
const radio = document.querySelector(`input[name=
|
|
277
|
+
const radio = document.querySelector(`input[name=active_camera][value="${key}"]`)
|
|
339
278
|
if (radio) radio.checked = true
|
|
340
279
|
setActiveCamera(key, true)
|
|
341
280
|
}
|
|
342
281
|
|
|
343
|
-
function move_camera(
|
|
344
|
-
const fromKey = String(
|
|
345
|
-
const toKey = String(
|
|
346
|
-
const duration = Number(
|
|
347
|
-
const src =
|
|
348
|
-
const dest =
|
|
282
|
+
function move_camera(props) {
|
|
283
|
+
const fromKey = String(props.from)
|
|
284
|
+
const toKey = String(props.to)
|
|
285
|
+
const duration = Number(props.duration) > 0 ? Number(props.duration) : CAMERA_BLEND_MS
|
|
286
|
+
const src = cameras[fromKey].cam
|
|
287
|
+
const dest = cameras[toKey].cam
|
|
349
288
|
const startTarget = (cameraTargets[fromKey] || cameraTargets.wide).clone()
|
|
350
289
|
const destTarget = (cameraTargets[toKey] || cameraTargets.wide).clone()
|
|
351
290
|
|
|
352
|
-
persistCameraControl(toKey)
|
|
353
291
|
const radio = document.querySelector(`input[name=camera][value="${toKey}"]`)
|
|
354
292
|
if (radio) radio.checked = true
|
|
355
293
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
cam.updateProjectionMatrix()
|
|
360
|
-
}
|
|
294
|
+
Object.entries(cameras).forEach(([key, value]) => {
|
|
295
|
+
value.cam.aspect = width / height
|
|
296
|
+
value.cam.updateProjectionMatrix()
|
|
361
297
|
})
|
|
362
298
|
|
|
363
299
|
src.updateMatrixWorld()
|
|
@@ -389,7 +325,7 @@ function move_camera(config) {
|
|
|
389
325
|
}
|
|
390
326
|
}
|
|
391
327
|
|
|
392
|
-
|
|
328
|
+
window.play_animation = play_animation
|
|
393
329
|
window.move_camera = move_camera
|
|
394
330
|
window.cut_to = cut_to
|
|
395
331
|
|
|
@@ -404,7 +340,15 @@ function tickEvents(elapsedMs) {
|
|
|
404
340
|
}
|
|
405
341
|
}
|
|
406
342
|
|
|
407
|
-
|
|
343
|
+
let studio
|
|
344
|
+
async function load_studio(cfg) {
|
|
345
|
+
logg(cfg, 'load_studio()')
|
|
346
|
+
if (studio && studio.parent) studio.parent.remove(studio)
|
|
347
|
+
studio = (await gltfLoader.loadAsync(`${cfg.path}/scene.glb`)).scene
|
|
348
|
+
rescale(studio, { height: cfg.height })
|
|
349
|
+
set_shadows(studio, false, true)
|
|
350
|
+
scene.add(studio)
|
|
351
|
+
}
|
|
408
352
|
|
|
409
353
|
/*
|
|
410
354
|
**/
|
|
@@ -413,7 +357,7 @@ async function init() {
|
|
|
413
357
|
|
|
414
358
|
if (newspartial_id) {
|
|
415
359
|
try {
|
|
416
|
-
const url = wco_origin + '/wco/api/newspartials/' + newspartial_id + '/config.json?api_key=' + api_key + '&api_secret=' + api_secret
|
|
360
|
+
const url = 'https://' + wco_origin + '/wco/api/newspartials/' + newspartial_id + '/config.json?api_key=' + api_key + '&api_secret=' + api_secret
|
|
417
361
|
chunkedInput = await fetch(url).then(r => r.json())
|
|
418
362
|
logg(chunkedInput, 'chunkedInput')
|
|
419
363
|
|
|
@@ -429,6 +373,19 @@ async function init() {
|
|
|
429
373
|
totalFrames = undefined
|
|
430
374
|
}
|
|
431
375
|
}
|
|
376
|
+
if (chunkedInput.studio) {
|
|
377
|
+
$(`select.${STUDIO_STOR}`).val(chunkedInput.studio)
|
|
378
|
+
load_studio(studios_config[chunkedInput.studio])
|
|
379
|
+
}
|
|
380
|
+
if (chunkedInput.spot_1) {
|
|
381
|
+
$('select.avatars[data-spot_id="spot_1"]').val(chunkedInput.spot_1)
|
|
382
|
+
}
|
|
383
|
+
if (chunkedInput.spot_2) {
|
|
384
|
+
$('select.avatars[data-spot_id="spot_2"]').val(chunkedInput.spot_2)
|
|
385
|
+
}
|
|
386
|
+
if (chunkedInput.spot_3) {
|
|
387
|
+
$('select.avatars[data-spot_id="spot_3"]').val(chunkedInput.spot_3)
|
|
388
|
+
}
|
|
432
389
|
|
|
433
390
|
scene = new THREE.Scene()
|
|
434
391
|
scene.background = new THREE.Color(0x333333) // new THREE.Color(0xd3d3d3)
|
|
@@ -438,6 +395,8 @@ async function init() {
|
|
|
438
395
|
* near — Camera frustum near plane.
|
|
439
396
|
* far — Camera frustum far plane.
|
|
440
397
|
**/
|
|
398
|
+
let camera_1, camera_2, camera_3, camera_wide
|
|
399
|
+
|
|
441
400
|
camera_1 = new THREE.PerspectiveCamera( 10, width/height, 0.1, 1000 )
|
|
442
401
|
camera_1.position.set( 0, 1.6, 4 )
|
|
443
402
|
camera_1.lookAt( 0, 1.5, 0 )
|
|
@@ -454,11 +413,16 @@ async function init() {
|
|
|
454
413
|
camera_wide.position.set( -2, 2.2, 8 )
|
|
455
414
|
camera_wide.lookAt( 0.5, 1.2, 0 )
|
|
456
415
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
416
|
+
cameras.wide.cam = camera_wide
|
|
417
|
+
cameras.spot_1.cam = camera_1
|
|
418
|
+
cameras.spot_2.cam = camera_2
|
|
419
|
+
cameras.spot_3.cam = camera_3
|
|
420
|
+
|
|
421
|
+
active_camera = new THREE.PerspectiveCamera( 10, width/height, 0.1, 1000 )
|
|
422
|
+
active_camera.position.copy( camera_wide.position )
|
|
423
|
+
active_camera.quaternion.copy( camera_wide.quaternion )
|
|
424
|
+
active_camera.fov = camera_wide.fov
|
|
425
|
+
active_camera.updateProjectionMatrix()
|
|
462
426
|
|
|
463
427
|
setup_light(scene)
|
|
464
428
|
|
|
@@ -466,22 +430,12 @@ async function init() {
|
|
|
466
430
|
grid.position.y = 0
|
|
467
431
|
scene.add(grid)
|
|
468
432
|
|
|
469
|
-
|
|
470
|
-
let studio
|
|
471
|
-
async function load_studio(cfg) {
|
|
472
|
-
logg(cfg, 'load_studio()')
|
|
473
|
-
if (studio && studio.parent) studio.parent.remove(studio)
|
|
474
|
-
studio = (await gltfLoader.loadAsync(`${cfg.path}/scene.glb`)).scene
|
|
475
|
-
rescale(studio, { height: cfg.height })
|
|
476
|
-
set_shadows(studio, false, true)
|
|
477
|
-
scene.add(studio)
|
|
478
|
-
}
|
|
479
433
|
await load_studio(scene_url)
|
|
480
|
-
$(
|
|
434
|
+
$(`select.${STUDIO_STOR}`).on('change', async function() {
|
|
481
435
|
const name = $(this).val()
|
|
482
|
-
if (!
|
|
483
|
-
localStorage.setItem(
|
|
484
|
-
scene_url =
|
|
436
|
+
if (!studios_config[name]) return
|
|
437
|
+
localStorage.setItem(STUDIO_STOR, name)
|
|
438
|
+
scene_url = studios_config[name]
|
|
485
439
|
loading.textContent = 'Loading...'
|
|
486
440
|
try {
|
|
487
441
|
await load_studio(scene_url)
|
|
@@ -493,13 +447,7 @@ async function init() {
|
|
|
493
447
|
})
|
|
494
448
|
|
|
495
449
|
|
|
496
|
-
|
|
497
|
-
// avatarOnly: true,
|
|
498
|
-
// avatarOnlyScene: scene,
|
|
499
|
-
// avatarOnlyCamera: camera,
|
|
500
|
-
// lipsyncModules: ["en"],
|
|
501
|
-
// dracoEnabled: true,
|
|
502
|
-
// })
|
|
450
|
+
let head_1, head_2, head_3
|
|
503
451
|
head_1 = new TalkingHead( document.getElementById('avatar_1'), {
|
|
504
452
|
avatarOnly: true,
|
|
505
453
|
avatarOnlyScene: scene,
|
|
@@ -521,47 +469,47 @@ async function init() {
|
|
|
521
469
|
lipsyncModules: ["en"],
|
|
522
470
|
dracoEnabled: true,
|
|
523
471
|
})
|
|
472
|
+
avatars.spot_1 = head_1
|
|
473
|
+
avatars.spot_2 = head_2
|
|
474
|
+
avatars.spot_3 = head_3
|
|
524
475
|
|
|
525
476
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
if (
|
|
534
|
-
|
|
535
|
-
const avatar = avatars[val]
|
|
536
|
-
if (!avatar || !avatar.url) return
|
|
477
|
+
$('select.avatars').on('change', async function() {
|
|
478
|
+
const spot_id = $(this).data('spot_id')
|
|
479
|
+
const name = $(this).val()
|
|
480
|
+
if (!name) return; // empty spot
|
|
481
|
+
const thisAvatar = avatars[spot_id]
|
|
482
|
+
localStorage.setItem(`${AVATAR_STOR}-${spot_id}`, name)
|
|
483
|
+
if (!thisAvatar) return
|
|
484
|
+
if (thisAvatar.armature && thisAvatar.armature.parent) thisAvatar.armature.parent.remove(thisAvatar.armature)
|
|
485
|
+
const avatar_config = avatars_config[name]
|
|
537
486
|
loading.textContent = 'Loading...'
|
|
538
487
|
try {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
body: avatar.type,
|
|
488
|
+
await thisAvatar.showAvatar({
|
|
489
|
+
url: avatar_config.url,
|
|
490
|
+
body: avatar_config.type,
|
|
543
491
|
avatarMood: 'neutral',
|
|
544
492
|
lipsyncLang: 'en'
|
|
545
493
|
}, (ev) => {
|
|
546
494
|
if ( ev.lengthComputable ) {
|
|
547
|
-
let
|
|
548
|
-
loading.textContent =
|
|
495
|
+
let percent = Math.min(100,Math.round(ev.loaded/ev.total * 100 ))
|
|
496
|
+
loading.textContent = `Loading ${percent}%`
|
|
549
497
|
}
|
|
550
498
|
})
|
|
551
|
-
|
|
552
|
-
set_shadows(
|
|
553
|
-
scene.add(
|
|
554
|
-
put_feet_at_origin(
|
|
555
|
-
|
|
556
|
-
point_camera_at_face(
|
|
557
|
-
await
|
|
499
|
+
thisAvatar.armature.rotation.set(0, 0, 0)
|
|
500
|
+
set_shadows(thisAvatar.armature, true, false)
|
|
501
|
+
scene.add(thisAvatar.armature)
|
|
502
|
+
put_feet_at_origin(thisAvatar)
|
|
503
|
+
thisAvatar.armature.position.add(new THREE.Vector3(...spot_positions[spot_id]))
|
|
504
|
+
point_camera_at_face(spot_id, thisAvatar)
|
|
505
|
+
await thisAvatar.streamStart(streamOpts, () => {}, () => {}, onSubtitles)
|
|
558
506
|
loading.textContent = 'loaded'
|
|
559
507
|
} catch (error) {
|
|
560
508
|
console.log(error)
|
|
561
509
|
loading.textContent = error.toString()
|
|
562
510
|
}
|
|
563
511
|
})
|
|
564
|
-
$('select.
|
|
512
|
+
$('select.avatars').trigger('change')
|
|
565
513
|
|
|
566
514
|
|
|
567
515
|
|
|
@@ -583,7 +531,7 @@ async function init() {
|
|
|
583
531
|
|
|
584
532
|
//
|
|
585
533
|
|
|
586
|
-
controls = new OrbitControls(
|
|
534
|
+
controls = new OrbitControls( active_camera, renderer.domElement )
|
|
587
535
|
controls.enableDamping = true
|
|
588
536
|
controls.enableRotate = true
|
|
589
537
|
controls.enablePan = true
|
|
@@ -594,25 +542,31 @@ async function init() {
|
|
|
594
542
|
controls.autoRotate = false
|
|
595
543
|
controls.update()
|
|
596
544
|
|
|
597
|
-
|
|
598
|
-
document.querySelectorAll('input[name=head]').forEach((input) => {
|
|
545
|
+
document.querySelectorAll('input[name=active_spot]').forEach((input) => {
|
|
599
546
|
input.addEventListener('change', () => {
|
|
600
547
|
if (!input.checked) return
|
|
601
|
-
|
|
548
|
+
active_avatar = avatars[input.value]
|
|
602
549
|
})
|
|
550
|
+
if (chunkedInput.active_spot && input.value === chunkedInput.active_spot) {
|
|
551
|
+
input.checked = true
|
|
552
|
+
}
|
|
603
553
|
})
|
|
604
|
-
const
|
|
605
|
-
|
|
554
|
+
const active_spot = document.querySelector('input[name=active_spot]:checked')
|
|
555
|
+
if (active_spot) {
|
|
556
|
+
active_avatar = avatars[active_spot.value]
|
|
557
|
+
}
|
|
606
558
|
|
|
607
|
-
|
|
608
|
-
document.querySelectorAll('input[name=camera]').forEach((input) => {
|
|
559
|
+
document.querySelectorAll('input[name=active_camera]').forEach((input) => {
|
|
609
560
|
input.addEventListener('change', () => {
|
|
610
561
|
if (!input.checked) return
|
|
611
562
|
setActiveCamera(input.value)
|
|
612
563
|
})
|
|
564
|
+
if (chunkedInput.active_camera && input.value === chunkedInput.active_camera) {
|
|
565
|
+
input.checked = true
|
|
566
|
+
}
|
|
613
567
|
})
|
|
614
|
-
const selected = document.querySelector('input[name=
|
|
615
|
-
|
|
568
|
+
const selected = document.querySelector('input[name=active_camera]:checked')
|
|
569
|
+
if (selected.value) setActiveCamera(selected.value, true)
|
|
616
570
|
|
|
617
571
|
document.querySelectorAll('input.light-ctrl').forEach((input) => {
|
|
618
572
|
input.addEventListener('change', syncLightsFromControls)
|
|
@@ -646,72 +600,31 @@ if (document.readyState === 'loading') {
|
|
|
646
600
|
init()
|
|
647
601
|
}
|
|
648
602
|
|
|
649
|
-
function cameras_fn(which) {
|
|
650
|
-
switch (which) {
|
|
651
|
-
case 'wide':
|
|
652
|
-
return camera_wide
|
|
653
|
-
case 'av_1':
|
|
654
|
-
return camera_1
|
|
655
|
-
case 'av_2':
|
|
656
|
-
return camera_2
|
|
657
|
-
case 'av_3':
|
|
658
|
-
return camera_3
|
|
659
|
-
default:
|
|
660
|
-
logg('fpq - cameras_fn default - this should never happen')
|
|
661
|
-
return camera_wide
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
function heads_fn(which) {
|
|
666
|
-
switch (which) {
|
|
667
|
-
case '1':
|
|
668
|
-
return head_1
|
|
669
|
-
break;
|
|
670
|
-
case '2':
|
|
671
|
-
return head_2
|
|
672
|
-
break;
|
|
673
|
-
case '3':
|
|
674
|
-
return head_3
|
|
675
|
-
break;
|
|
676
|
-
default:
|
|
677
|
-
logg('fpp - heads_fn default - this should never happen')
|
|
678
|
-
return head_1
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
function setActiveHead(id) {
|
|
683
|
-
head = heads_fn(id)
|
|
684
|
-
persistHeadControl(id)
|
|
685
|
-
}
|
|
686
603
|
|
|
687
604
|
function easeInOutCubic(t) {
|
|
688
605
|
return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2
|
|
689
606
|
}
|
|
690
607
|
|
|
691
|
-
function setActiveCamera(
|
|
692
|
-
const
|
|
693
|
-
|
|
694
|
-
const dest = cameras_fn(key)
|
|
695
|
-
const destTarget = (cameraTargets[key] || cameraTargets.wide).clone()
|
|
696
|
-
;[camera_wide, camera_1, camera_2, camera_3, camera].forEach((cam) => {
|
|
697
|
-
if (cam) {
|
|
698
|
-
cam.aspect = width / height
|
|
699
|
-
cam.updateProjectionMatrix()
|
|
700
|
-
}
|
|
701
|
-
})
|
|
608
|
+
function setActiveCamera(key, instant = false) {
|
|
609
|
+
const dest = cameras[key].cam
|
|
610
|
+
const destTarget = cameras[key].tgt.clone()
|
|
702
611
|
|
|
612
|
+
Object.entries(cameras).forEach(([key, value]) => {
|
|
613
|
+
value.cam.aspect = width / height
|
|
614
|
+
value.cam.updateProjectionMatrix()
|
|
615
|
+
})
|
|
703
616
|
dest.updateMatrixWorld()
|
|
704
617
|
|
|
705
|
-
const endPos
|
|
618
|
+
const endPos = dest.position.clone()
|
|
706
619
|
const endQuat = dest.quaternion.clone()
|
|
707
620
|
|
|
708
621
|
if (instant || !controls) {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
622
|
+
active_camera.position.copy(endPos)
|
|
623
|
+
active_camera.quaternion.copy(endQuat)
|
|
624
|
+
active_camera.fov = dest.fov
|
|
625
|
+
active_camera.near = dest.near
|
|
626
|
+
active_camera.far = dest.far
|
|
627
|
+
active_camera.updateProjectionMatrix()
|
|
715
628
|
faceTarget.copy(destTarget)
|
|
716
629
|
if (controls) {
|
|
717
630
|
controls.target.copy(destTarget)
|
|
@@ -722,9 +635,9 @@ function setActiveCamera(id, instant = false) {
|
|
|
722
635
|
}
|
|
723
636
|
|
|
724
637
|
cameraTransition = {
|
|
725
|
-
startPos:
|
|
726
|
-
startQuat:
|
|
727
|
-
startFov:
|
|
638
|
+
startPos: active_camera.position.clone(),
|
|
639
|
+
startQuat: active_camera.quaternion.clone(),
|
|
640
|
+
startFov: active_camera.fov,
|
|
728
641
|
startTarget: controls.target.clone(),
|
|
729
642
|
endPos: endPos,
|
|
730
643
|
endQuat: endQuat,
|
|
@@ -742,10 +655,10 @@ function updateCameraTransition(dt) {
|
|
|
742
655
|
const u = Math.min(1, cameraTransition.elapsed / cameraTransition.duration)
|
|
743
656
|
const e = easeInOutCubic(u)
|
|
744
657
|
const tr = cameraTransition
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
658
|
+
active_camera.position.lerpVectors(tr.startPos, tr.endPos, e)
|
|
659
|
+
active_camera.quaternion.slerpQuaternions(tr.startQuat, tr.endQuat, e)
|
|
660
|
+
active_camera.fov = tr.startFov + (tr.endFov - tr.startFov) * e
|
|
661
|
+
active_camera.updateProjectionMatrix()
|
|
749
662
|
if (controls) {
|
|
750
663
|
controls.target.lerpVectors(tr.startTarget, tr.endTarget, e)
|
|
751
664
|
faceTarget.copy(controls.target)
|
|
@@ -762,18 +675,16 @@ function updateCameraTransition(dt) {
|
|
|
762
675
|
}
|
|
763
676
|
|
|
764
677
|
function onWindowResize() {
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
cam.updateProjectionMatrix()
|
|
769
|
-
}
|
|
678
|
+
Object.entries(cameras).forEach(([key, value]) => {
|
|
679
|
+
value.cam.aspect = width / height
|
|
680
|
+
value.cam.updateProjectionMatrix()
|
|
770
681
|
})
|
|
771
682
|
renderer.setSize( width, height )
|
|
772
683
|
render()
|
|
773
684
|
}
|
|
774
685
|
|
|
775
686
|
function render() {
|
|
776
|
-
renderer.render( scene,
|
|
687
|
+
renderer.render( scene, active_camera )
|
|
777
688
|
}
|
|
778
689
|
|
|
779
690
|
function animate() {
|
|
@@ -789,15 +700,13 @@ function animate() {
|
|
|
789
700
|
|
|
790
701
|
if (capturing) tickEvents(captureFrame * dt)
|
|
791
702
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
update_walk(head_2, dt)
|
|
797
|
-
update_walk(head_3, dt)
|
|
703
|
+
Object.entries(avatars).forEach(([name, _avatar]) => {
|
|
704
|
+
_avatar.animate(dt)
|
|
705
|
+
update_walk(_avatar, dt)
|
|
706
|
+
})
|
|
798
707
|
updateCameraTransition(dt)
|
|
799
708
|
if (!cameraTransition && !capturing) controls.update()
|
|
800
|
-
renderer.render( scene,
|
|
709
|
+
renderer.render( scene, active_camera )
|
|
801
710
|
|
|
802
711
|
if (capturing) {
|
|
803
712
|
capturer.capture( renderer.domElement )
|
|
@@ -810,8 +719,9 @@ function animate() {
|
|
|
810
719
|
|
|
811
720
|
async function startSpeakCapture() {
|
|
812
721
|
if (capturing) return
|
|
813
|
-
if (!
|
|
722
|
+
if (!active_avatar) return
|
|
814
723
|
if (!chunkedInput) return
|
|
724
|
+
logg(null, 'startSpeakCapture()')
|
|
815
725
|
|
|
816
726
|
const last = chunkedInput.wtimes.length - 1
|
|
817
727
|
const duration_ms = chunkedInput.wtimes[last] + chunkedInput.wdurations[last]
|
|
@@ -826,7 +736,7 @@ async function startSpeakCapture() {
|
|
|
826
736
|
capturer.start()
|
|
827
737
|
logg('capturer.start')
|
|
828
738
|
status.textContent = 'capturing'
|
|
829
|
-
|
|
739
|
+
active_avatar.streamAudio(chunkedInput)
|
|
830
740
|
}
|
|
831
741
|
|
|
832
742
|
function finishCapture() {
|
|
@@ -846,9 +756,8 @@ function finishCapture() {
|
|
|
846
756
|
form.append('thumb', thumb)
|
|
847
757
|
if (newspartial_id) form.append('newspartial_id', newspartial_id)
|
|
848
758
|
|
|
849
|
-
const url = wco_origin
|
|
850
|
-
|
|
851
|
-
: '/wco/api/videos/'
|
|
759
|
+
const url = 'https://' + wco_origin + '/wco/api/videos/?api_key=' + api_key + '&api_secret=' + api_secret
|
|
760
|
+
|
|
852
761
|
fetch(url, {
|
|
853
762
|
method: 'POST',
|
|
854
763
|
body: form,
|
|
@@ -877,12 +786,12 @@ $('#speak').on('click', async () => {
|
|
|
877
786
|
|
|
878
787
|
$('#jesture').on('click', async () => {
|
|
879
788
|
try {
|
|
880
|
-
if (!
|
|
789
|
+
if (!active_avatar) return
|
|
881
790
|
const name = $('select.gestures').val()
|
|
882
791
|
const g = gestures[name]
|
|
883
|
-
const _anim = gesture_url(g,
|
|
884
|
-
|
|
885
|
-
|
|
792
|
+
const _anim = gesture_url(g, active_avatar.avatar)
|
|
793
|
+
active_avatar.speed = (g && typeof g === 'object' && g.speed) ? g.speed : 0
|
|
794
|
+
active_avatar.playAnimation( _anim )
|
|
886
795
|
} catch (error) {
|
|
887
796
|
console.log(error)
|
|
888
797
|
}
|
|
@@ -33,29 +33,30 @@
|
|
|
33
33
|
<div class='StudioW1'>
|
|
34
34
|
<div class='StudioW0'>
|
|
35
35
|
|
|
36
|
-
<div class='d-flex ctrl-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
|
-
|
|
42
|
+
|
|
43
|
+
<div class='active_spot d-flex ctrl-row'>
|
|
43
44
|
<div class='item'>
|
|
44
45
|
<label>
|
|
45
|
-
<input type="radio" name="
|
|
46
|
-
|
|
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="
|
|
52
|
-
|
|
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="
|
|
58
|
-
|
|
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
|
|
79
|
+
<div class='avatars d-flex ctrl-row'>
|
|
79
80
|
<div class='item'>
|
|
80
|
-
|
|
81
|
-
<select class='
|
|
81
|
+
spot 1
|
|
82
|
+
<select class='avatars' data-spot_id="spot_1" ><option></option></select>
|
|
82
83
|
</div>
|
|
83
84
|
<div class='item'>
|
|
84
|
-
|
|
85
|
-
<select class='
|
|
85
|
+
spot 2
|
|
86
|
+
<select class='avatars' data-spot_id='spot_2' ><option></option></select>
|
|
86
87
|
</div>
|
|
87
88
|
<div class='item'>
|
|
88
|
-
|
|
89
|
-
<select class='
|
|
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
|
|
94
|
+
<div class='active_camera d-flex ctrl-row'>
|
|
94
95
|
<label>
|
|
95
|
-
<input type="radio" name="
|
|
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="
|
|
100
|
-
|
|
100
|
+
<input type="radio" name="active_camera" value="spot_1">
|
|
101
|
+
spot 1
|
|
101
102
|
</label>
|
|
102
103
|
<label>
|
|
103
|
-
<input type="radio" name="
|
|
104
|
-
|
|
104
|
+
<input type="radio" name="active_camera" value="spot_2">
|
|
105
|
+
spot 2
|
|
105
106
|
</label>
|
|
106
107
|
<label>
|
|
107
|
-
<input type="radio" name="
|
|
108
|
-
|
|
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
|
|
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,6 +14,12 @@
|
|
|
14
14
|
%label Body
|
|
15
15
|
= f.text_area :body, class: 'tinymce'
|
|
16
16
|
|
|
17
|
+
.row
|
|
18
|
+
.col-12
|
|
19
|
+
.field
|
|
20
|
+
%label config_json
|
|
21
|
+
= f.text_area :config_json
|
|
22
|
+
|
|
17
23
|
.field
|
|
18
24
|
%label Newsvideo:
|
|
19
25
|
= f.select :newsvideo_id, options_for_select(@newsvideos_list, selected: newspartial.newsvideo_id || params[:newsvideo_id] ), {}, {}
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
|
|
32
32
|
-# = link_to 'Generate video 1', api_newsproducer_studio_1_path({ newspartial_id: newspartial.id.to_s, wco_origin: request.base_url, api_key: Wco::Setting.get('WASYACO_SIMPLE_API_KEY'), api_secret: Wco::Setting.get('WASYACO_SIMPLE_API_SECRET') }), target: :_blank, class: 'btn btn-primary', data: { confirm: 'Are you sure?' }
|
|
33
33
|
-# = link_to 'Generate video green', api_newsproducer_studio_green_path({ newspartial_id: newspartial.id.to_s, wco_origin: request.base_url, api_key: Wco::Setting.get('WASYACO_SIMPLE_API_KEY'), api_secret: Wco::Setting.get('WASYACO_SIMPLE_API_SECRET') }), target: :_blank, class: 'btn btn-primary', data: { confirm: 'Are you sure?' }
|
|
34
|
-
= link_to '_blue 2', api_newsproducer_studio_blue_path({ newspartial_id: newspartial.id.to_s, wco_origin:
|
|
35
|
-
|
|
34
|
+
= link_to '_blue 2', api_newsproducer_studio_blue_path({ newspartial_id: newspartial.id.to_s, wco_origin: Rails.application.routes.default_url_options[:host], api_key: Wco::Setting.get('WASYACO_SIMPLE_API_KEY'), api_secret: Wco::Setting.get('WASYACO_SIMPLE_API_SECRET') }), target: :_blank, class: 'btn btn-primary' # , data: { confirm: 'Are you sure?' }
|
|
35
|
+
= button_to 'generate video', newspartial_generate_video_path( newspartial )
|
|
36
36
|
Video:
|
|
37
37
|
- if newspartial.video
|
|
38
38
|
= image_tag newspartial.video.thumb.url(:thumb), class: 'thumb'
|
data/config/routes.rb
CHANGED
|
@@ -17,7 +17,7 @@ Wco::Engine.routes.draw do
|
|
|
17
17
|
patch 'reports/:id/add-config', to: 'reports#add_config'
|
|
18
18
|
get 'newspartials/:id/config', to: 'newspartials#show_config', as: :newspartial_config
|
|
19
19
|
match 'newspartials/:id/generate-speech', to: 'newspartials#generate_speech', as: :newspartial_generate_speech, via: [ :get, :post ]
|
|
20
|
-
match 'newspartials/:id/generate-video', to: 'newspartials#generate_video',
|
|
20
|
+
match 'newspartials/:id/generate-video', to: 'newspartials#generate_video', as: :newspartial_generate_video, via: [ :get, :post ]
|
|
21
21
|
|
|
22
22
|
get 'newsproducer/canvas', to: 'newsproducer#canvas'
|
|
23
23
|
get 'newsproducer/canvas_minimal', to: 'newsproducer#canvas_minimal'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wco_models
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.5.0.
|
|
4
|
+
version: 3.5.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Victor Pudeyev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: aws-sdk-s3
|